diff --git a/.cursor/rules/cmake-target-design.mdc b/.cursor/rules/cmake-target-design.mdc new file mode 100644 index 0000000..6331a34 --- /dev/null +++ b/.cursor/rules/cmake-target-design.mdc @@ -0,0 +1,71 @@ +--- +description: CMake target-based design conventions for OVR (no catchall include paths, no self-referencing link lists) +globs: **/CMakeLists.txt,**/*.cmake +alwaysApply: false +--- + +# CMake target-based design + +OVR's build is target-driven: every dependency should expose a CMake target +that carries its own include directories, compile definitions, sources, and +link dependencies. Avoid broad include shims such as `${repo}/extern`. + +## No catchall `extern/` include paths + +```cmake +# BAD - sweeping include path that resolves to whatever happens to +# live under extern/X/. Order-dependent, fragile when deps overlap (e.g. +# both tinygltf and stb bundle stb_image.h). +target_include_directories(rendercommon PUBLIC + $ +) + +# GOOD - each external dep owns its include path on its own target. +# Consumers link the target; the include path propagates. +target_link_libraries(rendercommon + PUBLIC tfnmodule # carries + PRIVATE stb tinyexr # carry , +) +``` + +## Header layout mirrors include style + +When a local helper target is consumed via ``, mirror that in the +filesystem so the target's own dir is the include root. Avoid `..` traversal in +INTERFACE include directories. + +``` +extern/glfwapp/ +├── CMakeLists.txt ← exposes ${CMAKE_CURRENT_LIST_DIR} as PUBLIC include +└── glfwapp/ ← matches the include prefix + ├── GLFWApp.h + └── camera_frame.h +``` + +## Don't put a target in a list it itself consumes + +```cmake +# BAD - glfwApp PUBLIC-links ${GFX_LIBRARIES}, which contains glfwApp. +# Self-referencing list, also forces imgui (also in GFX_LIBRARIES) to link +# its own consumer. +list(APPEND GFX_LIBRARIES glfwApp) +target_link_libraries(glfwApp PUBLIC ${GFX_LIBRARIES}) + +# GOOD - GFX_LIBRARIES is the lower-level set (gl, glfw, glad, imgui). +# glfwApp consumes them; consumers of glfwApp link glfwApp directly. +``` + +## Namespace-scope FetchContent'd deps when they bundle conflicting headers + +If an upstream bundles private copies of headers we also provide independently +(e.g. tinygltf bundles `stb_image.h` and `json.hpp`), do not expose the +upstream root directly. Mirror it under `build/_compat//` and expose +only `build/_compat/`. Consumers then include `` while the +upstream's quote-includes still resolve to its private bundled copies. + +## Use `SKIP_RETURN_CODE` for feature-probe fixtures + +CTest fixture-setup tests that may legitimately fail on hosts lacking a feature +(e.g. `gpu_probe` on a no-GPU CI runner) should set `SKIP_RETURN_CODE` so the +probe reports Skipped, not Failed. Dependent tests still skip through +`FIXTURES_REQUIRED`; `ctest` itself stays green on expected no-feature hosts. diff --git a/.cursor/rules/karpathy-guidelines.mdc b/.cursor/rules/karpathy-guidelines.mdc new file mode 100644 index 0000000..edd317f --- /dev/null +++ b/.cursor/rules/karpathy-guidelines.mdc @@ -0,0 +1,70 @@ +--- +description: Behavioral guidelines to reduce common LLM coding mistakes. Use when writing, reviewing, or refactoring code to avoid overcomplication, make surgical changes, surface assumptions, and define verifiable success criteria. +alwaysApply: true +--- + +# Karpathy behavioral guidelines + +Behavioral guidelines to reduce common LLM coding mistakes. Merge with project-specific instructions as needed. + +**Tradeoff:** These guidelines bias toward caution over speed. For trivial tasks, use judgment. + +## 1. Think Before Coding + +**Don't assume. Don't hide confusion. Surface tradeoffs.** + +Before implementing: +- State your assumptions explicitly. If uncertain, ask. +- If multiple interpretations exist, present them - don't pick silently. +- If a simpler approach exists, say so. Push back when warranted. +- If something is unclear, stop. Name what's confusing. Ask. + +## 2. Simplicity First + +**Minimum code that solves the problem. Nothing speculative.** + +- No features beyond what was asked. +- No abstractions for single-use code. +- No "flexibility" or "configurability" that wasn't requested. +- No error handling for impossible scenarios. +- If you write 200 lines and it could be 50, rewrite it. + +Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify. + +## 3. Surgical Changes + +**Touch only what you must. Clean up only your own mess.** + +When editing existing code: +- Don't "improve" adjacent code, comments, or formatting. +- Don't refactor things that aren't broken. +- Match existing style, even if you'd do it differently. +- If you notice unrelated dead code, mention it - don't delete it. + +When your changes create orphans: +- Remove imports/variables/functions that YOUR changes made unused. +- Don't remove pre-existing dead code unless asked. + +The test: Every changed line should trace directly to the user's request. + +## 4. Goal-Driven Execution + +**Define success criteria. Loop until verified.** + +Transform tasks into verifiable goals: +- "Add validation" → "Write tests for invalid inputs, then make them pass" +- "Fix the bug" → "Write a test that reproduces it, then make it pass" +- "Refactor X" → "Ensure tests pass before and after" + +For multi-step tasks, state a brief plan: +``` +1. [Step] → verify: [check] +2. [Step] → verify: [check] +3. [Step] → verify: [check] +``` + +Strong success criteria let you loop independently. Weak criteria ("make it work") require constant clarification. + +--- + +**These guidelines are working if:** fewer unnecessary changes in diffs, fewer rewrites due to overcomplication, and clarifying questions come before implementation rather than after mistakes. diff --git a/.cursor/rules/license-and-attribution.mdc b/.cursor/rules/license-and-attribution.mdc new file mode 100644 index 0000000..4093f1e --- /dev/null +++ b/.cursor/rules/license-and-attribution.mdc @@ -0,0 +1,48 @@ +--- +description: License and citation hygiene for OVR and its submodules +alwaysApply: true +--- + +# License and Attribution Hygiene + +## Verify attribution before writing + +License boilerplate is reusable; attribution is not. When copying or templating +`LICENSE` / `CITATION.cff`, always audit the destination project's authorship +before writing: + +1. Inspect the destination's source headers / README / git remote. +2. Replace any copied trailing `Copyright YYYY ` line with the + destination project's actual copyright holder. +3. If there is any ambiguity, ask the user. Do not guess or preserve a copied + name "just in case". + +```bash +# BAD - copies parent attribution into a submodule +cp LICENSE extern/tfnmodule/LICENSE + +# GOOD - copy boilerplate only, then rewrite the trailing copyright line +# after checking the destination project's own files. +``` + +## When asked to write CITATION.cff + +- Use author names from the destination project's source headers, README, or + existing citation metadata. +- Do not add institutions, affiliations, addresses, or co-authors unless the + user asks or the project already declares them. +- Do not infer ownership from adjacent repositories or old copied license text. + +## Submodules are not parent-repo files + +Submodule checkouts (`extern//`, `github-actions/`) are independent git +repos. Files added there are working-tree changes inside the submodule, not +normal parent-repo files. When editing a submodule, surface the two-step commit +flow: + +```bash +cd extern/ && git add ... && git commit && git push +cd ../.. && git add extern/ && git commit # bump pointer +``` + +The parent will show the submodule as dirty until both steps complete. diff --git a/.cursor/rules/python-package-conventions.mdc b/.cursor/rules/python-package-conventions.mdc new file mode 100644 index 0000000..a210ebd --- /dev/null +++ b/.cursor/rules/python-package-conventions.mdc @@ -0,0 +1,59 @@ +--- +description: Conventions for the ovrpy Python package + scikit-build-core wheel +globs: pyproject.toml,python/**,test/conftest.py,test/python/** +alwaysApply: false +--- + +# ovrpy Python Package Conventions + +## Skipping is opt-in, never automatic + +`pytest test/python/` runs every parametrized variant by default - including +the `[optix7]` (`gpu`) ones. A failing variant on a host lacking the hardware is +a real signal, not an automatic skip. + +The user opts out explicitly: + +```bash +pytest -m "not gpu" # CPU-only +pytest -m "not cpu" # GPU-only +ctest -LE gpu # ctest equivalent +``` + +Do not add `libcuda.so.1` probing or any other "auto-skip the GPU tier on a +GPU-less host" logic to the Python `_probe_backend`. The construct-time probe +(`ovrpy.create_renderer(name)`) is the only acceptable automatic skip trigger, +because it indicates a backend was not built / cannot construct, not that the +host lacks runtime hardware. + +## pytest config lives in `pyproject.toml` + +Keep `[tool.pytest.ini_options]` in the repo-root `pyproject.toml`, not in +`test/pytest.ini`. pytest finds the root config from any cwd in the tree; a +`test/`-local config can be missed and cause `PytestUnknownMarkWarning` instead +of `--strict-markers` enforcement. + +## Wheel install component is `ovrwheel` + +All `install(...)` rules that should ship in the pip/uv-built wheel must attach +`COMPONENT ovrwheel`. `pyproject.toml` sets +`install.components = ["ovrwheel"]` so third-party FetchContent install +rules (glfw3, glad, ospray cmake configs) don't leak into the wheel. + +## Wheel binaries: bundle inside `/ovrpy/` with `INSTALL_RPATH=$ORIGIN` + +`_core.so` plus the renderer/OSPRay/imgui closure live next to the package +init. C++ apps go in `/ovrpy/bin/` with `INSTALL_RPATH=$ORIGIN/..` and +are surfaced on `$PATH` via Python entry-point shims in `python/ovrpy/_apps.py` +(`os.execv` the bundled binary). + +Anchor shim lookups on `Path(_core.__file__).parent`, not +`Path(__file__).parent`: editable installs resolve `_apps.py` to the source +tree, while `_core.__file__` points at the real install location. + +## Loader-error helper translates missing system libs + +`python/ovrpy/__init__.py:_translate_loader_error` catches the dynamic linker's +`lib.so: cannot open shared object file` error and rewrites it with the +missing system lib plus `apt`/`dnf` install hints. Extend `_SYSTEM_LIB_HINTS` +when adding runtime deps that we deliberately don't bundle. diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 451f085..4912e96 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,6 +3,10 @@ name: CI env: DEBIAN_FRONTEND: noninteractive FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true" + # `CUDAARCHS` initialises CMAKE_CUDA_ARCHITECTURES on first configure + # (CMake >= 3.20). Single source of truth for SM target across all jobs; + # change here to retarget the whole workflow. + CUDAARCHS: "86" on: push: @@ -24,19 +28,15 @@ jobs: include: - cuda_version: "11.8.0" ubuntu_version: "22.04" - arch: "86" ospray_mode: fetchcontent - cuda_version: "11.8.0" ubuntu_version: "22.04" - arch: "86" ospray_mode: external - cuda_version: "12.8.1" ubuntu_version: "24.04" - arch: "86" ospray_mode: fetchcontent - cuda_version: "12.8.1" ubuntu_version: "24.04" - arch: "86" ospray_mode: external env: BUILD_DIR: build @@ -88,14 +88,31 @@ jobs: echo "OSPRAY_DIR=$OSPRAY_ROOT/lib/cmake/ospray-2.11.0" >> "$GITHUB_ENV" + - name: Set up Python (for pytest) + uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Install Python test dependencies + run: | + python -m pip install --upgrade pip + python -m pip install pytest pytest-xdist pytest-cov numpy pillow scikit-image + - name: Configure shell: bash + # OVR_BUILD_TESTS=ON now hard-requires Python3 + pytest + ovrpy at + # configure time. The "Install Python test dependencies" step + # above is what satisfies the pytest probe; if pytest isn't + # importable when cmake runs, configure exits non-zero with a + # clear install instruction. run: | CMAKE_ARGS=( -DCMAKE_BUILD_TYPE="${CONFIG}" -DOVR_BUILD_DEVICE_OPTIX7=ON -DOVR_BUILD_DEVICE_OSPRAY=ON - -DCMAKE_CUDA_ARCHITECTURES="${{ matrix.arch }}" + -DOVR_BUILD_TESTS=ON + -DOVR_BUILD_PYTHON_BINDINGS=ON + -DCMAKE_CUDA_ARCHITECTURES="${CUDAARCHS}" ) if [[ "${{ matrix.ospray_mode }}" == "external" ]]; then @@ -107,6 +124,29 @@ jobs: - name: Build run: cmake --build "${BUILD_DIR}" --target all --verbose -j"$(nproc)" + - name: Run CTest (C++ tier, CPU only) + shell: bash + # GHA runners have no NVIDIA GPU. The `gpu` CTest label excludes + # C++/CUDA tests that require a device. We also skip the + # `python_tests` entry here so its output isn't interleaved with + # C++ output and so we can drive pytest with the `gpu` marker + # filter directly in the next step. + run: | + ctest --test-dir "${BUILD_DIR}" --output-on-failure -LE gpu \ + --no-tests=error -E "python_tests" + + - name: Run pytest (Python tier, CPU only) + shell: bash + # `-m "not gpu"` deselects the `[optix7]` parametrize variants + # (tagged via `pytest.param("optix7", marks=pytest.mark.gpu)` in + # tests/conftest.py). Failures here MUST fail the job - swallowing + # them with `|| echo ...` previously made the entire Python tier + # advisory and let golden-image regressions ship unnoticed. + run: | + OVR_BUILD_DIR="${PWD}/${BUILD_DIR}" \ + OVR_TEST_FIXTURES="${PWD}/tests/fixtures" \ + python -m pytest tests/python/ -m "not gpu" -v --color=yes + build-windows: name: windows (CUDA ${{ matrix.cuda_version }}) runs-on: windows-latest @@ -115,7 +155,6 @@ jobs: matrix: include: - cuda_version: "12.8.1" - arch: "86" env: BUILD_DIR: build CONFIG: Release @@ -149,6 +188,17 @@ jobs: cuda: ${{ matrix.cuda_version }} method: network + - name: Set up Python (for pytest + ovrpy bindings) + uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Install Python test dependencies + shell: pwsh + run: | + python -m pip install --upgrade pip + python -m pip install pytest pytest-xdist pytest-cov numpy pillow scikit-image + - name: Configure shell: pwsh run: | @@ -158,11 +208,105 @@ jobs: "-DCMAKE_BUILD_TYPE=$env:CONFIG", "-DOVR_BUILD_DEVICE_OPTIX7=ON", "-DOVR_BUILD_DEVICE_OSPRAY=ON", - "-DCMAKE_CUDA_ARCHITECTURES=${{ matrix.arch }}", - "-DTBB_DIR=$env:TBB_DIR" + "-DTBB_DIR=$env:TBB_DIR", + "-DOVR_BUILD_TESTS=ON", + "-DOVR_BUILD_PYTHON_BINDINGS=ON", + "-DCMAKE_CUDA_ARCHITECTURES=${env:CUDAARCHS}" ) cmake @cmakeArgs - name: Build shell: pwsh run: cmake --build $env:BUILD_DIR --config $env:CONFIG --target ALL_BUILD --verbose + + - name: Run CTest (C++ tier, CPU only) + shell: pwsh + # OVR_BUILD_TESTS=ON requires OVR_BUILD_PYTHON_BINDINGS=ON (per + # tests/CMakeLists.txt's hard coupling), which is why we configure + # with bindings enabled even though we don't run the Python tier + # here. The pytest tier on Windows needs additional plumbing for + # the MSVC multi-config build layout (`_core.pyd` lands under + # build/ovrpy/$/ rather than build/ovrpy/) - tracked as a + # follow-up; skipping `python_tests` keeps this job green. + run: ctest --test-dir $env:BUILD_DIR -C $env:CONFIG --output-on-failure -LE gpu --no-tests=error -E "python_tests" + + coverage-linux: + name: coverage (CPU + Python, Debug) + runs-on: ubuntu-22.04 + env: + BUILD_DIR: build + CONFIG: Debug + + steps: + - name: Free Disk Space (Ubuntu) + uses: jlumbroso/free-disk-space@main + with: + tool-cache: true + android: true + dotnet: true + haskell: true + large-packages: true + swap-storage: true + + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install build dependencies + run: | + sudo apt-get update + sudo apt-get install -y cmake gcc g++ libtbb-dev libglfw3-dev xorg-dev wget + + - name: Install CUDA toolkit + uses: Jimver/cuda-toolkit@v0.2.34 + with: + cuda: "12.8.1" + method: network + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Install Python test deps + coverage tooling + run: | + python -m pip install --upgrade pip + python -m pip install pytest pytest-xdist pytest-cov numpy pillow scikit-image gcovr + + - name: Configure with coverage + run: | + cmake -S . -B "${BUILD_DIR}" \ + -DCMAKE_BUILD_TYPE=Debug \ + -DOVR_BUILD_TESTS=ON \ + -DOVR_BUILD_PYTHON_BINDINGS=ON \ + -DOVR_ENABLE_COVERAGE=ON \ + -DOVR_BUILD_DEVICE_OPTIX7=ON \ + -DOVR_BUILD_DEVICE_OSPRAY=ON \ + -DCMAKE_CUDA_ARCHITECTURES="${CUDAARCHS}" + + - name: Build + run: cmake --build "${BUILD_DIR}" --target all --verbose -j"$(nproc)" + + - name: Run tests + collect coverage via the `coverage` target + env: + # GHA runners have no GPU. C++ side: gpu-labelled tests already + # auto-skip via the `gpu_available` CTest fixture (gpu_probe + # exits non-zero when cudaGetDeviceCount() <= 0). Python side: + # pytest doesn't auto-skip - we deselect the `[optix7]` + # parametrize variants explicitly via PYTEST_ADDOPTS, which + # pytest splices in front of its own argv. + PYTEST_ADDOPTS: -m "not gpu" + run: | + cmake --build "${BUILD_DIR}" --target coverage + ls -la "${BUILD_DIR}/coverage" || true + + - name: Upload coverage reports + uses: actions/upload-artifact@v4 + if: always() + with: + name: coverage-reports + path: | + ${{ env.BUILD_DIR }}/coverage/coverage.xml + ${{ env.BUILD_DIR }}/coverage/coverage-py.xml + ${{ env.BUILD_DIR }}/coverage/index.html + if-no-files-found: ignore diff --git a/.gitignore b/.gitignore index 697c49e..6946b1d 100644 --- a/.gitignore +++ b/.gitignore @@ -45,4 +45,12 @@ projects/ CLAUDE.md -__pycache__/ \ No newline at end of file +__pycache__/ + +# Python packaging artefacts (pyproject.toml + scikit-build-core) +dist/ +*.egg-info/ +python/*.egg-info/ +.eggs/ + +uv.lock diff --git a/.gitmodules b/.gitmodules index d07172e..84bc37d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "github-actions"] path = github-actions url = https://github.com/wilsonCernWq/github-workflow-collections.git +[submodule "extern/tfnmodule"] + path = extern/tfnmodule + url = https://github.com/wilsonCernWq/TransferFunctionModule.git diff --git a/CMakeLists.txt b/CMakeLists.txt index fe58a8a..d8e6825 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,6 +73,11 @@ add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/gdt) # Other Libraries include(configure_oneapi) include(dep_opengl) +include(dep_json) +include(dep_stb) +include(dep_tinyexr) +include(dep_tinyobj) +include(dep_tinygltf) include(dep_usd) find_package(Threads REQUIRED) # find_package(OpenMP REQUIRED) @@ -97,16 +102,45 @@ add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/extern/bin2c EXCLUDE_FROM_ALL) include(${CMAKE_CURRENT_LIST_DIR}/extern/bin2c/target_add_embeded_shaders.cmake) ############################################################################### -# Transfer Function Module +# GLFW app shim (extern/glfwapp/) +# +# Always processed so the header-only `glfwapp_headers` INTERFACE target +# is available to consumers like renderbatch (which only needs the +# CameraFrame struct in ). The full `glfwapp` +# static lib is gated on OVR_BUILD_OPENGL inside the subdir's +# CMakeLists.txt. ############################################################################### -set(TFNMODULE_INCLUDE ${CMAKE_CURRENT_LIST_DIR}/extern/tfn/colormaps) -add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/extern/tfn/colormaps) -add_library(tfnmodule STATIC ${embedded_colormap}) +add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/extern/glfwapp EXCLUDE_FROM_ALL) + +############################################################################### +# Transfer Function Module +# +# Submodule at extern/tfnmodule/ ships its own CMakeLists.txt that defines +# the `tfnmodule` target (colormap sources + INTERFACE include of the +# colormaps dir). We extend its public include path with the submodule +# root so consumers can `#include "tfn/core.h"` etc. - what previously +# came from the broader `extern/` include shim. +############################################################################### +add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/extern/tfnmodule) target_include_directories(tfnmodule PUBLIC - $ + $ ) -if (UNIX) - set_target_properties(tfnmodule PROPERTIES POSITION_INDEPENDENT_CODE ON) + +############################################################################### +# Testing / Coverage +############################################################################### +option(OVR_BUILD_TESTS "Build C++/CUDA unit tests" OFF) +option(OVR_ENABLE_COVERAGE "Enable coverage instrumentation (requires Debug build)" OFF) + +# Only enable CTest at the top-level OVR build so embedding projects can decide +# for themselves. This defines `BUILD_TESTING` (ON by default) and calls +# `enable_testing()` which is required for `add_test` to do anything. +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) + include(CTest) +endif() + +if(OVR_ENABLE_COVERAGE) + include(configure_coverage) endif() add_subdirectory(ovr) @@ -117,3 +151,8 @@ add_subdirectory(projects) if(OVR_BUILD_PYTHON_BINDINGS) add_subdirectory(python) endif() + +if(OVR_BUILD_TESTS) + include(configure_tests) + add_subdirectory(tests) +endif() diff --git a/DEV.md b/DEV.md new file mode 100644 index 0000000..98a1610 --- /dev/null +++ b/DEV.md @@ -0,0 +1,250 @@ +# OVR developer guide + +Build-system internals, packaging guts, and contributor-only notes for +[Open Volume Renderer](README.md). End-user install instructions live in +the README. + +## Top-level CMake options + +| Option | Default | Effect | +| --- | --- | --- | +| `OVR_BUILD_DEVICE_OPTIX7` | ON | OptiX 7 backend (requires CUDA + OptiX SDK) | +| `OVR_BUILD_DEVICE_OSPRAY` | ON | OSPRay backend | +| `OVR_BUILD_CUDA` | ON | Compile CUDA sources / link cudart | +| `OVR_BUILD_OPENGL` | ON | GLFW + ImGui-based `renderapp`; also gates the imgui hooks compiled into the device backends | +| `OVR_BUILD_APPS` | ON | Application executables (`renderapp`, `renderbatch`) | +| `OVR_BUILD_PYTHON_BINDINGS` | OFF | The `ovrpy` pybind11 module | +| `OVR_BUILD_USD` | OFF | USDA scene loading via Pixar USD | +| `OVR_BUILD_TINYEXR` | ON | Fetch tinyexr v1.0.8 via FetchContent and link it into `rendercommon` to enable EXR read/write in `common/imageio.cpp`. Turn OFF to drop tinyexr from the build (a `.exr` filename then raises a runtime error) | +| `OVR_BUILD_TINYOBJ` | OFF | Same, for tinyobjloader v1.0.6 → `tinyobj` INTERFACE target | +| `OVR_BUILD_TINYGLTF` | OFF | Fetch tinygltf v2.5.0 via FetchContent and expose it as the `tinygltf` INTERFACE target (no consumer wired in by default) | +| `OVR_BUILD_TESTS` | OFF | C++/CUDA unit tests + register Python tests | +| `OVR_ENABLE_COVERAGE` | OFF | `--coverage -O0 -g` for GCC/Clang; adds the `coverage` target | + +## Manual cmake invocation + +The full equivalent of `./scripts/build.sh --all`: + +```bash +cmake -S . -B build \ + -DCMAKE_BUILD_TYPE=Release \ + -DOVR_BUILD_DEVICE_OPTIX7=ON \ + -DOVR_BUILD_DEVICE_OSPRAY=ON \ + -DOVR_BUILD_PYTHON_BINDINGS=ON \ + -DOVR_BUILD_TESTS=ON +cmake --build build -j +ctest --test-dir build --output-on-failure +``` + +Pointing at out-of-tree dependencies: + +```bash +cmake -S . -B build \ + -DOptiX_INSTALL_DIR= \ + -Dospray_DIR=/lib/cmake/ospray-x.x.0 \ + -DTBB_DIR=/lib/cmake/tbb \ + -DCMAKE_PREFIX_PATH= # optional +``` + +## `scripts/build.sh` phase matrix + +`--configure`, `--build`, `--test` are additive; with no flags the script +does configure + build. `--all` ≡ `--configure --build --test`. `--python` +is orthogonal and toggles `OVR_BUILD_PYTHON_BINDINGS=ON`. + +| Invocation | Configure | Build | Test | `OVR_BUILD_PYTHON_BINDINGS` | `OVR_BUILD_TESTS` | +| --- | :-: | :-: | :-: | :-: | :-: | +| (none) | yes | yes | | OFF | OFF | +| `--configure` | yes | | | OFF | OFF | +| `--build` | | yes | | (cache) | (cache) | +| `--test` | | | yes | **ON** | **ON** | +| `--build --test` | | yes | yes | **ON** | **ON** | +| `--configure --test` | yes | | yes | **ON** | **ON** | +| `--configure --build` | yes | yes | | OFF | OFF | +| `--configure --build --test` | yes | yes | yes | **ON** | **ON** | +| `--all` | yes | yes | yes | **ON** | **ON** | +| `--python` | yes | yes | | **ON** | OFF | +| `--build --python` | | yes | | **ON** (cache) | (cache) | +| `--clean` | (deletes the build dir, then exits) | | | | | + +`--test` (and therefore `--all`) implies `--python` because the test tier +is gated on the bindings. `--python` only takes effect when configure +runs; if you only `--build`, the script reuses whatever was in the cmake +cache from the previous configure. + +The script never mutates your environment. If `pytest` isn't importable +when `--test` is requested it prints `pip install -e .[test]` and exits. +If git submodules are missing it prints +`git submodule update --init --recursive` and exits. It does **not** run +pip, install system packages, or fetch submodules silently. + +Environment overrides: + +| Variable | Effect | +| --- | --- | +| `BUILD_DIR` | Override the build directory (default: `/build`) | +| `CMAKE_ARGS` | Extra flags appended to the cmake invocation | +| `CTEST_ARGS` | Extra flags passed to ctest (default: `-LE gpu --output-on-failure --no-tests=error`) | + +## Python wheel build (scikit-build-core) + +`pyproject.toml` drives +[scikit-build-core](https://scikit-build-core.readthedocs.io/), so +`pip install` / `uv sync` invokes the same top-level `CMakeLists.txt` +the cmake-only flow uses, with these scoped defaults: + +```toml +[tool.scikit-build.cmake.define] +OVR_BUILD_PYTHON_BINDINGS = "ON" +OVR_BUILD_APPS = "OFF" +OVR_BUILD_TESTS = "OFF" +``` + +`OVR_BUILD_OPENGL` keeps its global default (`ON`) so the interactive +viewer remains reachable from Python; the imgui/glad shared libs end up +in the wheel alongside the renderer + OSPRay closure. + +### Wheel layout + +``` +ovrpy/ +├── __init__.py re-exports the native module + loader-error helper +├── _core*.so pybind11 extension (PYBIND11_MODULE(_core, m)) +├── render.py `ovrpy-render` console entry point +├── _apps.py os.execv shims for the bundled C++ binaries +├── librenderlib.so renderer + statically-absorbed device backends +├── librendercommon.so common runtime +├── libimgui.so, libglad.so interactive (OpenGL) tier +├── lib*.so* (OSPRay closure) libospray, libtbb, libembree4, libopenvkl, +│ libispcrt, libOpenImageDenoise, plus +│ OpenVKL's 4/8/16-wide CPU-device modules +└── bin/ + ├── renderapp interactive viewer (RUNPATH=$ORIGIN/..) + └── renderbatch offline render-to-PNG (RUNPATH=$ORIGIN/..) +``` + +The C++ apps live in `bin/` rather than directly in the package root so +their `INSTALL_RPATH=$ORIGIN/..` resolves the renderer + OSPRay closure +without colliding with the wheel's pure-Python layout. They're surfaced +on the user's `$PATH` via `[project.scripts]` entries in `pyproject.toml` +that point at thin shims in `python/ovrpy/_apps.py`; each shim +`os.execv`s the matching bundled binary, side-stepping the +Python-version-specific RPATH path that would otherwise be needed to +ship them in `/bin/` directly. + +### Component scoping + +A custom CMake install component, `ovrwheel`, scopes which `install()` +rules ship in the wheel — only the OVR-owned libs above. Third-party +FetchContent install rules (glfw3, glad's own rules, OSPRay's cmake +configs) would otherwise leak their files into the wheel; we filter them +out via: + +```toml +[tool.scikit-build] +install.components = ["ovrwheel"] +``` + +The matching `python/CMakeLists.txt` rules attach `COMPONENT ovrwheel` to +every `install(TARGETS ...)` and `install(DIRECTORY ...)` call, plus set +`INSTALL_RPATH=$ORIGIN` on `_core`, `renderlib`, `rendercommon`, `imgui`, +and `glad`. OSPRay's own libs already ship with +`RUNPATH=$ORIGIN:$ORIGIN/../lib` so they self-resolve once unpacked. + +The OSPRay closure is sourced from `${ospray_DIR}/../..` (i.e. the lib +dir under whatever prefix `ospray_DIR` points at — set either by the +local FetchContent of `ospray_binary` or by an external +`-Dospray_DIR=...` override). + +### Loader-error translation + +`python/ovrpy/__init__.py` wraps `from . import _core` and translates the +dynamic linker's `lib.so: cannot open shared object file` message +into a friendlier `ImportError` that names the missing lib *and* prints +the matching `apt`/`dnf` install command. Recognised system libs: + +| Lib | Used by | Ubuntu/Debian | RHEL/Fedora | +| --- | --- | --- | --- | +| `libcuda.so.1` | OptiX backend | (NVIDIA driver) | (NVIDIA driver) | +| `libGL.so.1` | OpenGL tier | `libgl1` | `mesa-libGL` | +| `libOpenGL.so.0` | OpenGL ABI (GLVND) | `libopengl0` | `libglvnd-opengl` | +| `libX11.so.6` | imgui (interactive viewer) | `libx11-6` | `libX11` | +| `libvulkan.so.1` | imgui (Vulkan loader) | `libvulkan1` | `vulkan-loader` | + +To extend, edit `_SYSTEM_LIB_HINTS` in `python/ovrpy/__init__.py`. + +### Headless / CPU-only opt-outs + +```bash +pip install . -C cmake.define.OVR_BUILD_CUDA=OFF \ + -C cmake.define.OVR_BUILD_DEVICE_OPTIX7=OFF +# uv equivalent (pass through to scikit-build-core): +CMAKE_ARGS="-DOVR_BUILD_CUDA=OFF -DOVR_BUILD_DEVICE_OPTIX7=OFF" uv sync --extra test +``` + +### Starting clean + +When something goes sideways (stale editable install, mismatched RPATHs, +half-built `_core.so`): + +```bash +rm -rf .venv build build/skbuild +uv sync --extra test +``` + +`build/` holds the cmake-only artifacts (`scripts/build.sh`), +`build/skbuild/` holds the scikit-build-core wheel-build tree; both are +safe to delete. + +### Open follow-ups + +- Manylinux-tag adjustment (`auditwheel repair`) for cross-distro wheels. + +## Embedding OVR in a parent CMake project + +OVR uses `OVR_INSTALL_INCLUDEDIR` to describe the include root that gets +encoded into installed/exported OVR interface targets: + +- Standalone OVR: the top-level `CMakeLists.txt` includes + `GNUInstallDirs` and defaults `OVR_INSTALL_INCLUDEDIR` to + `${CMAKE_INSTALL_INCLUDEDIR}` (normally `include`). +- Embedded as a subdirectory: the parent may override + `OVR_INSTALL_INCLUDEDIR` before `add_subdirectory(...)` if OVR's + public headers should live under a package-specific subtree such as + `include/`. +- This variable controls only the *installed/exported* include + interface. OVR's build interface stays rooted in the OVR source tree + so the repository doesn't depend on parent-specific path conventions. + +Example: + +```cmake +include(GNUInstallDirs) +set(OVR_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/instantvnr") +add_subdirectory(open-volume-renderer) +``` + +## Continuous integration + +`.github/workflows/main.yml` runs three jobs per push / PR: + +| Job | Runner | What it covers | +| --- | --- | --- | +| `build-linux` | ubuntu-22.04 + ubuntu-24.04 (matrix) | Release build with CUDA 11.8 / 12.8 × OSPRay fetchcontent / external; runs C++ + Python tests, **excluding `gpu`-labelled tests** because GHA runners have no NVIDIA GPU | +| `build-windows` | windows-latest | Release build with MSVC + CUDA 12.8.1; runs C++ tests excluding `gpu` | +| `coverage-linux` | ubuntu-22.04 | Debug build with `OVR_ENABLE_COVERAGE=ON`; produces `coverage.xml` (Cobertura) and an HTML drill-down via `gcovr`, uploaded as an artifact | + +No runner has a GPU, so the OptiX 7 backend's runtime tests are local-only. +CI exercises the C++/binding surface and the OSPRay backend end-to-end. + +## Roadmap / open items + +- Commit golden-image regression baselines for the OSPRay and OptiX + backends (see `tests/README.md` and the `--update-baselines` workflow). +- Per-setter render-side assertions in `tests/python/test_setters.py` + (currently binding-level smoke only). +- A self-hosted GPU CI matrix entry to exercise the OptiX 7 + CUDA tests + that are skipped on GHA runners. +- USD/USDA loader is functional but off by default; tests cover only the + JSON path today. +- Manylinux wheel (`auditwheel repair`) for cross-distro distribution. diff --git a/LICENSE b/LICENSE index 7b2818d..b907189 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2019 Ingo Wald + Copyright 2019-2026 Qi Wu and contributors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index fa62a5b..4d92301 100644 --- a/README.md +++ b/README.md @@ -4,118 +4,170 @@ ![Expected Rendering Result](./data/example.jpg) -## TODO List +OVR is a CUDA + OSPRay volume rendering framework. It ships: + +- A C++/CUDA library (`renderlib`) with two pluggable backends: + - **OptiX 7** (NVIDIA GPU) for hardware-accelerated ray tracing + - **OSPRay** (Intel CPU) for high-quality CPU rendering, including + distributed rendering hooks +- Two reference applications: + - `renderapp` — interactive GLFW + ImGui viewer + - `renderbatch` — offline render-to-PNG driver +- A Python package (`ovrpy`) built with pybind11, including the + `ovrpy-render` console script +- A unified test suite (CTest + doctest + pytest) with optional + PSNR/SSIM rendering regression + +For build-system internals, packaging, CI, and contributor notes see +[`DEV.md`](DEV.md). Test infrastructure (markers, golden-image workflow, +coverage) is documented in [`tests/README.md`](tests/README.md). + +## Repository layout -- [ ] Complete & correct documentations -- [ ] Cleanup scene file features -- [ ] embed noise file into the code -- [ ] add neural representation renderer (with API for NN and Libtorch) +``` +. +├── apps/ renderapp + renderbatch executables +├── ovr/ core library (rendercommon, renderlib, devices/) +│ ├── devices/optix7/ OptiX 7 backend +│ ├── devices/ospray/ OSPRay backend +│ └── serializer/ scene loaders (DiVA/VIDi JSON, optional USDA) +├── python/ pybind11 binding source + `ovrpy` Python package +│ ├── python.cpp PYBIND11_MODULE(_core, m) +│ └── ovrpy/ re-exports `_core` as `import ovrpy` +├── tests/ doctest + pytest test suite (see tests/README.md) +├── pyproject.toml scikit-build-core driver for `pip install` +├── scripts/build.sh configure/build/test driver for the cmake flow +├── cmake/ CMake configure modules +├── extern/ vendored / FetchContent dependency wrappers +├── data/ example scenes, configs, transfer functions +├── gdt/ vendored math header library +└── projects/ sample integrations +``` -## Building the Code +## Requirements -This code contains two versions because the rendering framework was heavily factored and reimplemented -for multiple times. The new version lies in the `src` directory with the old version in `sources`. The -old version probably should not be used, so it is commented out intentionally. The old version is still -being kept because there are functionalities yet to be ported. +- CMake **>= 3.18** +- A C++17 compiler — tested on GCC 11/13 (Ubuntu 22.04/24.04) and MSVC 2019/2022 +- Threads (POSIX or Win32) -This code also contains experimental programs implemented for testing. Each directory in the `experiment` -folder contains one standalone program. They are simplied versions of the main renderer, which can be -useful for embeded rendering implementation. +Optional, gated by build-time flags (defaults shown): -## Dependencies +| Component | When needed | Notes | +| --- | --- | --- | +| CUDA Toolkit (≥ 11.x) | `OVR_BUILD_CUDA=ON` | CI tests against 11.8 and 12.8 | +| OptiX 7 SDK | `OVR_BUILD_DEVICE_OPTIX7=ON` | `OptiX_INSTALL_DIR=`; download from | +| OSPRay + TBB | `OVR_BUILD_DEVICE_OSPRAY=ON` | Auto-fetched via FetchContent; override with `-Dospray_DIR=...` | +| OpenGL + GLFW | `OVR_BUILD_OPENGL=ON` | Required for `renderapp`; on Debian/Ubuntu: `sudo apt install libglfw3-dev xorg-dev libtbb-dev` | +| Python 3 + pytest | `OVR_BUILD_TESTS=ON` and/or `OVR_BUILD_PYTHON_BINDINGS=ON` | `pip install -e .[test]` | +| Pixar USD | `OVR_BUILD_USD=ON` (off by default) | For USDA scene loading | -- a compiler - - on Windows, tested with Visual Studio 2017 and 2019 community editions. - - on Linux, tested with Ubuntu 18 and Ubuntu 19 default gcc installs. -- CUDA 11.3 or above - - Download from developer.nvidia.com. - - on Linux, suggest to put `/usr/local/cuda/bin` into your `PATH`. -- latest NVIDIA developer driver that comes with the SDK. - - download from http://developer.nvidia.com/optix and click "Get OptiX". -- OptiX 7 SDK - - download from http://developer.nvidia.com/optix and click "Get OptiX". - - on linux, suggest to set the environment variable `OptiX_INSTALL_DIR` to wherever you installed the SDK. - `export OptiX_INSTALL_DIR=` - - on windows, the installer should automatically put it into the right directory/ -- OSPRay & TBB - - if you are building this code in `Release` mode, simply download the latest OSPRay - from https://github.com/ospray/ospray/releases and TBB from https://github.com/oneapi-src/oneTBB/releases. - - if you are building this code in other configuration, you need to compile and install OSPRay manually. - You also do not need to download TBB separately because OSPRay's superbuild will provide a version of TBB. +Submodules: -Detailed steps below: +```bash +git submodule update --init --recursive +``` -## Building +`scripts/build.sh` checks `git submodule status` and refuses to proceed +if any submodule is uninitialised — it never runs `git submodule update` +on your behalf. -- Install required packages +## Install - - on Debian/Ubuntu: `sudo apt install libglfw3-dev cmake-curses-gui` +There are two equivalent paths; pick whichever matches what you're after. +Don't combine them on the same checkout — you'd build twice. -- Clone the code +### Python tier (`ovrpy`) via pip / uv -- Create (and enter) a build directory -``` - mkdir build - cd build -``` +```bash +# uv +uv sync --extra test +uv run ovrpy-render --help +uv run python -c "import ovrpy; print(ovrpy.vec2i())" -- Configure with cmake (Debug Mode) - - Ubuntu: - ``` - cmake .. -DCMAKE_BUILD_TYPE=Debug - # cmake .. \ - # -DCMAKE_BUILD_TYPE=Debug \ - # -DCMAKE_PREFIX_PATH= \ - # -Dospray_DIR=\lib\cmake\ospray-x.x.0 \ - # -DTBB_DIR=\lib\cmake\tbb - ``` - - Windows: - ``` - cmake -G "Visual Studio 16 2019" -T host=x64 -A x64 .. -DCMAKE_BUILD_TYPE=Debug - # cmake -G "Visual Studio 16 2019" -T host=x64 -A x64 .. ^ - # -DCMAKE_BUILD_TYPE=Debug ^ - # -DCMAKE_PREFIX_PATH= ^ - # -Dospray_DIR=\lib\cmake\ospray-x.x.0 ^ - # -DTBB_DIR=\lib\cmake\tbb - ``` - -- And build +# or plain pip +pip install -e .[test] +ovrpy-render --help ``` - cmake --build . + +`pip install` / `uv sync` invokes the same top-level `CMakeLists.txt` +through [scikit-build-core](https://scikit-build-core.readthedocs.io/), +producing a self-contained wheel at `/ovrpy/` (renderer + +OSPRay closure + interactive OpenGL tier all bundled). Headless / CPU-only +users can opt out of CUDA/OptiX: + +```bash +CMAKE_ARGS="-DOVR_BUILD_CUDA=OFF -DOVR_BUILD_DEVICE_OPTIX7=OFF" uv sync --extra test ``` -## Installing and Embedding - -OVR uses a generic CMake variable, `OVR_INSTALL_INCLUDEDIR`, to describe the -include root that should be encoded into installed/exported OVR interface -targets. - -- When OVR is configured standalone, `base/CMakeLists.txt` includes - `GNUInstallDirs` and defaults `OVR_INSTALL_INCLUDEDIR` to - `${CMAKE_INSTALL_INCLUDEDIR}` (normally `include`). -- When OVR is embedded as a subdirectory of a parent project, the parent may - override `OVR_INSTALL_INCLUDEDIR` before `add_subdirectory(base)` if OVR's - public headers should live under a package-specific subtree such as - `include/instantvnr`. -- This variable only controls the installed/exported include interface. OVR's - build interface intentionally stays rooted in the OVR source tree so the base - repository does not depend on parent-specific path conventions. - -Example parent-project override: - -```cmake -include(GNUInstallDirs) -set(OVR_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/instantvnr") -add_subdirectory(base) +ovrpy bundles its own renderer + OSPRay/imgui closure but relies on a few +host-provided system libraries (`libcuda.so.1`, `libGL.so.1`, +`libOpenGL.so.0`, `libX11.so.6`, `libvulkan.so.1`). If any are missing, +`import ovrpy` raises a translated `ImportError` that names the missing +lib and prints the exact `apt`/`dnf` install command. See +[`DEV.md`](DEV.md#loader-error-translation) for the full table. + +### C++ apps via `scripts/build.sh` + +`--configure`, `--build`, `--test` are additive; `--all` ≡ all three. +`--python` toggles the Python bindings on the cmake side (independent of +the pip/uv flow above). + +```bash +./scripts/build.sh # configure + build (C++ only) +./scripts/build.sh --python # configure + build, with the ovrpy bindings +./scripts/build.sh --all # configure + build + test +./scripts/build.sh --test # tests only, against an existing build +./scripts/build.sh --clean # rm -rf the build dir, exit ``` -Use plain `${CMAKE_INSTALL_INCLUDEDIR}` when you want OVR headers installed -directly under the global include root, and override `OVR_INSTALL_INCLUDEDIR` -only when the parent package intentionally nests them under its own prefix. +The full phase/option matrix and manual `cmake ... && cmake --build ...` +recipes are in [`DEV.md`](DEV.md). ## Running -- On Linux: +After `pip install -e .` / `uv sync`, three console scripts land on +`$PATH` — `ovrpy-render` is a Python entry point; `renderapp` and +`renderbatch` are the bundled C++ apps wrapped by tiny entry-point +shims (`python/ovrpy/_apps.py`) so they resolve their RPATH cleanly. + +```bash +# Python entry point +ovrpy-render data/configs/.json -o render.png --backend ospray + +# C++ apps (same binaries as the cmake-only flow, but on $PATH) +renderapp data/configs/.json # interactive viewer (needs GLFW + display) +renderbatch data/configs/.json # offline render to PNG + +# Same C++ apps from a cmake-only build (no pip install needed) +./build/renderapp data/configs/.json +./build/renderbatch data/configs/.json ``` -TODO + +Scene JSON files live under `data/configs/`; see +`data/configs/README.md` for the schema. The Python tier exposes the +same renderer through `import ovrpy`; see `tests/python/` for end-to-end +usage examples. + +## Testing + +```bash +./scripts/build.sh --all # configure + build + run the full suite +./scripts/build.sh --test # iterate on tests against an existing build + +# pytest only (after `pip install -e .[test]` or `uv sync --extra test`): +uv run pytest tests/python/ -v ``` + +When `OVR_BUILD_TESTS=ON`, CMake hard-requires `Python3` + +`OVR_BUILD_PYTHON_BINDINGS=ON` + an importable `pytest` and emits a +`FATAL_ERROR` with the install command if anything is missing — there is +no silent skip. + +See [`tests/README.md`](tests/README.md) for labels (`cpp` / `gpu` / +`python` / `golden`), the golden-image baseline workflow, coverage, and +troubleshooting. + +## License + +OVR is distributed under the Apache 2.0 License (see [`LICENSE`](LICENSE)). +Bundled / fetched dependencies retain their own licenses. diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index c2a0762..e6051c2 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -3,14 +3,32 @@ # ======================================================================== # add_executable(renderbatch main_batch.cpp) -target_link_libraries(renderbatch PUBLIC renderlib) +# `glfwapp_headers` is the header-only INTERFACE target that exposes +# `` (a pure CameraFrame struct, no OpenGL deps). +target_link_libraries(renderbatch PUBLIC renderlib glfwapp_headers) # the default rendering application if(OVR_BUILD_OPENGL) add_executable(renderapp main_app.cpp) - target_link_libraries(renderapp - PUBLIC - renderlib - glfwApp - ) + target_link_libraries(renderapp PUBLIC renderlib glfwapp) +endif() + +# Wheel-bundling: when the Python bindings are built (the pip / uv flow), +# install the apps into /ovrpy/bin/ so the entry-point shims in +# python/ovrpy/_apps.py can `os.execv` them. INSTALL_RPATH=$ORIGIN/.. +# resolves librenderlib + the rest of the closure that lives in the +# package root one level up. +if(OVR_BUILD_PYTHON_BINDINGS) + if(TARGET renderbatch) + set_target_properties(renderbatch PROPERTIES INSTALL_RPATH "$ORIGIN/..") + install(TARGETS renderbatch + RUNTIME DESTINATION bin + COMPONENT ovrwheel) + endif() + if(TARGET renderapp) + set_target_properties(renderapp PROPERTIES INSTALL_RPATH "$ORIGIN/..") + install(TARGETS renderapp + RUNTIME DESTINATION bin + COMPONENT ovrwheel) + endif() endif() diff --git a/cmake/configure_coverage.cmake b/cmake/configure_coverage.cmake new file mode 100644 index 0000000..ea3aa80 --- /dev/null +++ b/cmake/configure_coverage.cmake @@ -0,0 +1,63 @@ +# ======================================================================== # +# OVR coverage instrumentation (GCC / Clang only) # +# # +# Enable with `-DOVR_ENABLE_COVERAGE=ON -DCMAKE_BUILD_TYPE=Debug`. # +# Applies `--coverage -O0 -g` to every target that opts in via # +# `ovr_apply_coverage_flags()`. A top-level `coverage` custom # +# target is provided that runs ctest and invokes gcovr to produce an XML # +# and an HTML report under ${CMAKE_BINARY_DIR}/coverage/. # +# ======================================================================== # + +include_guard(GLOBAL) + +if(NOT (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")) + message(WARNING "OVR_ENABLE_COVERAGE requested but only GCC/Clang are supported; disabling.") + set(OVR_ENABLE_COVERAGE OFF CACHE BOOL "" FORCE) + return() +endif() + +message(STATUS "OVR coverage instrumentation enabled (--coverage)") + +# Apply coverage flags to host C/C++ compilation only; skip CUDA (nvcc doesn't +# understand --coverage directly). External dependencies built under extern/ +# will also pick these up, but gcovr's --exclude below filters them back out. +add_compile_options($<$:--coverage> + $<$:-O0> + $<$:-g>) +add_link_options(--coverage) + +# Back-compat shim so existing calls to ovr_apply_coverage_flags() are no-ops. +function(ovr_apply_coverage_flags TARGET) +endfunction() + +find_program(GCOVR_BIN gcovr) + +if(GCOVR_BIN) + add_custom_target(coverage + COMMENT "Running ctest and collecting C++ coverage with gcovr" + COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure + COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/coverage" + COMMAND ${GCOVR_BIN} + -r ${CMAKE_SOURCE_DIR} + --exclude ${CMAKE_BINARY_DIR} + --exclude ${CMAKE_SOURCE_DIR}/extern + --exclude ${CMAKE_SOURCE_DIR}/tests + # nvcc's device-link step generates an ephemeral + # /tmp/tmpxft_*_cmake_device_link.reg.c that's deleted before gcovr + # runs. Without this flag, gcovr aborts on those .gcda files; with + # it, gcovr just warns and skips them (what we want - the + # device-link stub has no user-meaningful coverage anyway). + --gcov-ignore-errors=source_not_found + --xml ${CMAKE_BINARY_DIR}/coverage/coverage.xml + --html-details ${CMAKE_BINARY_DIR}/coverage/index.html + USES_TERMINAL + VERBATIM + ) +else() + add_custom_target(coverage + COMMENT "gcovr not found; install with 'pip install gcovr'" + COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure + COMMAND ${CMAKE_COMMAND} -E echo + "gcovr not found; raw .gcda/.gcno remain under ${CMAKE_BINARY_DIR}" + ) +endif() diff --git a/cmake/configure_oneapi.cmake b/cmake/configure_oneapi.cmake index 159455b..8b1785b 100644 --- a/cmake/configure_oneapi.cmake +++ b/cmake/configure_oneapi.cmake @@ -44,6 +44,29 @@ if(OVR_BUILD_OSPRAY) if(NOT TARGET ospray::ospray) message(FATAL_ERROR "ospray not found") endif() + if(WIN32) + get_target_property(_ovr_ospray_dll ospray::ospray IMPORTED_LOCATION_RELEASE) + if(NOT _ovr_ospray_dll) + get_target_property(_ovr_ospray_dll ospray::ospray IMPORTED_LOCATION) + endif() + if(_ovr_ospray_dll) + get_filename_component(_ovr_ospray_bin_dir "${_ovr_ospray_dll}" DIRECTORY) + elseif(DEFINED ospray_DIR) + get_filename_component(_ovr_ospray_prefix "${ospray_DIR}/../../.." ABSOLUTE) + set(_ovr_ospray_bin_dir "${_ovr_ospray_prefix}/bin") + endif() + + if(_ovr_ospray_bin_dir AND IS_DIRECTORY "${_ovr_ospray_bin_dir}") + file(GLOB _ovr_ospray_runtime_dlls CONFIGURE_DEPENDS + "${_ovr_ospray_bin_dir}/*.dll" + ) + if(_ovr_ospray_runtime_dlls) + set_property(GLOBAL APPEND PROPERTY OVR_EXTRA_RUNTIME_DLLS + ${_ovr_ospray_runtime_dlls} + ) + endif() + endif() + endif() endif() if(OVR_BUILD_OPENVKL) diff --git a/cmake/configure_python.cmake b/cmake/configure_python.cmake index f6a1c20..ecf66eb 100644 --- a/cmake/configure_python.cmake +++ b/cmake/configure_python.cmake @@ -1,18 +1,37 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.18) include_guard(GLOBAL) -# Reuse PYTHON_EXECUTABLE set by parent project; only detect if not yet set. -if(NOT PYTHON_EXECUTABLE) -execute_process( - COMMAND "which" "python" OUTPUT_VARIABLE PYTHON_EXECUTABLE - OUTPUT_STRIP_TRAILING_WHITESPACE -) +# --------------------------------------------------------------------------- +# Locate Python (interpreter + Development.Module headers/libs for pybind11). +# +# We delegate to CMake's `FindPython3` rather than shelling out to `which +# python`. The legacy shim returned a Git-Bash-style POSIX path on Windows +# GHA runners (e.g. `/c/hostedtoolcache/.../python` with no `.exe`), which +# pybind11's bundled `FindPythonLibsNew.cmake` then failed to invoke +# (`Python config failure`). FindPython3 uses each platform's native +# discovery (py launcher / registry / venv / PATH) and returns a path the +# rest of the build can actually exec. +# +# Resolution order: +# 1. -DPYTHON_EXECUTABLE= (or a parent project setting it before +# add_subdirectory) is honoured by seeding Python3_EXECUTABLE. +# 2. Otherwise FindPython3 picks the active interpreter (venv, etc.). +# +# `Development.Module` (CMake 3.18+) is the minimal dev component needed +# to compile a Python extension; we don't link against libpython itself. +# --------------------------------------------------------------------------- +if(PYTHON_EXECUTABLE AND NOT Python3_EXECUTABLE) + set(Python3_EXECUTABLE "${PYTHON_EXECUTABLE}" CACHE FILEPATH + "Python interpreter used by OVR (seeded from PYTHON_EXECUTABLE)" FORCE) endif() -if("${PYTHON_EXECUTABLE}" STREQUAL "") -message(FATAL_ERROR "Python not found — pass -DPYTHON_EXECUTABLE= or activate a venv") -else() + +find_package(Python3 COMPONENTS Interpreter Development.Module REQUIRED) + +# Mirror back into PYTHON_EXECUTABLE so the legacy variable name still +# works for downstream consumers (incl. the torch ABI probe below). +set(PYTHON_EXECUTABLE "${Python3_EXECUTABLE}" CACHE FILEPATH + "Python interpreter used by OVR" FORCE) message(STATUS "PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}") -endif() # _GLIBCXX_USE_CXX11_ABI policy # ------------------------------------------------------------------------- @@ -92,6 +111,13 @@ endif() # ------------------------------------------------------------------ # import pybind11 # ------------------------------------------------------------------ +# Tell pybind11 to use CMake's modern FindPython (which we just ran via +# FindPython3) instead of its bundled `FindPythonLibsNew.cmake`. Without +# this, pybind11 re-discovers Python through the legacy path and on +# Windows trips over `PYTHON_EXECUTABLE` paths that don't have `.exe`. +set(PYBIND11_FINDPYTHON ON CACHE BOOL + "pybind11: use CMake's FindPython instead of FindPythonLibsNew" FORCE) + include(FetchContent) FetchContent_Declare(pybind11 GIT_REPOSITORY https://github.com/pybind/pybind11.git diff --git a/cmake/configure_tests.cmake b/cmake/configure_tests.cmake new file mode 100644 index 0000000..967c2aa --- /dev/null +++ b/cmake/configure_tests.cmake @@ -0,0 +1,217 @@ +# ======================================================================== # +# OVR unit-test scaffolding # +# # +# Fetches doctest at configure time (no extra submodule), exposes # +# `doctest_discover_tests` (from doctest's own cmake/ dir), and provides # +# the `ovr_add_cpp_test()` helper used by tests/cpp/CMakeLists.txt. # +# # +# GPU-labelled tests are gated via CTest fixtures so they auto-skip on # +# machines without an NVIDIA GPU (see the `gpu_probe` executable below). # +# ======================================================================== # + +include_guard(GLOBAL) + +include(FetchContent) + +set(DOCTEST_VERSION "v2.4.11") + +FetchContent_Declare( + doctest + GIT_REPOSITORY https://github.com/doctest/doctest.git + GIT_TAG ${DOCTEST_VERSION} + GIT_SHALLOW ON +) + +# Keep doctest quiet: we don't want its own test targets or install rules. +set(DOCTEST_WITH_TESTS OFF CACHE BOOL "" FORCE) +set(DOCTEST_WITH_MAIN_IN_STATIC_LIB OFF CACHE BOOL "" FORCE) +set(DOCTEST_NO_INSTALL ON CACHE BOOL "" FORCE) + +FetchContent_MakeAvailable(doctest) + +# Expose doctest's CMake helper module (doctest_discover_tests). +list(APPEND CMAKE_MODULE_PATH "${doctest_SOURCE_DIR}/scripts/cmake") +include(doctest) + +# -------------------------------------------------------------------------- +# ovr_add_cpp_test( +# SOURCES +# [LINK ] +# [DEFS ] +# [GPU] # label the test "gpu" and require gpu_probe +# [LABELS ]) +# -------------------------------------------------------------------------- +function(ovr_add_cpp_test NAME) + set(_options GPU) + set(_one_value) + set(_multi SOURCES LINK DEFS LABELS) + cmake_parse_arguments(_T "${_options}" "${_one_value}" "${_multi}" ${ARGN}) + + if(NOT _T_SOURCES) + message(FATAL_ERROR "ovr_add_cpp_test(${NAME}): SOURCES is required") + endif() + + add_executable(${NAME} ${_T_SOURCES}) + target_link_libraries(${NAME} PRIVATE doctest::doctest ${_T_LINK}) + target_compile_definitions(${NAME} PRIVATE ${_T_DEFS}) + target_compile_features(${NAME} PRIVATE cxx_std_17) + + # Keep test binaries grouped under /tests/ for easy discovery. + set_target_properties(${NAME} PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests" + ) + + # ----- Windows DLL staging ----------------------------------------------- + # On POSIX the test exes resolve their dependent shared libs via RPATH / + # the build's flat / layout, so this is a no-op there. + # + # On Windows the SHARED outputs (renderlib.dll, rendercommon.dll, glad.dll + # built here + the OSPRay/TBB closure pulled in by find_package) all land + # in // while these exes land in /tests//. + # Windows' loader searches the directory of the running exe first; that + # directory has none of those DLLs, so doctest_discover_tests's spawn of + # the freshly-built exe at PostBuildEvent time fails with 0xc0000135 + # (STATUS_DLL_NOT_FOUND) before main() runs - empty stdout, build fails. + # ctest-time invocations would hit the same wall. + # + # Stage the runtime closure next to each test exe. CMake's + # TARGET_RUNTIME_DLLS (3.21+) walks IMPORTED_LOCATION on linked imported / + # built SHARED targets. Some binary packages, notably OSPRay, also require + # sibling DLLs that are loaded by name and are not always represented in the + # imported target graph, so configure_oneapi.cmake records those explicitly + # in OVR_EXTRA_RUNTIME_DLLS. The $ wraps the empty TARGET_RUNTIME_DLLS + # case (e.g. gpu_probe links only cudart_static) so cmake -E doesn't trip on + # a zero-source copy. + if(WIN32 AND CMAKE_VERSION VERSION_GREATER_EQUAL "3.21") + add_custom_command(TARGET ${NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E + "$>,copy_if_different,true>" + "$" + "$" + COMMAND_EXPAND_LISTS + VERBATIM + ) + get_property(_ovr_extra_runtime_dlls GLOBAL PROPERTY OVR_EXTRA_RUNTIME_DLLS) + if(_ovr_extra_runtime_dlls) + list(REMOVE_DUPLICATES _ovr_extra_runtime_dlls) + add_custom_command(TARGET ${NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${_ovr_extra_runtime_dlls} + "$" + COMMAND_EXPAND_LISTS + VERBATIM + ) + endif() + endif() + + # Inherit coverage flags if enabled + if(OVR_ENABLE_COVERAGE) + ovr_apply_coverage_flags(${NAME}) + endif() + + set(_labels cpp) + if(_T_GPU) + list(APPEND _labels gpu) + endif() + if(_T_LABELS) + list(APPEND _labels ${_T_LABELS}) + endif() + + # On Windows, do not use doctest_discover_tests. The doctest module bundled + # with v2.4.11 always executes the test binary as a POST_BUILD step to + # enumerate test cases; its DISCOVERY_MODE PRE_TEST option is not supported + # in that version. That makes the build itself fail with MSB3073 when the + # Windows loader cannot resolve a runtime DLL before main() starts. Register + # one CTest entry per executable on Windows instead. This preserves coverage + # and CI signal while keeping DLL-load failures in the test phase, after all + # runtime staging has completed. + if(WIN32) + add_test(NAME ${NAME} + COMMAND "$" + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + ) + set_tests_properties(${NAME} PROPERTIES + LABELS "${_labels}" + ) + else() + # TEST_PREFIX is required so each registered CTest name starts with + # "." (e.g. "test_serializer_json.create_json_scene: ..."). Other + # CMake glue (tests/cpp/gpu_fixture_attach.cmake.in) attaches per-binary + # FIXTURES_REQUIRED by matching this prefix; without it the regex never + # fires and the fixture dependency silently never attaches. + doctest_discover_tests(${NAME} + ADD_LABELS 1 + TEST_PREFIX "${NAME}." + PROPERTIES LABELS "${_labels}" + ) + endif() + + # Tie GPU tests to the gpu_probe fixture (defined once below) so CTest + # auto-skips them when no CUDA device is available. + if(_T_GPU) + # Read back the discovered tests and add fixture dependency. + # doctest_discover_tests creates a CTest script that registers tests at + # ctest-time, so we attach FIXTURES_REQUIRED by label instead. + set_property(GLOBAL APPEND PROPERTY OVR_GPU_TEST_TARGETS ${NAME}) + endif() +endfunction() + +# -------------------------------------------------------------------------- +# gpu_probe: a tiny helper executable that exits 0 iff at least one CUDA +# device is visible. Wired as a CTest FIXTURES_SETUP so gpu-labelled tests +# auto-skip on hostless/driverless machines. +# -------------------------------------------------------------------------- +function(ovr_setup_gpu_probe) + if(NOT OVR_BUILD_CUDA) + return() + endif() + + set(_probe_src "${CMAKE_BINARY_DIR}/tests/gpu_probe.cpp") + file(WRITE "${_probe_src}" [=[ +// Auto-generated: exits 0 if at least one CUDA device is present. +#include +#include +int main() { + int count = 0; + cudaError_t err = cudaGetDeviceCount(&count); + if (err != cudaSuccess || count <= 0) { + std::fprintf(stderr, "gpu_probe: no CUDA device (err=%d, count=%d)\n", + (int)err, count); + return 1; + } + return 0; +} +]=]) + + add_executable(gpu_probe "${_probe_src}") + target_link_libraries(gpu_probe PRIVATE CUDA::cudart_static) + set_target_properties(gpu_probe PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests" + ) + + # Mirror the DLL-staging the cpp tests get (see ovr_add_cpp_test). Today + # gpu_probe only links cudart_static so the closure is empty, but a future + # tweak that pulls in a SHARED dep would otherwise break the same way. + if(WIN32 AND CMAKE_VERSION VERSION_GREATER_EQUAL "3.21") + add_custom_command(TARGET gpu_probe POST_BUILD + COMMAND ${CMAKE_COMMAND} -E + "$>,copy_if_different,true>" + "$" + "$" + COMMAND_EXPAND_LISTS + VERBATIM + ) + endif() + + add_test(NAME gpu_probe COMMAND gpu_probe) + set_tests_properties(gpu_probe PROPERTIES + FIXTURES_SETUP gpu_available + LABELS "gpu_probe" + # Treat exit code 1 ("no CUDA device on this host") as Skipped, not + # Failed. The fixture is still marked unavailable so dependent gpu- + # labelled tests auto-skip - the only difference is that ctest itself + # no longer returns non-zero on GPU-less hosts (CI runners, coverage + # jobs that build with OptiX on but have no driver, ...). + SKIP_RETURN_CODE 1 + ) +endfunction() diff --git a/extern/bin2c/CMakeLists.txt b/extern/bin2c/CMakeLists.txt index 25536d0..2f86436 100644 --- a/extern/bin2c/CMakeLists.txt +++ b/extern/bin2c/CMakeLists.txt @@ -6,14 +6,14 @@ project(bin2c-test) # Compile bin2c obviously add_executable(bin2c bin2c.c) target_compile_definitions(bin2c PRIVATE _CRT_SECURE_NO_WARNINGS) -# # Create our testing program -# add_executable(test test/main.cpp) +# Create our testing program +add_executable(bin2c_test test/main.cpp) -# # The testing program needs to read data from 'test/test.txt' -# add_custom_target(bin2c_run -# COMMAND bin2c -o test/embeded.h -n target test/test.txt -# WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} -# COMMENT "generate embeded file in ${CMAKE_CURRENT_SOURCE_DIR}" -# SOURCES test/main.cpp -# ) -# add_dependencies(test bin2c_run) +# The testing program needs to read data from 'test/test.txt' +add_custom_target(bin2c_run + COMMAND bin2c -o test/embeded.h -n target test/test.txt + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMENT "generate embeded file in ${CMAKE_CURRENT_SOURCE_DIR}" + SOURCES test/main.cpp +) +add_dependencies(bin2c_test bin2c_run) diff --git a/extern/configure.cmake b/extern/configure.cmake index 950346e..191d344 100644 --- a/extern/configure.cmake +++ b/extern/configure.cmake @@ -71,7 +71,7 @@ # # for building render apps # add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/glfwapp EXCLUDE_FROM_ALL) -# list(APPEND GFX_LIBRARIES glfwApp) +# list(APPEND GFX_LIBRARIES glfwapp) # endif() diff --git a/extern/dep_json.cmake b/extern/dep_json.cmake new file mode 100644 index 0000000..cf80a2e --- /dev/null +++ b/extern/dep_json.cmake @@ -0,0 +1,58 @@ +# ======================================================================== # +# Copyright 2019-2026 Qi Wu # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +# ======================================================================== # +# +# nlohmann/json (formerly vendored at extern/json/json.hpp). Pinned to the +# same v3.10.4 the embedded copy was at, so this swap is intended to be +# behaviour-preserving. Provides the INTERFACE target `nlohmann_json` (and +# its alias `nlohmann_json::nlohmann_json`). +# +# OVR sources continue to use `#include `. We synthesise a +# tiny compat header at `/json_compat/json/json.hpp` that just +# forwards to the upstream ``, and stitch the compat +# directory into the nlohmann_json INTERFACE target. Result: every place +# that links nlohmann_json gets both `` (canonical) +# and `` (legacy) for free, without touching call sites. +# +# `JSON_BuildTests=OFF` keeps the upstream repo from registering its 1k+ +# test cases in our CTest namespace; `JSON_Install=OFF` keeps its install +# rules out of our `ovrwheel` install component. +include(FetchContent) + +set(JSON_BuildTests OFF CACHE BOOL "" FORCE) +set(JSON_Install OFF CACHE BOOL "" FORCE) +mark_as_advanced(JSON_BuildTests JSON_Install) + +FetchContent_Declare(nlohmann_json + GIT_REPOSITORY https://github.com/nlohmann/json.git + GIT_TAG v3.10.4 + GIT_SHALLOW ON +) +FetchContent_MakeAvailable(nlohmann_json) + +# Synthesise the `` compat shim. file(WRITE) is idempotent +# at configure time, so this costs nothing on rebuilds. +set(_OVR_JSON_COMPAT_DIR "${CMAKE_BINARY_DIR}/json_compat") +file(WRITE "${_OVR_JSON_COMPAT_DIR}/json/json.hpp" +"// Auto-generated by extern/dep_json.cmake. Do not edit. +// +// This is the legacy include path OVR has always used; the actual +// implementation comes from the FetchContent'd nlohmann/json v3.10.4. +#pragma once +#include +") +target_include_directories(nlohmann_json INTERFACE + $ +) diff --git a/extern/dep_opengl.cmake b/extern/dep_opengl.cmake index d004cd5..70b24f0 100644 --- a/extern/dep_opengl.cmake +++ b/extern/dep_opengl.cmake @@ -33,8 +33,11 @@ if(OVR_BUILD_OPENGL) include(dep_imgui) list(APPEND GFX_LIBRARIES imgui) - # for building render apps - add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/glfwapp EXCLUDE_FROM_ALL) - list(APPEND GFX_LIBRARIES glfwApp) + # NOTE: `glfwapp` is intentionally NOT in GFX_LIBRARIES. It's a + # higher-level wrapper that *consumes* GFX_LIBRARIES; including it + # here would create a self-referencing list (glfwapp links + # ${GFX_LIBRARIES} which contains glfwapp) and force `imgui PRIVATE + # ${GFX_LIBRARIES}` to link its own consumer. Apps that want the + # full shim should link `glfwapp` directly (see apps/CMakeLists.txt). endif() diff --git a/extern/dep_stb.cmake b/extern/dep_stb.cmake new file mode 100644 index 0000000..70b57cd --- /dev/null +++ b/extern/dep_stb.cmake @@ -0,0 +1,43 @@ +# ======================================================================== # +# Copyright 2019-2026 Qi Wu # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +# ======================================================================== # +# +# nothings/stb (formerly vendored at extern/stbi/). Upstream: +# https://github.com/nothings/stb +# +# Pinned to commit 5736b15f7ea0ffb08dd38af21067c314d6a3aae9 (mid-2023), +# which ships stb_image.h v2.29 + stb_image_write.h v1.16 - newer than +# the vendored copies (v2.25 / v1.14) but API-compatible. +# +# Used by `ovr/common/imageio.cpp`. The repo doesn't tag releases, so +# the pin is a commit hash; bump deliberately when you want a newer +# version. We bypass the upstream CMakeLists.txt (which builds the +# many test/example executables under tests/) by populating the source +# dir directly and exposing it as a header-only INTERFACE target. +include(FetchContent) + +FetchContent_Declare(stb + GIT_REPOSITORY https://github.com/nothings/stb.git + GIT_TAG 5736b15f7ea0ffb08dd38af21067c314d6a3aae9 +) +FetchContent_GetProperties(stb) +if(NOT stb_POPULATED) + FetchContent_Populate(stb) +endif() + +add_library(stb INTERFACE) +target_include_directories(stb INTERFACE + $ +) diff --git a/extern/dep_tinyexr.cmake b/extern/dep_tinyexr.cmake new file mode 100644 index 0000000..b9e7395 --- /dev/null +++ b/extern/dep_tinyexr.cmake @@ -0,0 +1,66 @@ +# ======================================================================== # +# Copyright 2019-2026 Qi Wu # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +# ======================================================================== # +# +# tinyexr (formerly vendored at extern/tinyexr/). Pinned to v1.0.8. +# Upstream: https://github.com/syoyo/tinyexr +# +# Gated by `OVR_BUILD_TINYEXR` (default ON to preserve current behavior). +# When ON, exposes the `tinyexr` INTERFACE target which `rendercommon` +# links to provide EXR read/write via `ovr/common/imageio.cpp`. When OFF, +# the fetch is skipped, the target is not created, and `imageio.cpp` +# compiles without the EXR code path (a `.exr` filename then becomes a +# clear runtime error rather than a silent no-op). +# +# Upstream v1.0+ moved miniz to `deps/miniz/`, so we add both the repo +# root (for `tinyexr.h`) and the miniz subdir (for `miniz.c` which +# imageio.cpp pulls in to provide the implementation) to the include +# path. +# +# We bypass tinyexr's own CMakeLists.txt (FetchContent_Populate, not +# _MakeAvailable) because it builds a CLI test executable + emits install +# rules - both unwanted in our build/wheel. +option(OVR_BUILD_TINYEXR "Fetch tinyexr via FetchContent and expose it as the `tinyexr` INTERFACE target (enables EXR I/O in rendercommon)" ON) + +if(OVR_BUILD_TINYEXR) + include(FetchContent) + + FetchContent_Declare(tinyexr + GIT_REPOSITORY https://github.com/syoyo/tinyexr.git + GIT_TAG v1.0.8 + GIT_SHALLOW ON + ) + FetchContent_GetProperties(tinyexr) + if(NOT tinyexr_POPULATED) + FetchContent_Populate(tinyexr) + endif() + + add_library(tinyexr INTERFACE) + target_include_directories(tinyexr INTERFACE + $ + $ + ) + + # Modern tinyexr.h calls into miniz (`mz_compress`, `mz_compressBound`, + # `mz_uncompress`) but only declares them via `` - the user must + # provide the implementation. We propagate `miniz.c` as an INTERFACE + # source so each consumer compiles it as C (CMake picks the language + # from the .c extension), which keeps tentative-definition handling + # C-style and avoids the C++ redefinition errors that occur when + # `miniz.c` is `#include`d inside a `.cpp` TU. + target_sources(tinyexr INTERFACE + $ + ) +endif() diff --git a/extern/dep_tinygltf.cmake b/extern/dep_tinygltf.cmake new file mode 100644 index 0000000..c84e294 --- /dev/null +++ b/extern/dep_tinygltf.cmake @@ -0,0 +1,66 @@ +# ======================================================================== # +# Copyright 2019-2026 Qi Wu # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +# ======================================================================== # +# +# tinygltf (formerly vendored at extern/tinygltf/). Pinned to v2.5.0 to +# match the version that was previously checked in. Upstream: +# https://github.com/syoyo/tinygltf +# +# Gated by `OVR_BUILD_TINYGLTF`. Consumers do +# `target_link_libraries(my_target PRIVATE tinygltf)` and +# `#include `. +# +# Note the namespaced include path: tinygltf bundles its own copies of +# `stb_image.h`, `stb_image_write.h`, and `json.hpp` at the upstream +# repo root. Putting that root on the consumer's include path directly +# would shadow our own `dep_stb` / `dep_json` (or vice versa) depending +# on `target_link_libraries` order - subtle and fragile. We sidestep it +# by mirroring the upstream tree into `build/tinygltf_compat/tinygltf/` +# and only exposing the parent on the include path. tinygltf's internal +# quote-includes (`#include "stb_image.h"`) still resolve to its private +# bundled copies because quote-include search starts from the file's +# own dir. +# +# We bypass tinygltf's own CMakeLists.txt (via the bare +# FetchContent_Populate path rather than _MakeAvailable) because that +# upstream CMakeLists builds a loader_example executable and emits install +# rules - both unwanted noise for our build/wheel. +option(OVR_BUILD_TINYGLTF "Fetch tinygltf via FetchContent and expose it as the `tinygltf` INTERFACE target" ON) + +if(OVR_BUILD_TINYGLTF) + include(FetchContent) + + FetchContent_Declare(tinygltf + GIT_REPOSITORY https://github.com/syoyo/tinygltf.git + GIT_TAG v2.5.0 + GIT_SHALLOW ON + ) + FetchContent_GetProperties(tinygltf) + if(NOT tinygltf_POPULATED) + FetchContent_Populate(tinygltf) + endif() + + set(_OVR_TINYGLTF_COMPAT_DIR "${CMAKE_BINARY_DIR}/tinygltf_compat") + execute_process( + COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different + "${tinygltf_SOURCE_DIR}" + "${_OVR_TINYGLTF_COMPAT_DIR}/tinygltf" + ) + + add_library(tinygltf INTERFACE) + target_include_directories(tinygltf INTERFACE + $ + ) +endif() diff --git a/extern/dep_tinyobj.cmake b/extern/dep_tinyobj.cmake new file mode 100644 index 0000000..075efb9 --- /dev/null +++ b/extern/dep_tinyobj.cmake @@ -0,0 +1,59 @@ +# ======================================================================== # +# Copyright 2019-2026 Qi Wu # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +# ======================================================================== # +# +# tinyobjloader (formerly vendored at extern/tinyobj/). Pinned to v1.0.6 +# to match the timeframe of the previously checked-in copy. Upstream: +# https://github.com/tinyobjloader/tinyobjloader +# +# Gated by `OVR_BUILD_TINYOBJ`. Consumers do +# `target_link_libraries(my_target PRIVATE tinyobj)` and +# `#include `. +# +# tinyobj doesn't bundle any third-party deps (no stb / json), so the +# `tinyobj/` subdir scoping here is purely for symmetry with +# `dep_tinygltf` - a defensive pattern that keeps each FetchContent +# target isolated to its own namespaced include prefix. +# +# Bypasses upstream's CMakeLists.txt (which builds example/test +# executables) by populating the source dir directly and exposing it as +# a header-only INTERFACE target. +option(OVR_BUILD_TINYOBJ "Fetch tinyobjloader via FetchContent and expose it as the `tinyobj` INTERFACE target" ON) + +if(OVR_BUILD_TINYOBJ) + include(FetchContent) + + FetchContent_Declare(tinyobj + GIT_REPOSITORY https://github.com/tinyobjloader/tinyobjloader.git + GIT_TAG v1.0.6 + GIT_SHALLOW ON + ) + FetchContent_GetProperties(tinyobj) + if(NOT tinyobj_POPULATED) + FetchContent_Populate(tinyobj) + endif() + + set(_OVR_TINYOBJ_COMPAT_DIR "${CMAKE_BINARY_DIR}/tinyobj_compat") + execute_process( + COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different + "${tinyobj_SOURCE_DIR}" + "${_OVR_TINYOBJ_COMPAT_DIR}/tinyobj" + ) + + add_library(tinyobj INTERFACE) + target_include_directories(tinyobj INTERFACE + $ + ) +endif() diff --git a/extern/glfwapp/CMakeLists.txt b/extern/glfwapp/CMakeLists.txt index bf209f1..bc09600 100644 --- a/extern/glfwapp/CMakeLists.txt +++ b/extern/glfwapp/CMakeLists.txt @@ -30,11 +30,28 @@ # limitations under the License. # # ======================================================================== # -add_library(glfwApp STATIC - GLFWApp.h GLFWApp.cpp +# Sources nest under `glfwapp/` so consumers' `#include ` +# resolves through this target's own dir as the include root (no `..` +# parent traversal required). + +# Header-only target that exposes `` to consumers. Always +# built (no OpenGL deps) so that offline-render apps like `renderbatch` +# can `#include ` (a pure CameraFrame struct) +# without dragging the full GLFW/imgui stack onto their link line. +add_library(glfwapp_headers INTERFACE) +target_include_directories(glfwapp_headers INTERFACE + $ ) -target_link_libraries(glfwApp PUBLIC imgui gdt ${GFX_LIBRARIES}) -target_compile_definitions(glfwApp PRIVATE GLFWAPP_USE_OPENGL2) -if (UNIX) - set_target_properties(glfwApp PROPERTIES POSITION_INDEPENDENT_CODE ON) +target_link_libraries(glfwapp_headers INTERFACE gdt) + +# Full GLFW + imgui app shim - only built when OVR_BUILD_OPENGL is ON +# (otherwise the imgui/glfw/GFX_LIBRARIES targets it depends on don't +# exist). Consumers linking glfwapp get the headers transitively. +if(OVR_BUILD_OPENGL) + add_library(glfwapp STATIC glfwapp/GLFWApp.h glfwapp/GLFWApp.cpp) + target_link_libraries(glfwapp PUBLIC glfwapp_headers imgui gdt ${GFX_LIBRARIES}) + target_compile_definitions(glfwapp PRIVATE GLFWAPP_USE_OPENGL2) + if (UNIX) + set_target_properties(glfwapp PROPERTIES POSITION_INDEPENDENT_CODE ON) + endif() endif() diff --git a/extern/glfwapp/GLFWApp.cpp b/extern/glfwapp/glfwapp/GLFWApp.cpp similarity index 100% rename from extern/glfwapp/GLFWApp.cpp rename to extern/glfwapp/glfwapp/GLFWApp.cpp diff --git a/extern/glfwapp/GLFWApp.h b/extern/glfwapp/glfwapp/GLFWApp.h similarity index 100% rename from extern/glfwapp/GLFWApp.h rename to extern/glfwapp/glfwapp/GLFWApp.h diff --git a/extern/glfwapp/camera_frame.h b/extern/glfwapp/glfwapp/camera_frame.h similarity index 100% rename from extern/glfwapp/camera_frame.h rename to extern/glfwapp/glfwapp/camera_frame.h diff --git a/extern/json/LICENSE.MIT b/extern/json/LICENSE.MIT deleted file mode 100644 index f0622d6..0000000 --- a/extern/json/LICENSE.MIT +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2013-2021 Niels Lohmann - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/extern/json/json.hpp b/extern/json/json.hpp deleted file mode 100644 index 58c7a1d..0000000 --- a/extern/json/json.hpp +++ /dev/null @@ -1,26713 +0,0 @@ -/* - __ _____ _____ _____ - __| | __| | | | JSON for Modern C++ -| | |__ | | | | | | version 3.10.4 -|_____|_____|_____|_|___| https://github.com/nlohmann/json - -Licensed under the MIT License . -SPDX-License-Identifier: MIT -Copyright (c) 2013-2019 Niels Lohmann . - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#ifndef INCLUDE_NLOHMANN_JSON_HPP_ -#define INCLUDE_NLOHMANN_JSON_HPP_ - -#define NLOHMANN_JSON_VERSION_MAJOR 3 -#define NLOHMANN_JSON_VERSION_MINOR 10 -#define NLOHMANN_JSON_VERSION_PATCH 4 - -#include // all_of, find, for_each -#include // nullptr_t, ptrdiff_t, size_t -#include // hash, less -#include // initializer_list -#ifndef JSON_NO_IO - #include // istream, ostream -#endif // JSON_NO_IO -#include // random_access_iterator_tag -#include // unique_ptr -#include // accumulate -#include // string, stoi, to_string -#include // declval, forward, move, pair, swap -#include // vector - -// #include - - -#include -#include - -// #include - - -#include // transform -#include // array -#include // forward_list -#include // inserter, front_inserter, end -#include // map -#include // string -#include // tuple, make_tuple -#include // is_arithmetic, is_same, is_enum, underlying_type, is_convertible -#include // unordered_map -#include // pair, declval -#include // valarray - -// #include - - -#include // exception -#include // runtime_error -#include // to_string -#include // vector - -// #include - - -#include // array -#include // size_t -#include // uint8_t -#include // string - -namespace nlohmann -{ -namespace detail -{ -/////////////////////////// -// JSON type enumeration // -/////////////////////////// - -/*! -@brief the JSON type enumeration - -This enumeration collects the different JSON types. It is internally used to -distinguish the stored values, and the functions @ref basic_json::is_null(), -@ref basic_json::is_object(), @ref basic_json::is_array(), -@ref basic_json::is_string(), @ref basic_json::is_boolean(), -@ref basic_json::is_number() (with @ref basic_json::is_number_integer(), -@ref basic_json::is_number_unsigned(), and @ref basic_json::is_number_float()), -@ref basic_json::is_discarded(), @ref basic_json::is_primitive(), and -@ref basic_json::is_structured() rely on it. - -@note There are three enumeration entries (number_integer, number_unsigned, and -number_float), because the library distinguishes these three types for numbers: -@ref basic_json::number_unsigned_t is used for unsigned integers, -@ref basic_json::number_integer_t is used for signed integers, and -@ref basic_json::number_float_t is used for floating-point numbers or to -approximate integers which do not fit in the limits of their respective type. - -@sa see @ref basic_json::basic_json(const value_t value_type) -- create a JSON -value with the default value for a given type - -@since version 1.0.0 -*/ -enum class value_t : std::uint8_t -{ - null, ///< null value - object, ///< object (unordered set of name/value pairs) - array, ///< array (ordered collection of values) - string, ///< string value - boolean, ///< boolean value - number_integer, ///< number value (signed integer) - number_unsigned, ///< number value (unsigned integer) - number_float, ///< number value (floating-point) - binary, ///< binary array (ordered collection of bytes) - discarded ///< discarded by the parser callback function -}; - -/*! -@brief comparison operator for JSON types - -Returns an ordering that is similar to Python: -- order: null < boolean < number < object < array < string < binary -- furthermore, each type is not smaller than itself -- discarded values are not comparable -- binary is represented as a b"" string in python and directly comparable to a - string; however, making a binary array directly comparable with a string would - be surprising behavior in a JSON file. - -@since version 1.0.0 -*/ -inline bool operator<(const value_t lhs, const value_t rhs) noexcept -{ - static constexpr std::array order = {{ - 0 /* null */, 3 /* object */, 4 /* array */, 5 /* string */, - 1 /* boolean */, 2 /* integer */, 2 /* unsigned */, 2 /* float */, - 6 /* binary */ - } - }; - - const auto l_index = static_cast(lhs); - const auto r_index = static_cast(rhs); - return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index]; -} -} // namespace detail -} // namespace nlohmann - -// #include - - -#include -// #include - - -#include // declval, pair -// #include - - -/* Hedley - https://nemequ.github.io/hedley - * Created by Evan Nemerson - * - * To the extent possible under law, the author(s) have dedicated all - * copyright and related and neighboring rights to this software to - * the public domain worldwide. This software is distributed without - * any warranty. - * - * For details, see . - * SPDX-License-Identifier: CC0-1.0 - */ - -#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15) -#if defined(JSON_HEDLEY_VERSION) - #undef JSON_HEDLEY_VERSION -#endif -#define JSON_HEDLEY_VERSION 15 - -#if defined(JSON_HEDLEY_STRINGIFY_EX) - #undef JSON_HEDLEY_STRINGIFY_EX -#endif -#define JSON_HEDLEY_STRINGIFY_EX(x) #x - -#if defined(JSON_HEDLEY_STRINGIFY) - #undef JSON_HEDLEY_STRINGIFY -#endif -#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x) - -#if defined(JSON_HEDLEY_CONCAT_EX) - #undef JSON_HEDLEY_CONCAT_EX -#endif -#define JSON_HEDLEY_CONCAT_EX(a,b) a##b - -#if defined(JSON_HEDLEY_CONCAT) - #undef JSON_HEDLEY_CONCAT -#endif -#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b) - -#if defined(JSON_HEDLEY_CONCAT3_EX) - #undef JSON_HEDLEY_CONCAT3_EX -#endif -#define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c - -#if defined(JSON_HEDLEY_CONCAT3) - #undef JSON_HEDLEY_CONCAT3 -#endif -#define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c) - -#if defined(JSON_HEDLEY_VERSION_ENCODE) - #undef JSON_HEDLEY_VERSION_ENCODE -#endif -#define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision)) - -#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR) - #undef JSON_HEDLEY_VERSION_DECODE_MAJOR -#endif -#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000) - -#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR) - #undef JSON_HEDLEY_VERSION_DECODE_MINOR -#endif -#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000) - -#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION) - #undef JSON_HEDLEY_VERSION_DECODE_REVISION -#endif -#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000) - -#if defined(JSON_HEDLEY_GNUC_VERSION) - #undef JSON_HEDLEY_GNUC_VERSION -#endif -#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__) - #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) -#elif defined(__GNUC__) - #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0) -#endif - -#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK) - #undef JSON_HEDLEY_GNUC_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_GNUC_VERSION) - #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_MSVC_VERSION) - #undef JSON_HEDLEY_MSVC_VERSION -#endif -#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL) - #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100) -#elif defined(_MSC_FULL_VER) && !defined(__ICL) - #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10) -#elif defined(_MSC_VER) && !defined(__ICL) - #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0) -#endif - -#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK) - #undef JSON_HEDLEY_MSVC_VERSION_CHECK -#endif -#if !defined(JSON_HEDLEY_MSVC_VERSION) - #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0) -#elif defined(_MSC_VER) && (_MSC_VER >= 1400) - #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch))) -#elif defined(_MSC_VER) && (_MSC_VER >= 1200) - #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch))) -#else - #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor))) -#endif - -#if defined(JSON_HEDLEY_INTEL_VERSION) - #undef JSON_HEDLEY_INTEL_VERSION -#endif -#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL) - #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE) -#elif defined(__INTEL_COMPILER) && !defined(__ICL) - #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0) -#endif - -#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK) - #undef JSON_HEDLEY_INTEL_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_INTEL_VERSION) - #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_INTEL_CL_VERSION) - #undef JSON_HEDLEY_INTEL_CL_VERSION -#endif -#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL) - #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0) -#endif - -#if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK) - #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_INTEL_CL_VERSION) - #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_PGI_VERSION) - #undef JSON_HEDLEY_PGI_VERSION -#endif -#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__) - #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__) -#endif - -#if defined(JSON_HEDLEY_PGI_VERSION_CHECK) - #undef JSON_HEDLEY_PGI_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_PGI_VERSION) - #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_SUNPRO_VERSION) - #undef JSON_HEDLEY_SUNPRO_VERSION -#endif -#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000) - #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10) -#elif defined(__SUNPRO_C) - #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf) -#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000) - #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10) -#elif defined(__SUNPRO_CC) - #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf) -#endif - -#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK) - #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_SUNPRO_VERSION) - #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION) - #undef JSON_HEDLEY_EMSCRIPTEN_VERSION -#endif -#if defined(__EMSCRIPTEN__) - #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__) -#endif - -#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK) - #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION) - #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_ARM_VERSION) - #undef JSON_HEDLEY_ARM_VERSION -#endif -#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION) - #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100) -#elif defined(__CC_ARM) && defined(__ARMCC_VERSION) - #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100) -#endif - -#if defined(JSON_HEDLEY_ARM_VERSION_CHECK) - #undef JSON_HEDLEY_ARM_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_ARM_VERSION) - #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_IBM_VERSION) - #undef JSON_HEDLEY_IBM_VERSION -#endif -#if defined(__ibmxl__) - #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__) -#elif defined(__xlC__) && defined(__xlC_ver__) - #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff) -#elif defined(__xlC__) - #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0) -#endif - -#if defined(JSON_HEDLEY_IBM_VERSION_CHECK) - #undef JSON_HEDLEY_IBM_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_IBM_VERSION) - #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_VERSION) - #undef JSON_HEDLEY_TI_VERSION -#endif -#if \ - defined(__TI_COMPILER_VERSION__) && \ - ( \ - defined(__TMS470__) || defined(__TI_ARM__) || \ - defined(__MSP430__) || \ - defined(__TMS320C2000__) \ - ) -#if (__TI_COMPILER_VERSION__ >= 16000000) - #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif -#endif - -#if defined(JSON_HEDLEY_TI_VERSION_CHECK) - #undef JSON_HEDLEY_TI_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_VERSION) - #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_CL2000_VERSION) - #undef JSON_HEDLEY_TI_CL2000_VERSION -#endif -#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__) - #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif - -#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK) - #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_CL2000_VERSION) - #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_CL430_VERSION) - #undef JSON_HEDLEY_TI_CL430_VERSION -#endif -#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__) - #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif - -#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK) - #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_CL430_VERSION) - #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_ARMCL_VERSION) - #undef JSON_HEDLEY_TI_ARMCL_VERSION -#endif -#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__)) - #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif - -#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK) - #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_ARMCL_VERSION) - #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_CL6X_VERSION) - #undef JSON_HEDLEY_TI_CL6X_VERSION -#endif -#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__) - #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif - -#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK) - #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_CL6X_VERSION) - #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_CL7X_VERSION) - #undef JSON_HEDLEY_TI_CL7X_VERSION -#endif -#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__) - #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif - -#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK) - #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_CL7X_VERSION) - #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_CLPRU_VERSION) - #undef JSON_HEDLEY_TI_CLPRU_VERSION -#endif -#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__) - #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif - -#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK) - #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_CLPRU_VERSION) - #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_CRAY_VERSION) - #undef JSON_HEDLEY_CRAY_VERSION -#endif -#if defined(_CRAYC) - #if defined(_RELEASE_PATCHLEVEL) - #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL) - #else - #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0) - #endif -#endif - -#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK) - #undef JSON_HEDLEY_CRAY_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_CRAY_VERSION) - #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_IAR_VERSION) - #undef JSON_HEDLEY_IAR_VERSION -#endif -#if defined(__IAR_SYSTEMS_ICC__) - #if __VER__ > 1000 - #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000)) - #else - #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0) - #endif -#endif - -#if defined(JSON_HEDLEY_IAR_VERSION_CHECK) - #undef JSON_HEDLEY_IAR_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_IAR_VERSION) - #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TINYC_VERSION) - #undef JSON_HEDLEY_TINYC_VERSION -#endif -#if defined(__TINYC__) - #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100) -#endif - -#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK) - #undef JSON_HEDLEY_TINYC_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TINYC_VERSION) - #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_DMC_VERSION) - #undef JSON_HEDLEY_DMC_VERSION -#endif -#if defined(__DMC__) - #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf) -#endif - -#if defined(JSON_HEDLEY_DMC_VERSION_CHECK) - #undef JSON_HEDLEY_DMC_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_DMC_VERSION) - #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_COMPCERT_VERSION) - #undef JSON_HEDLEY_COMPCERT_VERSION -#endif -#if defined(__COMPCERT_VERSION__) - #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100) -#endif - -#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK) - #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_COMPCERT_VERSION) - #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_PELLES_VERSION) - #undef JSON_HEDLEY_PELLES_VERSION -#endif -#if defined(__POCC__) - #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0) -#endif - -#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK) - #undef JSON_HEDLEY_PELLES_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_PELLES_VERSION) - #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_MCST_LCC_VERSION) - #undef JSON_HEDLEY_MCST_LCC_VERSION -#endif -#if defined(__LCC__) && defined(__LCC_MINOR__) - #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__) -#endif - -#if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK) - #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_MCST_LCC_VERSION) - #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_GCC_VERSION) - #undef JSON_HEDLEY_GCC_VERSION -#endif -#if \ - defined(JSON_HEDLEY_GNUC_VERSION) && \ - !defined(__clang__) && \ - !defined(JSON_HEDLEY_INTEL_VERSION) && \ - !defined(JSON_HEDLEY_PGI_VERSION) && \ - !defined(JSON_HEDLEY_ARM_VERSION) && \ - !defined(JSON_HEDLEY_CRAY_VERSION) && \ - !defined(JSON_HEDLEY_TI_VERSION) && \ - !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \ - !defined(JSON_HEDLEY_TI_CL430_VERSION) && \ - !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \ - !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \ - !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \ - !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \ - !defined(__COMPCERT__) && \ - !defined(JSON_HEDLEY_MCST_LCC_VERSION) - #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION -#endif - -#if defined(JSON_HEDLEY_GCC_VERSION_CHECK) - #undef JSON_HEDLEY_GCC_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_GCC_VERSION) - #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_HAS_ATTRIBUTE) - #undef JSON_HEDLEY_HAS_ATTRIBUTE -#endif -#if \ - defined(__has_attribute) && \ - ( \ - (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \ - ) -# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute) -#else -# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE) - #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE -#endif -#if defined(__has_attribute) - #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) -#else - #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE) - #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE -#endif -#if defined(__has_attribute) - #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) -#else - #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE) - #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE -#endif -#if \ - defined(__has_cpp_attribute) && \ - defined(__cplusplus) && \ - (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) - #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute) -#else - #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0) -#endif - -#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS) - #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS -#endif -#if !defined(__cplusplus) || !defined(__has_cpp_attribute) - #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0) -#elif \ - !defined(JSON_HEDLEY_PGI_VERSION) && \ - !defined(JSON_HEDLEY_IAR_VERSION) && \ - (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \ - (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0)) - #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute) -#else - #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE) - #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE -#endif -#if defined(__has_cpp_attribute) && defined(__cplusplus) - #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) -#else - #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE) - #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE -#endif -#if defined(__has_cpp_attribute) && defined(__cplusplus) - #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) -#else - #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_HAS_BUILTIN) - #undef JSON_HEDLEY_HAS_BUILTIN -#endif -#if defined(__has_builtin) - #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin) -#else - #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN) - #undef JSON_HEDLEY_GNUC_HAS_BUILTIN -#endif -#if defined(__has_builtin) - #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) -#else - #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN) - #undef JSON_HEDLEY_GCC_HAS_BUILTIN -#endif -#if defined(__has_builtin) - #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) -#else - #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_HAS_FEATURE) - #undef JSON_HEDLEY_HAS_FEATURE -#endif -#if defined(__has_feature) - #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature) -#else - #define JSON_HEDLEY_HAS_FEATURE(feature) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE) - #undef JSON_HEDLEY_GNUC_HAS_FEATURE -#endif -#if defined(__has_feature) - #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) -#else - #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_FEATURE) - #undef JSON_HEDLEY_GCC_HAS_FEATURE -#endif -#if defined(__has_feature) - #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) -#else - #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_HAS_EXTENSION) - #undef JSON_HEDLEY_HAS_EXTENSION -#endif -#if defined(__has_extension) - #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension) -#else - #define JSON_HEDLEY_HAS_EXTENSION(extension) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION) - #undef JSON_HEDLEY_GNUC_HAS_EXTENSION -#endif -#if defined(__has_extension) - #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) -#else - #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION) - #undef JSON_HEDLEY_GCC_HAS_EXTENSION -#endif -#if defined(__has_extension) - #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) -#else - #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE) - #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE -#endif -#if defined(__has_declspec_attribute) - #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute) -#else - #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE) - #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE -#endif -#if defined(__has_declspec_attribute) - #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) -#else - #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE) - #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE -#endif -#if defined(__has_declspec_attribute) - #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) -#else - #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_HAS_WARNING) - #undef JSON_HEDLEY_HAS_WARNING -#endif -#if defined(__has_warning) - #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning) -#else - #define JSON_HEDLEY_HAS_WARNING(warning) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_WARNING) - #undef JSON_HEDLEY_GNUC_HAS_WARNING -#endif -#if defined(__has_warning) - #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) -#else - #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_WARNING) - #undef JSON_HEDLEY_GCC_HAS_WARNING -#endif -#if defined(__has_warning) - #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) -#else - #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if \ - (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ - defined(__clang__) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \ - JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \ - (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR)) - #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value) -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define JSON_HEDLEY_PRAGMA(value) __pragma(value) -#else - #define JSON_HEDLEY_PRAGMA(value) -#endif - -#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH) - #undef JSON_HEDLEY_DIAGNOSTIC_PUSH -#endif -#if defined(JSON_HEDLEY_DIAGNOSTIC_POP) - #undef JSON_HEDLEY_DIAGNOSTIC_POP -#endif -#if defined(__clang__) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") -#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") -#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push)) - #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop)) -#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop") -#elif \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") -#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") -#else - #define JSON_HEDLEY_DIAGNOSTIC_PUSH - #define JSON_HEDLEY_DIAGNOSTIC_POP -#endif - -/* JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ is for - HEDLEY INTERNAL USE ONLY. API subject to change without notice. */ -#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_) - #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ -#endif -#if defined(__cplusplus) -# if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat") -# if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions") -# if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions") -# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ - _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ - _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \ - xpr \ - JSON_HEDLEY_DIAGNOSTIC_POP -# else -# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ - _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ - xpr \ - JSON_HEDLEY_DIAGNOSTIC_POP -# endif -# else -# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ - xpr \ - JSON_HEDLEY_DIAGNOSTIC_POP -# endif -# endif -#endif -#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x -#endif - -#if defined(JSON_HEDLEY_CONST_CAST) - #undef JSON_HEDLEY_CONST_CAST -#endif -#if defined(__cplusplus) -# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast(expr)) -#elif \ - JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) -# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \ - ((T) (expr)); \ - JSON_HEDLEY_DIAGNOSTIC_POP \ - })) -#else -# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr)) -#endif - -#if defined(JSON_HEDLEY_REINTERPRET_CAST) - #undef JSON_HEDLEY_REINTERPRET_CAST -#endif -#if defined(__cplusplus) - #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast(expr)) -#else - #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr)) -#endif - -#if defined(JSON_HEDLEY_STATIC_CAST) - #undef JSON_HEDLEY_STATIC_CAST -#endif -#if defined(__cplusplus) - #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast(expr)) -#else - #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr)) -#endif - -#if defined(JSON_HEDLEY_CPP_CAST) - #undef JSON_HEDLEY_CPP_CAST -#endif -#if defined(__cplusplus) -# if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast") -# define JSON_HEDLEY_CPP_CAST(T, expr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \ - ((T) (expr)) \ - JSON_HEDLEY_DIAGNOSTIC_POP -# elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0) -# define JSON_HEDLEY_CPP_CAST(T, expr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("diag_suppress=Pe137") \ - JSON_HEDLEY_DIAGNOSTIC_POP -# else -# define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr)) -# endif -#else -# define JSON_HEDLEY_CPP_CAST(T, expr) (expr) -#endif - -#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED) - #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations") - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") -#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)") -#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786)) -#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445") -#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") -#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996)) -#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") -#elif \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718") -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)") -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)") -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215") -#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)") -#else - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED -#endif - -#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS) - #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") -#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)") -#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161)) -#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675") -#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"") -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068)) -#elif \ - JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") -#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161") -#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161") -#else - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS -#endif - -#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES) - #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes") - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"") -#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") -#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)") -#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292)) -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030)) -#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098") -#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097") -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)") -#elif \ - JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173") -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097") -#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097") -#else - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES -#endif - -#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL) - #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wcast-qual") - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"") -#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)") -#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") -#else - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL -#endif - -#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION) - #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wunused-function") - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"") -#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"") -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505)) -#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142") -#else - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION -#endif - -#if defined(JSON_HEDLEY_DEPRECATED) - #undef JSON_HEDLEY_DEPRECATED -#endif -#if defined(JSON_HEDLEY_DEPRECATED_FOR) - #undef JSON_HEDLEY_DEPRECATED_FOR -#endif -#if \ - JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since)) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement)) -#elif \ - (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) -#elif defined(__cplusplus) && (__cplusplus >= 201402L) - #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]]) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]]) -#elif \ - JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) - #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__)) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__)) -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated) -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated") - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated") -#else - #define JSON_HEDLEY_DEPRECATED(since) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) -#endif - -#if defined(JSON_HEDLEY_UNAVAILABLE) - #undef JSON_HEDLEY_UNAVAILABLE -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since))) -#else - #define JSON_HEDLEY_UNAVAILABLE(available_since) -#endif - -#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT) - #undef JSON_HEDLEY_WARN_UNUSED_RESULT -#endif -#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG) - #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) - #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__)) -#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L) - #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) - #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]]) -#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) - #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) - #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) -#elif defined(_Check_return_) /* SAL */ - #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_ - #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_ -#else - #define JSON_HEDLEY_WARN_UNUSED_RESULT - #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) -#endif - -#if defined(JSON_HEDLEY_SENTINEL) - #undef JSON_HEDLEY_SENTINEL -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position))) -#else - #define JSON_HEDLEY_SENTINEL(position) -#endif - -#if defined(JSON_HEDLEY_NO_RETURN) - #undef JSON_HEDLEY_NO_RETURN -#endif -#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_NO_RETURN __noreturn -#elif \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) -#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - #define JSON_HEDLEY_NO_RETURN _Noreturn -#elif defined(__cplusplus) && (__cplusplus >= 201103L) - #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]]) -#elif \ - JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) - #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) - #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return") -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) -#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus) - #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;") -#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) - #define JSON_HEDLEY_NO_RETURN __attribute((noreturn)) -#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) - #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) -#else - #define JSON_HEDLEY_NO_RETURN -#endif - -#if defined(JSON_HEDLEY_NO_ESCAPE) - #undef JSON_HEDLEY_NO_ESCAPE -#endif -#if JSON_HEDLEY_HAS_ATTRIBUTE(noescape) - #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__)) -#else - #define JSON_HEDLEY_NO_ESCAPE -#endif - -#if defined(JSON_HEDLEY_UNREACHABLE) - #undef JSON_HEDLEY_UNREACHABLE -#endif -#if defined(JSON_HEDLEY_UNREACHABLE_RETURN) - #undef JSON_HEDLEY_UNREACHABLE_RETURN -#endif -#if defined(JSON_HEDLEY_ASSUME) - #undef JSON_HEDLEY_ASSUME -#endif -#if \ - JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_ASSUME(expr) __assume(expr) -#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume) - #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr) -#elif \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) - #if defined(__cplusplus) - #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr) - #else - #define JSON_HEDLEY_ASSUME(expr) _nassert(expr) - #endif -#endif -#if \ - (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable() -#elif defined(JSON_HEDLEY_ASSUME) - #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0) -#endif -#if !defined(JSON_HEDLEY_ASSUME) - #if defined(JSON_HEDLEY_UNREACHABLE) - #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1))) - #else - #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr) - #endif -#endif -#if defined(JSON_HEDLEY_UNREACHABLE) - #if \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) - #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value)) - #else - #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE() - #endif -#else - #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value) -#endif -#if !defined(JSON_HEDLEY_UNREACHABLE) - #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0) -#endif - -JSON_HEDLEY_DIAGNOSTIC_PUSH -#if JSON_HEDLEY_HAS_WARNING("-Wpedantic") - #pragma clang diagnostic ignored "-Wpedantic" -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus) - #pragma clang diagnostic ignored "-Wc++98-compat-pedantic" -#endif -#if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0) - #if defined(__clang__) - #pragma clang diagnostic ignored "-Wvariadic-macros" - #elif defined(JSON_HEDLEY_GCC_VERSION) - #pragma GCC diagnostic ignored "-Wvariadic-macros" - #endif -#endif -#if defined(JSON_HEDLEY_NON_NULL) - #undef JSON_HEDLEY_NON_NULL -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) - #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__))) -#else - #define JSON_HEDLEY_NON_NULL(...) -#endif -JSON_HEDLEY_DIAGNOSTIC_POP - -#if defined(JSON_HEDLEY_PRINTF_FORMAT) - #undef JSON_HEDLEY_PRINTF_FORMAT -#endif -#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO) - #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check))) -#elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO) - #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check))) -#elif \ - JSON_HEDLEY_HAS_ATTRIBUTE(format) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check))) -#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0) - #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check)) -#else - #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) -#endif - -#if defined(JSON_HEDLEY_CONSTEXPR) - #undef JSON_HEDLEY_CONSTEXPR -#endif -#if defined(__cplusplus) - #if __cplusplus >= 201103L - #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr) - #endif -#endif -#if !defined(JSON_HEDLEY_CONSTEXPR) - #define JSON_HEDLEY_CONSTEXPR -#endif - -#if defined(JSON_HEDLEY_PREDICT) - #undef JSON_HEDLEY_PREDICT -#endif -#if defined(JSON_HEDLEY_LIKELY) - #undef JSON_HEDLEY_LIKELY -#endif -#if defined(JSON_HEDLEY_UNLIKELY) - #undef JSON_HEDLEY_UNLIKELY -#endif -#if defined(JSON_HEDLEY_UNPREDICTABLE) - #undef JSON_HEDLEY_UNPREDICTABLE -#endif -#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable) - #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr)) -#endif -#if \ - (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) -# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability)) -# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability)) -# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability)) -# define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 ) -# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 ) -#elif \ - (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) -# define JSON_HEDLEY_PREDICT(expr, expected, probability) \ - (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))) -# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \ - (__extension__ ({ \ - double hedley_probability_ = (probability); \ - ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \ - })) -# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \ - (__extension__ ({ \ - double hedley_probability_ = (probability); \ - ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \ - })) -# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) -# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) -#else -# define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)) -# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr)) -# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr)) -# define JSON_HEDLEY_LIKELY(expr) (!!(expr)) -# define JSON_HEDLEY_UNLIKELY(expr) (!!(expr)) -#endif -#if !defined(JSON_HEDLEY_UNPREDICTABLE) - #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5) -#endif - -#if defined(JSON_HEDLEY_MALLOC) - #undef JSON_HEDLEY_MALLOC -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_MALLOC __attribute__((__malloc__)) -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) - #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory") -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_MALLOC __declspec(restrict) -#else - #define JSON_HEDLEY_MALLOC -#endif - -#if defined(JSON_HEDLEY_PURE) - #undef JSON_HEDLEY_PURE -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) -# define JSON_HEDLEY_PURE __attribute__((__pure__)) -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) -# define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data") -#elif defined(__cplusplus) && \ - ( \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \ - ) -# define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;") -#else -# define JSON_HEDLEY_PURE -#endif - -#if defined(JSON_HEDLEY_CONST) - #undef JSON_HEDLEY_CONST -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(const) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_CONST __attribute__((__const__)) -#elif \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) - #define JSON_HEDLEY_CONST _Pragma("no_side_effect") -#else - #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE -#endif - -#if defined(JSON_HEDLEY_RESTRICT) - #undef JSON_HEDLEY_RESTRICT -#endif -#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus) - #define JSON_HEDLEY_RESTRICT restrict -#elif \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ - defined(__clang__) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_RESTRICT __restrict -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus) - #define JSON_HEDLEY_RESTRICT _Restrict -#else - #define JSON_HEDLEY_RESTRICT -#endif - -#if defined(JSON_HEDLEY_INLINE) - #undef JSON_HEDLEY_INLINE -#endif -#if \ - (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ - (defined(__cplusplus) && (__cplusplus >= 199711L)) - #define JSON_HEDLEY_INLINE inline -#elif \ - defined(JSON_HEDLEY_GCC_VERSION) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0) - #define JSON_HEDLEY_INLINE __inline__ -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_INLINE __inline -#else - #define JSON_HEDLEY_INLINE -#endif - -#if defined(JSON_HEDLEY_ALWAYS_INLINE) - #undef JSON_HEDLEY_ALWAYS_INLINE -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) -# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) -# define JSON_HEDLEY_ALWAYS_INLINE __forceinline -#elif defined(__cplusplus) && \ - ( \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \ - ) -# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;") -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) -# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced") -#else -# define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE -#endif - -#if defined(JSON_HEDLEY_NEVER_INLINE) - #undef JSON_HEDLEY_NEVER_INLINE -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) - #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__)) -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) -#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0) - #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline") -#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus) - #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;") -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never") -#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) - #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline)) -#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) - #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) -#else - #define JSON_HEDLEY_NEVER_INLINE -#endif - -#if defined(JSON_HEDLEY_PRIVATE) - #undef JSON_HEDLEY_PRIVATE -#endif -#if defined(JSON_HEDLEY_PUBLIC) - #undef JSON_HEDLEY_PUBLIC -#endif -#if defined(JSON_HEDLEY_IMPORT) - #undef JSON_HEDLEY_IMPORT -#endif -#if defined(_WIN32) || defined(__CYGWIN__) -# define JSON_HEDLEY_PRIVATE -# define JSON_HEDLEY_PUBLIC __declspec(dllexport) -# define JSON_HEDLEY_IMPORT __declspec(dllimport) -#else -# if \ - JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ - ( \ - defined(__TI_EABI__) && \ - ( \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \ - ) \ - ) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) -# define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden"))) -# define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default"))) -# else -# define JSON_HEDLEY_PRIVATE -# define JSON_HEDLEY_PUBLIC -# endif -# define JSON_HEDLEY_IMPORT extern -#endif - -#if defined(JSON_HEDLEY_NO_THROW) - #undef JSON_HEDLEY_NO_THROW -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__)) -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) - #define JSON_HEDLEY_NO_THROW __declspec(nothrow) -#else - #define JSON_HEDLEY_NO_THROW -#endif - -#if defined(JSON_HEDLEY_FALL_THROUGH) - #undef JSON_HEDLEY_FALL_THROUGH -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) -#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough) - #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]]) -#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough) - #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]]) -#elif defined(__fallthrough) /* SAL */ - #define JSON_HEDLEY_FALL_THROUGH __fallthrough -#else - #define JSON_HEDLEY_FALL_THROUGH -#endif - -#if defined(JSON_HEDLEY_RETURNS_NON_NULL) - #undef JSON_HEDLEY_RETURNS_NON_NULL -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__)) -#elif defined(_Ret_notnull_) /* SAL */ - #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_ -#else - #define JSON_HEDLEY_RETURNS_NON_NULL -#endif - -#if defined(JSON_HEDLEY_ARRAY_PARAM) - #undef JSON_HEDLEY_ARRAY_PARAM -#endif -#if \ - defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ - !defined(__STDC_NO_VLA__) && \ - !defined(__cplusplus) && \ - !defined(JSON_HEDLEY_PGI_VERSION) && \ - !defined(JSON_HEDLEY_TINYC_VERSION) - #define JSON_HEDLEY_ARRAY_PARAM(name) (name) -#else - #define JSON_HEDLEY_ARRAY_PARAM(name) -#endif - -#if defined(JSON_HEDLEY_IS_CONSTANT) - #undef JSON_HEDLEY_IS_CONSTANT -#endif -#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR) - #undef JSON_HEDLEY_REQUIRE_CONSTEXPR -#endif -/* JSON_HEDLEY_IS_CONSTEXPR_ is for - HEDLEY INTERNAL USE ONLY. API subject to change without notice. */ -#if defined(JSON_HEDLEY_IS_CONSTEXPR_) - #undef JSON_HEDLEY_IS_CONSTEXPR_ -#endif -#if \ - JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ - (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr) -#endif -#if !defined(__cplusplus) -# if \ - JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ - JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24) -#if defined(__INTPTR_TYPE__) - #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*) -#else - #include - #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*) -#endif -# elif \ - ( \ - defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \ - !defined(JSON_HEDLEY_SUNPRO_VERSION) && \ - !defined(JSON_HEDLEY_PGI_VERSION) && \ - !defined(JSON_HEDLEY_IAR_VERSION)) || \ - (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0) -#if defined(__INTPTR_TYPE__) - #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0) -#else - #include - #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0) -#endif -# elif \ - defined(JSON_HEDLEY_GCC_VERSION) || \ - defined(JSON_HEDLEY_INTEL_VERSION) || \ - defined(JSON_HEDLEY_TINYC_VERSION) || \ - defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \ - defined(JSON_HEDLEY_TI_CL2000_VERSION) || \ - defined(JSON_HEDLEY_TI_CL6X_VERSION) || \ - defined(JSON_HEDLEY_TI_CL7X_VERSION) || \ - defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \ - defined(__clang__) -# define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \ - sizeof(void) != \ - sizeof(*( \ - 1 ? \ - ((void*) ((expr) * 0L) ) : \ -((struct { char v[sizeof(void) * 2]; } *) 1) \ - ) \ - ) \ - ) -# endif -#endif -#if defined(JSON_HEDLEY_IS_CONSTEXPR_) - #if !defined(JSON_HEDLEY_IS_CONSTANT) - #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr) - #endif - #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1)) -#else - #if !defined(JSON_HEDLEY_IS_CONSTANT) - #define JSON_HEDLEY_IS_CONSTANT(expr) (0) - #endif - #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr) -#endif - -#if defined(JSON_HEDLEY_BEGIN_C_DECLS) - #undef JSON_HEDLEY_BEGIN_C_DECLS -#endif -#if defined(JSON_HEDLEY_END_C_DECLS) - #undef JSON_HEDLEY_END_C_DECLS -#endif -#if defined(JSON_HEDLEY_C_DECL) - #undef JSON_HEDLEY_C_DECL -#endif -#if defined(__cplusplus) - #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" { - #define JSON_HEDLEY_END_C_DECLS } - #define JSON_HEDLEY_C_DECL extern "C" -#else - #define JSON_HEDLEY_BEGIN_C_DECLS - #define JSON_HEDLEY_END_C_DECLS - #define JSON_HEDLEY_C_DECL -#endif - -#if defined(JSON_HEDLEY_STATIC_ASSERT) - #undef JSON_HEDLEY_STATIC_ASSERT -#endif -#if \ - !defined(__cplusplus) && ( \ - (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \ - (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - defined(_Static_assert) \ - ) -# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message) -#elif \ - (defined(__cplusplus) && (__cplusplus >= 201103L)) || \ - JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) -# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message)) -#else -# define JSON_HEDLEY_STATIC_ASSERT(expr, message) -#endif - -#if defined(JSON_HEDLEY_NULL) - #undef JSON_HEDLEY_NULL -#endif -#if defined(__cplusplus) - #if __cplusplus >= 201103L - #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr) - #elif defined(NULL) - #define JSON_HEDLEY_NULL NULL - #else - #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0) - #endif -#elif defined(NULL) - #define JSON_HEDLEY_NULL NULL -#else - #define JSON_HEDLEY_NULL ((void*) 0) -#endif - -#if defined(JSON_HEDLEY_MESSAGE) - #undef JSON_HEDLEY_MESSAGE -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") -# define JSON_HEDLEY_MESSAGE(msg) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ - JSON_HEDLEY_PRAGMA(message msg) \ - JSON_HEDLEY_DIAGNOSTIC_POP -#elif \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) -# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg) -#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) -# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg) -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) -# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg)) -#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0) -# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg)) -#else -# define JSON_HEDLEY_MESSAGE(msg) -#endif - -#if defined(JSON_HEDLEY_WARNING) - #undef JSON_HEDLEY_WARNING -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") -# define JSON_HEDLEY_WARNING(msg) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ - JSON_HEDLEY_PRAGMA(clang warning msg) \ - JSON_HEDLEY_DIAGNOSTIC_POP -#elif \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) -# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg) -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) -# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg)) -#else -# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg) -#endif - -#if defined(JSON_HEDLEY_REQUIRE) - #undef JSON_HEDLEY_REQUIRE -#endif -#if defined(JSON_HEDLEY_REQUIRE_MSG) - #undef JSON_HEDLEY_REQUIRE_MSG -#endif -#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if) -# if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat") -# define JSON_HEDLEY_REQUIRE(expr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ - __attribute__((diagnose_if(!(expr), #expr, "error"))) \ - JSON_HEDLEY_DIAGNOSTIC_POP -# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ - __attribute__((diagnose_if(!(expr), msg, "error"))) \ - JSON_HEDLEY_DIAGNOSTIC_POP -# else -# define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error"))) -# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error"))) -# endif -#else -# define JSON_HEDLEY_REQUIRE(expr) -# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) -#endif - -#if defined(JSON_HEDLEY_FLAGS) - #undef JSON_HEDLEY_FLAGS -#endif -#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion")) - #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__)) -#else - #define JSON_HEDLEY_FLAGS -#endif - -#if defined(JSON_HEDLEY_FLAGS_CAST) - #undef JSON_HEDLEY_FLAGS_CAST -#endif -#if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0) -# define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("warning(disable:188)") \ - ((T) (expr)); \ - JSON_HEDLEY_DIAGNOSTIC_POP \ - })) -#else -# define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr) -#endif - -#if defined(JSON_HEDLEY_EMPTY_BASES) - #undef JSON_HEDLEY_EMPTY_BASES -#endif -#if \ - (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases) -#else - #define JSON_HEDLEY_EMPTY_BASES -#endif - -/* Remaining macros are deprecated. */ - -#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK) - #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK -#endif -#if defined(__clang__) - #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0) -#else - #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE) - #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE -#endif -#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) - -#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE) - #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE -#endif -#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) - -#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN) - #undef JSON_HEDLEY_CLANG_HAS_BUILTIN -#endif -#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin) - -#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE) - #undef JSON_HEDLEY_CLANG_HAS_FEATURE -#endif -#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature) - -#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION) - #undef JSON_HEDLEY_CLANG_HAS_EXTENSION -#endif -#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension) - -#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE) - #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE -#endif -#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) - -#if defined(JSON_HEDLEY_CLANG_HAS_WARNING) - #undef JSON_HEDLEY_CLANG_HAS_WARNING -#endif -#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning) - -#endif /* !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < X) */ - -// #include - - -#include - -// #include - - -namespace nlohmann -{ -namespace detail -{ -template struct make_void -{ - using type = void; -}; -template using void_t = typename make_void::type; -} // namespace detail -} // namespace nlohmann - - -// https://en.cppreference.com/w/cpp/experimental/is_detected -namespace nlohmann -{ -namespace detail -{ -struct nonesuch -{ - nonesuch() = delete; - ~nonesuch() = delete; - nonesuch(nonesuch const&) = delete; - nonesuch(nonesuch const&&) = delete; - void operator=(nonesuch const&) = delete; - void operator=(nonesuch&&) = delete; -}; - -template class Op, - class... Args> -struct detector -{ - using value_t = std::false_type; - using type = Default; -}; - -template class Op, class... Args> -struct detector>, Op, Args...> -{ - using value_t = std::true_type; - using type = Op; -}; - -template class Op, class... Args> -using is_detected = typename detector::value_t; - -template class Op, class... Args> -struct is_detected_lazy : is_detected { }; - -template class Op, class... Args> -using detected_t = typename detector::type; - -template class Op, class... Args> -using detected_or = detector; - -template class Op, class... Args> -using detected_or_t = typename detected_or::type; - -template class Op, class... Args> -using is_detected_exact = std::is_same>; - -template class Op, class... Args> -using is_detected_convertible = - std::is_convertible, To>; -} // namespace detail -} // namespace nlohmann - - -// This file contains all internal macro definitions -// You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them - -// exclude unsupported compilers -#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK) - #if defined(__clang__) - #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400 - #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers" - #endif - #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER)) - #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800 - #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers" - #endif - #endif -#endif - -// C++ language standard detection -// if the user manually specified the used c++ version this is skipped -#if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11) - #if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) - #define JSON_HAS_CPP_20 - #define JSON_HAS_CPP_17 - #define JSON_HAS_CPP_14 - #elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 - #define JSON_HAS_CPP_17 - #define JSON_HAS_CPP_14 - #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) - #define JSON_HAS_CPP_14 - #endif - // the cpp 11 flag is always specified because it is the minimal required version - #define JSON_HAS_CPP_11 -#endif - -// disable documentation warnings on clang -#if defined(__clang__) - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Wdocumentation" - #pragma clang diagnostic ignored "-Wdocumentation-unknown-command" -#endif - -// allow to disable exceptions -#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION) - #define JSON_THROW(exception) throw exception - #define JSON_TRY try - #define JSON_CATCH(exception) catch(exception) - #define JSON_INTERNAL_CATCH(exception) catch(exception) -#else - #include - #define JSON_THROW(exception) std::abort() - #define JSON_TRY if(true) - #define JSON_CATCH(exception) if(false) - #define JSON_INTERNAL_CATCH(exception) if(false) -#endif - -// override exception macros -#if defined(JSON_THROW_USER) - #undef JSON_THROW - #define JSON_THROW JSON_THROW_USER -#endif -#if defined(JSON_TRY_USER) - #undef JSON_TRY - #define JSON_TRY JSON_TRY_USER -#endif -#if defined(JSON_CATCH_USER) - #undef JSON_CATCH - #define JSON_CATCH JSON_CATCH_USER - #undef JSON_INTERNAL_CATCH - #define JSON_INTERNAL_CATCH JSON_CATCH_USER -#endif -#if defined(JSON_INTERNAL_CATCH_USER) - #undef JSON_INTERNAL_CATCH - #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER -#endif - -// allow to override assert -#if !defined(JSON_ASSERT) - #include // assert - #define JSON_ASSERT(x) assert(x) -#endif - -// allow to access some private functions (needed by the test suite) -#if defined(JSON_TESTS_PRIVATE) - #define JSON_PRIVATE_UNLESS_TESTED public -#else - #define JSON_PRIVATE_UNLESS_TESTED private -#endif - -/*! -@brief macro to briefly define a mapping between an enum and JSON -@def NLOHMANN_JSON_SERIALIZE_ENUM -@since version 3.4.0 -*/ -#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \ - template \ - inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \ - { \ - static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ - static const std::pair m[] = __VA_ARGS__; \ - auto it = std::find_if(std::begin(m), std::end(m), \ - [e](const std::pair& ej_pair) -> bool \ - { \ - return ej_pair.first == e; \ - }); \ - j = ((it != std::end(m)) ? it : std::begin(m))->second; \ - } \ - template \ - inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \ - { \ - static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ - static const std::pair m[] = __VA_ARGS__; \ - auto it = std::find_if(std::begin(m), std::end(m), \ - [&j](const std::pair& ej_pair) -> bool \ - { \ - return ej_pair.second == j; \ - }); \ - e = ((it != std::end(m)) ? it : std::begin(m))->first; \ - } - -// Ugly macros to avoid uglier copy-paste when specializing basic_json. They -// may be removed in the future once the class is split. - -#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \ - template class ObjectType, \ - template class ArrayType, \ - class StringType, class BooleanType, class NumberIntegerType, \ - class NumberUnsignedType, class NumberFloatType, \ - template class AllocatorType, \ - template class JSONSerializer, \ - class BinaryType> - -#define NLOHMANN_BASIC_JSON_TPL \ - basic_json - -// Macros to simplify conversion from/to types - -#define NLOHMANN_JSON_EXPAND( x ) x -#define NLOHMANN_JSON_GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, NAME,...) NAME -#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \ - NLOHMANN_JSON_PASTE64, \ - NLOHMANN_JSON_PASTE63, \ - NLOHMANN_JSON_PASTE62, \ - NLOHMANN_JSON_PASTE61, \ - NLOHMANN_JSON_PASTE60, \ - NLOHMANN_JSON_PASTE59, \ - NLOHMANN_JSON_PASTE58, \ - NLOHMANN_JSON_PASTE57, \ - NLOHMANN_JSON_PASTE56, \ - NLOHMANN_JSON_PASTE55, \ - NLOHMANN_JSON_PASTE54, \ - NLOHMANN_JSON_PASTE53, \ - NLOHMANN_JSON_PASTE52, \ - NLOHMANN_JSON_PASTE51, \ - NLOHMANN_JSON_PASTE50, \ - NLOHMANN_JSON_PASTE49, \ - NLOHMANN_JSON_PASTE48, \ - NLOHMANN_JSON_PASTE47, \ - NLOHMANN_JSON_PASTE46, \ - NLOHMANN_JSON_PASTE45, \ - NLOHMANN_JSON_PASTE44, \ - NLOHMANN_JSON_PASTE43, \ - NLOHMANN_JSON_PASTE42, \ - NLOHMANN_JSON_PASTE41, \ - NLOHMANN_JSON_PASTE40, \ - NLOHMANN_JSON_PASTE39, \ - NLOHMANN_JSON_PASTE38, \ - NLOHMANN_JSON_PASTE37, \ - NLOHMANN_JSON_PASTE36, \ - NLOHMANN_JSON_PASTE35, \ - NLOHMANN_JSON_PASTE34, \ - NLOHMANN_JSON_PASTE33, \ - NLOHMANN_JSON_PASTE32, \ - NLOHMANN_JSON_PASTE31, \ - NLOHMANN_JSON_PASTE30, \ - NLOHMANN_JSON_PASTE29, \ - NLOHMANN_JSON_PASTE28, \ - NLOHMANN_JSON_PASTE27, \ - NLOHMANN_JSON_PASTE26, \ - NLOHMANN_JSON_PASTE25, \ - NLOHMANN_JSON_PASTE24, \ - NLOHMANN_JSON_PASTE23, \ - NLOHMANN_JSON_PASTE22, \ - NLOHMANN_JSON_PASTE21, \ - NLOHMANN_JSON_PASTE20, \ - NLOHMANN_JSON_PASTE19, \ - NLOHMANN_JSON_PASTE18, \ - NLOHMANN_JSON_PASTE17, \ - NLOHMANN_JSON_PASTE16, \ - NLOHMANN_JSON_PASTE15, \ - NLOHMANN_JSON_PASTE14, \ - NLOHMANN_JSON_PASTE13, \ - NLOHMANN_JSON_PASTE12, \ - NLOHMANN_JSON_PASTE11, \ - NLOHMANN_JSON_PASTE10, \ - NLOHMANN_JSON_PASTE9, \ - NLOHMANN_JSON_PASTE8, \ - NLOHMANN_JSON_PASTE7, \ - NLOHMANN_JSON_PASTE6, \ - NLOHMANN_JSON_PASTE5, \ - NLOHMANN_JSON_PASTE4, \ - NLOHMANN_JSON_PASTE3, \ - NLOHMANN_JSON_PASTE2, \ - NLOHMANN_JSON_PASTE1)(__VA_ARGS__)) -#define NLOHMANN_JSON_PASTE2(func, v1) func(v1) -#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2) -#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3) -#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4) -#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5) -#define NLOHMANN_JSON_PASTE7(func, v1, v2, v3, v4, v5, v6) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE6(func, v2, v3, v4, v5, v6) -#define NLOHMANN_JSON_PASTE8(func, v1, v2, v3, v4, v5, v6, v7) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE7(func, v2, v3, v4, v5, v6, v7) -#define NLOHMANN_JSON_PASTE9(func, v1, v2, v3, v4, v5, v6, v7, v8) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE8(func, v2, v3, v4, v5, v6, v7, v8) -#define NLOHMANN_JSON_PASTE10(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE9(func, v2, v3, v4, v5, v6, v7, v8, v9) -#define NLOHMANN_JSON_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE10(func, v2, v3, v4, v5, v6, v7, v8, v9, v10) -#define NLOHMANN_JSON_PASTE12(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE11(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) -#define NLOHMANN_JSON_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE12(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) -#define NLOHMANN_JSON_PASTE14(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE13(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) -#define NLOHMANN_JSON_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE14(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) -#define NLOHMANN_JSON_PASTE16(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE15(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) -#define NLOHMANN_JSON_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE16(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) -#define NLOHMANN_JSON_PASTE18(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE17(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) -#define NLOHMANN_JSON_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE18(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) -#define NLOHMANN_JSON_PASTE20(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE19(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) -#define NLOHMANN_JSON_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE20(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) -#define NLOHMANN_JSON_PASTE22(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE21(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) -#define NLOHMANN_JSON_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE22(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) -#define NLOHMANN_JSON_PASTE24(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE23(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) -#define NLOHMANN_JSON_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE24(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) -#define NLOHMANN_JSON_PASTE26(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE25(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) -#define NLOHMANN_JSON_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE26(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) -#define NLOHMANN_JSON_PASTE28(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE27(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) -#define NLOHMANN_JSON_PASTE29(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE28(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) -#define NLOHMANN_JSON_PASTE30(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE29(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) -#define NLOHMANN_JSON_PASTE31(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE30(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) -#define NLOHMANN_JSON_PASTE32(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE31(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) -#define NLOHMANN_JSON_PASTE33(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE32(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) -#define NLOHMANN_JSON_PASTE34(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE33(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) -#define NLOHMANN_JSON_PASTE35(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE34(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) -#define NLOHMANN_JSON_PASTE36(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE35(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) -#define NLOHMANN_JSON_PASTE37(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE36(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) -#define NLOHMANN_JSON_PASTE38(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE37(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) -#define NLOHMANN_JSON_PASTE39(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE38(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) -#define NLOHMANN_JSON_PASTE40(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE39(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) -#define NLOHMANN_JSON_PASTE41(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE40(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) -#define NLOHMANN_JSON_PASTE42(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE41(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) -#define NLOHMANN_JSON_PASTE43(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE42(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) -#define NLOHMANN_JSON_PASTE44(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE43(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) -#define NLOHMANN_JSON_PASTE45(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE44(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) -#define NLOHMANN_JSON_PASTE46(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE45(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) -#define NLOHMANN_JSON_PASTE47(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE46(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) -#define NLOHMANN_JSON_PASTE48(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE47(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) -#define NLOHMANN_JSON_PASTE49(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE48(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) -#define NLOHMANN_JSON_PASTE50(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE49(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) -#define NLOHMANN_JSON_PASTE51(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE50(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) -#define NLOHMANN_JSON_PASTE52(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE51(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) -#define NLOHMANN_JSON_PASTE53(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE52(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) -#define NLOHMANN_JSON_PASTE54(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE53(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) -#define NLOHMANN_JSON_PASTE55(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE54(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) -#define NLOHMANN_JSON_PASTE56(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE55(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) -#define NLOHMANN_JSON_PASTE57(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE56(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) -#define NLOHMANN_JSON_PASTE58(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE57(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) -#define NLOHMANN_JSON_PASTE59(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE58(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) -#define NLOHMANN_JSON_PASTE60(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE59(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) -#define NLOHMANN_JSON_PASTE61(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE60(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) -#define NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE61(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) -#define NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE62(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) -#define NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE63(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) - -#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1; -#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1); - -/*! -@brief macro -@def NLOHMANN_DEFINE_TYPE_INTRUSIVE -@since version 3.9.0 -*/ -#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \ - friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ - friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } - -/*! -@brief macro -@def NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE -@since version 3.9.0 -*/ -#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \ - inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ - inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } - - -// inspired from https://stackoverflow.com/a/26745591 -// allows to call any std function as if (e.g. with begin): -// using std::begin; begin(x); -// -// it allows using the detected idiom to retrieve the return type -// of such an expression -#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \ - namespace detail { \ - using std::std_name; \ - \ - template \ - using result_of_##std_name = decltype(std_name(std::declval()...)); \ - } \ - \ - namespace detail2 { \ - struct std_name##_tag \ - { \ - }; \ - \ - template \ - std_name##_tag std_name(T&&...); \ - \ - template \ - using result_of_##std_name = decltype(std_name(std::declval()...)); \ - \ - template \ - struct would_call_std_##std_name \ - { \ - static constexpr auto const value = ::nlohmann::detail:: \ - is_detected_exact::value; \ - }; \ - } /* namespace detail2 */ \ - \ - template \ - struct would_call_std_##std_name : detail2::would_call_std_##std_name \ - { \ - } - -#ifndef JSON_USE_IMPLICIT_CONVERSIONS - #define JSON_USE_IMPLICIT_CONVERSIONS 1 -#endif - -#if JSON_USE_IMPLICIT_CONVERSIONS - #define JSON_EXPLICIT -#else - #define JSON_EXPLICIT explicit -#endif - -#ifndef JSON_DIAGNOSTICS - #define JSON_DIAGNOSTICS 0 -#endif - - -namespace nlohmann -{ -namespace detail -{ - -/*! -@brief replace all occurrences of a substring by another string - -@param[in,out] s the string to manipulate; changed so that all - occurrences of @a f are replaced with @a t -@param[in] f the substring to replace with @a t -@param[in] t the string to replace @a f - -@pre The search string @a f must not be empty. **This precondition is -enforced with an assertion.** - -@since version 2.0.0 -*/ -inline void replace_substring(std::string& s, const std::string& f, - const std::string& t) -{ - JSON_ASSERT(!f.empty()); - for (auto pos = s.find(f); // find first occurrence of f - pos != std::string::npos; // make sure f was found - s.replace(pos, f.size(), t), // replace with t, and - pos = s.find(f, pos + t.size())) // find next occurrence of f - {} -} - -/*! - * @brief string escaping as described in RFC 6901 (Sect. 4) - * @param[in] s string to escape - * @return escaped string - * - * Note the order of escaping "~" to "~0" and "/" to "~1" is important. - */ -inline std::string escape(std::string s) -{ - replace_substring(s, "~", "~0"); - replace_substring(s, "/", "~1"); - return s; -} - -/*! - * @brief string unescaping as described in RFC 6901 (Sect. 4) - * @param[in] s string to unescape - * @return unescaped string - * - * Note the order of escaping "~1" to "/" and "~0" to "~" is important. - */ -static void unescape(std::string& s) -{ - replace_substring(s, "~1", "/"); - replace_substring(s, "~0", "~"); -} - -} // namespace detail -} // namespace nlohmann - -// #include - - -#include // size_t - -namespace nlohmann -{ -namespace detail -{ -/// struct to capture the start position of the current token -struct position_t -{ - /// the total number of characters read - std::size_t chars_read_total = 0; - /// the number of characters read in the current line - std::size_t chars_read_current_line = 0; - /// the number of lines read - std::size_t lines_read = 0; - - /// conversion to size_t to preserve SAX interface - constexpr operator size_t() const - { - return chars_read_total; - } -}; - -} // namespace detail -} // namespace nlohmann - -// #include - - -namespace nlohmann -{ -namespace detail -{ -//////////////// -// exceptions // -//////////////// - -/*! -@brief general exception of the @ref basic_json class - -This class is an extension of `std::exception` objects with a member @a id for -exception ids. It is used as the base class for all exceptions thrown by the -@ref basic_json class. This class can hence be used as "wildcard" to catch -exceptions. - -Subclasses: -- @ref parse_error for exceptions indicating a parse error -- @ref invalid_iterator for exceptions indicating errors with iterators -- @ref type_error for exceptions indicating executing a member function with - a wrong type -- @ref out_of_range for exceptions indicating access out of the defined range -- @ref other_error for exceptions indicating other library errors - -@internal -@note To have nothrow-copy-constructible exceptions, we internally use - `std::runtime_error` which can cope with arbitrary-length error messages. - Intermediate strings are built with static functions and then passed to - the actual constructor. -@endinternal - -@liveexample{The following code shows how arbitrary library exceptions can be -caught.,exception} - -@since version 3.0.0 -*/ -class exception : public std::exception -{ - public: - /// returns the explanatory string - const char* what() const noexcept override - { - return m.what(); - } - - /// the id of the exception - const int id; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes) - - protected: - JSON_HEDLEY_NON_NULL(3) - exception(int id_, const char* what_arg) : id(id_), m(what_arg) {} // NOLINT(bugprone-throw-keyword-missing) - - static std::string name(const std::string& ename, int id_) - { - return "[json.exception." + ename + "." + std::to_string(id_) + "] "; - } - - template - static std::string diagnostics(const BasicJsonType& leaf_element) - { -#if JSON_DIAGNOSTICS - std::vector tokens; - for (const auto* current = &leaf_element; current->m_parent != nullptr; current = current->m_parent) - { - switch (current->m_parent->type()) - { - case value_t::array: - { - for (std::size_t i = 0; i < current->m_parent->m_value.array->size(); ++i) - { - if (¤t->m_parent->m_value.array->operator[](i) == current) - { - tokens.emplace_back(std::to_string(i)); - break; - } - } - break; - } - - case value_t::object: - { - for (const auto& element : *current->m_parent->m_value.object) - { - if (&element.second == current) - { - tokens.emplace_back(element.first.c_str()); - break; - } - } - break; - } - - case value_t::null: // LCOV_EXCL_LINE - case value_t::string: // LCOV_EXCL_LINE - case value_t::boolean: // LCOV_EXCL_LINE - case value_t::number_integer: // LCOV_EXCL_LINE - case value_t::number_unsigned: // LCOV_EXCL_LINE - case value_t::number_float: // LCOV_EXCL_LINE - case value_t::binary: // LCOV_EXCL_LINE - case value_t::discarded: // LCOV_EXCL_LINE - default: // LCOV_EXCL_LINE - break; // LCOV_EXCL_LINE - } - } - - if (tokens.empty()) - { - return ""; - } - - return "(" + std::accumulate(tokens.rbegin(), tokens.rend(), std::string{}, - [](const std::string & a, const std::string & b) - { - return a + "/" + detail::escape(b); - }) + ") "; -#else - static_cast(leaf_element); - return ""; -#endif - } - - private: - /// an exception object as storage for error messages - std::runtime_error m; -}; - -/*! -@brief exception indicating a parse error - -This exception is thrown by the library when a parse error occurs. Parse errors -can occur during the deserialization of JSON text, CBOR, MessagePack, as well -as when using JSON Patch. - -Member @a byte holds the byte index of the last read character in the input -file. - -Exceptions have ids 1xx. - -name / id | example message | description ------------------------------- | --------------- | ------------------------- -json.exception.parse_error.101 | parse error at 2: unexpected end of input; expected string literal | This error indicates a syntax error while deserializing a JSON text. The error message describes that an unexpected token (character) was encountered, and the member @a byte indicates the error position. -json.exception.parse_error.102 | parse error at 14: missing or wrong low surrogate | JSON uses the `\uxxxx` format to describe Unicode characters. Code points above above 0xFFFF are split into two `\uxxxx` entries ("surrogate pairs"). This error indicates that the surrogate pair is incomplete or contains an invalid code point. -json.exception.parse_error.103 | parse error: code points above 0x10FFFF are invalid | Unicode supports code points up to 0x10FFFF. Code points above 0x10FFFF are invalid. -json.exception.parse_error.104 | parse error: JSON patch must be an array of objects | [RFC 6902](https://tools.ietf.org/html/rfc6902) requires a JSON Patch document to be a JSON document that represents an array of objects. -json.exception.parse_error.105 | parse error: operation must have string member 'op' | An operation of a JSON Patch document must contain exactly one "op" member, whose value indicates the operation to perform. Its value must be one of "add", "remove", "replace", "move", "copy", or "test"; other values are errors. -json.exception.parse_error.106 | parse error: array index '01' must not begin with '0' | An array index in a JSON Pointer ([RFC 6901](https://tools.ietf.org/html/rfc6901)) may be `0` or any number without a leading `0`. -json.exception.parse_error.107 | parse error: JSON pointer must be empty or begin with '/' - was: 'foo' | A JSON Pointer must be a Unicode string containing a sequence of zero or more reference tokens, each prefixed by a `/` character. -json.exception.parse_error.108 | parse error: escape character '~' must be followed with '0' or '1' | In a JSON Pointer, only `~0` and `~1` are valid escape sequences. -json.exception.parse_error.109 | parse error: array index 'one' is not a number | A JSON Pointer array index must be a number. -json.exception.parse_error.110 | parse error at 1: cannot read 2 bytes from vector | When parsing CBOR or MessagePack, the byte vector ends before the complete value has been read. -json.exception.parse_error.112 | parse error at 1: error reading CBOR; last byte: 0xF8 | Not all types of CBOR or MessagePack are supported. This exception occurs if an unsupported byte was read. -json.exception.parse_error.113 | parse error at 2: expected a CBOR string; last byte: 0x98 | While parsing a map key, a value that is not a string has been read. -json.exception.parse_error.114 | parse error: Unsupported BSON record type 0x0F | The parsing of the corresponding BSON record type is not implemented (yet). -json.exception.parse_error.115 | parse error at byte 5: syntax error while parsing UBJSON high-precision number: invalid number text: 1A | A UBJSON high-precision number could not be parsed. - -@note For an input with n bytes, 1 is the index of the first character and n+1 - is the index of the terminating null byte or the end of file. This also - holds true when reading a byte vector (CBOR or MessagePack). - -@liveexample{The following code shows how a `parse_error` exception can be -caught.,parse_error} - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref invalid_iterator for exceptions indicating errors with iterators -@sa - @ref type_error for exceptions indicating executing a member function with - a wrong type -@sa - @ref out_of_range for exceptions indicating access out of the defined range -@sa - @ref other_error for exceptions indicating other library errors - -@since version 3.0.0 -*/ -class parse_error : public exception -{ - public: - /*! - @brief create a parse error exception - @param[in] id_ the id of the exception - @param[in] pos the position where the error occurred (or with - chars_read_total=0 if the position cannot be - determined) - @param[in] what_arg the explanatory string - @return parse_error object - */ - template - static parse_error create(int id_, const position_t& pos, const std::string& what_arg, const BasicJsonType& context) - { - std::string w = exception::name("parse_error", id_) + "parse error" + - position_string(pos) + ": " + exception::diagnostics(context) + what_arg; - return {id_, pos.chars_read_total, w.c_str()}; - } - - template - static parse_error create(int id_, std::size_t byte_, const std::string& what_arg, const BasicJsonType& context) - { - std::string w = exception::name("parse_error", id_) + "parse error" + - (byte_ != 0 ? (" at byte " + std::to_string(byte_)) : "") + - ": " + exception::diagnostics(context) + what_arg; - return {id_, byte_, w.c_str()}; - } - - /*! - @brief byte index of the parse error - - The byte index of the last read character in the input file. - - @note For an input with n bytes, 1 is the index of the first character and - n+1 is the index of the terminating null byte or the end of file. - This also holds true when reading a byte vector (CBOR or MessagePack). - */ - const std::size_t byte; - - private: - parse_error(int id_, std::size_t byte_, const char* what_arg) - : exception(id_, what_arg), byte(byte_) {} - - static std::string position_string(const position_t& pos) - { - return " at line " + std::to_string(pos.lines_read + 1) + - ", column " + std::to_string(pos.chars_read_current_line); - } -}; - -/*! -@brief exception indicating errors with iterators - -This exception is thrown if iterators passed to a library function do not match -the expected semantics. - -Exceptions have ids 2xx. - -name / id | example message | description ------------------------------------ | --------------- | ------------------------- -json.exception.invalid_iterator.201 | iterators are not compatible | The iterators passed to constructor @ref basic_json(InputIT first, InputIT last) are not compatible, meaning they do not belong to the same container. Therefore, the range (@a first, @a last) is invalid. -json.exception.invalid_iterator.202 | iterator does not fit current value | In an erase or insert function, the passed iterator @a pos does not belong to the JSON value for which the function was called. It hence does not define a valid position for the deletion/insertion. -json.exception.invalid_iterator.203 | iterators do not fit current value | Either iterator passed to function @ref erase(IteratorType first, IteratorType last) does not belong to the JSON value from which values shall be erased. It hence does not define a valid range to delete values from. -json.exception.invalid_iterator.204 | iterators out of range | When an iterator range for a primitive type (number, boolean, or string) is passed to a constructor or an erase function, this range has to be exactly (@ref begin(), @ref end()), because this is the only way the single stored value is expressed. All other ranges are invalid. -json.exception.invalid_iterator.205 | iterator out of range | When an iterator for a primitive type (number, boolean, or string) is passed to an erase function, the iterator has to be the @ref begin() iterator, because it is the only way to address the stored value. All other iterators are invalid. -json.exception.invalid_iterator.206 | cannot construct with iterators from null | The iterators passed to constructor @ref basic_json(InputIT first, InputIT last) belong to a JSON null value and hence to not define a valid range. -json.exception.invalid_iterator.207 | cannot use key() for non-object iterators | The key() member function can only be used on iterators belonging to a JSON object, because other types do not have a concept of a key. -json.exception.invalid_iterator.208 | cannot use operator[] for object iterators | The operator[] to specify a concrete offset cannot be used on iterators belonging to a JSON object, because JSON objects are unordered. -json.exception.invalid_iterator.209 | cannot use offsets with object iterators | The offset operators (+, -, +=, -=) cannot be used on iterators belonging to a JSON object, because JSON objects are unordered. -json.exception.invalid_iterator.210 | iterators do not fit | The iterator range passed to the insert function are not compatible, meaning they do not belong to the same container. Therefore, the range (@a first, @a last) is invalid. -json.exception.invalid_iterator.211 | passed iterators may not belong to container | The iterator range passed to the insert function must not be a subrange of the container to insert to. -json.exception.invalid_iterator.212 | cannot compare iterators of different containers | When two iterators are compared, they must belong to the same container. -json.exception.invalid_iterator.213 | cannot compare order of object iterators | The order of object iterators cannot be compared, because JSON objects are unordered. -json.exception.invalid_iterator.214 | cannot get value | Cannot get value for iterator: Either the iterator belongs to a null value or it is an iterator to a primitive type (number, boolean, or string), but the iterator is different to @ref begin(). - -@liveexample{The following code shows how an `invalid_iterator` exception can be -caught.,invalid_iterator} - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref parse_error for exceptions indicating a parse error -@sa - @ref type_error for exceptions indicating executing a member function with - a wrong type -@sa - @ref out_of_range for exceptions indicating access out of the defined range -@sa - @ref other_error for exceptions indicating other library errors - -@since version 3.0.0 -*/ -class invalid_iterator : public exception -{ - public: - template - static invalid_iterator create(int id_, const std::string& what_arg, const BasicJsonType& context) - { - std::string w = exception::name("invalid_iterator", id_) + exception::diagnostics(context) + what_arg; - return {id_, w.c_str()}; - } - - private: - JSON_HEDLEY_NON_NULL(3) - invalid_iterator(int id_, const char* what_arg) - : exception(id_, what_arg) {} -}; - -/*! -@brief exception indicating executing a member function with a wrong type - -This exception is thrown in case of a type error; that is, a library function is -executed on a JSON value whose type does not match the expected semantics. - -Exceptions have ids 3xx. - -name / id | example message | description ------------------------------ | --------------- | ------------------------- -json.exception.type_error.301 | cannot create object from initializer list | To create an object from an initializer list, the initializer list must consist only of a list of pairs whose first element is a string. When this constraint is violated, an array is created instead. -json.exception.type_error.302 | type must be object, but is array | During implicit or explicit value conversion, the JSON type must be compatible to the target type. For instance, a JSON string can only be converted into string types, but not into numbers or boolean types. -json.exception.type_error.303 | incompatible ReferenceType for get_ref, actual type is object | To retrieve a reference to a value stored in a @ref basic_json object with @ref get_ref, the type of the reference must match the value type. For instance, for a JSON array, the @a ReferenceType must be @ref array_t &. -json.exception.type_error.304 | cannot use at() with string | The @ref at() member functions can only be executed for certain JSON types. -json.exception.type_error.305 | cannot use operator[] with string | The @ref operator[] member functions can only be executed for certain JSON types. -json.exception.type_error.306 | cannot use value() with string | The @ref value() member functions can only be executed for certain JSON types. -json.exception.type_error.307 | cannot use erase() with string | The @ref erase() member functions can only be executed for certain JSON types. -json.exception.type_error.308 | cannot use push_back() with string | The @ref push_back() and @ref operator+= member functions can only be executed for certain JSON types. -json.exception.type_error.309 | cannot use insert() with | The @ref insert() member functions can only be executed for certain JSON types. -json.exception.type_error.310 | cannot use swap() with number | The @ref swap() member functions can only be executed for certain JSON types. -json.exception.type_error.311 | cannot use emplace_back() with string | The @ref emplace_back() member function can only be executed for certain JSON types. -json.exception.type_error.312 | cannot use update() with string | The @ref update() member functions can only be executed for certain JSON types. -json.exception.type_error.313 | invalid value to unflatten | The @ref unflatten function converts an object whose keys are JSON Pointers back into an arbitrary nested JSON value. The JSON Pointers must not overlap, because then the resulting value would not be well defined. -json.exception.type_error.314 | only objects can be unflattened | The @ref unflatten function only works for an object whose keys are JSON Pointers. -json.exception.type_error.315 | values in object must be primitive | The @ref unflatten function only works for an object whose keys are JSON Pointers and whose values are primitive. -json.exception.type_error.316 | invalid UTF-8 byte at index 10: 0x7E | The @ref dump function only works with UTF-8 encoded strings; that is, if you assign a `std::string` to a JSON value, make sure it is UTF-8 encoded. | -json.exception.type_error.317 | JSON value cannot be serialized to requested format | The dynamic type of the object cannot be represented in the requested serialization format (e.g. a raw `true` or `null` JSON object cannot be serialized to BSON) | - -@liveexample{The following code shows how a `type_error` exception can be -caught.,type_error} - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref parse_error for exceptions indicating a parse error -@sa - @ref invalid_iterator for exceptions indicating errors with iterators -@sa - @ref out_of_range for exceptions indicating access out of the defined range -@sa - @ref other_error for exceptions indicating other library errors - -@since version 3.0.0 -*/ -class type_error : public exception -{ - public: - template - static type_error create(int id_, const std::string& what_arg, const BasicJsonType& context) - { - std::string w = exception::name("type_error", id_) + exception::diagnostics(context) + what_arg; - return {id_, w.c_str()}; - } - - private: - JSON_HEDLEY_NON_NULL(3) - type_error(int id_, const char* what_arg) : exception(id_, what_arg) {} -}; - -/*! -@brief exception indicating access out of the defined range - -This exception is thrown in case a library function is called on an input -parameter that exceeds the expected range, for instance in case of array -indices or nonexisting object keys. - -Exceptions have ids 4xx. - -name / id | example message | description -------------------------------- | --------------- | ------------------------- -json.exception.out_of_range.401 | array index 3 is out of range | The provided array index @a i is larger than @a size-1. -json.exception.out_of_range.402 | array index '-' (3) is out of range | The special array index `-` in a JSON Pointer never describes a valid element of the array, but the index past the end. That is, it can only be used to add elements at this position, but not to read it. -json.exception.out_of_range.403 | key 'foo' not found | The provided key was not found in the JSON object. -json.exception.out_of_range.404 | unresolved reference token 'foo' | A reference token in a JSON Pointer could not be resolved. -json.exception.out_of_range.405 | JSON pointer has no parent | The JSON Patch operations 'remove' and 'add' can not be applied to the root element of the JSON value. -json.exception.out_of_range.406 | number overflow parsing '10E1000' | A parsed number could not be stored as without changing it to NaN or INF. -json.exception.out_of_range.407 | number overflow serializing '9223372036854775808' | UBJSON and BSON only support integer numbers up to 9223372036854775807. (until version 3.8.0) | -json.exception.out_of_range.408 | excessive array size: 8658170730974374167 | The size (following `#`) of an UBJSON array or object exceeds the maximal capacity. | -json.exception.out_of_range.409 | BSON key cannot contain code point U+0000 (at byte 2) | Key identifiers to be serialized to BSON cannot contain code point U+0000, since the key is stored as zero-terminated c-string | - -@liveexample{The following code shows how an `out_of_range` exception can be -caught.,out_of_range} - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref parse_error for exceptions indicating a parse error -@sa - @ref invalid_iterator for exceptions indicating errors with iterators -@sa - @ref type_error for exceptions indicating executing a member function with - a wrong type -@sa - @ref other_error for exceptions indicating other library errors - -@since version 3.0.0 -*/ -class out_of_range : public exception -{ - public: - template - static out_of_range create(int id_, const std::string& what_arg, const BasicJsonType& context) - { - std::string w = exception::name("out_of_range", id_) + exception::diagnostics(context) + what_arg; - return {id_, w.c_str()}; - } - - private: - JSON_HEDLEY_NON_NULL(3) - out_of_range(int id_, const char* what_arg) : exception(id_, what_arg) {} -}; - -/*! -@brief exception indicating other library errors - -This exception is thrown in case of errors that cannot be classified with the -other exception types. - -Exceptions have ids 5xx. - -name / id | example message | description ------------------------------- | --------------- | ------------------------- -json.exception.other_error.501 | unsuccessful: {"op":"test","path":"/baz", "value":"bar"} | A JSON Patch operation 'test' failed. The unsuccessful operation is also printed. - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref parse_error for exceptions indicating a parse error -@sa - @ref invalid_iterator for exceptions indicating errors with iterators -@sa - @ref type_error for exceptions indicating executing a member function with - a wrong type -@sa - @ref out_of_range for exceptions indicating access out of the defined range - -@liveexample{The following code shows how an `other_error` exception can be -caught.,other_error} - -@since version 3.0.0 -*/ -class other_error : public exception -{ - public: - template - static other_error create(int id_, const std::string& what_arg, const BasicJsonType& context) - { - std::string w = exception::name("other_error", id_) + exception::diagnostics(context) + what_arg; - return {id_, w.c_str()}; - } - - private: - JSON_HEDLEY_NON_NULL(3) - other_error(int id_, const char* what_arg) : exception(id_, what_arg) {} -}; -} // namespace detail -} // namespace nlohmann - -// #include - -// #include - - -#include // size_t -#include // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type -#include // index_sequence, make_index_sequence, index_sequence_for - -// #include - - -namespace nlohmann -{ -namespace detail -{ - -template -using uncvref_t = typename std::remove_cv::type>::type; - -#ifdef JSON_HAS_CPP_14 - -// the following utilities are natively available in C++14 -using std::enable_if_t; -using std::index_sequence; -using std::make_index_sequence; -using std::index_sequence_for; - -#else - -// alias templates to reduce boilerplate -template -using enable_if_t = typename std::enable_if::type; - -// The following code is taken from https://github.com/abseil/abseil-cpp/blob/10cb35e459f5ecca5b2ff107635da0bfa41011b4/absl/utility/utility.h -// which is part of Google Abseil (https://github.com/abseil/abseil-cpp), licensed under the Apache License 2.0. - -//// START OF CODE FROM GOOGLE ABSEIL - -// integer_sequence -// -// Class template representing a compile-time integer sequence. An instantiation -// of `integer_sequence` has a sequence of integers encoded in its -// type through its template arguments (which is a common need when -// working with C++11 variadic templates). `absl::integer_sequence` is designed -// to be a drop-in replacement for C++14's `std::integer_sequence`. -// -// Example: -// -// template< class T, T... Ints > -// void user_function(integer_sequence); -// -// int main() -// { -// // user_function's `T` will be deduced to `int` and `Ints...` -// // will be deduced to `0, 1, 2, 3, 4`. -// user_function(make_integer_sequence()); -// } -template -struct integer_sequence -{ - using value_type = T; - static constexpr std::size_t size() noexcept - { - return sizeof...(Ints); - } -}; - -// index_sequence -// -// A helper template for an `integer_sequence` of `size_t`, -// `absl::index_sequence` is designed to be a drop-in replacement for C++14's -// `std::index_sequence`. -template -using index_sequence = integer_sequence; - -namespace utility_internal -{ - -template -struct Extend; - -// Note that SeqSize == sizeof...(Ints). It's passed explicitly for efficiency. -template -struct Extend, SeqSize, 0> -{ - using type = integer_sequence < T, Ints..., (Ints + SeqSize)... >; -}; - -template -struct Extend, SeqSize, 1> -{ - using type = integer_sequence < T, Ints..., (Ints + SeqSize)..., 2 * SeqSize >; -}; - -// Recursion helper for 'make_integer_sequence'. -// 'Gen::type' is an alias for 'integer_sequence'. -template -struct Gen -{ - using type = - typename Extend < typename Gen < T, N / 2 >::type, N / 2, N % 2 >::type; -}; - -template -struct Gen -{ - using type = integer_sequence; -}; - -} // namespace utility_internal - -// Compile-time sequences of integers - -// make_integer_sequence -// -// This template alias is equivalent to -// `integer_sequence`, and is designed to be a drop-in -// replacement for C++14's `std::make_integer_sequence`. -template -using make_integer_sequence = typename utility_internal::Gen::type; - -// make_index_sequence -// -// This template alias is equivalent to `index_sequence<0, 1, ..., N-1>`, -// and is designed to be a drop-in replacement for C++14's -// `std::make_index_sequence`. -template -using make_index_sequence = make_integer_sequence; - -// index_sequence_for -// -// Converts a typename pack into an index sequence of the same length, and -// is designed to be a drop-in replacement for C++14's -// `std::index_sequence_for()` -template -using index_sequence_for = make_index_sequence; - -//// END OF CODE FROM GOOGLE ABSEIL - -#endif - -// dispatch utility (taken from ranges-v3) -template struct priority_tag : priority_tag < N - 1 > {}; -template<> struct priority_tag<0> {}; - -// taken from ranges-v3 -template -struct static_const -{ - static constexpr T value{}; -}; - -template -constexpr T static_const::value; - -} // namespace detail -} // namespace nlohmann - -// #include - - -namespace nlohmann -{ -namespace detail -{ -// dispatching helper struct -template struct identity_tag {}; -} // namespace detail -} // namespace nlohmann - -// #include - - -#include // numeric_limits -#include // false_type, is_constructible, is_integral, is_same, true_type -#include // declval -#include // tuple - -// #include - - -// #include - - -#include // random_access_iterator_tag - -// #include - -// #include - - -namespace nlohmann -{ -namespace detail -{ -template -struct iterator_types {}; - -template -struct iterator_types < - It, - void_t> -{ - using difference_type = typename It::difference_type; - using value_type = typename It::value_type; - using pointer = typename It::pointer; - using reference = typename It::reference; - using iterator_category = typename It::iterator_category; -}; - -// This is required as some compilers implement std::iterator_traits in a way that -// doesn't work with SFINAE. See https://github.com/nlohmann/json/issues/1341. -template -struct iterator_traits -{ -}; - -template -struct iterator_traits < T, enable_if_t < !std::is_pointer::value >> - : iterator_types -{ -}; - -template -struct iterator_traits::value>> -{ - using iterator_category = std::random_access_iterator_tag; - using value_type = T; - using difference_type = ptrdiff_t; - using pointer = T*; - using reference = T&; -}; -} // namespace detail -} // namespace nlohmann - -// #include - - -// #include - - -namespace nlohmann -{ -NLOHMANN_CAN_CALL_STD_FUNC_IMPL(begin); -} // namespace nlohmann - -// #include - - -// #include - - -namespace nlohmann -{ -NLOHMANN_CAN_CALL_STD_FUNC_IMPL(end); -} // namespace nlohmann - -// #include - -// #include - -// #include -#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_ -#define INCLUDE_NLOHMANN_JSON_FWD_HPP_ - -#include // int64_t, uint64_t -#include // map -#include // allocator -#include // string -#include // vector - -/*! -@brief namespace for Niels Lohmann -@see https://github.com/nlohmann -@since version 1.0.0 -*/ -namespace nlohmann -{ -/*! -@brief default JSONSerializer template argument - -This serializer ignores the template arguments and uses ADL -([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl)) -for serialization. -*/ -template -struct adl_serializer; - -template class ObjectType = - std::map, - template class ArrayType = std::vector, - class StringType = std::string, class BooleanType = bool, - class NumberIntegerType = std::int64_t, - class NumberUnsignedType = std::uint64_t, - class NumberFloatType = double, - template class AllocatorType = std::allocator, - template class JSONSerializer = - adl_serializer, - class BinaryType = std::vector> -class basic_json; - -/*! -@brief JSON Pointer - -A JSON pointer defines a string syntax for identifying a specific value -within a JSON document. It can be used with functions `at` and -`operator[]`. Furthermore, JSON pointers are the base for JSON patches. - -@sa [RFC 6901](https://tools.ietf.org/html/rfc6901) - -@since version 2.0.0 -*/ -template -class json_pointer; - -/*! -@brief default JSON class - -This type is the default specialization of the @ref basic_json class which -uses the standard template types. - -@since version 1.0.0 -*/ -using json = basic_json<>; - -template -struct ordered_map; - -/*! -@brief ordered JSON class - -This type preserves the insertion order of object keys. - -@since version 3.9.0 -*/ -using ordered_json = basic_json; - -} // namespace nlohmann - -#endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_ - - -namespace nlohmann -{ -/*! -@brief detail namespace with internal helper functions - -This namespace collects functions that should not be exposed, -implementations of some @ref basic_json methods, and meta-programming helpers. - -@since version 2.1.0 -*/ -namespace detail -{ -///////////// -// helpers // -///////////// - -// Note to maintainers: -// -// Every trait in this file expects a non CV-qualified type. -// The only exceptions are in the 'aliases for detected' section -// (i.e. those of the form: decltype(T::member_function(std::declval()))) -// -// In this case, T has to be properly CV-qualified to constraint the function arguments -// (e.g. to_json(BasicJsonType&, const T&)) - -template struct is_basic_json : std::false_type {}; - -NLOHMANN_BASIC_JSON_TPL_DECLARATION -struct is_basic_json : std::true_type {}; - -////////////////////// -// json_ref helpers // -////////////////////// - -template -class json_ref; - -template -struct is_json_ref : std::false_type {}; - -template -struct is_json_ref> : std::true_type {}; - -////////////////////////// -// aliases for detected // -////////////////////////// - -template -using mapped_type_t = typename T::mapped_type; - -template -using key_type_t = typename T::key_type; - -template -using value_type_t = typename T::value_type; - -template -using difference_type_t = typename T::difference_type; - -template -using pointer_t = typename T::pointer; - -template -using reference_t = typename T::reference; - -template -using iterator_category_t = typename T::iterator_category; - -template -using to_json_function = decltype(T::to_json(std::declval()...)); - -template -using from_json_function = decltype(T::from_json(std::declval()...)); - -template -using get_template_function = decltype(std::declval().template get()); - -// trait checking if JSONSerializer::from_json(json const&, udt&) exists -template -struct has_from_json : std::false_type {}; - -// trait checking if j.get is valid -// use this trait instead of std::is_constructible or std::is_convertible, -// both rely on, or make use of implicit conversions, and thus fail when T -// has several constructors/operator= (see https://github.com/nlohmann/json/issues/958) -template -struct is_getable -{ - static constexpr bool value = is_detected::value; -}; - -template -struct has_from_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> -{ - using serializer = typename BasicJsonType::template json_serializer; - - static constexpr bool value = - is_detected_exact::value; -}; - -// This trait checks if JSONSerializer::from_json(json const&) exists -// this overload is used for non-default-constructible user-defined-types -template -struct has_non_default_from_json : std::false_type {}; - -template -struct has_non_default_from_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> -{ - using serializer = typename BasicJsonType::template json_serializer; - - static constexpr bool value = - is_detected_exact::value; -}; - -// This trait checks if BasicJsonType::json_serializer::to_json exists -// Do not evaluate the trait when T is a basic_json type, to avoid template instantiation infinite recursion. -template -struct has_to_json : std::false_type {}; - -template -struct has_to_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> -{ - using serializer = typename BasicJsonType::template json_serializer; - - static constexpr bool value = - is_detected_exact::value; -}; - - -/////////////////// -// is_ functions // -/////////////////// - -// https://en.cppreference.com/w/cpp/types/conjunction -template struct conjunction : std::true_type { }; -template struct conjunction : B1 { }; -template -struct conjunction -: std::conditional, B1>::type {}; - -// https://en.cppreference.com/w/cpp/types/negation -template struct negation : std::integral_constant < bool, !B::value > { }; - -// Reimplementation of is_constructible and is_default_constructible, due to them being broken for -// std::pair and std::tuple until LWG 2367 fix (see https://cplusplus.github.io/LWG/lwg-defects.html#2367). -// This causes compile errors in e.g. clang 3.5 or gcc 4.9. -template -struct is_default_constructible : std::is_default_constructible {}; - -template -struct is_default_constructible> - : conjunction, is_default_constructible> {}; - -template -struct is_default_constructible> - : conjunction, is_default_constructible> {}; - -template -struct is_default_constructible> - : conjunction...> {}; - -template -struct is_default_constructible> - : conjunction...> {}; - - -template -struct is_constructible : std::is_constructible {}; - -template -struct is_constructible> : is_default_constructible> {}; - -template -struct is_constructible> : is_default_constructible> {}; - -template -struct is_constructible> : is_default_constructible> {}; - -template -struct is_constructible> : is_default_constructible> {}; - - -template -struct is_iterator_traits : std::false_type {}; - -template -struct is_iterator_traits> -{ - private: - using traits = iterator_traits; - - public: - static constexpr auto value = - is_detected::value && - is_detected::value && - is_detected::value && - is_detected::value && - is_detected::value; -}; - -template -struct is_range -{ - private: - using t_ref = typename std::add_lvalue_reference::type; - - using iterator = detected_t; - using sentinel = detected_t; - - // to be 100% correct, it should use https://en.cppreference.com/w/cpp/iterator/input_or_output_iterator - // and https://en.cppreference.com/w/cpp/iterator/sentinel_for - // but reimplementing these would be too much work, as a lot of other concepts are used underneath - static constexpr auto is_iterator_begin = - is_iterator_traits>::value; - - public: - static constexpr bool value = !std::is_same::value && !std::is_same::value && is_iterator_begin; -}; - -template -using iterator_t = enable_if_t::value, result_of_begin())>>; - -template -using range_value_t = value_type_t>>; - -// The following implementation of is_complete_type is taken from -// https://blogs.msdn.microsoft.com/vcblog/2015/12/02/partial-support-for-expression-sfinae-in-vs-2015-update-1/ -// and is written by Xiang Fan who agreed to using it in this library. - -template -struct is_complete_type : std::false_type {}; - -template -struct is_complete_type : std::true_type {}; - -template -struct is_compatible_object_type_impl : std::false_type {}; - -template -struct is_compatible_object_type_impl < - BasicJsonType, CompatibleObjectType, - enable_if_t < is_detected::value&& - is_detected::value >> -{ - using object_t = typename BasicJsonType::object_t; - - // macOS's is_constructible does not play well with nonesuch... - static constexpr bool value = - is_constructible::value && - is_constructible::value; -}; - -template -struct is_compatible_object_type - : is_compatible_object_type_impl {}; - -template -struct is_constructible_object_type_impl : std::false_type {}; - -template -struct is_constructible_object_type_impl < - BasicJsonType, ConstructibleObjectType, - enable_if_t < is_detected::value&& - is_detected::value >> -{ - using object_t = typename BasicJsonType::object_t; - - static constexpr bool value = - (is_default_constructible::value && - (std::is_move_assignable::value || - std::is_copy_assignable::value) && - (is_constructible::value && - std::is_same < - typename object_t::mapped_type, - typename ConstructibleObjectType::mapped_type >::value)) || - (has_from_json::value || - has_non_default_from_json < - BasicJsonType, - typename ConstructibleObjectType::mapped_type >::value); -}; - -template -struct is_constructible_object_type - : is_constructible_object_type_impl {}; - -template -struct is_compatible_string_type -{ - static constexpr auto value = - is_constructible::value; -}; - -template -struct is_constructible_string_type -{ - static constexpr auto value = - is_constructible::value; -}; - -template -struct is_compatible_array_type_impl : std::false_type {}; - -template -struct is_compatible_array_type_impl < - BasicJsonType, CompatibleArrayType, - enable_if_t < - is_detected::value&& - is_iterator_traits>>::value&& -// special case for types like std::filesystem::path whose iterator's value_type are themselves -// c.f. https://github.com/nlohmann/json/pull/3073 - !std::is_same>::value >> -{ - static constexpr bool value = - is_constructible>::value; -}; - -template -struct is_compatible_array_type - : is_compatible_array_type_impl {}; - -template -struct is_constructible_array_type_impl : std::false_type {}; - -template -struct is_constructible_array_type_impl < - BasicJsonType, ConstructibleArrayType, - enable_if_t::value >> - : std::true_type {}; - -template -struct is_constructible_array_type_impl < - BasicJsonType, ConstructibleArrayType, - enable_if_t < !std::is_same::value&& - !is_compatible_string_type::value&& - is_default_constructible::value&& -(std::is_move_assignable::value || - std::is_copy_assignable::value)&& -is_detected::value&& -is_iterator_traits>>::value&& -is_detected::value&& -// special case for types like std::filesystem::path whose iterator's value_type are themselves -// c.f. https://github.com/nlohmann/json/pull/3073 -!std::is_same>::value&& - is_complete_type < - detected_t>::value >> -{ - using value_type = range_value_t; - - static constexpr bool value = - std::is_same::value || - has_from_json::value || - has_non_default_from_json < - BasicJsonType, - value_type >::value; -}; - -template -struct is_constructible_array_type - : is_constructible_array_type_impl {}; - -template -struct is_compatible_integer_type_impl : std::false_type {}; - -template -struct is_compatible_integer_type_impl < - RealIntegerType, CompatibleNumberIntegerType, - enable_if_t < std::is_integral::value&& - std::is_integral::value&& - !std::is_same::value >> -{ - // is there an assert somewhere on overflows? - using RealLimits = std::numeric_limits; - using CompatibleLimits = std::numeric_limits; - - static constexpr auto value = - is_constructible::value && - CompatibleLimits::is_integer && - RealLimits::is_signed == CompatibleLimits::is_signed; -}; - -template -struct is_compatible_integer_type - : is_compatible_integer_type_impl {}; - -template -struct is_compatible_type_impl: std::false_type {}; - -template -struct is_compatible_type_impl < - BasicJsonType, CompatibleType, - enable_if_t::value >> -{ - static constexpr bool value = - has_to_json::value; -}; - -template -struct is_compatible_type - : is_compatible_type_impl {}; - -template -struct is_constructible_tuple : std::false_type {}; - -template -struct is_constructible_tuple> : conjunction...> {}; - -// a naive helper to check if a type is an ordered_map (exploits the fact that -// ordered_map inherits capacity() from std::vector) -template -struct is_ordered_map -{ - using one = char; - - struct two - { - char x[2]; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) - }; - - template static one test( decltype(&C::capacity) ) ; - template static two test(...); - - enum { value = sizeof(test(nullptr)) == sizeof(char) }; // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) -}; - -// to avoid useless casts (see https://github.com/nlohmann/json/issues/2893#issuecomment-889152324) -template < typename T, typename U, enable_if_t < !std::is_same::value, int > = 0 > -T conditional_static_cast(U value) -{ - return static_cast(value); -} - -template::value, int> = 0> -T conditional_static_cast(U value) -{ - return value; -} - -} // namespace detail -} // namespace nlohmann - -// #include - - -#ifdef JSON_HAS_CPP_17 - #include -#endif - -namespace nlohmann -{ -namespace detail -{ -template -void from_json(const BasicJsonType& j, typename std::nullptr_t& n) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_null())) - { - JSON_THROW(type_error::create(302, "type must be null, but is " + std::string(j.type_name()), j)); - } - n = nullptr; -} - -// overloads for basic_json template parameters -template < typename BasicJsonType, typename ArithmeticType, - enable_if_t < std::is_arithmetic::value&& - !std::is_same::value, - int > = 0 > -void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val) -{ - switch (static_cast(j)) - { - case value_t::number_unsigned: - { - val = static_cast(*j.template get_ptr()); - break; - } - case value_t::number_integer: - { - val = static_cast(*j.template get_ptr()); - break; - } - case value_t::number_float: - { - val = static_cast(*j.template get_ptr()); - break; - } - - case value_t::null: - case value_t::object: - case value_t::array: - case value_t::string: - case value_t::boolean: - case value_t::binary: - case value_t::discarded: - default: - JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name()), j)); - } -} - -template -void from_json(const BasicJsonType& j, typename BasicJsonType::boolean_t& b) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_boolean())) - { - JSON_THROW(type_error::create(302, "type must be boolean, but is " + std::string(j.type_name()), j)); - } - b = *j.template get_ptr(); -} - -template -void from_json(const BasicJsonType& j, typename BasicJsonType::string_t& s) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_string())) - { - JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()), j)); - } - s = *j.template get_ptr(); -} - -template < - typename BasicJsonType, typename ConstructibleStringType, - enable_if_t < - is_constructible_string_type::value&& - !std::is_same::value, - int > = 0 > -void from_json(const BasicJsonType& j, ConstructibleStringType& s) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_string())) - { - JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()), j)); - } - - s = *j.template get_ptr(); -} - -template -void from_json(const BasicJsonType& j, typename BasicJsonType::number_float_t& val) -{ - get_arithmetic_value(j, val); -} - -template -void from_json(const BasicJsonType& j, typename BasicJsonType::number_unsigned_t& val) -{ - get_arithmetic_value(j, val); -} - -template -void from_json(const BasicJsonType& j, typename BasicJsonType::number_integer_t& val) -{ - get_arithmetic_value(j, val); -} - -template::value, int> = 0> -void from_json(const BasicJsonType& j, EnumType& e) -{ - typename std::underlying_type::type val; - get_arithmetic_value(j, val); - e = static_cast(val); -} - -// forward_list doesn't have an insert method -template::value, int> = 0> -void from_json(const BasicJsonType& j, std::forward_list& l) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_array())) - { - JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j)); - } - l.clear(); - std::transform(j.rbegin(), j.rend(), - std::front_inserter(l), [](const BasicJsonType & i) - { - return i.template get(); - }); -} - -// valarray doesn't have an insert method -template::value, int> = 0> -void from_json(const BasicJsonType& j, std::valarray& l) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_array())) - { - JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j)); - } - l.resize(j.size()); - std::transform(j.begin(), j.end(), std::begin(l), - [](const BasicJsonType & elem) - { - return elem.template get(); - }); -} - -template -auto from_json(const BasicJsonType& j, T (&arr)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) --> decltype(j.template get(), void()) -{ - for (std::size_t i = 0; i < N; ++i) - { - arr[i] = j.at(i).template get(); - } -} - -template -void from_json_array_impl(const BasicJsonType& j, typename BasicJsonType::array_t& arr, priority_tag<3> /*unused*/) -{ - arr = *j.template get_ptr(); -} - -template -auto from_json_array_impl(const BasicJsonType& j, std::array& arr, - priority_tag<2> /*unused*/) --> decltype(j.template get(), void()) -{ - for (std::size_t i = 0; i < N; ++i) - { - arr[i] = j.at(i).template get(); - } -} - -template::value, - int> = 0> -auto from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, priority_tag<1> /*unused*/) --> decltype( - arr.reserve(std::declval()), - j.template get(), - void()) -{ - using std::end; - - ConstructibleArrayType ret; - ret.reserve(j.size()); - std::transform(j.begin(), j.end(), - std::inserter(ret, end(ret)), [](const BasicJsonType & i) - { - // get() returns *this, this won't call a from_json - // method when value_type is BasicJsonType - return i.template get(); - }); - arr = std::move(ret); -} - -template::value, - int> = 0> -void from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, - priority_tag<0> /*unused*/) -{ - using std::end; - - ConstructibleArrayType ret; - std::transform( - j.begin(), j.end(), std::inserter(ret, end(ret)), - [](const BasicJsonType & i) - { - // get() returns *this, this won't call a from_json - // method when value_type is BasicJsonType - return i.template get(); - }); - arr = std::move(ret); -} - -template < typename BasicJsonType, typename ConstructibleArrayType, - enable_if_t < - is_constructible_array_type::value&& - !is_constructible_object_type::value&& - !is_constructible_string_type::value&& - !std::is_same::value&& - !is_basic_json::value, - int > = 0 > -auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr) --> decltype(from_json_array_impl(j, arr, priority_tag<3> {}), -j.template get(), -void()) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_array())) - { - JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j)); - } - - from_json_array_impl(j, arr, priority_tag<3> {}); -} - -template < typename BasicJsonType, typename T, std::size_t... Idx > -std::array from_json_inplace_array_impl(BasicJsonType&& j, - identity_tag> /*unused*/, index_sequence /*unused*/) -{ - return { { std::forward(j).at(Idx).template get()... } }; -} - -template < typename BasicJsonType, typename T, std::size_t N > -auto from_json(BasicJsonType&& j, identity_tag> tag) --> decltype(from_json_inplace_array_impl(std::forward(j), tag, make_index_sequence {})) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_array())) - { - JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j)); - } - - return from_json_inplace_array_impl(std::forward(j), tag, make_index_sequence {}); -} - -template -void from_json(const BasicJsonType& j, typename BasicJsonType::binary_t& bin) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_binary())) - { - JSON_THROW(type_error::create(302, "type must be binary, but is " + std::string(j.type_name()), j)); - } - - bin = *j.template get_ptr(); -} - -template::value, int> = 0> -void from_json(const BasicJsonType& j, ConstructibleObjectType& obj) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_object())) - { - JSON_THROW(type_error::create(302, "type must be object, but is " + std::string(j.type_name()), j)); - } - - ConstructibleObjectType ret; - const auto* inner_object = j.template get_ptr(); - using value_type = typename ConstructibleObjectType::value_type; - std::transform( - inner_object->begin(), inner_object->end(), - std::inserter(ret, ret.begin()), - [](typename BasicJsonType::object_t::value_type const & p) - { - return value_type(p.first, p.second.template get()); - }); - obj = std::move(ret); -} - -// overload for arithmetic types, not chosen for basic_json template arguments -// (BooleanType, etc..); note: Is it really necessary to provide explicit -// overloads for boolean_t etc. in case of a custom BooleanType which is not -// an arithmetic type? -template < typename BasicJsonType, typename ArithmeticType, - enable_if_t < - std::is_arithmetic::value&& - !std::is_same::value&& - !std::is_same::value&& - !std::is_same::value&& - !std::is_same::value, - int > = 0 > -void from_json(const BasicJsonType& j, ArithmeticType& val) -{ - switch (static_cast(j)) - { - case value_t::number_unsigned: - { - val = static_cast(*j.template get_ptr()); - break; - } - case value_t::number_integer: - { - val = static_cast(*j.template get_ptr()); - break; - } - case value_t::number_float: - { - val = static_cast(*j.template get_ptr()); - break; - } - case value_t::boolean: - { - val = static_cast(*j.template get_ptr()); - break; - } - - case value_t::null: - case value_t::object: - case value_t::array: - case value_t::string: - case value_t::binary: - case value_t::discarded: - default: - JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name()), j)); - } -} - -template -std::tuple from_json_tuple_impl_base(BasicJsonType&& j, index_sequence /*unused*/) -{ - return std::make_tuple(std::forward(j).at(Idx).template get()...); -} - -template < typename BasicJsonType, class A1, class A2 > -std::pair from_json_tuple_impl(BasicJsonType&& j, identity_tag> /*unused*/, priority_tag<0> /*unused*/) -{ - return {std::forward(j).at(0).template get(), - std::forward(j).at(1).template get()}; -} - -template -void from_json_tuple_impl(BasicJsonType&& j, std::pair& p, priority_tag<1> /*unused*/) -{ - p = from_json_tuple_impl(std::forward(j), identity_tag> {}, priority_tag<0> {}); -} - -template -std::tuple from_json_tuple_impl(BasicJsonType&& j, identity_tag> /*unused*/, priority_tag<2> /*unused*/) -{ - return from_json_tuple_impl_base(std::forward(j), index_sequence_for {}); -} - -template -void from_json_tuple_impl(BasicJsonType&& j, std::tuple& t, priority_tag<3> /*unused*/) -{ - t = from_json_tuple_impl_base(std::forward(j), index_sequence_for {}); -} - -template -auto from_json(BasicJsonType&& j, TupleRelated&& t) --> decltype(from_json_tuple_impl(std::forward(j), std::forward(t), priority_tag<3> {})) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_array())) - { - JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j)); - } - - return from_json_tuple_impl(std::forward(j), std::forward(t), priority_tag<3> {}); -} - -template < typename BasicJsonType, typename Key, typename Value, typename Compare, typename Allocator, - typename = enable_if_t < !std::is_constructible < - typename BasicJsonType::string_t, Key >::value >> -void from_json(const BasicJsonType& j, std::map& m) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_array())) - { - JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j)); - } - m.clear(); - for (const auto& p : j) - { - if (JSON_HEDLEY_UNLIKELY(!p.is_array())) - { - JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()), j)); - } - m.emplace(p.at(0).template get(), p.at(1).template get()); - } -} - -template < typename BasicJsonType, typename Key, typename Value, typename Hash, typename KeyEqual, typename Allocator, - typename = enable_if_t < !std::is_constructible < - typename BasicJsonType::string_t, Key >::value >> -void from_json(const BasicJsonType& j, std::unordered_map& m) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_array())) - { - JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j)); - } - m.clear(); - for (const auto& p : j) - { - if (JSON_HEDLEY_UNLIKELY(!p.is_array())) - { - JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()), j)); - } - m.emplace(p.at(0).template get(), p.at(1).template get()); - } -} - -#ifdef JSON_HAS_CPP_17 -template -void from_json(const BasicJsonType& j, std::filesystem::path& p) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_string())) - { - JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()), j)); - } - p = *j.template get_ptr(); -} -#endif - -struct from_json_fn -{ - template - auto operator()(const BasicJsonType& j, T&& val) const - noexcept(noexcept(from_json(j, std::forward(val)))) - -> decltype(from_json(j, std::forward(val))) - { - return from_json(j, std::forward(val)); - } -}; -} // namespace detail - -/// namespace to hold default `from_json` function -/// to see why this is required: -/// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4381.html -namespace // NOLINT(cert-dcl59-cpp,fuchsia-header-anon-namespaces,google-build-namespaces) -{ -constexpr const auto& from_json = detail::static_const::value; // NOLINT(misc-definitions-in-headers) -} // namespace -} // namespace nlohmann - -// #include - - -#include // copy -#include // begin, end -#include // string -#include // tuple, get -#include // is_same, is_constructible, is_floating_point, is_enum, underlying_type -#include // move, forward, declval, pair -#include // valarray -#include // vector - -// #include - -// #include - - -#include // size_t -#include // input_iterator_tag -#include // string, to_string -#include // tuple_size, get, tuple_element -#include // move - -// #include - -// #include - - -namespace nlohmann -{ -namespace detail -{ -template -void int_to_string( string_type& target, std::size_t value ) -{ - // For ADL - using std::to_string; - target = to_string(value); -} -template class iteration_proxy_value -{ - public: - using difference_type = std::ptrdiff_t; - using value_type = iteration_proxy_value; - using pointer = value_type * ; - using reference = value_type & ; - using iterator_category = std::input_iterator_tag; - using string_type = typename std::remove_cv< typename std::remove_reference().key() ) >::type >::type; - - private: - /// the iterator - IteratorType anchor; - /// an index for arrays (used to create key names) - std::size_t array_index = 0; - /// last stringified array index - mutable std::size_t array_index_last = 0; - /// a string representation of the array index - mutable string_type array_index_str = "0"; - /// an empty string (to return a reference for primitive values) - const string_type empty_str{}; - - public: - explicit iteration_proxy_value(IteratorType it) noexcept - : anchor(std::move(it)) - {} - - /// dereference operator (needed for range-based for) - iteration_proxy_value& operator*() - { - return *this; - } - - /// increment operator (needed for range-based for) - iteration_proxy_value& operator++() - { - ++anchor; - ++array_index; - - return *this; - } - - /// equality operator (needed for InputIterator) - bool operator==(const iteration_proxy_value& o) const - { - return anchor == o.anchor; - } - - /// inequality operator (needed for range-based for) - bool operator!=(const iteration_proxy_value& o) const - { - return anchor != o.anchor; - } - - /// return key of the iterator - const string_type& key() const - { - JSON_ASSERT(anchor.m_object != nullptr); - - switch (anchor.m_object->type()) - { - // use integer array index as key - case value_t::array: - { - if (array_index != array_index_last) - { - int_to_string( array_index_str, array_index ); - array_index_last = array_index; - } - return array_index_str; - } - - // use key from the object - case value_t::object: - return anchor.key(); - - // use an empty key for all primitive types - case value_t::null: - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - return empty_str; - } - } - - /// return value of the iterator - typename IteratorType::reference value() const - { - return anchor.value(); - } -}; - -/// proxy class for the items() function -template class iteration_proxy -{ - private: - /// the container to iterate - typename IteratorType::reference container; - - public: - /// construct iteration proxy from a container - explicit iteration_proxy(typename IteratorType::reference cont) noexcept - : container(cont) {} - - /// return iterator begin (needed for range-based for) - iteration_proxy_value begin() noexcept - { - return iteration_proxy_value(container.begin()); - } - - /// return iterator end (needed for range-based for) - iteration_proxy_value end() noexcept - { - return iteration_proxy_value(container.end()); - } -}; -// Structured Bindings Support -// For further reference see https://blog.tartanllama.xyz/structured-bindings/ -// And see https://github.com/nlohmann/json/pull/1391 -template = 0> -auto get(const nlohmann::detail::iteration_proxy_value& i) -> decltype(i.key()) -{ - return i.key(); -} -// Structured Bindings Support -// For further reference see https://blog.tartanllama.xyz/structured-bindings/ -// And see https://github.com/nlohmann/json/pull/1391 -template = 0> -auto get(const nlohmann::detail::iteration_proxy_value& i) -> decltype(i.value()) -{ - return i.value(); -} -} // namespace detail -} // namespace nlohmann - -// The Addition to the STD Namespace is required to add -// Structured Bindings Support to the iteration_proxy_value class -// For further reference see https://blog.tartanllama.xyz/structured-bindings/ -// And see https://github.com/nlohmann/json/pull/1391 -namespace std -{ -#if defined(__clang__) - // Fix: https://github.com/nlohmann/json/issues/1401 - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Wmismatched-tags" -#endif -template -class tuple_size<::nlohmann::detail::iteration_proxy_value> - : public std::integral_constant {}; - -template -class tuple_element> -{ - public: - using type = decltype( - get(std::declval < - ::nlohmann::detail::iteration_proxy_value> ())); -}; -#if defined(__clang__) - #pragma clang diagnostic pop -#endif -} // namespace std - -// #include - -// #include - -// #include - - -#ifdef JSON_HAS_CPP_17 - #include -#endif - -namespace nlohmann -{ -namespace detail -{ -////////////////// -// constructors // -////////////////// - -/* - * Note all external_constructor<>::construct functions need to call - * j.m_value.destroy(j.m_type) to avoid a memory leak in case j contains an - * allocated value (e.g., a string). See bug issue - * https://github.com/nlohmann/json/issues/2865 for more information. - */ - -template struct external_constructor; - -template<> -struct external_constructor -{ - template - static void construct(BasicJsonType& j, typename BasicJsonType::boolean_t b) noexcept - { - j.m_value.destroy(j.m_type); - j.m_type = value_t::boolean; - j.m_value = b; - j.assert_invariant(); - } -}; - -template<> -struct external_constructor -{ - template - static void construct(BasicJsonType& j, const typename BasicJsonType::string_t& s) - { - j.m_value.destroy(j.m_type); - j.m_type = value_t::string; - j.m_value = s; - j.assert_invariant(); - } - - template - static void construct(BasicJsonType& j, typename BasicJsonType::string_t&& s) - { - j.m_value.destroy(j.m_type); - j.m_type = value_t::string; - j.m_value = std::move(s); - j.assert_invariant(); - } - - template < typename BasicJsonType, typename CompatibleStringType, - enable_if_t < !std::is_same::value, - int > = 0 > - static void construct(BasicJsonType& j, const CompatibleStringType& str) - { - j.m_value.destroy(j.m_type); - j.m_type = value_t::string; - j.m_value.string = j.template create(str); - j.assert_invariant(); - } -}; - -template<> -struct external_constructor -{ - template - static void construct(BasicJsonType& j, const typename BasicJsonType::binary_t& b) - { - j.m_value.destroy(j.m_type); - j.m_type = value_t::binary; - j.m_value = typename BasicJsonType::binary_t(b); - j.assert_invariant(); - } - - template - static void construct(BasicJsonType& j, typename BasicJsonType::binary_t&& b) - { - j.m_value.destroy(j.m_type); - j.m_type = value_t::binary; - j.m_value = typename BasicJsonType::binary_t(std::move(b)); - j.assert_invariant(); - } -}; - -template<> -struct external_constructor -{ - template - static void construct(BasicJsonType& j, typename BasicJsonType::number_float_t val) noexcept - { - j.m_value.destroy(j.m_type); - j.m_type = value_t::number_float; - j.m_value = val; - j.assert_invariant(); - } -}; - -template<> -struct external_constructor -{ - template - static void construct(BasicJsonType& j, typename BasicJsonType::number_unsigned_t val) noexcept - { - j.m_value.destroy(j.m_type); - j.m_type = value_t::number_unsigned; - j.m_value = val; - j.assert_invariant(); - } -}; - -template<> -struct external_constructor -{ - template - static void construct(BasicJsonType& j, typename BasicJsonType::number_integer_t val) noexcept - { - j.m_value.destroy(j.m_type); - j.m_type = value_t::number_integer; - j.m_value = val; - j.assert_invariant(); - } -}; - -template<> -struct external_constructor -{ - template - static void construct(BasicJsonType& j, const typename BasicJsonType::array_t& arr) - { - j.m_value.destroy(j.m_type); - j.m_type = value_t::array; - j.m_value = arr; - j.set_parents(); - j.assert_invariant(); - } - - template - static void construct(BasicJsonType& j, typename BasicJsonType::array_t&& arr) - { - j.m_value.destroy(j.m_type); - j.m_type = value_t::array; - j.m_value = std::move(arr); - j.set_parents(); - j.assert_invariant(); - } - - template < typename BasicJsonType, typename CompatibleArrayType, - enable_if_t < !std::is_same::value, - int > = 0 > - static void construct(BasicJsonType& j, const CompatibleArrayType& arr) - { - using std::begin; - using std::end; - - j.m_value.destroy(j.m_type); - j.m_type = value_t::array; - j.m_value.array = j.template create(begin(arr), end(arr)); - j.set_parents(); - j.assert_invariant(); - } - - template - static void construct(BasicJsonType& j, const std::vector& arr) - { - j.m_value.destroy(j.m_type); - j.m_type = value_t::array; - j.m_value = value_t::array; - j.m_value.array->reserve(arr.size()); - for (const bool x : arr) - { - j.m_value.array->push_back(x); - j.set_parent(j.m_value.array->back()); - } - j.assert_invariant(); - } - - template::value, int> = 0> - static void construct(BasicJsonType& j, const std::valarray& arr) - { - j.m_value.destroy(j.m_type); - j.m_type = value_t::array; - j.m_value = value_t::array; - j.m_value.array->resize(arr.size()); - if (arr.size() > 0) - { - std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin()); - } - j.set_parents(); - j.assert_invariant(); - } -}; - -template<> -struct external_constructor -{ - template - static void construct(BasicJsonType& j, const typename BasicJsonType::object_t& obj) - { - j.m_value.destroy(j.m_type); - j.m_type = value_t::object; - j.m_value = obj; - j.set_parents(); - j.assert_invariant(); - } - - template - static void construct(BasicJsonType& j, typename BasicJsonType::object_t&& obj) - { - j.m_value.destroy(j.m_type); - j.m_type = value_t::object; - j.m_value = std::move(obj); - j.set_parents(); - j.assert_invariant(); - } - - template < typename BasicJsonType, typename CompatibleObjectType, - enable_if_t < !std::is_same::value, int > = 0 > - static void construct(BasicJsonType& j, const CompatibleObjectType& obj) - { - using std::begin; - using std::end; - - j.m_value.destroy(j.m_type); - j.m_type = value_t::object; - j.m_value.object = j.template create(begin(obj), end(obj)); - j.set_parents(); - j.assert_invariant(); - } -}; - -///////////// -// to_json // -///////////// - -template::value, int> = 0> -void to_json(BasicJsonType& j, T b) noexcept -{ - external_constructor::construct(j, b); -} - -template::value, int> = 0> -void to_json(BasicJsonType& j, const CompatibleString& s) -{ - external_constructor::construct(j, s); -} - -template -void to_json(BasicJsonType& j, typename BasicJsonType::string_t&& s) -{ - external_constructor::construct(j, std::move(s)); -} - -template::value, int> = 0> -void to_json(BasicJsonType& j, FloatType val) noexcept -{ - external_constructor::construct(j, static_cast(val)); -} - -template::value, int> = 0> -void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noexcept -{ - external_constructor::construct(j, static_cast(val)); -} - -template::value, int> = 0> -void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noexcept -{ - external_constructor::construct(j, static_cast(val)); -} - -template::value, int> = 0> -void to_json(BasicJsonType& j, EnumType e) noexcept -{ - using underlying_type = typename std::underlying_type::type; - external_constructor::construct(j, static_cast(e)); -} - -template -void to_json(BasicJsonType& j, const std::vector& e) -{ - external_constructor::construct(j, e); -} - -template < typename BasicJsonType, typename CompatibleArrayType, - enable_if_t < is_compatible_array_type::value&& - !is_compatible_object_type::value&& - !is_compatible_string_type::value&& - !std::is_same::value&& - !is_basic_json::value, - int > = 0 > -void to_json(BasicJsonType& j, const CompatibleArrayType& arr) -{ - external_constructor::construct(j, arr); -} - -template -void to_json(BasicJsonType& j, const typename BasicJsonType::binary_t& bin) -{ - external_constructor::construct(j, bin); -} - -template::value, int> = 0> -void to_json(BasicJsonType& j, const std::valarray& arr) -{ - external_constructor::construct(j, std::move(arr)); -} - -template -void to_json(BasicJsonType& j, typename BasicJsonType::array_t&& arr) -{ - external_constructor::construct(j, std::move(arr)); -} - -template < typename BasicJsonType, typename CompatibleObjectType, - enable_if_t < is_compatible_object_type::value&& !is_basic_json::value, int > = 0 > -void to_json(BasicJsonType& j, const CompatibleObjectType& obj) -{ - external_constructor::construct(j, obj); -} - -template -void to_json(BasicJsonType& j, typename BasicJsonType::object_t&& obj) -{ - external_constructor::construct(j, std::move(obj)); -} - -template < - typename BasicJsonType, typename T, std::size_t N, - enable_if_t < !std::is_constructible::value, // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) - int > = 0 > -void to_json(BasicJsonType& j, const T(&arr)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) -{ - external_constructor::construct(j, arr); -} - -template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible::value&& std::is_constructible::value, int > = 0 > -void to_json(BasicJsonType& j, const std::pair& p) -{ - j = { p.first, p.second }; -} - -// for https://github.com/nlohmann/json/pull/1134 -template>::value, int> = 0> -void to_json(BasicJsonType& j, const T& b) -{ - j = { {b.key(), b.value()} }; -} - -template -void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequence /*unused*/) -{ - j = { std::get(t)... }; -} - -template::value, int > = 0> -void to_json(BasicJsonType& j, const T& t) -{ - to_json_tuple_impl(j, t, make_index_sequence::value> {}); -} - -#ifdef JSON_HAS_CPP_17 -template -void to_json(BasicJsonType& j, const std::filesystem::path& p) -{ - j = p.string(); -} -#endif - -struct to_json_fn -{ - template - auto operator()(BasicJsonType& j, T&& val) const noexcept(noexcept(to_json(j, std::forward(val)))) - -> decltype(to_json(j, std::forward(val)), void()) - { - return to_json(j, std::forward(val)); - } -}; -} // namespace detail - -/// namespace to hold default `to_json` function -/// to see why this is required: -/// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4381.html -namespace // NOLINT(cert-dcl59-cpp,fuchsia-header-anon-namespaces,google-build-namespaces) -{ -constexpr const auto& to_json = detail::static_const::value; // NOLINT(misc-definitions-in-headers) -} // namespace -} // namespace nlohmann - -// #include - -// #include - - -namespace nlohmann -{ - -template -struct adl_serializer -{ - /*! - @brief convert a JSON value to any value type - - This function is usually called by the `get()` function of the - @ref basic_json class (either explicit or via conversion operators). - - @note This function is chosen for default-constructible value types. - - @param[in] j JSON value to read from - @param[in,out] val value to write to - */ - template - static auto from_json(BasicJsonType && j, TargetType& val) noexcept( - noexcept(::nlohmann::from_json(std::forward(j), val))) - -> decltype(::nlohmann::from_json(std::forward(j), val), void()) - { - ::nlohmann::from_json(std::forward(j), val); - } - - /*! - @brief convert a JSON value to any value type - - This function is usually called by the `get()` function of the - @ref basic_json class (either explicit or via conversion operators). - - @note This function is chosen for value types which are not default-constructible. - - @param[in] j JSON value to read from - - @return copy of the JSON value, converted to @a ValueType - */ - template - static auto from_json(BasicJsonType && j) noexcept( - noexcept(::nlohmann::from_json(std::forward(j), detail::identity_tag {}))) - -> decltype(::nlohmann::from_json(std::forward(j), detail::identity_tag {})) - { - return ::nlohmann::from_json(std::forward(j), detail::identity_tag {}); - } - - /*! - @brief convert any value type to a JSON value - - This function is usually called by the constructors of the @ref basic_json - class. - - @param[in,out] j JSON value to write to - @param[in] val value to read from - */ - template - static auto to_json(BasicJsonType& j, TargetType && val) noexcept( - noexcept(::nlohmann::to_json(j, std::forward(val)))) - -> decltype(::nlohmann::to_json(j, std::forward(val)), void()) - { - ::nlohmann::to_json(j, std::forward(val)); - } -}; -} // namespace nlohmann - -// #include - - -#include // uint8_t, uint64_t -#include // tie -#include // move - -namespace nlohmann -{ - -/*! -@brief an internal type for a backed binary type - -This type extends the template parameter @a BinaryType provided to `basic_json` -with a subtype used by BSON and MessagePack. This type exists so that the user -does not have to specify a type themselves with a specific naming scheme in -order to override the binary type. - -@tparam BinaryType container to store bytes (`std::vector` by - default) - -@since version 3.8.0; changed type of subtypes to std::uint64_t in 3.10.0. -*/ -template -class byte_container_with_subtype : public BinaryType -{ - public: - /// the type of the underlying container - using container_type = BinaryType; - /// the type of the subtype - using subtype_type = std::uint64_t; - - byte_container_with_subtype() noexcept(noexcept(container_type())) - : container_type() - {} - - byte_container_with_subtype(const container_type& b) noexcept(noexcept(container_type(b))) - : container_type(b) - {} - - byte_container_with_subtype(container_type&& b) noexcept(noexcept(container_type(std::move(b)))) - : container_type(std::move(b)) - {} - - byte_container_with_subtype(const container_type& b, subtype_type subtype_) noexcept(noexcept(container_type(b))) - : container_type(b) - , m_subtype(subtype_) - , m_has_subtype(true) - {} - - byte_container_with_subtype(container_type&& b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b)))) - : container_type(std::move(b)) - , m_subtype(subtype_) - , m_has_subtype(true) - {} - - bool operator==(const byte_container_with_subtype& rhs) const - { - return std::tie(static_cast(*this), m_subtype, m_has_subtype) == - std::tie(static_cast(rhs), rhs.m_subtype, rhs.m_has_subtype); - } - - bool operator!=(const byte_container_with_subtype& rhs) const - { - return !(rhs == *this); - } - - /*! - @brief sets the binary subtype - - Sets the binary subtype of the value, also flags a binary JSON value as - having a subtype, which has implications for serialization. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @sa see @ref subtype() -- return the binary subtype - @sa see @ref clear_subtype() -- clears the binary subtype - @sa see @ref has_subtype() -- returns whether or not the binary value has a - subtype - - @since version 3.8.0 - */ - void set_subtype(subtype_type subtype_) noexcept - { - m_subtype = subtype_; - m_has_subtype = true; - } - - /*! - @brief return the binary subtype - - Returns the numerical subtype of the value if it has a subtype. If it does - not have a subtype, this function will return subtype_type(-1) as a sentinel - value. - - @return the numerical subtype of the binary value - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @sa see @ref set_subtype() -- sets the binary subtype - @sa see @ref clear_subtype() -- clears the binary subtype - @sa see @ref has_subtype() -- returns whether or not the binary value has a - subtype - - @since version 3.8.0; fixed return value to properly return - subtype_type(-1) as documented in version 3.10.0 - */ - constexpr subtype_type subtype() const noexcept - { - return m_has_subtype ? m_subtype : subtype_type(-1); - } - - /*! - @brief return whether the value has a subtype - - @return whether the value has a subtype - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @sa see @ref subtype() -- return the binary subtype - @sa see @ref set_subtype() -- sets the binary subtype - @sa see @ref clear_subtype() -- clears the binary subtype - - @since version 3.8.0 - */ - constexpr bool has_subtype() const noexcept - { - return m_has_subtype; - } - - /*! - @brief clears the binary subtype - - Clears the binary subtype and flags the value as not having a subtype, which - has implications for serialization; for instance MessagePack will prefer the - bin family over the ext family. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @sa see @ref subtype() -- return the binary subtype - @sa see @ref set_subtype() -- sets the binary subtype - @sa see @ref has_subtype() -- returns whether or not the binary value has a - subtype - - @since version 3.8.0 - */ - void clear_subtype() noexcept - { - m_subtype = 0; - m_has_subtype = false; - } - - private: - subtype_type m_subtype = 0; - bool m_has_subtype = false; -}; - -} // namespace nlohmann - -// #include - -// #include - -// #include - -// #include - - -#include // uint8_t -#include // size_t -#include // hash - -// #include - -// #include - - -namespace nlohmann -{ -namespace detail -{ - -// boost::hash_combine -inline std::size_t combine(std::size_t seed, std::size_t h) noexcept -{ - seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U); - return seed; -} - -/*! -@brief hash a JSON value - -The hash function tries to rely on std::hash where possible. Furthermore, the -type of the JSON value is taken into account to have different hash values for -null, 0, 0U, and false, etc. - -@tparam BasicJsonType basic_json specialization -@param j JSON value to hash -@return hash value of j -*/ -template -std::size_t hash(const BasicJsonType& j) -{ - using string_t = typename BasicJsonType::string_t; - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - - const auto type = static_cast(j.type()); - switch (j.type()) - { - case BasicJsonType::value_t::null: - case BasicJsonType::value_t::discarded: - { - return combine(type, 0); - } - - case BasicJsonType::value_t::object: - { - auto seed = combine(type, j.size()); - for (const auto& element : j.items()) - { - const auto h = std::hash {}(element.key()); - seed = combine(seed, h); - seed = combine(seed, hash(element.value())); - } - return seed; - } - - case BasicJsonType::value_t::array: - { - auto seed = combine(type, j.size()); - for (const auto& element : j) - { - seed = combine(seed, hash(element)); - } - return seed; - } - - case BasicJsonType::value_t::string: - { - const auto h = std::hash {}(j.template get_ref()); - return combine(type, h); - } - - case BasicJsonType::value_t::boolean: - { - const auto h = std::hash {}(j.template get()); - return combine(type, h); - } - - case BasicJsonType::value_t::number_integer: - { - const auto h = std::hash {}(j.template get()); - return combine(type, h); - } - - case BasicJsonType::value_t::number_unsigned: - { - const auto h = std::hash {}(j.template get()); - return combine(type, h); - } - - case BasicJsonType::value_t::number_float: - { - const auto h = std::hash {}(j.template get()); - return combine(type, h); - } - - case BasicJsonType::value_t::binary: - { - auto seed = combine(type, j.get_binary().size()); - const auto h = std::hash {}(j.get_binary().has_subtype()); - seed = combine(seed, h); - seed = combine(seed, static_cast(j.get_binary().subtype())); - for (const auto byte : j.get_binary()) - { - seed = combine(seed, std::hash {}(byte)); - } - return seed; - } - - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE - return 0; // LCOV_EXCL_LINE - } -} - -} // namespace detail -} // namespace nlohmann - -// #include - - -#include // generate_n -#include // array -#include // ldexp -#include // size_t -#include // uint8_t, uint16_t, uint32_t, uint64_t -#include // snprintf -#include // memcpy -#include // back_inserter -#include // numeric_limits -#include // char_traits, string -#include // make_pair, move -#include // vector - -// #include - -// #include - - -#include // array -#include // size_t -#include // strlen -#include // begin, end, iterator_traits, random_access_iterator_tag, distance, next -#include // shared_ptr, make_shared, addressof -#include // accumulate -#include // string, char_traits -#include // enable_if, is_base_of, is_pointer, is_integral, remove_pointer -#include // pair, declval - -#ifndef JSON_NO_IO - #include // FILE * - #include // istream -#endif // JSON_NO_IO - -// #include - -// #include - - -namespace nlohmann -{ -namespace detail -{ -/// the supported input formats -enum class input_format_t { json, cbor, msgpack, ubjson, bson }; - -//////////////////// -// input adapters // -//////////////////// - -#ifndef JSON_NO_IO -/*! -Input adapter for stdio file access. This adapter read only 1 byte and do not use any - buffer. This adapter is a very low level adapter. -*/ -class file_input_adapter -{ - public: - using char_type = char; - - JSON_HEDLEY_NON_NULL(2) - explicit file_input_adapter(std::FILE* f) noexcept - : m_file(f) - {} - - // make class move-only - file_input_adapter(const file_input_adapter&) = delete; - file_input_adapter(file_input_adapter&&) noexcept = default; - file_input_adapter& operator=(const file_input_adapter&) = delete; - file_input_adapter& operator=(file_input_adapter&&) = delete; - ~file_input_adapter() = default; - - std::char_traits::int_type get_character() noexcept - { - return std::fgetc(m_file); - } - - private: - /// the file pointer to read from - std::FILE* m_file; -}; - - -/*! -Input adapter for a (caching) istream. Ignores a UFT Byte Order Mark at -beginning of input. Does not support changing the underlying std::streambuf -in mid-input. Maintains underlying std::istream and std::streambuf to support -subsequent use of standard std::istream operations to process any input -characters following those used in parsing the JSON input. Clears the -std::istream flags; any input errors (e.g., EOF) will be detected by the first -subsequent call for input from the std::istream. -*/ -class input_stream_adapter -{ - public: - using char_type = char; - - ~input_stream_adapter() - { - // clear stream flags; we use underlying streambuf I/O, do not - // maintain ifstream flags, except eof - if (is != nullptr) - { - is->clear(is->rdstate() & std::ios::eofbit); - } - } - - explicit input_stream_adapter(std::istream& i) - : is(&i), sb(i.rdbuf()) - {} - - // delete because of pointer members - input_stream_adapter(const input_stream_adapter&) = delete; - input_stream_adapter& operator=(input_stream_adapter&) = delete; - input_stream_adapter& operator=(input_stream_adapter&&) = delete; - - input_stream_adapter(input_stream_adapter&& rhs) noexcept - : is(rhs.is), sb(rhs.sb) - { - rhs.is = nullptr; - rhs.sb = nullptr; - } - - // std::istream/std::streambuf use std::char_traits::to_int_type, to - // ensure that std::char_traits::eof() and the character 0xFF do not - // end up as the same value, eg. 0xFFFFFFFF. - std::char_traits::int_type get_character() - { - auto res = sb->sbumpc(); - // set eof manually, as we don't use the istream interface. - if (JSON_HEDLEY_UNLIKELY(res == std::char_traits::eof())) - { - is->clear(is->rdstate() | std::ios::eofbit); - } - return res; - } - - private: - /// the associated input stream - std::istream* is = nullptr; - std::streambuf* sb = nullptr; -}; -#endif // JSON_NO_IO - -// General-purpose iterator-based adapter. It might not be as fast as -// theoretically possible for some containers, but it is extremely versatile. -template -class iterator_input_adapter -{ - public: - using char_type = typename std::iterator_traits::value_type; - - iterator_input_adapter(IteratorType first, IteratorType last) - : current(std::move(first)), end(std::move(last)) - {} - - typename std::char_traits::int_type get_character() - { - if (JSON_HEDLEY_LIKELY(current != end)) - { - auto result = std::char_traits::to_int_type(*current); - std::advance(current, 1); - return result; - } - - return std::char_traits::eof(); - } - - private: - IteratorType current; - IteratorType end; - - template - friend struct wide_string_input_helper; - - bool empty() const - { - return current == end; - } -}; - - -template -struct wide_string_input_helper; - -template -struct wide_string_input_helper -{ - // UTF-32 - static void fill_buffer(BaseInputAdapter& input, - std::array::int_type, 4>& utf8_bytes, - size_t& utf8_bytes_index, - size_t& utf8_bytes_filled) - { - utf8_bytes_index = 0; - - if (JSON_HEDLEY_UNLIKELY(input.empty())) - { - utf8_bytes[0] = std::char_traits::eof(); - utf8_bytes_filled = 1; - } - else - { - // get the current character - const auto wc = input.get_character(); - - // UTF-32 to UTF-8 encoding - if (wc < 0x80) - { - utf8_bytes[0] = static_cast::int_type>(wc); - utf8_bytes_filled = 1; - } - else if (wc <= 0x7FF) - { - utf8_bytes[0] = static_cast::int_type>(0xC0u | ((static_cast(wc) >> 6u) & 0x1Fu)); - utf8_bytes[1] = static_cast::int_type>(0x80u | (static_cast(wc) & 0x3Fu)); - utf8_bytes_filled = 2; - } - else if (wc <= 0xFFFF) - { - utf8_bytes[0] = static_cast::int_type>(0xE0u | ((static_cast(wc) >> 12u) & 0x0Fu)); - utf8_bytes[1] = static_cast::int_type>(0x80u | ((static_cast(wc) >> 6u) & 0x3Fu)); - utf8_bytes[2] = static_cast::int_type>(0x80u | (static_cast(wc) & 0x3Fu)); - utf8_bytes_filled = 3; - } - else if (wc <= 0x10FFFF) - { - utf8_bytes[0] = static_cast::int_type>(0xF0u | ((static_cast(wc) >> 18u) & 0x07u)); - utf8_bytes[1] = static_cast::int_type>(0x80u | ((static_cast(wc) >> 12u) & 0x3Fu)); - utf8_bytes[2] = static_cast::int_type>(0x80u | ((static_cast(wc) >> 6u) & 0x3Fu)); - utf8_bytes[3] = static_cast::int_type>(0x80u | (static_cast(wc) & 0x3Fu)); - utf8_bytes_filled = 4; - } - else - { - // unknown character - utf8_bytes[0] = static_cast::int_type>(wc); - utf8_bytes_filled = 1; - } - } - } -}; - -template -struct wide_string_input_helper -{ - // UTF-16 - static void fill_buffer(BaseInputAdapter& input, - std::array::int_type, 4>& utf8_bytes, - size_t& utf8_bytes_index, - size_t& utf8_bytes_filled) - { - utf8_bytes_index = 0; - - if (JSON_HEDLEY_UNLIKELY(input.empty())) - { - utf8_bytes[0] = std::char_traits::eof(); - utf8_bytes_filled = 1; - } - else - { - // get the current character - const auto wc = input.get_character(); - - // UTF-16 to UTF-8 encoding - if (wc < 0x80) - { - utf8_bytes[0] = static_cast::int_type>(wc); - utf8_bytes_filled = 1; - } - else if (wc <= 0x7FF) - { - utf8_bytes[0] = static_cast::int_type>(0xC0u | ((static_cast(wc) >> 6u))); - utf8_bytes[1] = static_cast::int_type>(0x80u | (static_cast(wc) & 0x3Fu)); - utf8_bytes_filled = 2; - } - else if (0xD800 > wc || wc >= 0xE000) - { - utf8_bytes[0] = static_cast::int_type>(0xE0u | ((static_cast(wc) >> 12u))); - utf8_bytes[1] = static_cast::int_type>(0x80u | ((static_cast(wc) >> 6u) & 0x3Fu)); - utf8_bytes[2] = static_cast::int_type>(0x80u | (static_cast(wc) & 0x3Fu)); - utf8_bytes_filled = 3; - } - else - { - if (JSON_HEDLEY_UNLIKELY(!input.empty())) - { - const auto wc2 = static_cast(input.get_character()); - const auto charcode = 0x10000u + (((static_cast(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu)); - utf8_bytes[0] = static_cast::int_type>(0xF0u | (charcode >> 18u)); - utf8_bytes[1] = static_cast::int_type>(0x80u | ((charcode >> 12u) & 0x3Fu)); - utf8_bytes[2] = static_cast::int_type>(0x80u | ((charcode >> 6u) & 0x3Fu)); - utf8_bytes[3] = static_cast::int_type>(0x80u | (charcode & 0x3Fu)); - utf8_bytes_filled = 4; - } - else - { - utf8_bytes[0] = static_cast::int_type>(wc); - utf8_bytes_filled = 1; - } - } - } - } -}; - -// Wraps another input apdater to convert wide character types into individual bytes. -template -class wide_string_input_adapter -{ - public: - using char_type = char; - - wide_string_input_adapter(BaseInputAdapter base) - : base_adapter(base) {} - - typename std::char_traits::int_type get_character() noexcept - { - // check if buffer needs to be filled - if (utf8_bytes_index == utf8_bytes_filled) - { - fill_buffer(); - - JSON_ASSERT(utf8_bytes_filled > 0); - JSON_ASSERT(utf8_bytes_index == 0); - } - - // use buffer - JSON_ASSERT(utf8_bytes_filled > 0); - JSON_ASSERT(utf8_bytes_index < utf8_bytes_filled); - return utf8_bytes[utf8_bytes_index++]; - } - - private: - BaseInputAdapter base_adapter; - - template - void fill_buffer() - { - wide_string_input_helper::fill_buffer(base_adapter, utf8_bytes, utf8_bytes_index, utf8_bytes_filled); - } - - /// a buffer for UTF-8 bytes - std::array::int_type, 4> utf8_bytes = {{0, 0, 0, 0}}; - - /// index to the utf8_codes array for the next valid byte - std::size_t utf8_bytes_index = 0; - /// number of valid bytes in the utf8_codes array - std::size_t utf8_bytes_filled = 0; -}; - - -template -struct iterator_input_adapter_factory -{ - using iterator_type = IteratorType; - using char_type = typename std::iterator_traits::value_type; - using adapter_type = iterator_input_adapter; - - static adapter_type create(IteratorType first, IteratorType last) - { - return adapter_type(std::move(first), std::move(last)); - } -}; - -template -struct is_iterator_of_multibyte -{ - using value_type = typename std::iterator_traits::value_type; - enum - { - value = sizeof(value_type) > 1 - }; -}; - -template -struct iterator_input_adapter_factory::value>> -{ - using iterator_type = IteratorType; - using char_type = typename std::iterator_traits::value_type; - using base_adapter_type = iterator_input_adapter; - using adapter_type = wide_string_input_adapter; - - static adapter_type create(IteratorType first, IteratorType last) - { - return adapter_type(base_adapter_type(std::move(first), std::move(last))); - } -}; - -// General purpose iterator-based input -template -typename iterator_input_adapter_factory::adapter_type input_adapter(IteratorType first, IteratorType last) -{ - using factory_type = iterator_input_adapter_factory; - return factory_type::create(first, last); -} - -// Convenience shorthand from container to iterator -// Enables ADL on begin(container) and end(container) -// Encloses the using declarations in namespace for not to leak them to outside scope - -namespace container_input_adapter_factory_impl -{ - -using std::begin; -using std::end; - -template -struct container_input_adapter_factory {}; - -template -struct container_input_adapter_factory< ContainerType, - void_t()), end(std::declval()))>> - { - using adapter_type = decltype(input_adapter(begin(std::declval()), end(std::declval()))); - - static adapter_type create(const ContainerType& container) -{ - return input_adapter(begin(container), end(container)); -} - }; - -} // namespace container_input_adapter_factory_impl - -template -typename container_input_adapter_factory_impl::container_input_adapter_factory::adapter_type input_adapter(const ContainerType& container) -{ - return container_input_adapter_factory_impl::container_input_adapter_factory::create(container); -} - -#ifndef JSON_NO_IO -// Special cases with fast paths -inline file_input_adapter input_adapter(std::FILE* file) -{ - return file_input_adapter(file); -} - -inline input_stream_adapter input_adapter(std::istream& stream) -{ - return input_stream_adapter(stream); -} - -inline input_stream_adapter input_adapter(std::istream&& stream) -{ - return input_stream_adapter(stream); -} -#endif // JSON_NO_IO - -using contiguous_bytes_input_adapter = decltype(input_adapter(std::declval(), std::declval())); - -// Null-delimited strings, and the like. -template < typename CharT, - typename std::enable_if < - std::is_pointer::value&& - !std::is_array::value&& - std::is_integral::type>::value&& - sizeof(typename std::remove_pointer::type) == 1, - int >::type = 0 > -contiguous_bytes_input_adapter input_adapter(CharT b) -{ - auto length = std::strlen(reinterpret_cast(b)); - const auto* ptr = reinterpret_cast(b); - return input_adapter(ptr, ptr + length); -} - -template -auto input_adapter(T (&array)[N]) -> decltype(input_adapter(array, array + N)) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) -{ - return input_adapter(array, array + N); -} - -// This class only handles inputs of input_buffer_adapter type. -// It's required so that expressions like {ptr, len} can be implicitely casted -// to the correct adapter. -class span_input_adapter -{ - public: - template < typename CharT, - typename std::enable_if < - std::is_pointer::value&& - std::is_integral::type>::value&& - sizeof(typename std::remove_pointer::type) == 1, - int >::type = 0 > - span_input_adapter(CharT b, std::size_t l) - : ia(reinterpret_cast(b), reinterpret_cast(b) + l) {} - - template::iterator_category, std::random_access_iterator_tag>::value, - int>::type = 0> - span_input_adapter(IteratorType first, IteratorType last) - : ia(input_adapter(first, last)) {} - - contiguous_bytes_input_adapter&& get() - { - return std::move(ia); // NOLINT(hicpp-move-const-arg,performance-move-const-arg) - } - - private: - contiguous_bytes_input_adapter ia; -}; -} // namespace detail -} // namespace nlohmann - -// #include - - -#include -#include // string -#include // move -#include // vector - -// #include - -// #include - - -namespace nlohmann -{ - -/*! -@brief SAX interface - -This class describes the SAX interface used by @ref nlohmann::json::sax_parse. -Each function is called in different situations while the input is parsed. The -boolean return value informs the parser whether to continue processing the -input. -*/ -template -struct json_sax -{ - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using binary_t = typename BasicJsonType::binary_t; - - /*! - @brief a null value was read - @return whether parsing should proceed - */ - virtual bool null() = 0; - - /*! - @brief a boolean value was read - @param[in] val boolean value - @return whether parsing should proceed - */ - virtual bool boolean(bool val) = 0; - - /*! - @brief an integer number was read - @param[in] val integer value - @return whether parsing should proceed - */ - virtual bool number_integer(number_integer_t val) = 0; - - /*! - @brief an unsigned integer number was read - @param[in] val unsigned integer value - @return whether parsing should proceed - */ - virtual bool number_unsigned(number_unsigned_t val) = 0; - - /*! - @brief an floating-point number was read - @param[in] val floating-point value - @param[in] s raw token value - @return whether parsing should proceed - */ - virtual bool number_float(number_float_t val, const string_t& s) = 0; - - /*! - @brief a string was read - @param[in] val string value - @return whether parsing should proceed - @note It is safe to move the passed string. - */ - virtual bool string(string_t& val) = 0; - - /*! - @brief a binary string was read - @param[in] val binary value - @return whether parsing should proceed - @note It is safe to move the passed binary. - */ - virtual bool binary(binary_t& val) = 0; - - /*! - @brief the beginning of an object was read - @param[in] elements number of object elements or -1 if unknown - @return whether parsing should proceed - @note binary formats may report the number of elements - */ - virtual bool start_object(std::size_t elements) = 0; - - /*! - @brief an object key was read - @param[in] val object key - @return whether parsing should proceed - @note It is safe to move the passed string. - */ - virtual bool key(string_t& val) = 0; - - /*! - @brief the end of an object was read - @return whether parsing should proceed - */ - virtual bool end_object() = 0; - - /*! - @brief the beginning of an array was read - @param[in] elements number of array elements or -1 if unknown - @return whether parsing should proceed - @note binary formats may report the number of elements - */ - virtual bool start_array(std::size_t elements) = 0; - - /*! - @brief the end of an array was read - @return whether parsing should proceed - */ - virtual bool end_array() = 0; - - /*! - @brief a parse error occurred - @param[in] position the position in the input where the error occurs - @param[in] last_token the last read token - @param[in] ex an exception object describing the error - @return whether parsing should proceed (must return false) - */ - virtual bool parse_error(std::size_t position, - const std::string& last_token, - const detail::exception& ex) = 0; - - json_sax() = default; - json_sax(const json_sax&) = default; - json_sax(json_sax&&) noexcept = default; - json_sax& operator=(const json_sax&) = default; - json_sax& operator=(json_sax&&) noexcept = default; - virtual ~json_sax() = default; -}; - - -namespace detail -{ -/*! -@brief SAX implementation to create a JSON value from SAX events - -This class implements the @ref json_sax interface and processes the SAX events -to create a JSON value which makes it basically a DOM parser. The structure or -hierarchy of the JSON value is managed by the stack `ref_stack` which contains -a pointer to the respective array or object for each recursion depth. - -After successful parsing, the value that is passed by reference to the -constructor contains the parsed value. - -@tparam BasicJsonType the JSON type -*/ -template -class json_sax_dom_parser -{ - public: - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using binary_t = typename BasicJsonType::binary_t; - - /*! - @param[in,out] r reference to a JSON value that is manipulated while - parsing - @param[in] allow_exceptions_ whether parse errors yield exceptions - */ - explicit json_sax_dom_parser(BasicJsonType& r, const bool allow_exceptions_ = true) - : root(r), allow_exceptions(allow_exceptions_) - {} - - // make class move-only - json_sax_dom_parser(const json_sax_dom_parser&) = delete; - json_sax_dom_parser(json_sax_dom_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) - json_sax_dom_parser& operator=(const json_sax_dom_parser&) = delete; - json_sax_dom_parser& operator=(json_sax_dom_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) - ~json_sax_dom_parser() = default; - - bool null() - { - handle_value(nullptr); - return true; - } - - bool boolean(bool val) - { - handle_value(val); - return true; - } - - bool number_integer(number_integer_t val) - { - handle_value(val); - return true; - } - - bool number_unsigned(number_unsigned_t val) - { - handle_value(val); - return true; - } - - bool number_float(number_float_t val, const string_t& /*unused*/) - { - handle_value(val); - return true; - } - - bool string(string_t& val) - { - handle_value(val); - return true; - } - - bool binary(binary_t& val) - { - handle_value(std::move(val)); - return true; - } - - bool start_object(std::size_t len) - { - ref_stack.push_back(handle_value(BasicJsonType::value_t::object)); - - if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size())) - { - JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len), *ref_stack.back())); - } - - return true; - } - - bool key(string_t& val) - { - // add null at given key and store the reference for later - object_element = &(ref_stack.back()->m_value.object->operator[](val)); - return true; - } - - bool end_object() - { - ref_stack.back()->set_parents(); - ref_stack.pop_back(); - return true; - } - - bool start_array(std::size_t len) - { - ref_stack.push_back(handle_value(BasicJsonType::value_t::array)); - - if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size())) - { - JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len), *ref_stack.back())); - } - - return true; - } - - bool end_array() - { - ref_stack.back()->set_parents(); - ref_stack.pop_back(); - return true; - } - - template - bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, - const Exception& ex) - { - errored = true; - static_cast(ex); - if (allow_exceptions) - { - JSON_THROW(ex); - } - return false; - } - - constexpr bool is_errored() const - { - return errored; - } - - private: - /*! - @invariant If the ref stack is empty, then the passed value will be the new - root. - @invariant If the ref stack contains a value, then it is an array or an - object to which we can add elements - */ - template - JSON_HEDLEY_RETURNS_NON_NULL - BasicJsonType* handle_value(Value&& v) - { - if (ref_stack.empty()) - { - root = BasicJsonType(std::forward(v)); - return &root; - } - - JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object()); - - if (ref_stack.back()->is_array()) - { - ref_stack.back()->m_value.array->emplace_back(std::forward(v)); - return &(ref_stack.back()->m_value.array->back()); - } - - JSON_ASSERT(ref_stack.back()->is_object()); - JSON_ASSERT(object_element); - *object_element = BasicJsonType(std::forward(v)); - return object_element; - } - - /// the parsed JSON value - BasicJsonType& root; - /// stack to model hierarchy of values - std::vector ref_stack {}; - /// helper to hold the reference for the next object element - BasicJsonType* object_element = nullptr; - /// whether a syntax error occurred - bool errored = false; - /// whether to throw exceptions in case of errors - const bool allow_exceptions = true; -}; - -template -class json_sax_dom_callback_parser -{ - public: - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using binary_t = typename BasicJsonType::binary_t; - using parser_callback_t = typename BasicJsonType::parser_callback_t; - using parse_event_t = typename BasicJsonType::parse_event_t; - - json_sax_dom_callback_parser(BasicJsonType& r, - const parser_callback_t cb, - const bool allow_exceptions_ = true) - : root(r), callback(cb), allow_exceptions(allow_exceptions_) - { - keep_stack.push_back(true); - } - - // make class move-only - json_sax_dom_callback_parser(const json_sax_dom_callback_parser&) = delete; - json_sax_dom_callback_parser(json_sax_dom_callback_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) - json_sax_dom_callback_parser& operator=(const json_sax_dom_callback_parser&) = delete; - json_sax_dom_callback_parser& operator=(json_sax_dom_callback_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) - ~json_sax_dom_callback_parser() = default; - - bool null() - { - handle_value(nullptr); - return true; - } - - bool boolean(bool val) - { - handle_value(val); - return true; - } - - bool number_integer(number_integer_t val) - { - handle_value(val); - return true; - } - - bool number_unsigned(number_unsigned_t val) - { - handle_value(val); - return true; - } - - bool number_float(number_float_t val, const string_t& /*unused*/) - { - handle_value(val); - return true; - } - - bool string(string_t& val) - { - handle_value(val); - return true; - } - - bool binary(binary_t& val) - { - handle_value(std::move(val)); - return true; - } - - bool start_object(std::size_t len) - { - // check callback for object start - const bool keep = callback(static_cast(ref_stack.size()), parse_event_t::object_start, discarded); - keep_stack.push_back(keep); - - auto val = handle_value(BasicJsonType::value_t::object, true); - ref_stack.push_back(val.second); - - // check object limit - if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size())) - { - JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len), *ref_stack.back())); - } - - return true; - } - - bool key(string_t& val) - { - BasicJsonType k = BasicJsonType(val); - - // check callback for key - const bool keep = callback(static_cast(ref_stack.size()), parse_event_t::key, k); - key_keep_stack.push_back(keep); - - // add discarded value at given key and store the reference for later - if (keep && ref_stack.back()) - { - object_element = &(ref_stack.back()->m_value.object->operator[](val) = discarded); - } - - return true; - } - - bool end_object() - { - if (ref_stack.back()) - { - if (!callback(static_cast(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back())) - { - // discard object - *ref_stack.back() = discarded; - } - else - { - ref_stack.back()->set_parents(); - } - } - - JSON_ASSERT(!ref_stack.empty()); - JSON_ASSERT(!keep_stack.empty()); - ref_stack.pop_back(); - keep_stack.pop_back(); - - if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured()) - { - // remove discarded value - for (auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it) - { - if (it->is_discarded()) - { - ref_stack.back()->erase(it); - break; - } - } - } - - return true; - } - - bool start_array(std::size_t len) - { - const bool keep = callback(static_cast(ref_stack.size()), parse_event_t::array_start, discarded); - keep_stack.push_back(keep); - - auto val = handle_value(BasicJsonType::value_t::array, true); - ref_stack.push_back(val.second); - - // check array limit - if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size())) - { - JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len), *ref_stack.back())); - } - - return true; - } - - bool end_array() - { - bool keep = true; - - if (ref_stack.back()) - { - keep = callback(static_cast(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back()); - if (keep) - { - ref_stack.back()->set_parents(); - } - else - { - // discard array - *ref_stack.back() = discarded; - } - } - - JSON_ASSERT(!ref_stack.empty()); - JSON_ASSERT(!keep_stack.empty()); - ref_stack.pop_back(); - keep_stack.pop_back(); - - // remove discarded value - if (!keep && !ref_stack.empty() && ref_stack.back()->is_array()) - { - ref_stack.back()->m_value.array->pop_back(); - } - - return true; - } - - template - bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, - const Exception& ex) - { - errored = true; - static_cast(ex); - if (allow_exceptions) - { - JSON_THROW(ex); - } - return false; - } - - constexpr bool is_errored() const - { - return errored; - } - - private: - /*! - @param[in] v value to add to the JSON value we build during parsing - @param[in] skip_callback whether we should skip calling the callback - function; this is required after start_array() and - start_object() SAX events, because otherwise we would call the - callback function with an empty array or object, respectively. - - @invariant If the ref stack is empty, then the passed value will be the new - root. - @invariant If the ref stack contains a value, then it is an array or an - object to which we can add elements - - @return pair of boolean (whether value should be kept) and pointer (to the - passed value in the ref_stack hierarchy; nullptr if not kept) - */ - template - std::pair handle_value(Value&& v, const bool skip_callback = false) - { - JSON_ASSERT(!keep_stack.empty()); - - // do not handle this value if we know it would be added to a discarded - // container - if (!keep_stack.back()) - { - return {false, nullptr}; - } - - // create value - auto value = BasicJsonType(std::forward(v)); - - // check callback - const bool keep = skip_callback || callback(static_cast(ref_stack.size()), parse_event_t::value, value); - - // do not handle this value if we just learnt it shall be discarded - if (!keep) - { - return {false, nullptr}; - } - - if (ref_stack.empty()) - { - root = std::move(value); - return {true, &root}; - } - - // skip this value if we already decided to skip the parent - // (https://github.com/nlohmann/json/issues/971#issuecomment-413678360) - if (!ref_stack.back()) - { - return {false, nullptr}; - } - - // we now only expect arrays and objects - JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object()); - - // array - if (ref_stack.back()->is_array()) - { - ref_stack.back()->m_value.array->emplace_back(std::move(value)); - return {true, &(ref_stack.back()->m_value.array->back())}; - } - - // object - JSON_ASSERT(ref_stack.back()->is_object()); - // check if we should store an element for the current key - JSON_ASSERT(!key_keep_stack.empty()); - const bool store_element = key_keep_stack.back(); - key_keep_stack.pop_back(); - - if (!store_element) - { - return {false, nullptr}; - } - - JSON_ASSERT(object_element); - *object_element = std::move(value); - return {true, object_element}; - } - - /// the parsed JSON value - BasicJsonType& root; - /// stack to model hierarchy of values - std::vector ref_stack {}; - /// stack to manage which values to keep - std::vector keep_stack {}; - /// stack to manage which object keys to keep - std::vector key_keep_stack {}; - /// helper to hold the reference for the next object element - BasicJsonType* object_element = nullptr; - /// whether a syntax error occurred - bool errored = false; - /// callback function - const parser_callback_t callback = nullptr; - /// whether to throw exceptions in case of errors - const bool allow_exceptions = true; - /// a discarded value for the callback - BasicJsonType discarded = BasicJsonType::value_t::discarded; -}; - -template -class json_sax_acceptor -{ - public: - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using binary_t = typename BasicJsonType::binary_t; - - bool null() - { - return true; - } - - bool boolean(bool /*unused*/) - { - return true; - } - - bool number_integer(number_integer_t /*unused*/) - { - return true; - } - - bool number_unsigned(number_unsigned_t /*unused*/) - { - return true; - } - - bool number_float(number_float_t /*unused*/, const string_t& /*unused*/) - { - return true; - } - - bool string(string_t& /*unused*/) - { - return true; - } - - bool binary(binary_t& /*unused*/) - { - return true; - } - - bool start_object(std::size_t /*unused*/ = std::size_t(-1)) - { - return true; - } - - bool key(string_t& /*unused*/) - { - return true; - } - - bool end_object() - { - return true; - } - - bool start_array(std::size_t /*unused*/ = std::size_t(-1)) - { - return true; - } - - bool end_array() - { - return true; - } - - bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, const detail::exception& /*unused*/) - { - return false; - } -}; -} // namespace detail - -} // namespace nlohmann - -// #include - - -#include // array -#include // localeconv -#include // size_t -#include // snprintf -#include // strtof, strtod, strtold, strtoll, strtoull -#include // initializer_list -#include // char_traits, string -#include // move -#include // vector - -// #include - -// #include - -// #include - - -namespace nlohmann -{ -namespace detail -{ -/////////// -// lexer // -/////////// - -template -class lexer_base -{ - public: - /// token types for the parser - enum class token_type - { - uninitialized, ///< indicating the scanner is uninitialized - literal_true, ///< the `true` literal - literal_false, ///< the `false` literal - literal_null, ///< the `null` literal - value_string, ///< a string -- use get_string() for actual value - value_unsigned, ///< an unsigned integer -- use get_number_unsigned() for actual value - value_integer, ///< a signed integer -- use get_number_integer() for actual value - value_float, ///< an floating point number -- use get_number_float() for actual value - begin_array, ///< the character for array begin `[` - begin_object, ///< the character for object begin `{` - end_array, ///< the character for array end `]` - end_object, ///< the character for object end `}` - name_separator, ///< the name separator `:` - value_separator, ///< the value separator `,` - parse_error, ///< indicating a parse error - end_of_input, ///< indicating the end of the input buffer - literal_or_value ///< a literal or the begin of a value (only for diagnostics) - }; - - /// return name of values of type token_type (only used for errors) - JSON_HEDLEY_RETURNS_NON_NULL - JSON_HEDLEY_CONST - static const char* token_type_name(const token_type t) noexcept - { - switch (t) - { - case token_type::uninitialized: - return ""; - case token_type::literal_true: - return "true literal"; - case token_type::literal_false: - return "false literal"; - case token_type::literal_null: - return "null literal"; - case token_type::value_string: - return "string literal"; - case token_type::value_unsigned: - case token_type::value_integer: - case token_type::value_float: - return "number literal"; - case token_type::begin_array: - return "'['"; - case token_type::begin_object: - return "'{'"; - case token_type::end_array: - return "']'"; - case token_type::end_object: - return "'}'"; - case token_type::name_separator: - return "':'"; - case token_type::value_separator: - return "','"; - case token_type::parse_error: - return ""; - case token_type::end_of_input: - return "end of input"; - case token_type::literal_or_value: - return "'[', '{', or a literal"; - // LCOV_EXCL_START - default: // catch non-enum values - return "unknown token"; - // LCOV_EXCL_STOP - } - } -}; -/*! -@brief lexical analysis - -This class organizes the lexical analysis during JSON deserialization. -*/ -template -class lexer : public lexer_base -{ - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using char_type = typename InputAdapterType::char_type; - using char_int_type = typename std::char_traits::int_type; - - public: - using token_type = typename lexer_base::token_type; - - explicit lexer(InputAdapterType&& adapter, bool ignore_comments_ = false) noexcept - : ia(std::move(adapter)) - , ignore_comments(ignore_comments_) - , decimal_point_char(static_cast(get_decimal_point())) - {} - - // delete because of pointer members - lexer(const lexer&) = delete; - lexer(lexer&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) - lexer& operator=(lexer&) = delete; - lexer& operator=(lexer&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) - ~lexer() = default; - - private: - ///////////////////// - // locales - ///////////////////// - - /// return the locale-dependent decimal point - JSON_HEDLEY_PURE - static char get_decimal_point() noexcept - { - const auto* loc = localeconv(); - JSON_ASSERT(loc != nullptr); - return (loc->decimal_point == nullptr) ? '.' : *(loc->decimal_point); - } - - ///////////////////// - // scan functions - ///////////////////// - - /*! - @brief get codepoint from 4 hex characters following `\u` - - For input "\u c1 c2 c3 c4" the codepoint is: - (c1 * 0x1000) + (c2 * 0x0100) + (c3 * 0x0010) + c4 - = (c1 << 12) + (c2 << 8) + (c3 << 4) + (c4 << 0) - - Furthermore, the possible characters '0'..'9', 'A'..'F', and 'a'..'f' - must be converted to the integers 0x0..0x9, 0xA..0xF, 0xA..0xF, resp. The - conversion is done by subtracting the offset (0x30, 0x37, and 0x57) - between the ASCII value of the character and the desired integer value. - - @return codepoint (0x0000..0xFFFF) or -1 in case of an error (e.g. EOF or - non-hex character) - */ - int get_codepoint() - { - // this function only makes sense after reading `\u` - JSON_ASSERT(current == 'u'); - int codepoint = 0; - - const auto factors = { 12u, 8u, 4u, 0u }; - for (const auto factor : factors) - { - get(); - - if (current >= '0' && current <= '9') - { - codepoint += static_cast((static_cast(current) - 0x30u) << factor); - } - else if (current >= 'A' && current <= 'F') - { - codepoint += static_cast((static_cast(current) - 0x37u) << factor); - } - else if (current >= 'a' && current <= 'f') - { - codepoint += static_cast((static_cast(current) - 0x57u) << factor); - } - else - { - return -1; - } - } - - JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF); - return codepoint; - } - - /*! - @brief check if the next byte(s) are inside a given range - - Adds the current byte and, for each passed range, reads a new byte and - checks if it is inside the range. If a violation was detected, set up an - error message and return false. Otherwise, return true. - - @param[in] ranges list of integers; interpreted as list of pairs of - inclusive lower and upper bound, respectively - - @pre The passed list @a ranges must have 2, 4, or 6 elements; that is, - 1, 2, or 3 pairs. This precondition is enforced by an assertion. - - @return true if and only if no range violation was detected - */ - bool next_byte_in_range(std::initializer_list ranges) - { - JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6); - add(current); - - for (auto range = ranges.begin(); range != ranges.end(); ++range) - { - get(); - if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range))) - { - add(current); - } - else - { - error_message = "invalid string: ill-formed UTF-8 byte"; - return false; - } - } - - return true; - } - - /*! - @brief scan a string literal - - This function scans a string according to Sect. 7 of RFC 8259. While - scanning, bytes are escaped and copied into buffer token_buffer. Then the - function returns successfully, token_buffer is *not* null-terminated (as it - may contain \0 bytes), and token_buffer.size() is the number of bytes in the - string. - - @return token_type::value_string if string could be successfully scanned, - token_type::parse_error otherwise - - @note In case of errors, variable error_message contains a textual - description. - */ - token_type scan_string() - { - // reset token_buffer (ignore opening quote) - reset(); - - // we entered the function by reading an open quote - JSON_ASSERT(current == '\"'); - - while (true) - { - // get next character - switch (get()) - { - // end of file while parsing string - case std::char_traits::eof(): - { - error_message = "invalid string: missing closing quote"; - return token_type::parse_error; - } - - // closing quote - case '\"': - { - return token_type::value_string; - } - - // escapes - case '\\': - { - switch (get()) - { - // quotation mark - case '\"': - add('\"'); - break; - // reverse solidus - case '\\': - add('\\'); - break; - // solidus - case '/': - add('/'); - break; - // backspace - case 'b': - add('\b'); - break; - // form feed - case 'f': - add('\f'); - break; - // line feed - case 'n': - add('\n'); - break; - // carriage return - case 'r': - add('\r'); - break; - // tab - case 't': - add('\t'); - break; - - // unicode escapes - case 'u': - { - const int codepoint1 = get_codepoint(); - int codepoint = codepoint1; // start with codepoint1 - - if (JSON_HEDLEY_UNLIKELY(codepoint1 == -1)) - { - error_message = "invalid string: '\\u' must be followed by 4 hex digits"; - return token_type::parse_error; - } - - // check if code point is a high surrogate - if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF) - { - // expect next \uxxxx entry - if (JSON_HEDLEY_LIKELY(get() == '\\' && get() == 'u')) - { - const int codepoint2 = get_codepoint(); - - if (JSON_HEDLEY_UNLIKELY(codepoint2 == -1)) - { - error_message = "invalid string: '\\u' must be followed by 4 hex digits"; - return token_type::parse_error; - } - - // check if codepoint2 is a low surrogate - if (JSON_HEDLEY_LIKELY(0xDC00 <= codepoint2 && codepoint2 <= 0xDFFF)) - { - // overwrite codepoint - codepoint = static_cast( - // high surrogate occupies the most significant 22 bits - (static_cast(codepoint1) << 10u) - // low surrogate occupies the least significant 15 bits - + static_cast(codepoint2) - // there is still the 0xD800, 0xDC00 and 0x10000 noise - // in the result so we have to subtract with: - // (0xD800 << 10) + DC00 - 0x10000 = 0x35FDC00 - - 0x35FDC00u); - } - else - { - error_message = "invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF"; - return token_type::parse_error; - } - } - else - { - error_message = "invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF"; - return token_type::parse_error; - } - } - else - { - if (JSON_HEDLEY_UNLIKELY(0xDC00 <= codepoint1 && codepoint1 <= 0xDFFF)) - { - error_message = "invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF"; - return token_type::parse_error; - } - } - - // result of the above calculation yields a proper codepoint - JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF); - - // translate codepoint into bytes - if (codepoint < 0x80) - { - // 1-byte characters: 0xxxxxxx (ASCII) - add(static_cast(codepoint)); - } - else if (codepoint <= 0x7FF) - { - // 2-byte characters: 110xxxxx 10xxxxxx - add(static_cast(0xC0u | (static_cast(codepoint) >> 6u))); - add(static_cast(0x80u | (static_cast(codepoint) & 0x3Fu))); - } - else if (codepoint <= 0xFFFF) - { - // 3-byte characters: 1110xxxx 10xxxxxx 10xxxxxx - add(static_cast(0xE0u | (static_cast(codepoint) >> 12u))); - add(static_cast(0x80u | ((static_cast(codepoint) >> 6u) & 0x3Fu))); - add(static_cast(0x80u | (static_cast(codepoint) & 0x3Fu))); - } - else - { - // 4-byte characters: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx - add(static_cast(0xF0u | (static_cast(codepoint) >> 18u))); - add(static_cast(0x80u | ((static_cast(codepoint) >> 12u) & 0x3Fu))); - add(static_cast(0x80u | ((static_cast(codepoint) >> 6u) & 0x3Fu))); - add(static_cast(0x80u | (static_cast(codepoint) & 0x3Fu))); - } - - break; - } - - // other characters after escape - default: - error_message = "invalid string: forbidden character after backslash"; - return token_type::parse_error; - } - - break; - } - - // invalid control characters - case 0x00: - { - error_message = "invalid string: control character U+0000 (NUL) must be escaped to \\u0000"; - return token_type::parse_error; - } - - case 0x01: - { - error_message = "invalid string: control character U+0001 (SOH) must be escaped to \\u0001"; - return token_type::parse_error; - } - - case 0x02: - { - error_message = "invalid string: control character U+0002 (STX) must be escaped to \\u0002"; - return token_type::parse_error; - } - - case 0x03: - { - error_message = "invalid string: control character U+0003 (ETX) must be escaped to \\u0003"; - return token_type::parse_error; - } - - case 0x04: - { - error_message = "invalid string: control character U+0004 (EOT) must be escaped to \\u0004"; - return token_type::parse_error; - } - - case 0x05: - { - error_message = "invalid string: control character U+0005 (ENQ) must be escaped to \\u0005"; - return token_type::parse_error; - } - - case 0x06: - { - error_message = "invalid string: control character U+0006 (ACK) must be escaped to \\u0006"; - return token_type::parse_error; - } - - case 0x07: - { - error_message = "invalid string: control character U+0007 (BEL) must be escaped to \\u0007"; - return token_type::parse_error; - } - - case 0x08: - { - error_message = "invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b"; - return token_type::parse_error; - } - - case 0x09: - { - error_message = "invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t"; - return token_type::parse_error; - } - - case 0x0A: - { - error_message = "invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n"; - return token_type::parse_error; - } - - case 0x0B: - { - error_message = "invalid string: control character U+000B (VT) must be escaped to \\u000B"; - return token_type::parse_error; - } - - case 0x0C: - { - error_message = "invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f"; - return token_type::parse_error; - } - - case 0x0D: - { - error_message = "invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r"; - return token_type::parse_error; - } - - case 0x0E: - { - error_message = "invalid string: control character U+000E (SO) must be escaped to \\u000E"; - return token_type::parse_error; - } - - case 0x0F: - { - error_message = "invalid string: control character U+000F (SI) must be escaped to \\u000F"; - return token_type::parse_error; - } - - case 0x10: - { - error_message = "invalid string: control character U+0010 (DLE) must be escaped to \\u0010"; - return token_type::parse_error; - } - - case 0x11: - { - error_message = "invalid string: control character U+0011 (DC1) must be escaped to \\u0011"; - return token_type::parse_error; - } - - case 0x12: - { - error_message = "invalid string: control character U+0012 (DC2) must be escaped to \\u0012"; - return token_type::parse_error; - } - - case 0x13: - { - error_message = "invalid string: control character U+0013 (DC3) must be escaped to \\u0013"; - return token_type::parse_error; - } - - case 0x14: - { - error_message = "invalid string: control character U+0014 (DC4) must be escaped to \\u0014"; - return token_type::parse_error; - } - - case 0x15: - { - error_message = "invalid string: control character U+0015 (NAK) must be escaped to \\u0015"; - return token_type::parse_error; - } - - case 0x16: - { - error_message = "invalid string: control character U+0016 (SYN) must be escaped to \\u0016"; - return token_type::parse_error; - } - - case 0x17: - { - error_message = "invalid string: control character U+0017 (ETB) must be escaped to \\u0017"; - return token_type::parse_error; - } - - case 0x18: - { - error_message = "invalid string: control character U+0018 (CAN) must be escaped to \\u0018"; - return token_type::parse_error; - } - - case 0x19: - { - error_message = "invalid string: control character U+0019 (EM) must be escaped to \\u0019"; - return token_type::parse_error; - } - - case 0x1A: - { - error_message = "invalid string: control character U+001A (SUB) must be escaped to \\u001A"; - return token_type::parse_error; - } - - case 0x1B: - { - error_message = "invalid string: control character U+001B (ESC) must be escaped to \\u001B"; - return token_type::parse_error; - } - - case 0x1C: - { - error_message = "invalid string: control character U+001C (FS) must be escaped to \\u001C"; - return token_type::parse_error; - } - - case 0x1D: - { - error_message = "invalid string: control character U+001D (GS) must be escaped to \\u001D"; - return token_type::parse_error; - } - - case 0x1E: - { - error_message = "invalid string: control character U+001E (RS) must be escaped to \\u001E"; - return token_type::parse_error; - } - - case 0x1F: - { - error_message = "invalid string: control character U+001F (US) must be escaped to \\u001F"; - return token_type::parse_error; - } - - // U+0020..U+007F (except U+0022 (quote) and U+005C (backspace)) - case 0x20: - case 0x21: - case 0x23: - case 0x24: - case 0x25: - case 0x26: - case 0x27: - case 0x28: - case 0x29: - case 0x2A: - case 0x2B: - case 0x2C: - case 0x2D: - case 0x2E: - case 0x2F: - case 0x30: - case 0x31: - case 0x32: - case 0x33: - case 0x34: - case 0x35: - case 0x36: - case 0x37: - case 0x38: - case 0x39: - case 0x3A: - case 0x3B: - case 0x3C: - case 0x3D: - case 0x3E: - case 0x3F: - case 0x40: - case 0x41: - case 0x42: - case 0x43: - case 0x44: - case 0x45: - case 0x46: - case 0x47: - case 0x48: - case 0x49: - case 0x4A: - case 0x4B: - case 0x4C: - case 0x4D: - case 0x4E: - case 0x4F: - case 0x50: - case 0x51: - case 0x52: - case 0x53: - case 0x54: - case 0x55: - case 0x56: - case 0x57: - case 0x58: - case 0x59: - case 0x5A: - case 0x5B: - case 0x5D: - case 0x5E: - case 0x5F: - case 0x60: - case 0x61: - case 0x62: - case 0x63: - case 0x64: - case 0x65: - case 0x66: - case 0x67: - case 0x68: - case 0x69: - case 0x6A: - case 0x6B: - case 0x6C: - case 0x6D: - case 0x6E: - case 0x6F: - case 0x70: - case 0x71: - case 0x72: - case 0x73: - case 0x74: - case 0x75: - case 0x76: - case 0x77: - case 0x78: - case 0x79: - case 0x7A: - case 0x7B: - case 0x7C: - case 0x7D: - case 0x7E: - case 0x7F: - { - add(current); - break; - } - - // U+0080..U+07FF: bytes C2..DF 80..BF - case 0xC2: - case 0xC3: - case 0xC4: - case 0xC5: - case 0xC6: - case 0xC7: - case 0xC8: - case 0xC9: - case 0xCA: - case 0xCB: - case 0xCC: - case 0xCD: - case 0xCE: - case 0xCF: - case 0xD0: - case 0xD1: - case 0xD2: - case 0xD3: - case 0xD4: - case 0xD5: - case 0xD6: - case 0xD7: - case 0xD8: - case 0xD9: - case 0xDA: - case 0xDB: - case 0xDC: - case 0xDD: - case 0xDE: - case 0xDF: - { - if (JSON_HEDLEY_UNLIKELY(!next_byte_in_range({0x80, 0xBF}))) - { - return token_type::parse_error; - } - break; - } - - // U+0800..U+0FFF: bytes E0 A0..BF 80..BF - case 0xE0: - { - if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF})))) - { - return token_type::parse_error; - } - break; - } - - // U+1000..U+CFFF: bytes E1..EC 80..BF 80..BF - // U+E000..U+FFFF: bytes EE..EF 80..BF 80..BF - case 0xE1: - case 0xE2: - case 0xE3: - case 0xE4: - case 0xE5: - case 0xE6: - case 0xE7: - case 0xE8: - case 0xE9: - case 0xEA: - case 0xEB: - case 0xEC: - case 0xEE: - case 0xEF: - { - if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0xBF, 0x80, 0xBF})))) - { - return token_type::parse_error; - } - break; - } - - // U+D000..U+D7FF: bytes ED 80..9F 80..BF - case 0xED: - { - if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0x9F, 0x80, 0xBF})))) - { - return token_type::parse_error; - } - break; - } - - // U+10000..U+3FFFF F0 90..BF 80..BF 80..BF - case 0xF0: - { - if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) - { - return token_type::parse_error; - } - break; - } - - // U+40000..U+FFFFF F1..F3 80..BF 80..BF 80..BF - case 0xF1: - case 0xF2: - case 0xF3: - { - if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) - { - return token_type::parse_error; - } - break; - } - - // U+100000..U+10FFFF F4 80..8F 80..BF 80..BF - case 0xF4: - { - if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF})))) - { - return token_type::parse_error; - } - break; - } - - // remaining bytes (80..C1 and F5..FF) are ill-formed - default: - { - error_message = "invalid string: ill-formed UTF-8 byte"; - return token_type::parse_error; - } - } - } - } - - /*! - * @brief scan a comment - * @return whether comment could be scanned successfully - */ - bool scan_comment() - { - switch (get()) - { - // single-line comments skip input until a newline or EOF is read - case '/': - { - while (true) - { - switch (get()) - { - case '\n': - case '\r': - case std::char_traits::eof(): - case '\0': - return true; - - default: - break; - } - } - } - - // multi-line comments skip input until */ is read - case '*': - { - while (true) - { - switch (get()) - { - case std::char_traits::eof(): - case '\0': - { - error_message = "invalid comment; missing closing '*/'"; - return false; - } - - case '*': - { - switch (get()) - { - case '/': - return true; - - default: - { - unget(); - continue; - } - } - } - - default: - continue; - } - } - } - - // unexpected character after reading '/' - default: - { - error_message = "invalid comment; expecting '/' or '*' after '/'"; - return false; - } - } - } - - JSON_HEDLEY_NON_NULL(2) - static void strtof(float& f, const char* str, char** endptr) noexcept - { - f = std::strtof(str, endptr); - } - - JSON_HEDLEY_NON_NULL(2) - static void strtof(double& f, const char* str, char** endptr) noexcept - { - f = std::strtod(str, endptr); - } - - JSON_HEDLEY_NON_NULL(2) - static void strtof(long double& f, const char* str, char** endptr) noexcept - { - f = std::strtold(str, endptr); - } - - /*! - @brief scan a number literal - - This function scans a string according to Sect. 6 of RFC 8259. - - The function is realized with a deterministic finite state machine derived - from the grammar described in RFC 8259. Starting in state "init", the - input is read and used to determined the next state. Only state "done" - accepts the number. State "error" is a trap state to model errors. In the - table below, "anything" means any character but the ones listed before. - - state | 0 | 1-9 | e E | + | - | . | anything - ---------|----------|----------|----------|---------|---------|----------|----------- - init | zero | any1 | [error] | [error] | minus | [error] | [error] - minus | zero | any1 | [error] | [error] | [error] | [error] | [error] - zero | done | done | exponent | done | done | decimal1 | done - any1 | any1 | any1 | exponent | done | done | decimal1 | done - decimal1 | decimal2 | decimal2 | [error] | [error] | [error] | [error] | [error] - decimal2 | decimal2 | decimal2 | exponent | done | done | done | done - exponent | any2 | any2 | [error] | sign | sign | [error] | [error] - sign | any2 | any2 | [error] | [error] | [error] | [error] | [error] - any2 | any2 | any2 | done | done | done | done | done - - The state machine is realized with one label per state (prefixed with - "scan_number_") and `goto` statements between them. The state machine - contains cycles, but any cycle can be left when EOF is read. Therefore, - the function is guaranteed to terminate. - - During scanning, the read bytes are stored in token_buffer. This string is - then converted to a signed integer, an unsigned integer, or a - floating-point number. - - @return token_type::value_unsigned, token_type::value_integer, or - token_type::value_float if number could be successfully scanned, - token_type::parse_error otherwise - - @note The scanner is independent of the current locale. Internally, the - locale's decimal point is used instead of `.` to work with the - locale-dependent converters. - */ - token_type scan_number() // lgtm [cpp/use-of-goto] - { - // reset token_buffer to store the number's bytes - reset(); - - // the type of the parsed number; initially set to unsigned; will be - // changed if minus sign, decimal point or exponent is read - token_type number_type = token_type::value_unsigned; - - // state (init): we just found out we need to scan a number - switch (current) - { - case '-': - { - add(current); - goto scan_number_minus; - } - - case '0': - { - add(current); - goto scan_number_zero; - } - - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - add(current); - goto scan_number_any1; - } - - // all other characters are rejected outside scan_number() - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE - } - -scan_number_minus: - // state: we just parsed a leading minus sign - number_type = token_type::value_integer; - switch (get()) - { - case '0': - { - add(current); - goto scan_number_zero; - } - - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - add(current); - goto scan_number_any1; - } - - default: - { - error_message = "invalid number; expected digit after '-'"; - return token_type::parse_error; - } - } - -scan_number_zero: - // state: we just parse a zero (maybe with a leading minus sign) - switch (get()) - { - case '.': - { - add(decimal_point_char); - goto scan_number_decimal1; - } - - case 'e': - case 'E': - { - add(current); - goto scan_number_exponent; - } - - default: - goto scan_number_done; - } - -scan_number_any1: - // state: we just parsed a number 0-9 (maybe with a leading minus sign) - switch (get()) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - add(current); - goto scan_number_any1; - } - - case '.': - { - add(decimal_point_char); - goto scan_number_decimal1; - } - - case 'e': - case 'E': - { - add(current); - goto scan_number_exponent; - } - - default: - goto scan_number_done; - } - -scan_number_decimal1: - // state: we just parsed a decimal point - number_type = token_type::value_float; - switch (get()) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - add(current); - goto scan_number_decimal2; - } - - default: - { - error_message = "invalid number; expected digit after '.'"; - return token_type::parse_error; - } - } - -scan_number_decimal2: - // we just parsed at least one number after a decimal point - switch (get()) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - add(current); - goto scan_number_decimal2; - } - - case 'e': - case 'E': - { - add(current); - goto scan_number_exponent; - } - - default: - goto scan_number_done; - } - -scan_number_exponent: - // we just parsed an exponent - number_type = token_type::value_float; - switch (get()) - { - case '+': - case '-': - { - add(current); - goto scan_number_sign; - } - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - add(current); - goto scan_number_any2; - } - - default: - { - error_message = - "invalid number; expected '+', '-', or digit after exponent"; - return token_type::parse_error; - } - } - -scan_number_sign: - // we just parsed an exponent sign - switch (get()) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - add(current); - goto scan_number_any2; - } - - default: - { - error_message = "invalid number; expected digit after exponent sign"; - return token_type::parse_error; - } - } - -scan_number_any2: - // we just parsed a number after the exponent or exponent sign - switch (get()) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - add(current); - goto scan_number_any2; - } - - default: - goto scan_number_done; - } - -scan_number_done: - // unget the character after the number (we only read it to know that - // we are done scanning a number) - unget(); - - char* endptr = nullptr; // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) - errno = 0; - - // try to parse integers first and fall back to floats - if (number_type == token_type::value_unsigned) - { - const auto x = std::strtoull(token_buffer.data(), &endptr, 10); - - // we checked the number format before - JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size()); - - if (errno == 0) - { - value_unsigned = static_cast(x); - if (value_unsigned == x) - { - return token_type::value_unsigned; - } - } - } - else if (number_type == token_type::value_integer) - { - const auto x = std::strtoll(token_buffer.data(), &endptr, 10); - - // we checked the number format before - JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size()); - - if (errno == 0) - { - value_integer = static_cast(x); - if (value_integer == x) - { - return token_type::value_integer; - } - } - } - - // this code is reached if we parse a floating-point number or if an - // integer conversion above failed - strtof(value_float, token_buffer.data(), &endptr); - - // we checked the number format before - JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size()); - - return token_type::value_float; - } - - /*! - @param[in] literal_text the literal text to expect - @param[in] length the length of the passed literal text - @param[in] return_type the token type to return on success - */ - JSON_HEDLEY_NON_NULL(2) - token_type scan_literal(const char_type* literal_text, const std::size_t length, - token_type return_type) - { - JSON_ASSERT(std::char_traits::to_char_type(current) == literal_text[0]); - for (std::size_t i = 1; i < length; ++i) - { - if (JSON_HEDLEY_UNLIKELY(std::char_traits::to_char_type(get()) != literal_text[i])) - { - error_message = "invalid literal"; - return token_type::parse_error; - } - } - return return_type; - } - - ///////////////////// - // input management - ///////////////////// - - /// reset token_buffer; current character is beginning of token - void reset() noexcept - { - token_buffer.clear(); - token_string.clear(); - token_string.push_back(std::char_traits::to_char_type(current)); - } - - /* - @brief get next character from the input - - This function provides the interface to the used input adapter. It does - not throw in case the input reached EOF, but returns a - `std::char_traits::eof()` in that case. Stores the scanned characters - for use in error messages. - - @return character read from the input - */ - char_int_type get() - { - ++position.chars_read_total; - ++position.chars_read_current_line; - - if (next_unget) - { - // just reset the next_unget variable and work with current - next_unget = false; - } - else - { - current = ia.get_character(); - } - - if (JSON_HEDLEY_LIKELY(current != std::char_traits::eof())) - { - token_string.push_back(std::char_traits::to_char_type(current)); - } - - if (current == '\n') - { - ++position.lines_read; - position.chars_read_current_line = 0; - } - - return current; - } - - /*! - @brief unget current character (read it again on next get) - - We implement unget by setting variable next_unget to true. The input is not - changed - we just simulate ungetting by modifying chars_read_total, - chars_read_current_line, and token_string. The next call to get() will - behave as if the unget character is read again. - */ - void unget() - { - next_unget = true; - - --position.chars_read_total; - - // in case we "unget" a newline, we have to also decrement the lines_read - if (position.chars_read_current_line == 0) - { - if (position.lines_read > 0) - { - --position.lines_read; - } - } - else - { - --position.chars_read_current_line; - } - - if (JSON_HEDLEY_LIKELY(current != std::char_traits::eof())) - { - JSON_ASSERT(!token_string.empty()); - token_string.pop_back(); - } - } - - /// add a character to token_buffer - void add(char_int_type c) - { - token_buffer.push_back(static_cast(c)); - } - - public: - ///////////////////// - // value getters - ///////////////////// - - /// return integer value - constexpr number_integer_t get_number_integer() const noexcept - { - return value_integer; - } - - /// return unsigned integer value - constexpr number_unsigned_t get_number_unsigned() const noexcept - { - return value_unsigned; - } - - /// return floating-point value - constexpr number_float_t get_number_float() const noexcept - { - return value_float; - } - - /// return current string value (implicitly resets the token; useful only once) - string_t& get_string() - { - return token_buffer; - } - - ///////////////////// - // diagnostics - ///////////////////// - - /// return position of last read token - constexpr position_t get_position() const noexcept - { - return position; - } - - /// return the last read token (for errors only). Will never contain EOF - /// (an arbitrary value that is not a valid char value, often -1), because - /// 255 may legitimately occur. May contain NUL, which should be escaped. - std::string get_token_string() const - { - // escape control characters - std::string result; - for (const auto c : token_string) - { - if (static_cast(c) <= '\x1F') - { - // escape control characters - std::array cs{{}}; - (std::snprintf)(cs.data(), cs.size(), "", static_cast(c)); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) - result += cs.data(); - } - else - { - // add character as is - result.push_back(static_cast(c)); - } - } - - return result; - } - - /// return syntax error message - JSON_HEDLEY_RETURNS_NON_NULL - constexpr const char* get_error_message() const noexcept - { - return error_message; - } - - ///////////////////// - // actual scanner - ///////////////////// - - /*! - @brief skip the UTF-8 byte order mark - @return true iff there is no BOM or the correct BOM has been skipped - */ - bool skip_bom() - { - if (get() == 0xEF) - { - // check if we completely parse the BOM - return get() == 0xBB && get() == 0xBF; - } - - // the first character is not the beginning of the BOM; unget it to - // process is later - unget(); - return true; - } - - void skip_whitespace() - { - do - { - get(); - } - while (current == ' ' || current == '\t' || current == '\n' || current == '\r'); - } - - token_type scan() - { - // initially, skip the BOM - if (position.chars_read_total == 0 && !skip_bom()) - { - error_message = "invalid BOM; must be 0xEF 0xBB 0xBF if given"; - return token_type::parse_error; - } - - // read next character and ignore whitespace - skip_whitespace(); - - // ignore comments - while (ignore_comments && current == '/') - { - if (!scan_comment()) - { - return token_type::parse_error; - } - - // skip following whitespace - skip_whitespace(); - } - - switch (current) - { - // structural characters - case '[': - return token_type::begin_array; - case ']': - return token_type::end_array; - case '{': - return token_type::begin_object; - case '}': - return token_type::end_object; - case ':': - return token_type::name_separator; - case ',': - return token_type::value_separator; - - // literals - case 't': - { - std::array true_literal = {{char_type('t'), char_type('r'), char_type('u'), char_type('e')}}; - return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true); - } - case 'f': - { - std::array false_literal = {{char_type('f'), char_type('a'), char_type('l'), char_type('s'), char_type('e')}}; - return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false); - } - case 'n': - { - std::array null_literal = {{char_type('n'), char_type('u'), char_type('l'), char_type('l')}}; - return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null); - } - - // string - case '\"': - return scan_string(); - - // number - case '-': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - return scan_number(); - - // end of input (the null byte is needed when parsing from - // string literals) - case '\0': - case std::char_traits::eof(): - return token_type::end_of_input; - - // error - default: - error_message = "invalid literal"; - return token_type::parse_error; - } - } - - private: - /// input adapter - InputAdapterType ia; - - /// whether comments should be ignored (true) or signaled as errors (false) - const bool ignore_comments = false; - - /// the current character - char_int_type current = std::char_traits::eof(); - - /// whether the next get() call should just return current - bool next_unget = false; - - /// the start position of the current token - position_t position {}; - - /// raw input token string (for error messages) - std::vector token_string {}; - - /// buffer for variable-length tokens (numbers, strings) - string_t token_buffer {}; - - /// a description of occurred lexer errors - const char* error_message = ""; - - // number values - number_integer_t value_integer = 0; - number_unsigned_t value_unsigned = 0; - number_float_t value_float = 0; - - /// the decimal point - const char_int_type decimal_point_char = '.'; -}; -} // namespace detail -} // namespace nlohmann - -// #include - -// #include - - -#include // size_t -#include // declval -#include // string - -// #include - -// #include - - -namespace nlohmann -{ -namespace detail -{ -template -using null_function_t = decltype(std::declval().null()); - -template -using boolean_function_t = - decltype(std::declval().boolean(std::declval())); - -template -using number_integer_function_t = - decltype(std::declval().number_integer(std::declval())); - -template -using number_unsigned_function_t = - decltype(std::declval().number_unsigned(std::declval())); - -template -using number_float_function_t = decltype(std::declval().number_float( - std::declval(), std::declval())); - -template -using string_function_t = - decltype(std::declval().string(std::declval())); - -template -using binary_function_t = - decltype(std::declval().binary(std::declval())); - -template -using start_object_function_t = - decltype(std::declval().start_object(std::declval())); - -template -using key_function_t = - decltype(std::declval().key(std::declval())); - -template -using end_object_function_t = decltype(std::declval().end_object()); - -template -using start_array_function_t = - decltype(std::declval().start_array(std::declval())); - -template -using end_array_function_t = decltype(std::declval().end_array()); - -template -using parse_error_function_t = decltype(std::declval().parse_error( - std::declval(), std::declval(), - std::declval())); - -template -struct is_sax -{ - private: - static_assert(is_basic_json::value, - "BasicJsonType must be of type basic_json<...>"); - - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using binary_t = typename BasicJsonType::binary_t; - using exception_t = typename BasicJsonType::exception; - - public: - static constexpr bool value = - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value; -}; - -template -struct is_sax_static_asserts -{ - private: - static_assert(is_basic_json::value, - "BasicJsonType must be of type basic_json<...>"); - - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using binary_t = typename BasicJsonType::binary_t; - using exception_t = typename BasicJsonType::exception; - - public: - static_assert(is_detected_exact::value, - "Missing/invalid function: bool null()"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool boolean(bool)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool boolean(bool)"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool number_integer(number_integer_t)"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool number_unsigned(number_unsigned_t)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool number_float(number_float_t, const string_t&)"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool string(string_t&)"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool binary(binary_t&)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool start_object(std::size_t)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool key(string_t&)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool end_object()"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool start_array(std::size_t)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool end_array()"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool parse_error(std::size_t, const " - "std::string&, const exception&)"); -}; -} // namespace detail -} // namespace nlohmann - -// #include - -// #include - - -namespace nlohmann -{ -namespace detail -{ - -/// how to treat CBOR tags -enum class cbor_tag_handler_t -{ - error, ///< throw a parse_error exception in case of a tag - ignore, ///< ignore tags - store ///< store tags as binary type -}; - -/*! -@brief determine system byte order - -@return true if and only if system's byte order is little endian - -@note from https://stackoverflow.com/a/1001328/266378 -*/ -static inline bool little_endianess(int num = 1) noexcept -{ - return *reinterpret_cast(&num) == 1; -} - - -/////////////////// -// binary reader // -/////////////////// - -/*! -@brief deserialization of CBOR, MessagePack, and UBJSON values -*/ -template> -class binary_reader -{ - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using binary_t = typename BasicJsonType::binary_t; - using json_sax_t = SAX; - using char_type = typename InputAdapterType::char_type; - using char_int_type = typename std::char_traits::int_type; - - public: - /*! - @brief create a binary reader - - @param[in] adapter input adapter to read from - */ - explicit binary_reader(InputAdapterType&& adapter) noexcept : ia(std::move(adapter)) - { - (void)detail::is_sax_static_asserts {}; - } - - // make class move-only - binary_reader(const binary_reader&) = delete; - binary_reader(binary_reader&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) - binary_reader& operator=(const binary_reader&) = delete; - binary_reader& operator=(binary_reader&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) - ~binary_reader() = default; - - /*! - @param[in] format the binary format to parse - @param[in] sax_ a SAX event processor - @param[in] strict whether to expect the input to be consumed completed - @param[in] tag_handler how to treat CBOR tags - - @return whether parsing was successful - */ - JSON_HEDLEY_NON_NULL(3) - bool sax_parse(const input_format_t format, - json_sax_t* sax_, - const bool strict = true, - const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) - { - sax = sax_; - bool result = false; - - switch (format) - { - case input_format_t::bson: - result = parse_bson_internal(); - break; - - case input_format_t::cbor: - result = parse_cbor_internal(true, tag_handler); - break; - - case input_format_t::msgpack: - result = parse_msgpack_internal(); - break; - - case input_format_t::ubjson: - result = parse_ubjson_internal(); - break; - - case input_format_t::json: // LCOV_EXCL_LINE - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE - } - - // strict mode: next byte must be EOF - if (result && strict) - { - if (format == input_format_t::ubjson) - { - get_ignore_noop(); - } - else - { - get(); - } - - if (JSON_HEDLEY_UNLIKELY(current != std::char_traits::eof())) - { - return sax->parse_error(chars_read, get_token_string(), - parse_error::create(110, chars_read, exception_message(format, "expected end of input; last byte: 0x" + get_token_string(), "value"), BasicJsonType())); - } - } - - return result; - } - - private: - ////////// - // BSON // - ////////// - - /*! - @brief Reads in a BSON-object and passes it to the SAX-parser. - @return whether a valid BSON-value was passed to the SAX parser - */ - bool parse_bson_internal() - { - std::int32_t document_size{}; - get_number(input_format_t::bson, document_size); - - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1)))) - { - return false; - } - - if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_list(/*is_array*/false))) - { - return false; - } - - return sax->end_object(); - } - - /*! - @brief Parses a C-style string from the BSON input. - @param[in,out] result A reference to the string variable where the read - string is to be stored. - @return `true` if the \x00-byte indicating the end of the string was - encountered before the EOF; false` indicates an unexpected EOF. - */ - bool get_bson_cstr(string_t& result) - { - auto out = std::back_inserter(result); - while (true) - { - get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::bson, "cstring"))) - { - return false; - } - if (current == 0x00) - { - return true; - } - *out++ = static_cast(current); - } - } - - /*! - @brief Parses a zero-terminated string of length @a len from the BSON - input. - @param[in] len The length (including the zero-byte at the end) of the - string to be read. - @param[in,out] result A reference to the string variable where the read - string is to be stored. - @tparam NumberType The type of the length @a len - @pre len >= 1 - @return `true` if the string was successfully parsed - */ - template - bool get_bson_string(const NumberType len, string_t& result) - { - if (JSON_HEDLEY_UNLIKELY(len < 1)) - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, "string length must be at least 1, is " + std::to_string(len), "string"), BasicJsonType())); - } - - return get_string(input_format_t::bson, len - static_cast(1), result) && get() != std::char_traits::eof(); - } - - /*! - @brief Parses a byte array input of length @a len from the BSON input. - @param[in] len The length of the byte array to be read. - @param[in,out] result A reference to the binary variable where the read - array is to be stored. - @tparam NumberType The type of the length @a len - @pre len >= 0 - @return `true` if the byte array was successfully parsed - */ - template - bool get_bson_binary(const NumberType len, binary_t& result) - { - if (JSON_HEDLEY_UNLIKELY(len < 0)) - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, "byte array length cannot be negative, is " + std::to_string(len), "binary"), BasicJsonType())); - } - - // All BSON binary values have a subtype - std::uint8_t subtype{}; - get_number(input_format_t::bson, subtype); - result.set_subtype(subtype); - - return get_binary(input_format_t::bson, len, result); - } - - /*! - @brief Read a BSON document element of the given @a element_type. - @param[in] element_type The BSON element type, c.f. http://bsonspec.org/spec.html - @param[in] element_type_parse_position The position in the input stream, - where the `element_type` was read. - @warning Not all BSON element types are supported yet. An unsupported - @a element_type will give rise to a parse_error.114: - Unsupported BSON record type 0x... - @return whether a valid BSON-object/array was passed to the SAX parser - */ - bool parse_bson_element_internal(const char_int_type element_type, - const std::size_t element_type_parse_position) - { - switch (element_type) - { - case 0x01: // double - { - double number{}; - return get_number(input_format_t::bson, number) && sax->number_float(static_cast(number), ""); - } - - case 0x02: // string - { - std::int32_t len{}; - string_t value; - return get_number(input_format_t::bson, len) && get_bson_string(len, value) && sax->string(value); - } - - case 0x03: // object - { - return parse_bson_internal(); - } - - case 0x04: // array - { - return parse_bson_array(); - } - - case 0x05: // binary - { - std::int32_t len{}; - binary_t value; - return get_number(input_format_t::bson, len) && get_bson_binary(len, value) && sax->binary(value); - } - - case 0x08: // boolean - { - return sax->boolean(get() != 0); - } - - case 0x0A: // null - { - return sax->null(); - } - - case 0x10: // int32 - { - std::int32_t value{}; - return get_number(input_format_t::bson, value) && sax->number_integer(value); - } - - case 0x12: // int64 - { - std::int64_t value{}; - return get_number(input_format_t::bson, value) && sax->number_integer(value); - } - - default: // anything else not supported (yet) - { - std::array cr{{}}; - (std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast(element_type)); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) - return sax->parse_error(element_type_parse_position, std::string(cr.data()), parse_error::create(114, element_type_parse_position, "Unsupported BSON record type 0x" + std::string(cr.data()), BasicJsonType())); - } - } - } - - /*! - @brief Read a BSON element list (as specified in the BSON-spec) - - The same binary layout is used for objects and arrays, hence it must be - indicated with the argument @a is_array which one is expected - (true --> array, false --> object). - - @param[in] is_array Determines if the element list being read is to be - treated as an object (@a is_array == false), or as an - array (@a is_array == true). - @return whether a valid BSON-object/array was passed to the SAX parser - */ - bool parse_bson_element_list(const bool is_array) - { - string_t key; - - while (auto element_type = get()) - { - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::bson, "element list"))) - { - return false; - } - - const std::size_t element_type_parse_position = chars_read; - if (JSON_HEDLEY_UNLIKELY(!get_bson_cstr(key))) - { - return false; - } - - if (!is_array && !sax->key(key)) - { - return false; - } - - if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position))) - { - return false; - } - - // get_bson_cstr only appends - key.clear(); - } - - return true; - } - - /*! - @brief Reads an array from the BSON input and passes it to the SAX-parser. - @return whether a valid BSON-array was passed to the SAX parser - */ - bool parse_bson_array() - { - std::int32_t document_size{}; - get_number(input_format_t::bson, document_size); - - if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1)))) - { - return false; - } - - if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_list(/*is_array*/true))) - { - return false; - } - - return sax->end_array(); - } - - ////////// - // CBOR // - ////////// - - /*! - @param[in] get_char whether a new character should be retrieved from the - input (true) or whether the last read character should - be considered instead (false) - @param[in] tag_handler how CBOR tags should be treated - - @return whether a valid CBOR value was passed to the SAX parser - */ - bool parse_cbor_internal(const bool get_char, - const cbor_tag_handler_t tag_handler) - { - switch (get_char ? get() : current) - { - // EOF - case std::char_traits::eof(): - return unexpect_eof(input_format_t::cbor, "value"); - - // Integer 0x00..0x17 (0..23) - case 0x00: - case 0x01: - case 0x02: - case 0x03: - case 0x04: - case 0x05: - case 0x06: - case 0x07: - case 0x08: - case 0x09: - case 0x0A: - case 0x0B: - case 0x0C: - case 0x0D: - case 0x0E: - case 0x0F: - case 0x10: - case 0x11: - case 0x12: - case 0x13: - case 0x14: - case 0x15: - case 0x16: - case 0x17: - return sax->number_unsigned(static_cast(current)); - - case 0x18: // Unsigned integer (one-byte uint8_t follows) - { - std::uint8_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_unsigned(number); - } - - case 0x19: // Unsigned integer (two-byte uint16_t follows) - { - std::uint16_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_unsigned(number); - } - - case 0x1A: // Unsigned integer (four-byte uint32_t follows) - { - std::uint32_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_unsigned(number); - } - - case 0x1B: // Unsigned integer (eight-byte uint64_t follows) - { - std::uint64_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_unsigned(number); - } - - // Negative integer -1-0x00..-1-0x17 (-1..-24) - case 0x20: - case 0x21: - case 0x22: - case 0x23: - case 0x24: - case 0x25: - case 0x26: - case 0x27: - case 0x28: - case 0x29: - case 0x2A: - case 0x2B: - case 0x2C: - case 0x2D: - case 0x2E: - case 0x2F: - case 0x30: - case 0x31: - case 0x32: - case 0x33: - case 0x34: - case 0x35: - case 0x36: - case 0x37: - return sax->number_integer(static_cast(0x20 - 1 - current)); - - case 0x38: // Negative integer (one-byte uint8_t follows) - { - std::uint8_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast(-1) - number); - } - - case 0x39: // Negative integer -1-n (two-byte uint16_t follows) - { - std::uint16_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast(-1) - number); - } - - case 0x3A: // Negative integer -1-n (four-byte uint32_t follows) - { - std::uint32_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast(-1) - number); - } - - case 0x3B: // Negative integer -1-n (eight-byte uint64_t follows) - { - std::uint64_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast(-1) - - static_cast(number)); - } - - // Binary data (0x00..0x17 bytes follow) - case 0x40: - case 0x41: - case 0x42: - case 0x43: - case 0x44: - case 0x45: - case 0x46: - case 0x47: - case 0x48: - case 0x49: - case 0x4A: - case 0x4B: - case 0x4C: - case 0x4D: - case 0x4E: - case 0x4F: - case 0x50: - case 0x51: - case 0x52: - case 0x53: - case 0x54: - case 0x55: - case 0x56: - case 0x57: - case 0x58: // Binary data (one-byte uint8_t for n follows) - case 0x59: // Binary data (two-byte uint16_t for n follow) - case 0x5A: // Binary data (four-byte uint32_t for n follow) - case 0x5B: // Binary data (eight-byte uint64_t for n follow) - case 0x5F: // Binary data (indefinite length) - { - binary_t b; - return get_cbor_binary(b) && sax->binary(b); - } - - // UTF-8 string (0x00..0x17 bytes follow) - case 0x60: - case 0x61: - case 0x62: - case 0x63: - case 0x64: - case 0x65: - case 0x66: - case 0x67: - case 0x68: - case 0x69: - case 0x6A: - case 0x6B: - case 0x6C: - case 0x6D: - case 0x6E: - case 0x6F: - case 0x70: - case 0x71: - case 0x72: - case 0x73: - case 0x74: - case 0x75: - case 0x76: - case 0x77: - case 0x78: // UTF-8 string (one-byte uint8_t for n follows) - case 0x79: // UTF-8 string (two-byte uint16_t for n follow) - case 0x7A: // UTF-8 string (four-byte uint32_t for n follow) - case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow) - case 0x7F: // UTF-8 string (indefinite length) - { - string_t s; - return get_cbor_string(s) && sax->string(s); - } - - // array (0x00..0x17 data items follow) - case 0x80: - case 0x81: - case 0x82: - case 0x83: - case 0x84: - case 0x85: - case 0x86: - case 0x87: - case 0x88: - case 0x89: - case 0x8A: - case 0x8B: - case 0x8C: - case 0x8D: - case 0x8E: - case 0x8F: - case 0x90: - case 0x91: - case 0x92: - case 0x93: - case 0x94: - case 0x95: - case 0x96: - case 0x97: - return get_cbor_array(static_cast(static_cast(current) & 0x1Fu), tag_handler); - - case 0x98: // array (one-byte uint8_t for n follows) - { - std::uint8_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast(len), tag_handler); - } - - case 0x99: // array (two-byte uint16_t for n follow) - { - std::uint16_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast(len), tag_handler); - } - - case 0x9A: // array (four-byte uint32_t for n follow) - { - std::uint32_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast(len), tag_handler); - } - - case 0x9B: // array (eight-byte uint64_t for n follow) - { - std::uint64_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_array(detail::conditional_static_cast(len), tag_handler); - } - - case 0x9F: // array (indefinite length) - return get_cbor_array(std::size_t(-1), tag_handler); - - // map (0x00..0x17 pairs of data items follow) - case 0xA0: - case 0xA1: - case 0xA2: - case 0xA3: - case 0xA4: - case 0xA5: - case 0xA6: - case 0xA7: - case 0xA8: - case 0xA9: - case 0xAA: - case 0xAB: - case 0xAC: - case 0xAD: - case 0xAE: - case 0xAF: - case 0xB0: - case 0xB1: - case 0xB2: - case 0xB3: - case 0xB4: - case 0xB5: - case 0xB6: - case 0xB7: - return get_cbor_object(static_cast(static_cast(current) & 0x1Fu), tag_handler); - - case 0xB8: // map (one-byte uint8_t for n follows) - { - std::uint8_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast(len), tag_handler); - } - - case 0xB9: // map (two-byte uint16_t for n follow) - { - std::uint16_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast(len), tag_handler); - } - - case 0xBA: // map (four-byte uint32_t for n follow) - { - std::uint32_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast(len), tag_handler); - } - - case 0xBB: // map (eight-byte uint64_t for n follow) - { - std::uint64_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_object(detail::conditional_static_cast(len), tag_handler); - } - - case 0xBF: // map (indefinite length) - return get_cbor_object(std::size_t(-1), tag_handler); - - case 0xC6: // tagged item - case 0xC7: - case 0xC8: - case 0xC9: - case 0xCA: - case 0xCB: - case 0xCC: - case 0xCD: - case 0xCE: - case 0xCF: - case 0xD0: - case 0xD1: - case 0xD2: - case 0xD3: - case 0xD4: - case 0xD8: // tagged item (1 bytes follow) - case 0xD9: // tagged item (2 bytes follow) - case 0xDA: // tagged item (4 bytes follow) - case 0xDB: // tagged item (8 bytes follow) - { - switch (tag_handler) - { - case cbor_tag_handler_t::error: - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::cbor, "invalid byte: 0x" + last_token, "value"), BasicJsonType())); - } - - case cbor_tag_handler_t::ignore: - { - // ignore binary subtype - switch (current) - { - case 0xD8: - { - std::uint8_t subtype_to_ignore{}; - get_number(input_format_t::cbor, subtype_to_ignore); - break; - } - case 0xD9: - { - std::uint16_t subtype_to_ignore{}; - get_number(input_format_t::cbor, subtype_to_ignore); - break; - } - case 0xDA: - { - std::uint32_t subtype_to_ignore{}; - get_number(input_format_t::cbor, subtype_to_ignore); - break; - } - case 0xDB: - { - std::uint64_t subtype_to_ignore{}; - get_number(input_format_t::cbor, subtype_to_ignore); - break; - } - default: - break; - } - return parse_cbor_internal(true, tag_handler); - } - - case cbor_tag_handler_t::store: - { - binary_t b; - // use binary subtype and store in binary container - switch (current) - { - case 0xD8: - { - std::uint8_t subtype{}; - get_number(input_format_t::cbor, subtype); - b.set_subtype(detail::conditional_static_cast(subtype)); - break; - } - case 0xD9: - { - std::uint16_t subtype{}; - get_number(input_format_t::cbor, subtype); - b.set_subtype(detail::conditional_static_cast(subtype)); - break; - } - case 0xDA: - { - std::uint32_t subtype{}; - get_number(input_format_t::cbor, subtype); - b.set_subtype(detail::conditional_static_cast(subtype)); - break; - } - case 0xDB: - { - std::uint64_t subtype{}; - get_number(input_format_t::cbor, subtype); - b.set_subtype(detail::conditional_static_cast(subtype)); - break; - } - default: - return parse_cbor_internal(true, tag_handler); - } - get(); - return get_cbor_binary(b) && sax->binary(b); - } - - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE - return false; // LCOV_EXCL_LINE - } - } - - case 0xF4: // false - return sax->boolean(false); - - case 0xF5: // true - return sax->boolean(true); - - case 0xF6: // null - return sax->null(); - - case 0xF9: // Half-Precision Float (two-byte IEEE 754) - { - const auto byte1_raw = get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "number"))) - { - return false; - } - const auto byte2_raw = get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "number"))) - { - return false; - } - - const auto byte1 = static_cast(byte1_raw); - const auto byte2 = static_cast(byte2_raw); - - // code from RFC 7049, Appendix D, Figure 3: - // As half-precision floating-point numbers were only added - // to IEEE 754 in 2008, today's programming platforms often - // still only have limited support for them. It is very - // easy to include at least decoding support for them even - // without such support. An example of a small decoder for - // half-precision floating-point numbers in the C language - // is shown in Fig. 3. - const auto half = static_cast((byte1 << 8u) + byte2); - const double val = [&half] - { - const int exp = (half >> 10u) & 0x1Fu; - const unsigned int mant = half & 0x3FFu; - JSON_ASSERT(0 <= exp&& exp <= 32); - JSON_ASSERT(mant <= 1024); - switch (exp) - { - case 0: - return std::ldexp(mant, -24); - case 31: - return (mant == 0) - ? std::numeric_limits::infinity() - : std::numeric_limits::quiet_NaN(); - default: - return std::ldexp(mant + 1024, exp - 25); - } - }(); - return sax->number_float((half & 0x8000u) != 0 - ? static_cast(-val) - : static_cast(val), ""); - } - - case 0xFA: // Single-Precision Float (four-byte IEEE 754) - { - float number{}; - return get_number(input_format_t::cbor, number) && sax->number_float(static_cast(number), ""); - } - - case 0xFB: // Double-Precision Float (eight-byte IEEE 754) - { - double number{}; - return get_number(input_format_t::cbor, number) && sax->number_float(static_cast(number), ""); - } - - default: // anything else (0xFF is handled inside the other types) - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::cbor, "invalid byte: 0x" + last_token, "value"), BasicJsonType())); - } - } - } - - /*! - @brief reads a CBOR string - - This function first reads starting bytes to determine the expected - string length and then copies this number of bytes into a string. - Additionally, CBOR's strings with indefinite lengths are supported. - - @param[out] result created string - - @return whether string creation completed - */ - bool get_cbor_string(string_t& result) - { - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "string"))) - { - return false; - } - - switch (current) - { - // UTF-8 string (0x00..0x17 bytes follow) - case 0x60: - case 0x61: - case 0x62: - case 0x63: - case 0x64: - case 0x65: - case 0x66: - case 0x67: - case 0x68: - case 0x69: - case 0x6A: - case 0x6B: - case 0x6C: - case 0x6D: - case 0x6E: - case 0x6F: - case 0x70: - case 0x71: - case 0x72: - case 0x73: - case 0x74: - case 0x75: - case 0x76: - case 0x77: - { - return get_string(input_format_t::cbor, static_cast(current) & 0x1Fu, result); - } - - case 0x78: // UTF-8 string (one-byte uint8_t for n follows) - { - std::uint8_t len{}; - return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); - } - - case 0x79: // UTF-8 string (two-byte uint16_t for n follow) - { - std::uint16_t len{}; - return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); - } - - case 0x7A: // UTF-8 string (four-byte uint32_t for n follow) - { - std::uint32_t len{}; - return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); - } - - case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow) - { - std::uint64_t len{}; - return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); - } - - case 0x7F: // UTF-8 string (indefinite length) - { - while (get() != 0xFF) - { - string_t chunk; - if (!get_cbor_string(chunk)) - { - return false; - } - result.append(chunk); - } - return true; - } - - default: - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::cbor, "expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x" + last_token, "string"), BasicJsonType())); - } - } - } - - /*! - @brief reads a CBOR byte array - - This function first reads starting bytes to determine the expected - byte array length and then copies this number of bytes into the byte array. - Additionally, CBOR's byte arrays with indefinite lengths are supported. - - @param[out] result created byte array - - @return whether byte array creation completed - */ - bool get_cbor_binary(binary_t& result) - { - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "binary"))) - { - return false; - } - - switch (current) - { - // Binary data (0x00..0x17 bytes follow) - case 0x40: - case 0x41: - case 0x42: - case 0x43: - case 0x44: - case 0x45: - case 0x46: - case 0x47: - case 0x48: - case 0x49: - case 0x4A: - case 0x4B: - case 0x4C: - case 0x4D: - case 0x4E: - case 0x4F: - case 0x50: - case 0x51: - case 0x52: - case 0x53: - case 0x54: - case 0x55: - case 0x56: - case 0x57: - { - return get_binary(input_format_t::cbor, static_cast(current) & 0x1Fu, result); - } - - case 0x58: // Binary data (one-byte uint8_t for n follows) - { - std::uint8_t len{}; - return get_number(input_format_t::cbor, len) && - get_binary(input_format_t::cbor, len, result); - } - - case 0x59: // Binary data (two-byte uint16_t for n follow) - { - std::uint16_t len{}; - return get_number(input_format_t::cbor, len) && - get_binary(input_format_t::cbor, len, result); - } - - case 0x5A: // Binary data (four-byte uint32_t for n follow) - { - std::uint32_t len{}; - return get_number(input_format_t::cbor, len) && - get_binary(input_format_t::cbor, len, result); - } - - case 0x5B: // Binary data (eight-byte uint64_t for n follow) - { - std::uint64_t len{}; - return get_number(input_format_t::cbor, len) && - get_binary(input_format_t::cbor, len, result); - } - - case 0x5F: // Binary data (indefinite length) - { - while (get() != 0xFF) - { - binary_t chunk; - if (!get_cbor_binary(chunk)) - { - return false; - } - result.insert(result.end(), chunk.begin(), chunk.end()); - } - return true; - } - - default: - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::cbor, "expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x" + last_token, "binary"), BasicJsonType())); - } - } - } - - /*! - @param[in] len the length of the array or std::size_t(-1) for an - array of indefinite size - @param[in] tag_handler how CBOR tags should be treated - @return whether array creation completed - */ - bool get_cbor_array(const std::size_t len, - const cbor_tag_handler_t tag_handler) - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_array(len))) - { - return false; - } - - if (len != std::size_t(-1)) - { - for (std::size_t i = 0; i < len; ++i) - { - if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(true, tag_handler))) - { - return false; - } - } - } - else - { - while (get() != 0xFF) - { - if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(false, tag_handler))) - { - return false; - } - } - } - - return sax->end_array(); - } - - /*! - @param[in] len the length of the object or std::size_t(-1) for an - object of indefinite size - @param[in] tag_handler how CBOR tags should be treated - @return whether object creation completed - */ - bool get_cbor_object(const std::size_t len, - const cbor_tag_handler_t tag_handler) - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(len))) - { - return false; - } - - if (len != 0) - { - string_t key; - if (len != std::size_t(-1)) - { - for (std::size_t i = 0; i < len; ++i) - { - get(); - if (JSON_HEDLEY_UNLIKELY(!get_cbor_string(key) || !sax->key(key))) - { - return false; - } - - if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(true, tag_handler))) - { - return false; - } - key.clear(); - } - } - else - { - while (get() != 0xFF) - { - if (JSON_HEDLEY_UNLIKELY(!get_cbor_string(key) || !sax->key(key))) - { - return false; - } - - if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(true, tag_handler))) - { - return false; - } - key.clear(); - } - } - } - - return sax->end_object(); - } - - ///////////// - // MsgPack // - ///////////// - - /*! - @return whether a valid MessagePack value was passed to the SAX parser - */ - bool parse_msgpack_internal() - { - switch (get()) - { - // EOF - case std::char_traits::eof(): - return unexpect_eof(input_format_t::msgpack, "value"); - - // positive fixint - case 0x00: - case 0x01: - case 0x02: - case 0x03: - case 0x04: - case 0x05: - case 0x06: - case 0x07: - case 0x08: - case 0x09: - case 0x0A: - case 0x0B: - case 0x0C: - case 0x0D: - case 0x0E: - case 0x0F: - case 0x10: - case 0x11: - case 0x12: - case 0x13: - case 0x14: - case 0x15: - case 0x16: - case 0x17: - case 0x18: - case 0x19: - case 0x1A: - case 0x1B: - case 0x1C: - case 0x1D: - case 0x1E: - case 0x1F: - case 0x20: - case 0x21: - case 0x22: - case 0x23: - case 0x24: - case 0x25: - case 0x26: - case 0x27: - case 0x28: - case 0x29: - case 0x2A: - case 0x2B: - case 0x2C: - case 0x2D: - case 0x2E: - case 0x2F: - case 0x30: - case 0x31: - case 0x32: - case 0x33: - case 0x34: - case 0x35: - case 0x36: - case 0x37: - case 0x38: - case 0x39: - case 0x3A: - case 0x3B: - case 0x3C: - case 0x3D: - case 0x3E: - case 0x3F: - case 0x40: - case 0x41: - case 0x42: - case 0x43: - case 0x44: - case 0x45: - case 0x46: - case 0x47: - case 0x48: - case 0x49: - case 0x4A: - case 0x4B: - case 0x4C: - case 0x4D: - case 0x4E: - case 0x4F: - case 0x50: - case 0x51: - case 0x52: - case 0x53: - case 0x54: - case 0x55: - case 0x56: - case 0x57: - case 0x58: - case 0x59: - case 0x5A: - case 0x5B: - case 0x5C: - case 0x5D: - case 0x5E: - case 0x5F: - case 0x60: - case 0x61: - case 0x62: - case 0x63: - case 0x64: - case 0x65: - case 0x66: - case 0x67: - case 0x68: - case 0x69: - case 0x6A: - case 0x6B: - case 0x6C: - case 0x6D: - case 0x6E: - case 0x6F: - case 0x70: - case 0x71: - case 0x72: - case 0x73: - case 0x74: - case 0x75: - case 0x76: - case 0x77: - case 0x78: - case 0x79: - case 0x7A: - case 0x7B: - case 0x7C: - case 0x7D: - case 0x7E: - case 0x7F: - return sax->number_unsigned(static_cast(current)); - - // fixmap - case 0x80: - case 0x81: - case 0x82: - case 0x83: - case 0x84: - case 0x85: - case 0x86: - case 0x87: - case 0x88: - case 0x89: - case 0x8A: - case 0x8B: - case 0x8C: - case 0x8D: - case 0x8E: - case 0x8F: - return get_msgpack_object(static_cast(static_cast(current) & 0x0Fu)); - - // fixarray - case 0x90: - case 0x91: - case 0x92: - case 0x93: - case 0x94: - case 0x95: - case 0x96: - case 0x97: - case 0x98: - case 0x99: - case 0x9A: - case 0x9B: - case 0x9C: - case 0x9D: - case 0x9E: - case 0x9F: - return get_msgpack_array(static_cast(static_cast(current) & 0x0Fu)); - - // fixstr - case 0xA0: - case 0xA1: - case 0xA2: - case 0xA3: - case 0xA4: - case 0xA5: - case 0xA6: - case 0xA7: - case 0xA8: - case 0xA9: - case 0xAA: - case 0xAB: - case 0xAC: - case 0xAD: - case 0xAE: - case 0xAF: - case 0xB0: - case 0xB1: - case 0xB2: - case 0xB3: - case 0xB4: - case 0xB5: - case 0xB6: - case 0xB7: - case 0xB8: - case 0xB9: - case 0xBA: - case 0xBB: - case 0xBC: - case 0xBD: - case 0xBE: - case 0xBF: - case 0xD9: // str 8 - case 0xDA: // str 16 - case 0xDB: // str 32 - { - string_t s; - return get_msgpack_string(s) && sax->string(s); - } - - case 0xC0: // nil - return sax->null(); - - case 0xC2: // false - return sax->boolean(false); - - case 0xC3: // true - return sax->boolean(true); - - case 0xC4: // bin 8 - case 0xC5: // bin 16 - case 0xC6: // bin 32 - case 0xC7: // ext 8 - case 0xC8: // ext 16 - case 0xC9: // ext 32 - case 0xD4: // fixext 1 - case 0xD5: // fixext 2 - case 0xD6: // fixext 4 - case 0xD7: // fixext 8 - case 0xD8: // fixext 16 - { - binary_t b; - return get_msgpack_binary(b) && sax->binary(b); - } - - case 0xCA: // float 32 - { - float number{}; - return get_number(input_format_t::msgpack, number) && sax->number_float(static_cast(number), ""); - } - - case 0xCB: // float 64 - { - double number{}; - return get_number(input_format_t::msgpack, number) && sax->number_float(static_cast(number), ""); - } - - case 0xCC: // uint 8 - { - std::uint8_t number{}; - return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number); - } - - case 0xCD: // uint 16 - { - std::uint16_t number{}; - return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number); - } - - case 0xCE: // uint 32 - { - std::uint32_t number{}; - return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number); - } - - case 0xCF: // uint 64 - { - std::uint64_t number{}; - return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number); - } - - case 0xD0: // int 8 - { - std::int8_t number{}; - return get_number(input_format_t::msgpack, number) && sax->number_integer(number); - } - - case 0xD1: // int 16 - { - std::int16_t number{}; - return get_number(input_format_t::msgpack, number) && sax->number_integer(number); - } - - case 0xD2: // int 32 - { - std::int32_t number{}; - return get_number(input_format_t::msgpack, number) && sax->number_integer(number); - } - - case 0xD3: // int 64 - { - std::int64_t number{}; - return get_number(input_format_t::msgpack, number) && sax->number_integer(number); - } - - case 0xDC: // array 16 - { - std::uint16_t len{}; - return get_number(input_format_t::msgpack, len) && get_msgpack_array(static_cast(len)); - } - - case 0xDD: // array 32 - { - std::uint32_t len{}; - return get_number(input_format_t::msgpack, len) && get_msgpack_array(static_cast(len)); - } - - case 0xDE: // map 16 - { - std::uint16_t len{}; - return get_number(input_format_t::msgpack, len) && get_msgpack_object(static_cast(len)); - } - - case 0xDF: // map 32 - { - std::uint32_t len{}; - return get_number(input_format_t::msgpack, len) && get_msgpack_object(static_cast(len)); - } - - // negative fixint - case 0xE0: - case 0xE1: - case 0xE2: - case 0xE3: - case 0xE4: - case 0xE5: - case 0xE6: - case 0xE7: - case 0xE8: - case 0xE9: - case 0xEA: - case 0xEB: - case 0xEC: - case 0xED: - case 0xEE: - case 0xEF: - case 0xF0: - case 0xF1: - case 0xF2: - case 0xF3: - case 0xF4: - case 0xF5: - case 0xF6: - case 0xF7: - case 0xF8: - case 0xF9: - case 0xFA: - case 0xFB: - case 0xFC: - case 0xFD: - case 0xFE: - case 0xFF: - return sax->number_integer(static_cast(current)); - - default: // anything else - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::msgpack, "invalid byte: 0x" + last_token, "value"), BasicJsonType())); - } - } - } - - /*! - @brief reads a MessagePack string - - This function first reads starting bytes to determine the expected - string length and then copies this number of bytes into a string. - - @param[out] result created string - - @return whether string creation completed - */ - bool get_msgpack_string(string_t& result) - { - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::msgpack, "string"))) - { - return false; - } - - switch (current) - { - // fixstr - case 0xA0: - case 0xA1: - case 0xA2: - case 0xA3: - case 0xA4: - case 0xA5: - case 0xA6: - case 0xA7: - case 0xA8: - case 0xA9: - case 0xAA: - case 0xAB: - case 0xAC: - case 0xAD: - case 0xAE: - case 0xAF: - case 0xB0: - case 0xB1: - case 0xB2: - case 0xB3: - case 0xB4: - case 0xB5: - case 0xB6: - case 0xB7: - case 0xB8: - case 0xB9: - case 0xBA: - case 0xBB: - case 0xBC: - case 0xBD: - case 0xBE: - case 0xBF: - { - return get_string(input_format_t::msgpack, static_cast(current) & 0x1Fu, result); - } - - case 0xD9: // str 8 - { - std::uint8_t len{}; - return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result); - } - - case 0xDA: // str 16 - { - std::uint16_t len{}; - return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result); - } - - case 0xDB: // str 32 - { - std::uint32_t len{}; - return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result); - } - - default: - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::msgpack, "expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x" + last_token, "string"), BasicJsonType())); - } - } - } - - /*! - @brief reads a MessagePack byte array - - This function first reads starting bytes to determine the expected - byte array length and then copies this number of bytes into a byte array. - - @param[out] result created byte array - - @return whether byte array creation completed - */ - bool get_msgpack_binary(binary_t& result) - { - // helper function to set the subtype - auto assign_and_return_true = [&result](std::int8_t subtype) - { - result.set_subtype(static_cast(subtype)); - return true; - }; - - switch (current) - { - case 0xC4: // bin 8 - { - std::uint8_t len{}; - return get_number(input_format_t::msgpack, len) && - get_binary(input_format_t::msgpack, len, result); - } - - case 0xC5: // bin 16 - { - std::uint16_t len{}; - return get_number(input_format_t::msgpack, len) && - get_binary(input_format_t::msgpack, len, result); - } - - case 0xC6: // bin 32 - { - std::uint32_t len{}; - return get_number(input_format_t::msgpack, len) && - get_binary(input_format_t::msgpack, len, result); - } - - case 0xC7: // ext 8 - { - std::uint8_t len{}; - std::int8_t subtype{}; - return get_number(input_format_t::msgpack, len) && - get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, len, result) && - assign_and_return_true(subtype); - } - - case 0xC8: // ext 16 - { - std::uint16_t len{}; - std::int8_t subtype{}; - return get_number(input_format_t::msgpack, len) && - get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, len, result) && - assign_and_return_true(subtype); - } - - case 0xC9: // ext 32 - { - std::uint32_t len{}; - std::int8_t subtype{}; - return get_number(input_format_t::msgpack, len) && - get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, len, result) && - assign_and_return_true(subtype); - } - - case 0xD4: // fixext 1 - { - std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 1, result) && - assign_and_return_true(subtype); - } - - case 0xD5: // fixext 2 - { - std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 2, result) && - assign_and_return_true(subtype); - } - - case 0xD6: // fixext 4 - { - std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 4, result) && - assign_and_return_true(subtype); - } - - case 0xD7: // fixext 8 - { - std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 8, result) && - assign_and_return_true(subtype); - } - - case 0xD8: // fixext 16 - { - std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 16, result) && - assign_and_return_true(subtype); - } - - default: // LCOV_EXCL_LINE - return false; // LCOV_EXCL_LINE - } - } - - /*! - @param[in] len the length of the array - @return whether array creation completed - */ - bool get_msgpack_array(const std::size_t len) - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_array(len))) - { - return false; - } - - for (std::size_t i = 0; i < len; ++i) - { - if (JSON_HEDLEY_UNLIKELY(!parse_msgpack_internal())) - { - return false; - } - } - - return sax->end_array(); - } - - /*! - @param[in] len the length of the object - @return whether object creation completed - */ - bool get_msgpack_object(const std::size_t len) - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(len))) - { - return false; - } - - string_t key; - for (std::size_t i = 0; i < len; ++i) - { - get(); - if (JSON_HEDLEY_UNLIKELY(!get_msgpack_string(key) || !sax->key(key))) - { - return false; - } - - if (JSON_HEDLEY_UNLIKELY(!parse_msgpack_internal())) - { - return false; - } - key.clear(); - } - - return sax->end_object(); - } - - //////////// - // UBJSON // - //////////// - - /*! - @param[in] get_char whether a new character should be retrieved from the - input (true, default) or whether the last read - character should be considered instead - - @return whether a valid UBJSON value was passed to the SAX parser - */ - bool parse_ubjson_internal(const bool get_char = true) - { - return get_ubjson_value(get_char ? get_ignore_noop() : current); - } - - /*! - @brief reads a UBJSON string - - This function is either called after reading the 'S' byte explicitly - indicating a string, or in case of an object key where the 'S' byte can be - left out. - - @param[out] result created string - @param[in] get_char whether a new character should be retrieved from the - input (true, default) or whether the last read - character should be considered instead - - @return whether string creation completed - */ - bool get_ubjson_string(string_t& result, const bool get_char = true) - { - if (get_char) - { - get(); // TODO(niels): may we ignore N here? - } - - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "value"))) - { - return false; - } - - switch (current) - { - case 'U': - { - std::uint8_t len{}; - return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); - } - - case 'i': - { - std::int8_t len{}; - return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); - } - - case 'I': - { - std::int16_t len{}; - return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); - } - - case 'l': - { - std::int32_t len{}; - return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); - } - - case 'L': - { - std::int64_t len{}; - return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); - } - - default: - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "expected length type specification (U, i, I, l, L); last byte: 0x" + last_token, "string"), BasicJsonType())); - } - } - - /*! - @param[out] result determined size - @return whether size determination completed - */ - bool get_ubjson_size_value(std::size_t& result) - { - switch (get_ignore_noop()) - { - case 'U': - { - std::uint8_t number{}; - if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number))) - { - return false; - } - result = static_cast(number); - return true; - } - - case 'i': - { - std::int8_t number{}; - if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number))) - { - return false; - } - result = static_cast(number); // NOLINT(bugprone-signed-char-misuse,cert-str34-c): number is not a char - return true; - } - - case 'I': - { - std::int16_t number{}; - if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number))) - { - return false; - } - result = static_cast(number); - return true; - } - - case 'l': - { - std::int32_t number{}; - if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number))) - { - return false; - } - result = static_cast(number); - return true; - } - - case 'L': - { - std::int64_t number{}; - if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number))) - { - return false; - } - result = static_cast(number); - return true; - } - - default: - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token, "size"), BasicJsonType())); - } - } - } - - /*! - @brief determine the type and size for a container - - In the optimized UBJSON format, a type and a size can be provided to allow - for a more compact representation. - - @param[out] result pair of the size and the type - - @return whether pair creation completed - */ - bool get_ubjson_size_type(std::pair& result) - { - result.first = string_t::npos; // size - result.second = 0; // type - - get_ignore_noop(); - - if (current == '$') - { - result.second = get(); // must not ignore 'N', because 'N' maybe the type - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "type"))) - { - return false; - } - - get_ignore_noop(); - if (JSON_HEDLEY_UNLIKELY(current != '#')) - { - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "value"))) - { - return false; - } - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::ubjson, "expected '#' after type information; last byte: 0x" + last_token, "size"), BasicJsonType())); - } - - return get_ubjson_size_value(result.first); - } - - if (current == '#') - { - return get_ubjson_size_value(result.first); - } - - return true; - } - - /*! - @param prefix the previously read or set type prefix - @return whether value creation completed - */ - bool get_ubjson_value(const char_int_type prefix) - { - switch (prefix) - { - case std::char_traits::eof(): // EOF - return unexpect_eof(input_format_t::ubjson, "value"); - - case 'T': // true - return sax->boolean(true); - case 'F': // false - return sax->boolean(false); - - case 'Z': // null - return sax->null(); - - case 'U': - { - std::uint8_t number{}; - return get_number(input_format_t::ubjson, number) && sax->number_unsigned(number); - } - - case 'i': - { - std::int8_t number{}; - return get_number(input_format_t::ubjson, number) && sax->number_integer(number); - } - - case 'I': - { - std::int16_t number{}; - return get_number(input_format_t::ubjson, number) && sax->number_integer(number); - } - - case 'l': - { - std::int32_t number{}; - return get_number(input_format_t::ubjson, number) && sax->number_integer(number); - } - - case 'L': - { - std::int64_t number{}; - return get_number(input_format_t::ubjson, number) && sax->number_integer(number); - } - - case 'd': - { - float number{}; - return get_number(input_format_t::ubjson, number) && sax->number_float(static_cast(number), ""); - } - - case 'D': - { - double number{}; - return get_number(input_format_t::ubjson, number) && sax->number_float(static_cast(number), ""); - } - - case 'H': - { - return get_ubjson_high_precision_number(); - } - - case 'C': // char - { - get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "char"))) - { - return false; - } - if (JSON_HEDLEY_UNLIKELY(current > 127)) - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "byte after 'C' must be in range 0x00..0x7F; last byte: 0x" + last_token, "char"), BasicJsonType())); - } - string_t s(1, static_cast(current)); - return sax->string(s); - } - - case 'S': // string - { - string_t s; - return get_ubjson_string(s) && sax->string(s); - } - - case '[': // array - return get_ubjson_array(); - - case '{': // object - return get_ubjson_object(); - - default: // anything else - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::ubjson, "invalid byte: 0x" + last_token, "value"), BasicJsonType())); - } - } - } - - /*! - @return whether array creation completed - */ - bool get_ubjson_array() - { - std::pair size_and_type; - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_type(size_and_type))) - { - return false; - } - - if (size_and_type.first != string_t::npos) - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_array(size_and_type.first))) - { - return false; - } - - if (size_and_type.second != 0) - { - if (size_and_type.second != 'N') - { - for (std::size_t i = 0; i < size_and_type.first; ++i) - { - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_value(size_and_type.second))) - { - return false; - } - } - } - } - else - { - for (std::size_t i = 0; i < size_and_type.first; ++i) - { - if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal())) - { - return false; - } - } - } - } - else - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1)))) - { - return false; - } - - while (current != ']') - { - if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal(false))) - { - return false; - } - get_ignore_noop(); - } - } - - return sax->end_array(); - } - - /*! - @return whether object creation completed - */ - bool get_ubjson_object() - { - std::pair size_and_type; - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_type(size_and_type))) - { - return false; - } - - string_t key; - if (size_and_type.first != string_t::npos) - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(size_and_type.first))) - { - return false; - } - - if (size_and_type.second != 0) - { - for (std::size_t i = 0; i < size_and_type.first; ++i) - { - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_string(key) || !sax->key(key))) - { - return false; - } - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_value(size_and_type.second))) - { - return false; - } - key.clear(); - } - } - else - { - for (std::size_t i = 0; i < size_and_type.first; ++i) - { - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_string(key) || !sax->key(key))) - { - return false; - } - if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal())) - { - return false; - } - key.clear(); - } - } - } - else - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1)))) - { - return false; - } - - while (current != '}') - { - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_string(key, false) || !sax->key(key))) - { - return false; - } - if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal())) - { - return false; - } - get_ignore_noop(); - key.clear(); - } - } - - return sax->end_object(); - } - - // Note, no reader for UBJSON binary types is implemented because they do - // not exist - - bool get_ubjson_high_precision_number() - { - // get size of following number string - std::size_t size{}; - auto res = get_ubjson_size_value(size); - if (JSON_HEDLEY_UNLIKELY(!res)) - { - return res; - } - - // get number string - std::vector number_vector; - for (std::size_t i = 0; i < size; ++i) - { - get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "number"))) - { - return false; - } - number_vector.push_back(static_cast(current)); - } - - // parse number string - using ia_type = decltype(detail::input_adapter(number_vector)); - auto number_lexer = detail::lexer(detail::input_adapter(number_vector), false); - const auto result_number = number_lexer.scan(); - const auto number_string = number_lexer.get_token_string(); - const auto result_remainder = number_lexer.scan(); - - using token_type = typename detail::lexer_base::token_type; - - if (JSON_HEDLEY_UNLIKELY(result_remainder != token_type::end_of_input)) - { - return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read, exception_message(input_format_t::ubjson, "invalid number text: " + number_lexer.get_token_string(), "high-precision number"), BasicJsonType())); - } - - switch (result_number) - { - case token_type::value_integer: - return sax->number_integer(number_lexer.get_number_integer()); - case token_type::value_unsigned: - return sax->number_unsigned(number_lexer.get_number_unsigned()); - case token_type::value_float: - return sax->number_float(number_lexer.get_number_float(), std::move(number_string)); - case token_type::uninitialized: - case token_type::literal_true: - case token_type::literal_false: - case token_type::literal_null: - case token_type::value_string: - case token_type::begin_array: - case token_type::begin_object: - case token_type::end_array: - case token_type::end_object: - case token_type::name_separator: - case token_type::value_separator: - case token_type::parse_error: - case token_type::end_of_input: - case token_type::literal_or_value: - default: - return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read, exception_message(input_format_t::ubjson, "invalid number text: " + number_lexer.get_token_string(), "high-precision number"), BasicJsonType())); - } - } - - /////////////////////// - // Utility functions // - /////////////////////// - - /*! - @brief get next character from the input - - This function provides the interface to the used input adapter. It does - not throw in case the input reached EOF, but returns a -'ve valued - `std::char_traits::eof()` in that case. - - @return character read from the input - */ - char_int_type get() - { - ++chars_read; - return current = ia.get_character(); - } - - /*! - @return character read from the input after ignoring all 'N' entries - */ - char_int_type get_ignore_noop() - { - do - { - get(); - } - while (current == 'N'); - - return current; - } - - /* - @brief read a number from the input - - @tparam NumberType the type of the number - @param[in] format the current format (for diagnostics) - @param[out] result number of type @a NumberType - - @return whether conversion completed - - @note This function needs to respect the system's endianess, because - bytes in CBOR, MessagePack, and UBJSON are stored in network order - (big endian) and therefore need reordering on little endian systems. - */ - template - bool get_number(const input_format_t format, NumberType& result) - { - // step 1: read input into array with system's byte order - std::array vec{}; - for (std::size_t i = 0; i < sizeof(NumberType); ++i) - { - get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format, "number"))) - { - return false; - } - - // reverse byte order prior to conversion if necessary - if (is_little_endian != InputIsLittleEndian) - { - vec[sizeof(NumberType) - i - 1] = static_cast(current); - } - else - { - vec[i] = static_cast(current); // LCOV_EXCL_LINE - } - } - - // step 2: convert array into number of type T and return - std::memcpy(&result, vec.data(), sizeof(NumberType)); - return true; - } - - /*! - @brief create a string by reading characters from the input - - @tparam NumberType the type of the number - @param[in] format the current format (for diagnostics) - @param[in] len number of characters to read - @param[out] result string created by reading @a len bytes - - @return whether string creation completed - - @note We can not reserve @a len bytes for the result, because @a len - may be too large. Usually, @ref unexpect_eof() detects the end of - the input before we run out of string memory. - */ - template - bool get_string(const input_format_t format, - const NumberType len, - string_t& result) - { - bool success = true; - for (NumberType i = 0; i < len; i++) - { - get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format, "string"))) - { - success = false; - break; - } - result.push_back(static_cast(current)); - } - return success; - } - - /*! - @brief create a byte array by reading bytes from the input - - @tparam NumberType the type of the number - @param[in] format the current format (for diagnostics) - @param[in] len number of bytes to read - @param[out] result byte array created by reading @a len bytes - - @return whether byte array creation completed - - @note We can not reserve @a len bytes for the result, because @a len - may be too large. Usually, @ref unexpect_eof() detects the end of - the input before we run out of memory. - */ - template - bool get_binary(const input_format_t format, - const NumberType len, - binary_t& result) - { - bool success = true; - for (NumberType i = 0; i < len; i++) - { - get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format, "binary"))) - { - success = false; - break; - } - result.push_back(static_cast(current)); - } - return success; - } - - /*! - @param[in] format the current format (for diagnostics) - @param[in] context further context information (for diagnostics) - @return whether the last read character is not EOF - */ - JSON_HEDLEY_NON_NULL(3) - bool unexpect_eof(const input_format_t format, const char* context) const - { - if (JSON_HEDLEY_UNLIKELY(current == std::char_traits::eof())) - { - return sax->parse_error(chars_read, "", - parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context), BasicJsonType())); - } - return true; - } - - /*! - @return a string representation of the last read byte - */ - std::string get_token_string() const - { - std::array cr{{}}; - (std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast(current)); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) - return std::string{cr.data()}; - } - - /*! - @param[in] format the current format - @param[in] detail a detailed error message - @param[in] context further context information - @return a message string to use in the parse_error exceptions - */ - std::string exception_message(const input_format_t format, - const std::string& detail, - const std::string& context) const - { - std::string error_msg = "syntax error while parsing "; - - switch (format) - { - case input_format_t::cbor: - error_msg += "CBOR"; - break; - - case input_format_t::msgpack: - error_msg += "MessagePack"; - break; - - case input_format_t::ubjson: - error_msg += "UBJSON"; - break; - - case input_format_t::bson: - error_msg += "BSON"; - break; - - case input_format_t::json: // LCOV_EXCL_LINE - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE - } - - return error_msg + " " + context + ": " + detail; - } - - private: - /// input adapter - InputAdapterType ia; - - /// the current character - char_int_type current = std::char_traits::eof(); - - /// the number of characters read - std::size_t chars_read = 0; - - /// whether we can assume little endianess - const bool is_little_endian = little_endianess(); - - /// the SAX parser - json_sax_t* sax = nullptr; -}; -} // namespace detail -} // namespace nlohmann - -// #include - -// #include - -// #include - - -#include // isfinite -#include // uint8_t -#include // function -#include // string -#include // move -#include // vector - -// #include - -// #include - -// #include - -// #include - -// #include - -// #include - -// #include - - -namespace nlohmann -{ -namespace detail -{ -//////////// -// parser // -//////////// - -enum class parse_event_t : std::uint8_t -{ - /// the parser read `{` and started to process a JSON object - object_start, - /// the parser read `}` and finished processing a JSON object - object_end, - /// the parser read `[` and started to process a JSON array - array_start, - /// the parser read `]` and finished processing a JSON array - array_end, - /// the parser read a key of a value in an object - key, - /// the parser finished reading a JSON value - value -}; - -template -using parser_callback_t = - std::function; - -/*! -@brief syntax analysis - -This class implements a recursive descent parser. -*/ -template -class parser -{ - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using lexer_t = lexer; - using token_type = typename lexer_t::token_type; - - public: - /// a parser reading from an input adapter - explicit parser(InputAdapterType&& adapter, - const parser_callback_t cb = nullptr, - const bool allow_exceptions_ = true, - const bool skip_comments = false) - : callback(cb) - , m_lexer(std::move(adapter), skip_comments) - , allow_exceptions(allow_exceptions_) - { - // read first token - get_token(); - } - - /*! - @brief public parser interface - - @param[in] strict whether to expect the last token to be EOF - @param[in,out] result parsed JSON value - - @throw parse_error.101 in case of an unexpected token - @throw parse_error.102 if to_unicode fails or surrogate error - @throw parse_error.103 if to_unicode fails - */ - void parse(const bool strict, BasicJsonType& result) - { - if (callback) - { - json_sax_dom_callback_parser sdp(result, callback, allow_exceptions); - sax_parse_internal(&sdp); - - // in strict mode, input must be completely read - if (strict && (get_token() != token_type::end_of_input)) - { - sdp.parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), - exception_message(token_type::end_of_input, "value"), BasicJsonType())); - } - - // in case of an error, return discarded value - if (sdp.is_errored()) - { - result = value_t::discarded; - return; - } - - // set top-level value to null if it was discarded by the callback - // function - if (result.is_discarded()) - { - result = nullptr; - } - } - else - { - json_sax_dom_parser sdp(result, allow_exceptions); - sax_parse_internal(&sdp); - - // in strict mode, input must be completely read - if (strict && (get_token() != token_type::end_of_input)) - { - sdp.parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input, "value"), BasicJsonType())); - } - - // in case of an error, return discarded value - if (sdp.is_errored()) - { - result = value_t::discarded; - return; - } - } - - result.assert_invariant(); - } - - /*! - @brief public accept interface - - @param[in] strict whether to expect the last token to be EOF - @return whether the input is a proper JSON text - */ - bool accept(const bool strict = true) - { - json_sax_acceptor sax_acceptor; - return sax_parse(&sax_acceptor, strict); - } - - template - JSON_HEDLEY_NON_NULL(2) - bool sax_parse(SAX* sax, const bool strict = true) - { - (void)detail::is_sax_static_asserts {}; - const bool result = sax_parse_internal(sax); - - // strict mode: next byte must be EOF - if (result && strict && (get_token() != token_type::end_of_input)) - { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input, "value"), BasicJsonType())); - } - - return result; - } - - private: - template - JSON_HEDLEY_NON_NULL(2) - bool sax_parse_internal(SAX* sax) - { - // stack to remember the hierarchy of structured values we are parsing - // true = array; false = object - std::vector states; - // value to avoid a goto (see comment where set to true) - bool skip_to_state_evaluation = false; - - while (true) - { - if (!skip_to_state_evaluation) - { - // invariant: get_token() was called before each iteration - switch (last_token) - { - case token_type::begin_object: - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1)))) - { - return false; - } - - // closing } -> we are done - if (get_token() == token_type::end_object) - { - if (JSON_HEDLEY_UNLIKELY(!sax->end_object())) - { - return false; - } - break; - } - - // parse key - if (JSON_HEDLEY_UNLIKELY(last_token != token_type::value_string)) - { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"), BasicJsonType())); - } - if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.get_string()))) - { - return false; - } - - // parse separator (:) - if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) - { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator, "object separator"), BasicJsonType())); - } - - // remember we are now inside an object - states.push_back(false); - - // parse values - get_token(); - continue; - } - - case token_type::begin_array: - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1)))) - { - return false; - } - - // closing ] -> we are done - if (get_token() == token_type::end_array) - { - if (JSON_HEDLEY_UNLIKELY(!sax->end_array())) - { - return false; - } - break; - } - - // remember we are now inside an array - states.push_back(true); - - // parse values (no need to call get_token) - continue; - } - - case token_type::value_float: - { - const auto res = m_lexer.get_number_float(); - - if (JSON_HEDLEY_UNLIKELY(!std::isfinite(res))) - { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - out_of_range::create(406, "number overflow parsing '" + m_lexer.get_token_string() + "'", BasicJsonType())); - } - - if (JSON_HEDLEY_UNLIKELY(!sax->number_float(res, m_lexer.get_string()))) - { - return false; - } - - break; - } - - case token_type::literal_false: - { - if (JSON_HEDLEY_UNLIKELY(!sax->boolean(false))) - { - return false; - } - break; - } - - case token_type::literal_null: - { - if (JSON_HEDLEY_UNLIKELY(!sax->null())) - { - return false; - } - break; - } - - case token_type::literal_true: - { - if (JSON_HEDLEY_UNLIKELY(!sax->boolean(true))) - { - return false; - } - break; - } - - case token_type::value_integer: - { - if (JSON_HEDLEY_UNLIKELY(!sax->number_integer(m_lexer.get_number_integer()))) - { - return false; - } - break; - } - - case token_type::value_string: - { - if (JSON_HEDLEY_UNLIKELY(!sax->string(m_lexer.get_string()))) - { - return false; - } - break; - } - - case token_type::value_unsigned: - { - if (JSON_HEDLEY_UNLIKELY(!sax->number_unsigned(m_lexer.get_number_unsigned()))) - { - return false; - } - break; - } - - case token_type::parse_error: - { - // using "uninitialized" to avoid "expected" message - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized, "value"), BasicJsonType())); - } - - case token_type::uninitialized: - case token_type::end_array: - case token_type::end_object: - case token_type::name_separator: - case token_type::value_separator: - case token_type::end_of_input: - case token_type::literal_or_value: - default: // the last token was unexpected - { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value, "value"), BasicJsonType())); - } - } - } - else - { - skip_to_state_evaluation = false; - } - - // we reached this line after we successfully parsed a value - if (states.empty()) - { - // empty stack: we reached the end of the hierarchy: done - return true; - } - - if (states.back()) // array - { - // comma -> next value - if (get_token() == token_type::value_separator) - { - // parse a new value - get_token(); - continue; - } - - // closing ] - if (JSON_HEDLEY_LIKELY(last_token == token_type::end_array)) - { - if (JSON_HEDLEY_UNLIKELY(!sax->end_array())) - { - return false; - } - - // We are done with this array. Before we can parse a - // new value, we need to evaluate the new state first. - // By setting skip_to_state_evaluation to false, we - // are effectively jumping to the beginning of this if. - JSON_ASSERT(!states.empty()); - states.pop_back(); - skip_to_state_evaluation = true; - continue; - } - - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_array, "array"), BasicJsonType())); - } - - // states.back() is false -> object - - // comma -> next value - if (get_token() == token_type::value_separator) - { - // parse key - if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::value_string)) - { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"), BasicJsonType())); - } - - if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.get_string()))) - { - return false; - } - - // parse separator (:) - if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) - { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator, "object separator"), BasicJsonType())); - } - - // parse values - get_token(); - continue; - } - - // closing } - if (JSON_HEDLEY_LIKELY(last_token == token_type::end_object)) - { - if (JSON_HEDLEY_UNLIKELY(!sax->end_object())) - { - return false; - } - - // We are done with this object. Before we can parse a - // new value, we need to evaluate the new state first. - // By setting skip_to_state_evaluation to false, we - // are effectively jumping to the beginning of this if. - JSON_ASSERT(!states.empty()); - states.pop_back(); - skip_to_state_evaluation = true; - continue; - } - - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_object, "object"), BasicJsonType())); - } - } - - /// get next token from lexer - token_type get_token() - { - return last_token = m_lexer.scan(); - } - - std::string exception_message(const token_type expected, const std::string& context) - { - std::string error_msg = "syntax error "; - - if (!context.empty()) - { - error_msg += "while parsing " + context + " "; - } - - error_msg += "- "; - - if (last_token == token_type::parse_error) - { - error_msg += std::string(m_lexer.get_error_message()) + "; last read: '" + - m_lexer.get_token_string() + "'"; - } - else - { - error_msg += "unexpected " + std::string(lexer_t::token_type_name(last_token)); - } - - if (expected != token_type::uninitialized) - { - error_msg += "; expected " + std::string(lexer_t::token_type_name(expected)); - } - - return error_msg; - } - - private: - /// callback function - const parser_callback_t callback = nullptr; - /// the type of the last read token - token_type last_token = token_type::uninitialized; - /// the lexer - lexer_t m_lexer; - /// whether to throw exceptions in case of errors - const bool allow_exceptions = true; -}; - -} // namespace detail -} // namespace nlohmann - -// #include - - -// #include - - -#include // ptrdiff_t -#include // numeric_limits - -// #include - - -namespace nlohmann -{ -namespace detail -{ -/* -@brief an iterator for primitive JSON types - -This class models an iterator for primitive JSON types (boolean, number, -string). It's only purpose is to allow the iterator/const_iterator classes -to "iterate" over primitive values. Internally, the iterator is modeled by -a `difference_type` variable. Value begin_value (`0`) models the begin, -end_value (`1`) models past the end. -*/ -class primitive_iterator_t -{ - private: - using difference_type = std::ptrdiff_t; - static constexpr difference_type begin_value = 0; - static constexpr difference_type end_value = begin_value + 1; - - JSON_PRIVATE_UNLESS_TESTED: - /// iterator as signed integer type - difference_type m_it = (std::numeric_limits::min)(); - - public: - constexpr difference_type get_value() const noexcept - { - return m_it; - } - - /// set iterator to a defined beginning - void set_begin() noexcept - { - m_it = begin_value; - } - - /// set iterator to a defined past the end - void set_end() noexcept - { - m_it = end_value; - } - - /// return whether the iterator can be dereferenced - constexpr bool is_begin() const noexcept - { - return m_it == begin_value; - } - - /// return whether the iterator is at end - constexpr bool is_end() const noexcept - { - return m_it == end_value; - } - - friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept - { - return lhs.m_it == rhs.m_it; - } - - friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept - { - return lhs.m_it < rhs.m_it; - } - - primitive_iterator_t operator+(difference_type n) noexcept - { - auto result = *this; - result += n; - return result; - } - - friend constexpr difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept - { - return lhs.m_it - rhs.m_it; - } - - primitive_iterator_t& operator++() noexcept - { - ++m_it; - return *this; - } - - primitive_iterator_t const operator++(int) noexcept // NOLINT(readability-const-return-type) - { - auto result = *this; - ++m_it; - return result; - } - - primitive_iterator_t& operator--() noexcept - { - --m_it; - return *this; - } - - primitive_iterator_t const operator--(int) noexcept // NOLINT(readability-const-return-type) - { - auto result = *this; - --m_it; - return result; - } - - primitive_iterator_t& operator+=(difference_type n) noexcept - { - m_it += n; - return *this; - } - - primitive_iterator_t& operator-=(difference_type n) noexcept - { - m_it -= n; - return *this; - } -}; -} // namespace detail -} // namespace nlohmann - - -namespace nlohmann -{ -namespace detail -{ -/*! -@brief an iterator value - -@note This structure could easily be a union, but MSVC currently does not allow -unions members with complex constructors, see https://github.com/nlohmann/json/pull/105. -*/ -template struct internal_iterator -{ - /// iterator for JSON objects - typename BasicJsonType::object_t::iterator object_iterator {}; - /// iterator for JSON arrays - typename BasicJsonType::array_t::iterator array_iterator {}; - /// generic iterator for all other types - primitive_iterator_t primitive_iterator {}; -}; -} // namespace detail -} // namespace nlohmann - -// #include - - -#include // iterator, random_access_iterator_tag, bidirectional_iterator_tag, advance, next -#include // conditional, is_const, remove_const - -// #include - -// #include - -// #include - -// #include - -// #include - -// #include - -// #include - - -namespace nlohmann -{ -namespace detail -{ -// forward declare, to be able to friend it later on -template class iteration_proxy; -template class iteration_proxy_value; - -/*! -@brief a template for a bidirectional iterator for the @ref basic_json class -This class implements a both iterators (iterator and const_iterator) for the -@ref basic_json class. -@note An iterator is called *initialized* when a pointer to a JSON value has - been set (e.g., by a constructor or a copy assignment). If the iterator is - default-constructed, it is *uninitialized* and most methods are undefined. - **The library uses assertions to detect calls on uninitialized iterators.** -@requirement The class satisfies the following concept requirements: -- -[BidirectionalIterator](https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator): - The iterator that can be moved can be moved in both directions (i.e. - incremented and decremented). -@since version 1.0.0, simplified in version 2.0.9, change to bidirectional - iterators in version 3.0.0 (see https://github.com/nlohmann/json/issues/593) -*/ -template -class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-special-member-functions) -{ - /// the iterator with BasicJsonType of different const-ness - using other_iter_impl = iter_impl::value, typename std::remove_const::type, const BasicJsonType>::type>; - /// allow basic_json to access private members - friend other_iter_impl; - friend BasicJsonType; - friend iteration_proxy; - friend iteration_proxy_value; - - using object_t = typename BasicJsonType::object_t; - using array_t = typename BasicJsonType::array_t; - // make sure BasicJsonType is basic_json or const basic_json - static_assert(is_basic_json::type>::value, - "iter_impl only accepts (const) basic_json"); - - public: - - /// The std::iterator class template (used as a base class to provide typedefs) is deprecated in C++17. - /// The C++ Standard has never required user-defined iterators to derive from std::iterator. - /// A user-defined iterator should provide publicly accessible typedefs named - /// iterator_category, value_type, difference_type, pointer, and reference. - /// Note that value_type is required to be non-const, even for constant iterators. - using iterator_category = std::bidirectional_iterator_tag; - - /// the type of the values when the iterator is dereferenced - using value_type = typename BasicJsonType::value_type; - /// a type to represent differences between iterators - using difference_type = typename BasicJsonType::difference_type; - /// defines a pointer to the type iterated over (value_type) - using pointer = typename std::conditional::value, - typename BasicJsonType::const_pointer, - typename BasicJsonType::pointer>::type; - /// defines a reference to the type iterated over (value_type) - using reference = - typename std::conditional::value, - typename BasicJsonType::const_reference, - typename BasicJsonType::reference>::type; - - iter_impl() = default; - ~iter_impl() = default; - iter_impl(iter_impl&&) noexcept = default; - iter_impl& operator=(iter_impl&&) noexcept = default; - - /*! - @brief constructor for a given JSON instance - @param[in] object pointer to a JSON object for this iterator - @pre object != nullptr - @post The iterator is initialized; i.e. `m_object != nullptr`. - */ - explicit iter_impl(pointer object) noexcept : m_object(object) - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - { - m_it.object_iterator = typename object_t::iterator(); - break; - } - - case value_t::array: - { - m_it.array_iterator = typename array_t::iterator(); - break; - } - - case value_t::null: - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - { - m_it.primitive_iterator = primitive_iterator_t(); - break; - } - } - } - - /*! - @note The conventional copy constructor and copy assignment are implicitly - defined. Combined with the following converting constructor and - assignment, they support: (1) copy from iterator to iterator, (2) - copy from const iterator to const iterator, and (3) conversion from - iterator to const iterator. However conversion from const iterator - to iterator is not defined. - */ - - /*! - @brief const copy constructor - @param[in] other const iterator to copy from - @note This copy constructor had to be defined explicitly to circumvent a bug - occurring on msvc v19.0 compiler (VS 2015) debug build. For more - information refer to: https://github.com/nlohmann/json/issues/1608 - */ - iter_impl(const iter_impl& other) noexcept - : m_object(other.m_object), m_it(other.m_it) - {} - - /*! - @brief converting assignment - @param[in] other const iterator to copy from - @return const/non-const iterator - @note It is not checked whether @a other is initialized. - */ - iter_impl& operator=(const iter_impl& other) noexcept - { - if (&other != this) - { - m_object = other.m_object; - m_it = other.m_it; - } - return *this; - } - - /*! - @brief converting constructor - @param[in] other non-const iterator to copy from - @note It is not checked whether @a other is initialized. - */ - iter_impl(const iter_impl::type>& other) noexcept - : m_object(other.m_object), m_it(other.m_it) - {} - - /*! - @brief converting assignment - @param[in] other non-const iterator to copy from - @return const/non-const iterator - @note It is not checked whether @a other is initialized. - */ - iter_impl& operator=(const iter_impl::type>& other) noexcept // NOLINT(cert-oop54-cpp) - { - m_object = other.m_object; - m_it = other.m_it; - return *this; - } - - JSON_PRIVATE_UNLESS_TESTED: - /*! - @brief set the iterator to the first value - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - void set_begin() noexcept - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - { - m_it.object_iterator = m_object->m_value.object->begin(); - break; - } - - case value_t::array: - { - m_it.array_iterator = m_object->m_value.array->begin(); - break; - } - - case value_t::null: - { - // set to end so begin()==end() is true: null is empty - m_it.primitive_iterator.set_end(); - break; - } - - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - { - m_it.primitive_iterator.set_begin(); - break; - } - } - } - - /*! - @brief set the iterator past the last value - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - void set_end() noexcept - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - { - m_it.object_iterator = m_object->m_value.object->end(); - break; - } - - case value_t::array: - { - m_it.array_iterator = m_object->m_value.array->end(); - break; - } - - case value_t::null: - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - { - m_it.primitive_iterator.set_end(); - break; - } - } - } - - public: - /*! - @brief return a reference to the value pointed to by the iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - reference operator*() const - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - { - JSON_ASSERT(m_it.object_iterator != m_object->m_value.object->end()); - return m_it.object_iterator->second; - } - - case value_t::array: - { - JSON_ASSERT(m_it.array_iterator != m_object->m_value.array->end()); - return *m_it.array_iterator; - } - - case value_t::null: - JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object)); - - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - { - if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) - { - return *m_object; - } - - JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object)); - } - } - } - - /*! - @brief dereference the iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - pointer operator->() const - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - { - JSON_ASSERT(m_it.object_iterator != m_object->m_value.object->end()); - return &(m_it.object_iterator->second); - } - - case value_t::array: - { - JSON_ASSERT(m_it.array_iterator != m_object->m_value.array->end()); - return &*m_it.array_iterator; - } - - case value_t::null: - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - { - if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) - { - return m_object; - } - - JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object)); - } - } - } - - /*! - @brief post-increment (it++) - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - iter_impl const operator++(int) // NOLINT(readability-const-return-type) - { - auto result = *this; - ++(*this); - return result; - } - - /*! - @brief pre-increment (++it) - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - iter_impl& operator++() - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - { - std::advance(m_it.object_iterator, 1); - break; - } - - case value_t::array: - { - std::advance(m_it.array_iterator, 1); - break; - } - - case value_t::null: - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - { - ++m_it.primitive_iterator; - break; - } - } - - return *this; - } - - /*! - @brief post-decrement (it--) - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - iter_impl const operator--(int) // NOLINT(readability-const-return-type) - { - auto result = *this; - --(*this); - return result; - } - - /*! - @brief pre-decrement (--it) - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - iter_impl& operator--() - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - { - std::advance(m_it.object_iterator, -1); - break; - } - - case value_t::array: - { - std::advance(m_it.array_iterator, -1); - break; - } - - case value_t::null: - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - { - --m_it.primitive_iterator; - break; - } - } - - return *this; - } - - /*! - @brief comparison: equal - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - template < typename IterImpl, detail::enable_if_t < (std::is_same::value || std::is_same::value), std::nullptr_t > = nullptr > - bool operator==(const IterImpl& other) const - { - // if objects are not the same, the comparison is undefined - if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object)) - { - JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers", *m_object)); - } - - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - return (m_it.object_iterator == other.m_it.object_iterator); - - case value_t::array: - return (m_it.array_iterator == other.m_it.array_iterator); - - case value_t::null: - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - return (m_it.primitive_iterator == other.m_it.primitive_iterator); - } - } - - /*! - @brief comparison: not equal - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - template < typename IterImpl, detail::enable_if_t < (std::is_same::value || std::is_same::value), std::nullptr_t > = nullptr > - bool operator!=(const IterImpl& other) const - { - return !operator==(other); - } - - /*! - @brief comparison: smaller - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - bool operator<(const iter_impl& other) const - { - // if objects are not the same, the comparison is undefined - if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object)) - { - JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers", *m_object)); - } - - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - JSON_THROW(invalid_iterator::create(213, "cannot compare order of object iterators", *m_object)); - - case value_t::array: - return (m_it.array_iterator < other.m_it.array_iterator); - - case value_t::null: - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - return (m_it.primitive_iterator < other.m_it.primitive_iterator); - } - } - - /*! - @brief comparison: less than or equal - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - bool operator<=(const iter_impl& other) const - { - return !other.operator < (*this); - } - - /*! - @brief comparison: greater than - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - bool operator>(const iter_impl& other) const - { - return !operator<=(other); - } - - /*! - @brief comparison: greater than or equal - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - bool operator>=(const iter_impl& other) const - { - return !operator<(other); - } - - /*! - @brief add to iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - iter_impl& operator+=(difference_type i) - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators", *m_object)); - - case value_t::array: - { - std::advance(m_it.array_iterator, i); - break; - } - - case value_t::null: - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - { - m_it.primitive_iterator += i; - break; - } - } - - return *this; - } - - /*! - @brief subtract from iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - iter_impl& operator-=(difference_type i) - { - return operator+=(-i); - } - - /*! - @brief add to iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - iter_impl operator+(difference_type i) const - { - auto result = *this; - result += i; - return result; - } - - /*! - @brief addition of distance and iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - friend iter_impl operator+(difference_type i, const iter_impl& it) - { - auto result = it; - result += i; - return result; - } - - /*! - @brief subtract from iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - iter_impl operator-(difference_type i) const - { - auto result = *this; - result -= i; - return result; - } - - /*! - @brief return difference - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - difference_type operator-(const iter_impl& other) const - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators", *m_object)); - - case value_t::array: - return m_it.array_iterator - other.m_it.array_iterator; - - case value_t::null: - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - return m_it.primitive_iterator - other.m_it.primitive_iterator; - } - } - - /*! - @brief access to successor - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - reference operator[](difference_type n) const - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - JSON_THROW(invalid_iterator::create(208, "cannot use operator[] for object iterators", *m_object)); - - case value_t::array: - return *std::next(m_it.array_iterator, n); - - case value_t::null: - JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object)); - - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - { - if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.get_value() == -n)) - { - return *m_object; - } - - JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object)); - } - } - } - - /*! - @brief return the key of an object iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - const typename object_t::key_type& key() const - { - JSON_ASSERT(m_object != nullptr); - - if (JSON_HEDLEY_LIKELY(m_object->is_object())) - { - return m_it.object_iterator->first; - } - - JSON_THROW(invalid_iterator::create(207, "cannot use key() for non-object iterators", *m_object)); - } - - /*! - @brief return the value of an iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - reference value() const - { - return operator*(); - } - - JSON_PRIVATE_UNLESS_TESTED: - /// associated JSON instance - pointer m_object = nullptr; - /// the actual iterator of the associated instance - internal_iterator::type> m_it {}; -}; -} // namespace detail -} // namespace nlohmann - -// #include - -// #include - - -#include // ptrdiff_t -#include // reverse_iterator -#include // declval - -namespace nlohmann -{ -namespace detail -{ -////////////////////// -// reverse_iterator // -////////////////////// - -/*! -@brief a template for a reverse iterator class - -@tparam Base the base iterator type to reverse. Valid types are @ref -iterator (to create @ref reverse_iterator) and @ref const_iterator (to -create @ref const_reverse_iterator). - -@requirement The class satisfies the following concept requirements: -- -[BidirectionalIterator](https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator): - The iterator that can be moved can be moved in both directions (i.e. - incremented and decremented). -- [OutputIterator](https://en.cppreference.com/w/cpp/named_req/OutputIterator): - It is possible to write to the pointed-to element (only if @a Base is - @ref iterator). - -@since version 1.0.0 -*/ -template -class json_reverse_iterator : public std::reverse_iterator -{ - public: - using difference_type = std::ptrdiff_t; - /// shortcut to the reverse iterator adapter - using base_iterator = std::reverse_iterator; - /// the reference type for the pointed-to element - using reference = typename Base::reference; - - /// create reverse iterator from iterator - explicit json_reverse_iterator(const typename base_iterator::iterator_type& it) noexcept - : base_iterator(it) {} - - /// create reverse iterator from base class - explicit json_reverse_iterator(const base_iterator& it) noexcept : base_iterator(it) {} - - /// post-increment (it++) - json_reverse_iterator const operator++(int) // NOLINT(readability-const-return-type) - { - return static_cast(base_iterator::operator++(1)); - } - - /// pre-increment (++it) - json_reverse_iterator& operator++() - { - return static_cast(base_iterator::operator++()); - } - - /// post-decrement (it--) - json_reverse_iterator const operator--(int) // NOLINT(readability-const-return-type) - { - return static_cast(base_iterator::operator--(1)); - } - - /// pre-decrement (--it) - json_reverse_iterator& operator--() - { - return static_cast(base_iterator::operator--()); - } - - /// add to iterator - json_reverse_iterator& operator+=(difference_type i) - { - return static_cast(base_iterator::operator+=(i)); - } - - /// add to iterator - json_reverse_iterator operator+(difference_type i) const - { - return static_cast(base_iterator::operator+(i)); - } - - /// subtract from iterator - json_reverse_iterator operator-(difference_type i) const - { - return static_cast(base_iterator::operator-(i)); - } - - /// return difference - difference_type operator-(const json_reverse_iterator& other) const - { - return base_iterator(*this) - base_iterator(other); - } - - /// access to successor - reference operator[](difference_type n) const - { - return *(this->operator+(n)); - } - - /// return the key of an object iterator - auto key() const -> decltype(std::declval().key()) - { - auto it = --this->base(); - return it.key(); - } - - /// return the value of an iterator - reference value() const - { - auto it = --this->base(); - return it.operator * (); - } -}; -} // namespace detail -} // namespace nlohmann - -// #include - -// #include - - -#include // all_of -#include // isdigit -#include // max -#include // accumulate -#include // string -#include // move -#include // vector - -// #include - -// #include - -// #include - -// #include - - -namespace nlohmann -{ -template -class json_pointer -{ - // allow basic_json to access private members - NLOHMANN_BASIC_JSON_TPL_DECLARATION - friend class basic_json; - - public: - /*! - @brief create JSON pointer - - Create a JSON pointer according to the syntax described in - [Section 3 of RFC6901](https://tools.ietf.org/html/rfc6901#section-3). - - @param[in] s string representing the JSON pointer; if omitted, the empty - string is assumed which references the whole JSON value - - @throw parse_error.107 if the given JSON pointer @a s is nonempty and does - not begin with a slash (`/`); see example below - - @throw parse_error.108 if a tilde (`~`) in the given JSON pointer @a s is - not followed by `0` (representing `~`) or `1` (representing `/`); see - example below - - @liveexample{The example shows the construction several valid JSON pointers - as well as the exceptional behavior.,json_pointer} - - @since version 2.0.0 - */ - explicit json_pointer(const std::string& s = "") - : reference_tokens(split(s)) - {} - - /*! - @brief return a string representation of the JSON pointer - - @invariant For each JSON pointer `ptr`, it holds: - @code {.cpp} - ptr == json_pointer(ptr.to_string()); - @endcode - - @return a string representation of the JSON pointer - - @liveexample{The example shows the result of `to_string`.,json_pointer__to_string} - - @since version 2.0.0 - */ - std::string to_string() const - { - return std::accumulate(reference_tokens.begin(), reference_tokens.end(), - std::string{}, - [](const std::string & a, const std::string & b) - { - return a + "/" + detail::escape(b); - }); - } - - /// @copydoc to_string() - operator std::string() const - { - return to_string(); - } - - /*! - @brief append another JSON pointer at the end of this JSON pointer - - @param[in] ptr JSON pointer to append - @return JSON pointer with @a ptr appended - - @liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add} - - @complexity Linear in the length of @a ptr. - - @sa see @ref operator/=(std::string) to append a reference token - @sa see @ref operator/=(std::size_t) to append an array index - @sa see @ref operator/(const json_pointer&, const json_pointer&) for a binary operator - - @since version 3.6.0 - */ - json_pointer& operator/=(const json_pointer& ptr) - { - reference_tokens.insert(reference_tokens.end(), - ptr.reference_tokens.begin(), - ptr.reference_tokens.end()); - return *this; - } - - /*! - @brief append an unescaped reference token at the end of this JSON pointer - - @param[in] token reference token to append - @return JSON pointer with @a token appended without escaping @a token - - @liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add} - - @complexity Amortized constant. - - @sa see @ref operator/=(const json_pointer&) to append a JSON pointer - @sa see @ref operator/=(std::size_t) to append an array index - @sa see @ref operator/(const json_pointer&, std::size_t) for a binary operator - - @since version 3.6.0 - */ - json_pointer& operator/=(std::string token) - { - push_back(std::move(token)); - return *this; - } - - /*! - @brief append an array index at the end of this JSON pointer - - @param[in] array_idx array index to append - @return JSON pointer with @a array_idx appended - - @liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add} - - @complexity Amortized constant. - - @sa see @ref operator/=(const json_pointer&) to append a JSON pointer - @sa see @ref operator/=(std::string) to append a reference token - @sa see @ref operator/(const json_pointer&, std::string) for a binary operator - - @since version 3.6.0 - */ - json_pointer& operator/=(std::size_t array_idx) - { - return *this /= std::to_string(array_idx); - } - - /*! - @brief create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer - - @param[in] lhs JSON pointer - @param[in] rhs JSON pointer - @return a new JSON pointer with @a rhs appended to @a lhs - - @liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary} - - @complexity Linear in the length of @a lhs and @a rhs. - - @sa see @ref operator/=(const json_pointer&) to append a JSON pointer - - @since version 3.6.0 - */ - friend json_pointer operator/(const json_pointer& lhs, - const json_pointer& rhs) - { - return json_pointer(lhs) /= rhs; - } - - /*! - @brief create a new JSON pointer by appending the unescaped token at the end of the JSON pointer - - @param[in] ptr JSON pointer - @param[in] token reference token - @return a new JSON pointer with unescaped @a token appended to @a ptr - - @liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary} - - @complexity Linear in the length of @a ptr. - - @sa see @ref operator/=(std::string) to append a reference token - - @since version 3.6.0 - */ - friend json_pointer operator/(const json_pointer& ptr, std::string token) // NOLINT(performance-unnecessary-value-param) - { - return json_pointer(ptr) /= std::move(token); - } - - /*! - @brief create a new JSON pointer by appending the array-index-token at the end of the JSON pointer - - @param[in] ptr JSON pointer - @param[in] array_idx array index - @return a new JSON pointer with @a array_idx appended to @a ptr - - @liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary} - - @complexity Linear in the length of @a ptr. - - @sa see @ref operator/=(std::size_t) to append an array index - - @since version 3.6.0 - */ - friend json_pointer operator/(const json_pointer& ptr, std::size_t array_idx) - { - return json_pointer(ptr) /= array_idx; - } - - /*! - @brief returns the parent of this JSON pointer - - @return parent of this JSON pointer; in case this JSON pointer is the root, - the root itself is returned - - @complexity Linear in the length of the JSON pointer. - - @liveexample{The example shows the result of `parent_pointer` for different - JSON Pointers.,json_pointer__parent_pointer} - - @since version 3.6.0 - */ - json_pointer parent_pointer() const - { - if (empty()) - { - return *this; - } - - json_pointer res = *this; - res.pop_back(); - return res; - } - - /*! - @brief remove last reference token - - @pre not `empty()` - - @liveexample{The example shows the usage of `pop_back`.,json_pointer__pop_back} - - @complexity Constant. - - @throw out_of_range.405 if JSON pointer has no parent - - @since version 3.6.0 - */ - void pop_back() - { - if (JSON_HEDLEY_UNLIKELY(empty())) - { - JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent", BasicJsonType())); - } - - reference_tokens.pop_back(); - } - - /*! - @brief return last reference token - - @pre not `empty()` - @return last reference token - - @liveexample{The example shows the usage of `back`.,json_pointer__back} - - @complexity Constant. - - @throw out_of_range.405 if JSON pointer has no parent - - @since version 3.6.0 - */ - const std::string& back() const - { - if (JSON_HEDLEY_UNLIKELY(empty())) - { - JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent", BasicJsonType())); - } - - return reference_tokens.back(); - } - - /*! - @brief append an unescaped token at the end of the reference pointer - - @param[in] token token to add - - @complexity Amortized constant. - - @liveexample{The example shows the result of `push_back` for different - JSON Pointers.,json_pointer__push_back} - - @since version 3.6.0 - */ - void push_back(const std::string& token) - { - reference_tokens.push_back(token); - } - - /// @copydoc push_back(const std::string&) - void push_back(std::string&& token) - { - reference_tokens.push_back(std::move(token)); - } - - /*! - @brief return whether pointer points to the root document - - @return true iff the JSON pointer points to the root document - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @liveexample{The example shows the result of `empty` for different JSON - Pointers.,json_pointer__empty} - - @since version 3.6.0 - */ - bool empty() const noexcept - { - return reference_tokens.empty(); - } - - private: - /*! - @param[in] s reference token to be converted into an array index - - @return integer representation of @a s - - @throw parse_error.106 if an array index begins with '0' - @throw parse_error.109 if an array index begins not with a digit - @throw out_of_range.404 if string @a s could not be converted to an integer - @throw out_of_range.410 if an array index exceeds size_type - */ - static typename BasicJsonType::size_type array_index(const std::string& s) - { - using size_type = typename BasicJsonType::size_type; - - // error condition (cf. RFC 6901, Sect. 4) - if (JSON_HEDLEY_UNLIKELY(s.size() > 1 && s[0] == '0')) - { - JSON_THROW(detail::parse_error::create(106, 0, "array index '" + s + "' must not begin with '0'", BasicJsonType())); - } - - // error condition (cf. RFC 6901, Sect. 4) - if (JSON_HEDLEY_UNLIKELY(s.size() > 1 && !(s[0] >= '1' && s[0] <= '9'))) - { - JSON_THROW(detail::parse_error::create(109, 0, "array index '" + s + "' is not a number", BasicJsonType())); - } - - std::size_t processed_chars = 0; - unsigned long long res = 0; // NOLINT(runtime/int) - JSON_TRY - { - res = std::stoull(s, &processed_chars); - } - JSON_CATCH(std::out_of_range&) - { - JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + s + "'", BasicJsonType())); - } - - // check if the string was completely read - if (JSON_HEDLEY_UNLIKELY(processed_chars != s.size())) - { - JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + s + "'", BasicJsonType())); - } - - // only triggered on special platforms (like 32bit), see also - // https://github.com/nlohmann/json/pull/2203 - if (res >= static_cast((std::numeric_limits::max)())) // NOLINT(runtime/int) - { - JSON_THROW(detail::out_of_range::create(410, "array index " + s + " exceeds size_type", BasicJsonType())); // LCOV_EXCL_LINE - } - - return static_cast(res); - } - - JSON_PRIVATE_UNLESS_TESTED: - json_pointer top() const - { - if (JSON_HEDLEY_UNLIKELY(empty())) - { - JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent", BasicJsonType())); - } - - json_pointer result = *this; - result.reference_tokens = {reference_tokens[0]}; - return result; - } - - private: - /*! - @brief create and return a reference to the pointed to value - - @complexity Linear in the number of reference tokens. - - @throw parse_error.109 if array index is not a number - @throw type_error.313 if value cannot be unflattened - */ - BasicJsonType& get_and_create(BasicJsonType& j) const - { - auto* result = &j; - - // in case no reference tokens exist, return a reference to the JSON value - // j which will be overwritten by a primitive value - for (const auto& reference_token : reference_tokens) - { - switch (result->type()) - { - case detail::value_t::null: - { - if (reference_token == "0") - { - // start a new array if reference token is 0 - result = &result->operator[](0); - } - else - { - // start a new object otherwise - result = &result->operator[](reference_token); - } - break; - } - - case detail::value_t::object: - { - // create an entry in the object - result = &result->operator[](reference_token); - break; - } - - case detail::value_t::array: - { - // create an entry in the array - result = &result->operator[](array_index(reference_token)); - break; - } - - /* - The following code is only reached if there exists a reference - token _and_ the current value is primitive. In this case, we have - an error situation, because primitive values may only occur as - single value; that is, with an empty list of reference tokens. - */ - case detail::value_t::string: - case detail::value_t::boolean: - case detail::value_t::number_integer: - case detail::value_t::number_unsigned: - case detail::value_t::number_float: - case detail::value_t::binary: - case detail::value_t::discarded: - default: - JSON_THROW(detail::type_error::create(313, "invalid value to unflatten", j)); - } - } - - return *result; - } - - /*! - @brief return a reference to the pointed to value - - @note This version does not throw if a value is not present, but tries to - create nested values instead. For instance, calling this function - with pointer `"/this/that"` on a null value is equivalent to calling - `operator[]("this").operator[]("that")` on that value, effectively - changing the null value to an object. - - @param[in] ptr a JSON value - - @return reference to the JSON value pointed to by the JSON pointer - - @complexity Linear in the length of the JSON pointer. - - @throw parse_error.106 if an array index begins with '0' - @throw parse_error.109 if an array index was not a number - @throw out_of_range.404 if the JSON pointer can not be resolved - */ - BasicJsonType& get_unchecked(BasicJsonType* ptr) const - { - for (const auto& reference_token : reference_tokens) - { - // convert null values to arrays or objects before continuing - if (ptr->is_null()) - { - // check if reference token is a number - const bool nums = - std::all_of(reference_token.begin(), reference_token.end(), - [](const unsigned char x) - { - return std::isdigit(x); - }); - - // change value to array for numbers or "-" or to object otherwise - *ptr = (nums || reference_token == "-") - ? detail::value_t::array - : detail::value_t::object; - } - - switch (ptr->type()) - { - case detail::value_t::object: - { - // use unchecked object access - ptr = &ptr->operator[](reference_token); - break; - } - - case detail::value_t::array: - { - if (reference_token == "-") - { - // explicitly treat "-" as index beyond the end - ptr = &ptr->operator[](ptr->m_value.array->size()); - } - else - { - // convert array index to number; unchecked access - ptr = &ptr->operator[](array_index(reference_token)); - } - break; - } - - case detail::value_t::null: - case detail::value_t::string: - case detail::value_t::boolean: - case detail::value_t::number_integer: - case detail::value_t::number_unsigned: - case detail::value_t::number_float: - case detail::value_t::binary: - case detail::value_t::discarded: - default: - JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'", *ptr)); - } - } - - return *ptr; - } - - /*! - @throw parse_error.106 if an array index begins with '0' - @throw parse_error.109 if an array index was not a number - @throw out_of_range.402 if the array index '-' is used - @throw out_of_range.404 if the JSON pointer can not be resolved - */ - BasicJsonType& get_checked(BasicJsonType* ptr) const - { - for (const auto& reference_token : reference_tokens) - { - switch (ptr->type()) - { - case detail::value_t::object: - { - // note: at performs range check - ptr = &ptr->at(reference_token); - break; - } - - case detail::value_t::array: - { - if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) - { - // "-" always fails the range check - JSON_THROW(detail::out_of_range::create(402, - "array index '-' (" + std::to_string(ptr->m_value.array->size()) + - ") is out of range", *ptr)); - } - - // note: at performs range check - ptr = &ptr->at(array_index(reference_token)); - break; - } - - case detail::value_t::null: - case detail::value_t::string: - case detail::value_t::boolean: - case detail::value_t::number_integer: - case detail::value_t::number_unsigned: - case detail::value_t::number_float: - case detail::value_t::binary: - case detail::value_t::discarded: - default: - JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'", *ptr)); - } - } - - return *ptr; - } - - /*! - @brief return a const reference to the pointed to value - - @param[in] ptr a JSON value - - @return const reference to the JSON value pointed to by the JSON - pointer - - @throw parse_error.106 if an array index begins with '0' - @throw parse_error.109 if an array index was not a number - @throw out_of_range.402 if the array index '-' is used - @throw out_of_range.404 if the JSON pointer can not be resolved - */ - const BasicJsonType& get_unchecked(const BasicJsonType* ptr) const - { - for (const auto& reference_token : reference_tokens) - { - switch (ptr->type()) - { - case detail::value_t::object: - { - // use unchecked object access - ptr = &ptr->operator[](reference_token); - break; - } - - case detail::value_t::array: - { - if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) - { - // "-" cannot be used for const access - JSON_THROW(detail::out_of_range::create(402, "array index '-' (" + std::to_string(ptr->m_value.array->size()) + ") is out of range", *ptr)); - } - - // use unchecked array access - ptr = &ptr->operator[](array_index(reference_token)); - break; - } - - case detail::value_t::null: - case detail::value_t::string: - case detail::value_t::boolean: - case detail::value_t::number_integer: - case detail::value_t::number_unsigned: - case detail::value_t::number_float: - case detail::value_t::binary: - case detail::value_t::discarded: - default: - JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'", *ptr)); - } - } - - return *ptr; - } - - /*! - @throw parse_error.106 if an array index begins with '0' - @throw parse_error.109 if an array index was not a number - @throw out_of_range.402 if the array index '-' is used - @throw out_of_range.404 if the JSON pointer can not be resolved - */ - const BasicJsonType& get_checked(const BasicJsonType* ptr) const - { - for (const auto& reference_token : reference_tokens) - { - switch (ptr->type()) - { - case detail::value_t::object: - { - // note: at performs range check - ptr = &ptr->at(reference_token); - break; - } - - case detail::value_t::array: - { - if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) - { - // "-" always fails the range check - JSON_THROW(detail::out_of_range::create(402, - "array index '-' (" + std::to_string(ptr->m_value.array->size()) + - ") is out of range", *ptr)); - } - - // note: at performs range check - ptr = &ptr->at(array_index(reference_token)); - break; - } - - case detail::value_t::null: - case detail::value_t::string: - case detail::value_t::boolean: - case detail::value_t::number_integer: - case detail::value_t::number_unsigned: - case detail::value_t::number_float: - case detail::value_t::binary: - case detail::value_t::discarded: - default: - JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'", *ptr)); - } - } - - return *ptr; - } - - /*! - @throw parse_error.106 if an array index begins with '0' - @throw parse_error.109 if an array index was not a number - */ - bool contains(const BasicJsonType* ptr) const - { - for (const auto& reference_token : reference_tokens) - { - switch (ptr->type()) - { - case detail::value_t::object: - { - if (!ptr->contains(reference_token)) - { - // we did not find the key in the object - return false; - } - - ptr = &ptr->operator[](reference_token); - break; - } - - case detail::value_t::array: - { - if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) - { - // "-" always fails the range check - return false; - } - if (JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !("0" <= reference_token && reference_token <= "9"))) - { - // invalid char - return false; - } - if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1)) - { - if (JSON_HEDLEY_UNLIKELY(!('1' <= reference_token[0] && reference_token[0] <= '9'))) - { - // first char should be between '1' and '9' - return false; - } - for (std::size_t i = 1; i < reference_token.size(); i++) - { - if (JSON_HEDLEY_UNLIKELY(!('0' <= reference_token[i] && reference_token[i] <= '9'))) - { - // other char should be between '0' and '9' - return false; - } - } - } - - const auto idx = array_index(reference_token); - if (idx >= ptr->size()) - { - // index out of range - return false; - } - - ptr = &ptr->operator[](idx); - break; - } - - case detail::value_t::null: - case detail::value_t::string: - case detail::value_t::boolean: - case detail::value_t::number_integer: - case detail::value_t::number_unsigned: - case detail::value_t::number_float: - case detail::value_t::binary: - case detail::value_t::discarded: - default: - { - // we do not expect primitive values if there is still a - // reference token to process - return false; - } - } - } - - // no reference token left means we found a primitive value - return true; - } - - /*! - @brief split the string input to reference tokens - - @note This function is only called by the json_pointer constructor. - All exceptions below are documented there. - - @throw parse_error.107 if the pointer is not empty or begins with '/' - @throw parse_error.108 if character '~' is not followed by '0' or '1' - */ - static std::vector split(const std::string& reference_string) - { - std::vector result; - - // special case: empty reference string -> no reference tokens - if (reference_string.empty()) - { - return result; - } - - // check if nonempty reference string begins with slash - if (JSON_HEDLEY_UNLIKELY(reference_string[0] != '/')) - { - JSON_THROW(detail::parse_error::create(107, 1, "JSON pointer must be empty or begin with '/' - was: '" + reference_string + "'", BasicJsonType())); - } - - // extract the reference tokens: - // - slash: position of the last read slash (or end of string) - // - start: position after the previous slash - for ( - // search for the first slash after the first character - std::size_t slash = reference_string.find_first_of('/', 1), - // set the beginning of the first reference token - start = 1; - // we can stop if start == 0 (if slash == std::string::npos) - start != 0; - // set the beginning of the next reference token - // (will eventually be 0 if slash == std::string::npos) - start = (slash == std::string::npos) ? 0 : slash + 1, - // find next slash - slash = reference_string.find_first_of('/', start)) - { - // use the text between the beginning of the reference token - // (start) and the last slash (slash). - auto reference_token = reference_string.substr(start, slash - start); - - // check reference tokens are properly escaped - for (std::size_t pos = reference_token.find_first_of('~'); - pos != std::string::npos; - pos = reference_token.find_first_of('~', pos + 1)) - { - JSON_ASSERT(reference_token[pos] == '~'); - - // ~ must be followed by 0 or 1 - if (JSON_HEDLEY_UNLIKELY(pos == reference_token.size() - 1 || - (reference_token[pos + 1] != '0' && - reference_token[pos + 1] != '1'))) - { - JSON_THROW(detail::parse_error::create(108, 0, "escape character '~' must be followed with '0' or '1'", BasicJsonType())); - } - } - - // finally, store the reference token - detail::unescape(reference_token); - result.push_back(reference_token); - } - - return result; - } - - private: - /*! - @param[in] reference_string the reference string to the current value - @param[in] value the value to consider - @param[in,out] result the result object to insert values to - - @note Empty objects or arrays are flattened to `null`. - */ - static void flatten(const std::string& reference_string, - const BasicJsonType& value, - BasicJsonType& result) - { - switch (value.type()) - { - case detail::value_t::array: - { - if (value.m_value.array->empty()) - { - // flatten empty array as null - result[reference_string] = nullptr; - } - else - { - // iterate array and use index as reference string - for (std::size_t i = 0; i < value.m_value.array->size(); ++i) - { - flatten(reference_string + "/" + std::to_string(i), - value.m_value.array->operator[](i), result); - } - } - break; - } - - case detail::value_t::object: - { - if (value.m_value.object->empty()) - { - // flatten empty object as null - result[reference_string] = nullptr; - } - else - { - // iterate object and use keys as reference string - for (const auto& element : *value.m_value.object) - { - flatten(reference_string + "/" + detail::escape(element.first), element.second, result); - } - } - break; - } - - case detail::value_t::null: - case detail::value_t::string: - case detail::value_t::boolean: - case detail::value_t::number_integer: - case detail::value_t::number_unsigned: - case detail::value_t::number_float: - case detail::value_t::binary: - case detail::value_t::discarded: - default: - { - // add primitive value with its reference string - result[reference_string] = value; - break; - } - } - } - - /*! - @param[in] value flattened JSON - - @return unflattened JSON - - @throw parse_error.109 if array index is not a number - @throw type_error.314 if value is not an object - @throw type_error.315 if object values are not primitive - @throw type_error.313 if value cannot be unflattened - */ - static BasicJsonType - unflatten(const BasicJsonType& value) - { - if (JSON_HEDLEY_UNLIKELY(!value.is_object())) - { - JSON_THROW(detail::type_error::create(314, "only objects can be unflattened", value)); - } - - BasicJsonType result; - - // iterate the JSON object values - for (const auto& element : *value.m_value.object) - { - if (JSON_HEDLEY_UNLIKELY(!element.second.is_primitive())) - { - JSON_THROW(detail::type_error::create(315, "values in object must be primitive", element.second)); - } - - // assign value to reference pointed to by JSON pointer; Note that if - // the JSON pointer is "" (i.e., points to the whole value), function - // get_and_create returns a reference to result itself. An assignment - // will then create a primitive value. - json_pointer(element.first).get_and_create(result) = element.second; - } - - return result; - } - - /*! - @brief compares two JSON pointers for equality - - @param[in] lhs JSON pointer to compare - @param[in] rhs JSON pointer to compare - @return whether @a lhs is equal to @a rhs - - @complexity Linear in the length of the JSON pointer - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - */ - friend bool operator==(json_pointer const& lhs, - json_pointer const& rhs) noexcept - { - return lhs.reference_tokens == rhs.reference_tokens; - } - - /*! - @brief compares two JSON pointers for inequality - - @param[in] lhs JSON pointer to compare - @param[in] rhs JSON pointer to compare - @return whether @a lhs is not equal @a rhs - - @complexity Linear in the length of the JSON pointer - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - */ - friend bool operator!=(json_pointer const& lhs, - json_pointer const& rhs) noexcept - { - return !(lhs == rhs); - } - - /// the reference tokens - std::vector reference_tokens; -}; -} // namespace nlohmann - -// #include - - -#include -#include - -// #include - - -namespace nlohmann -{ -namespace detail -{ -template -class json_ref -{ - public: - using value_type = BasicJsonType; - - json_ref(value_type&& value) - : owned_value(std::move(value)) - {} - - json_ref(const value_type& value) - : value_ref(&value) - {} - - json_ref(std::initializer_list init) - : owned_value(init) - {} - - template < - class... Args, - enable_if_t::value, int> = 0 > - json_ref(Args && ... args) - : owned_value(std::forward(args)...) - {} - - // class should be movable only - json_ref(json_ref&&) noexcept = default; - json_ref(const json_ref&) = delete; - json_ref& operator=(const json_ref&) = delete; - json_ref& operator=(json_ref&&) = delete; - ~json_ref() = default; - - value_type moved_or_copied() const - { - if (value_ref == nullptr) - { - return std::move(owned_value); - } - return *value_ref; - } - - value_type const& operator*() const - { - return value_ref ? *value_ref : owned_value; - } - - value_type const* operator->() const - { - return &** this; - } - - private: - mutable value_type owned_value = nullptr; - value_type const* value_ref = nullptr; -}; -} // namespace detail -} // namespace nlohmann - -// #include - -// #include - -// #include - -// #include - -// #include - - -#include // reverse -#include // array -#include // isnan, isinf -#include // uint8_t, uint16_t, uint32_t, uint64_t -#include // memcpy -#include // numeric_limits -#include // string -#include // move - -// #include - -// #include - -// #include - - -#include // copy -#include // size_t -#include // back_inserter -#include // shared_ptr, make_shared -#include // basic_string -#include // vector - -#ifndef JSON_NO_IO - #include // streamsize - #include // basic_ostream -#endif // JSON_NO_IO - -// #include - - -namespace nlohmann -{ -namespace detail -{ -/// abstract output adapter interface -template struct output_adapter_protocol -{ - virtual void write_character(CharType c) = 0; - virtual void write_characters(const CharType* s, std::size_t length) = 0; - virtual ~output_adapter_protocol() = default; - - output_adapter_protocol() = default; - output_adapter_protocol(const output_adapter_protocol&) = default; - output_adapter_protocol(output_adapter_protocol&&) noexcept = default; - output_adapter_protocol& operator=(const output_adapter_protocol&) = default; - output_adapter_protocol& operator=(output_adapter_protocol&&) noexcept = default; -}; - -/// a type to simplify interfaces -template -using output_adapter_t = std::shared_ptr>; - -/// output adapter for byte vectors -template> -class output_vector_adapter : public output_adapter_protocol -{ - public: - explicit output_vector_adapter(std::vector& vec) noexcept - : v(vec) - {} - - void write_character(CharType c) override - { - v.push_back(c); - } - - JSON_HEDLEY_NON_NULL(2) - void write_characters(const CharType* s, std::size_t length) override - { - std::copy(s, s + length, std::back_inserter(v)); - } - - private: - std::vector& v; -}; - -#ifndef JSON_NO_IO -/// output adapter for output streams -template -class output_stream_adapter : public output_adapter_protocol -{ - public: - explicit output_stream_adapter(std::basic_ostream& s) noexcept - : stream(s) - {} - - void write_character(CharType c) override - { - stream.put(c); - } - - JSON_HEDLEY_NON_NULL(2) - void write_characters(const CharType* s, std::size_t length) override - { - stream.write(s, static_cast(length)); - } - - private: - std::basic_ostream& stream; -}; -#endif // JSON_NO_IO - -/// output adapter for basic_string -template> -class output_string_adapter : public output_adapter_protocol -{ - public: - explicit output_string_adapter(StringType& s) noexcept - : str(s) - {} - - void write_character(CharType c) override - { - str.push_back(c); - } - - JSON_HEDLEY_NON_NULL(2) - void write_characters(const CharType* s, std::size_t length) override - { - str.append(s, length); - } - - private: - StringType& str; -}; - -template> -class output_adapter -{ - public: - template> - output_adapter(std::vector& vec) - : oa(std::make_shared>(vec)) {} - -#ifndef JSON_NO_IO - output_adapter(std::basic_ostream& s) - : oa(std::make_shared>(s)) {} -#endif // JSON_NO_IO - - output_adapter(StringType& s) - : oa(std::make_shared>(s)) {} - - operator output_adapter_t() - { - return oa; - } - - private: - output_adapter_t oa = nullptr; -}; -} // namespace detail -} // namespace nlohmann - - -namespace nlohmann -{ -namespace detail -{ -/////////////////// -// binary writer // -/////////////////// - -/*! -@brief serialization to CBOR and MessagePack values -*/ -template -class binary_writer -{ - using string_t = typename BasicJsonType::string_t; - using binary_t = typename BasicJsonType::binary_t; - using number_float_t = typename BasicJsonType::number_float_t; - - public: - /*! - @brief create a binary writer - - @param[in] adapter output adapter to write to - */ - explicit binary_writer(output_adapter_t adapter) : oa(std::move(adapter)) - { - JSON_ASSERT(oa); - } - - /*! - @param[in] j JSON value to serialize - @pre j.type() == value_t::object - */ - void write_bson(const BasicJsonType& j) - { - switch (j.type()) - { - case value_t::object: - { - write_bson_object(*j.m_value.object); - break; - } - - case value_t::null: - case value_t::array: - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - { - JSON_THROW(type_error::create(317, "to serialize to BSON, top-level type must be object, but is " + std::string(j.type_name()), j)); - } - } - } - - /*! - @param[in] j JSON value to serialize - */ - void write_cbor(const BasicJsonType& j) - { - switch (j.type()) - { - case value_t::null: - { - oa->write_character(to_char_type(0xF6)); - break; - } - - case value_t::boolean: - { - oa->write_character(j.m_value.boolean - ? to_char_type(0xF5) - : to_char_type(0xF4)); - break; - } - - case value_t::number_integer: - { - if (j.m_value.number_integer >= 0) - { - // CBOR does not differentiate between positive signed - // integers and unsigned integers. Therefore, we used the - // code from the value_t::number_unsigned case here. - if (j.m_value.number_integer <= 0x17) - { - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_integer <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x18)); - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_integer <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x19)); - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_integer <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x1A)); - write_number(static_cast(j.m_value.number_integer)); - } - else - { - oa->write_character(to_char_type(0x1B)); - write_number(static_cast(j.m_value.number_integer)); - } - } - else - { - // The conversions below encode the sign in the first - // byte, and the value is converted to a positive number. - const auto positive_number = -1 - j.m_value.number_integer; - if (j.m_value.number_integer >= -24) - { - write_number(static_cast(0x20 + positive_number)); - } - else if (positive_number <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x38)); - write_number(static_cast(positive_number)); - } - else if (positive_number <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x39)); - write_number(static_cast(positive_number)); - } - else if (positive_number <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x3A)); - write_number(static_cast(positive_number)); - } - else - { - oa->write_character(to_char_type(0x3B)); - write_number(static_cast(positive_number)); - } - } - break; - } - - case value_t::number_unsigned: - { - if (j.m_value.number_unsigned <= 0x17) - { - write_number(static_cast(j.m_value.number_unsigned)); - } - else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x18)); - write_number(static_cast(j.m_value.number_unsigned)); - } - else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x19)); - write_number(static_cast(j.m_value.number_unsigned)); - } - else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x1A)); - write_number(static_cast(j.m_value.number_unsigned)); - } - else - { - oa->write_character(to_char_type(0x1B)); - write_number(static_cast(j.m_value.number_unsigned)); - } - break; - } - - case value_t::number_float: - { - if (std::isnan(j.m_value.number_float)) - { - // NaN is 0xf97e00 in CBOR - oa->write_character(to_char_type(0xF9)); - oa->write_character(to_char_type(0x7E)); - oa->write_character(to_char_type(0x00)); - } - else if (std::isinf(j.m_value.number_float)) - { - // Infinity is 0xf97c00, -Infinity is 0xf9fc00 - oa->write_character(to_char_type(0xf9)); - oa->write_character(j.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC)); - oa->write_character(to_char_type(0x00)); - } - else - { - write_compact_float(j.m_value.number_float, detail::input_format_t::cbor); - } - break; - } - - case value_t::string: - { - // step 1: write control byte and the string length - const auto N = j.m_value.string->size(); - if (N <= 0x17) - { - write_number(static_cast(0x60 + N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x78)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x79)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x7A)); - write_number(static_cast(N)); - } - // LCOV_EXCL_START - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x7B)); - write_number(static_cast(N)); - } - // LCOV_EXCL_STOP - - // step 2: write the string - oa->write_characters( - reinterpret_cast(j.m_value.string->c_str()), - j.m_value.string->size()); - break; - } - - case value_t::array: - { - // step 1: write control byte and the array size - const auto N = j.m_value.array->size(); - if (N <= 0x17) - { - write_number(static_cast(0x80 + N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x98)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x99)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x9A)); - write_number(static_cast(N)); - } - // LCOV_EXCL_START - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x9B)); - write_number(static_cast(N)); - } - // LCOV_EXCL_STOP - - // step 2: write each element - for (const auto& el : *j.m_value.array) - { - write_cbor(el); - } - break; - } - - case value_t::binary: - { - if (j.m_value.binary->has_subtype()) - { - if (j.m_value.binary->subtype() <= (std::numeric_limits::max)()) - { - write_number(static_cast(0xd8)); - write_number(static_cast(j.m_value.binary->subtype())); - } - else if (j.m_value.binary->subtype() <= (std::numeric_limits::max)()) - { - write_number(static_cast(0xd9)); - write_number(static_cast(j.m_value.binary->subtype())); - } - else if (j.m_value.binary->subtype() <= (std::numeric_limits::max)()) - { - write_number(static_cast(0xda)); - write_number(static_cast(j.m_value.binary->subtype())); - } - else if (j.m_value.binary->subtype() <= (std::numeric_limits::max)()) - { - write_number(static_cast(0xdb)); - write_number(static_cast(j.m_value.binary->subtype())); - } - } - - // step 1: write control byte and the binary array size - const auto N = j.m_value.binary->size(); - if (N <= 0x17) - { - write_number(static_cast(0x40 + N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x58)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x59)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x5A)); - write_number(static_cast(N)); - } - // LCOV_EXCL_START - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x5B)); - write_number(static_cast(N)); - } - // LCOV_EXCL_STOP - - // step 2: write each element - oa->write_characters( - reinterpret_cast(j.m_value.binary->data()), - N); - - break; - } - - case value_t::object: - { - // step 1: write control byte and the object size - const auto N = j.m_value.object->size(); - if (N <= 0x17) - { - write_number(static_cast(0xA0 + N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0xB8)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0xB9)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0xBA)); - write_number(static_cast(N)); - } - // LCOV_EXCL_START - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0xBB)); - write_number(static_cast(N)); - } - // LCOV_EXCL_STOP - - // step 2: write each element - for (const auto& el : *j.m_value.object) - { - write_cbor(el.first); - write_cbor(el.second); - } - break; - } - - case value_t::discarded: - default: - break; - } - } - - /*! - @param[in] j JSON value to serialize - */ - void write_msgpack(const BasicJsonType& j) - { - switch (j.type()) - { - case value_t::null: // nil - { - oa->write_character(to_char_type(0xC0)); - break; - } - - case value_t::boolean: // true and false - { - oa->write_character(j.m_value.boolean - ? to_char_type(0xC3) - : to_char_type(0xC2)); - break; - } - - case value_t::number_integer: - { - if (j.m_value.number_integer >= 0) - { - // MessagePack does not differentiate between positive - // signed integers and unsigned integers. Therefore, we used - // the code from the value_t::number_unsigned case here. - if (j.m_value.number_unsigned < 128) - { - // positive fixnum - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) - { - // uint 8 - oa->write_character(to_char_type(0xCC)); - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) - { - // uint 16 - oa->write_character(to_char_type(0xCD)); - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) - { - // uint 32 - oa->write_character(to_char_type(0xCE)); - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) - { - // uint 64 - oa->write_character(to_char_type(0xCF)); - write_number(static_cast(j.m_value.number_integer)); - } - } - else - { - if (j.m_value.number_integer >= -32) - { - // negative fixnum - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_integer >= (std::numeric_limits::min)() && - j.m_value.number_integer <= (std::numeric_limits::max)()) - { - // int 8 - oa->write_character(to_char_type(0xD0)); - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_integer >= (std::numeric_limits::min)() && - j.m_value.number_integer <= (std::numeric_limits::max)()) - { - // int 16 - oa->write_character(to_char_type(0xD1)); - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_integer >= (std::numeric_limits::min)() && - j.m_value.number_integer <= (std::numeric_limits::max)()) - { - // int 32 - oa->write_character(to_char_type(0xD2)); - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_integer >= (std::numeric_limits::min)() && - j.m_value.number_integer <= (std::numeric_limits::max)()) - { - // int 64 - oa->write_character(to_char_type(0xD3)); - write_number(static_cast(j.m_value.number_integer)); - } - } - break; - } - - case value_t::number_unsigned: - { - if (j.m_value.number_unsigned < 128) - { - // positive fixnum - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) - { - // uint 8 - oa->write_character(to_char_type(0xCC)); - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) - { - // uint 16 - oa->write_character(to_char_type(0xCD)); - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) - { - // uint 32 - oa->write_character(to_char_type(0xCE)); - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) - { - // uint 64 - oa->write_character(to_char_type(0xCF)); - write_number(static_cast(j.m_value.number_integer)); - } - break; - } - - case value_t::number_float: - { - write_compact_float(j.m_value.number_float, detail::input_format_t::msgpack); - break; - } - - case value_t::string: - { - // step 1: write control byte and the string length - const auto N = j.m_value.string->size(); - if (N <= 31) - { - // fixstr - write_number(static_cast(0xA0 | N)); - } - else if (N <= (std::numeric_limits::max)()) - { - // str 8 - oa->write_character(to_char_type(0xD9)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - // str 16 - oa->write_character(to_char_type(0xDA)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - // str 32 - oa->write_character(to_char_type(0xDB)); - write_number(static_cast(N)); - } - - // step 2: write the string - oa->write_characters( - reinterpret_cast(j.m_value.string->c_str()), - j.m_value.string->size()); - break; - } - - case value_t::array: - { - // step 1: write control byte and the array size - const auto N = j.m_value.array->size(); - if (N <= 15) - { - // fixarray - write_number(static_cast(0x90 | N)); - } - else if (N <= (std::numeric_limits::max)()) - { - // array 16 - oa->write_character(to_char_type(0xDC)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - // array 32 - oa->write_character(to_char_type(0xDD)); - write_number(static_cast(N)); - } - - // step 2: write each element - for (const auto& el : *j.m_value.array) - { - write_msgpack(el); - } - break; - } - - case value_t::binary: - { - // step 0: determine if the binary type has a set subtype to - // determine whether or not to use the ext or fixext types - const bool use_ext = j.m_value.binary->has_subtype(); - - // step 1: write control byte and the byte string length - const auto N = j.m_value.binary->size(); - if (N <= (std::numeric_limits::max)()) - { - std::uint8_t output_type{}; - bool fixed = true; - if (use_ext) - { - switch (N) - { - case 1: - output_type = 0xD4; // fixext 1 - break; - case 2: - output_type = 0xD5; // fixext 2 - break; - case 4: - output_type = 0xD6; // fixext 4 - break; - case 8: - output_type = 0xD7; // fixext 8 - break; - case 16: - output_type = 0xD8; // fixext 16 - break; - default: - output_type = 0xC7; // ext 8 - fixed = false; - break; - } - - } - else - { - output_type = 0xC4; // bin 8 - fixed = false; - } - - oa->write_character(to_char_type(output_type)); - if (!fixed) - { - write_number(static_cast(N)); - } - } - else if (N <= (std::numeric_limits::max)()) - { - std::uint8_t output_type = use_ext - ? 0xC8 // ext 16 - : 0xC5; // bin 16 - - oa->write_character(to_char_type(output_type)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - std::uint8_t output_type = use_ext - ? 0xC9 // ext 32 - : 0xC6; // bin 32 - - oa->write_character(to_char_type(output_type)); - write_number(static_cast(N)); - } - - // step 1.5: if this is an ext type, write the subtype - if (use_ext) - { - write_number(static_cast(j.m_value.binary->subtype())); - } - - // step 2: write the byte string - oa->write_characters( - reinterpret_cast(j.m_value.binary->data()), - N); - - break; - } - - case value_t::object: - { - // step 1: write control byte and the object size - const auto N = j.m_value.object->size(); - if (N <= 15) - { - // fixmap - write_number(static_cast(0x80 | (N & 0xF))); - } - else if (N <= (std::numeric_limits::max)()) - { - // map 16 - oa->write_character(to_char_type(0xDE)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - // map 32 - oa->write_character(to_char_type(0xDF)); - write_number(static_cast(N)); - } - - // step 2: write each element - for (const auto& el : *j.m_value.object) - { - write_msgpack(el.first); - write_msgpack(el.second); - } - break; - } - - case value_t::discarded: - default: - break; - } - } - - /*! - @param[in] j JSON value to serialize - @param[in] use_count whether to use '#' prefixes (optimized format) - @param[in] use_type whether to use '$' prefixes (optimized format) - @param[in] add_prefix whether prefixes need to be used for this value - */ - void write_ubjson(const BasicJsonType& j, const bool use_count, - const bool use_type, const bool add_prefix = true) - { - switch (j.type()) - { - case value_t::null: - { - if (add_prefix) - { - oa->write_character(to_char_type('Z')); - } - break; - } - - case value_t::boolean: - { - if (add_prefix) - { - oa->write_character(j.m_value.boolean - ? to_char_type('T') - : to_char_type('F')); - } - break; - } - - case value_t::number_integer: - { - write_number_with_ubjson_prefix(j.m_value.number_integer, add_prefix); - break; - } - - case value_t::number_unsigned: - { - write_number_with_ubjson_prefix(j.m_value.number_unsigned, add_prefix); - break; - } - - case value_t::number_float: - { - write_number_with_ubjson_prefix(j.m_value.number_float, add_prefix); - break; - } - - case value_t::string: - { - if (add_prefix) - { - oa->write_character(to_char_type('S')); - } - write_number_with_ubjson_prefix(j.m_value.string->size(), true); - oa->write_characters( - reinterpret_cast(j.m_value.string->c_str()), - j.m_value.string->size()); - break; - } - - case value_t::array: - { - if (add_prefix) - { - oa->write_character(to_char_type('[')); - } - - bool prefix_required = true; - if (use_type && !j.m_value.array->empty()) - { - JSON_ASSERT(use_count); - const CharType first_prefix = ubjson_prefix(j.front()); - const bool same_prefix = std::all_of(j.begin() + 1, j.end(), - [this, first_prefix](const BasicJsonType & v) - { - return ubjson_prefix(v) == first_prefix; - }); - - if (same_prefix) - { - prefix_required = false; - oa->write_character(to_char_type('$')); - oa->write_character(first_prefix); - } - } - - if (use_count) - { - oa->write_character(to_char_type('#')); - write_number_with_ubjson_prefix(j.m_value.array->size(), true); - } - - for (const auto& el : *j.m_value.array) - { - write_ubjson(el, use_count, use_type, prefix_required); - } - - if (!use_count) - { - oa->write_character(to_char_type(']')); - } - - break; - } - - case value_t::binary: - { - if (add_prefix) - { - oa->write_character(to_char_type('[')); - } - - if (use_type && !j.m_value.binary->empty()) - { - JSON_ASSERT(use_count); - oa->write_character(to_char_type('$')); - oa->write_character('U'); - } - - if (use_count) - { - oa->write_character(to_char_type('#')); - write_number_with_ubjson_prefix(j.m_value.binary->size(), true); - } - - if (use_type) - { - oa->write_characters( - reinterpret_cast(j.m_value.binary->data()), - j.m_value.binary->size()); - } - else - { - for (size_t i = 0; i < j.m_value.binary->size(); ++i) - { - oa->write_character(to_char_type('U')); - oa->write_character(j.m_value.binary->data()[i]); - } - } - - if (!use_count) - { - oa->write_character(to_char_type(']')); - } - - break; - } - - case value_t::object: - { - if (add_prefix) - { - oa->write_character(to_char_type('{')); - } - - bool prefix_required = true; - if (use_type && !j.m_value.object->empty()) - { - JSON_ASSERT(use_count); - const CharType first_prefix = ubjson_prefix(j.front()); - const bool same_prefix = std::all_of(j.begin(), j.end(), - [this, first_prefix](const BasicJsonType & v) - { - return ubjson_prefix(v) == first_prefix; - }); - - if (same_prefix) - { - prefix_required = false; - oa->write_character(to_char_type('$')); - oa->write_character(first_prefix); - } - } - - if (use_count) - { - oa->write_character(to_char_type('#')); - write_number_with_ubjson_prefix(j.m_value.object->size(), true); - } - - for (const auto& el : *j.m_value.object) - { - write_number_with_ubjson_prefix(el.first.size(), true); - oa->write_characters( - reinterpret_cast(el.first.c_str()), - el.first.size()); - write_ubjson(el.second, use_count, use_type, prefix_required); - } - - if (!use_count) - { - oa->write_character(to_char_type('}')); - } - - break; - } - - case value_t::discarded: - default: - break; - } - } - - private: - ////////// - // BSON // - ////////// - - /*! - @return The size of a BSON document entry header, including the id marker - and the entry name size (and its null-terminator). - */ - static std::size_t calc_bson_entry_header_size(const string_t& name, const BasicJsonType& j) - { - const auto it = name.find(static_cast(0)); - if (JSON_HEDLEY_UNLIKELY(it != BasicJsonType::string_t::npos)) - { - JSON_THROW(out_of_range::create(409, "BSON key cannot contain code point U+0000 (at byte " + std::to_string(it) + ")", j)); - static_cast(j); - } - - return /*id*/ 1ul + name.size() + /*zero-terminator*/1u; - } - - /*! - @brief Writes the given @a element_type and @a name to the output adapter - */ - void write_bson_entry_header(const string_t& name, - const std::uint8_t element_type) - { - oa->write_character(to_char_type(element_type)); // boolean - oa->write_characters( - reinterpret_cast(name.c_str()), - name.size() + 1u); - } - - /*! - @brief Writes a BSON element with key @a name and boolean value @a value - */ - void write_bson_boolean(const string_t& name, - const bool value) - { - write_bson_entry_header(name, 0x08); - oa->write_character(value ? to_char_type(0x01) : to_char_type(0x00)); - } - - /*! - @brief Writes a BSON element with key @a name and double value @a value - */ - void write_bson_double(const string_t& name, - const double value) - { - write_bson_entry_header(name, 0x01); - write_number(value); - } - - /*! - @return The size of the BSON-encoded string in @a value - */ - static std::size_t calc_bson_string_size(const string_t& value) - { - return sizeof(std::int32_t) + value.size() + 1ul; - } - - /*! - @brief Writes a BSON element with key @a name and string value @a value - */ - void write_bson_string(const string_t& name, - const string_t& value) - { - write_bson_entry_header(name, 0x02); - - write_number(static_cast(value.size() + 1ul)); - oa->write_characters( - reinterpret_cast(value.c_str()), - value.size() + 1); - } - - /*! - @brief Writes a BSON element with key @a name and null value - */ - void write_bson_null(const string_t& name) - { - write_bson_entry_header(name, 0x0A); - } - - /*! - @return The size of the BSON-encoded integer @a value - */ - static std::size_t calc_bson_integer_size(const std::int64_t value) - { - return (std::numeric_limits::min)() <= value && value <= (std::numeric_limits::max)() - ? sizeof(std::int32_t) - : sizeof(std::int64_t); - } - - /*! - @brief Writes a BSON element with key @a name and integer @a value - */ - void write_bson_integer(const string_t& name, - const std::int64_t value) - { - if ((std::numeric_limits::min)() <= value && value <= (std::numeric_limits::max)()) - { - write_bson_entry_header(name, 0x10); // int32 - write_number(static_cast(value)); - } - else - { - write_bson_entry_header(name, 0x12); // int64 - write_number(static_cast(value)); - } - } - - /*! - @return The size of the BSON-encoded unsigned integer in @a j - */ - static constexpr std::size_t calc_bson_unsigned_size(const std::uint64_t value) noexcept - { - return (value <= static_cast((std::numeric_limits::max)())) - ? sizeof(std::int32_t) - : sizeof(std::int64_t); - } - - /*! - @brief Writes a BSON element with key @a name and unsigned @a value - */ - void write_bson_unsigned(const string_t& name, - const BasicJsonType& j) - { - if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) - { - write_bson_entry_header(name, 0x10 /* int32 */); - write_number(static_cast(j.m_value.number_unsigned)); - } - else if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) - { - write_bson_entry_header(name, 0x12 /* int64 */); - write_number(static_cast(j.m_value.number_unsigned)); - } - else - { - JSON_THROW(out_of_range::create(407, "integer number " + std::to_string(j.m_value.number_unsigned) + " cannot be represented by BSON as it does not fit int64", j)); - } - } - - /*! - @brief Writes a BSON element with key @a name and object @a value - */ - void write_bson_object_entry(const string_t& name, - const typename BasicJsonType::object_t& value) - { - write_bson_entry_header(name, 0x03); // object - write_bson_object(value); - } - - /*! - @return The size of the BSON-encoded array @a value - */ - static std::size_t calc_bson_array_size(const typename BasicJsonType::array_t& value) - { - std::size_t array_index = 0ul; - - const std::size_t embedded_document_size = std::accumulate(std::begin(value), std::end(value), std::size_t(0), [&array_index](std::size_t result, const typename BasicJsonType::array_t::value_type & el) - { - return result + calc_bson_element_size(std::to_string(array_index++), el); - }); - - return sizeof(std::int32_t) + embedded_document_size + 1ul; - } - - /*! - @return The size of the BSON-encoded binary array @a value - */ - static std::size_t calc_bson_binary_size(const typename BasicJsonType::binary_t& value) - { - return sizeof(std::int32_t) + value.size() + 1ul; - } - - /*! - @brief Writes a BSON element with key @a name and array @a value - */ - void write_bson_array(const string_t& name, - const typename BasicJsonType::array_t& value) - { - write_bson_entry_header(name, 0x04); // array - write_number(static_cast(calc_bson_array_size(value))); - - std::size_t array_index = 0ul; - - for (const auto& el : value) - { - write_bson_element(std::to_string(array_index++), el); - } - - oa->write_character(to_char_type(0x00)); - } - - /*! - @brief Writes a BSON element with key @a name and binary value @a value - */ - void write_bson_binary(const string_t& name, - const binary_t& value) - { - write_bson_entry_header(name, 0x05); - - write_number(static_cast(value.size())); - write_number(value.has_subtype() ? static_cast(value.subtype()) : std::uint8_t(0x00)); - - oa->write_characters(reinterpret_cast(value.data()), value.size()); - } - - /*! - @brief Calculates the size necessary to serialize the JSON value @a j with its @a name - @return The calculated size for the BSON document entry for @a j with the given @a name. - */ - static std::size_t calc_bson_element_size(const string_t& name, - const BasicJsonType& j) - { - const auto header_size = calc_bson_entry_header_size(name, j); - switch (j.type()) - { - case value_t::object: - return header_size + calc_bson_object_size(*j.m_value.object); - - case value_t::array: - return header_size + calc_bson_array_size(*j.m_value.array); - - case value_t::binary: - return header_size + calc_bson_binary_size(*j.m_value.binary); - - case value_t::boolean: - return header_size + 1ul; - - case value_t::number_float: - return header_size + 8ul; - - case value_t::number_integer: - return header_size + calc_bson_integer_size(j.m_value.number_integer); - - case value_t::number_unsigned: - return header_size + calc_bson_unsigned_size(j.m_value.number_unsigned); - - case value_t::string: - return header_size + calc_bson_string_size(*j.m_value.string); - - case value_t::null: - return header_size + 0ul; - - // LCOV_EXCL_START - case value_t::discarded: - default: - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) - return 0ul; - // LCOV_EXCL_STOP - } - } - - /*! - @brief Serializes the JSON value @a j to BSON and associates it with the - key @a name. - @param name The name to associate with the JSON entity @a j within the - current BSON document - */ - void write_bson_element(const string_t& name, - const BasicJsonType& j) - { - switch (j.type()) - { - case value_t::object: - return write_bson_object_entry(name, *j.m_value.object); - - case value_t::array: - return write_bson_array(name, *j.m_value.array); - - case value_t::binary: - return write_bson_binary(name, *j.m_value.binary); - - case value_t::boolean: - return write_bson_boolean(name, j.m_value.boolean); - - case value_t::number_float: - return write_bson_double(name, j.m_value.number_float); - - case value_t::number_integer: - return write_bson_integer(name, j.m_value.number_integer); - - case value_t::number_unsigned: - return write_bson_unsigned(name, j); - - case value_t::string: - return write_bson_string(name, *j.m_value.string); - - case value_t::null: - return write_bson_null(name); - - // LCOV_EXCL_START - case value_t::discarded: - default: - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) - return; - // LCOV_EXCL_STOP - } - } - - /*! - @brief Calculates the size of the BSON serialization of the given - JSON-object @a j. - @param[in] value JSON value to serialize - @pre value.type() == value_t::object - */ - static std::size_t calc_bson_object_size(const typename BasicJsonType::object_t& value) - { - std::size_t document_size = std::accumulate(value.begin(), value.end(), std::size_t(0), - [](size_t result, const typename BasicJsonType::object_t::value_type & el) - { - return result += calc_bson_element_size(el.first, el.second); - }); - - return sizeof(std::int32_t) + document_size + 1ul; - } - - /*! - @param[in] value JSON value to serialize - @pre value.type() == value_t::object - */ - void write_bson_object(const typename BasicJsonType::object_t& value) - { - write_number(static_cast(calc_bson_object_size(value))); - - for (const auto& el : value) - { - write_bson_element(el.first, el.second); - } - - oa->write_character(to_char_type(0x00)); - } - - ////////// - // CBOR // - ////////// - - static constexpr CharType get_cbor_float_prefix(float /*unused*/) - { - return to_char_type(0xFA); // Single-Precision Float - } - - static constexpr CharType get_cbor_float_prefix(double /*unused*/) - { - return to_char_type(0xFB); // Double-Precision Float - } - - ///////////// - // MsgPack // - ///////////// - - static constexpr CharType get_msgpack_float_prefix(float /*unused*/) - { - return to_char_type(0xCA); // float 32 - } - - static constexpr CharType get_msgpack_float_prefix(double /*unused*/) - { - return to_char_type(0xCB); // float 64 - } - - //////////// - // UBJSON // - //////////// - - // UBJSON: write number (floating point) - template::value, int>::type = 0> - void write_number_with_ubjson_prefix(const NumberType n, - const bool add_prefix) - { - if (add_prefix) - { - oa->write_character(get_ubjson_float_prefix(n)); - } - write_number(n); - } - - // UBJSON: write number (unsigned integer) - template::value, int>::type = 0> - void write_number_with_ubjson_prefix(const NumberType n, - const bool add_prefix) - { - if (n <= static_cast((std::numeric_limits::max)())) - { - if (add_prefix) - { - oa->write_character(to_char_type('i')); // int8 - } - write_number(static_cast(n)); - } - else if (n <= (std::numeric_limits::max)()) - { - if (add_prefix) - { - oa->write_character(to_char_type('U')); // uint8 - } - write_number(static_cast(n)); - } - else if (n <= static_cast((std::numeric_limits::max)())) - { - if (add_prefix) - { - oa->write_character(to_char_type('I')); // int16 - } - write_number(static_cast(n)); - } - else if (n <= static_cast((std::numeric_limits::max)())) - { - if (add_prefix) - { - oa->write_character(to_char_type('l')); // int32 - } - write_number(static_cast(n)); - } - else if (n <= static_cast((std::numeric_limits::max)())) - { - if (add_prefix) - { - oa->write_character(to_char_type('L')); // int64 - } - write_number(static_cast(n)); - } - else - { - if (add_prefix) - { - oa->write_character(to_char_type('H')); // high-precision number - } - - const auto number = BasicJsonType(n).dump(); - write_number_with_ubjson_prefix(number.size(), true); - for (std::size_t i = 0; i < number.size(); ++i) - { - oa->write_character(to_char_type(static_cast(number[i]))); - } - } - } - - // UBJSON: write number (signed integer) - template < typename NumberType, typename std::enable_if < - std::is_signed::value&& - !std::is_floating_point::value, int >::type = 0 > - void write_number_with_ubjson_prefix(const NumberType n, - const bool add_prefix) - { - if ((std::numeric_limits::min)() <= n && n <= (std::numeric_limits::max)()) - { - if (add_prefix) - { - oa->write_character(to_char_type('i')); // int8 - } - write_number(static_cast(n)); - } - else if (static_cast((std::numeric_limits::min)()) <= n && n <= static_cast((std::numeric_limits::max)())) - { - if (add_prefix) - { - oa->write_character(to_char_type('U')); // uint8 - } - write_number(static_cast(n)); - } - else if ((std::numeric_limits::min)() <= n && n <= (std::numeric_limits::max)()) - { - if (add_prefix) - { - oa->write_character(to_char_type('I')); // int16 - } - write_number(static_cast(n)); - } - else if ((std::numeric_limits::min)() <= n && n <= (std::numeric_limits::max)()) - { - if (add_prefix) - { - oa->write_character(to_char_type('l')); // int32 - } - write_number(static_cast(n)); - } - else if ((std::numeric_limits::min)() <= n && n <= (std::numeric_limits::max)()) - { - if (add_prefix) - { - oa->write_character(to_char_type('L')); // int64 - } - write_number(static_cast(n)); - } - // LCOV_EXCL_START - else - { - if (add_prefix) - { - oa->write_character(to_char_type('H')); // high-precision number - } - - const auto number = BasicJsonType(n).dump(); - write_number_with_ubjson_prefix(number.size(), true); - for (std::size_t i = 0; i < number.size(); ++i) - { - oa->write_character(to_char_type(static_cast(number[i]))); - } - } - // LCOV_EXCL_STOP - } - - /*! - @brief determine the type prefix of container values - */ - CharType ubjson_prefix(const BasicJsonType& j) const noexcept - { - switch (j.type()) - { - case value_t::null: - return 'Z'; - - case value_t::boolean: - return j.m_value.boolean ? 'T' : 'F'; - - case value_t::number_integer: - { - if ((std::numeric_limits::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits::max)()) - { - return 'i'; - } - if ((std::numeric_limits::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits::max)()) - { - return 'U'; - } - if ((std::numeric_limits::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits::max)()) - { - return 'I'; - } - if ((std::numeric_limits::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits::max)()) - { - return 'l'; - } - if ((std::numeric_limits::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits::max)()) - { - return 'L'; - } - // anything else is treated as high-precision number - return 'H'; // LCOV_EXCL_LINE - } - - case value_t::number_unsigned: - { - if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) - { - return 'i'; - } - if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) - { - return 'U'; - } - if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) - { - return 'I'; - } - if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) - { - return 'l'; - } - if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) - { - return 'L'; - } - // anything else is treated as high-precision number - return 'H'; // LCOV_EXCL_LINE - } - - case value_t::number_float: - return get_ubjson_float_prefix(j.m_value.number_float); - - case value_t::string: - return 'S'; - - case value_t::array: // fallthrough - case value_t::binary: - return '['; - - case value_t::object: - return '{'; - - case value_t::discarded: - default: // discarded values - return 'N'; - } - } - - static constexpr CharType get_ubjson_float_prefix(float /*unused*/) - { - return 'd'; // float 32 - } - - static constexpr CharType get_ubjson_float_prefix(double /*unused*/) - { - return 'D'; // float 64 - } - - /////////////////////// - // Utility functions // - /////////////////////// - - /* - @brief write a number to output input - @param[in] n number of type @a NumberType - @tparam NumberType the type of the number - @tparam OutputIsLittleEndian Set to true if output data is - required to be little endian - - @note This function needs to respect the system's endianess, because bytes - in CBOR, MessagePack, and UBJSON are stored in network order (big - endian) and therefore need reordering on little endian systems. - */ - template - void write_number(const NumberType n) - { - // step 1: write number to array of length NumberType - std::array vec{}; - std::memcpy(vec.data(), &n, sizeof(NumberType)); - - // step 2: write array to output (with possible reordering) - if (is_little_endian != OutputIsLittleEndian) - { - // reverse byte order prior to conversion if necessary - std::reverse(vec.begin(), vec.end()); - } - - oa->write_characters(vec.data(), sizeof(NumberType)); - } - - void write_compact_float(const number_float_t n, detail::input_format_t format) - { -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wfloat-equal" -#endif - if (static_cast(n) >= static_cast(std::numeric_limits::lowest()) && - static_cast(n) <= static_cast((std::numeric_limits::max)()) && - static_cast(static_cast(n)) == static_cast(n)) - { - oa->write_character(format == detail::input_format_t::cbor - ? get_cbor_float_prefix(static_cast(n)) - : get_msgpack_float_prefix(static_cast(n))); - write_number(static_cast(n)); - } - else - { - oa->write_character(format == detail::input_format_t::cbor - ? get_cbor_float_prefix(n) - : get_msgpack_float_prefix(n)); - write_number(n); - } -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif - } - - public: - // The following to_char_type functions are implement the conversion - // between uint8_t and CharType. In case CharType is not unsigned, - // such a conversion is required to allow values greater than 128. - // See for a discussion. - template < typename C = CharType, - enable_if_t < std::is_signed::value && std::is_signed::value > * = nullptr > - static constexpr CharType to_char_type(std::uint8_t x) noexcept - { - return *reinterpret_cast(&x); - } - - template < typename C = CharType, - enable_if_t < std::is_signed::value && std::is_unsigned::value > * = nullptr > - static CharType to_char_type(std::uint8_t x) noexcept - { - static_assert(sizeof(std::uint8_t) == sizeof(CharType), "size of CharType must be equal to std::uint8_t"); - static_assert(std::is_trivial::value, "CharType must be trivial"); - CharType result; - std::memcpy(&result, &x, sizeof(x)); - return result; - } - - template::value>* = nullptr> - static constexpr CharType to_char_type(std::uint8_t x) noexcept - { - return x; - } - - template < typename InputCharType, typename C = CharType, - enable_if_t < - std::is_signed::value && - std::is_signed::value && - std::is_same::type>::value - > * = nullptr > - static constexpr CharType to_char_type(InputCharType x) noexcept - { - return x; - } - - private: - /// whether we can assume little endianess - const bool is_little_endian = little_endianess(); - - /// the output - output_adapter_t oa = nullptr; -}; -} // namespace detail -} // namespace nlohmann - -// #include - -// #include - - -#include // reverse, remove, fill, find, none_of -#include // array -#include // localeconv, lconv -#include // labs, isfinite, isnan, signbit -#include // size_t, ptrdiff_t -#include // uint8_t -#include // snprintf -#include // numeric_limits -#include // string, char_traits -#include // setfill, setw -#include // stringstream -#include // is_same -#include // move - -// #include - - -#include // array -#include // signbit, isfinite -#include // intN_t, uintN_t -#include // memcpy, memmove -#include // numeric_limits -#include // conditional - -// #include - - -namespace nlohmann -{ -namespace detail -{ - -/*! -@brief implements the Grisu2 algorithm for binary to decimal floating-point -conversion. - -This implementation is a slightly modified version of the reference -implementation which may be obtained from -http://florian.loitsch.com/publications (bench.tar.gz). - -The code is distributed under the MIT license, Copyright (c) 2009 Florian Loitsch. - -For a detailed description of the algorithm see: - -[1] Loitsch, "Printing Floating-Point Numbers Quickly and Accurately with - Integers", Proceedings of the ACM SIGPLAN 2010 Conference on Programming - Language Design and Implementation, PLDI 2010 -[2] Burger, Dybvig, "Printing Floating-Point Numbers Quickly and Accurately", - Proceedings of the ACM SIGPLAN 1996 Conference on Programming Language - Design and Implementation, PLDI 1996 -*/ -namespace dtoa_impl -{ - -template -Target reinterpret_bits(const Source source) -{ - static_assert(sizeof(Target) == sizeof(Source), "size mismatch"); - - Target target; - std::memcpy(&target, &source, sizeof(Source)); - return target; -} - -struct diyfp // f * 2^e -{ - static constexpr int kPrecision = 64; // = q - - std::uint64_t f = 0; - int e = 0; - - constexpr diyfp(std::uint64_t f_, int e_) noexcept : f(f_), e(e_) {} - - /*! - @brief returns x - y - @pre x.e == y.e and x.f >= y.f - */ - static diyfp sub(const diyfp& x, const diyfp& y) noexcept - { - JSON_ASSERT(x.e == y.e); - JSON_ASSERT(x.f >= y.f); - - return {x.f - y.f, x.e}; - } - - /*! - @brief returns x * y - @note The result is rounded. (Only the upper q bits are returned.) - */ - static diyfp mul(const diyfp& x, const diyfp& y) noexcept - { - static_assert(kPrecision == 64, "internal error"); - - // Computes: - // f = round((x.f * y.f) / 2^q) - // e = x.e + y.e + q - - // Emulate the 64-bit * 64-bit multiplication: - // - // p = u * v - // = (u_lo + 2^32 u_hi) (v_lo + 2^32 v_hi) - // = (u_lo v_lo ) + 2^32 ((u_lo v_hi ) + (u_hi v_lo )) + 2^64 (u_hi v_hi ) - // = (p0 ) + 2^32 ((p1 ) + (p2 )) + 2^64 (p3 ) - // = (p0_lo + 2^32 p0_hi) + 2^32 ((p1_lo + 2^32 p1_hi) + (p2_lo + 2^32 p2_hi)) + 2^64 (p3 ) - // = (p0_lo ) + 2^32 (p0_hi + p1_lo + p2_lo ) + 2^64 (p1_hi + p2_hi + p3) - // = (p0_lo ) + 2^32 (Q ) + 2^64 (H ) - // = (p0_lo ) + 2^32 (Q_lo + 2^32 Q_hi ) + 2^64 (H ) - // - // (Since Q might be larger than 2^32 - 1) - // - // = (p0_lo + 2^32 Q_lo) + 2^64 (Q_hi + H) - // - // (Q_hi + H does not overflow a 64-bit int) - // - // = p_lo + 2^64 p_hi - - const std::uint64_t u_lo = x.f & 0xFFFFFFFFu; - const std::uint64_t u_hi = x.f >> 32u; - const std::uint64_t v_lo = y.f & 0xFFFFFFFFu; - const std::uint64_t v_hi = y.f >> 32u; - - const std::uint64_t p0 = u_lo * v_lo; - const std::uint64_t p1 = u_lo * v_hi; - const std::uint64_t p2 = u_hi * v_lo; - const std::uint64_t p3 = u_hi * v_hi; - - const std::uint64_t p0_hi = p0 >> 32u; - const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu; - const std::uint64_t p1_hi = p1 >> 32u; - const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu; - const std::uint64_t p2_hi = p2 >> 32u; - - std::uint64_t Q = p0_hi + p1_lo + p2_lo; - - // The full product might now be computed as - // - // p_hi = p3 + p2_hi + p1_hi + (Q >> 32) - // p_lo = p0_lo + (Q << 32) - // - // But in this particular case here, the full p_lo is not required. - // Effectively we only need to add the highest bit in p_lo to p_hi (and - // Q_hi + 1 does not overflow). - - Q += std::uint64_t{1} << (64u - 32u - 1u); // round, ties up - - const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u); - - return {h, x.e + y.e + 64}; - } - - /*! - @brief normalize x such that the significand is >= 2^(q-1) - @pre x.f != 0 - */ - static diyfp normalize(diyfp x) noexcept - { - JSON_ASSERT(x.f != 0); - - while ((x.f >> 63u) == 0) - { - x.f <<= 1u; - x.e--; - } - - return x; - } - - /*! - @brief normalize x such that the result has the exponent E - @pre e >= x.e and the upper e - x.e bits of x.f must be zero. - */ - static diyfp normalize_to(const diyfp& x, const int target_exponent) noexcept - { - const int delta = x.e - target_exponent; - - JSON_ASSERT(delta >= 0); - JSON_ASSERT(((x.f << delta) >> delta) == x.f); - - return {x.f << delta, target_exponent}; - } -}; - -struct boundaries -{ - diyfp w; - diyfp minus; - diyfp plus; -}; - -/*! -Compute the (normalized) diyfp representing the input number 'value' and its -boundaries. - -@pre value must be finite and positive -*/ -template -boundaries compute_boundaries(FloatType value) -{ - JSON_ASSERT(std::isfinite(value)); - JSON_ASSERT(value > 0); - - // Convert the IEEE representation into a diyfp. - // - // If v is denormal: - // value = 0.F * 2^(1 - bias) = ( F) * 2^(1 - bias - (p-1)) - // If v is normalized: - // value = 1.F * 2^(E - bias) = (2^(p-1) + F) * 2^(E - bias - (p-1)) - - static_assert(std::numeric_limits::is_iec559, - "internal error: dtoa_short requires an IEEE-754 floating-point implementation"); - - constexpr int kPrecision = std::numeric_limits::digits; // = p (includes the hidden bit) - constexpr int kBias = std::numeric_limits::max_exponent - 1 + (kPrecision - 1); - constexpr int kMinExp = 1 - kBias; - constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1); // = 2^(p-1) - - using bits_type = typename std::conditional::type; - - const auto bits = static_cast(reinterpret_bits(value)); - const std::uint64_t E = bits >> (kPrecision - 1); - const std::uint64_t F = bits & (kHiddenBit - 1); - - const bool is_denormal = E == 0; - const diyfp v = is_denormal - ? diyfp(F, kMinExp) - : diyfp(F + kHiddenBit, static_cast(E) - kBias); - - // Compute the boundaries m- and m+ of the floating-point value - // v = f * 2^e. - // - // Determine v- and v+, the floating-point predecessor and successor if v, - // respectively. - // - // v- = v - 2^e if f != 2^(p-1) or e == e_min (A) - // = v - 2^(e-1) if f == 2^(p-1) and e > e_min (B) - // - // v+ = v + 2^e - // - // Let m- = (v- + v) / 2 and m+ = (v + v+) / 2. All real numbers _strictly_ - // between m- and m+ round to v, regardless of how the input rounding - // algorithm breaks ties. - // - // ---+-------------+-------------+-------------+-------------+--- (A) - // v- m- v m+ v+ - // - // -----------------+------+------+-------------+-------------+--- (B) - // v- m- v m+ v+ - - const bool lower_boundary_is_closer = F == 0 && E > 1; - const diyfp m_plus = diyfp(2 * v.f + 1, v.e - 1); - const diyfp m_minus = lower_boundary_is_closer - ? diyfp(4 * v.f - 1, v.e - 2) // (B) - : diyfp(2 * v.f - 1, v.e - 1); // (A) - - // Determine the normalized w+ = m+. - const diyfp w_plus = diyfp::normalize(m_plus); - - // Determine w- = m- such that e_(w-) = e_(w+). - const diyfp w_minus = diyfp::normalize_to(m_minus, w_plus.e); - - return {diyfp::normalize(v), w_minus, w_plus}; -} - -// Given normalized diyfp w, Grisu needs to find a (normalized) cached -// power-of-ten c, such that the exponent of the product c * w = f * 2^e lies -// within a certain range [alpha, gamma] (Definition 3.2 from [1]) -// -// alpha <= e = e_c + e_w + q <= gamma -// -// or -// -// f_c * f_w * 2^alpha <= f_c 2^(e_c) * f_w 2^(e_w) * 2^q -// <= f_c * f_w * 2^gamma -// -// Since c and w are normalized, i.e. 2^(q-1) <= f < 2^q, this implies -// -// 2^(q-1) * 2^(q-1) * 2^alpha <= c * w * 2^q < 2^q * 2^q * 2^gamma -// -// or -// -// 2^(q - 2 + alpha) <= c * w < 2^(q + gamma) -// -// The choice of (alpha,gamma) determines the size of the table and the form of -// the digit generation procedure. Using (alpha,gamma)=(-60,-32) works out well -// in practice: -// -// The idea is to cut the number c * w = f * 2^e into two parts, which can be -// processed independently: An integral part p1, and a fractional part p2: -// -// f * 2^e = ( (f div 2^-e) * 2^-e + (f mod 2^-e) ) * 2^e -// = (f div 2^-e) + (f mod 2^-e) * 2^e -// = p1 + p2 * 2^e -// -// The conversion of p1 into decimal form requires a series of divisions and -// modulos by (a power of) 10. These operations are faster for 32-bit than for -// 64-bit integers, so p1 should ideally fit into a 32-bit integer. This can be -// achieved by choosing -// -// -e >= 32 or e <= -32 := gamma -// -// In order to convert the fractional part -// -// p2 * 2^e = p2 / 2^-e = d[-1] / 10^1 + d[-2] / 10^2 + ... -// -// into decimal form, the fraction is repeatedly multiplied by 10 and the digits -// d[-i] are extracted in order: -// -// (10 * p2) div 2^-e = d[-1] -// (10 * p2) mod 2^-e = d[-2] / 10^1 + ... -// -// The multiplication by 10 must not overflow. It is sufficient to choose -// -// 10 * p2 < 16 * p2 = 2^4 * p2 <= 2^64. -// -// Since p2 = f mod 2^-e < 2^-e, -// -// -e <= 60 or e >= -60 := alpha - -constexpr int kAlpha = -60; -constexpr int kGamma = -32; - -struct cached_power // c = f * 2^e ~= 10^k -{ - std::uint64_t f; - int e; - int k; -}; - -/*! -For a normalized diyfp w = f * 2^e, this function returns a (normalized) cached -power-of-ten c = f_c * 2^e_c, such that the exponent of the product w * c -satisfies (Definition 3.2 from [1]) - - alpha <= e_c + e + q <= gamma. -*/ -inline cached_power get_cached_power_for_binary_exponent(int e) -{ - // Now - // - // alpha <= e_c + e + q <= gamma (1) - // ==> f_c * 2^alpha <= c * 2^e * 2^q - // - // and since the c's are normalized, 2^(q-1) <= f_c, - // - // ==> 2^(q - 1 + alpha) <= c * 2^(e + q) - // ==> 2^(alpha - e - 1) <= c - // - // If c were an exact power of ten, i.e. c = 10^k, one may determine k as - // - // k = ceil( log_10( 2^(alpha - e - 1) ) ) - // = ceil( (alpha - e - 1) * log_10(2) ) - // - // From the paper: - // "In theory the result of the procedure could be wrong since c is rounded, - // and the computation itself is approximated [...]. In practice, however, - // this simple function is sufficient." - // - // For IEEE double precision floating-point numbers converted into - // normalized diyfp's w = f * 2^e, with q = 64, - // - // e >= -1022 (min IEEE exponent) - // -52 (p - 1) - // -52 (p - 1, possibly normalize denormal IEEE numbers) - // -11 (normalize the diyfp) - // = -1137 - // - // and - // - // e <= +1023 (max IEEE exponent) - // -52 (p - 1) - // -11 (normalize the diyfp) - // = 960 - // - // This binary exponent range [-1137,960] results in a decimal exponent - // range [-307,324]. One does not need to store a cached power for each - // k in this range. For each such k it suffices to find a cached power - // such that the exponent of the product lies in [alpha,gamma]. - // This implies that the difference of the decimal exponents of adjacent - // table entries must be less than or equal to - // - // floor( (gamma - alpha) * log_10(2) ) = 8. - // - // (A smaller distance gamma-alpha would require a larger table.) - - // NB: - // Actually this function returns c, such that -60 <= e_c + e + 64 <= -34. - - constexpr int kCachedPowersMinDecExp = -300; - constexpr int kCachedPowersDecStep = 8; - - static constexpr std::array kCachedPowers = - { - { - { 0xAB70FE17C79AC6CA, -1060, -300 }, - { 0xFF77B1FCBEBCDC4F, -1034, -292 }, - { 0xBE5691EF416BD60C, -1007, -284 }, - { 0x8DD01FAD907FFC3C, -980, -276 }, - { 0xD3515C2831559A83, -954, -268 }, - { 0x9D71AC8FADA6C9B5, -927, -260 }, - { 0xEA9C227723EE8BCB, -901, -252 }, - { 0xAECC49914078536D, -874, -244 }, - { 0x823C12795DB6CE57, -847, -236 }, - { 0xC21094364DFB5637, -821, -228 }, - { 0x9096EA6F3848984F, -794, -220 }, - { 0xD77485CB25823AC7, -768, -212 }, - { 0xA086CFCD97BF97F4, -741, -204 }, - { 0xEF340A98172AACE5, -715, -196 }, - { 0xB23867FB2A35B28E, -688, -188 }, - { 0x84C8D4DFD2C63F3B, -661, -180 }, - { 0xC5DD44271AD3CDBA, -635, -172 }, - { 0x936B9FCEBB25C996, -608, -164 }, - { 0xDBAC6C247D62A584, -582, -156 }, - { 0xA3AB66580D5FDAF6, -555, -148 }, - { 0xF3E2F893DEC3F126, -529, -140 }, - { 0xB5B5ADA8AAFF80B8, -502, -132 }, - { 0x87625F056C7C4A8B, -475, -124 }, - { 0xC9BCFF6034C13053, -449, -116 }, - { 0x964E858C91BA2655, -422, -108 }, - { 0xDFF9772470297EBD, -396, -100 }, - { 0xA6DFBD9FB8E5B88F, -369, -92 }, - { 0xF8A95FCF88747D94, -343, -84 }, - { 0xB94470938FA89BCF, -316, -76 }, - { 0x8A08F0F8BF0F156B, -289, -68 }, - { 0xCDB02555653131B6, -263, -60 }, - { 0x993FE2C6D07B7FAC, -236, -52 }, - { 0xE45C10C42A2B3B06, -210, -44 }, - { 0xAA242499697392D3, -183, -36 }, - { 0xFD87B5F28300CA0E, -157, -28 }, - { 0xBCE5086492111AEB, -130, -20 }, - { 0x8CBCCC096F5088CC, -103, -12 }, - { 0xD1B71758E219652C, -77, -4 }, - { 0x9C40000000000000, -50, 4 }, - { 0xE8D4A51000000000, -24, 12 }, - { 0xAD78EBC5AC620000, 3, 20 }, - { 0x813F3978F8940984, 30, 28 }, - { 0xC097CE7BC90715B3, 56, 36 }, - { 0x8F7E32CE7BEA5C70, 83, 44 }, - { 0xD5D238A4ABE98068, 109, 52 }, - { 0x9F4F2726179A2245, 136, 60 }, - { 0xED63A231D4C4FB27, 162, 68 }, - { 0xB0DE65388CC8ADA8, 189, 76 }, - { 0x83C7088E1AAB65DB, 216, 84 }, - { 0xC45D1DF942711D9A, 242, 92 }, - { 0x924D692CA61BE758, 269, 100 }, - { 0xDA01EE641A708DEA, 295, 108 }, - { 0xA26DA3999AEF774A, 322, 116 }, - { 0xF209787BB47D6B85, 348, 124 }, - { 0xB454E4A179DD1877, 375, 132 }, - { 0x865B86925B9BC5C2, 402, 140 }, - { 0xC83553C5C8965D3D, 428, 148 }, - { 0x952AB45CFA97A0B3, 455, 156 }, - { 0xDE469FBD99A05FE3, 481, 164 }, - { 0xA59BC234DB398C25, 508, 172 }, - { 0xF6C69A72A3989F5C, 534, 180 }, - { 0xB7DCBF5354E9BECE, 561, 188 }, - { 0x88FCF317F22241E2, 588, 196 }, - { 0xCC20CE9BD35C78A5, 614, 204 }, - { 0x98165AF37B2153DF, 641, 212 }, - { 0xE2A0B5DC971F303A, 667, 220 }, - { 0xA8D9D1535CE3B396, 694, 228 }, - { 0xFB9B7CD9A4A7443C, 720, 236 }, - { 0xBB764C4CA7A44410, 747, 244 }, - { 0x8BAB8EEFB6409C1A, 774, 252 }, - { 0xD01FEF10A657842C, 800, 260 }, - { 0x9B10A4E5E9913129, 827, 268 }, - { 0xE7109BFBA19C0C9D, 853, 276 }, - { 0xAC2820D9623BF429, 880, 284 }, - { 0x80444B5E7AA7CF85, 907, 292 }, - { 0xBF21E44003ACDD2D, 933, 300 }, - { 0x8E679C2F5E44FF8F, 960, 308 }, - { 0xD433179D9C8CB841, 986, 316 }, - { 0x9E19DB92B4E31BA9, 1013, 324 }, - } - }; - - // This computation gives exactly the same results for k as - // k = ceil((kAlpha - e - 1) * 0.30102999566398114) - // for |e| <= 1500, but doesn't require floating-point operations. - // NB: log_10(2) ~= 78913 / 2^18 - JSON_ASSERT(e >= -1500); - JSON_ASSERT(e <= 1500); - const int f = kAlpha - e - 1; - const int k = (f * 78913) / (1 << 18) + static_cast(f > 0); - - const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep; - JSON_ASSERT(index >= 0); - JSON_ASSERT(static_cast(index) < kCachedPowers.size()); - - const cached_power cached = kCachedPowers[static_cast(index)]; - JSON_ASSERT(kAlpha <= cached.e + e + 64); - JSON_ASSERT(kGamma >= cached.e + e + 64); - - return cached; -} - -/*! -For n != 0, returns k, such that pow10 := 10^(k-1) <= n < 10^k. -For n == 0, returns 1 and sets pow10 := 1. -*/ -inline int find_largest_pow10(const std::uint32_t n, std::uint32_t& pow10) -{ - // LCOV_EXCL_START - if (n >= 1000000000) - { - pow10 = 1000000000; - return 10; - } - // LCOV_EXCL_STOP - if (n >= 100000000) - { - pow10 = 100000000; - return 9; - } - if (n >= 10000000) - { - pow10 = 10000000; - return 8; - } - if (n >= 1000000) - { - pow10 = 1000000; - return 7; - } - if (n >= 100000) - { - pow10 = 100000; - return 6; - } - if (n >= 10000) - { - pow10 = 10000; - return 5; - } - if (n >= 1000) - { - pow10 = 1000; - return 4; - } - if (n >= 100) - { - pow10 = 100; - return 3; - } - if (n >= 10) - { - pow10 = 10; - return 2; - } - - pow10 = 1; - return 1; -} - -inline void grisu2_round(char* buf, int len, std::uint64_t dist, std::uint64_t delta, - std::uint64_t rest, std::uint64_t ten_k) -{ - JSON_ASSERT(len >= 1); - JSON_ASSERT(dist <= delta); - JSON_ASSERT(rest <= delta); - JSON_ASSERT(ten_k > 0); - - // <--------------------------- delta ----> - // <---- dist ---------> - // --------------[------------------+-------------------]-------------- - // M- w M+ - // - // ten_k - // <------> - // <---- rest ----> - // --------------[------------------+----+--------------]-------------- - // w V - // = buf * 10^k - // - // ten_k represents a unit-in-the-last-place in the decimal representation - // stored in buf. - // Decrement buf by ten_k while this takes buf closer to w. - - // The tests are written in this order to avoid overflow in unsigned - // integer arithmetic. - - while (rest < dist - && delta - rest >= ten_k - && (rest + ten_k < dist || dist - rest > rest + ten_k - dist)) - { - JSON_ASSERT(buf[len - 1] != '0'); - buf[len - 1]--; - rest += ten_k; - } -} - -/*! -Generates V = buffer * 10^decimal_exponent, such that M- <= V <= M+. -M- and M+ must be normalized and share the same exponent -60 <= e <= -32. -*/ -inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent, - diyfp M_minus, diyfp w, diyfp M_plus) -{ - static_assert(kAlpha >= -60, "internal error"); - static_assert(kGamma <= -32, "internal error"); - - // Generates the digits (and the exponent) of a decimal floating-point - // number V = buffer * 10^decimal_exponent in the range [M-, M+]. The diyfp's - // w, M- and M+ share the same exponent e, which satisfies alpha <= e <= gamma. - // - // <--------------------------- delta ----> - // <---- dist ---------> - // --------------[------------------+-------------------]-------------- - // M- w M+ - // - // Grisu2 generates the digits of M+ from left to right and stops as soon as - // V is in [M-,M+]. - - JSON_ASSERT(M_plus.e >= kAlpha); - JSON_ASSERT(M_plus.e <= kGamma); - - std::uint64_t delta = diyfp::sub(M_plus, M_minus).f; // (significand of (M+ - M-), implicit exponent is e) - std::uint64_t dist = diyfp::sub(M_plus, w ).f; // (significand of (M+ - w ), implicit exponent is e) - - // Split M+ = f * 2^e into two parts p1 and p2 (note: e < 0): - // - // M+ = f * 2^e - // = ((f div 2^-e) * 2^-e + (f mod 2^-e)) * 2^e - // = ((p1 ) * 2^-e + (p2 )) * 2^e - // = p1 + p2 * 2^e - - const diyfp one(std::uint64_t{1} << -M_plus.e, M_plus.e); - - auto p1 = static_cast(M_plus.f >> -one.e); // p1 = f div 2^-e (Since -e >= 32, p1 fits into a 32-bit int.) - std::uint64_t p2 = M_plus.f & (one.f - 1); // p2 = f mod 2^-e - - // 1) - // - // Generate the digits of the integral part p1 = d[n-1]...d[1]d[0] - - JSON_ASSERT(p1 > 0); - - std::uint32_t pow10{}; - const int k = find_largest_pow10(p1, pow10); - - // 10^(k-1) <= p1 < 10^k, pow10 = 10^(k-1) - // - // p1 = (p1 div 10^(k-1)) * 10^(k-1) + (p1 mod 10^(k-1)) - // = (d[k-1] ) * 10^(k-1) + (p1 mod 10^(k-1)) - // - // M+ = p1 + p2 * 2^e - // = d[k-1] * 10^(k-1) + (p1 mod 10^(k-1)) + p2 * 2^e - // = d[k-1] * 10^(k-1) + ((p1 mod 10^(k-1)) * 2^-e + p2) * 2^e - // = d[k-1] * 10^(k-1) + ( rest) * 2^e - // - // Now generate the digits d[n] of p1 from left to right (n = k-1,...,0) - // - // p1 = d[k-1]...d[n] * 10^n + d[n-1]...d[0] - // - // but stop as soon as - // - // rest * 2^e = (d[n-1]...d[0] * 2^-e + p2) * 2^e <= delta * 2^e - - int n = k; - while (n > 0) - { - // Invariants: - // M+ = buffer * 10^n + (p1 + p2 * 2^e) (buffer = 0 for n = k) - // pow10 = 10^(n-1) <= p1 < 10^n - // - const std::uint32_t d = p1 / pow10; // d = p1 div 10^(n-1) - const std::uint32_t r = p1 % pow10; // r = p1 mod 10^(n-1) - // - // M+ = buffer * 10^n + (d * 10^(n-1) + r) + p2 * 2^e - // = (buffer * 10 + d) * 10^(n-1) + (r + p2 * 2^e) - // - JSON_ASSERT(d <= 9); - buffer[length++] = static_cast('0' + d); // buffer := buffer * 10 + d - // - // M+ = buffer * 10^(n-1) + (r + p2 * 2^e) - // - p1 = r; - n--; - // - // M+ = buffer * 10^n + (p1 + p2 * 2^e) - // pow10 = 10^n - // - - // Now check if enough digits have been generated. - // Compute - // - // p1 + p2 * 2^e = (p1 * 2^-e + p2) * 2^e = rest * 2^e - // - // Note: - // Since rest and delta share the same exponent e, it suffices to - // compare the significands. - const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2; - if (rest <= delta) - { - // V = buffer * 10^n, with M- <= V <= M+. - - decimal_exponent += n; - - // We may now just stop. But instead look if the buffer could be - // decremented to bring V closer to w. - // - // pow10 = 10^n is now 1 ulp in the decimal representation V. - // The rounding procedure works with diyfp's with an implicit - // exponent of e. - // - // 10^n = (10^n * 2^-e) * 2^e = ulp * 2^e - // - const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e; - grisu2_round(buffer, length, dist, delta, rest, ten_n); - - return; - } - - pow10 /= 10; - // - // pow10 = 10^(n-1) <= p1 < 10^n - // Invariants restored. - } - - // 2) - // - // The digits of the integral part have been generated: - // - // M+ = d[k-1]...d[1]d[0] + p2 * 2^e - // = buffer + p2 * 2^e - // - // Now generate the digits of the fractional part p2 * 2^e. - // - // Note: - // No decimal point is generated: the exponent is adjusted instead. - // - // p2 actually represents the fraction - // - // p2 * 2^e - // = p2 / 2^-e - // = d[-1] / 10^1 + d[-2] / 10^2 + ... - // - // Now generate the digits d[-m] of p1 from left to right (m = 1,2,...) - // - // p2 * 2^e = d[-1]d[-2]...d[-m] * 10^-m - // + 10^-m * (d[-m-1] / 10^1 + d[-m-2] / 10^2 + ...) - // - // using - // - // 10^m * p2 = ((10^m * p2) div 2^-e) * 2^-e + ((10^m * p2) mod 2^-e) - // = ( d) * 2^-e + ( r) - // - // or - // 10^m * p2 * 2^e = d + r * 2^e - // - // i.e. - // - // M+ = buffer + p2 * 2^e - // = buffer + 10^-m * (d + r * 2^e) - // = (buffer * 10^m + d) * 10^-m + 10^-m * r * 2^e - // - // and stop as soon as 10^-m * r * 2^e <= delta * 2^e - - JSON_ASSERT(p2 > delta); - - int m = 0; - for (;;) - { - // Invariant: - // M+ = buffer * 10^-m + 10^-m * (d[-m-1] / 10 + d[-m-2] / 10^2 + ...) * 2^e - // = buffer * 10^-m + 10^-m * (p2 ) * 2^e - // = buffer * 10^-m + 10^-m * (1/10 * (10 * p2) ) * 2^e - // = buffer * 10^-m + 10^-m * (1/10 * ((10*p2 div 2^-e) * 2^-e + (10*p2 mod 2^-e)) * 2^e - // - JSON_ASSERT(p2 <= (std::numeric_limits::max)() / 10); - p2 *= 10; - const std::uint64_t d = p2 >> -one.e; // d = (10 * p2) div 2^-e - const std::uint64_t r = p2 & (one.f - 1); // r = (10 * p2) mod 2^-e - // - // M+ = buffer * 10^-m + 10^-m * (1/10 * (d * 2^-e + r) * 2^e - // = buffer * 10^-m + 10^-m * (1/10 * (d + r * 2^e)) - // = (buffer * 10 + d) * 10^(-m-1) + 10^(-m-1) * r * 2^e - // - JSON_ASSERT(d <= 9); - buffer[length++] = static_cast('0' + d); // buffer := buffer * 10 + d - // - // M+ = buffer * 10^(-m-1) + 10^(-m-1) * r * 2^e - // - p2 = r; - m++; - // - // M+ = buffer * 10^-m + 10^-m * p2 * 2^e - // Invariant restored. - - // Check if enough digits have been generated. - // - // 10^-m * p2 * 2^e <= delta * 2^e - // p2 * 2^e <= 10^m * delta * 2^e - // p2 <= 10^m * delta - delta *= 10; - dist *= 10; - if (p2 <= delta) - { - break; - } - } - - // V = buffer * 10^-m, with M- <= V <= M+. - - decimal_exponent -= m; - - // 1 ulp in the decimal representation is now 10^-m. - // Since delta and dist are now scaled by 10^m, we need to do the - // same with ulp in order to keep the units in sync. - // - // 10^m * 10^-m = 1 = 2^-e * 2^e = ten_m * 2^e - // - const std::uint64_t ten_m = one.f; - grisu2_round(buffer, length, dist, delta, p2, ten_m); - - // By construction this algorithm generates the shortest possible decimal - // number (Loitsch, Theorem 6.2) which rounds back to w. - // For an input number of precision p, at least - // - // N = 1 + ceil(p * log_10(2)) - // - // decimal digits are sufficient to identify all binary floating-point - // numbers (Matula, "In-and-Out conversions"). - // This implies that the algorithm does not produce more than N decimal - // digits. - // - // N = 17 for p = 53 (IEEE double precision) - // N = 9 for p = 24 (IEEE single precision) -} - -/*! -v = buf * 10^decimal_exponent -len is the length of the buffer (number of decimal digits) -The buffer must be large enough, i.e. >= max_digits10. -*/ -JSON_HEDLEY_NON_NULL(1) -inline void grisu2(char* buf, int& len, int& decimal_exponent, - diyfp m_minus, diyfp v, diyfp m_plus) -{ - JSON_ASSERT(m_plus.e == m_minus.e); - JSON_ASSERT(m_plus.e == v.e); - - // --------(-----------------------+-----------------------)-------- (A) - // m- v m+ - // - // --------------------(-----------+-----------------------)-------- (B) - // m- v m+ - // - // First scale v (and m- and m+) such that the exponent is in the range - // [alpha, gamma]. - - const cached_power cached = get_cached_power_for_binary_exponent(m_plus.e); - - const diyfp c_minus_k(cached.f, cached.e); // = c ~= 10^-k - - // The exponent of the products is = v.e + c_minus_k.e + q and is in the range [alpha,gamma] - const diyfp w = diyfp::mul(v, c_minus_k); - const diyfp w_minus = diyfp::mul(m_minus, c_minus_k); - const diyfp w_plus = diyfp::mul(m_plus, c_minus_k); - - // ----(---+---)---------------(---+---)---------------(---+---)---- - // w- w w+ - // = c*m- = c*v = c*m+ - // - // diyfp::mul rounds its result and c_minus_k is approximated too. w, w- and - // w+ are now off by a small amount. - // In fact: - // - // w - v * 10^k < 1 ulp - // - // To account for this inaccuracy, add resp. subtract 1 ulp. - // - // --------+---[---------------(---+---)---------------]---+-------- - // w- M- w M+ w+ - // - // Now any number in [M-, M+] (bounds included) will round to w when input, - // regardless of how the input rounding algorithm breaks ties. - // - // And digit_gen generates the shortest possible such number in [M-, M+]. - // Note that this does not mean that Grisu2 always generates the shortest - // possible number in the interval (m-, m+). - const diyfp M_minus(w_minus.f + 1, w_minus.e); - const diyfp M_plus (w_plus.f - 1, w_plus.e ); - - decimal_exponent = -cached.k; // = -(-k) = k - - grisu2_digit_gen(buf, len, decimal_exponent, M_minus, w, M_plus); -} - -/*! -v = buf * 10^decimal_exponent -len is the length of the buffer (number of decimal digits) -The buffer must be large enough, i.e. >= max_digits10. -*/ -template -JSON_HEDLEY_NON_NULL(1) -void grisu2(char* buf, int& len, int& decimal_exponent, FloatType value) -{ - static_assert(diyfp::kPrecision >= std::numeric_limits::digits + 3, - "internal error: not enough precision"); - - JSON_ASSERT(std::isfinite(value)); - JSON_ASSERT(value > 0); - - // If the neighbors (and boundaries) of 'value' are always computed for double-precision - // numbers, all float's can be recovered using strtod (and strtof). However, the resulting - // decimal representations are not exactly "short". - // - // The documentation for 'std::to_chars' (https://en.cppreference.com/w/cpp/utility/to_chars) - // says "value is converted to a string as if by std::sprintf in the default ("C") locale" - // and since sprintf promotes float's to double's, I think this is exactly what 'std::to_chars' - // does. - // On the other hand, the documentation for 'std::to_chars' requires that "parsing the - // representation using the corresponding std::from_chars function recovers value exactly". That - // indicates that single precision floating-point numbers should be recovered using - // 'std::strtof'. - // - // NB: If the neighbors are computed for single-precision numbers, there is a single float - // (7.0385307e-26f) which can't be recovered using strtod. The resulting double precision - // value is off by 1 ulp. -#if 0 - const boundaries w = compute_boundaries(static_cast(value)); -#else - const boundaries w = compute_boundaries(value); -#endif - - grisu2(buf, len, decimal_exponent, w.minus, w.w, w.plus); -} - -/*! -@brief appends a decimal representation of e to buf -@return a pointer to the element following the exponent. -@pre -1000 < e < 1000 -*/ -JSON_HEDLEY_NON_NULL(1) -JSON_HEDLEY_RETURNS_NON_NULL -inline char* append_exponent(char* buf, int e) -{ - JSON_ASSERT(e > -1000); - JSON_ASSERT(e < 1000); - - if (e < 0) - { - e = -e; - *buf++ = '-'; - } - else - { - *buf++ = '+'; - } - - auto k = static_cast(e); - if (k < 10) - { - // Always print at least two digits in the exponent. - // This is for compatibility with printf("%g"). - *buf++ = '0'; - *buf++ = static_cast('0' + k); - } - else if (k < 100) - { - *buf++ = static_cast('0' + k / 10); - k %= 10; - *buf++ = static_cast('0' + k); - } - else - { - *buf++ = static_cast('0' + k / 100); - k %= 100; - *buf++ = static_cast('0' + k / 10); - k %= 10; - *buf++ = static_cast('0' + k); - } - - return buf; -} - -/*! -@brief prettify v = buf * 10^decimal_exponent - -If v is in the range [10^min_exp, 10^max_exp) it will be printed in fixed-point -notation. Otherwise it will be printed in exponential notation. - -@pre min_exp < 0 -@pre max_exp > 0 -*/ -JSON_HEDLEY_NON_NULL(1) -JSON_HEDLEY_RETURNS_NON_NULL -inline char* format_buffer(char* buf, int len, int decimal_exponent, - int min_exp, int max_exp) -{ - JSON_ASSERT(min_exp < 0); - JSON_ASSERT(max_exp > 0); - - const int k = len; - const int n = len + decimal_exponent; - - // v = buf * 10^(n-k) - // k is the length of the buffer (number of decimal digits) - // n is the position of the decimal point relative to the start of the buffer. - - if (k <= n && n <= max_exp) - { - // digits[000] - // len <= max_exp + 2 - - std::memset(buf + k, '0', static_cast(n) - static_cast(k)); - // Make it look like a floating-point number (#362, #378) - buf[n + 0] = '.'; - buf[n + 1] = '0'; - return buf + (static_cast(n) + 2); - } - - if (0 < n && n <= max_exp) - { - // dig.its - // len <= max_digits10 + 1 - - JSON_ASSERT(k > n); - - std::memmove(buf + (static_cast(n) + 1), buf + n, static_cast(k) - static_cast(n)); - buf[n] = '.'; - return buf + (static_cast(k) + 1U); - } - - if (min_exp < n && n <= 0) - { - // 0.[000]digits - // len <= 2 + (-min_exp - 1) + max_digits10 - - std::memmove(buf + (2 + static_cast(-n)), buf, static_cast(k)); - buf[0] = '0'; - buf[1] = '.'; - std::memset(buf + 2, '0', static_cast(-n)); - return buf + (2U + static_cast(-n) + static_cast(k)); - } - - if (k == 1) - { - // dE+123 - // len <= 1 + 5 - - buf += 1; - } - else - { - // d.igitsE+123 - // len <= max_digits10 + 1 + 5 - - std::memmove(buf + 2, buf + 1, static_cast(k) - 1); - buf[1] = '.'; - buf += 1 + static_cast(k); - } - - *buf++ = 'e'; - return append_exponent(buf, n - 1); -} - -} // namespace dtoa_impl - -/*! -@brief generates a decimal representation of the floating-point number value in [first, last). - -The format of the resulting decimal representation is similar to printf's %g -format. Returns an iterator pointing past-the-end of the decimal representation. - -@note The input number must be finite, i.e. NaN's and Inf's are not supported. -@note The buffer must be large enough. -@note The result is NOT null-terminated. -*/ -template -JSON_HEDLEY_NON_NULL(1, 2) -JSON_HEDLEY_RETURNS_NON_NULL -char* to_chars(char* first, const char* last, FloatType value) -{ - static_cast(last); // maybe unused - fix warning - JSON_ASSERT(std::isfinite(value)); - - // Use signbit(value) instead of (value < 0) since signbit works for -0. - if (std::signbit(value)) - { - value = -value; - *first++ = '-'; - } - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wfloat-equal" -#endif - if (value == 0) // +-0 - { - *first++ = '0'; - // Make it look like a floating-point number (#362, #378) - *first++ = '.'; - *first++ = '0'; - return first; - } -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif - - JSON_ASSERT(last - first >= std::numeric_limits::max_digits10); - - // Compute v = buffer * 10^decimal_exponent. - // The decimal digits are stored in the buffer, which needs to be interpreted - // as an unsigned decimal integer. - // len is the length of the buffer, i.e. the number of decimal digits. - int len = 0; - int decimal_exponent = 0; - dtoa_impl::grisu2(first, len, decimal_exponent, value); - - JSON_ASSERT(len <= std::numeric_limits::max_digits10); - - // Format the buffer like printf("%.*g", prec, value) - constexpr int kMinExp = -4; - // Use digits10 here to increase compatibility with version 2. - constexpr int kMaxExp = std::numeric_limits::digits10; - - JSON_ASSERT(last - first >= kMaxExp + 2); - JSON_ASSERT(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits::max_digits10); - JSON_ASSERT(last - first >= std::numeric_limits::max_digits10 + 6); - - return dtoa_impl::format_buffer(first, len, decimal_exponent, kMinExp, kMaxExp); -} - -} // namespace detail -} // namespace nlohmann - -// #include - -// #include - -// #include - -// #include - -// #include - -// #include - - -namespace nlohmann -{ -namespace detail -{ -/////////////////// -// serialization // -/////////////////// - -/// how to treat decoding errors -enum class error_handler_t -{ - strict, ///< throw a type_error exception in case of invalid UTF-8 - replace, ///< replace invalid UTF-8 sequences with U+FFFD - ignore ///< ignore invalid UTF-8 sequences -}; - -template -class serializer -{ - using string_t = typename BasicJsonType::string_t; - using number_float_t = typename BasicJsonType::number_float_t; - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using binary_char_t = typename BasicJsonType::binary_t::value_type; - static constexpr std::uint8_t UTF8_ACCEPT = 0; - static constexpr std::uint8_t UTF8_REJECT = 1; - - public: - /*! - @param[in] s output stream to serialize to - @param[in] ichar indentation character to use - @param[in] error_handler_ how to react on decoding errors - */ - serializer(output_adapter_t s, const char ichar, - error_handler_t error_handler_ = error_handler_t::strict) - : o(std::move(s)) - , loc(std::localeconv()) - , thousands_sep(loc->thousands_sep == nullptr ? '\0' : std::char_traits::to_char_type(* (loc->thousands_sep))) - , decimal_point(loc->decimal_point == nullptr ? '\0' : std::char_traits::to_char_type(* (loc->decimal_point))) - , indent_char(ichar) - , indent_string(512, indent_char) - , error_handler(error_handler_) - {} - - // delete because of pointer members - serializer(const serializer&) = delete; - serializer& operator=(const serializer&) = delete; - serializer(serializer&&) = delete; - serializer& operator=(serializer&&) = delete; - ~serializer() = default; - - /*! - @brief internal implementation of the serialization function - - This function is called by the public member function dump and organizes - the serialization internally. The indentation level is propagated as - additional parameter. In case of arrays and objects, the function is - called recursively. - - - strings and object keys are escaped using `escape_string()` - - integer numbers are converted implicitly via `operator<<` - - floating-point numbers are converted to a string using `"%g"` format - - binary values are serialized as objects containing the subtype and the - byte array - - @param[in] val value to serialize - @param[in] pretty_print whether the output shall be pretty-printed - @param[in] ensure_ascii If @a ensure_ascii is true, all non-ASCII characters - in the output are escaped with `\uXXXX` sequences, and the result consists - of ASCII characters only. - @param[in] indent_step the indent level - @param[in] current_indent the current indent level (only used internally) - */ - void dump(const BasicJsonType& val, - const bool pretty_print, - const bool ensure_ascii, - const unsigned int indent_step, - const unsigned int current_indent = 0) - { - switch (val.m_type) - { - case value_t::object: - { - if (val.m_value.object->empty()) - { - o->write_characters("{}", 2); - return; - } - - if (pretty_print) - { - o->write_characters("{\n", 2); - - // variable to hold indentation for recursive calls - const auto new_indent = current_indent + indent_step; - if (JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent)) - { - indent_string.resize(indent_string.size() * 2, ' '); - } - - // first n-1 elements - auto i = val.m_value.object->cbegin(); - for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i) - { - o->write_characters(indent_string.c_str(), new_indent); - o->write_character('\"'); - dump_escaped(i->first, ensure_ascii); - o->write_characters("\": ", 3); - dump(i->second, true, ensure_ascii, indent_step, new_indent); - o->write_characters(",\n", 2); - } - - // last element - JSON_ASSERT(i != val.m_value.object->cend()); - JSON_ASSERT(std::next(i) == val.m_value.object->cend()); - o->write_characters(indent_string.c_str(), new_indent); - o->write_character('\"'); - dump_escaped(i->first, ensure_ascii); - o->write_characters("\": ", 3); - dump(i->second, true, ensure_ascii, indent_step, new_indent); - - o->write_character('\n'); - o->write_characters(indent_string.c_str(), current_indent); - o->write_character('}'); - } - else - { - o->write_character('{'); - - // first n-1 elements - auto i = val.m_value.object->cbegin(); - for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i) - { - o->write_character('\"'); - dump_escaped(i->first, ensure_ascii); - o->write_characters("\":", 2); - dump(i->second, false, ensure_ascii, indent_step, current_indent); - o->write_character(','); - } - - // last element - JSON_ASSERT(i != val.m_value.object->cend()); - JSON_ASSERT(std::next(i) == val.m_value.object->cend()); - o->write_character('\"'); - dump_escaped(i->first, ensure_ascii); - o->write_characters("\":", 2); - dump(i->second, false, ensure_ascii, indent_step, current_indent); - - o->write_character('}'); - } - - return; - } - - case value_t::array: - { - if (val.m_value.array->empty()) - { - o->write_characters("[]", 2); - return; - } - - if (pretty_print) - { - o->write_characters("[\n", 2); - - // variable to hold indentation for recursive calls - const auto new_indent = current_indent + indent_step; - if (JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent)) - { - indent_string.resize(indent_string.size() * 2, ' '); - } - - // first n-1 elements - for (auto i = val.m_value.array->cbegin(); - i != val.m_value.array->cend() - 1; ++i) - { - o->write_characters(indent_string.c_str(), new_indent); - dump(*i, true, ensure_ascii, indent_step, new_indent); - o->write_characters(",\n", 2); - } - - // last element - JSON_ASSERT(!val.m_value.array->empty()); - o->write_characters(indent_string.c_str(), new_indent); - dump(val.m_value.array->back(), true, ensure_ascii, indent_step, new_indent); - - o->write_character('\n'); - o->write_characters(indent_string.c_str(), current_indent); - o->write_character(']'); - } - else - { - o->write_character('['); - - // first n-1 elements - for (auto i = val.m_value.array->cbegin(); - i != val.m_value.array->cend() - 1; ++i) - { - dump(*i, false, ensure_ascii, indent_step, current_indent); - o->write_character(','); - } - - // last element - JSON_ASSERT(!val.m_value.array->empty()); - dump(val.m_value.array->back(), false, ensure_ascii, indent_step, current_indent); - - o->write_character(']'); - } - - return; - } - - case value_t::string: - { - o->write_character('\"'); - dump_escaped(*val.m_value.string, ensure_ascii); - o->write_character('\"'); - return; - } - - case value_t::binary: - { - if (pretty_print) - { - o->write_characters("{\n", 2); - - // variable to hold indentation for recursive calls - const auto new_indent = current_indent + indent_step; - if (JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent)) - { - indent_string.resize(indent_string.size() * 2, ' '); - } - - o->write_characters(indent_string.c_str(), new_indent); - - o->write_characters("\"bytes\": [", 10); - - if (!val.m_value.binary->empty()) - { - for (auto i = val.m_value.binary->cbegin(); - i != val.m_value.binary->cend() - 1; ++i) - { - dump_integer(*i); - o->write_characters(", ", 2); - } - dump_integer(val.m_value.binary->back()); - } - - o->write_characters("],\n", 3); - o->write_characters(indent_string.c_str(), new_indent); - - o->write_characters("\"subtype\": ", 11); - if (val.m_value.binary->has_subtype()) - { - dump_integer(val.m_value.binary->subtype()); - } - else - { - o->write_characters("null", 4); - } - o->write_character('\n'); - o->write_characters(indent_string.c_str(), current_indent); - o->write_character('}'); - } - else - { - o->write_characters("{\"bytes\":[", 10); - - if (!val.m_value.binary->empty()) - { - for (auto i = val.m_value.binary->cbegin(); - i != val.m_value.binary->cend() - 1; ++i) - { - dump_integer(*i); - o->write_character(','); - } - dump_integer(val.m_value.binary->back()); - } - - o->write_characters("],\"subtype\":", 12); - if (val.m_value.binary->has_subtype()) - { - dump_integer(val.m_value.binary->subtype()); - o->write_character('}'); - } - else - { - o->write_characters("null}", 5); - } - } - return; - } - - case value_t::boolean: - { - if (val.m_value.boolean) - { - o->write_characters("true", 4); - } - else - { - o->write_characters("false", 5); - } - return; - } - - case value_t::number_integer: - { - dump_integer(val.m_value.number_integer); - return; - } - - case value_t::number_unsigned: - { - dump_integer(val.m_value.number_unsigned); - return; - } - - case value_t::number_float: - { - dump_float(val.m_value.number_float); - return; - } - - case value_t::discarded: - { - o->write_characters("", 11); - return; - } - - case value_t::null: - { - o->write_characters("null", 4); - return; - } - - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE - } - } - - JSON_PRIVATE_UNLESS_TESTED: - /*! - @brief dump escaped string - - Escape a string by replacing certain special characters by a sequence of an - escape character (backslash) and another character and other control - characters by a sequence of "\u" followed by a four-digit hex - representation. The escaped string is written to output stream @a o. - - @param[in] s the string to escape - @param[in] ensure_ascii whether to escape non-ASCII characters with - \uXXXX sequences - - @complexity Linear in the length of string @a s. - */ - void dump_escaped(const string_t& s, const bool ensure_ascii) - { - std::uint32_t codepoint{}; - std::uint8_t state = UTF8_ACCEPT; - std::size_t bytes = 0; // number of bytes written to string_buffer - - // number of bytes written at the point of the last valid byte - std::size_t bytes_after_last_accept = 0; - std::size_t undumped_chars = 0; - - for (std::size_t i = 0; i < s.size(); ++i) - { - const auto byte = static_cast(s[i]); - - switch (decode(state, codepoint, byte)) - { - case UTF8_ACCEPT: // decode found a new code point - { - switch (codepoint) - { - case 0x08: // backspace - { - string_buffer[bytes++] = '\\'; - string_buffer[bytes++] = 'b'; - break; - } - - case 0x09: // horizontal tab - { - string_buffer[bytes++] = '\\'; - string_buffer[bytes++] = 't'; - break; - } - - case 0x0A: // newline - { - string_buffer[bytes++] = '\\'; - string_buffer[bytes++] = 'n'; - break; - } - - case 0x0C: // formfeed - { - string_buffer[bytes++] = '\\'; - string_buffer[bytes++] = 'f'; - break; - } - - case 0x0D: // carriage return - { - string_buffer[bytes++] = '\\'; - string_buffer[bytes++] = 'r'; - break; - } - - case 0x22: // quotation mark - { - string_buffer[bytes++] = '\\'; - string_buffer[bytes++] = '\"'; - break; - } - - case 0x5C: // reverse solidus - { - string_buffer[bytes++] = '\\'; - string_buffer[bytes++] = '\\'; - break; - } - - default: - { - // escape control characters (0x00..0x1F) or, if - // ensure_ascii parameter is used, non-ASCII characters - if ((codepoint <= 0x1F) || (ensure_ascii && (codepoint >= 0x7F))) - { - if (codepoint <= 0xFFFF) - { - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg) - (std::snprintf)(string_buffer.data() + bytes, 7, "\\u%04x", - static_cast(codepoint)); - bytes += 6; - } - else - { - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg) - (std::snprintf)(string_buffer.data() + bytes, 13, "\\u%04x\\u%04x", - static_cast(0xD7C0u + (codepoint >> 10u)), - static_cast(0xDC00u + (codepoint & 0x3FFu))); - bytes += 12; - } - } - else - { - // copy byte to buffer (all previous bytes - // been copied have in default case above) - string_buffer[bytes++] = s[i]; - } - break; - } - } - - // write buffer and reset index; there must be 13 bytes - // left, as this is the maximal number of bytes to be - // written ("\uxxxx\uxxxx\0") for one code point - if (string_buffer.size() - bytes < 13) - { - o->write_characters(string_buffer.data(), bytes); - bytes = 0; - } - - // remember the byte position of this accept - bytes_after_last_accept = bytes; - undumped_chars = 0; - break; - } - - case UTF8_REJECT: // decode found invalid UTF-8 byte - { - switch (error_handler) - { - case error_handler_t::strict: - { - std::stringstream ss; - ss << std::uppercase << std::setfill('0') << std::setw(2) << std::hex << (byte | 0); - JSON_THROW(type_error::create(316, "invalid UTF-8 byte at index " + std::to_string(i) + ": 0x" + ss.str(), BasicJsonType())); - } - - case error_handler_t::ignore: - case error_handler_t::replace: - { - // in case we saw this character the first time, we - // would like to read it again, because the byte - // may be OK for itself, but just not OK for the - // previous sequence - if (undumped_chars > 0) - { - --i; - } - - // reset length buffer to the last accepted index; - // thus removing/ignoring the invalid characters - bytes = bytes_after_last_accept; - - if (error_handler == error_handler_t::replace) - { - // add a replacement character - if (ensure_ascii) - { - string_buffer[bytes++] = '\\'; - string_buffer[bytes++] = 'u'; - string_buffer[bytes++] = 'f'; - string_buffer[bytes++] = 'f'; - string_buffer[bytes++] = 'f'; - string_buffer[bytes++] = 'd'; - } - else - { - string_buffer[bytes++] = detail::binary_writer::to_char_type('\xEF'); - string_buffer[bytes++] = detail::binary_writer::to_char_type('\xBF'); - string_buffer[bytes++] = detail::binary_writer::to_char_type('\xBD'); - } - - // write buffer and reset index; there must be 13 bytes - // left, as this is the maximal number of bytes to be - // written ("\uxxxx\uxxxx\0") for one code point - if (string_buffer.size() - bytes < 13) - { - o->write_characters(string_buffer.data(), bytes); - bytes = 0; - } - - bytes_after_last_accept = bytes; - } - - undumped_chars = 0; - - // continue processing the string - state = UTF8_ACCEPT; - break; - } - - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE - } - break; - } - - default: // decode found yet incomplete multi-byte code point - { - if (!ensure_ascii) - { - // code point will not be escaped - copy byte to buffer - string_buffer[bytes++] = s[i]; - } - ++undumped_chars; - break; - } - } - } - - // we finished processing the string - if (JSON_HEDLEY_LIKELY(state == UTF8_ACCEPT)) - { - // write buffer - if (bytes > 0) - { - o->write_characters(string_buffer.data(), bytes); - } - } - else - { - // we finish reading, but do not accept: string was incomplete - switch (error_handler) - { - case error_handler_t::strict: - { - std::stringstream ss; - ss << std::uppercase << std::setfill('0') << std::setw(2) << std::hex << (static_cast(s.back()) | 0); - JSON_THROW(type_error::create(316, "incomplete UTF-8 string; last byte: 0x" + ss.str(), BasicJsonType())); - } - - case error_handler_t::ignore: - { - // write all accepted bytes - o->write_characters(string_buffer.data(), bytes_after_last_accept); - break; - } - - case error_handler_t::replace: - { - // write all accepted bytes - o->write_characters(string_buffer.data(), bytes_after_last_accept); - // add a replacement character - if (ensure_ascii) - { - o->write_characters("\\ufffd", 6); - } - else - { - o->write_characters("\xEF\xBF\xBD", 3); - } - break; - } - - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE - } - } - } - - private: - /*! - @brief count digits - - Count the number of decimal (base 10) digits for an input unsigned integer. - - @param[in] x unsigned integer number to count its digits - @return number of decimal digits - */ - inline unsigned int count_digits(number_unsigned_t x) noexcept - { - unsigned int n_digits = 1; - for (;;) - { - if (x < 10) - { - return n_digits; - } - if (x < 100) - { - return n_digits + 1; - } - if (x < 1000) - { - return n_digits + 2; - } - if (x < 10000) - { - return n_digits + 3; - } - x = x / 10000u; - n_digits += 4; - } - } - - /*! - @brief dump an integer - - Dump a given integer to output stream @a o. Works internally with - @a number_buffer. - - @param[in] x integer number (signed or unsigned) to dump - @tparam NumberType either @a number_integer_t or @a number_unsigned_t - */ - template < typename NumberType, detail::enable_if_t < - std::is_integral::value || - std::is_same::value || - std::is_same::value || - std::is_same::value, - int > = 0 > - void dump_integer(NumberType x) - { - static constexpr std::array, 100> digits_to_99 - { - { - {{'0', '0'}}, {{'0', '1'}}, {{'0', '2'}}, {{'0', '3'}}, {{'0', '4'}}, {{'0', '5'}}, {{'0', '6'}}, {{'0', '7'}}, {{'0', '8'}}, {{'0', '9'}}, - {{'1', '0'}}, {{'1', '1'}}, {{'1', '2'}}, {{'1', '3'}}, {{'1', '4'}}, {{'1', '5'}}, {{'1', '6'}}, {{'1', '7'}}, {{'1', '8'}}, {{'1', '9'}}, - {{'2', '0'}}, {{'2', '1'}}, {{'2', '2'}}, {{'2', '3'}}, {{'2', '4'}}, {{'2', '5'}}, {{'2', '6'}}, {{'2', '7'}}, {{'2', '8'}}, {{'2', '9'}}, - {{'3', '0'}}, {{'3', '1'}}, {{'3', '2'}}, {{'3', '3'}}, {{'3', '4'}}, {{'3', '5'}}, {{'3', '6'}}, {{'3', '7'}}, {{'3', '8'}}, {{'3', '9'}}, - {{'4', '0'}}, {{'4', '1'}}, {{'4', '2'}}, {{'4', '3'}}, {{'4', '4'}}, {{'4', '5'}}, {{'4', '6'}}, {{'4', '7'}}, {{'4', '8'}}, {{'4', '9'}}, - {{'5', '0'}}, {{'5', '1'}}, {{'5', '2'}}, {{'5', '3'}}, {{'5', '4'}}, {{'5', '5'}}, {{'5', '6'}}, {{'5', '7'}}, {{'5', '8'}}, {{'5', '9'}}, - {{'6', '0'}}, {{'6', '1'}}, {{'6', '2'}}, {{'6', '3'}}, {{'6', '4'}}, {{'6', '5'}}, {{'6', '6'}}, {{'6', '7'}}, {{'6', '8'}}, {{'6', '9'}}, - {{'7', '0'}}, {{'7', '1'}}, {{'7', '2'}}, {{'7', '3'}}, {{'7', '4'}}, {{'7', '5'}}, {{'7', '6'}}, {{'7', '7'}}, {{'7', '8'}}, {{'7', '9'}}, - {{'8', '0'}}, {{'8', '1'}}, {{'8', '2'}}, {{'8', '3'}}, {{'8', '4'}}, {{'8', '5'}}, {{'8', '6'}}, {{'8', '7'}}, {{'8', '8'}}, {{'8', '9'}}, - {{'9', '0'}}, {{'9', '1'}}, {{'9', '2'}}, {{'9', '3'}}, {{'9', '4'}}, {{'9', '5'}}, {{'9', '6'}}, {{'9', '7'}}, {{'9', '8'}}, {{'9', '9'}}, - } - }; - - // special case for "0" - if (x == 0) - { - o->write_character('0'); - return; - } - - // use a pointer to fill the buffer - auto buffer_ptr = number_buffer.begin(); // NOLINT(llvm-qualified-auto,readability-qualified-auto,cppcoreguidelines-pro-type-vararg,hicpp-vararg) - - const bool is_negative = std::is_signed::value && !(x >= 0); // see issue #755 - number_unsigned_t abs_value; - - unsigned int n_chars{}; - - if (is_negative) - { - *buffer_ptr = '-'; - abs_value = remove_sign(static_cast(x)); - - // account one more byte for the minus sign - n_chars = 1 + count_digits(abs_value); - } - else - { - abs_value = static_cast(x); - n_chars = count_digits(abs_value); - } - - // spare 1 byte for '\0' - JSON_ASSERT(n_chars < number_buffer.size() - 1); - - // jump to the end to generate the string from backward - // so we later avoid reversing the result - buffer_ptr += n_chars; - - // Fast int2ascii implementation inspired by "Fastware" talk by Andrei Alexandrescu - // See: https://www.youtube.com/watch?v=o4-CwDo2zpg - while (abs_value >= 100) - { - const auto digits_index = static_cast((abs_value % 100)); - abs_value /= 100; - *(--buffer_ptr) = digits_to_99[digits_index][1]; - *(--buffer_ptr) = digits_to_99[digits_index][0]; - } - - if (abs_value >= 10) - { - const auto digits_index = static_cast(abs_value); - *(--buffer_ptr) = digits_to_99[digits_index][1]; - *(--buffer_ptr) = digits_to_99[digits_index][0]; - } - else - { - *(--buffer_ptr) = static_cast('0' + abs_value); - } - - o->write_characters(number_buffer.data(), n_chars); - } - - /*! - @brief dump a floating-point number - - Dump a given floating-point number to output stream @a o. Works internally - with @a number_buffer. - - @param[in] x floating-point number to dump - */ - void dump_float(number_float_t x) - { - // NaN / inf - if (!std::isfinite(x)) - { - o->write_characters("null", 4); - return; - } - - // If number_float_t is an IEEE-754 single or double precision number, - // use the Grisu2 algorithm to produce short numbers which are - // guaranteed to round-trip, using strtof and strtod, resp. - // - // NB: The test below works if == . - static constexpr bool is_ieee_single_or_double - = (std::numeric_limits::is_iec559 && std::numeric_limits::digits == 24 && std::numeric_limits::max_exponent == 128) || - (std::numeric_limits::is_iec559 && std::numeric_limits::digits == 53 && std::numeric_limits::max_exponent == 1024); - - dump_float(x, std::integral_constant()); - } - - void dump_float(number_float_t x, std::true_type /*is_ieee_single_or_double*/) - { - auto* begin = number_buffer.data(); - auto* end = ::nlohmann::detail::to_chars(begin, begin + number_buffer.size(), x); - - o->write_characters(begin, static_cast(end - begin)); - } - - void dump_float(number_float_t x, std::false_type /*is_ieee_single_or_double*/) - { - // get number of digits for a float -> text -> float round-trip - static constexpr auto d = std::numeric_limits::max_digits10; - - // the actual conversion - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg) - std::ptrdiff_t len = (std::snprintf)(number_buffer.data(), number_buffer.size(), "%.*g", d, x); - - // negative value indicates an error - JSON_ASSERT(len > 0); - // check if buffer was large enough - JSON_ASSERT(static_cast(len) < number_buffer.size()); - - // erase thousands separator - if (thousands_sep != '\0') - { - // NOLINTNEXTLINE(readability-qualified-auto,llvm-qualified-auto): std::remove returns an iterator, see https://github.com/nlohmann/json/issues/3081 - const auto end = std::remove(number_buffer.begin(), number_buffer.begin() + len, thousands_sep); - std::fill(end, number_buffer.end(), '\0'); - JSON_ASSERT((end - number_buffer.begin()) <= len); - len = (end - number_buffer.begin()); - } - - // convert decimal point to '.' - if (decimal_point != '\0' && decimal_point != '.') - { - // NOLINTNEXTLINE(readability-qualified-auto,llvm-qualified-auto): std::find returns an iterator, see https://github.com/nlohmann/json/issues/3081 - const auto dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point); - if (dec_pos != number_buffer.end()) - { - *dec_pos = '.'; - } - } - - o->write_characters(number_buffer.data(), static_cast(len)); - - // determine if need to append ".0" - const bool value_is_int_like = - std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1, - [](char c) - { - return c == '.' || c == 'e'; - }); - - if (value_is_int_like) - { - o->write_characters(".0", 2); - } - } - - /*! - @brief check whether a string is UTF-8 encoded - - The function checks each byte of a string whether it is UTF-8 encoded. The - result of the check is stored in the @a state parameter. The function must - be called initially with state 0 (accept). State 1 means the string must - be rejected, because the current byte is not allowed. If the string is - completely processed, but the state is non-zero, the string ended - prematurely; that is, the last byte indicated more bytes should have - followed. - - @param[in,out] state the state of the decoding - @param[in,out] codep codepoint (valid only if resulting state is UTF8_ACCEPT) - @param[in] byte next byte to decode - @return new state - - @note The function has been edited: a std::array is used. - - @copyright Copyright (c) 2008-2009 Bjoern Hoehrmann - @sa http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ - */ - static std::uint8_t decode(std::uint8_t& state, std::uint32_t& codep, const std::uint8_t byte) noexcept - { - static const std::array utf8d = - { - { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 00..1F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 20..3F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 40..5F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 60..7F - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, // 80..9F - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // A0..BF - 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // C0..DF - 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3, // E0..EF - 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, // F0..FF - 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1, // s0..s0 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, // s1..s2 - 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, // s3..s4 - 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, // s5..s6 - 1, 3, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // s7..s8 - } - }; - - JSON_ASSERT(byte < utf8d.size()); - const std::uint8_t type = utf8d[byte]; - - codep = (state != UTF8_ACCEPT) - ? (byte & 0x3fu) | (codep << 6u) - : (0xFFu >> type) & (byte); - - std::size_t index = 256u + static_cast(state) * 16u + static_cast(type); - JSON_ASSERT(index < 400); - state = utf8d[index]; - return state; - } - - /* - * Overload to make the compiler happy while it is instantiating - * dump_integer for number_unsigned_t. - * Must never be called. - */ - number_unsigned_t remove_sign(number_unsigned_t x) - { - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE - return x; // LCOV_EXCL_LINE - } - - /* - * Helper function for dump_integer - * - * This function takes a negative signed integer and returns its absolute - * value as unsigned integer. The plus/minus shuffling is necessary as we can - * not directly remove the sign of an arbitrary signed integer as the - * absolute values of INT_MIN and INT_MAX are usually not the same. See - * #1708 for details. - */ - inline number_unsigned_t remove_sign(number_integer_t x) noexcept - { - JSON_ASSERT(x < 0 && x < (std::numeric_limits::max)()); // NOLINT(misc-redundant-expression) - return static_cast(-(x + 1)) + 1; - } - - private: - /// the output of the serializer - output_adapter_t o = nullptr; - - /// a (hopefully) large enough character buffer - std::array number_buffer{{}}; - - /// the locale - const std::lconv* loc = nullptr; - /// the locale's thousand separator character - const char thousands_sep = '\0'; - /// the locale's decimal point character - const char decimal_point = '\0'; - - /// string buffer - std::array string_buffer{{}}; - - /// the indentation character - const char indent_char; - /// the indentation string - string_t indent_string; - - /// error_handler how to react on decoding errors - const error_handler_t error_handler; -}; -} // namespace detail -} // namespace nlohmann - -// #include - -// #include - -// #include - - -#include // less -#include // initializer_list -#include // input_iterator_tag, iterator_traits -#include // allocator -#include // for out_of_range -#include // enable_if, is_convertible -#include // pair -#include // vector - -// #include - - -namespace nlohmann -{ - -/// ordered_map: a minimal map-like container that preserves insertion order -/// for use within nlohmann::basic_json -template , - class Allocator = std::allocator>> - struct ordered_map : std::vector, Allocator> -{ - using key_type = Key; - using mapped_type = T; - using Container = std::vector, Allocator>; - using typename Container::iterator; - using typename Container::const_iterator; - using typename Container::size_type; - using typename Container::value_type; - - // Explicit constructors instead of `using Container::Container` - // otherwise older compilers choke on it (GCC <= 5.5, xcode <= 9.4) - ordered_map(const Allocator& alloc = Allocator()) : Container{alloc} {} - template - ordered_map(It first, It last, const Allocator& alloc = Allocator()) - : Container{first, last, alloc} {} - ordered_map(std::initializer_list init, const Allocator& alloc = Allocator() ) - : Container{init, alloc} {} - - std::pair emplace(const key_type& key, T&& t) - { - for (auto it = this->begin(); it != this->end(); ++it) - { - if (it->first == key) - { - return {it, false}; - } - } - Container::emplace_back(key, t); - return {--this->end(), true}; - } - - T& operator[](const Key& key) - { - return emplace(key, T{}).first->second; - } - - const T& operator[](const Key& key) const - { - return at(key); - } - - T& at(const Key& key) - { - for (auto it = this->begin(); it != this->end(); ++it) - { - if (it->first == key) - { - return it->second; - } - } - - JSON_THROW(std::out_of_range("key not found")); - } - - const T& at(const Key& key) const - { - for (auto it = this->begin(); it != this->end(); ++it) - { - if (it->first == key) - { - return it->second; - } - } - - JSON_THROW(std::out_of_range("key not found")); - } - - size_type erase(const Key& key) - { - for (auto it = this->begin(); it != this->end(); ++it) - { - if (it->first == key) - { - // Since we cannot move const Keys, re-construct them in place - for (auto next = it; ++next != this->end(); ++it) - { - it->~value_type(); // Destroy but keep allocation - new (&*it) value_type{std::move(*next)}; - } - Container::pop_back(); - return 1; - } - } - return 0; - } - - iterator erase(iterator pos) - { - auto it = pos; - - // Since we cannot move const Keys, re-construct them in place - for (auto next = it; ++next != this->end(); ++it) - { - it->~value_type(); // Destroy but keep allocation - new (&*it) value_type{std::move(*next)}; - } - Container::pop_back(); - return pos; - } - - size_type count(const Key& key) const - { - for (auto it = this->begin(); it != this->end(); ++it) - { - if (it->first == key) - { - return 1; - } - } - return 0; - } - - iterator find(const Key& key) - { - for (auto it = this->begin(); it != this->end(); ++it) - { - if (it->first == key) - { - return it; - } - } - return Container::end(); - } - - const_iterator find(const Key& key) const - { - for (auto it = this->begin(); it != this->end(); ++it) - { - if (it->first == key) - { - return it; - } - } - return Container::end(); - } - - std::pair insert( value_type&& value ) - { - return emplace(value.first, std::move(value.second)); - } - - std::pair insert( const value_type& value ) - { - for (auto it = this->begin(); it != this->end(); ++it) - { - if (it->first == value.first) - { - return {it, false}; - } - } - Container::push_back(value); - return {--this->end(), true}; - } - - template - using require_input_iter = typename std::enable_if::iterator_category, - std::input_iterator_tag>::value>::type; - - template> - void insert(InputIt first, InputIt last) - { - for (auto it = first; it != last; ++it) - { - insert(*it); - } - } -}; - -} // namespace nlohmann - - -#if defined(JSON_HAS_CPP_17) - #include -#endif - -/*! -@brief namespace for Niels Lohmann -@see https://github.com/nlohmann -@since version 1.0.0 -*/ -namespace nlohmann -{ - -/*! -@brief a class to store JSON values - -@tparam ObjectType type for JSON objects (`std::map` by default; will be used -in @ref object_t) -@tparam ArrayType type for JSON arrays (`std::vector` by default; will be used -in @ref array_t) -@tparam StringType type for JSON strings and object keys (`std::string` by -default; will be used in @ref string_t) -@tparam BooleanType type for JSON booleans (`bool` by default; will be used -in @ref boolean_t) -@tparam NumberIntegerType type for JSON integer numbers (`int64_t` by -default; will be used in @ref number_integer_t) -@tparam NumberUnsignedType type for JSON unsigned integer numbers (@c -`uint64_t` by default; will be used in @ref number_unsigned_t) -@tparam NumberFloatType type for JSON floating-point numbers (`double` by -default; will be used in @ref number_float_t) -@tparam BinaryType type for packed binary data for compatibility with binary -serialization formats (`std::vector` by default; will be used in -@ref binary_t) -@tparam AllocatorType type of the allocator to use (`std::allocator` by -default) -@tparam JSONSerializer the serializer to resolve internal calls to `to_json()` -and `from_json()` (@ref adl_serializer by default) - -@requirement The class satisfies the following concept requirements: -- Basic - - [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible): - JSON values can be default constructed. The result will be a JSON null - value. - - [MoveConstructible](https://en.cppreference.com/w/cpp/named_req/MoveConstructible): - A JSON value can be constructed from an rvalue argument. - - [CopyConstructible](https://en.cppreference.com/w/cpp/named_req/CopyConstructible): - A JSON value can be copy-constructed from an lvalue expression. - - [MoveAssignable](https://en.cppreference.com/w/cpp/named_req/MoveAssignable): - A JSON value van be assigned from an rvalue argument. - - [CopyAssignable](https://en.cppreference.com/w/cpp/named_req/CopyAssignable): - A JSON value can be copy-assigned from an lvalue expression. - - [Destructible](https://en.cppreference.com/w/cpp/named_req/Destructible): - JSON values can be destructed. -- Layout - - [StandardLayoutType](https://en.cppreference.com/w/cpp/named_req/StandardLayoutType): - JSON values have - [standard layout](https://en.cppreference.com/w/cpp/language/data_members#Standard_layout): - All non-static data members are private and standard layout types, the - class has no virtual functions or (virtual) base classes. -- Library-wide - - [EqualityComparable](https://en.cppreference.com/w/cpp/named_req/EqualityComparable): - JSON values can be compared with `==`, see @ref - operator==(const_reference,const_reference). - - [LessThanComparable](https://en.cppreference.com/w/cpp/named_req/LessThanComparable): - JSON values can be compared with `<`, see @ref - operator<(const_reference,const_reference). - - [Swappable](https://en.cppreference.com/w/cpp/named_req/Swappable): - Any JSON lvalue or rvalue of can be swapped with any lvalue or rvalue of - other compatible types, using unqualified function call @ref swap(). - - [NullablePointer](https://en.cppreference.com/w/cpp/named_req/NullablePointer): - JSON values can be compared against `std::nullptr_t` objects which are used - to model the `null` value. -- Container - - [Container](https://en.cppreference.com/w/cpp/named_req/Container): - JSON values can be used like STL containers and provide iterator access. - - [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer); - JSON values can be used like STL containers and provide reverse iterator - access. - -@invariant The member variables @a m_value and @a m_type have the following -relationship: -- If `m_type == value_t::object`, then `m_value.object != nullptr`. -- If `m_type == value_t::array`, then `m_value.array != nullptr`. -- If `m_type == value_t::string`, then `m_value.string != nullptr`. -The invariants are checked by member function assert_invariant(). - -@internal -@note ObjectType trick from https://stackoverflow.com/a/9860911 -@endinternal - -@see [RFC 8259: The JavaScript Object Notation (JSON) Data Interchange -Format](https://tools.ietf.org/html/rfc8259) - -@since version 1.0.0 - -@nosubgrouping -*/ -NLOHMANN_BASIC_JSON_TPL_DECLARATION -class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-special-member-functions) -{ - private: - template friend struct detail::external_constructor; - friend ::nlohmann::json_pointer; - - template - friend class ::nlohmann::detail::parser; - friend ::nlohmann::detail::serializer; - template - friend class ::nlohmann::detail::iter_impl; - template - friend class ::nlohmann::detail::binary_writer; - template - friend class ::nlohmann::detail::binary_reader; - template - friend class ::nlohmann::detail::json_sax_dom_parser; - template - friend class ::nlohmann::detail::json_sax_dom_callback_parser; - friend class ::nlohmann::detail::exception; - - /// workaround type for MSVC - using basic_json_t = NLOHMANN_BASIC_JSON_TPL; - - JSON_PRIVATE_UNLESS_TESTED: - // convenience aliases for types residing in namespace detail; - using lexer = ::nlohmann::detail::lexer_base; - - template - static ::nlohmann::detail::parser parser( - InputAdapterType adapter, - detail::parser_callback_tcb = nullptr, - const bool allow_exceptions = true, - const bool ignore_comments = false - ) - { - return ::nlohmann::detail::parser(std::move(adapter), - std::move(cb), allow_exceptions, ignore_comments); - } - - private: - using primitive_iterator_t = ::nlohmann::detail::primitive_iterator_t; - template - using internal_iterator = ::nlohmann::detail::internal_iterator; - template - using iter_impl = ::nlohmann::detail::iter_impl; - template - using iteration_proxy = ::nlohmann::detail::iteration_proxy; - template using json_reverse_iterator = ::nlohmann::detail::json_reverse_iterator; - - template - using output_adapter_t = ::nlohmann::detail::output_adapter_t; - - template - using binary_reader = ::nlohmann::detail::binary_reader; - template using binary_writer = ::nlohmann::detail::binary_writer; - - JSON_PRIVATE_UNLESS_TESTED: - using serializer = ::nlohmann::detail::serializer; - - public: - using value_t = detail::value_t; - /// JSON Pointer, see @ref nlohmann::json_pointer - using json_pointer = ::nlohmann::json_pointer; - template - using json_serializer = JSONSerializer; - /// how to treat decoding errors - using error_handler_t = detail::error_handler_t; - /// how to treat CBOR tags - using cbor_tag_handler_t = detail::cbor_tag_handler_t; - /// helper type for initializer lists of basic_json values - using initializer_list_t = std::initializer_list>; - - using input_format_t = detail::input_format_t; - /// SAX interface type, see @ref nlohmann::json_sax - using json_sax_t = json_sax; - - //////////////// - // exceptions // - //////////////// - - /// @name exceptions - /// Classes to implement user-defined exceptions. - /// @{ - - /// @copydoc detail::exception - using exception = detail::exception; - /// @copydoc detail::parse_error - using parse_error = detail::parse_error; - /// @copydoc detail::invalid_iterator - using invalid_iterator = detail::invalid_iterator; - /// @copydoc detail::type_error - using type_error = detail::type_error; - /// @copydoc detail::out_of_range - using out_of_range = detail::out_of_range; - /// @copydoc detail::other_error - using other_error = detail::other_error; - - /// @} - - - ///////////////////// - // container types // - ///////////////////// - - /// @name container types - /// The canonic container types to use @ref basic_json like any other STL - /// container. - /// @{ - - /// the type of elements in a basic_json container - using value_type = basic_json; - - /// the type of an element reference - using reference = value_type&; - /// the type of an element const reference - using const_reference = const value_type&; - - /// a type to represent differences between iterators - using difference_type = std::ptrdiff_t; - /// a type to represent container sizes - using size_type = std::size_t; - - /// the allocator type - using allocator_type = AllocatorType; - - /// the type of an element pointer - using pointer = typename std::allocator_traits::pointer; - /// the type of an element const pointer - using const_pointer = typename std::allocator_traits::const_pointer; - - /// an iterator for a basic_json container - using iterator = iter_impl; - /// a const iterator for a basic_json container - using const_iterator = iter_impl; - /// a reverse iterator for a basic_json container - using reverse_iterator = json_reverse_iterator; - /// a const reverse iterator for a basic_json container - using const_reverse_iterator = json_reverse_iterator; - - /// @} - - - /*! - @brief returns the allocator associated with the container - */ - static allocator_type get_allocator() - { - return allocator_type(); - } - - /*! - @brief returns version information on the library - - This function returns a JSON object with information about the library, - including the version number and information on the platform and compiler. - - @return JSON object holding version information - key | description - ----------- | --------------- - `compiler` | Information on the used compiler. It is an object with the following keys: `c++` (the used C++ standard), `family` (the compiler family; possible values are `clang`, `icc`, `gcc`, `ilecpp`, `msvc`, `pgcpp`, `sunpro`, and `unknown`), and `version` (the compiler version). - `copyright` | The copyright line for the library as string. - `name` | The name of the library as string. - `platform` | The used platform as string. Possible values are `win32`, `linux`, `apple`, `unix`, and `unknown`. - `url` | The URL of the project as string. - `version` | The version of the library. It is an object with the following keys: `major`, `minor`, and `patch` as defined by [Semantic Versioning](http://semver.org), and `string` (the version string). - - @liveexample{The following code shows an example output of the `meta()` - function.,meta} - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes to any JSON value. - - @complexity Constant. - - @since 2.1.0 - */ - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json meta() - { - basic_json result; - - result["copyright"] = "(C) 2013-2021 Niels Lohmann"; - result["name"] = "JSON for Modern C++"; - result["url"] = "https://github.com/nlohmann/json"; - result["version"]["string"] = - std::to_string(NLOHMANN_JSON_VERSION_MAJOR) + "." + - std::to_string(NLOHMANN_JSON_VERSION_MINOR) + "." + - std::to_string(NLOHMANN_JSON_VERSION_PATCH); - result["version"]["major"] = NLOHMANN_JSON_VERSION_MAJOR; - result["version"]["minor"] = NLOHMANN_JSON_VERSION_MINOR; - result["version"]["patch"] = NLOHMANN_JSON_VERSION_PATCH; - -#ifdef _WIN32 - result["platform"] = "win32"; -#elif defined __linux__ - result["platform"] = "linux"; -#elif defined __APPLE__ - result["platform"] = "apple"; -#elif defined __unix__ - result["platform"] = "unix"; -#else - result["platform"] = "unknown"; -#endif - -#if defined(__ICC) || defined(__INTEL_COMPILER) - result["compiler"] = {{"family", "icc"}, {"version", __INTEL_COMPILER}}; -#elif defined(__clang__) - result["compiler"] = {{"family", "clang"}, {"version", __clang_version__}}; -#elif defined(__GNUC__) || defined(__GNUG__) - result["compiler"] = {{"family", "gcc"}, {"version", std::to_string(__GNUC__) + "." + std::to_string(__GNUC_MINOR__) + "." + std::to_string(__GNUC_PATCHLEVEL__)}}; -#elif defined(__HP_cc) || defined(__HP_aCC) - result["compiler"] = "hp" -#elif defined(__IBMCPP__) - result["compiler"] = {{"family", "ilecpp"}, {"version", __IBMCPP__}}; -#elif defined(_MSC_VER) - result["compiler"] = {{"family", "msvc"}, {"version", _MSC_VER}}; -#elif defined(__PGI) - result["compiler"] = {{"family", "pgcpp"}, {"version", __PGI}}; -#elif defined(__SUNPRO_CC) - result["compiler"] = {{"family", "sunpro"}, {"version", __SUNPRO_CC}}; -#else - result["compiler"] = {{"family", "unknown"}, {"version", "unknown"}}; -#endif - -#ifdef __cplusplus - result["compiler"]["c++"] = std::to_string(__cplusplus); -#else - result["compiler"]["c++"] = "unknown"; -#endif - return result; - } - - - /////////////////////////// - // JSON value data types // - /////////////////////////// - - /// @name JSON value data types - /// The data types to store a JSON value. These types are derived from - /// the template arguments passed to class @ref basic_json. - /// @{ - -#if defined(JSON_HAS_CPP_14) - // Use transparent comparator if possible, combined with perfect forwarding - // on find() and count() calls prevents unnecessary string construction. - using object_comparator_t = std::less<>; -#else - using object_comparator_t = std::less; -#endif - - /*! - @brief a type for an object - - [RFC 8259](https://tools.ietf.org/html/rfc8259) describes JSON objects as follows: - > An object is an unordered collection of zero or more name/value pairs, - > where a name is a string and a value is a string, number, boolean, null, - > object, or array. - - To store objects in C++, a type is defined by the template parameters - described below. - - @tparam ObjectType the container to store objects (e.g., `std::map` or - `std::unordered_map`) - @tparam StringType the type of the keys or names (e.g., `std::string`). - The comparison function `std::less` is used to order elements - inside the container. - @tparam AllocatorType the allocator to use for objects (e.g., - `std::allocator`) - - #### Default type - - With the default values for @a ObjectType (`std::map`), @a StringType - (`std::string`), and @a AllocatorType (`std::allocator`), the default - value for @a object_t is: - - @code {.cpp} - std::map< - std::string, // key_type - basic_json, // value_type - std::less, // key_compare - std::allocator> // allocator_type - > - @endcode - - #### Behavior - - The choice of @a object_t influences the behavior of the JSON class. With - the default type, objects have the following behavior: - - - When all names are unique, objects will be interoperable in the sense - that all software implementations receiving that object will agree on - the name-value mappings. - - When the names within an object are not unique, it is unspecified which - one of the values for a given key will be chosen. For instance, - `{"key": 2, "key": 1}` could be equal to either `{"key": 1}` or - `{"key": 2}`. - - Internally, name/value pairs are stored in lexicographical order of the - names. Objects will also be serialized (see @ref dump) in this order. - For instance, `{"b": 1, "a": 2}` and `{"a": 2, "b": 1}` will be stored - and serialized as `{"a": 2, "b": 1}`. - - When comparing objects, the order of the name/value pairs is irrelevant. - This makes objects interoperable in the sense that they will not be - affected by these differences. For instance, `{"b": 1, "a": 2}` and - `{"a": 2, "b": 1}` will be treated as equal. - - #### Limits - - [RFC 8259](https://tools.ietf.org/html/rfc8259) specifies: - > An implementation may set limits on the maximum depth of nesting. - - In this class, the object's limit of nesting is not explicitly constrained. - However, a maximum depth of nesting may be introduced by the compiler or - runtime environment. A theoretical limit can be queried by calling the - @ref max_size function of a JSON object. - - #### Storage - - Objects are stored as pointers in a @ref basic_json type. That is, for any - access to object values, a pointer of type `object_t*` must be - dereferenced. - - @sa see @ref array_t -- type for an array value - - @since version 1.0.0 - - @note The order name/value pairs are added to the object is *not* - preserved by the library. Therefore, iterating an object may return - name/value pairs in a different order than they were originally stored. In - fact, keys will be traversed in alphabetical order as `std::map` with - `std::less` is used by default. Please note this behavior conforms to [RFC - 8259](https://tools.ietf.org/html/rfc8259), because any order implements the - specified "unordered" nature of JSON objects. - */ - using object_t = ObjectType>>; - - /*! - @brief a type for an array - - [RFC 8259](https://tools.ietf.org/html/rfc8259) describes JSON arrays as follows: - > An array is an ordered sequence of zero or more values. - - To store objects in C++, a type is defined by the template parameters - explained below. - - @tparam ArrayType container type to store arrays (e.g., `std::vector` or - `std::list`) - @tparam AllocatorType allocator to use for arrays (e.g., `std::allocator`) - - #### Default type - - With the default values for @a ArrayType (`std::vector`) and @a - AllocatorType (`std::allocator`), the default value for @a array_t is: - - @code {.cpp} - std::vector< - basic_json, // value_type - std::allocator // allocator_type - > - @endcode - - #### Limits - - [RFC 8259](https://tools.ietf.org/html/rfc8259) specifies: - > An implementation may set limits on the maximum depth of nesting. - - In this class, the array's limit of nesting is not explicitly constrained. - However, a maximum depth of nesting may be introduced by the compiler or - runtime environment. A theoretical limit can be queried by calling the - @ref max_size function of a JSON array. - - #### Storage - - Arrays are stored as pointers in a @ref basic_json type. That is, for any - access to array values, a pointer of type `array_t*` must be dereferenced. - - @sa see @ref object_t -- type for an object value - - @since version 1.0.0 - */ - using array_t = ArrayType>; - - /*! - @brief a type for a string - - [RFC 8259](https://tools.ietf.org/html/rfc8259) describes JSON strings as follows: - > A string is a sequence of zero or more Unicode characters. - - To store objects in C++, a type is defined by the template parameter - described below. Unicode values are split by the JSON class into - byte-sized characters during deserialization. - - @tparam StringType the container to store strings (e.g., `std::string`). - Note this container is used for keys/names in objects, see @ref object_t. - - #### Default type - - With the default values for @a StringType (`std::string`), the default - value for @a string_t is: - - @code {.cpp} - std::string - @endcode - - #### Encoding - - Strings are stored in UTF-8 encoding. Therefore, functions like - `std::string::size()` or `std::string::length()` return the number of - bytes in the string rather than the number of characters or glyphs. - - #### String comparison - - [RFC 8259](https://tools.ietf.org/html/rfc8259) states: - > Software implementations are typically required to test names of object - > members for equality. Implementations that transform the textual - > representation into sequences of Unicode code units and then perform the - > comparison numerically, code unit by code unit, are interoperable in the - > sense that implementations will agree in all cases on equality or - > inequality of two strings. For example, implementations that compare - > strings with escaped characters unconverted may incorrectly find that - > `"a\\b"` and `"a\u005Cb"` are not equal. - - This implementation is interoperable as it does compare strings code unit - by code unit. - - #### Storage - - String values are stored as pointers in a @ref basic_json type. That is, - for any access to string values, a pointer of type `string_t*` must be - dereferenced. - - @since version 1.0.0 - */ - using string_t = StringType; - - /*! - @brief a type for a boolean - - [RFC 8259](https://tools.ietf.org/html/rfc8259) implicitly describes a boolean as a - type which differentiates the two literals `true` and `false`. - - To store objects in C++, a type is defined by the template parameter @a - BooleanType which chooses the type to use. - - #### Default type - - With the default values for @a BooleanType (`bool`), the default value for - @a boolean_t is: - - @code {.cpp} - bool - @endcode - - #### Storage - - Boolean values are stored directly inside a @ref basic_json type. - - @since version 1.0.0 - */ - using boolean_t = BooleanType; - - /*! - @brief a type for a number (integer) - - [RFC 8259](https://tools.ietf.org/html/rfc8259) describes numbers as follows: - > The representation of numbers is similar to that used in most - > programming languages. A number is represented in base 10 using decimal - > digits. It contains an integer component that may be prefixed with an - > optional minus sign, which may be followed by a fraction part and/or an - > exponent part. Leading zeros are not allowed. (...) Numeric values that - > cannot be represented in the grammar below (such as Infinity and NaN) - > are not permitted. - - This description includes both integer and floating-point numbers. - However, C++ allows more precise storage if it is known whether the number - is a signed integer, an unsigned integer or a floating-point number. - Therefore, three different types, @ref number_integer_t, @ref - number_unsigned_t and @ref number_float_t are used. - - To store integer numbers in C++, a type is defined by the template - parameter @a NumberIntegerType which chooses the type to use. - - #### Default type - - With the default values for @a NumberIntegerType (`int64_t`), the default - value for @a number_integer_t is: - - @code {.cpp} - int64_t - @endcode - - #### Default behavior - - - The restrictions about leading zeros is not enforced in C++. Instead, - leading zeros in integer literals lead to an interpretation as octal - number. Internally, the value will be stored as decimal number. For - instance, the C++ integer literal `010` will be serialized to `8`. - During deserialization, leading zeros yield an error. - - Not-a-number (NaN) values will be serialized to `null`. - - #### Limits - - [RFC 8259](https://tools.ietf.org/html/rfc8259) specifies: - > An implementation may set limits on the range and precision of numbers. - - When the default type is used, the maximal integer number that can be - stored is `9223372036854775807` (INT64_MAX) and the minimal integer number - that can be stored is `-9223372036854775808` (INT64_MIN). Integer numbers - that are out of range will yield over/underflow when used in a - constructor. During deserialization, too large or small integer numbers - will be automatically be stored as @ref number_unsigned_t or @ref - number_float_t. - - [RFC 8259](https://tools.ietf.org/html/rfc8259) further states: - > Note that when such software is used, numbers that are integers and are - > in the range \f$[-2^{53}+1, 2^{53}-1]\f$ are interoperable in the sense - > that implementations will agree exactly on their numeric values. - - As this range is a subrange of the exactly supported range [INT64_MIN, - INT64_MAX], this class's integer type is interoperable. - - #### Storage - - Integer number values are stored directly inside a @ref basic_json type. - - @sa see @ref number_float_t -- type for number values (floating-point) - - @sa see @ref number_unsigned_t -- type for number values (unsigned integer) - - @since version 1.0.0 - */ - using number_integer_t = NumberIntegerType; - - /*! - @brief a type for a number (unsigned) - - [RFC 8259](https://tools.ietf.org/html/rfc8259) describes numbers as follows: - > The representation of numbers is similar to that used in most - > programming languages. A number is represented in base 10 using decimal - > digits. It contains an integer component that may be prefixed with an - > optional minus sign, which may be followed by a fraction part and/or an - > exponent part. Leading zeros are not allowed. (...) Numeric values that - > cannot be represented in the grammar below (such as Infinity and NaN) - > are not permitted. - - This description includes both integer and floating-point numbers. - However, C++ allows more precise storage if it is known whether the number - is a signed integer, an unsigned integer or a floating-point number. - Therefore, three different types, @ref number_integer_t, @ref - number_unsigned_t and @ref number_float_t are used. - - To store unsigned integer numbers in C++, a type is defined by the - template parameter @a NumberUnsignedType which chooses the type to use. - - #### Default type - - With the default values for @a NumberUnsignedType (`uint64_t`), the - default value for @a number_unsigned_t is: - - @code {.cpp} - uint64_t - @endcode - - #### Default behavior - - - The restrictions about leading zeros is not enforced in C++. Instead, - leading zeros in integer literals lead to an interpretation as octal - number. Internally, the value will be stored as decimal number. For - instance, the C++ integer literal `010` will be serialized to `8`. - During deserialization, leading zeros yield an error. - - Not-a-number (NaN) values will be serialized to `null`. - - #### Limits - - [RFC 8259](https://tools.ietf.org/html/rfc8259) specifies: - > An implementation may set limits on the range and precision of numbers. - - When the default type is used, the maximal integer number that can be - stored is `18446744073709551615` (UINT64_MAX) and the minimal integer - number that can be stored is `0`. Integer numbers that are out of range - will yield over/underflow when used in a constructor. During - deserialization, too large or small integer numbers will be automatically - be stored as @ref number_integer_t or @ref number_float_t. - - [RFC 8259](https://tools.ietf.org/html/rfc8259) further states: - > Note that when such software is used, numbers that are integers and are - > in the range \f$[-2^{53}+1, 2^{53}-1]\f$ are interoperable in the sense - > that implementations will agree exactly on their numeric values. - - As this range is a subrange (when considered in conjunction with the - number_integer_t type) of the exactly supported range [0, UINT64_MAX], - this class's integer type is interoperable. - - #### Storage - - Integer number values are stored directly inside a @ref basic_json type. - - @sa see @ref number_float_t -- type for number values (floating-point) - @sa see @ref number_integer_t -- type for number values (integer) - - @since version 2.0.0 - */ - using number_unsigned_t = NumberUnsignedType; - - /*! - @brief a type for a number (floating-point) - - [RFC 8259](https://tools.ietf.org/html/rfc8259) describes numbers as follows: - > The representation of numbers is similar to that used in most - > programming languages. A number is represented in base 10 using decimal - > digits. It contains an integer component that may be prefixed with an - > optional minus sign, which may be followed by a fraction part and/or an - > exponent part. Leading zeros are not allowed. (...) Numeric values that - > cannot be represented in the grammar below (such as Infinity and NaN) - > are not permitted. - - This description includes both integer and floating-point numbers. - However, C++ allows more precise storage if it is known whether the number - is a signed integer, an unsigned integer or a floating-point number. - Therefore, three different types, @ref number_integer_t, @ref - number_unsigned_t and @ref number_float_t are used. - - To store floating-point numbers in C++, a type is defined by the template - parameter @a NumberFloatType which chooses the type to use. - - #### Default type - - With the default values for @a NumberFloatType (`double`), the default - value for @a number_float_t is: - - @code {.cpp} - double - @endcode - - #### Default behavior - - - The restrictions about leading zeros is not enforced in C++. Instead, - leading zeros in floating-point literals will be ignored. Internally, - the value will be stored as decimal number. For instance, the C++ - floating-point literal `01.2` will be serialized to `1.2`. During - deserialization, leading zeros yield an error. - - Not-a-number (NaN) values will be serialized to `null`. - - #### Limits - - [RFC 8259](https://tools.ietf.org/html/rfc8259) states: - > This specification allows implementations to set limits on the range and - > precision of numbers accepted. Since software that implements IEEE - > 754-2008 binary64 (double precision) numbers is generally available and - > widely used, good interoperability can be achieved by implementations - > that expect no more precision or range than these provide, in the sense - > that implementations will approximate JSON numbers within the expected - > precision. - - This implementation does exactly follow this approach, as it uses double - precision floating-point numbers. Note values smaller than - `-1.79769313486232e+308` and values greater than `1.79769313486232e+308` - will be stored as NaN internally and be serialized to `null`. - - #### Storage - - Floating-point number values are stored directly inside a @ref basic_json - type. - - @sa see @ref number_integer_t -- type for number values (integer) - - @sa see @ref number_unsigned_t -- type for number values (unsigned integer) - - @since version 1.0.0 - */ - using number_float_t = NumberFloatType; - - /*! - @brief a type for a packed binary type - - This type is a type designed to carry binary data that appears in various - serialized formats, such as CBOR's Major Type 2, MessagePack's bin, and - BSON's generic binary subtype. This type is NOT a part of standard JSON and - exists solely for compatibility with these binary types. As such, it is - simply defined as an ordered sequence of zero or more byte values. - - Additionally, as an implementation detail, the subtype of the binary data is - carried around as a `std::uint8_t`, which is compatible with both of the - binary data formats that use binary subtyping, (though the specific - numbering is incompatible with each other, and it is up to the user to - translate between them). - - [CBOR's RFC 7049](https://tools.ietf.org/html/rfc7049) describes this type - as: - > Major type 2: a byte string. The string's length in bytes is represented - > following the rules for positive integers (major type 0). - - [MessagePack's documentation on the bin type - family](https://github.com/msgpack/msgpack/blob/master/spec.md#bin-format-family) - describes this type as: - > Bin format family stores an byte array in 2, 3, or 5 bytes of extra bytes - > in addition to the size of the byte array. - - [BSON's specifications](http://bsonspec.org/spec.html) describe several - binary types; however, this type is intended to represent the generic binary - type which has the description: - > Generic binary subtype - This is the most commonly used binary subtype and - > should be the 'default' for drivers and tools. - - None of these impose any limitations on the internal representation other - than the basic unit of storage be some type of array whose parts are - decomposable into bytes. - - The default representation of this binary format is a - `std::vector`, which is a very common way to represent a byte - array in modern C++. - - #### Default type - - The default values for @a BinaryType is `std::vector` - - #### Storage - - Binary Arrays are stored as pointers in a @ref basic_json type. That is, - for any access to array values, a pointer of the type `binary_t*` must be - dereferenced. - - #### Notes on subtypes - - - CBOR - - Binary values are represented as byte strings. Subtypes are serialized - as tagged values. - - MessagePack - - If a subtype is given and the binary array contains exactly 1, 2, 4, 8, - or 16 elements, the fixext family (fixext1, fixext2, fixext4, fixext8) - is used. For other sizes, the ext family (ext8, ext16, ext32) is used. - The subtype is then added as singed 8-bit integer. - - If no subtype is given, the bin family (bin8, bin16, bin32) is used. - - BSON - - If a subtype is given, it is used and added as unsigned 8-bit integer. - - If no subtype is given, the generic binary subtype 0x00 is used. - - @sa see @ref binary -- create a binary array - - @since version 3.8.0 - */ - using binary_t = nlohmann::byte_container_with_subtype; - /// @} - - private: - - /// helper for exception-safe object creation - template - JSON_HEDLEY_RETURNS_NON_NULL - static T* create(Args&& ... args) - { - AllocatorType alloc; - using AllocatorTraits = std::allocator_traits>; - - auto deleter = [&](T * obj) - { - AllocatorTraits::deallocate(alloc, obj, 1); - }; - std::unique_ptr obj(AllocatorTraits::allocate(alloc, 1), deleter); - AllocatorTraits::construct(alloc, obj.get(), std::forward(args)...); - JSON_ASSERT(obj != nullptr); - return obj.release(); - } - - //////////////////////// - // JSON value storage // - //////////////////////// - - JSON_PRIVATE_UNLESS_TESTED: - /*! - @brief a JSON value - - The actual storage for a JSON value of the @ref basic_json class. This - union combines the different storage types for the JSON value types - defined in @ref value_t. - - JSON type | value_t type | used type - --------- | --------------- | ------------------------ - object | object | pointer to @ref object_t - array | array | pointer to @ref array_t - string | string | pointer to @ref string_t - boolean | boolean | @ref boolean_t - number | number_integer | @ref number_integer_t - number | number_unsigned | @ref number_unsigned_t - number | number_float | @ref number_float_t - binary | binary | pointer to @ref binary_t - null | null | *no value is stored* - - @note Variable-length types (objects, arrays, and strings) are stored as - pointers. The size of the union should not exceed 64 bits if the default - value types are used. - - @since version 1.0.0 - */ - union json_value - { - /// object (stored with pointer to save storage) - object_t* object; - /// array (stored with pointer to save storage) - array_t* array; - /// string (stored with pointer to save storage) - string_t* string; - /// binary (stored with pointer to save storage) - binary_t* binary; - /// boolean - boolean_t boolean; - /// number (integer) - number_integer_t number_integer; - /// number (unsigned integer) - number_unsigned_t number_unsigned; - /// number (floating-point) - number_float_t number_float; - - /// default constructor (for null values) - json_value() = default; - /// constructor for booleans - json_value(boolean_t v) noexcept : boolean(v) {} - /// constructor for numbers (integer) - json_value(number_integer_t v) noexcept : number_integer(v) {} - /// constructor for numbers (unsigned) - json_value(number_unsigned_t v) noexcept : number_unsigned(v) {} - /// constructor for numbers (floating-point) - json_value(number_float_t v) noexcept : number_float(v) {} - /// constructor for empty values of a given type - json_value(value_t t) - { - switch (t) - { - case value_t::object: - { - object = create(); - break; - } - - case value_t::array: - { - array = create(); - break; - } - - case value_t::string: - { - string = create(""); - break; - } - - case value_t::binary: - { - binary = create(); - break; - } - - case value_t::boolean: - { - boolean = boolean_t(false); - break; - } - - case value_t::number_integer: - { - number_integer = number_integer_t(0); - break; - } - - case value_t::number_unsigned: - { - number_unsigned = number_unsigned_t(0); - break; - } - - case value_t::number_float: - { - number_float = number_float_t(0.0); - break; - } - - case value_t::null: - { - object = nullptr; // silence warning, see #821 - break; - } - - case value_t::discarded: - default: - { - object = nullptr; // silence warning, see #821 - if (JSON_HEDLEY_UNLIKELY(t == value_t::null)) - { - JSON_THROW(other_error::create(500, "961c151d2e87f2686a955a9be24d316f1362bf21 3.10.4", basic_json())); // LCOV_EXCL_LINE - } - break; - } - } - } - - /// constructor for strings - json_value(const string_t& value) : string(create(value)) {} - - /// constructor for rvalue strings - json_value(string_t&& value) : string(create(std::move(value))) {} - - /// constructor for objects - json_value(const object_t& value) : object(create(value)) {} - - /// constructor for rvalue objects - json_value(object_t&& value) : object(create(std::move(value))) {} - - /// constructor for arrays - json_value(const array_t& value) : array(create(value)) {} - - /// constructor for rvalue arrays - json_value(array_t&& value) : array(create(std::move(value))) {} - - /// constructor for binary arrays - json_value(const typename binary_t::container_type& value) : binary(create(value)) {} - - /// constructor for rvalue binary arrays - json_value(typename binary_t::container_type&& value) : binary(create(std::move(value))) {} - - /// constructor for binary arrays (internal type) - json_value(const binary_t& value) : binary(create(value)) {} - - /// constructor for rvalue binary arrays (internal type) - json_value(binary_t&& value) : binary(create(std::move(value))) {} - - void destroy(value_t t) - { - if (t == value_t::array || t == value_t::object) - { - // flatten the current json_value to a heap-allocated stack - std::vector stack; - - // move the top-level items to stack - if (t == value_t::array) - { - stack.reserve(array->size()); - std::move(array->begin(), array->end(), std::back_inserter(stack)); - } - else - { - stack.reserve(object->size()); - for (auto&& it : *object) - { - stack.push_back(std::move(it.second)); - } - } - - while (!stack.empty()) - { - // move the last item to local variable to be processed - basic_json current_item(std::move(stack.back())); - stack.pop_back(); - - // if current_item is array/object, move - // its children to the stack to be processed later - if (current_item.is_array()) - { - std::move(current_item.m_value.array->begin(), current_item.m_value.array->end(), std::back_inserter(stack)); - - current_item.m_value.array->clear(); - } - else if (current_item.is_object()) - { - for (auto&& it : *current_item.m_value.object) - { - stack.push_back(std::move(it.second)); - } - - current_item.m_value.object->clear(); - } - - // it's now safe that current_item get destructed - // since it doesn't have any children - } - } - - switch (t) - { - case value_t::object: - { - AllocatorType alloc; - std::allocator_traits::destroy(alloc, object); - std::allocator_traits::deallocate(alloc, object, 1); - break; - } - - case value_t::array: - { - AllocatorType alloc; - std::allocator_traits::destroy(alloc, array); - std::allocator_traits::deallocate(alloc, array, 1); - break; - } - - case value_t::string: - { - AllocatorType alloc; - std::allocator_traits::destroy(alloc, string); - std::allocator_traits::deallocate(alloc, string, 1); - break; - } - - case value_t::binary: - { - AllocatorType alloc; - std::allocator_traits::destroy(alloc, binary); - std::allocator_traits::deallocate(alloc, binary, 1); - break; - } - - case value_t::null: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::discarded: - default: - { - break; - } - } - } - }; - - private: - /*! - @brief checks the class invariants - - This function asserts the class invariants. It needs to be called at the - end of every constructor to make sure that created objects respect the - invariant. Furthermore, it has to be called each time the type of a JSON - value is changed, because the invariant expresses a relationship between - @a m_type and @a m_value. - - Furthermore, the parent relation is checked for arrays and objects: If - @a check_parents true and the value is an array or object, then the - container's elements must have the current value as parent. - - @param[in] check_parents whether the parent relation should be checked. - The value is true by default and should only be set to false - during destruction of objects when the invariant does not - need to hold. - */ - void assert_invariant(bool check_parents = true) const noexcept - { - JSON_ASSERT(m_type != value_t::object || m_value.object != nullptr); - JSON_ASSERT(m_type != value_t::array || m_value.array != nullptr); - JSON_ASSERT(m_type != value_t::string || m_value.string != nullptr); - JSON_ASSERT(m_type != value_t::binary || m_value.binary != nullptr); - -#if JSON_DIAGNOSTICS - JSON_TRY - { - // cppcheck-suppress assertWithSideEffect - JSON_ASSERT(!check_parents || !is_structured() || std::all_of(begin(), end(), [this](const basic_json & j) - { - return j.m_parent == this; - })); - } - JSON_CATCH(...) {} // LCOV_EXCL_LINE -#endif - static_cast(check_parents); - } - - void set_parents() - { -#if JSON_DIAGNOSTICS - switch (m_type) - { - case value_t::array: - { - for (auto& element : *m_value.array) - { - element.m_parent = this; - } - break; - } - - case value_t::object: - { - for (auto& element : *m_value.object) - { - element.second.m_parent = this; - } - break; - } - - case value_t::null: - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - break; - } -#endif - } - - iterator set_parents(iterator it, typename iterator::difference_type count) - { -#if JSON_DIAGNOSTICS - for (typename iterator::difference_type i = 0; i < count; ++i) - { - (it + i)->m_parent = this; - } -#else - static_cast(count); -#endif - return it; - } - - reference set_parent(reference j, std::size_t old_capacity = std::size_t(-1)) - { -#if JSON_DIAGNOSTICS - if (old_capacity != std::size_t(-1)) - { - // see https://github.com/nlohmann/json/issues/2838 - JSON_ASSERT(type() == value_t::array); - if (JSON_HEDLEY_UNLIKELY(m_value.array->capacity() != old_capacity)) - { - // capacity has changed: update all parents - set_parents(); - return j; - } - } - - // ordered_json uses a vector internally, so pointers could have - // been invalidated; see https://github.com/nlohmann/json/issues/2962 -#ifdef JSON_HEDLEY_MSVC_VERSION -#pragma warning(push ) -#pragma warning(disable : 4127) // ignore warning to replace if with if constexpr -#endif - if (detail::is_ordered_map::value) - { - set_parents(); - return j; - } -#ifdef JSON_HEDLEY_MSVC_VERSION -#pragma warning( pop ) -#endif - - j.m_parent = this; -#else - static_cast(j); - static_cast(old_capacity); -#endif - return j; - } - - public: - ////////////////////////// - // JSON parser callback // - ////////////////////////// - - /*! - @brief parser event types - - The parser callback distinguishes the following events: - - `object_start`: the parser read `{` and started to process a JSON object - - `key`: the parser read a key of a value in an object - - `object_end`: the parser read `}` and finished processing a JSON object - - `array_start`: the parser read `[` and started to process a JSON array - - `array_end`: the parser read `]` and finished processing a JSON array - - `value`: the parser finished reading a JSON value - - @image html callback_events.png "Example when certain parse events are triggered" - - @sa see @ref parser_callback_t for more information and examples - */ - using parse_event_t = detail::parse_event_t; - - /*! - @brief per-element parser callback type - - With a parser callback function, the result of parsing a JSON text can be - influenced. When passed to @ref parse, it is called on certain events - (passed as @ref parse_event_t via parameter @a event) with a set recursion - depth @a depth and context JSON value @a parsed. The return value of the - callback function is a boolean indicating whether the element that emitted - the callback shall be kept or not. - - We distinguish six scenarios (determined by the event type) in which the - callback function can be called. The following table describes the values - of the parameters @a depth, @a event, and @a parsed. - - parameter @a event | description | parameter @a depth | parameter @a parsed - ------------------ | ----------- | ------------------ | ------------------- - parse_event_t::object_start | the parser read `{` and started to process a JSON object | depth of the parent of the JSON object | a JSON value with type discarded - parse_event_t::key | the parser read a key of a value in an object | depth of the currently parsed JSON object | a JSON string containing the key - parse_event_t::object_end | the parser read `}` and finished processing a JSON object | depth of the parent of the JSON object | the parsed JSON object - parse_event_t::array_start | the parser read `[` and started to process a JSON array | depth of the parent of the JSON array | a JSON value with type discarded - parse_event_t::array_end | the parser read `]` and finished processing a JSON array | depth of the parent of the JSON array | the parsed JSON array - parse_event_t::value | the parser finished reading a JSON value | depth of the value | the parsed JSON value - - @image html callback_events.png "Example when certain parse events are triggered" - - Discarding a value (i.e., returning `false`) has different effects - depending on the context in which function was called: - - - Discarded values in structured types are skipped. That is, the parser - will behave as if the discarded value was never read. - - In case a value outside a structured type is skipped, it is replaced - with `null`. This case happens if the top-level element is skipped. - - @param[in] depth the depth of the recursion during parsing - - @param[in] event an event of type parse_event_t indicating the context in - the callback function has been called - - @param[in,out] parsed the current intermediate parse result; note that - writing to this value has no effect for parse_event_t::key events - - @return Whether the JSON value which called the function during parsing - should be kept (`true`) or not (`false`). In the latter case, it is either - skipped completely or replaced by an empty discarded object. - - @sa see @ref parse for examples - - @since version 1.0.0 - */ - using parser_callback_t = detail::parser_callback_t; - - ////////////////// - // constructors // - ////////////////// - - /// @name constructors and destructors - /// Constructors of class @ref basic_json, copy/move constructor, copy - /// assignment, static functions creating objects, and the destructor. - /// @{ - - /*! - @brief create an empty value with a given type - - Create an empty JSON value with a given type. The value will be default - initialized with an empty value which depends on the type: - - Value type | initial value - ----------- | ------------- - null | `null` - boolean | `false` - string | `""` - number | `0` - object | `{}` - array | `[]` - binary | empty array - - @param[in] v the type of the value to create - - @complexity Constant. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes to any JSON value. - - @liveexample{The following code shows the constructor for different @ref - value_t values,basic_json__value_t} - - @sa see @ref clear() -- restores the postcondition of this constructor - - @since version 1.0.0 - */ - basic_json(const value_t v) - : m_type(v), m_value(v) - { - assert_invariant(); - } - - /*! - @brief create a null object - - Create a `null` JSON value. It either takes a null pointer as parameter - (explicitly creating `null`) or no parameter (implicitly creating `null`). - The passed null pointer itself is not read -- it is only used to choose - the right constructor. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this constructor never throws - exceptions. - - @liveexample{The following code shows the constructor with and without a - null pointer parameter.,basic_json__nullptr_t} - - @since version 1.0.0 - */ - basic_json(std::nullptr_t = nullptr) noexcept - : basic_json(value_t::null) - { - assert_invariant(); - } - - /*! - @brief create a JSON value - - This is a "catch all" constructor for all compatible JSON types; that is, - types for which a `to_json()` method exists. The constructor forwards the - parameter @a val to that method (to `json_serializer::to_json` method - with `U = uncvref_t`, to be exact). - - Template type @a CompatibleType includes, but is not limited to, the - following types: - - **arrays**: @ref array_t and all kinds of compatible containers such as - `std::vector`, `std::deque`, `std::list`, `std::forward_list`, - `std::array`, `std::valarray`, `std::set`, `std::unordered_set`, - `std::multiset`, and `std::unordered_multiset` with a `value_type` from - which a @ref basic_json value can be constructed. - - **objects**: @ref object_t and all kinds of compatible associative - containers such as `std::map`, `std::unordered_map`, `std::multimap`, - and `std::unordered_multimap` with a `key_type` compatible to - @ref string_t and a `value_type` from which a @ref basic_json value can - be constructed. - - **strings**: @ref string_t, string literals, and all compatible string - containers can be used. - - **numbers**: @ref number_integer_t, @ref number_unsigned_t, - @ref number_float_t, and all convertible number types such as `int`, - `size_t`, `int64_t`, `float` or `double` can be used. - - **boolean**: @ref boolean_t / `bool` can be used. - - **binary**: @ref binary_t / `std::vector` may be used, - unfortunately because string literals cannot be distinguished from binary - character arrays by the C++ type system, all types compatible with `const - char*` will be directed to the string constructor instead. This is both - for backwards compatibility, and due to the fact that a binary type is not - a standard JSON type. - - See the examples below. - - @tparam CompatibleType a type such that: - - @a CompatibleType is not derived from `std::istream`, - - @a CompatibleType is not @ref basic_json (to avoid hijacking copy/move - constructors), - - @a CompatibleType is not a different @ref basic_json type (i.e. with different template arguments) - - @a CompatibleType is not a @ref basic_json nested type (e.g., - @ref json_pointer, @ref iterator, etc ...) - - `json_serializer` has a `to_json(basic_json_t&, CompatibleType&&)` method - - @tparam U = `uncvref_t` - - @param[in] val the value to be forwarded to the respective constructor - - @complexity Usually linear in the size of the passed @a val, also - depending on the implementation of the called `to_json()` - method. - - @exceptionsafety Depends on the called constructor. For types directly - supported by the library (i.e., all types for which no `to_json()` function - was provided), strong guarantee holds: if an exception is thrown, there are - no changes to any JSON value. - - @liveexample{The following code shows the constructor with several - compatible types.,basic_json__CompatibleType} - - @since version 2.1.0 - */ - template < typename CompatibleType, - typename U = detail::uncvref_t, - detail::enable_if_t < - !detail::is_basic_json::value && detail::is_compatible_type::value, int > = 0 > - basic_json(CompatibleType && val) noexcept(noexcept( // NOLINT(bugprone-forwarding-reference-overload,bugprone-exception-escape) - JSONSerializer::to_json(std::declval(), - std::forward(val)))) - { - JSONSerializer::to_json(*this, std::forward(val)); - set_parents(); - assert_invariant(); - } - - /*! - @brief create a JSON value from an existing one - - This is a constructor for existing @ref basic_json types. - It does not hijack copy/move constructors, since the parameter has different - template arguments than the current ones. - - The constructor tries to convert the internal @ref m_value of the parameter. - - @tparam BasicJsonType a type such that: - - @a BasicJsonType is a @ref basic_json type. - - @a BasicJsonType has different template arguments than @ref basic_json_t. - - @param[in] val the @ref basic_json value to be converted. - - @complexity Usually linear in the size of the passed @a val, also - depending on the implementation of the called `to_json()` - method. - - @exceptionsafety Depends on the called constructor. For types directly - supported by the library (i.e., all types for which no `to_json()` function - was provided), strong guarantee holds: if an exception is thrown, there are - no changes to any JSON value. - - @since version 3.2.0 - */ - template < typename BasicJsonType, - detail::enable_if_t < - detail::is_basic_json::value&& !std::is_same::value, int > = 0 > - basic_json(const BasicJsonType& val) - { - using other_boolean_t = typename BasicJsonType::boolean_t; - using other_number_float_t = typename BasicJsonType::number_float_t; - using other_number_integer_t = typename BasicJsonType::number_integer_t; - using other_number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using other_string_t = typename BasicJsonType::string_t; - using other_object_t = typename BasicJsonType::object_t; - using other_array_t = typename BasicJsonType::array_t; - using other_binary_t = typename BasicJsonType::binary_t; - - switch (val.type()) - { - case value_t::boolean: - JSONSerializer::to_json(*this, val.template get()); - break; - case value_t::number_float: - JSONSerializer::to_json(*this, val.template get()); - break; - case value_t::number_integer: - JSONSerializer::to_json(*this, val.template get()); - break; - case value_t::number_unsigned: - JSONSerializer::to_json(*this, val.template get()); - break; - case value_t::string: - JSONSerializer::to_json(*this, val.template get_ref()); - break; - case value_t::object: - JSONSerializer::to_json(*this, val.template get_ref()); - break; - case value_t::array: - JSONSerializer::to_json(*this, val.template get_ref()); - break; - case value_t::binary: - JSONSerializer::to_json(*this, val.template get_ref()); - break; - case value_t::null: - *this = nullptr; - break; - case value_t::discarded: - m_type = value_t::discarded; - break; - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE - } - set_parents(); - assert_invariant(); - } - - /*! - @brief create a container (array or object) from an initializer list - - Creates a JSON value of type array or object from the passed initializer - list @a init. In case @a type_deduction is `true` (default), the type of - the JSON value to be created is deducted from the initializer list @a init - according to the following rules: - - 1. If the list is empty, an empty JSON object value `{}` is created. - 2. If the list consists of pairs whose first element is a string, a JSON - object value is created where the first elements of the pairs are - treated as keys and the second elements are as values. - 3. In all other cases, an array is created. - - The rules aim to create the best fit between a C++ initializer list and - JSON values. The rationale is as follows: - - 1. The empty initializer list is written as `{}` which is exactly an empty - JSON object. - 2. C++ has no way of describing mapped types other than to list a list of - pairs. As JSON requires that keys must be of type string, rule 2 is the - weakest constraint one can pose on initializer lists to interpret them - as an object. - 3. In all other cases, the initializer list could not be interpreted as - JSON object type, so interpreting it as JSON array type is safe. - - With the rules described above, the following JSON values cannot be - expressed by an initializer list: - - - the empty array (`[]`): use @ref array(initializer_list_t) - with an empty initializer list in this case - - arrays whose elements satisfy rule 2: use @ref - array(initializer_list_t) with the same initializer list - in this case - - @note When used without parentheses around an empty initializer list, @ref - basic_json() is called instead of this function, yielding the JSON null - value. - - @param[in] init initializer list with JSON values - - @param[in] type_deduction internal parameter; when set to `true`, the type - of the JSON value is deducted from the initializer list @a init; when set - to `false`, the type provided via @a manual_type is forced. This mode is - used by the functions @ref array(initializer_list_t) and - @ref object(initializer_list_t). - - @param[in] manual_type internal parameter; when @a type_deduction is set - to `false`, the created JSON value will use the provided type (only @ref - value_t::array and @ref value_t::object are valid); when @a type_deduction - is set to `true`, this parameter has no effect - - @throw type_error.301 if @a type_deduction is `false`, @a manual_type is - `value_t::object`, but @a init contains an element which is not a pair - whose first element is a string. In this case, the constructor could not - create an object. If @a type_deduction would have be `true`, an array - would have been created. See @ref object(initializer_list_t) - for an example. - - @complexity Linear in the size of the initializer list @a init. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes to any JSON value. - - @liveexample{The example below shows how JSON values are created from - initializer lists.,basic_json__list_init_t} - - @sa see @ref array(initializer_list_t) -- create a JSON array - value from an initializer list - @sa see @ref object(initializer_list_t) -- create a JSON object - value from an initializer list - - @since version 1.0.0 - */ - basic_json(initializer_list_t init, - bool type_deduction = true, - value_t manual_type = value_t::array) - { - // check if each element is an array with two elements whose first - // element is a string - bool is_an_object = std::all_of(init.begin(), init.end(), - [](const detail::json_ref& element_ref) - { - return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[0].is_string(); - }); - - // adjust type if type deduction is not wanted - if (!type_deduction) - { - // if array is wanted, do not create an object though possible - if (manual_type == value_t::array) - { - is_an_object = false; - } - - // if object is wanted but impossible, throw an exception - if (JSON_HEDLEY_UNLIKELY(manual_type == value_t::object && !is_an_object)) - { - JSON_THROW(type_error::create(301, "cannot create object from initializer list", basic_json())); - } - } - - if (is_an_object) - { - // the initializer list is a list of pairs -> create object - m_type = value_t::object; - m_value = value_t::object; - - for (auto& element_ref : init) - { - auto element = element_ref.moved_or_copied(); - m_value.object->emplace( - std::move(*((*element.m_value.array)[0].m_value.string)), - std::move((*element.m_value.array)[1])); - } - } - else - { - // the initializer list describes an array -> create array - m_type = value_t::array; - m_value.array = create(init.begin(), init.end()); - } - - set_parents(); - assert_invariant(); - } - - /*! - @brief explicitly create a binary array (without subtype) - - Creates a JSON binary array value from a given binary container. Binary - values are part of various binary formats, such as CBOR, MessagePack, and - BSON. This constructor is used to create a value for serialization to those - formats. - - @note Note, this function exists because of the difficulty in correctly - specifying the correct template overload in the standard value ctor, as both - JSON arrays and JSON binary arrays are backed with some form of a - `std::vector`. Because JSON binary arrays are a non-standard extension it - was decided that it would be best to prevent automatic initialization of a - binary array type, for backwards compatibility and so it does not happen on - accident. - - @param[in] init container containing bytes to use as binary type - - @return JSON binary array value - - @complexity Linear in the size of @a init. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes to any JSON value. - - @since version 3.8.0 - */ - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json binary(const typename binary_t::container_type& init) - { - auto res = basic_json(); - res.m_type = value_t::binary; - res.m_value = init; - return res; - } - - /*! - @brief explicitly create a binary array (with subtype) - - Creates a JSON binary array value from a given binary container. Binary - values are part of various binary formats, such as CBOR, MessagePack, and - BSON. This constructor is used to create a value for serialization to those - formats. - - @note Note, this function exists because of the difficulty in correctly - specifying the correct template overload in the standard value ctor, as both - JSON arrays and JSON binary arrays are backed with some form of a - `std::vector`. Because JSON binary arrays are a non-standard extension it - was decided that it would be best to prevent automatic initialization of a - binary array type, for backwards compatibility and so it does not happen on - accident. - - @param[in] init container containing bytes to use as binary type - @param[in] subtype subtype to use in MessagePack and BSON - - @return JSON binary array value - - @complexity Linear in the size of @a init. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes to any JSON value. - - @since version 3.8.0 - */ - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json binary(const typename binary_t::container_type& init, typename binary_t::subtype_type subtype) - { - auto res = basic_json(); - res.m_type = value_t::binary; - res.m_value = binary_t(init, subtype); - return res; - } - - /// @copydoc binary(const typename binary_t::container_type&) - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json binary(typename binary_t::container_type&& init) - { - auto res = basic_json(); - res.m_type = value_t::binary; - res.m_value = std::move(init); - return res; - } - - /// @copydoc binary(const typename binary_t::container_type&, typename binary_t::subtype_type) - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json binary(typename binary_t::container_type&& init, typename binary_t::subtype_type subtype) - { - auto res = basic_json(); - res.m_type = value_t::binary; - res.m_value = binary_t(std::move(init), subtype); - return res; - } - - /*! - @brief explicitly create an array from an initializer list - - Creates a JSON array value from a given initializer list. That is, given a - list of values `a, b, c`, creates the JSON value `[a, b, c]`. If the - initializer list is empty, the empty array `[]` is created. - - @note This function is only needed to express two edge cases that cannot - be realized with the initializer list constructor (@ref - basic_json(initializer_list_t, bool, value_t)). These cases - are: - 1. creating an array whose elements are all pairs whose first element is a - string -- in this case, the initializer list constructor would create an - object, taking the first elements as keys - 2. creating an empty array -- passing the empty initializer list to the - initializer list constructor yields an empty object - - @param[in] init initializer list with JSON values to create an array from - (optional) - - @return JSON array value - - @complexity Linear in the size of @a init. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes to any JSON value. - - @liveexample{The following code shows an example for the `array` - function.,array} - - @sa see @ref basic_json(initializer_list_t, bool, value_t) -- - create a JSON value from an initializer list - @sa see @ref object(initializer_list_t) -- create a JSON object - value from an initializer list - - @since version 1.0.0 - */ - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json array(initializer_list_t init = {}) - { - return basic_json(init, false, value_t::array); - } - - /*! - @brief explicitly create an object from an initializer list - - Creates a JSON object value from a given initializer list. The initializer - lists elements must be pairs, and their first elements must be strings. If - the initializer list is empty, the empty object `{}` is created. - - @note This function is only added for symmetry reasons. In contrast to the - related function @ref array(initializer_list_t), there are - no cases which can only be expressed by this function. That is, any - initializer list @a init can also be passed to the initializer list - constructor @ref basic_json(initializer_list_t, bool, value_t). - - @param[in] init initializer list to create an object from (optional) - - @return JSON object value - - @throw type_error.301 if @a init is not a list of pairs whose first - elements are strings. In this case, no object can be created. When such a - value is passed to @ref basic_json(initializer_list_t, bool, value_t), - an array would have been created from the passed initializer list @a init. - See example below. - - @complexity Linear in the size of @a init. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes to any JSON value. - - @liveexample{The following code shows an example for the `object` - function.,object} - - @sa see @ref basic_json(initializer_list_t, bool, value_t) -- - create a JSON value from an initializer list - @sa see @ref array(initializer_list_t) -- create a JSON array - value from an initializer list - - @since version 1.0.0 - */ - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json object(initializer_list_t init = {}) - { - return basic_json(init, false, value_t::object); - } - - /*! - @brief construct an array with count copies of given value - - Constructs a JSON array value by creating @a cnt copies of a passed value. - In case @a cnt is `0`, an empty array is created. - - @param[in] cnt the number of JSON copies of @a val to create - @param[in] val the JSON value to copy - - @post `std::distance(begin(),end()) == cnt` holds. - - @complexity Linear in @a cnt. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes to any JSON value. - - @liveexample{The following code shows examples for the @ref - basic_json(size_type\, const basic_json&) - constructor.,basic_json__size_type_basic_json} - - @since version 1.0.0 - */ - basic_json(size_type cnt, const basic_json& val) - : m_type(value_t::array) - { - m_value.array = create(cnt, val); - set_parents(); - assert_invariant(); - } - - /*! - @brief construct a JSON container given an iterator range - - Constructs the JSON value with the contents of the range `[first, last)`. - The semantics depends on the different types a JSON value can have: - - In case of a null type, invalid_iterator.206 is thrown. - - In case of other primitive types (number, boolean, or string), @a first - must be `begin()` and @a last must be `end()`. In this case, the value is - copied. Otherwise, invalid_iterator.204 is thrown. - - In case of structured types (array, object), the constructor behaves as - similar versions for `std::vector` or `std::map`; that is, a JSON array - or object is constructed from the values in the range. - - @tparam InputIT an input iterator type (@ref iterator or @ref - const_iterator) - - @param[in] first begin of the range to copy from (included) - @param[in] last end of the range to copy from (excluded) - - @pre Iterators @a first and @a last must be initialized. **This - precondition is enforced with an assertion (see warning).** If - assertions are switched off, a violation of this precondition yields - undefined behavior. - - @pre Range `[first, last)` is valid. Usually, this precondition cannot be - checked efficiently. Only certain edge cases are detected; see the - description of the exceptions below. A violation of this precondition - yields undefined behavior. - - @warning A precondition is enforced with a runtime assertion that will - result in calling `std::abort` if this precondition is not met. - Assertions can be disabled by defining `NDEBUG` at compile time. - See https://en.cppreference.com/w/cpp/error/assert for more - information. - - @throw invalid_iterator.201 if iterators @a first and @a last are not - compatible (i.e., do not belong to the same JSON value). In this case, - the range `[first, last)` is undefined. - @throw invalid_iterator.204 if iterators @a first and @a last belong to a - primitive type (number, boolean, or string), but @a first does not point - to the first element any more. In this case, the range `[first, last)` is - undefined. See example code below. - @throw invalid_iterator.206 if iterators @a first and @a last belong to a - null value. In this case, the range `[first, last)` is undefined. - - @complexity Linear in distance between @a first and @a last. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes to any JSON value. - - @liveexample{The example below shows several ways to create JSON values by - specifying a subrange with iterators.,basic_json__InputIt_InputIt} - - @since version 1.0.0 - */ - template < class InputIT, typename std::enable_if < - std::is_same::value || - std::is_same::value, int >::type = 0 > - basic_json(InputIT first, InputIT last) - { - JSON_ASSERT(first.m_object != nullptr); - JSON_ASSERT(last.m_object != nullptr); - - // make sure iterator fits the current value - if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) - { - JSON_THROW(invalid_iterator::create(201, "iterators are not compatible", basic_json())); - } - - // copy type from first iterator - m_type = first.m_object->m_type; - - // check if iterator range is complete for primitive values - switch (m_type) - { - case value_t::boolean: - case value_t::number_float: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::string: - { - if (JSON_HEDLEY_UNLIKELY(!first.m_it.primitive_iterator.is_begin() - || !last.m_it.primitive_iterator.is_end())) - { - JSON_THROW(invalid_iterator::create(204, "iterators out of range", *first.m_object)); - } - break; - } - - case value_t::null: - case value_t::object: - case value_t::array: - case value_t::binary: - case value_t::discarded: - default: - break; - } - - switch (m_type) - { - case value_t::number_integer: - { - m_value.number_integer = first.m_object->m_value.number_integer; - break; - } - - case value_t::number_unsigned: - { - m_value.number_unsigned = first.m_object->m_value.number_unsigned; - break; - } - - case value_t::number_float: - { - m_value.number_float = first.m_object->m_value.number_float; - break; - } - - case value_t::boolean: - { - m_value.boolean = first.m_object->m_value.boolean; - break; - } - - case value_t::string: - { - m_value = *first.m_object->m_value.string; - break; - } - - case value_t::object: - { - m_value.object = create(first.m_it.object_iterator, - last.m_it.object_iterator); - break; - } - - case value_t::array: - { - m_value.array = create(first.m_it.array_iterator, - last.m_it.array_iterator); - break; - } - - case value_t::binary: - { - m_value = *first.m_object->m_value.binary; - break; - } - - case value_t::null: - case value_t::discarded: - default: - JSON_THROW(invalid_iterator::create(206, "cannot construct with iterators from " + std::string(first.m_object->type_name()), *first.m_object)); - } - - set_parents(); - assert_invariant(); - } - - - /////////////////////////////////////// - // other constructors and destructor // - /////////////////////////////////////// - - template, - std::is_same>::value, int> = 0 > - basic_json(const JsonRef& ref) : basic_json(ref.moved_or_copied()) {} - - /*! - @brief copy constructor - - Creates a copy of a given JSON value. - - @param[in] other the JSON value to copy - - @post `*this == other` - - @complexity Linear in the size of @a other. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes to any JSON value. - - @requirement This function helps `basic_json` satisfying the - [Container](https://en.cppreference.com/w/cpp/named_req/Container) - requirements: - - The complexity is linear. - - As postcondition, it holds: `other == basic_json(other)`. - - @liveexample{The following code shows an example for the copy - constructor.,basic_json__basic_json} - - @since version 1.0.0 - */ - basic_json(const basic_json& other) - : m_type(other.m_type) - { - // check of passed value is valid - other.assert_invariant(); - - switch (m_type) - { - case value_t::object: - { - m_value = *other.m_value.object; - break; - } - - case value_t::array: - { - m_value = *other.m_value.array; - break; - } - - case value_t::string: - { - m_value = *other.m_value.string; - break; - } - - case value_t::boolean: - { - m_value = other.m_value.boolean; - break; - } - - case value_t::number_integer: - { - m_value = other.m_value.number_integer; - break; - } - - case value_t::number_unsigned: - { - m_value = other.m_value.number_unsigned; - break; - } - - case value_t::number_float: - { - m_value = other.m_value.number_float; - break; - } - - case value_t::binary: - { - m_value = *other.m_value.binary; - break; - } - - case value_t::null: - case value_t::discarded: - default: - break; - } - - set_parents(); - assert_invariant(); - } - - /*! - @brief move constructor - - Move constructor. Constructs a JSON value with the contents of the given - value @a other using move semantics. It "steals" the resources from @a - other and leaves it as JSON null value. - - @param[in,out] other value to move to this object - - @post `*this` has the same value as @a other before the call. - @post @a other is a JSON null value. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this constructor never throws - exceptions. - - @requirement This function helps `basic_json` satisfying the - [MoveConstructible](https://en.cppreference.com/w/cpp/named_req/MoveConstructible) - requirements. - - @liveexample{The code below shows the move constructor explicitly called - via std::move.,basic_json__moveconstructor} - - @since version 1.0.0 - */ - basic_json(basic_json&& other) noexcept - : m_type(std::move(other.m_type)), - m_value(std::move(other.m_value)) - { - // check that passed value is valid - other.assert_invariant(false); - - // invalidate payload - other.m_type = value_t::null; - other.m_value = {}; - - set_parents(); - assert_invariant(); - } - - /*! - @brief copy assignment - - Copy assignment operator. Copies a JSON value via the "copy and swap" - strategy: It is expressed in terms of the copy constructor, destructor, - and the `swap()` member function. - - @param[in] other value to copy from - - @complexity Linear. - - @requirement This function helps `basic_json` satisfying the - [Container](https://en.cppreference.com/w/cpp/named_req/Container) - requirements: - - The complexity is linear. - - @liveexample{The code below shows and example for the copy assignment. It - creates a copy of value `a` which is then swapped with `b`. Finally\, the - copy of `a` (which is the null value after the swap) is - destroyed.,basic_json__copyassignment} - - @since version 1.0.0 - */ - basic_json& operator=(basic_json other) noexcept ( - std::is_nothrow_move_constructible::value&& - std::is_nothrow_move_assignable::value&& - std::is_nothrow_move_constructible::value&& - std::is_nothrow_move_assignable::value - ) - { - // check that passed value is valid - other.assert_invariant(); - - using std::swap; - swap(m_type, other.m_type); - swap(m_value, other.m_value); - - set_parents(); - assert_invariant(); - return *this; - } - - /*! - @brief destructor - - Destroys the JSON value and frees all allocated memory. - - @complexity Linear. - - @requirement This function helps `basic_json` satisfying the - [Container](https://en.cppreference.com/w/cpp/named_req/Container) - requirements: - - The complexity is linear. - - All stored elements are destroyed and all memory is freed. - - @since version 1.0.0 - */ - ~basic_json() noexcept - { - assert_invariant(false); - m_value.destroy(m_type); - } - - /// @} - - public: - /////////////////////// - // object inspection // - /////////////////////// - - /// @name object inspection - /// Functions to inspect the type of a JSON value. - /// @{ - - /*! - @brief serialization - - Serialization function for JSON values. The function tries to mimic - Python's `json.dumps()` function, and currently supports its @a indent - and @a ensure_ascii parameters. - - @param[in] indent If indent is nonnegative, then array elements and object - members will be pretty-printed with that indent level. An indent level of - `0` will only insert newlines. `-1` (the default) selects the most compact - representation. - @param[in] indent_char The character to use for indentation if @a indent is - greater than `0`. The default is ` ` (space). - @param[in] ensure_ascii If @a ensure_ascii is true, all non-ASCII characters - in the output are escaped with `\uXXXX` sequences, and the result consists - of ASCII characters only. - @param[in] error_handler how to react on decoding errors; there are three - possible values: `strict` (throws and exception in case a decoding error - occurs; default), `replace` (replace invalid UTF-8 sequences with U+FFFD), - and `ignore` (ignore invalid UTF-8 sequences during serialization; all - bytes are copied to the output unchanged). - - @return string containing the serialization of the JSON value - - @throw type_error.316 if a string stored inside the JSON value is not - UTF-8 encoded and @a error_handler is set to strict - - @note Binary values are serialized as object containing two keys: - - "bytes": an array of bytes as integers - - "subtype": the subtype as integer or "null" if the binary has no subtype - - @complexity Linear. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes in the JSON value. - - @liveexample{The following example shows the effect of different @a indent\, - @a indent_char\, and @a ensure_ascii parameters to the result of the - serialization.,dump} - - @see https://docs.python.org/2/library/json.html#json.dump - - @since version 1.0.0; indentation character @a indent_char, option - @a ensure_ascii and exceptions added in version 3.0.0; error - handlers added in version 3.4.0; serialization of binary values added - in version 3.8.0. - */ - string_t dump(const int indent = -1, - const char indent_char = ' ', - const bool ensure_ascii = false, - const error_handler_t error_handler = error_handler_t::strict) const - { - string_t result; - serializer s(detail::output_adapter(result), indent_char, error_handler); - - if (indent >= 0) - { - s.dump(*this, true, ensure_ascii, static_cast(indent)); - } - else - { - s.dump(*this, false, ensure_ascii, 0); - } - - return result; - } - - /*! - @brief return the type of the JSON value (explicit) - - Return the type of the JSON value as a value from the @ref value_t - enumeration. - - @return the type of the JSON value - Value type | return value - ------------------------- | ------------------------- - null | value_t::null - boolean | value_t::boolean - string | value_t::string - number (integer) | value_t::number_integer - number (unsigned integer) | value_t::number_unsigned - number (floating-point) | value_t::number_float - object | value_t::object - array | value_t::array - binary | value_t::binary - discarded | value_t::discarded - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `type()` for all JSON - types.,type} - - @sa see @ref operator value_t() -- return the type of the JSON value (implicit) - @sa see @ref type_name() -- return the type as string - - @since version 1.0.0 - */ - constexpr value_t type() const noexcept - { - return m_type; - } - - /*! - @brief return whether type is primitive - - This function returns true if and only if the JSON type is primitive - (string, number, boolean, or null). - - @return `true` if type is primitive (string, number, boolean, or null), - `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_primitive()` for all JSON - types.,is_primitive} - - @sa see @ref is_structured() -- returns whether JSON value is structured - @sa see @ref is_null() -- returns whether JSON value is `null` - @sa see @ref is_string() -- returns whether JSON value is a string - @sa see @ref is_boolean() -- returns whether JSON value is a boolean - @sa see @ref is_number() -- returns whether JSON value is a number - @sa see @ref is_binary() -- returns whether JSON value is a binary array - - @since version 1.0.0 - */ - constexpr bool is_primitive() const noexcept - { - return is_null() || is_string() || is_boolean() || is_number() || is_binary(); - } - - /*! - @brief return whether type is structured - - This function returns true if and only if the JSON type is structured - (array or object). - - @return `true` if type is structured (array or object), `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_structured()` for all JSON - types.,is_structured} - - @sa see @ref is_primitive() -- returns whether value is primitive - @sa see @ref is_array() -- returns whether value is an array - @sa see @ref is_object() -- returns whether value is an object - - @since version 1.0.0 - */ - constexpr bool is_structured() const noexcept - { - return is_array() || is_object(); - } - - /*! - @brief return whether value is null - - This function returns true if and only if the JSON value is null. - - @return `true` if type is null, `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_null()` for all JSON - types.,is_null} - - @since version 1.0.0 - */ - constexpr bool is_null() const noexcept - { - return m_type == value_t::null; - } - - /*! - @brief return whether value is a boolean - - This function returns true if and only if the JSON value is a boolean. - - @return `true` if type is boolean, `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_boolean()` for all JSON - types.,is_boolean} - - @since version 1.0.0 - */ - constexpr bool is_boolean() const noexcept - { - return m_type == value_t::boolean; - } - - /*! - @brief return whether value is a number - - This function returns true if and only if the JSON value is a number. This - includes both integer (signed and unsigned) and floating-point values. - - @return `true` if type is number (regardless whether integer, unsigned - integer or floating-type), `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_number()` for all JSON - types.,is_number} - - @sa see @ref is_number_integer() -- check if value is an integer or unsigned - integer number - @sa see @ref is_number_unsigned() -- check if value is an unsigned integer - number - @sa see @ref is_number_float() -- check if value is a floating-point number - - @since version 1.0.0 - */ - constexpr bool is_number() const noexcept - { - return is_number_integer() || is_number_float(); - } - - /*! - @brief return whether value is an integer number - - This function returns true if and only if the JSON value is a signed or - unsigned integer number. This excludes floating-point values. - - @return `true` if type is an integer or unsigned integer number, `false` - otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_number_integer()` for all - JSON types.,is_number_integer} - - @sa see @ref is_number() -- check if value is a number - @sa see @ref is_number_unsigned() -- check if value is an unsigned integer - number - @sa see @ref is_number_float() -- check if value is a floating-point number - - @since version 1.0.0 - */ - constexpr bool is_number_integer() const noexcept - { - return m_type == value_t::number_integer || m_type == value_t::number_unsigned; - } - - /*! - @brief return whether value is an unsigned integer number - - This function returns true if and only if the JSON value is an unsigned - integer number. This excludes floating-point and signed integer values. - - @return `true` if type is an unsigned integer number, `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_number_unsigned()` for all - JSON types.,is_number_unsigned} - - @sa see @ref is_number() -- check if value is a number - @sa see @ref is_number_integer() -- check if value is an integer or unsigned - integer number - @sa see @ref is_number_float() -- check if value is a floating-point number - - @since version 2.0.0 - */ - constexpr bool is_number_unsigned() const noexcept - { - return m_type == value_t::number_unsigned; - } - - /*! - @brief return whether value is a floating-point number - - This function returns true if and only if the JSON value is a - floating-point number. This excludes signed and unsigned integer values. - - @return `true` if type is a floating-point number, `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_number_float()` for all - JSON types.,is_number_float} - - @sa see @ref is_number() -- check if value is number - @sa see @ref is_number_integer() -- check if value is an integer number - @sa see @ref is_number_unsigned() -- check if value is an unsigned integer - number - - @since version 1.0.0 - */ - constexpr bool is_number_float() const noexcept - { - return m_type == value_t::number_float; - } - - /*! - @brief return whether value is an object - - This function returns true if and only if the JSON value is an object. - - @return `true` if type is object, `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_object()` for all JSON - types.,is_object} - - @since version 1.0.0 - */ - constexpr bool is_object() const noexcept - { - return m_type == value_t::object; - } - - /*! - @brief return whether value is an array - - This function returns true if and only if the JSON value is an array. - - @return `true` if type is array, `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_array()` for all JSON - types.,is_array} - - @since version 1.0.0 - */ - constexpr bool is_array() const noexcept - { - return m_type == value_t::array; - } - - /*! - @brief return whether value is a string - - This function returns true if and only if the JSON value is a string. - - @return `true` if type is string, `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_string()` for all JSON - types.,is_string} - - @since version 1.0.0 - */ - constexpr bool is_string() const noexcept - { - return m_type == value_t::string; - } - - /*! - @brief return whether value is a binary array - - This function returns true if and only if the JSON value is a binary array. - - @return `true` if type is binary array, `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_binary()` for all JSON - types.,is_binary} - - @since version 3.8.0 - */ - constexpr bool is_binary() const noexcept - { - return m_type == value_t::binary; - } - - /*! - @brief return whether value is discarded - - This function returns true if and only if the JSON value was discarded - during parsing with a callback function (see @ref parser_callback_t). - - @note This function will always be `false` for JSON values after parsing. - That is, discarded values can only occur during parsing, but will be - removed when inside a structured value or replaced by null in other cases. - - @return `true` if type is discarded, `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_discarded()` for all JSON - types.,is_discarded} - - @since version 1.0.0 - */ - constexpr bool is_discarded() const noexcept - { - return m_type == value_t::discarded; - } - - /*! - @brief return the type of the JSON value (implicit) - - Implicitly return the type of the JSON value as a value from the @ref - value_t enumeration. - - @return the type of the JSON value - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies the @ref value_t operator for - all JSON types.,operator__value_t} - - @sa see @ref type() -- return the type of the JSON value (explicit) - @sa see @ref type_name() -- return the type as string - - @since version 1.0.0 - */ - constexpr operator value_t() const noexcept - { - return m_type; - } - - /// @} - - private: - ////////////////// - // value access // - ////////////////// - - /// get a boolean (explicit) - boolean_t get_impl(boolean_t* /*unused*/) const - { - if (JSON_HEDLEY_LIKELY(is_boolean())) - { - return m_value.boolean; - } - - JSON_THROW(type_error::create(302, "type must be boolean, but is " + std::string(type_name()), *this)); - } - - /// get a pointer to the value (object) - object_t* get_impl_ptr(object_t* /*unused*/) noexcept - { - return is_object() ? m_value.object : nullptr; - } - - /// get a pointer to the value (object) - constexpr const object_t* get_impl_ptr(const object_t* /*unused*/) const noexcept - { - return is_object() ? m_value.object : nullptr; - } - - /// get a pointer to the value (array) - array_t* get_impl_ptr(array_t* /*unused*/) noexcept - { - return is_array() ? m_value.array : nullptr; - } - - /// get a pointer to the value (array) - constexpr const array_t* get_impl_ptr(const array_t* /*unused*/) const noexcept - { - return is_array() ? m_value.array : nullptr; - } - - /// get a pointer to the value (string) - string_t* get_impl_ptr(string_t* /*unused*/) noexcept - { - return is_string() ? m_value.string : nullptr; - } - - /// get a pointer to the value (string) - constexpr const string_t* get_impl_ptr(const string_t* /*unused*/) const noexcept - { - return is_string() ? m_value.string : nullptr; - } - - /// get a pointer to the value (boolean) - boolean_t* get_impl_ptr(boolean_t* /*unused*/) noexcept - { - return is_boolean() ? &m_value.boolean : nullptr; - } - - /// get a pointer to the value (boolean) - constexpr const boolean_t* get_impl_ptr(const boolean_t* /*unused*/) const noexcept - { - return is_boolean() ? &m_value.boolean : nullptr; - } - - /// get a pointer to the value (integer number) - number_integer_t* get_impl_ptr(number_integer_t* /*unused*/) noexcept - { - return is_number_integer() ? &m_value.number_integer : nullptr; - } - - /// get a pointer to the value (integer number) - constexpr const number_integer_t* get_impl_ptr(const number_integer_t* /*unused*/) const noexcept - { - return is_number_integer() ? &m_value.number_integer : nullptr; - } - - /// get a pointer to the value (unsigned number) - number_unsigned_t* get_impl_ptr(number_unsigned_t* /*unused*/) noexcept - { - return is_number_unsigned() ? &m_value.number_unsigned : nullptr; - } - - /// get a pointer to the value (unsigned number) - constexpr const number_unsigned_t* get_impl_ptr(const number_unsigned_t* /*unused*/) const noexcept - { - return is_number_unsigned() ? &m_value.number_unsigned : nullptr; - } - - /// get a pointer to the value (floating-point number) - number_float_t* get_impl_ptr(number_float_t* /*unused*/) noexcept - { - return is_number_float() ? &m_value.number_float : nullptr; - } - - /// get a pointer to the value (floating-point number) - constexpr const number_float_t* get_impl_ptr(const number_float_t* /*unused*/) const noexcept - { - return is_number_float() ? &m_value.number_float : nullptr; - } - - /// get a pointer to the value (binary) - binary_t* get_impl_ptr(binary_t* /*unused*/) noexcept - { - return is_binary() ? m_value.binary : nullptr; - } - - /// get a pointer to the value (binary) - constexpr const binary_t* get_impl_ptr(const binary_t* /*unused*/) const noexcept - { - return is_binary() ? m_value.binary : nullptr; - } - - /*! - @brief helper function to implement get_ref() - - This function helps to implement get_ref() without code duplication for - const and non-const overloads - - @tparam ThisType will be deduced as `basic_json` or `const basic_json` - - @throw type_error.303 if ReferenceType does not match underlying value - type of the current JSON - */ - template - static ReferenceType get_ref_impl(ThisType& obj) - { - // delegate the call to get_ptr<>() - auto* ptr = obj.template get_ptr::type>(); - - if (JSON_HEDLEY_LIKELY(ptr != nullptr)) - { - return *ptr; - } - - JSON_THROW(type_error::create(303, "incompatible ReferenceType for get_ref, actual type is " + std::string(obj.type_name()), obj)); - } - - public: - /// @name value access - /// Direct access to the stored value of a JSON value. - /// @{ - - /*! - @brief get a pointer value (implicit) - - Implicit pointer access to the internally stored JSON value. No copies are - made. - - @warning Writing data to the pointee of the result yields an undefined - state. - - @tparam PointerType pointer type; must be a pointer to @ref array_t, @ref - object_t, @ref string_t, @ref boolean_t, @ref number_integer_t, - @ref number_unsigned_t, or @ref number_float_t. Enforced by a static - assertion. - - @return pointer to the internally stored JSON value if the requested - pointer type @a PointerType fits to the JSON value; `nullptr` otherwise - - @complexity Constant. - - @liveexample{The example below shows how pointers to internal values of a - JSON value can be requested. Note that no type conversions are made and a - `nullptr` is returned if the value and the requested pointer type does not - match.,get_ptr} - - @since version 1.0.0 - */ - template::value, int>::type = 0> - auto get_ptr() noexcept -> decltype(std::declval().get_impl_ptr(std::declval())) - { - // delegate the call to get_impl_ptr<>() - return get_impl_ptr(static_cast(nullptr)); - } - - /*! - @brief get a pointer value (implicit) - @copydoc get_ptr() - */ - template < typename PointerType, typename std::enable_if < - std::is_pointer::value&& - std::is_const::type>::value, int >::type = 0 > - constexpr auto get_ptr() const noexcept -> decltype(std::declval().get_impl_ptr(std::declval())) - { - // delegate the call to get_impl_ptr<>() const - return get_impl_ptr(static_cast(nullptr)); - } - - private: - /*! - @brief get a value (explicit) - - Explicit type conversion between the JSON value and a compatible value - which is [CopyConstructible](https://en.cppreference.com/w/cpp/named_req/CopyConstructible) - and [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible). - The value is converted by calling the @ref json_serializer - `from_json()` method. - - The function is equivalent to executing - @code {.cpp} - ValueType ret; - JSONSerializer::from_json(*this, ret); - return ret; - @endcode - - This overloads is chosen if: - - @a ValueType is not @ref basic_json, - - @ref json_serializer has a `from_json()` method of the form - `void from_json(const basic_json&, ValueType&)`, and - - @ref json_serializer does not have a `from_json()` method of - the form `ValueType from_json(const basic_json&)` - - @tparam ValueType the returned value type - - @return copy of the JSON value, converted to @a ValueType - - @throw what @ref json_serializer `from_json()` method throws - - @liveexample{The example below shows several conversions from JSON values - to other types. There a few things to note: (1) Floating-point numbers can - be converted to integers\, (2) A JSON array can be converted to a standard - `std::vector`\, (3) A JSON object can be converted to C++ - associative containers such as `std::unordered_map`.,get__ValueType_const} - - @since version 2.1.0 - */ - template < typename ValueType, - detail::enable_if_t < - detail::is_default_constructible::value&& - detail::has_from_json::value, - int > = 0 > - ValueType get_impl(detail::priority_tag<0> /*unused*/) const noexcept(noexcept( - JSONSerializer::from_json(std::declval(), std::declval()))) - { - auto ret = ValueType(); - JSONSerializer::from_json(*this, ret); - return ret; - } - - /*! - @brief get a value (explicit); special case - - Explicit type conversion between the JSON value and a compatible value - which is **not** [CopyConstructible](https://en.cppreference.com/w/cpp/named_req/CopyConstructible) - and **not** [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible). - The value is converted by calling the @ref json_serializer - `from_json()` method. - - The function is equivalent to executing - @code {.cpp} - return JSONSerializer::from_json(*this); - @endcode - - This overloads is chosen if: - - @a ValueType is not @ref basic_json and - - @ref json_serializer has a `from_json()` method of the form - `ValueType from_json(const basic_json&)` - - @note If @ref json_serializer has both overloads of - `from_json()`, this one is chosen. - - @tparam ValueType the returned value type - - @return copy of the JSON value, converted to @a ValueType - - @throw what @ref json_serializer `from_json()` method throws - - @since version 2.1.0 - */ - template < typename ValueType, - detail::enable_if_t < - detail::has_non_default_from_json::value, - int > = 0 > - ValueType get_impl(detail::priority_tag<1> /*unused*/) const noexcept(noexcept( - JSONSerializer::from_json(std::declval()))) - { - return JSONSerializer::from_json(*this); - } - - /*! - @brief get special-case overload - - This overloads converts the current @ref basic_json in a different - @ref basic_json type - - @tparam BasicJsonType == @ref basic_json - - @return a copy of *this, converted into @a BasicJsonType - - @complexity Depending on the implementation of the called `from_json()` - method. - - @since version 3.2.0 - */ - template < typename BasicJsonType, - detail::enable_if_t < - detail::is_basic_json::value, - int > = 0 > - BasicJsonType get_impl(detail::priority_tag<2> /*unused*/) const - { - return *this; - } - - /*! - @brief get special-case overload - - This overloads avoids a lot of template boilerplate, it can be seen as the - identity method - - @tparam BasicJsonType == @ref basic_json - - @return a copy of *this - - @complexity Constant. - - @since version 2.1.0 - */ - template::value, - int> = 0> - basic_json get_impl(detail::priority_tag<3> /*unused*/) const - { - return *this; - } - - /*! - @brief get a pointer value (explicit) - @copydoc get() - */ - template::value, - int> = 0> - constexpr auto get_impl(detail::priority_tag<4> /*unused*/) const noexcept - -> decltype(std::declval().template get_ptr()) - { - // delegate the call to get_ptr - return get_ptr(); - } - - public: - /*! - @brief get a (pointer) value (explicit) - - Performs explicit type conversion between the JSON value and a compatible value if required. - - - If the requested type is a pointer to the internally stored JSON value that pointer is returned. - No copies are made. - - - If the requested type is the current @ref basic_json, or a different @ref basic_json convertible - from the current @ref basic_json. - - - Otherwise the value is converted by calling the @ref json_serializer `from_json()` - method. - - @tparam ValueTypeCV the provided value type - @tparam ValueType the returned value type - - @return copy of the JSON value, converted to @tparam ValueType if necessary - - @throw what @ref json_serializer `from_json()` method throws if conversion is required - - @since version 2.1.0 - */ - template < typename ValueTypeCV, typename ValueType = detail::uncvref_t> -#if defined(JSON_HAS_CPP_14) - constexpr -#endif - auto get() const noexcept( - noexcept(std::declval().template get_impl(detail::priority_tag<4> {}))) - -> decltype(std::declval().template get_impl(detail::priority_tag<4> {})) - { - // we cannot static_assert on ValueTypeCV being non-const, because - // there is support for get(), which is why we - // still need the uncvref - static_assert(!std::is_reference::value, - "get() cannot be used with reference types, you might want to use get_ref()"); - return get_impl(detail::priority_tag<4> {}); - } - - /*! - @brief get a pointer value (explicit) - - Explicit pointer access to the internally stored JSON value. No copies are - made. - - @warning The pointer becomes invalid if the underlying JSON object - changes. - - @tparam PointerType pointer type; must be a pointer to @ref array_t, @ref - object_t, @ref string_t, @ref boolean_t, @ref number_integer_t, - @ref number_unsigned_t, or @ref number_float_t. - - @return pointer to the internally stored JSON value if the requested - pointer type @a PointerType fits to the JSON value; `nullptr` otherwise - - @complexity Constant. - - @liveexample{The example below shows how pointers to internal values of a - JSON value can be requested. Note that no type conversions are made and a - `nullptr` is returned if the value and the requested pointer type does not - match.,get__PointerType} - - @sa see @ref get_ptr() for explicit pointer-member access - - @since version 1.0.0 - */ - template::value, int>::type = 0> - auto get() noexcept -> decltype(std::declval().template get_ptr()) - { - // delegate the call to get_ptr - return get_ptr(); - } - - /*! - @brief get a value (explicit) - - Explicit type conversion between the JSON value and a compatible value. - The value is filled into the input parameter by calling the @ref json_serializer - `from_json()` method. - - The function is equivalent to executing - @code {.cpp} - ValueType v; - JSONSerializer::from_json(*this, v); - @endcode - - This overloads is chosen if: - - @a ValueType is not @ref basic_json, - - @ref json_serializer has a `from_json()` method of the form - `void from_json(const basic_json&, ValueType&)`, and - - @tparam ValueType the input parameter type. - - @return the input parameter, allowing chaining calls. - - @throw what @ref json_serializer `from_json()` method throws - - @liveexample{The example below shows several conversions from JSON values - to other types. There a few things to note: (1) Floating-point numbers can - be converted to integers\, (2) A JSON array can be converted to a standard - `std::vector`\, (3) A JSON object can be converted to C++ - associative containers such as `std::unordered_map`.,get_to} - - @since version 3.3.0 - */ - template < typename ValueType, - detail::enable_if_t < - !detail::is_basic_json::value&& - detail::has_from_json::value, - int > = 0 > - ValueType & get_to(ValueType& v) const noexcept(noexcept( - JSONSerializer::from_json(std::declval(), v))) - { - JSONSerializer::from_json(*this, v); - return v; - } - - // specialization to allow to call get_to with a basic_json value - // see https://github.com/nlohmann/json/issues/2175 - template::value, - int> = 0> - ValueType & get_to(ValueType& v) const - { - v = *this; - return v; - } - - template < - typename T, std::size_t N, - typename Array = T (&)[N], // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) - detail::enable_if_t < - detail::has_from_json::value, int > = 0 > - Array get_to(T (&v)[N]) const // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) - noexcept(noexcept(JSONSerializer::from_json( - std::declval(), v))) - { - JSONSerializer::from_json(*this, v); - return v; - } - - /*! - @brief get a reference value (implicit) - - Implicit reference access to the internally stored JSON value. No copies - are made. - - @warning Writing data to the referee of the result yields an undefined - state. - - @tparam ReferenceType reference type; must be a reference to @ref array_t, - @ref object_t, @ref string_t, @ref boolean_t, @ref number_integer_t, or - @ref number_float_t. Enforced by static assertion. - - @return reference to the internally stored JSON value if the requested - reference type @a ReferenceType fits to the JSON value; throws - type_error.303 otherwise - - @throw type_error.303 in case passed type @a ReferenceType is incompatible - with the stored JSON value; see example below - - @complexity Constant. - - @liveexample{The example shows several calls to `get_ref()`.,get_ref} - - @since version 1.1.0 - */ - template::value, int>::type = 0> - ReferenceType get_ref() - { - // delegate call to get_ref_impl - return get_ref_impl(*this); - } - - /*! - @brief get a reference value (implicit) - @copydoc get_ref() - */ - template < typename ReferenceType, typename std::enable_if < - std::is_reference::value&& - std::is_const::type>::value, int >::type = 0 > - ReferenceType get_ref() const - { - // delegate call to get_ref_impl - return get_ref_impl(*this); - } - - /*! - @brief get a value (implicit) - - Implicit type conversion between the JSON value and a compatible value. - The call is realized by calling @ref get() const. - - @tparam ValueType non-pointer type compatible to the JSON value, for - instance `int` for JSON integer numbers, `bool` for JSON booleans, or - `std::vector` types for JSON arrays. The character type of @ref string_t - as well as an initializer list of this type is excluded to avoid - ambiguities as these types implicitly convert to `std::string`. - - @return copy of the JSON value, converted to type @a ValueType - - @throw type_error.302 in case passed type @a ValueType is incompatible - to the JSON value type (e.g., the JSON value is of type boolean, but a - string is requested); see example below - - @complexity Linear in the size of the JSON value. - - @liveexample{The example below shows several conversions from JSON values - to other types. There a few things to note: (1) Floating-point numbers can - be converted to integers\, (2) A JSON array can be converted to a standard - `std::vector`\, (3) A JSON object can be converted to C++ - associative containers such as `std::unordered_map`.,operator__ValueType} - - @since version 1.0.0 - */ - template < typename ValueType, typename std::enable_if < - detail::conjunction < - detail::negation>, - detail::negation>>, - detail::negation>, - detail::negation>, - detail::negation>>, - -#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914)) - detail::negation>, -#endif - detail::is_detected_lazy - >::value, int >::type = 0 > - JSON_EXPLICIT operator ValueType() const - { - // delegate the call to get<>() const - return get(); - } - - /*! - @return reference to the binary value - - @throw type_error.302 if the value is not binary - - @sa see @ref is_binary() to check if the value is binary - - @since version 3.8.0 - */ - binary_t& get_binary() - { - if (!is_binary()) - { - JSON_THROW(type_error::create(302, "type must be binary, but is " + std::string(type_name()), *this)); - } - - return *get_ptr(); - } - - /// @copydoc get_binary() - const binary_t& get_binary() const - { - if (!is_binary()) - { - JSON_THROW(type_error::create(302, "type must be binary, but is " + std::string(type_name()), *this)); - } - - return *get_ptr(); - } - - /// @} - - - //////////////////// - // element access // - //////////////////// - - /// @name element access - /// Access to the JSON value. - /// @{ - - /*! - @brief access specified array element with bounds checking - - Returns a reference to the element at specified location @a idx, with - bounds checking. - - @param[in] idx index of the element to access - - @return reference to the element at index @a idx - - @throw type_error.304 if the JSON value is not an array; in this case, - calling `at` with an index makes no sense. See example below. - @throw out_of_range.401 if the index @a idx is out of range of the array; - that is, `idx >= size()`. See example below. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes in the JSON value. - - @complexity Constant. - - @since version 1.0.0 - - @liveexample{The example below shows how array elements can be read and - written using `at()`. It also demonstrates the different exceptions that - can be thrown.,at__size_type} - */ - reference at(size_type idx) - { - // at only works for arrays - if (JSON_HEDLEY_LIKELY(is_array())) - { - JSON_TRY - { - return set_parent(m_value.array->at(idx)); - } - JSON_CATCH (std::out_of_range&) - { - // create better exception explanation - JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range", *this)); - } - } - else - { - JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name()), *this)); - } - } - - /*! - @brief access specified array element with bounds checking - - Returns a const reference to the element at specified location @a idx, - with bounds checking. - - @param[in] idx index of the element to access - - @return const reference to the element at index @a idx - - @throw type_error.304 if the JSON value is not an array; in this case, - calling `at` with an index makes no sense. See example below. - @throw out_of_range.401 if the index @a idx is out of range of the array; - that is, `idx >= size()`. See example below. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes in the JSON value. - - @complexity Constant. - - @since version 1.0.0 - - @liveexample{The example below shows how array elements can be read using - `at()`. It also demonstrates the different exceptions that can be thrown., - at__size_type_const} - */ - const_reference at(size_type idx) const - { - // at only works for arrays - if (JSON_HEDLEY_LIKELY(is_array())) - { - JSON_TRY - { - return m_value.array->at(idx); - } - JSON_CATCH (std::out_of_range&) - { - // create better exception explanation - JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range", *this)); - } - } - else - { - JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name()), *this)); - } - } - - /*! - @brief access specified object element with bounds checking - - Returns a reference to the element at with specified key @a key, with - bounds checking. - - @param[in] key key of the element to access - - @return reference to the element at key @a key - - @throw type_error.304 if the JSON value is not an object; in this case, - calling `at` with a key makes no sense. See example below. - @throw out_of_range.403 if the key @a key is is not stored in the object; - that is, `find(key) == end()`. See example below. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes in the JSON value. - - @complexity Logarithmic in the size of the container. - - @sa see @ref operator[](const typename object_t::key_type&) for unchecked - access by reference - @sa see @ref value() for access by value with a default value - - @since version 1.0.0 - - @liveexample{The example below shows how object elements can be read and - written using `at()`. It also demonstrates the different exceptions that - can be thrown.,at__object_t_key_type} - */ - reference at(const typename object_t::key_type& key) - { - // at only works for objects - if (JSON_HEDLEY_LIKELY(is_object())) - { - JSON_TRY - { - return set_parent(m_value.object->at(key)); - } - JSON_CATCH (std::out_of_range&) - { - // create better exception explanation - JSON_THROW(out_of_range::create(403, "key '" + key + "' not found", *this)); - } - } - else - { - JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name()), *this)); - } - } - - /*! - @brief access specified object element with bounds checking - - Returns a const reference to the element at with specified key @a key, - with bounds checking. - - @param[in] key key of the element to access - - @return const reference to the element at key @a key - - @throw type_error.304 if the JSON value is not an object; in this case, - calling `at` with a key makes no sense. See example below. - @throw out_of_range.403 if the key @a key is is not stored in the object; - that is, `find(key) == end()`. See example below. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes in the JSON value. - - @complexity Logarithmic in the size of the container. - - @sa see @ref operator[](const typename object_t::key_type&) for unchecked - access by reference - @sa see @ref value() for access by value with a default value - - @since version 1.0.0 - - @liveexample{The example below shows how object elements can be read using - `at()`. It also demonstrates the different exceptions that can be thrown., - at__object_t_key_type_const} - */ - const_reference at(const typename object_t::key_type& key) const - { - // at only works for objects - if (JSON_HEDLEY_LIKELY(is_object())) - { - JSON_TRY - { - return m_value.object->at(key); - } - JSON_CATCH (std::out_of_range&) - { - // create better exception explanation - JSON_THROW(out_of_range::create(403, "key '" + key + "' not found", *this)); - } - } - else - { - JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name()), *this)); - } - } - - /*! - @brief access specified array element - - Returns a reference to the element at specified location @a idx. - - @note If @a idx is beyond the range of the array (i.e., `idx >= size()`), - then the array is silently filled up with `null` values to make `idx` a - valid reference to the last stored element. - - @param[in] idx index of the element to access - - @return reference to the element at index @a idx - - @throw type_error.305 if the JSON value is not an array or null; in that - cases, using the [] operator with an index makes no sense. - - @complexity Constant if @a idx is in the range of the array. Otherwise - linear in `idx - size()`. - - @liveexample{The example below shows how array elements can be read and - written using `[]` operator. Note the addition of `null` - values.,operatorarray__size_type} - - @since version 1.0.0 - */ - reference operator[](size_type idx) - { - // implicitly convert null value to an empty array - if (is_null()) - { - m_type = value_t::array; - m_value.array = create(); - assert_invariant(); - } - - // operator[] only works for arrays - if (JSON_HEDLEY_LIKELY(is_array())) - { - // fill up array with null values if given idx is outside range - if (idx >= m_value.array->size()) - { -#if JSON_DIAGNOSTICS - // remember array size & capacity before resizing - const auto old_size = m_value.array->size(); - const auto old_capacity = m_value.array->capacity(); -#endif - m_value.array->resize(idx + 1); - -#if JSON_DIAGNOSTICS - if (JSON_HEDLEY_UNLIKELY(m_value.array->capacity() != old_capacity)) - { - // capacity has changed: update all parents - set_parents(); - } - else - { - // set parent for values added above - set_parents(begin() + static_cast(old_size), static_cast(idx + 1 - old_size)); - } -#endif - assert_invariant(); - } - - return m_value.array->operator[](idx); - } - - JSON_THROW(type_error::create(305, "cannot use operator[] with a numeric argument with " + std::string(type_name()), *this)); - } - - /*! - @brief access specified array element - - Returns a const reference to the element at specified location @a idx. - - @param[in] idx index of the element to access - - @return const reference to the element at index @a idx - - @throw type_error.305 if the JSON value is not an array; in that case, - using the [] operator with an index makes no sense. - - @complexity Constant. - - @liveexample{The example below shows how array elements can be read using - the `[]` operator.,operatorarray__size_type_const} - - @since version 1.0.0 - */ - const_reference operator[](size_type idx) const - { - // const operator[] only works for arrays - if (JSON_HEDLEY_LIKELY(is_array())) - { - return m_value.array->operator[](idx); - } - - JSON_THROW(type_error::create(305, "cannot use operator[] with a numeric argument with " + std::string(type_name()), *this)); - } - - /*! - @brief access specified object element - - Returns a reference to the element at with specified key @a key. - - @note If @a key is not found in the object, then it is silently added to - the object and filled with a `null` value to make `key` a valid reference. - In case the value was `null` before, it is converted to an object. - - @param[in] key key of the element to access - - @return reference to the element at key @a key - - @throw type_error.305 if the JSON value is not an object or null; in that - cases, using the [] operator with a key makes no sense. - - @complexity Logarithmic in the size of the container. - - @liveexample{The example below shows how object elements can be read and - written using the `[]` operator.,operatorarray__key_type} - - @sa see @ref at(const typename object_t::key_type&) for access by reference - with range checking - @sa see @ref value() for access by value with a default value - - @since version 1.0.0 - */ - reference operator[](const typename object_t::key_type& key) - { - // implicitly convert null value to an empty object - if (is_null()) - { - m_type = value_t::object; - m_value.object = create(); - assert_invariant(); - } - - // operator[] only works for objects - if (JSON_HEDLEY_LIKELY(is_object())) - { - return set_parent(m_value.object->operator[](key)); - } - - JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()), *this)); - } - - /*! - @brief read-only access specified object element - - Returns a const reference to the element at with specified key @a key. No - bounds checking is performed. - - @warning If the element with key @a key does not exist, the behavior is - undefined. - - @param[in] key key of the element to access - - @return const reference to the element at key @a key - - @pre The element with key @a key must exist. **This precondition is - enforced with an assertion.** - - @throw type_error.305 if the JSON value is not an object; in that case, - using the [] operator with a key makes no sense. - - @complexity Logarithmic in the size of the container. - - @liveexample{The example below shows how object elements can be read using - the `[]` operator.,operatorarray__key_type_const} - - @sa see @ref at(const typename object_t::key_type&) for access by reference - with range checking - @sa see @ref value() for access by value with a default value - - @since version 1.0.0 - */ - const_reference operator[](const typename object_t::key_type& key) const - { - // const operator[] only works for objects - if (JSON_HEDLEY_LIKELY(is_object())) - { - JSON_ASSERT(m_value.object->find(key) != m_value.object->end()); - return m_value.object->find(key)->second; - } - - JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()), *this)); - } - - /*! - @brief access specified object element - - Returns a reference to the element at with specified key @a key. - - @note If @a key is not found in the object, then it is silently added to - the object and filled with a `null` value to make `key` a valid reference. - In case the value was `null` before, it is converted to an object. - - @param[in] key key of the element to access - - @return reference to the element at key @a key - - @throw type_error.305 if the JSON value is not an object or null; in that - cases, using the [] operator with a key makes no sense. - - @complexity Logarithmic in the size of the container. - - @liveexample{The example below shows how object elements can be read and - written using the `[]` operator.,operatorarray__key_type} - - @sa see @ref at(const typename object_t::key_type&) for access by reference - with range checking - @sa see @ref value() for access by value with a default value - - @since version 1.1.0 - */ - template - JSON_HEDLEY_NON_NULL(2) - reference operator[](T* key) - { - // implicitly convert null to object - if (is_null()) - { - m_type = value_t::object; - m_value = value_t::object; - assert_invariant(); - } - - // at only works for objects - if (JSON_HEDLEY_LIKELY(is_object())) - { - return set_parent(m_value.object->operator[](key)); - } - - JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()), *this)); - } - - /*! - @brief read-only access specified object element - - Returns a const reference to the element at with specified key @a key. No - bounds checking is performed. - - @warning If the element with key @a key does not exist, the behavior is - undefined. - - @param[in] key key of the element to access - - @return const reference to the element at key @a key - - @pre The element with key @a key must exist. **This precondition is - enforced with an assertion.** - - @throw type_error.305 if the JSON value is not an object; in that case, - using the [] operator with a key makes no sense. - - @complexity Logarithmic in the size of the container. - - @liveexample{The example below shows how object elements can be read using - the `[]` operator.,operatorarray__key_type_const} - - @sa see @ref at(const typename object_t::key_type&) for access by reference - with range checking - @sa see @ref value() for access by value with a default value - - @since version 1.1.0 - */ - template - JSON_HEDLEY_NON_NULL(2) - const_reference operator[](T* key) const - { - // at only works for objects - if (JSON_HEDLEY_LIKELY(is_object())) - { - JSON_ASSERT(m_value.object->find(key) != m_value.object->end()); - return m_value.object->find(key)->second; - } - - JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()), *this)); - } - - /*! - @brief access specified object element with default value - - Returns either a copy of an object's element at the specified key @a key - or a given default value if no element with key @a key exists. - - The function is basically equivalent to executing - @code {.cpp} - try { - return at(key); - } catch(out_of_range) { - return default_value; - } - @endcode - - @note Unlike @ref at(const typename object_t::key_type&), this function - does not throw if the given key @a key was not found. - - @note Unlike @ref operator[](const typename object_t::key_type& key), this - function does not implicitly add an element to the position defined by @a - key. This function is furthermore also applicable to const objects. - - @param[in] key key of the element to access - @param[in] default_value the value to return if @a key is not found - - @tparam ValueType type compatible to JSON values, for instance `int` for - JSON integer numbers, `bool` for JSON booleans, or `std::vector` types for - JSON arrays. Note the type of the expected value at @a key and the default - value @a default_value must be compatible. - - @return copy of the element at key @a key or @a default_value if @a key - is not found - - @throw type_error.302 if @a default_value does not match the type of the - value at @a key - @throw type_error.306 if the JSON value is not an object; in that case, - using `value()` with a key makes no sense. - - @complexity Logarithmic in the size of the container. - - @liveexample{The example below shows how object elements can be queried - with a default value.,basic_json__value} - - @sa see @ref at(const typename object_t::key_type&) for access by reference - with range checking - @sa see @ref operator[](const typename object_t::key_type&) for unchecked - access by reference - - @since version 1.0.0 - */ - // using std::is_convertible in a std::enable_if will fail when using explicit conversions - template < class ValueType, typename std::enable_if < - detail::is_getable::value - && !std::is_same::value, int >::type = 0 > - ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const - { - // at only works for objects - if (JSON_HEDLEY_LIKELY(is_object())) - { - // if key is found, return value and given default value otherwise - const auto it = find(key); - if (it != end()) - { - return it->template get(); - } - - return default_value; - } - - JSON_THROW(type_error::create(306, "cannot use value() with " + std::string(type_name()), *this)); - } - - /*! - @brief overload for a default value of type const char* - @copydoc basic_json::value(const typename object_t::key_type&, const ValueType&) const - */ - string_t value(const typename object_t::key_type& key, const char* default_value) const - { - return value(key, string_t(default_value)); - } - - /*! - @brief access specified object element via JSON Pointer with default value - - Returns either a copy of an object's element at the specified key @a key - or a given default value if no element with key @a key exists. - - The function is basically equivalent to executing - @code {.cpp} - try { - return at(ptr); - } catch(out_of_range) { - return default_value; - } - @endcode - - @note Unlike @ref at(const json_pointer&), this function does not throw - if the given key @a key was not found. - - @param[in] ptr a JSON pointer to the element to access - @param[in] default_value the value to return if @a ptr found no value - - @tparam ValueType type compatible to JSON values, for instance `int` for - JSON integer numbers, `bool` for JSON booleans, or `std::vector` types for - JSON arrays. Note the type of the expected value at @a key and the default - value @a default_value must be compatible. - - @return copy of the element at key @a key or @a default_value if @a key - is not found - - @throw type_error.302 if @a default_value does not match the type of the - value at @a ptr - @throw type_error.306 if the JSON value is not an object; in that case, - using `value()` with a key makes no sense. - - @complexity Logarithmic in the size of the container. - - @liveexample{The example below shows how object elements can be queried - with a default value.,basic_json__value_ptr} - - @sa see @ref operator[](const json_pointer&) for unchecked access by reference - - @since version 2.0.2 - */ - template::value, int>::type = 0> - ValueType value(const json_pointer& ptr, const ValueType& default_value) const - { - // at only works for objects - if (JSON_HEDLEY_LIKELY(is_object())) - { - // if pointer resolves a value, return it or use default value - JSON_TRY - { - return ptr.get_checked(this).template get(); - } - JSON_INTERNAL_CATCH (out_of_range&) - { - return default_value; - } - } - - JSON_THROW(type_error::create(306, "cannot use value() with " + std::string(type_name()), *this)); - } - - /*! - @brief overload for a default value of type const char* - @copydoc basic_json::value(const json_pointer&, ValueType) const - */ - JSON_HEDLEY_NON_NULL(3) - string_t value(const json_pointer& ptr, const char* default_value) const - { - return value(ptr, string_t(default_value)); - } - - /*! - @brief access the first element - - Returns a reference to the first element in the container. For a JSON - container `c`, the expression `c.front()` is equivalent to `*c.begin()`. - - @return In case of a structured type (array or object), a reference to the - first element is returned. In case of number, string, boolean, or binary - values, a reference to the value is returned. - - @complexity Constant. - - @pre The JSON value must not be `null` (would throw `std::out_of_range`) - or an empty array or object (undefined behavior, **guarded by - assertions**). - @post The JSON value remains unchanged. - - @throw invalid_iterator.214 when called on `null` value - - @liveexample{The following code shows an example for `front()`.,front} - - @sa see @ref back() -- access the last element - - @since version 1.0.0 - */ - reference front() - { - return *begin(); - } - - /*! - @copydoc basic_json::front() - */ - const_reference front() const - { - return *cbegin(); - } - - /*! - @brief access the last element - - Returns a reference to the last element in the container. For a JSON - container `c`, the expression `c.back()` is equivalent to - @code {.cpp} - auto tmp = c.end(); - --tmp; - return *tmp; - @endcode - - @return In case of a structured type (array or object), a reference to the - last element is returned. In case of number, string, boolean, or binary - values, a reference to the value is returned. - - @complexity Constant. - - @pre The JSON value must not be `null` (would throw `std::out_of_range`) - or an empty array or object (undefined behavior, **guarded by - assertions**). - @post The JSON value remains unchanged. - - @throw invalid_iterator.214 when called on a `null` value. See example - below. - - @liveexample{The following code shows an example for `back()`.,back} - - @sa see @ref front() -- access the first element - - @since version 1.0.0 - */ - reference back() - { - auto tmp = end(); - --tmp; - return *tmp; - } - - /*! - @copydoc basic_json::back() - */ - const_reference back() const - { - auto tmp = cend(); - --tmp; - return *tmp; - } - - /*! - @brief remove element given an iterator - - Removes the element specified by iterator @a pos. The iterator @a pos must - be valid and dereferenceable. Thus the `end()` iterator (which is valid, - but is not dereferenceable) cannot be used as a value for @a pos. - - If called on a primitive type other than `null`, the resulting JSON value - will be `null`. - - @param[in] pos iterator to the element to remove - @return Iterator following the last removed element. If the iterator @a - pos refers to the last element, the `end()` iterator is returned. - - @tparam IteratorType an @ref iterator or @ref const_iterator - - @post Invalidates iterators and references at or after the point of the - erase, including the `end()` iterator. - - @throw type_error.307 if called on a `null` value; example: `"cannot use - erase() with null"` - @throw invalid_iterator.202 if called on an iterator which does not belong - to the current JSON value; example: `"iterator does not fit current - value"` - @throw invalid_iterator.205 if called on a primitive type with invalid - iterator (i.e., any iterator which is not `begin()`); example: `"iterator - out of range"` - - @complexity The complexity depends on the type: - - objects: amortized constant - - arrays: linear in distance between @a pos and the end of the container - - strings and binary: linear in the length of the member - - other types: constant - - @liveexample{The example shows the result of `erase()` for different JSON - types.,erase__IteratorType} - - @sa see @ref erase(IteratorType, IteratorType) -- removes the elements in - the given range - @sa see @ref erase(const typename object_t::key_type&) -- removes the element - from an object at the given key - @sa see @ref erase(const size_type) -- removes the element from an array at - the given index - - @since version 1.0.0 - */ - template < class IteratorType, typename std::enable_if < - std::is_same::value || - std::is_same::value, int >::type - = 0 > - IteratorType erase(IteratorType pos) - { - // make sure iterator fits the current value - if (JSON_HEDLEY_UNLIKELY(this != pos.m_object)) - { - JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", *this)); - } - - IteratorType result = end(); - - switch (m_type) - { - case value_t::boolean: - case value_t::number_float: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::string: - case value_t::binary: - { - if (JSON_HEDLEY_UNLIKELY(!pos.m_it.primitive_iterator.is_begin())) - { - JSON_THROW(invalid_iterator::create(205, "iterator out of range", *this)); - } - - if (is_string()) - { - AllocatorType alloc; - std::allocator_traits::destroy(alloc, m_value.string); - std::allocator_traits::deallocate(alloc, m_value.string, 1); - m_value.string = nullptr; - } - else if (is_binary()) - { - AllocatorType alloc; - std::allocator_traits::destroy(alloc, m_value.binary); - std::allocator_traits::deallocate(alloc, m_value.binary, 1); - m_value.binary = nullptr; - } - - m_type = value_t::null; - assert_invariant(); - break; - } - - case value_t::object: - { - result.m_it.object_iterator = m_value.object->erase(pos.m_it.object_iterator); - break; - } - - case value_t::array: - { - result.m_it.array_iterator = m_value.array->erase(pos.m_it.array_iterator); - break; - } - - case value_t::null: - case value_t::discarded: - default: - JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name()), *this)); - } - - return result; - } - - /*! - @brief remove elements given an iterator range - - Removes the element specified by the range `[first; last)`. The iterator - @a first does not need to be dereferenceable if `first == last`: erasing - an empty range is a no-op. - - If called on a primitive type other than `null`, the resulting JSON value - will be `null`. - - @param[in] first iterator to the beginning of the range to remove - @param[in] last iterator past the end of the range to remove - @return Iterator following the last removed element. If the iterator @a - second refers to the last element, the `end()` iterator is returned. - - @tparam IteratorType an @ref iterator or @ref const_iterator - - @post Invalidates iterators and references at or after the point of the - erase, including the `end()` iterator. - - @throw type_error.307 if called on a `null` value; example: `"cannot use - erase() with null"` - @throw invalid_iterator.203 if called on iterators which does not belong - to the current JSON value; example: `"iterators do not fit current value"` - @throw invalid_iterator.204 if called on a primitive type with invalid - iterators (i.e., if `first != begin()` and `last != end()`); example: - `"iterators out of range"` - - @complexity The complexity depends on the type: - - objects: `log(size()) + std::distance(first, last)` - - arrays: linear in the distance between @a first and @a last, plus linear - in the distance between @a last and end of the container - - strings and binary: linear in the length of the member - - other types: constant - - @liveexample{The example shows the result of `erase()` for different JSON - types.,erase__IteratorType_IteratorType} - - @sa see @ref erase(IteratorType) -- removes the element at a given position - @sa see @ref erase(const typename object_t::key_type&) -- removes the element - from an object at the given key - @sa see @ref erase(const size_type) -- removes the element from an array at - the given index - - @since version 1.0.0 - */ - template < class IteratorType, typename std::enable_if < - std::is_same::value || - std::is_same::value, int >::type - = 0 > - IteratorType erase(IteratorType first, IteratorType last) - { - // make sure iterator fits the current value - if (JSON_HEDLEY_UNLIKELY(this != first.m_object || this != last.m_object)) - { - JSON_THROW(invalid_iterator::create(203, "iterators do not fit current value", *this)); - } - - IteratorType result = end(); - - switch (m_type) - { - case value_t::boolean: - case value_t::number_float: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::string: - case value_t::binary: - { - if (JSON_HEDLEY_LIKELY(!first.m_it.primitive_iterator.is_begin() - || !last.m_it.primitive_iterator.is_end())) - { - JSON_THROW(invalid_iterator::create(204, "iterators out of range", *this)); - } - - if (is_string()) - { - AllocatorType alloc; - std::allocator_traits::destroy(alloc, m_value.string); - std::allocator_traits::deallocate(alloc, m_value.string, 1); - m_value.string = nullptr; - } - else if (is_binary()) - { - AllocatorType alloc; - std::allocator_traits::destroy(alloc, m_value.binary); - std::allocator_traits::deallocate(alloc, m_value.binary, 1); - m_value.binary = nullptr; - } - - m_type = value_t::null; - assert_invariant(); - break; - } - - case value_t::object: - { - result.m_it.object_iterator = m_value.object->erase(first.m_it.object_iterator, - last.m_it.object_iterator); - break; - } - - case value_t::array: - { - result.m_it.array_iterator = m_value.array->erase(first.m_it.array_iterator, - last.m_it.array_iterator); - break; - } - - case value_t::null: - case value_t::discarded: - default: - JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name()), *this)); - } - - return result; - } - - /*! - @brief remove element from a JSON object given a key - - Removes elements from a JSON object with the key value @a key. - - @param[in] key value of the elements to remove - - @return Number of elements removed. If @a ObjectType is the default - `std::map` type, the return value will always be `0` (@a key was not - found) or `1` (@a key was found). - - @post References and iterators to the erased elements are invalidated. - Other references and iterators are not affected. - - @throw type_error.307 when called on a type other than JSON object; - example: `"cannot use erase() with null"` - - @complexity `log(size()) + count(key)` - - @liveexample{The example shows the effect of `erase()`.,erase__key_type} - - @sa see @ref erase(IteratorType) -- removes the element at a given position - @sa see @ref erase(IteratorType, IteratorType) -- removes the elements in - the given range - @sa see @ref erase(const size_type) -- removes the element from an array at - the given index - - @since version 1.0.0 - */ - size_type erase(const typename object_t::key_type& key) - { - // this erase only works for objects - if (JSON_HEDLEY_LIKELY(is_object())) - { - return m_value.object->erase(key); - } - - JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name()), *this)); - } - - /*! - @brief remove element from a JSON array given an index - - Removes element from a JSON array at the index @a idx. - - @param[in] idx index of the element to remove - - @throw type_error.307 when called on a type other than JSON object; - example: `"cannot use erase() with null"` - @throw out_of_range.401 when `idx >= size()`; example: `"array index 17 - is out of range"` - - @complexity Linear in distance between @a idx and the end of the container. - - @liveexample{The example shows the effect of `erase()`.,erase__size_type} - - @sa see @ref erase(IteratorType) -- removes the element at a given position - @sa see @ref erase(IteratorType, IteratorType) -- removes the elements in - the given range - @sa see @ref erase(const typename object_t::key_type&) -- removes the element - from an object at the given key - - @since version 1.0.0 - */ - void erase(const size_type idx) - { - // this erase only works for arrays - if (JSON_HEDLEY_LIKELY(is_array())) - { - if (JSON_HEDLEY_UNLIKELY(idx >= size())) - { - JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range", *this)); - } - - m_value.array->erase(m_value.array->begin() + static_cast(idx)); - } - else - { - JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name()), *this)); - } - } - - /// @} - - - //////////// - // lookup // - //////////// - - /// @name lookup - /// @{ - - /*! - @brief find an element in a JSON object - - Finds an element in a JSON object with key equivalent to @a key. If the - element is not found or the JSON value is not an object, end() is - returned. - - @note This method always returns @ref end() when executed on a JSON type - that is not an object. - - @param[in] key key value of the element to search for. - - @return Iterator to an element with key equivalent to @a key. If no such - element is found or the JSON value is not an object, past-the-end (see - @ref end()) iterator is returned. - - @complexity Logarithmic in the size of the JSON object. - - @liveexample{The example shows how `find()` is used.,find__key_type} - - @sa see @ref contains(KeyT&&) const -- checks whether a key exists - - @since version 1.0.0 - */ - template - iterator find(KeyT&& key) - { - auto result = end(); - - if (is_object()) - { - result.m_it.object_iterator = m_value.object->find(std::forward(key)); - } - - return result; - } - - /*! - @brief find an element in a JSON object - @copydoc find(KeyT&&) - */ - template - const_iterator find(KeyT&& key) const - { - auto result = cend(); - - if (is_object()) - { - result.m_it.object_iterator = m_value.object->find(std::forward(key)); - } - - return result; - } - - /*! - @brief returns the number of occurrences of a key in a JSON object - - Returns the number of elements with key @a key. If ObjectType is the - default `std::map` type, the return value will always be `0` (@a key was - not found) or `1` (@a key was found). - - @note This method always returns `0` when executed on a JSON type that is - not an object. - - @param[in] key key value of the element to count - - @return Number of elements with key @a key. If the JSON value is not an - object, the return value will be `0`. - - @complexity Logarithmic in the size of the JSON object. - - @liveexample{The example shows how `count()` is used.,count} - - @since version 1.0.0 - */ - template - size_type count(KeyT&& key) const - { - // return 0 for all nonobject types - return is_object() ? m_value.object->count(std::forward(key)) : 0; - } - - /*! - @brief check the existence of an element in a JSON object - - Check whether an element exists in a JSON object with key equivalent to - @a key. If the element is not found or the JSON value is not an object, - false is returned. - - @note This method always returns false when executed on a JSON type - that is not an object. - - @param[in] key key value to check its existence. - - @return true if an element with specified @a key exists. If no such - element with such key is found or the JSON value is not an object, - false is returned. - - @complexity Logarithmic in the size of the JSON object. - - @liveexample{The following code shows an example for `contains()`.,contains} - - @sa see @ref find(KeyT&&) -- returns an iterator to an object element - @sa see @ref contains(const json_pointer&) const -- checks the existence for a JSON pointer - - @since version 3.6.0 - */ - template < typename KeyT, typename std::enable_if < - !std::is_same::type, json_pointer>::value, int >::type = 0 > - bool contains(KeyT && key) const - { - return is_object() && m_value.object->find(std::forward(key)) != m_value.object->end(); - } - - /*! - @brief check the existence of an element in a JSON object given a JSON pointer - - Check whether the given JSON pointer @a ptr can be resolved in the current - JSON value. - - @note This method can be executed on any JSON value type. - - @param[in] ptr JSON pointer to check its existence. - - @return true if the JSON pointer can be resolved to a stored value, false - otherwise. - - @post If `j.contains(ptr)` returns true, it is safe to call `j[ptr]`. - - @throw parse_error.106 if an array index begins with '0' - @throw parse_error.109 if an array index was not a number - - @complexity Logarithmic in the size of the JSON object. - - @liveexample{The following code shows an example for `contains()`.,contains_json_pointer} - - @sa see @ref contains(KeyT &&) const -- checks the existence of a key - - @since version 3.7.0 - */ - bool contains(const json_pointer& ptr) const - { - return ptr.contains(this); - } - - /// @} - - - /////////////// - // iterators // - /////////////// - - /// @name iterators - /// @{ - - /*! - @brief returns an iterator to the first element - - Returns an iterator to the first element. - - @image html range-begin-end.svg "Illustration from cppreference.com" - - @return iterator to the first element - - @complexity Constant. - - @requirement This function helps `basic_json` satisfying the - [Container](https://en.cppreference.com/w/cpp/named_req/Container) - requirements: - - The complexity is constant. - - @liveexample{The following code shows an example for `begin()`.,begin} - - @sa see @ref cbegin() -- returns a const iterator to the beginning - @sa see @ref end() -- returns an iterator to the end - @sa see @ref cend() -- returns a const iterator to the end - - @since version 1.0.0 - */ - iterator begin() noexcept - { - iterator result(this); - result.set_begin(); - return result; - } - - /*! - @copydoc basic_json::cbegin() - */ - const_iterator begin() const noexcept - { - return cbegin(); - } - - /*! - @brief returns a const iterator to the first element - - Returns a const iterator to the first element. - - @image html range-begin-end.svg "Illustration from cppreference.com" - - @return const iterator to the first element - - @complexity Constant. - - @requirement This function helps `basic_json` satisfying the - [Container](https://en.cppreference.com/w/cpp/named_req/Container) - requirements: - - The complexity is constant. - - Has the semantics of `const_cast(*this).begin()`. - - @liveexample{The following code shows an example for `cbegin()`.,cbegin} - - @sa see @ref begin() -- returns an iterator to the beginning - @sa see @ref end() -- returns an iterator to the end - @sa see @ref cend() -- returns a const iterator to the end - - @since version 1.0.0 - */ - const_iterator cbegin() const noexcept - { - const_iterator result(this); - result.set_begin(); - return result; - } - - /*! - @brief returns an iterator to one past the last element - - Returns an iterator to one past the last element. - - @image html range-begin-end.svg "Illustration from cppreference.com" - - @return iterator one past the last element - - @complexity Constant. - - @requirement This function helps `basic_json` satisfying the - [Container](https://en.cppreference.com/w/cpp/named_req/Container) - requirements: - - The complexity is constant. - - @liveexample{The following code shows an example for `end()`.,end} - - @sa see @ref cend() -- returns a const iterator to the end - @sa see @ref begin() -- returns an iterator to the beginning - @sa see @ref cbegin() -- returns a const iterator to the beginning - - @since version 1.0.0 - */ - iterator end() noexcept - { - iterator result(this); - result.set_end(); - return result; - } - - /*! - @copydoc basic_json::cend() - */ - const_iterator end() const noexcept - { - return cend(); - } - - /*! - @brief returns a const iterator to one past the last element - - Returns a const iterator to one past the last element. - - @image html range-begin-end.svg "Illustration from cppreference.com" - - @return const iterator one past the last element - - @complexity Constant. - - @requirement This function helps `basic_json` satisfying the - [Container](https://en.cppreference.com/w/cpp/named_req/Container) - requirements: - - The complexity is constant. - - Has the semantics of `const_cast(*this).end()`. - - @liveexample{The following code shows an example for `cend()`.,cend} - - @sa see @ref end() -- returns an iterator to the end - @sa see @ref begin() -- returns an iterator to the beginning - @sa see @ref cbegin() -- returns a const iterator to the beginning - - @since version 1.0.0 - */ - const_iterator cend() const noexcept - { - const_iterator result(this); - result.set_end(); - return result; - } - - /*! - @brief returns an iterator to the reverse-beginning - - Returns an iterator to the reverse-beginning; that is, the last element. - - @image html range-rbegin-rend.svg "Illustration from cppreference.com" - - @complexity Constant. - - @requirement This function helps `basic_json` satisfying the - [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer) - requirements: - - The complexity is constant. - - Has the semantics of `reverse_iterator(end())`. - - @liveexample{The following code shows an example for `rbegin()`.,rbegin} - - @sa see @ref crbegin() -- returns a const reverse iterator to the beginning - @sa see @ref rend() -- returns a reverse iterator to the end - @sa see @ref crend() -- returns a const reverse iterator to the end - - @since version 1.0.0 - */ - reverse_iterator rbegin() noexcept - { - return reverse_iterator(end()); - } - - /*! - @copydoc basic_json::crbegin() - */ - const_reverse_iterator rbegin() const noexcept - { - return crbegin(); - } - - /*! - @brief returns an iterator to the reverse-end - - Returns an iterator to the reverse-end; that is, one before the first - element. - - @image html range-rbegin-rend.svg "Illustration from cppreference.com" - - @complexity Constant. - - @requirement This function helps `basic_json` satisfying the - [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer) - requirements: - - The complexity is constant. - - Has the semantics of `reverse_iterator(begin())`. - - @liveexample{The following code shows an example for `rend()`.,rend} - - @sa see @ref crend() -- returns a const reverse iterator to the end - @sa see @ref rbegin() -- returns a reverse iterator to the beginning - @sa see @ref crbegin() -- returns a const reverse iterator to the beginning - - @since version 1.0.0 - */ - reverse_iterator rend() noexcept - { - return reverse_iterator(begin()); - } - - /*! - @copydoc basic_json::crend() - */ - const_reverse_iterator rend() const noexcept - { - return crend(); - } - - /*! - @brief returns a const reverse iterator to the last element - - Returns a const iterator to the reverse-beginning; that is, the last - element. - - @image html range-rbegin-rend.svg "Illustration from cppreference.com" - - @complexity Constant. - - @requirement This function helps `basic_json` satisfying the - [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer) - requirements: - - The complexity is constant. - - Has the semantics of `const_cast(*this).rbegin()`. - - @liveexample{The following code shows an example for `crbegin()`.,crbegin} - - @sa see @ref rbegin() -- returns a reverse iterator to the beginning - @sa see @ref rend() -- returns a reverse iterator to the end - @sa see @ref crend() -- returns a const reverse iterator to the end - - @since version 1.0.0 - */ - const_reverse_iterator crbegin() const noexcept - { - return const_reverse_iterator(cend()); - } - - /*! - @brief returns a const reverse iterator to one before the first - - Returns a const reverse iterator to the reverse-end; that is, one before - the first element. - - @image html range-rbegin-rend.svg "Illustration from cppreference.com" - - @complexity Constant. - - @requirement This function helps `basic_json` satisfying the - [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer) - requirements: - - The complexity is constant. - - Has the semantics of `const_cast(*this).rend()`. - - @liveexample{The following code shows an example for `crend()`.,crend} - - @sa see @ref rend() -- returns a reverse iterator to the end - @sa see @ref rbegin() -- returns a reverse iterator to the beginning - @sa see @ref crbegin() -- returns a const reverse iterator to the beginning - - @since version 1.0.0 - */ - const_reverse_iterator crend() const noexcept - { - return const_reverse_iterator(cbegin()); - } - - public: - /*! - @brief wrapper to access iterator member functions in range-based for - - This function allows to access @ref iterator::key() and @ref - iterator::value() during range-based for loops. In these loops, a - reference to the JSON values is returned, so there is no access to the - underlying iterator. - - For loop without iterator_wrapper: - - @code{cpp} - for (auto it = j_object.begin(); it != j_object.end(); ++it) - { - std::cout << "key: " << it.key() << ", value:" << it.value() << '\n'; - } - @endcode - - Range-based for loop without iterator proxy: - - @code{cpp} - for (auto it : j_object) - { - // "it" is of type json::reference and has no key() member - std::cout << "value: " << it << '\n'; - } - @endcode - - Range-based for loop with iterator proxy: - - @code{cpp} - for (auto it : json::iterator_wrapper(j_object)) - { - std::cout << "key: " << it.key() << ", value:" << it.value() << '\n'; - } - @endcode - - @note When iterating over an array, `key()` will return the index of the - element as string (see example). - - @param[in] ref reference to a JSON value - @return iteration proxy object wrapping @a ref with an interface to use in - range-based for loops - - @liveexample{The following code shows how the wrapper is used,iterator_wrapper} - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes in the JSON value. - - @complexity Constant. - - @note The name of this function is not yet final and may change in the - future. - - @deprecated This stream operator is deprecated and will be removed in - future 4.0.0 of the library. Please use @ref items() instead; - that is, replace `json::iterator_wrapper(j)` with `j.items()`. - */ - JSON_HEDLEY_DEPRECATED_FOR(3.1.0, items()) - static iteration_proxy iterator_wrapper(reference ref) noexcept - { - return ref.items(); - } - - /*! - @copydoc iterator_wrapper(reference) - */ - JSON_HEDLEY_DEPRECATED_FOR(3.1.0, items()) - static iteration_proxy iterator_wrapper(const_reference ref) noexcept - { - return ref.items(); - } - - /*! - @brief helper to access iterator member functions in range-based for - - This function allows to access @ref iterator::key() and @ref - iterator::value() during range-based for loops. In these loops, a - reference to the JSON values is returned, so there is no access to the - underlying iterator. - - For loop without `items()` function: - - @code{cpp} - for (auto it = j_object.begin(); it != j_object.end(); ++it) - { - std::cout << "key: " << it.key() << ", value:" << it.value() << '\n'; - } - @endcode - - Range-based for loop without `items()` function: - - @code{cpp} - for (auto it : j_object) - { - // "it" is of type json::reference and has no key() member - std::cout << "value: " << it << '\n'; - } - @endcode - - Range-based for loop with `items()` function: - - @code{cpp} - for (auto& el : j_object.items()) - { - std::cout << "key: " << el.key() << ", value:" << el.value() << '\n'; - } - @endcode - - The `items()` function also allows to use - [structured bindings](https://en.cppreference.com/w/cpp/language/structured_binding) - (C++17): - - @code{cpp} - for (auto& [key, val] : j_object.items()) - { - std::cout << "key: " << key << ", value:" << val << '\n'; - } - @endcode - - @note When iterating over an array, `key()` will return the index of the - element as string (see example). For primitive types (e.g., numbers), - `key()` returns an empty string. - - @warning Using `items()` on temporary objects is dangerous. Make sure the - object's lifetime exeeds the iteration. See - for more - information. - - @return iteration proxy object wrapping @a ref with an interface to use in - range-based for loops - - @liveexample{The following code shows how the function is used.,items} - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes in the JSON value. - - @complexity Constant. - - @since version 3.1.0, structured bindings support since 3.5.0. - */ - iteration_proxy items() noexcept - { - return iteration_proxy(*this); - } - - /*! - @copydoc items() - */ - iteration_proxy items() const noexcept - { - return iteration_proxy(*this); - } - - /// @} - - - ////////////// - // capacity // - ////////////// - - /// @name capacity - /// @{ - - /*! - @brief checks whether the container is empty. - - Checks if a JSON value has no elements (i.e. whether its @ref size is `0`). - - @return The return value depends on the different types and is - defined as follows: - Value type | return value - ----------- | ------------- - null | `true` - boolean | `false` - string | `false` - number | `false` - binary | `false` - object | result of function `object_t::empty()` - array | result of function `array_t::empty()` - - @liveexample{The following code uses `empty()` to check if a JSON - object contains any elements.,empty} - - @complexity Constant, as long as @ref array_t and @ref object_t satisfy - the Container concept; that is, their `empty()` functions have constant - complexity. - - @iterators No changes. - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @note This function does not return whether a string stored as JSON value - is empty - it returns whether the JSON container itself is empty which is - false in the case of a string. - - @requirement This function helps `basic_json` satisfying the - [Container](https://en.cppreference.com/w/cpp/named_req/Container) - requirements: - - The complexity is constant. - - Has the semantics of `begin() == end()`. - - @sa see @ref size() -- returns the number of elements - - @since version 1.0.0 - */ - bool empty() const noexcept - { - switch (m_type) - { - case value_t::null: - { - // null values are empty - return true; - } - - case value_t::array: - { - // delegate call to array_t::empty() - return m_value.array->empty(); - } - - case value_t::object: - { - // delegate call to object_t::empty() - return m_value.object->empty(); - } - - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - { - // all other types are nonempty - return false; - } - } - } - - /*! - @brief returns the number of elements - - Returns the number of elements in a JSON value. - - @return The return value depends on the different types and is - defined as follows: - Value type | return value - ----------- | ------------- - null | `0` - boolean | `1` - string | `1` - number | `1` - binary | `1` - object | result of function object_t::size() - array | result of function array_t::size() - - @liveexample{The following code calls `size()` on the different value - types.,size} - - @complexity Constant, as long as @ref array_t and @ref object_t satisfy - the Container concept; that is, their size() functions have constant - complexity. - - @iterators No changes. - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @note This function does not return the length of a string stored as JSON - value - it returns the number of elements in the JSON value which is 1 in - the case of a string. - - @requirement This function helps `basic_json` satisfying the - [Container](https://en.cppreference.com/w/cpp/named_req/Container) - requirements: - - The complexity is constant. - - Has the semantics of `std::distance(begin(), end())`. - - @sa see @ref empty() -- checks whether the container is empty - @sa see @ref max_size() -- returns the maximal number of elements - - @since version 1.0.0 - */ - size_type size() const noexcept - { - switch (m_type) - { - case value_t::null: - { - // null values are empty - return 0; - } - - case value_t::array: - { - // delegate call to array_t::size() - return m_value.array->size(); - } - - case value_t::object: - { - // delegate call to object_t::size() - return m_value.object->size(); - } - - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - { - // all other types have size 1 - return 1; - } - } - } - - /*! - @brief returns the maximum possible number of elements - - Returns the maximum number of elements a JSON value is able to hold due to - system or library implementation limitations, i.e. `std::distance(begin(), - end())` for the JSON value. - - @return The return value depends on the different types and is - defined as follows: - Value type | return value - ----------- | ------------- - null | `0` (same as `size()`) - boolean | `1` (same as `size()`) - string | `1` (same as `size()`) - number | `1` (same as `size()`) - binary | `1` (same as `size()`) - object | result of function `object_t::max_size()` - array | result of function `array_t::max_size()` - - @liveexample{The following code calls `max_size()` on the different value - types. Note the output is implementation specific.,max_size} - - @complexity Constant, as long as @ref array_t and @ref object_t satisfy - the Container concept; that is, their `max_size()` functions have constant - complexity. - - @iterators No changes. - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @requirement This function helps `basic_json` satisfying the - [Container](https://en.cppreference.com/w/cpp/named_req/Container) - requirements: - - The complexity is constant. - - Has the semantics of returning `b.size()` where `b` is the largest - possible JSON value. - - @sa see @ref size() -- returns the number of elements - - @since version 1.0.0 - */ - size_type max_size() const noexcept - { - switch (m_type) - { - case value_t::array: - { - // delegate call to array_t::max_size() - return m_value.array->max_size(); - } - - case value_t::object: - { - // delegate call to object_t::max_size() - return m_value.object->max_size(); - } - - case value_t::null: - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - { - // all other types have max_size() == size() - return size(); - } - } - } - - /// @} - - - /////////////// - // modifiers // - /////////////// - - /// @name modifiers - /// @{ - - /*! - @brief clears the contents - - Clears the content of a JSON value and resets it to the default value as - if @ref basic_json(value_t) would have been called with the current value - type from @ref type(): - - Value type | initial value - ----------- | ------------- - null | `null` - boolean | `false` - string | `""` - number | `0` - binary | An empty byte vector - object | `{}` - array | `[]` - - @post Has the same effect as calling - @code {.cpp} - *this = basic_json(type()); - @endcode - - @liveexample{The example below shows the effect of `clear()` to different - JSON types.,clear} - - @complexity Linear in the size of the JSON value. - - @iterators All iterators, pointers and references related to this container - are invalidated. - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @sa see @ref basic_json(value_t) -- constructor that creates an object with the - same value than calling `clear()` - - @since version 1.0.0 - */ - void clear() noexcept - { - switch (m_type) - { - case value_t::number_integer: - { - m_value.number_integer = 0; - break; - } - - case value_t::number_unsigned: - { - m_value.number_unsigned = 0; - break; - } - - case value_t::number_float: - { - m_value.number_float = 0.0; - break; - } - - case value_t::boolean: - { - m_value.boolean = false; - break; - } - - case value_t::string: - { - m_value.string->clear(); - break; - } - - case value_t::binary: - { - m_value.binary->clear(); - break; - } - - case value_t::array: - { - m_value.array->clear(); - break; - } - - case value_t::object: - { - m_value.object->clear(); - break; - } - - case value_t::null: - case value_t::discarded: - default: - break; - } - } - - /*! - @brief add an object to an array - - Appends the given element @a val to the end of the JSON value. If the - function is called on a JSON null value, an empty array is created before - appending @a val. - - @param[in] val the value to add to the JSON array - - @throw type_error.308 when called on a type other than JSON array or - null; example: `"cannot use push_back() with number"` - - @complexity Amortized constant. - - @liveexample{The example shows how `push_back()` and `+=` can be used to - add elements to a JSON array. Note how the `null` value was silently - converted to a JSON array.,push_back} - - @since version 1.0.0 - */ - void push_back(basic_json&& val) - { - // push_back only works for null objects or arrays - if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_array()))) - { - JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()), *this)); - } - - // transform null object into an array - if (is_null()) - { - m_type = value_t::array; - m_value = value_t::array; - assert_invariant(); - } - - // add element to array (move semantics) - const auto old_capacity = m_value.array->capacity(); - m_value.array->push_back(std::move(val)); - set_parent(m_value.array->back(), old_capacity); - // if val is moved from, basic_json move constructor marks it null so we do not call the destructor - } - - /*! - @brief add an object to an array - @copydoc push_back(basic_json&&) - */ - reference operator+=(basic_json&& val) - { - push_back(std::move(val)); - return *this; - } - - /*! - @brief add an object to an array - @copydoc push_back(basic_json&&) - */ - void push_back(const basic_json& val) - { - // push_back only works for null objects or arrays - if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_array()))) - { - JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()), *this)); - } - - // transform null object into an array - if (is_null()) - { - m_type = value_t::array; - m_value = value_t::array; - assert_invariant(); - } - - // add element to array - const auto old_capacity = m_value.array->capacity(); - m_value.array->push_back(val); - set_parent(m_value.array->back(), old_capacity); - } - - /*! - @brief add an object to an array - @copydoc push_back(basic_json&&) - */ - reference operator+=(const basic_json& val) - { - push_back(val); - return *this; - } - - /*! - @brief add an object to an object - - Inserts the given element @a val to the JSON object. If the function is - called on a JSON null value, an empty object is created before inserting - @a val. - - @param[in] val the value to add to the JSON object - - @throw type_error.308 when called on a type other than JSON object or - null; example: `"cannot use push_back() with number"` - - @complexity Logarithmic in the size of the container, O(log(`size()`)). - - @liveexample{The example shows how `push_back()` and `+=` can be used to - add elements to a JSON object. Note how the `null` value was silently - converted to a JSON object.,push_back__object_t__value} - - @since version 1.0.0 - */ - void push_back(const typename object_t::value_type& val) - { - // push_back only works for null objects or objects - if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_object()))) - { - JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()), *this)); - } - - // transform null object into an object - if (is_null()) - { - m_type = value_t::object; - m_value = value_t::object; - assert_invariant(); - } - - // add element to object - auto res = m_value.object->insert(val); - set_parent(res.first->second); - } - - /*! - @brief add an object to an object - @copydoc push_back(const typename object_t::value_type&) - */ - reference operator+=(const typename object_t::value_type& val) - { - push_back(val); - return *this; - } - - /*! - @brief add an object to an object - - This function allows to use `push_back` with an initializer list. In case - - 1. the current value is an object, - 2. the initializer list @a init contains only two elements, and - 3. the first element of @a init is a string, - - @a init is converted into an object element and added using - @ref push_back(const typename object_t::value_type&). Otherwise, @a init - is converted to a JSON value and added using @ref push_back(basic_json&&). - - @param[in] init an initializer list - - @complexity Linear in the size of the initializer list @a init. - - @note This function is required to resolve an ambiguous overload error, - because pairs like `{"key", "value"}` can be both interpreted as - `object_t::value_type` or `std::initializer_list`, see - https://github.com/nlohmann/json/issues/235 for more information. - - @liveexample{The example shows how initializer lists are treated as - objects when possible.,push_back__initializer_list} - */ - void push_back(initializer_list_t init) - { - if (is_object() && init.size() == 2 && (*init.begin())->is_string()) - { - basic_json&& key = init.begin()->moved_or_copied(); - push_back(typename object_t::value_type( - std::move(key.get_ref()), (init.begin() + 1)->moved_or_copied())); - } - else - { - push_back(basic_json(init)); - } - } - - /*! - @brief add an object to an object - @copydoc push_back(initializer_list_t) - */ - reference operator+=(initializer_list_t init) - { - push_back(init); - return *this; - } - - /*! - @brief add an object to an array - - Creates a JSON value from the passed parameters @a args to the end of the - JSON value. If the function is called on a JSON null value, an empty array - is created before appending the value created from @a args. - - @param[in] args arguments to forward to a constructor of @ref basic_json - @tparam Args compatible types to create a @ref basic_json object - - @return reference to the inserted element - - @throw type_error.311 when called on a type other than JSON array or - null; example: `"cannot use emplace_back() with number"` - - @complexity Amortized constant. - - @liveexample{The example shows how `push_back()` can be used to add - elements to a JSON array. Note how the `null` value was silently converted - to a JSON array.,emplace_back} - - @since version 2.0.8, returns reference since 3.7.0 - */ - template - reference emplace_back(Args&& ... args) - { - // emplace_back only works for null objects or arrays - if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_array()))) - { - JSON_THROW(type_error::create(311, "cannot use emplace_back() with " + std::string(type_name()), *this)); - } - - // transform null object into an array - if (is_null()) - { - m_type = value_t::array; - m_value = value_t::array; - assert_invariant(); - } - - // add element to array (perfect forwarding) - const auto old_capacity = m_value.array->capacity(); - m_value.array->emplace_back(std::forward(args)...); - return set_parent(m_value.array->back(), old_capacity); - } - - /*! - @brief add an object to an object if key does not exist - - Inserts a new element into a JSON object constructed in-place with the - given @a args if there is no element with the key in the container. If the - function is called on a JSON null value, an empty object is created before - appending the value created from @a args. - - @param[in] args arguments to forward to a constructor of @ref basic_json - @tparam Args compatible types to create a @ref basic_json object - - @return a pair consisting of an iterator to the inserted element, or the - already-existing element if no insertion happened, and a bool - denoting whether the insertion took place. - - @throw type_error.311 when called on a type other than JSON object or - null; example: `"cannot use emplace() with number"` - - @complexity Logarithmic in the size of the container, O(log(`size()`)). - - @liveexample{The example shows how `emplace()` can be used to add elements - to a JSON object. Note how the `null` value was silently converted to a - JSON object. Further note how no value is added if there was already one - value stored with the same key.,emplace} - - @since version 2.0.8 - */ - template - std::pair emplace(Args&& ... args) - { - // emplace only works for null objects or arrays - if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_object()))) - { - JSON_THROW(type_error::create(311, "cannot use emplace() with " + std::string(type_name()), *this)); - } - - // transform null object into an object - if (is_null()) - { - m_type = value_t::object; - m_value = value_t::object; - assert_invariant(); - } - - // add element to array (perfect forwarding) - auto res = m_value.object->emplace(std::forward(args)...); - set_parent(res.first->second); - - // create result iterator and set iterator to the result of emplace - auto it = begin(); - it.m_it.object_iterator = res.first; - - // return pair of iterator and boolean - return {it, res.second}; - } - - /// Helper for insertion of an iterator - /// @note: This uses std::distance to support GCC 4.8, - /// see https://github.com/nlohmann/json/pull/1257 - template - iterator insert_iterator(const_iterator pos, Args&& ... args) - { - iterator result(this); - JSON_ASSERT(m_value.array != nullptr); - - auto insert_pos = std::distance(m_value.array->begin(), pos.m_it.array_iterator); - m_value.array->insert(pos.m_it.array_iterator, std::forward(args)...); - result.m_it.array_iterator = m_value.array->begin() + insert_pos; - - // This could have been written as: - // result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, cnt, val); - // but the return value of insert is missing in GCC 4.8, so it is written this way instead. - - set_parents(); - return result; - } - - /*! - @brief inserts element - - Inserts element @a val before iterator @a pos. - - @param[in] pos iterator before which the content will be inserted; may be - the end() iterator - @param[in] val element to insert - @return iterator pointing to the inserted @a val. - - @throw type_error.309 if called on JSON values other than arrays; - example: `"cannot use insert() with string"` - @throw invalid_iterator.202 if @a pos is not an iterator of *this; - example: `"iterator does not fit current value"` - - @complexity Constant plus linear in the distance between @a pos and end of - the container. - - @liveexample{The example shows how `insert()` is used.,insert} - - @since version 1.0.0 - */ - iterator insert(const_iterator pos, const basic_json& val) - { - // insert only works for arrays - if (JSON_HEDLEY_LIKELY(is_array())) - { - // check if iterator pos fits to this JSON value - if (JSON_HEDLEY_UNLIKELY(pos.m_object != this)) - { - JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", *this)); - } - - // insert to array and return iterator - return insert_iterator(pos, val); - } - - JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()), *this)); - } - - /*! - @brief inserts element - @copydoc insert(const_iterator, const basic_json&) - */ - iterator insert(const_iterator pos, basic_json&& val) - { - return insert(pos, val); - } - - /*! - @brief inserts elements - - Inserts @a cnt copies of @a val before iterator @a pos. - - @param[in] pos iterator before which the content will be inserted; may be - the end() iterator - @param[in] cnt number of copies of @a val to insert - @param[in] val element to insert - @return iterator pointing to the first element inserted, or @a pos if - `cnt==0` - - @throw type_error.309 if called on JSON values other than arrays; example: - `"cannot use insert() with string"` - @throw invalid_iterator.202 if @a pos is not an iterator of *this; - example: `"iterator does not fit current value"` - - @complexity Linear in @a cnt plus linear in the distance between @a pos - and end of the container. - - @liveexample{The example shows how `insert()` is used.,insert__count} - - @since version 1.0.0 - */ - iterator insert(const_iterator pos, size_type cnt, const basic_json& val) - { - // insert only works for arrays - if (JSON_HEDLEY_LIKELY(is_array())) - { - // check if iterator pos fits to this JSON value - if (JSON_HEDLEY_UNLIKELY(pos.m_object != this)) - { - JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", *this)); - } - - // insert to array and return iterator - return insert_iterator(pos, cnt, val); - } - - JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()), *this)); - } - - /*! - @brief inserts elements - - Inserts elements from range `[first, last)` before iterator @a pos. - - @param[in] pos iterator before which the content will be inserted; may be - the end() iterator - @param[in] first begin of the range of elements to insert - @param[in] last end of the range of elements to insert - - @throw type_error.309 if called on JSON values other than arrays; example: - `"cannot use insert() with string"` - @throw invalid_iterator.202 if @a pos is not an iterator of *this; - example: `"iterator does not fit current value"` - @throw invalid_iterator.210 if @a first and @a last do not belong to the - same JSON value; example: `"iterators do not fit"` - @throw invalid_iterator.211 if @a first or @a last are iterators into - container for which insert is called; example: `"passed iterators may not - belong to container"` - - @return iterator pointing to the first element inserted, or @a pos if - `first==last` - - @complexity Linear in `std::distance(first, last)` plus linear in the - distance between @a pos and end of the container. - - @liveexample{The example shows how `insert()` is used.,insert__range} - - @since version 1.0.0 - */ - iterator insert(const_iterator pos, const_iterator first, const_iterator last) - { - // insert only works for arrays - if (JSON_HEDLEY_UNLIKELY(!is_array())) - { - JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()), *this)); - } - - // check if iterator pos fits to this JSON value - if (JSON_HEDLEY_UNLIKELY(pos.m_object != this)) - { - JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", *this)); - } - - // check if range iterators belong to the same JSON object - if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) - { - JSON_THROW(invalid_iterator::create(210, "iterators do not fit", *this)); - } - - if (JSON_HEDLEY_UNLIKELY(first.m_object == this)) - { - JSON_THROW(invalid_iterator::create(211, "passed iterators may not belong to container", *this)); - } - - // insert to array and return iterator - return insert_iterator(pos, first.m_it.array_iterator, last.m_it.array_iterator); - } - - /*! - @brief inserts elements - - Inserts elements from initializer list @a ilist before iterator @a pos. - - @param[in] pos iterator before which the content will be inserted; may be - the end() iterator - @param[in] ilist initializer list to insert the values from - - @throw type_error.309 if called on JSON values other than arrays; example: - `"cannot use insert() with string"` - @throw invalid_iterator.202 if @a pos is not an iterator of *this; - example: `"iterator does not fit current value"` - - @return iterator pointing to the first element inserted, or @a pos if - `ilist` is empty - - @complexity Linear in `ilist.size()` plus linear in the distance between - @a pos and end of the container. - - @liveexample{The example shows how `insert()` is used.,insert__ilist} - - @since version 1.0.0 - */ - iterator insert(const_iterator pos, initializer_list_t ilist) - { - // insert only works for arrays - if (JSON_HEDLEY_UNLIKELY(!is_array())) - { - JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()), *this)); - } - - // check if iterator pos fits to this JSON value - if (JSON_HEDLEY_UNLIKELY(pos.m_object != this)) - { - JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", *this)); - } - - // insert to array and return iterator - return insert_iterator(pos, ilist.begin(), ilist.end()); - } - - /*! - @brief inserts elements - - Inserts elements from range `[first, last)`. - - @param[in] first begin of the range of elements to insert - @param[in] last end of the range of elements to insert - - @throw type_error.309 if called on JSON values other than objects; example: - `"cannot use insert() with string"` - @throw invalid_iterator.202 if iterator @a first or @a last does does not - point to an object; example: `"iterators first and last must point to - objects"` - @throw invalid_iterator.210 if @a first and @a last do not belong to the - same JSON value; example: `"iterators do not fit"` - - @complexity Logarithmic: `O(N*log(size() + N))`, where `N` is the number - of elements to insert. - - @liveexample{The example shows how `insert()` is used.,insert__range_object} - - @since version 3.0.0 - */ - void insert(const_iterator first, const_iterator last) - { - // insert only works for objects - if (JSON_HEDLEY_UNLIKELY(!is_object())) - { - JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()), *this)); - } - - // check if range iterators belong to the same JSON object - if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) - { - JSON_THROW(invalid_iterator::create(210, "iterators do not fit", *this)); - } - - // passed iterators must belong to objects - if (JSON_HEDLEY_UNLIKELY(!first.m_object->is_object())) - { - JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects", *this)); - } - - m_value.object->insert(first.m_it.object_iterator, last.m_it.object_iterator); - } - - /*! - @brief updates a JSON object from another object, overwriting existing keys - - Inserts all values from JSON object @a j and overwrites existing keys. - - @param[in] j JSON object to read values from - @param[in] merge_objects when true, existing keys are not overwritten, but - contents of objects are merged recursively - (default: false) - - @throw type_error.312 if called on JSON values other than objects; example: - `"cannot use update() with string"` - - @complexity O(N*log(size() + N)), where N is the number of elements to - insert. - - @liveexample{The example shows how `update()` is used.,update} - - @sa https://docs.python.org/3.6/library/stdtypes.html#dict.update - - @since version 3.0.0, `merge_objects` parameter added in 3.10.4. - */ - void update(const_reference j, bool merge_objects = false) - { - update(j.begin(), j.end(), merge_objects); - } - - /*! - @brief updates a JSON object from another object, overwriting existing keys - - Inserts all values from from range `[first, last)` and overwrites existing - keys. - - @param[in] first begin of the range of elements to insert - @param[in] last end of the range of elements to insert - @param[in] merge_objects when true, existing keys are not overwritten, but - contents of objects are merged recursively - (default: false) - - @throw type_error.312 if called on JSON values other than objects; example: - `"cannot use update() with string"` - @throw type_error.312 if iterator @a first or @a last does does not - point to an object; example: `"cannot use update() with string"` - @throw invalid_iterator.210 if @a first and @a last do not belong to the - same JSON value; example: `"iterators do not fit"` - - @complexity O(N*log(size() + N)), where N is the number of elements to - insert. - - @liveexample{The example shows how `update()` is used__range.,update} - - @sa https://docs.python.org/3.6/library/stdtypes.html#dict.update - - @since version 3.0.0, `merge_objects` parameter added in 3.10.4. - */ - void update(const_iterator first, const_iterator last, bool merge_objects = false) - { - // implicitly convert null value to an empty object - if (is_null()) - { - m_type = value_t::object; - m_value.object = create(); - assert_invariant(); - } - - if (JSON_HEDLEY_UNLIKELY(!is_object())) - { - JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name()), *this)); - } - - // check if range iterators belong to the same JSON object - if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) - { - JSON_THROW(invalid_iterator::create(210, "iterators do not fit", *this)); - } - - // passed iterators must belong to objects - if (JSON_HEDLEY_UNLIKELY(!first.m_object->is_object())) - { - JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(first.m_object->type_name()), *first.m_object)); - } - - for (auto it = first; it != last; ++it) - { - if (merge_objects && it.value().is_object()) - { - auto it2 = m_value.object->find(it.key()); - if (it2 != m_value.object->end()) - { - it2->second.update(it.value(), true); - continue; - } - } - m_value.object->operator[](it.key()) = it.value(); -#if JSON_DIAGNOSTICS - m_value.object->operator[](it.key()).m_parent = this; -#endif - } - } - - /*! - @brief exchanges the values - - Exchanges the contents of the JSON value with those of @a other. Does not - invoke any move, copy, or swap operations on individual elements. All - iterators and references remain valid. The past-the-end iterator is - invalidated. - - @param[in,out] other JSON value to exchange the contents with - - @complexity Constant. - - @liveexample{The example below shows how JSON values can be swapped with - `swap()`.,swap__reference} - - @since version 1.0.0 - */ - void swap(reference other) noexcept ( - std::is_nothrow_move_constructible::value&& - std::is_nothrow_move_assignable::value&& - std::is_nothrow_move_constructible::value&& - std::is_nothrow_move_assignable::value - ) - { - std::swap(m_type, other.m_type); - std::swap(m_value, other.m_value); - - set_parents(); - other.set_parents(); - assert_invariant(); - } - - /*! - @brief exchanges the values - - Exchanges the contents of the JSON value from @a left with those of @a right. Does not - invoke any move, copy, or swap operations on individual elements. All - iterators and references remain valid. The past-the-end iterator is - invalidated. implemented as a friend function callable via ADL. - - @param[in,out] left JSON value to exchange the contents with - @param[in,out] right JSON value to exchange the contents with - - @complexity Constant. - - @liveexample{The example below shows how JSON values can be swapped with - `swap()`.,swap__reference} - - @since version 1.0.0 - */ - friend void swap(reference left, reference right) noexcept ( - std::is_nothrow_move_constructible::value&& - std::is_nothrow_move_assignable::value&& - std::is_nothrow_move_constructible::value&& - std::is_nothrow_move_assignable::value - ) - { - left.swap(right); - } - - /*! - @brief exchanges the values - - Exchanges the contents of a JSON array with those of @a other. Does not - invoke any move, copy, or swap operations on individual elements. All - iterators and references remain valid. The past-the-end iterator is - invalidated. - - @param[in,out] other array to exchange the contents with - - @throw type_error.310 when JSON value is not an array; example: `"cannot - use swap() with string"` - - @complexity Constant. - - @liveexample{The example below shows how arrays can be swapped with - `swap()`.,swap__array_t} - - @since version 1.0.0 - */ - void swap(array_t& other) // NOLINT(bugprone-exception-escape) - { - // swap only works for arrays - if (JSON_HEDLEY_LIKELY(is_array())) - { - std::swap(*(m_value.array), other); - } - else - { - JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()), *this)); - } - } - - /*! - @brief exchanges the values - - Exchanges the contents of a JSON object with those of @a other. Does not - invoke any move, copy, or swap operations on individual elements. All - iterators and references remain valid. The past-the-end iterator is - invalidated. - - @param[in,out] other object to exchange the contents with - - @throw type_error.310 when JSON value is not an object; example: - `"cannot use swap() with string"` - - @complexity Constant. - - @liveexample{The example below shows how objects can be swapped with - `swap()`.,swap__object_t} - - @since version 1.0.0 - */ - void swap(object_t& other) // NOLINT(bugprone-exception-escape) - { - // swap only works for objects - if (JSON_HEDLEY_LIKELY(is_object())) - { - std::swap(*(m_value.object), other); - } - else - { - JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()), *this)); - } - } - - /*! - @brief exchanges the values - - Exchanges the contents of a JSON string with those of @a other. Does not - invoke any move, copy, or swap operations on individual elements. All - iterators and references remain valid. The past-the-end iterator is - invalidated. - - @param[in,out] other string to exchange the contents with - - @throw type_error.310 when JSON value is not a string; example: `"cannot - use swap() with boolean"` - - @complexity Constant. - - @liveexample{The example below shows how strings can be swapped with - `swap()`.,swap__string_t} - - @since version 1.0.0 - */ - void swap(string_t& other) // NOLINT(bugprone-exception-escape) - { - // swap only works for strings - if (JSON_HEDLEY_LIKELY(is_string())) - { - std::swap(*(m_value.string), other); - } - else - { - JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()), *this)); - } - } - - /*! - @brief exchanges the values - - Exchanges the contents of a JSON string with those of @a other. Does not - invoke any move, copy, or swap operations on individual elements. All - iterators and references remain valid. The past-the-end iterator is - invalidated. - - @param[in,out] other binary to exchange the contents with - - @throw type_error.310 when JSON value is not a string; example: `"cannot - use swap() with boolean"` - - @complexity Constant. - - @liveexample{The example below shows how strings can be swapped with - `swap()`.,swap__binary_t} - - @since version 3.8.0 - */ - void swap(binary_t& other) // NOLINT(bugprone-exception-escape) - { - // swap only works for strings - if (JSON_HEDLEY_LIKELY(is_binary())) - { - std::swap(*(m_value.binary), other); - } - else - { - JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()), *this)); - } - } - - /// @copydoc swap(binary_t&) - void swap(typename binary_t::container_type& other) // NOLINT(bugprone-exception-escape) - { - // swap only works for strings - if (JSON_HEDLEY_LIKELY(is_binary())) - { - std::swap(*(m_value.binary), other); - } - else - { - JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()), *this)); - } - } - - /// @} - - public: - ////////////////////////////////////////// - // lexicographical comparison operators // - ////////////////////////////////////////// - - /// @name lexicographical comparison operators - /// @{ - - /*! - @brief comparison: equal - - Compares two JSON values for equality according to the following rules: - - Two JSON values are equal if (1) they are from the same type and (2) - their stored values are the same according to their respective - `operator==`. - - Integer and floating-point numbers are automatically converted before - comparison. Note that two NaN values are always treated as unequal. - - Two JSON null values are equal. - - @note Floating-point inside JSON values numbers are compared with - `json::number_float_t::operator==` which is `double::operator==` by - default. To compare floating-point while respecting an epsilon, an alternative - [comparison function](https://github.com/mariokonrad/marnav/blob/master/include/marnav/math/floatingpoint.hpp#L34-#L39) - could be used, for instance - @code {.cpp} - template::value, T>::type> - inline bool is_same(T a, T b, T epsilon = std::numeric_limits::epsilon()) noexcept - { - return std::abs(a - b) <= epsilon; - } - @endcode - Or you can self-defined operator equal function like this: - @code {.cpp} - bool my_equal(const_reference lhs, const_reference rhs) { - const auto lhs_type lhs.type(); - const auto rhs_type rhs.type(); - if (lhs_type == rhs_type) { - switch(lhs_type) - // self_defined case - case value_t::number_float: - return std::abs(lhs - rhs) <= std::numeric_limits::epsilon(); - // other cases remain the same with the original - ... - } - ... - } - @endcode - - @note NaN values never compare equal to themselves or to other NaN values. - - @param[in] lhs first JSON value to consider - @param[in] rhs second JSON value to consider - @return whether the values @a lhs and @a rhs are equal - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @complexity Linear. - - @liveexample{The example demonstrates comparing several JSON - types.,operator__equal} - - @since version 1.0.0 - */ - friend bool operator==(const_reference lhs, const_reference rhs) noexcept - { -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wfloat-equal" -#endif - const auto lhs_type = lhs.type(); - const auto rhs_type = rhs.type(); - - if (lhs_type == rhs_type) - { - switch (lhs_type) - { - case value_t::array: - return *lhs.m_value.array == *rhs.m_value.array; - - case value_t::object: - return *lhs.m_value.object == *rhs.m_value.object; - - case value_t::null: - return true; - - case value_t::string: - return *lhs.m_value.string == *rhs.m_value.string; - - case value_t::boolean: - return lhs.m_value.boolean == rhs.m_value.boolean; - - case value_t::number_integer: - return lhs.m_value.number_integer == rhs.m_value.number_integer; - - case value_t::number_unsigned: - return lhs.m_value.number_unsigned == rhs.m_value.number_unsigned; - - case value_t::number_float: - return lhs.m_value.number_float == rhs.m_value.number_float; - - case value_t::binary: - return *lhs.m_value.binary == *rhs.m_value.binary; - - case value_t::discarded: - default: - return false; - } - } - else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) - { - return static_cast(lhs.m_value.number_integer) == rhs.m_value.number_float; - } - else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) - { - return lhs.m_value.number_float == static_cast(rhs.m_value.number_integer); - } - else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) - { - return static_cast(lhs.m_value.number_unsigned) == rhs.m_value.number_float; - } - else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) - { - return lhs.m_value.number_float == static_cast(rhs.m_value.number_unsigned); - } - else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) - { - return static_cast(lhs.m_value.number_unsigned) == rhs.m_value.number_integer; - } - else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) - { - return lhs.m_value.number_integer == static_cast(rhs.m_value.number_unsigned); - } - - return false; -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif - } - - /*! - @brief comparison: equal - @copydoc operator==(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator==(const_reference lhs, ScalarType rhs) noexcept - { - return lhs == basic_json(rhs); - } - - /*! - @brief comparison: equal - @copydoc operator==(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator==(ScalarType lhs, const_reference rhs) noexcept - { - return basic_json(lhs) == rhs; - } - - /*! - @brief comparison: not equal - - Compares two JSON values for inequality by calculating `not (lhs == rhs)`. - - @param[in] lhs first JSON value to consider - @param[in] rhs second JSON value to consider - @return whether the values @a lhs and @a rhs are not equal - - @complexity Linear. - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @liveexample{The example demonstrates comparing several JSON - types.,operator__notequal} - - @since version 1.0.0 - */ - friend bool operator!=(const_reference lhs, const_reference rhs) noexcept - { - return !(lhs == rhs); - } - - /*! - @brief comparison: not equal - @copydoc operator!=(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator!=(const_reference lhs, ScalarType rhs) noexcept - { - return lhs != basic_json(rhs); - } - - /*! - @brief comparison: not equal - @copydoc operator!=(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator!=(ScalarType lhs, const_reference rhs) noexcept - { - return basic_json(lhs) != rhs; - } - - /*! - @brief comparison: less than - - Compares whether one JSON value @a lhs is less than another JSON value @a - rhs according to the following rules: - - If @a lhs and @a rhs have the same type, the values are compared using - the default `<` operator. - - Integer and floating-point numbers are automatically converted before - comparison - - In case @a lhs and @a rhs have different types, the values are ignored - and the order of the types is considered, see - @ref operator<(const value_t, const value_t). - - @param[in] lhs first JSON value to consider - @param[in] rhs second JSON value to consider - @return whether @a lhs is less than @a rhs - - @complexity Linear. - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @liveexample{The example demonstrates comparing several JSON - types.,operator__less} - - @since version 1.0.0 - */ - friend bool operator<(const_reference lhs, const_reference rhs) noexcept - { - const auto lhs_type = lhs.type(); - const auto rhs_type = rhs.type(); - - if (lhs_type == rhs_type) - { - switch (lhs_type) - { - case value_t::array: - // note parentheses are necessary, see - // https://github.com/nlohmann/json/issues/1530 - return (*lhs.m_value.array) < (*rhs.m_value.array); - - case value_t::object: - return (*lhs.m_value.object) < (*rhs.m_value.object); - - case value_t::null: - return false; - - case value_t::string: - return (*lhs.m_value.string) < (*rhs.m_value.string); - - case value_t::boolean: - return (lhs.m_value.boolean) < (rhs.m_value.boolean); - - case value_t::number_integer: - return (lhs.m_value.number_integer) < (rhs.m_value.number_integer); - - case value_t::number_unsigned: - return (lhs.m_value.number_unsigned) < (rhs.m_value.number_unsigned); - - case value_t::number_float: - return (lhs.m_value.number_float) < (rhs.m_value.number_float); - - case value_t::binary: - return (*lhs.m_value.binary) < (*rhs.m_value.binary); - - case value_t::discarded: - default: - return false; - } - } - else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) - { - return static_cast(lhs.m_value.number_integer) < rhs.m_value.number_float; - } - else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) - { - return lhs.m_value.number_float < static_cast(rhs.m_value.number_integer); - } - else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) - { - return static_cast(lhs.m_value.number_unsigned) < rhs.m_value.number_float; - } - else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) - { - return lhs.m_value.number_float < static_cast(rhs.m_value.number_unsigned); - } - else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) - { - return lhs.m_value.number_integer < static_cast(rhs.m_value.number_unsigned); - } - else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) - { - return static_cast(lhs.m_value.number_unsigned) < rhs.m_value.number_integer; - } - - // We only reach this line if we cannot compare values. In that case, - // we compare types. Note we have to call the operator explicitly, - // because MSVC has problems otherwise. - return operator<(lhs_type, rhs_type); - } - - /*! - @brief comparison: less than - @copydoc operator<(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator<(const_reference lhs, ScalarType rhs) noexcept - { - return lhs < basic_json(rhs); - } - - /*! - @brief comparison: less than - @copydoc operator<(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator<(ScalarType lhs, const_reference rhs) noexcept - { - return basic_json(lhs) < rhs; - } - - /*! - @brief comparison: less than or equal - - Compares whether one JSON value @a lhs is less than or equal to another - JSON value by calculating `not (rhs < lhs)`. - - @param[in] lhs first JSON value to consider - @param[in] rhs second JSON value to consider - @return whether @a lhs is less than or equal to @a rhs - - @complexity Linear. - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @liveexample{The example demonstrates comparing several JSON - types.,operator__greater} - - @since version 1.0.0 - */ - friend bool operator<=(const_reference lhs, const_reference rhs) noexcept - { - return !(rhs < lhs); - } - - /*! - @brief comparison: less than or equal - @copydoc operator<=(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator<=(const_reference lhs, ScalarType rhs) noexcept - { - return lhs <= basic_json(rhs); - } - - /*! - @brief comparison: less than or equal - @copydoc operator<=(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator<=(ScalarType lhs, const_reference rhs) noexcept - { - return basic_json(lhs) <= rhs; - } - - /*! - @brief comparison: greater than - - Compares whether one JSON value @a lhs is greater than another - JSON value by calculating `not (lhs <= rhs)`. - - @param[in] lhs first JSON value to consider - @param[in] rhs second JSON value to consider - @return whether @a lhs is greater than to @a rhs - - @complexity Linear. - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @liveexample{The example demonstrates comparing several JSON - types.,operator__lessequal} - - @since version 1.0.0 - */ - friend bool operator>(const_reference lhs, const_reference rhs) noexcept - { - return !(lhs <= rhs); - } - - /*! - @brief comparison: greater than - @copydoc operator>(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator>(const_reference lhs, ScalarType rhs) noexcept - { - return lhs > basic_json(rhs); - } - - /*! - @brief comparison: greater than - @copydoc operator>(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator>(ScalarType lhs, const_reference rhs) noexcept - { - return basic_json(lhs) > rhs; - } - - /*! - @brief comparison: greater than or equal - - Compares whether one JSON value @a lhs is greater than or equal to another - JSON value by calculating `not (lhs < rhs)`. - - @param[in] lhs first JSON value to consider - @param[in] rhs second JSON value to consider - @return whether @a lhs is greater than or equal to @a rhs - - @complexity Linear. - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @liveexample{The example demonstrates comparing several JSON - types.,operator__greaterequal} - - @since version 1.0.0 - */ - friend bool operator>=(const_reference lhs, const_reference rhs) noexcept - { - return !(lhs < rhs); - } - - /*! - @brief comparison: greater than or equal - @copydoc operator>=(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator>=(const_reference lhs, ScalarType rhs) noexcept - { - return lhs >= basic_json(rhs); - } - - /*! - @brief comparison: greater than or equal - @copydoc operator>=(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator>=(ScalarType lhs, const_reference rhs) noexcept - { - return basic_json(lhs) >= rhs; - } - - /// @} - - /////////////////// - // serialization // - /////////////////// - - /// @name serialization - /// @{ -#ifndef JSON_NO_IO - /*! - @brief serialize to stream - - Serialize the given JSON value @a j to the output stream @a o. The JSON - value will be serialized using the @ref dump member function. - - - The indentation of the output can be controlled with the member variable - `width` of the output stream @a o. For instance, using the manipulator - `std::setw(4)` on @a o sets the indentation level to `4` and the - serialization result is the same as calling `dump(4)`. - - - The indentation character can be controlled with the member variable - `fill` of the output stream @a o. For instance, the manipulator - `std::setfill('\\t')` sets indentation to use a tab character rather than - the default space character. - - @param[in,out] o stream to serialize to - @param[in] j JSON value to serialize - - @return the stream @a o - - @throw type_error.316 if a string stored inside the JSON value is not - UTF-8 encoded - - @complexity Linear. - - @liveexample{The example below shows the serialization with different - parameters to `width` to adjust the indentation level.,operator_serialize} - - @since version 1.0.0; indentation character added in version 3.0.0 - */ - friend std::ostream& operator<<(std::ostream& o, const basic_json& j) - { - // read width member and use it as indentation parameter if nonzero - const bool pretty_print = o.width() > 0; - const auto indentation = pretty_print ? o.width() : 0; - - // reset width to 0 for subsequent calls to this stream - o.width(0); - - // do the actual serialization - serializer s(detail::output_adapter(o), o.fill()); - s.dump(j, pretty_print, false, static_cast(indentation)); - return o; - } - - /*! - @brief serialize to stream - @deprecated This stream operator is deprecated and will be removed in - future 4.0.0 of the library. Please use - @ref operator<<(std::ostream&, const basic_json&) - instead; that is, replace calls like `j >> o;` with `o << j;`. - @since version 1.0.0; deprecated since version 3.0.0 - */ - JSON_HEDLEY_DEPRECATED_FOR(3.0.0, operator<<(std::ostream&, const basic_json&)) - friend std::ostream& operator>>(const basic_json& j, std::ostream& o) - { - return o << j; - } -#endif // JSON_NO_IO - /// @} - - - ///////////////////// - // deserialization // - ///////////////////// - - /// @name deserialization - /// @{ - - /*! - @brief deserialize from a compatible input - - @tparam InputType A compatible input, for instance - - an std::istream object - - a FILE pointer - - a C-style array of characters - - a pointer to a null-terminated string of single byte characters - - an object obj for which begin(obj) and end(obj) produces a valid pair of - iterators. - - @param[in] i input to read from - @param[in] cb a parser callback function of type @ref parser_callback_t - which is used to control the deserialization by filtering unwanted values - (optional) - @param[in] allow_exceptions whether to throw exceptions in case of a - parse error (optional, true by default) - @param[in] ignore_comments whether comments should be ignored and treated - like whitespace (true) or yield a parse error (true); (optional, false by - default) - - @return deserialized JSON value; in case of a parse error and - @a allow_exceptions set to `false`, the return value will be - value_t::discarded. - - @throw parse_error.101 if a parse error occurs; example: `""unexpected end - of input; expected string literal""` - @throw parse_error.102 if to_unicode fails or surrogate error - @throw parse_error.103 if to_unicode fails - - @complexity Linear in the length of the input. The parser is a predictive - LL(1) parser. The complexity can be higher if the parser callback function - @a cb or reading from the input @a i has a super-linear complexity. - - @note A UTF-8 byte order mark is silently ignored. - - @liveexample{The example below demonstrates the `parse()` function reading - from an array.,parse__array__parser_callback_t} - - @liveexample{The example below demonstrates the `parse()` function with - and without callback function.,parse__string__parser_callback_t} - - @liveexample{The example below demonstrates the `parse()` function with - and without callback function.,parse__istream__parser_callback_t} - - @liveexample{The example below demonstrates the `parse()` function reading - from a contiguous container.,parse__contiguouscontainer__parser_callback_t} - - @since version 2.0.3 (contiguous containers); version 3.9.0 allowed to - ignore comments. - */ - template - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json parse(InputType&& i, - const parser_callback_t cb = nullptr, - const bool allow_exceptions = true, - const bool ignore_comments = false) - { - basic_json result; - parser(detail::input_adapter(std::forward(i)), cb, allow_exceptions, ignore_comments).parse(true, result); - return result; - } - - /*! - @brief deserialize from a pair of character iterators - - The value_type of the iterator must be a integral type with size of 1, 2 or - 4 bytes, which will be interpreted respectively as UTF-8, UTF-16 and UTF-32. - - @param[in] first iterator to start of character range - @param[in] last iterator to end of character range - @param[in] cb a parser callback function of type @ref parser_callback_t - which is used to control the deserialization by filtering unwanted values - (optional) - @param[in] allow_exceptions whether to throw exceptions in case of a - parse error (optional, true by default) - @param[in] ignore_comments whether comments should be ignored and treated - like whitespace (true) or yield a parse error (true); (optional, false by - default) - - @return deserialized JSON value; in case of a parse error and - @a allow_exceptions set to `false`, the return value will be - value_t::discarded. - - @throw parse_error.101 if a parse error occurs; example: `""unexpected end - of input; expected string literal""` - @throw parse_error.102 if to_unicode fails or surrogate error - @throw parse_error.103 if to_unicode fails - */ - template - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json parse(IteratorType first, - IteratorType last, - const parser_callback_t cb = nullptr, - const bool allow_exceptions = true, - const bool ignore_comments = false) - { - basic_json result; - parser(detail::input_adapter(std::move(first), std::move(last)), cb, allow_exceptions, ignore_comments).parse(true, result); - return result; - } - - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, parse(ptr, ptr + len)) - static basic_json parse(detail::span_input_adapter&& i, - const parser_callback_t cb = nullptr, - const bool allow_exceptions = true, - const bool ignore_comments = false) - { - basic_json result; - parser(i.get(), cb, allow_exceptions, ignore_comments).parse(true, result); - return result; - } - - /*! - @brief check if the input is valid JSON - - Unlike the @ref parse(InputType&&, const parser_callback_t,const bool) - function, this function neither throws an exception in case of invalid JSON - input (i.e., a parse error) nor creates diagnostic information. - - @tparam InputType A compatible input, for instance - - an std::istream object - - a FILE pointer - - a C-style array of characters - - a pointer to a null-terminated string of single byte characters - - an object obj for which begin(obj) and end(obj) produces a valid pair of - iterators. - - @param[in] i input to read from - @param[in] ignore_comments whether comments should be ignored and treated - like whitespace (true) or yield a parse error (true); (optional, false by - default) - - @return Whether the input read from @a i is valid JSON. - - @complexity Linear in the length of the input. The parser is a predictive - LL(1) parser. - - @note A UTF-8 byte order mark is silently ignored. - - @liveexample{The example below demonstrates the `accept()` function reading - from a string.,accept__string} - */ - template - static bool accept(InputType&& i, - const bool ignore_comments = false) - { - return parser(detail::input_adapter(std::forward(i)), nullptr, false, ignore_comments).accept(true); - } - - template - static bool accept(IteratorType first, IteratorType last, - const bool ignore_comments = false) - { - return parser(detail::input_adapter(std::move(first), std::move(last)), nullptr, false, ignore_comments).accept(true); - } - - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, accept(ptr, ptr + len)) - static bool accept(detail::span_input_adapter&& i, - const bool ignore_comments = false) - { - return parser(i.get(), nullptr, false, ignore_comments).accept(true); - } - - /*! - @brief generate SAX events - - The SAX event lister must follow the interface of @ref json_sax. - - This function reads from a compatible input. Examples are: - - an std::istream object - - a FILE pointer - - a C-style array of characters - - a pointer to a null-terminated string of single byte characters - - an object obj for which begin(obj) and end(obj) produces a valid pair of - iterators. - - @param[in] i input to read from - @param[in,out] sax SAX event listener - @param[in] format the format to parse (JSON, CBOR, MessagePack, or UBJSON) - @param[in] strict whether the input has to be consumed completely - @param[in] ignore_comments whether comments should be ignored and treated - like whitespace (true) or yield a parse error (true); (optional, false by - default); only applies to the JSON file format. - - @return return value of the last processed SAX event - - @throw parse_error.101 if a parse error occurs; example: `""unexpected end - of input; expected string literal""` - @throw parse_error.102 if to_unicode fails or surrogate error - @throw parse_error.103 if to_unicode fails - - @complexity Linear in the length of the input. The parser is a predictive - LL(1) parser. The complexity can be higher if the SAX consumer @a sax has - a super-linear complexity. - - @note A UTF-8 byte order mark is silently ignored. - - @liveexample{The example below demonstrates the `sax_parse()` function - reading from string and processing the events with a user-defined SAX - event consumer.,sax_parse} - - @since version 3.2.0 - */ - template - JSON_HEDLEY_NON_NULL(2) - static bool sax_parse(InputType&& i, SAX* sax, - input_format_t format = input_format_t::json, - const bool strict = true, - const bool ignore_comments = false) - { - auto ia = detail::input_adapter(std::forward(i)); - return format == input_format_t::json - ? parser(std::move(ia), nullptr, true, ignore_comments).sax_parse(sax, strict) - : detail::binary_reader(std::move(ia)).sax_parse(format, sax, strict); - } - - template - JSON_HEDLEY_NON_NULL(3) - static bool sax_parse(IteratorType first, IteratorType last, SAX* sax, - input_format_t format = input_format_t::json, - const bool strict = true, - const bool ignore_comments = false) - { - auto ia = detail::input_adapter(std::move(first), std::move(last)); - return format == input_format_t::json - ? parser(std::move(ia), nullptr, true, ignore_comments).sax_parse(sax, strict) - : detail::binary_reader(std::move(ia)).sax_parse(format, sax, strict); - } - - template - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, sax_parse(ptr, ptr + len, ...)) - JSON_HEDLEY_NON_NULL(2) - static bool sax_parse(detail::span_input_adapter&& i, SAX* sax, - input_format_t format = input_format_t::json, - const bool strict = true, - const bool ignore_comments = false) - { - auto ia = i.get(); - return format == input_format_t::json - // NOLINTNEXTLINE(hicpp-move-const-arg,performance-move-const-arg) - ? parser(std::move(ia), nullptr, true, ignore_comments).sax_parse(sax, strict) - // NOLINTNEXTLINE(hicpp-move-const-arg,performance-move-const-arg) - : detail::binary_reader(std::move(ia)).sax_parse(format, sax, strict); - } -#ifndef JSON_NO_IO - /*! - @brief deserialize from stream - @deprecated This stream operator is deprecated and will be removed in - version 4.0.0 of the library. Please use - @ref operator>>(std::istream&, basic_json&) - instead; that is, replace calls like `j << i;` with `i >> j;`. - @since version 1.0.0; deprecated since version 3.0.0 - */ - JSON_HEDLEY_DEPRECATED_FOR(3.0.0, operator>>(std::istream&, basic_json&)) - friend std::istream& operator<<(basic_json& j, std::istream& i) - { - return operator>>(i, j); - } - - /*! - @brief deserialize from stream - - Deserializes an input stream to a JSON value. - - @param[in,out] i input stream to read a serialized JSON value from - @param[in,out] j JSON value to write the deserialized input to - - @throw parse_error.101 in case of an unexpected token - @throw parse_error.102 if to_unicode fails or surrogate error - @throw parse_error.103 if to_unicode fails - - @complexity Linear in the length of the input. The parser is a predictive - LL(1) parser. - - @note A UTF-8 byte order mark is silently ignored. - - @liveexample{The example below shows how a JSON value is constructed by - reading a serialization from a stream.,operator_deserialize} - - @sa parse(std::istream&, const parser_callback_t) for a variant with a - parser callback function to filter values while parsing - - @since version 1.0.0 - */ - friend std::istream& operator>>(std::istream& i, basic_json& j) - { - parser(detail::input_adapter(i)).parse(false, j); - return i; - } -#endif // JSON_NO_IO - /// @} - - /////////////////////////// - // convenience functions // - /////////////////////////// - - /*! - @brief return the type as string - - Returns the type name as string to be used in error messages - usually to - indicate that a function was called on a wrong JSON type. - - @return a string representation of a the @a m_type member: - Value type | return value - ----------- | ------------- - null | `"null"` - boolean | `"boolean"` - string | `"string"` - number | `"number"` (for all number types) - object | `"object"` - array | `"array"` - binary | `"binary"` - discarded | `"discarded"` - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @complexity Constant. - - @liveexample{The following code exemplifies `type_name()` for all JSON - types.,type_name} - - @sa see @ref type() -- return the type of the JSON value - @sa see @ref operator value_t() -- return the type of the JSON value (implicit) - - @since version 1.0.0, public since 2.1.0, `const char*` and `noexcept` - since 3.0.0 - */ - JSON_HEDLEY_RETURNS_NON_NULL - const char* type_name() const noexcept - { - { - switch (m_type) - { - case value_t::null: - return "null"; - case value_t::object: - return "object"; - case value_t::array: - return "array"; - case value_t::string: - return "string"; - case value_t::boolean: - return "boolean"; - case value_t::binary: - return "binary"; - case value_t::discarded: - return "discarded"; - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - default: - return "number"; - } - } - } - - - JSON_PRIVATE_UNLESS_TESTED: - ////////////////////// - // member variables // - ////////////////////// - - /// the type of the current element - value_t m_type = value_t::null; - - /// the value of the current element - json_value m_value = {}; - -#if JSON_DIAGNOSTICS - /// a pointer to a parent value (for debugging purposes) - basic_json* m_parent = nullptr; -#endif - - ////////////////////////////////////////// - // binary serialization/deserialization // - ////////////////////////////////////////// - - /// @name binary serialization/deserialization support - /// @{ - - public: - /*! - @brief create a CBOR serialization of a given JSON value - - Serializes a given JSON value @a j to a byte vector using the CBOR (Concise - Binary Object Representation) serialization format. CBOR is a binary - serialization format which aims to be more compact than JSON itself, yet - more efficient to parse. - - The library uses the following mapping from JSON values types to - CBOR types according to the CBOR specification (RFC 7049): - - JSON value type | value/range | CBOR type | first byte - --------------- | ------------------------------------------ | ---------------------------------- | --------------- - null | `null` | Null | 0xF6 - boolean | `true` | True | 0xF5 - boolean | `false` | False | 0xF4 - number_integer | -9223372036854775808..-2147483649 | Negative integer (8 bytes follow) | 0x3B - number_integer | -2147483648..-32769 | Negative integer (4 bytes follow) | 0x3A - number_integer | -32768..-129 | Negative integer (2 bytes follow) | 0x39 - number_integer | -128..-25 | Negative integer (1 byte follow) | 0x38 - number_integer | -24..-1 | Negative integer | 0x20..0x37 - number_integer | 0..23 | Integer | 0x00..0x17 - number_integer | 24..255 | Unsigned integer (1 byte follow) | 0x18 - number_integer | 256..65535 | Unsigned integer (2 bytes follow) | 0x19 - number_integer | 65536..4294967295 | Unsigned integer (4 bytes follow) | 0x1A - number_integer | 4294967296..18446744073709551615 | Unsigned integer (8 bytes follow) | 0x1B - number_unsigned | 0..23 | Integer | 0x00..0x17 - number_unsigned | 24..255 | Unsigned integer (1 byte follow) | 0x18 - number_unsigned | 256..65535 | Unsigned integer (2 bytes follow) | 0x19 - number_unsigned | 65536..4294967295 | Unsigned integer (4 bytes follow) | 0x1A - number_unsigned | 4294967296..18446744073709551615 | Unsigned integer (8 bytes follow) | 0x1B - number_float | *any value representable by a float* | Single-Precision Float | 0xFA - number_float | *any value NOT representable by a float* | Double-Precision Float | 0xFB - string | *length*: 0..23 | UTF-8 string | 0x60..0x77 - string | *length*: 23..255 | UTF-8 string (1 byte follow) | 0x78 - string | *length*: 256..65535 | UTF-8 string (2 bytes follow) | 0x79 - string | *length*: 65536..4294967295 | UTF-8 string (4 bytes follow) | 0x7A - string | *length*: 4294967296..18446744073709551615 | UTF-8 string (8 bytes follow) | 0x7B - array | *size*: 0..23 | array | 0x80..0x97 - array | *size*: 23..255 | array (1 byte follow) | 0x98 - array | *size*: 256..65535 | array (2 bytes follow) | 0x99 - array | *size*: 65536..4294967295 | array (4 bytes follow) | 0x9A - array | *size*: 4294967296..18446744073709551615 | array (8 bytes follow) | 0x9B - object | *size*: 0..23 | map | 0xA0..0xB7 - object | *size*: 23..255 | map (1 byte follow) | 0xB8 - object | *size*: 256..65535 | map (2 bytes follow) | 0xB9 - object | *size*: 65536..4294967295 | map (4 bytes follow) | 0xBA - object | *size*: 4294967296..18446744073709551615 | map (8 bytes follow) | 0xBB - binary | *size*: 0..23 | byte string | 0x40..0x57 - binary | *size*: 23..255 | byte string (1 byte follow) | 0x58 - binary | *size*: 256..65535 | byte string (2 bytes follow) | 0x59 - binary | *size*: 65536..4294967295 | byte string (4 bytes follow) | 0x5A - binary | *size*: 4294967296..18446744073709551615 | byte string (8 bytes follow) | 0x5B - - Binary values with subtype are mapped to tagged values (0xD8..0xDB) - depending on the subtype, followed by a byte string, see "binary" cells - in the table above. - - @note The mapping is **complete** in the sense that any JSON value type - can be converted to a CBOR value. - - @note If NaN or Infinity are stored inside a JSON number, they are - serialized properly. This behavior differs from the @ref dump() - function which serializes NaN or Infinity to `null`. - - @note The following CBOR types are not used in the conversion: - - UTF-8 strings terminated by "break" (0x7F) - - arrays terminated by "break" (0x9F) - - maps terminated by "break" (0xBF) - - byte strings terminated by "break" (0x5F) - - date/time (0xC0..0xC1) - - bignum (0xC2..0xC3) - - decimal fraction (0xC4) - - bigfloat (0xC5) - - expected conversions (0xD5..0xD7) - - simple values (0xE0..0xF3, 0xF8) - - undefined (0xF7) - - half-precision floats (0xF9) - - break (0xFF) - - @param[in] j JSON value to serialize - @return CBOR serialization as byte vector - - @complexity Linear in the size of the JSON value @a j. - - @liveexample{The example shows the serialization of a JSON value to a byte - vector in CBOR format.,to_cbor} - - @sa http://cbor.io - @sa see @ref from_cbor(InputType&&, const bool, const bool, const cbor_tag_handler_t) for the - analogous deserialization - @sa see @ref to_msgpack(const basic_json&) for the related MessagePack format - @sa see @ref to_ubjson(const basic_json&, const bool, const bool) for the - related UBJSON format - - @since version 2.0.9; compact representation of floating-point numbers - since version 3.8.0 - */ - static std::vector to_cbor(const basic_json& j) - { - std::vector result; - to_cbor(j, result); - return result; - } - - static void to_cbor(const basic_json& j, detail::output_adapter o) - { - binary_writer(o).write_cbor(j); - } - - static void to_cbor(const basic_json& j, detail::output_adapter o) - { - binary_writer(o).write_cbor(j); - } - - /*! - @brief create a MessagePack serialization of a given JSON value - - Serializes a given JSON value @a j to a byte vector using the MessagePack - serialization format. MessagePack is a binary serialization format which - aims to be more compact than JSON itself, yet more efficient to parse. - - The library uses the following mapping from JSON values types to - MessagePack types according to the MessagePack specification: - - JSON value type | value/range | MessagePack type | first byte - --------------- | --------------------------------- | ---------------- | ---------- - null | `null` | nil | 0xC0 - boolean | `true` | true | 0xC3 - boolean | `false` | false | 0xC2 - number_integer | -9223372036854775808..-2147483649 | int64 | 0xD3 - number_integer | -2147483648..-32769 | int32 | 0xD2 - number_integer | -32768..-129 | int16 | 0xD1 - number_integer | -128..-33 | int8 | 0xD0 - number_integer | -32..-1 | negative fixint | 0xE0..0xFF - number_integer | 0..127 | positive fixint | 0x00..0x7F - number_integer | 128..255 | uint 8 | 0xCC - number_integer | 256..65535 | uint 16 | 0xCD - number_integer | 65536..4294967295 | uint 32 | 0xCE - number_integer | 4294967296..18446744073709551615 | uint 64 | 0xCF - number_unsigned | 0..127 | positive fixint | 0x00..0x7F - number_unsigned | 128..255 | uint 8 | 0xCC - number_unsigned | 256..65535 | uint 16 | 0xCD - number_unsigned | 65536..4294967295 | uint 32 | 0xCE - number_unsigned | 4294967296..18446744073709551615 | uint 64 | 0xCF - number_float | *any value representable by a float* | float 32 | 0xCA - number_float | *any value NOT representable by a float* | float 64 | 0xCB - string | *length*: 0..31 | fixstr | 0xA0..0xBF - string | *length*: 32..255 | str 8 | 0xD9 - string | *length*: 256..65535 | str 16 | 0xDA - string | *length*: 65536..4294967295 | str 32 | 0xDB - array | *size*: 0..15 | fixarray | 0x90..0x9F - array | *size*: 16..65535 | array 16 | 0xDC - array | *size*: 65536..4294967295 | array 32 | 0xDD - object | *size*: 0..15 | fix map | 0x80..0x8F - object | *size*: 16..65535 | map 16 | 0xDE - object | *size*: 65536..4294967295 | map 32 | 0xDF - binary | *size*: 0..255 | bin 8 | 0xC4 - binary | *size*: 256..65535 | bin 16 | 0xC5 - binary | *size*: 65536..4294967295 | bin 32 | 0xC6 - - @note The mapping is **complete** in the sense that any JSON value type - can be converted to a MessagePack value. - - @note The following values can **not** be converted to a MessagePack value: - - strings with more than 4294967295 bytes - - byte strings with more than 4294967295 bytes - - arrays with more than 4294967295 elements - - objects with more than 4294967295 elements - - @note Any MessagePack output created @ref to_msgpack can be successfully - parsed by @ref from_msgpack. - - @note If NaN or Infinity are stored inside a JSON number, they are - serialized properly. This behavior differs from the @ref dump() - function which serializes NaN or Infinity to `null`. - - @param[in] j JSON value to serialize - @return MessagePack serialization as byte vector - - @complexity Linear in the size of the JSON value @a j. - - @liveexample{The example shows the serialization of a JSON value to a byte - vector in MessagePack format.,to_msgpack} - - @sa http://msgpack.org - @sa see @ref from_msgpack for the analogous deserialization - @sa see @ref to_cbor(const basic_json& for the related CBOR format - @sa see @ref to_ubjson(const basic_json&, const bool, const bool) for the - related UBJSON format - - @since version 2.0.9 - */ - static std::vector to_msgpack(const basic_json& j) - { - std::vector result; - to_msgpack(j, result); - return result; - } - - static void to_msgpack(const basic_json& j, detail::output_adapter o) - { - binary_writer(o).write_msgpack(j); - } - - static void to_msgpack(const basic_json& j, detail::output_adapter o) - { - binary_writer(o).write_msgpack(j); - } - - /*! - @brief create a UBJSON serialization of a given JSON value - - Serializes a given JSON value @a j to a byte vector using the UBJSON - (Universal Binary JSON) serialization format. UBJSON aims to be more compact - than JSON itself, yet more efficient to parse. - - The library uses the following mapping from JSON values types to - UBJSON types according to the UBJSON specification: - - JSON value type | value/range | UBJSON type | marker - --------------- | --------------------------------- | ----------- | ------ - null | `null` | null | `Z` - boolean | `true` | true | `T` - boolean | `false` | false | `F` - number_integer | -9223372036854775808..-2147483649 | int64 | `L` - number_integer | -2147483648..-32769 | int32 | `l` - number_integer | -32768..-129 | int16 | `I` - number_integer | -128..127 | int8 | `i` - number_integer | 128..255 | uint8 | `U` - number_integer | 256..32767 | int16 | `I` - number_integer | 32768..2147483647 | int32 | `l` - number_integer | 2147483648..9223372036854775807 | int64 | `L` - number_unsigned | 0..127 | int8 | `i` - number_unsigned | 128..255 | uint8 | `U` - number_unsigned | 256..32767 | int16 | `I` - number_unsigned | 32768..2147483647 | int32 | `l` - number_unsigned | 2147483648..9223372036854775807 | int64 | `L` - number_unsigned | 2147483649..18446744073709551615 | high-precision | `H` - number_float | *any value* | float64 | `D` - string | *with shortest length indicator* | string | `S` - array | *see notes on optimized format* | array | `[` - object | *see notes on optimized format* | map | `{` - - @note The mapping is **complete** in the sense that any JSON value type - can be converted to a UBJSON value. - - @note The following values can **not** be converted to a UBJSON value: - - strings with more than 9223372036854775807 bytes (theoretical) - - @note The following markers are not used in the conversion: - - `Z`: no-op values are not created. - - `C`: single-byte strings are serialized with `S` markers. - - @note Any UBJSON output created @ref to_ubjson can be successfully parsed - by @ref from_ubjson. - - @note If NaN or Infinity are stored inside a JSON number, they are - serialized properly. This behavior differs from the @ref dump() - function which serializes NaN or Infinity to `null`. - - @note The optimized formats for containers are supported: Parameter - @a use_size adds size information to the beginning of a container and - removes the closing marker. Parameter @a use_type further checks - whether all elements of a container have the same type and adds the - type marker to the beginning of the container. The @a use_type - parameter must only be used together with @a use_size = true. Note - that @a use_size = true alone may result in larger representations - - the benefit of this parameter is that the receiving side is - immediately informed on the number of elements of the container. - - @note If the JSON data contains the binary type, the value stored is a list - of integers, as suggested by the UBJSON documentation. In particular, - this means that serialization and the deserialization of a JSON - containing binary values into UBJSON and back will result in a - different JSON object. - - @param[in] j JSON value to serialize - @param[in] use_size whether to add size annotations to container types - @param[in] use_type whether to add type annotations to container types - (must be combined with @a use_size = true) - @return UBJSON serialization as byte vector - - @complexity Linear in the size of the JSON value @a j. - - @liveexample{The example shows the serialization of a JSON value to a byte - vector in UBJSON format.,to_ubjson} - - @sa http://ubjson.org - @sa see @ref from_ubjson(InputType&&, const bool, const bool) for the - analogous deserialization - @sa see @ref to_cbor(const basic_json& for the related CBOR format - @sa see @ref to_msgpack(const basic_json&) for the related MessagePack format - - @since version 3.1.0 - */ - static std::vector to_ubjson(const basic_json& j, - const bool use_size = false, - const bool use_type = false) - { - std::vector result; - to_ubjson(j, result, use_size, use_type); - return result; - } - - static void to_ubjson(const basic_json& j, detail::output_adapter o, - const bool use_size = false, const bool use_type = false) - { - binary_writer(o).write_ubjson(j, use_size, use_type); - } - - static void to_ubjson(const basic_json& j, detail::output_adapter o, - const bool use_size = false, const bool use_type = false) - { - binary_writer(o).write_ubjson(j, use_size, use_type); - } - - - /*! - @brief Serializes the given JSON object `j` to BSON and returns a vector - containing the corresponding BSON-representation. - - BSON (Binary JSON) is a binary format in which zero or more ordered key/value pairs are - stored as a single entity (a so-called document). - - The library uses the following mapping from JSON values types to BSON types: - - JSON value type | value/range | BSON type | marker - --------------- | --------------------------------- | ----------- | ------ - null | `null` | null | 0x0A - boolean | `true`, `false` | boolean | 0x08 - number_integer | -9223372036854775808..-2147483649 | int64 | 0x12 - number_integer | -2147483648..2147483647 | int32 | 0x10 - number_integer | 2147483648..9223372036854775807 | int64 | 0x12 - number_unsigned | 0..2147483647 | int32 | 0x10 - number_unsigned | 2147483648..9223372036854775807 | int64 | 0x12 - number_unsigned | 9223372036854775808..18446744073709551615| -- | -- - number_float | *any value* | double | 0x01 - string | *any value* | string | 0x02 - array | *any value* | document | 0x04 - object | *any value* | document | 0x03 - binary | *any value* | binary | 0x05 - - @warning The mapping is **incomplete**, since only JSON-objects (and things - contained therein) can be serialized to BSON. - Also, integers larger than 9223372036854775807 cannot be serialized to BSON, - and the keys may not contain U+0000, since they are serialized a - zero-terminated c-strings. - - @throw out_of_range.407 if `j.is_number_unsigned() && j.get() > 9223372036854775807` - @throw out_of_range.409 if a key in `j` contains a NULL (U+0000) - @throw type_error.317 if `!j.is_object()` - - @pre The input `j` is required to be an object: `j.is_object() == true`. - - @note Any BSON output created via @ref to_bson can be successfully parsed - by @ref from_bson. - - @param[in] j JSON value to serialize - @return BSON serialization as byte vector - - @complexity Linear in the size of the JSON value @a j. - - @liveexample{The example shows the serialization of a JSON value to a byte - vector in BSON format.,to_bson} - - @sa http://bsonspec.org/spec.html - @sa see @ref from_bson(detail::input_adapter&&, const bool strict) for the - analogous deserialization - @sa see @ref to_ubjson(const basic_json&, const bool, const bool) for the - related UBJSON format - @sa see @ref to_cbor(const basic_json&) for the related CBOR format - @sa see @ref to_msgpack(const basic_json&) for the related MessagePack format - */ - static std::vector to_bson(const basic_json& j) - { - std::vector result; - to_bson(j, result); - return result; - } - - /*! - @brief Serializes the given JSON object `j` to BSON and forwards the - corresponding BSON-representation to the given output_adapter `o`. - @param j The JSON object to convert to BSON. - @param o The output adapter that receives the binary BSON representation. - @pre The input `j` shall be an object: `j.is_object() == true` - @sa see @ref to_bson(const basic_json&) - */ - static void to_bson(const basic_json& j, detail::output_adapter o) - { - binary_writer(o).write_bson(j); - } - - /*! - @copydoc to_bson(const basic_json&, detail::output_adapter) - */ - static void to_bson(const basic_json& j, detail::output_adapter o) - { - binary_writer(o).write_bson(j); - } - - - /*! - @brief create a JSON value from an input in CBOR format - - Deserializes a given input @a i to a JSON value using the CBOR (Concise - Binary Object Representation) serialization format. - - The library maps CBOR types to JSON value types as follows: - - CBOR type | JSON value type | first byte - ---------------------- | --------------- | ---------- - Integer | number_unsigned | 0x00..0x17 - Unsigned integer | number_unsigned | 0x18 - Unsigned integer | number_unsigned | 0x19 - Unsigned integer | number_unsigned | 0x1A - Unsigned integer | number_unsigned | 0x1B - Negative integer | number_integer | 0x20..0x37 - Negative integer | number_integer | 0x38 - Negative integer | number_integer | 0x39 - Negative integer | number_integer | 0x3A - Negative integer | number_integer | 0x3B - Byte string | binary | 0x40..0x57 - Byte string | binary | 0x58 - Byte string | binary | 0x59 - Byte string | binary | 0x5A - Byte string | binary | 0x5B - UTF-8 string | string | 0x60..0x77 - UTF-8 string | string | 0x78 - UTF-8 string | string | 0x79 - UTF-8 string | string | 0x7A - UTF-8 string | string | 0x7B - UTF-8 string | string | 0x7F - array | array | 0x80..0x97 - array | array | 0x98 - array | array | 0x99 - array | array | 0x9A - array | array | 0x9B - array | array | 0x9F - map | object | 0xA0..0xB7 - map | object | 0xB8 - map | object | 0xB9 - map | object | 0xBA - map | object | 0xBB - map | object | 0xBF - False | `false` | 0xF4 - True | `true` | 0xF5 - Null | `null` | 0xF6 - Half-Precision Float | number_float | 0xF9 - Single-Precision Float | number_float | 0xFA - Double-Precision Float | number_float | 0xFB - - @warning The mapping is **incomplete** in the sense that not all CBOR - types can be converted to a JSON value. The following CBOR types - are not supported and will yield parse errors (parse_error.112): - - date/time (0xC0..0xC1) - - bignum (0xC2..0xC3) - - decimal fraction (0xC4) - - bigfloat (0xC5) - - expected conversions (0xD5..0xD7) - - simple values (0xE0..0xF3, 0xF8) - - undefined (0xF7) - - @warning CBOR allows map keys of any type, whereas JSON only allows - strings as keys in object values. Therefore, CBOR maps with keys - other than UTF-8 strings are rejected (parse_error.113). - - @note Any CBOR output created @ref to_cbor can be successfully parsed by - @ref from_cbor. - - @param[in] i an input in CBOR format convertible to an input adapter - @param[in] strict whether to expect the input to be consumed until EOF - (true by default) - @param[in] allow_exceptions whether to throw exceptions in case of a - parse error (optional, true by default) - @param[in] tag_handler how to treat CBOR tags (optional, error by default) - - @return deserialized JSON value; in case of a parse error and - @a allow_exceptions set to `false`, the return value will be - value_t::discarded. - - @throw parse_error.110 if the given input ends prematurely or the end of - file was not reached when @a strict was set to true - @throw parse_error.112 if unsupported features from CBOR were - used in the given input @a v or if the input is not valid CBOR - @throw parse_error.113 if a string was expected as map key, but not found - - @complexity Linear in the size of the input @a i. - - @liveexample{The example shows the deserialization of a byte vector in CBOR - format to a JSON value.,from_cbor} - - @sa http://cbor.io - @sa see @ref to_cbor(const basic_json&) for the analogous serialization - @sa see @ref from_msgpack(InputType&&, const bool, const bool) for the - related MessagePack format - @sa see @ref from_ubjson(InputType&&, const bool, const bool) for the - related UBJSON format - - @since version 2.0.9; parameter @a start_index since 2.1.1; changed to - consume input adapters, removed start_index parameter, and added - @a strict parameter since 3.0.0; added @a allow_exceptions parameter - since 3.2.0; added @a tag_handler parameter since 3.9.0. - */ - template - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json from_cbor(InputType&& i, - const bool strict = true, - const bool allow_exceptions = true, - const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = detail::input_adapter(std::forward(i)); - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler); - return res ? result : basic_json(value_t::discarded); - } - - /*! - @copydoc from_cbor(InputType&&, const bool, const bool, const cbor_tag_handler_t) - */ - template - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json from_cbor(IteratorType first, IteratorType last, - const bool strict = true, - const bool allow_exceptions = true, - const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = detail::input_adapter(std::move(first), std::move(last)); - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler); - return res ? result : basic_json(value_t::discarded); - } - - template - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len)) - static basic_json from_cbor(const T* ptr, std::size_t len, - const bool strict = true, - const bool allow_exceptions = true, - const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) - { - return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler); - } - - - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len)) - static basic_json from_cbor(detail::span_input_adapter&& i, - const bool strict = true, - const bool allow_exceptions = true, - const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = i.get(); - // NOLINTNEXTLINE(hicpp-move-const-arg,performance-move-const-arg) - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler); - return res ? result : basic_json(value_t::discarded); - } - - /*! - @brief create a JSON value from an input in MessagePack format - - Deserializes a given input @a i to a JSON value using the MessagePack - serialization format. - - The library maps MessagePack types to JSON value types as follows: - - MessagePack type | JSON value type | first byte - ---------------- | --------------- | ---------- - positive fixint | number_unsigned | 0x00..0x7F - fixmap | object | 0x80..0x8F - fixarray | array | 0x90..0x9F - fixstr | string | 0xA0..0xBF - nil | `null` | 0xC0 - false | `false` | 0xC2 - true | `true` | 0xC3 - float 32 | number_float | 0xCA - float 64 | number_float | 0xCB - uint 8 | number_unsigned | 0xCC - uint 16 | number_unsigned | 0xCD - uint 32 | number_unsigned | 0xCE - uint 64 | number_unsigned | 0xCF - int 8 | number_integer | 0xD0 - int 16 | number_integer | 0xD1 - int 32 | number_integer | 0xD2 - int 64 | number_integer | 0xD3 - str 8 | string | 0xD9 - str 16 | string | 0xDA - str 32 | string | 0xDB - array 16 | array | 0xDC - array 32 | array | 0xDD - map 16 | object | 0xDE - map 32 | object | 0xDF - bin 8 | binary | 0xC4 - bin 16 | binary | 0xC5 - bin 32 | binary | 0xC6 - ext 8 | binary | 0xC7 - ext 16 | binary | 0xC8 - ext 32 | binary | 0xC9 - fixext 1 | binary | 0xD4 - fixext 2 | binary | 0xD5 - fixext 4 | binary | 0xD6 - fixext 8 | binary | 0xD7 - fixext 16 | binary | 0xD8 - negative fixint | number_integer | 0xE0-0xFF - - @note Any MessagePack output created @ref to_msgpack can be successfully - parsed by @ref from_msgpack. - - @param[in] i an input in MessagePack format convertible to an input - adapter - @param[in] strict whether to expect the input to be consumed until EOF - (true by default) - @param[in] allow_exceptions whether to throw exceptions in case of a - parse error (optional, true by default) - - @return deserialized JSON value; in case of a parse error and - @a allow_exceptions set to `false`, the return value will be - value_t::discarded. - - @throw parse_error.110 if the given input ends prematurely or the end of - file was not reached when @a strict was set to true - @throw parse_error.112 if unsupported features from MessagePack were - used in the given input @a i or if the input is not valid MessagePack - @throw parse_error.113 if a string was expected as map key, but not found - - @complexity Linear in the size of the input @a i. - - @liveexample{The example shows the deserialization of a byte vector in - MessagePack format to a JSON value.,from_msgpack} - - @sa http://msgpack.org - @sa see @ref to_msgpack(const basic_json&) for the analogous serialization - @sa see @ref from_cbor(InputType&&, const bool, const bool, const cbor_tag_handler_t) for the - related CBOR format - @sa see @ref from_ubjson(InputType&&, const bool, const bool) for - the related UBJSON format - @sa see @ref from_bson(InputType&&, const bool, const bool) for - the related BSON format - - @since version 2.0.9; parameter @a start_index since 2.1.1; changed to - consume input adapters, removed start_index parameter, and added - @a strict parameter since 3.0.0; added @a allow_exceptions parameter - since 3.2.0 - */ - template - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json from_msgpack(InputType&& i, - const bool strict = true, - const bool allow_exceptions = true) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = detail::input_adapter(std::forward(i)); - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::msgpack, &sdp, strict); - return res ? result : basic_json(value_t::discarded); - } - - /*! - @copydoc from_msgpack(InputType&&, const bool, const bool) - */ - template - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json from_msgpack(IteratorType first, IteratorType last, - const bool strict = true, - const bool allow_exceptions = true) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = detail::input_adapter(std::move(first), std::move(last)); - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::msgpack, &sdp, strict); - return res ? result : basic_json(value_t::discarded); - } - - - template - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len)) - static basic_json from_msgpack(const T* ptr, std::size_t len, - const bool strict = true, - const bool allow_exceptions = true) - { - return from_msgpack(ptr, ptr + len, strict, allow_exceptions); - } - - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len)) - static basic_json from_msgpack(detail::span_input_adapter&& i, - const bool strict = true, - const bool allow_exceptions = true) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = i.get(); - // NOLINTNEXTLINE(hicpp-move-const-arg,performance-move-const-arg) - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::msgpack, &sdp, strict); - return res ? result : basic_json(value_t::discarded); - } - - - /*! - @brief create a JSON value from an input in UBJSON format - - Deserializes a given input @a i to a JSON value using the UBJSON (Universal - Binary JSON) serialization format. - - The library maps UBJSON types to JSON value types as follows: - - UBJSON type | JSON value type | marker - ----------- | --------------------------------------- | ------ - no-op | *no value, next value is read* | `N` - null | `null` | `Z` - false | `false` | `F` - true | `true` | `T` - float32 | number_float | `d` - float64 | number_float | `D` - uint8 | number_unsigned | `U` - int8 | number_integer | `i` - int16 | number_integer | `I` - int32 | number_integer | `l` - int64 | number_integer | `L` - high-precision number | number_integer, number_unsigned, or number_float - depends on number string | 'H' - string | string | `S` - char | string | `C` - array | array (optimized values are supported) | `[` - object | object (optimized values are supported) | `{` - - @note The mapping is **complete** in the sense that any UBJSON value can - be converted to a JSON value. - - @param[in] i an input in UBJSON format convertible to an input adapter - @param[in] strict whether to expect the input to be consumed until EOF - (true by default) - @param[in] allow_exceptions whether to throw exceptions in case of a - parse error (optional, true by default) - - @return deserialized JSON value; in case of a parse error and - @a allow_exceptions set to `false`, the return value will be - value_t::discarded. - - @throw parse_error.110 if the given input ends prematurely or the end of - file was not reached when @a strict was set to true - @throw parse_error.112 if a parse error occurs - @throw parse_error.113 if a string could not be parsed successfully - - @complexity Linear in the size of the input @a i. - - @liveexample{The example shows the deserialization of a byte vector in - UBJSON format to a JSON value.,from_ubjson} - - @sa http://ubjson.org - @sa see @ref to_ubjson(const basic_json&, const bool, const bool) for the - analogous serialization - @sa see @ref from_cbor(InputType&&, const bool, const bool, const cbor_tag_handler_t) for the - related CBOR format - @sa see @ref from_msgpack(InputType&&, const bool, const bool) for - the related MessagePack format - @sa see @ref from_bson(InputType&&, const bool, const bool) for - the related BSON format - - @since version 3.1.0; added @a allow_exceptions parameter since 3.2.0 - */ - template - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json from_ubjson(InputType&& i, - const bool strict = true, - const bool allow_exceptions = true) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = detail::input_adapter(std::forward(i)); - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::ubjson, &sdp, strict); - return res ? result : basic_json(value_t::discarded); - } - - /*! - @copydoc from_ubjson(InputType&&, const bool, const bool) - */ - template - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json from_ubjson(IteratorType first, IteratorType last, - const bool strict = true, - const bool allow_exceptions = true) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = detail::input_adapter(std::move(first), std::move(last)); - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::ubjson, &sdp, strict); - return res ? result : basic_json(value_t::discarded); - } - - template - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len)) - static basic_json from_ubjson(const T* ptr, std::size_t len, - const bool strict = true, - const bool allow_exceptions = true) - { - return from_ubjson(ptr, ptr + len, strict, allow_exceptions); - } - - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len)) - static basic_json from_ubjson(detail::span_input_adapter&& i, - const bool strict = true, - const bool allow_exceptions = true) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = i.get(); - // NOLINTNEXTLINE(hicpp-move-const-arg,performance-move-const-arg) - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::ubjson, &sdp, strict); - return res ? result : basic_json(value_t::discarded); - } - - - /*! - @brief Create a JSON value from an input in BSON format - - Deserializes a given input @a i to a JSON value using the BSON (Binary JSON) - serialization format. - - The library maps BSON record types to JSON value types as follows: - - BSON type | BSON marker byte | JSON value type - --------------- | ---------------- | --------------------------- - double | 0x01 | number_float - string | 0x02 | string - document | 0x03 | object - array | 0x04 | array - binary | 0x05 | binary - undefined | 0x06 | still unsupported - ObjectId | 0x07 | still unsupported - boolean | 0x08 | boolean - UTC Date-Time | 0x09 | still unsupported - null | 0x0A | null - Regular Expr. | 0x0B | still unsupported - DB Pointer | 0x0C | still unsupported - JavaScript Code | 0x0D | still unsupported - Symbol | 0x0E | still unsupported - JavaScript Code | 0x0F | still unsupported - int32 | 0x10 | number_integer - Timestamp | 0x11 | still unsupported - 128-bit decimal float | 0x13 | still unsupported - Max Key | 0x7F | still unsupported - Min Key | 0xFF | still unsupported - - @warning The mapping is **incomplete**. The unsupported mappings - are indicated in the table above. - - @param[in] i an input in BSON format convertible to an input adapter - @param[in] strict whether to expect the input to be consumed until EOF - (true by default) - @param[in] allow_exceptions whether to throw exceptions in case of a - parse error (optional, true by default) - - @return deserialized JSON value; in case of a parse error and - @a allow_exceptions set to `false`, the return value will be - value_t::discarded. - - @throw parse_error.114 if an unsupported BSON record type is encountered - - @complexity Linear in the size of the input @a i. - - @liveexample{The example shows the deserialization of a byte vector in - BSON format to a JSON value.,from_bson} - - @sa http://bsonspec.org/spec.html - @sa see @ref to_bson(const basic_json&) for the analogous serialization - @sa see @ref from_cbor(InputType&&, const bool, const bool, const cbor_tag_handler_t) for the - related CBOR format - @sa see @ref from_msgpack(InputType&&, const bool, const bool) for - the related MessagePack format - @sa see @ref from_ubjson(InputType&&, const bool, const bool) for the - related UBJSON format - */ - template - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json from_bson(InputType&& i, - const bool strict = true, - const bool allow_exceptions = true) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = detail::input_adapter(std::forward(i)); - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::bson, &sdp, strict); - return res ? result : basic_json(value_t::discarded); - } - - /*! - @copydoc from_bson(InputType&&, const bool, const bool) - */ - template - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json from_bson(IteratorType first, IteratorType last, - const bool strict = true, - const bool allow_exceptions = true) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = detail::input_adapter(std::move(first), std::move(last)); - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::bson, &sdp, strict); - return res ? result : basic_json(value_t::discarded); - } - - template - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_bson(ptr, ptr + len)) - static basic_json from_bson(const T* ptr, std::size_t len, - const bool strict = true, - const bool allow_exceptions = true) - { - return from_bson(ptr, ptr + len, strict, allow_exceptions); - } - - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_bson(ptr, ptr + len)) - static basic_json from_bson(detail::span_input_adapter&& i, - const bool strict = true, - const bool allow_exceptions = true) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = i.get(); - // NOLINTNEXTLINE(hicpp-move-const-arg,performance-move-const-arg) - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::bson, &sdp, strict); - return res ? result : basic_json(value_t::discarded); - } - /// @} - - ////////////////////////// - // JSON Pointer support // - ////////////////////////// - - /// @name JSON Pointer functions - /// @{ - - /*! - @brief access specified element via JSON Pointer - - Uses a JSON pointer to retrieve a reference to the respective JSON value. - No bound checking is performed. Similar to @ref operator[](const typename - object_t::key_type&), `null` values are created in arrays and objects if - necessary. - - In particular: - - If the JSON pointer points to an object key that does not exist, it - is created an filled with a `null` value before a reference to it - is returned. - - If the JSON pointer points to an array index that does not exist, it - is created an filled with a `null` value before a reference to it - is returned. All indices between the current maximum and the given - index are also filled with `null`. - - The special value `-` is treated as a synonym for the index past the - end. - - @param[in] ptr a JSON pointer - - @return reference to the element pointed to by @a ptr - - @complexity Constant. - - @throw parse_error.106 if an array index begins with '0' - @throw parse_error.109 if an array index was not a number - @throw out_of_range.404 if the JSON pointer can not be resolved - - @liveexample{The behavior is shown in the example.,operatorjson_pointer} - - @since version 2.0.0 - */ - reference operator[](const json_pointer& ptr) - { - return ptr.get_unchecked(this); - } - - /*! - @brief access specified element via JSON Pointer - - Uses a JSON pointer to retrieve a reference to the respective JSON value. - No bound checking is performed. The function does not change the JSON - value; no `null` values are created. In particular, the special value - `-` yields an exception. - - @param[in] ptr JSON pointer to the desired element - - @return const reference to the element pointed to by @a ptr - - @complexity Constant. - - @throw parse_error.106 if an array index begins with '0' - @throw parse_error.109 if an array index was not a number - @throw out_of_range.402 if the array index '-' is used - @throw out_of_range.404 if the JSON pointer can not be resolved - - @liveexample{The behavior is shown in the example.,operatorjson_pointer_const} - - @since version 2.0.0 - */ - const_reference operator[](const json_pointer& ptr) const - { - return ptr.get_unchecked(this); - } - - /*! - @brief access specified element via JSON Pointer - - Returns a reference to the element at with specified JSON pointer @a ptr, - with bounds checking. - - @param[in] ptr JSON pointer to the desired element - - @return reference to the element pointed to by @a ptr - - @throw parse_error.106 if an array index in the passed JSON pointer @a ptr - begins with '0'. See example below. - - @throw parse_error.109 if an array index in the passed JSON pointer @a ptr - is not a number. See example below. - - @throw out_of_range.401 if an array index in the passed JSON pointer @a ptr - is out of range. See example below. - - @throw out_of_range.402 if the array index '-' is used in the passed JSON - pointer @a ptr. As `at` provides checked access (and no elements are - implicitly inserted), the index '-' is always invalid. See example below. - - @throw out_of_range.403 if the JSON pointer describes a key of an object - which cannot be found. See example below. - - @throw out_of_range.404 if the JSON pointer @a ptr can not be resolved. - See example below. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes in the JSON value. - - @complexity Constant. - - @since version 2.0.0 - - @liveexample{The behavior is shown in the example.,at_json_pointer} - */ - reference at(const json_pointer& ptr) - { - return ptr.get_checked(this); - } - - /*! - @brief access specified element via JSON Pointer - - Returns a const reference to the element at with specified JSON pointer @a - ptr, with bounds checking. - - @param[in] ptr JSON pointer to the desired element - - @return reference to the element pointed to by @a ptr - - @throw parse_error.106 if an array index in the passed JSON pointer @a ptr - begins with '0'. See example below. - - @throw parse_error.109 if an array index in the passed JSON pointer @a ptr - is not a number. See example below. - - @throw out_of_range.401 if an array index in the passed JSON pointer @a ptr - is out of range. See example below. - - @throw out_of_range.402 if the array index '-' is used in the passed JSON - pointer @a ptr. As `at` provides checked access (and no elements are - implicitly inserted), the index '-' is always invalid. See example below. - - @throw out_of_range.403 if the JSON pointer describes a key of an object - which cannot be found. See example below. - - @throw out_of_range.404 if the JSON pointer @a ptr can not be resolved. - See example below. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes in the JSON value. - - @complexity Constant. - - @since version 2.0.0 - - @liveexample{The behavior is shown in the example.,at_json_pointer_const} - */ - const_reference at(const json_pointer& ptr) const - { - return ptr.get_checked(this); - } - - /*! - @brief return flattened JSON value - - The function creates a JSON object whose keys are JSON pointers (see [RFC - 6901](https://tools.ietf.org/html/rfc6901)) and whose values are all - primitive. The original JSON value can be restored using the @ref - unflatten() function. - - @return an object that maps JSON pointers to primitive values - - @note Empty objects and arrays are flattened to `null` and will not be - reconstructed correctly by the @ref unflatten() function. - - @complexity Linear in the size the JSON value. - - @liveexample{The following code shows how a JSON object is flattened to an - object whose keys consist of JSON pointers.,flatten} - - @sa see @ref unflatten() for the reverse function - - @since version 2.0.0 - */ - basic_json flatten() const - { - basic_json result(value_t::object); - json_pointer::flatten("", *this, result); - return result; - } - - /*! - @brief unflatten a previously flattened JSON value - - The function restores the arbitrary nesting of a JSON value that has been - flattened before using the @ref flatten() function. The JSON value must - meet certain constraints: - 1. The value must be an object. - 2. The keys must be JSON pointers (see - [RFC 6901](https://tools.ietf.org/html/rfc6901)) - 3. The mapped values must be primitive JSON types. - - @return the original JSON from a flattened version - - @note Empty objects and arrays are flattened by @ref flatten() to `null` - values and can not unflattened to their original type. Apart from - this example, for a JSON value `j`, the following is always true: - `j == j.flatten().unflatten()`. - - @complexity Linear in the size the JSON value. - - @throw type_error.314 if value is not an object - @throw type_error.315 if object values are not primitive - - @liveexample{The following code shows how a flattened JSON object is - unflattened into the original nested JSON object.,unflatten} - - @sa see @ref flatten() for the reverse function - - @since version 2.0.0 - */ - basic_json unflatten() const - { - return json_pointer::unflatten(*this); - } - - /// @} - - ////////////////////////// - // JSON Patch functions // - ////////////////////////// - - /// @name JSON Patch functions - /// @{ - - /*! - @brief applies a JSON patch - - [JSON Patch](http://jsonpatch.com) defines a JSON document structure for - expressing a sequence of operations to apply to a JSON) document. With - this function, a JSON Patch is applied to the current JSON value by - executing all operations from the patch. - - @param[in] json_patch JSON patch document - @return patched document - - @note The application of a patch is atomic: Either all operations succeed - and the patched document is returned or an exception is thrown. In - any case, the original value is not changed: the patch is applied - to a copy of the value. - - @throw parse_error.104 if the JSON patch does not consist of an array of - objects - - @throw parse_error.105 if the JSON patch is malformed (e.g., mandatory - attributes are missing); example: `"operation add must have member path"` - - @throw out_of_range.401 if an array index is out of range. - - @throw out_of_range.403 if a JSON pointer inside the patch could not be - resolved successfully in the current JSON value; example: `"key baz not - found"` - - @throw out_of_range.405 if JSON pointer has no parent ("add", "remove", - "move") - - @throw other_error.501 if "test" operation was unsuccessful - - @complexity Linear in the size of the JSON value and the length of the - JSON patch. As usually only a fraction of the JSON value is affected by - the patch, the complexity can usually be neglected. - - @liveexample{The following code shows how a JSON patch is applied to a - value.,patch} - - @sa see @ref diff -- create a JSON patch by comparing two JSON values - - @sa [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902) - @sa [RFC 6901 (JSON Pointer)](https://tools.ietf.org/html/rfc6901) - - @since version 2.0.0 - */ - basic_json patch(const basic_json& json_patch) const - { - // make a working copy to apply the patch to - basic_json result = *this; - - // the valid JSON Patch operations - enum class patch_operations {add, remove, replace, move, copy, test, invalid}; - - const auto get_op = [](const std::string & op) - { - if (op == "add") - { - return patch_operations::add; - } - if (op == "remove") - { - return patch_operations::remove; - } - if (op == "replace") - { - return patch_operations::replace; - } - if (op == "move") - { - return patch_operations::move; - } - if (op == "copy") - { - return patch_operations::copy; - } - if (op == "test") - { - return patch_operations::test; - } - - return patch_operations::invalid; - }; - - // wrapper for "add" operation; add value at ptr - const auto operation_add = [&result](json_pointer & ptr, basic_json val) - { - // adding to the root of the target document means replacing it - if (ptr.empty()) - { - result = val; - return; - } - - // make sure the top element of the pointer exists - json_pointer top_pointer = ptr.top(); - if (top_pointer != ptr) - { - result.at(top_pointer); - } - - // get reference to parent of JSON pointer ptr - const auto last_path = ptr.back(); - ptr.pop_back(); - basic_json& parent = result[ptr]; - - switch (parent.m_type) - { - case value_t::null: - case value_t::object: - { - // use operator[] to add value - parent[last_path] = val; - break; - } - - case value_t::array: - { - if (last_path == "-") - { - // special case: append to back - parent.push_back(val); - } - else - { - const auto idx = json_pointer::array_index(last_path); - if (JSON_HEDLEY_UNLIKELY(idx > parent.size())) - { - // avoid undefined behavior - JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range", parent)); - } - - // default case: insert add offset - parent.insert(parent.begin() + static_cast(idx), val); - } - break; - } - - // if there exists a parent it cannot be primitive - case value_t::string: // LCOV_EXCL_LINE - case value_t::boolean: // LCOV_EXCL_LINE - case value_t::number_integer: // LCOV_EXCL_LINE - case value_t::number_unsigned: // LCOV_EXCL_LINE - case value_t::number_float: // LCOV_EXCL_LINE - case value_t::binary: // LCOV_EXCL_LINE - case value_t::discarded: // LCOV_EXCL_LINE - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE - } - }; - - // wrapper for "remove" operation; remove value at ptr - const auto operation_remove = [this, &result](json_pointer & ptr) - { - // get reference to parent of JSON pointer ptr - const auto last_path = ptr.back(); - ptr.pop_back(); - basic_json& parent = result.at(ptr); - - // remove child - if (parent.is_object()) - { - // perform range check - auto it = parent.find(last_path); - if (JSON_HEDLEY_LIKELY(it != parent.end())) - { - parent.erase(it); - } - else - { - JSON_THROW(out_of_range::create(403, "key '" + last_path + "' not found", *this)); - } - } - else if (parent.is_array()) - { - // note erase performs range check - parent.erase(json_pointer::array_index(last_path)); - } - }; - - // type check: top level value must be an array - if (JSON_HEDLEY_UNLIKELY(!json_patch.is_array())) - { - JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects", json_patch)); - } - - // iterate and apply the operations - for (const auto& val : json_patch) - { - // wrapper to get a value for an operation - const auto get_value = [&val](const std::string & op, - const std::string & member, - bool string_type) -> basic_json & - { - // find value - auto it = val.m_value.object->find(member); - - // context-sensitive error message - const auto error_msg = (op == "op") ? "operation" : "operation '" + op + "'"; - - // check if desired value is present - if (JSON_HEDLEY_UNLIKELY(it == val.m_value.object->end())) - { - // NOLINTNEXTLINE(performance-inefficient-string-concatenation) - JSON_THROW(parse_error::create(105, 0, error_msg + " must have member '" + member + "'", val)); - } - - // check if result is of type string - if (JSON_HEDLEY_UNLIKELY(string_type && !it->second.is_string())) - { - // NOLINTNEXTLINE(performance-inefficient-string-concatenation) - JSON_THROW(parse_error::create(105, 0, error_msg + " must have string member '" + member + "'", val)); - } - - // no error: return value - return it->second; - }; - - // type check: every element of the array must be an object - if (JSON_HEDLEY_UNLIKELY(!val.is_object())) - { - JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects", val)); - } - - // collect mandatory members - const auto op = get_value("op", "op", true).template get(); - const auto path = get_value(op, "path", true).template get(); - json_pointer ptr(path); - - switch (get_op(op)) - { - case patch_operations::add: - { - operation_add(ptr, get_value("add", "value", false)); - break; - } - - case patch_operations::remove: - { - operation_remove(ptr); - break; - } - - case patch_operations::replace: - { - // the "path" location must exist - use at() - result.at(ptr) = get_value("replace", "value", false); - break; - } - - case patch_operations::move: - { - const auto from_path = get_value("move", "from", true).template get(); - json_pointer from_ptr(from_path); - - // the "from" location must exist - use at() - basic_json v = result.at(from_ptr); - - // The move operation is functionally identical to a - // "remove" operation on the "from" location, followed - // immediately by an "add" operation at the target - // location with the value that was just removed. - operation_remove(from_ptr); - operation_add(ptr, v); - break; - } - - case patch_operations::copy: - { - const auto from_path = get_value("copy", "from", true).template get(); - const json_pointer from_ptr(from_path); - - // the "from" location must exist - use at() - basic_json v = result.at(from_ptr); - - // The copy is functionally identical to an "add" - // operation at the target location using the value - // specified in the "from" member. - operation_add(ptr, v); - break; - } - - case patch_operations::test: - { - bool success = false; - JSON_TRY - { - // check if "value" matches the one at "path" - // the "path" location must exist - use at() - success = (result.at(ptr) == get_value("test", "value", false)); - } - JSON_INTERNAL_CATCH (out_of_range&) - { - // ignore out of range errors: success remains false - } - - // throw an exception if test fails - if (JSON_HEDLEY_UNLIKELY(!success)) - { - JSON_THROW(other_error::create(501, "unsuccessful: " + val.dump(), val)); - } - - break; - } - - case patch_operations::invalid: - default: - { - // op must be "add", "remove", "replace", "move", "copy", or - // "test" - JSON_THROW(parse_error::create(105, 0, "operation value '" + op + "' is invalid", val)); - } - } - } - - return result; - } - - /*! - @brief creates a diff as a JSON patch - - Creates a [JSON Patch](http://jsonpatch.com) so that value @a source can - be changed into the value @a target by calling @ref patch function. - - @invariant For two JSON values @a source and @a target, the following code - yields always `true`: - @code {.cpp} - source.patch(diff(source, target)) == target; - @endcode - - @note Currently, only `remove`, `add`, and `replace` operations are - generated. - - @param[in] source JSON value to compare from - @param[in] target JSON value to compare against - @param[in] path helper value to create JSON pointers - - @return a JSON patch to convert the @a source to @a target - - @complexity Linear in the lengths of @a source and @a target. - - @liveexample{The following code shows how a JSON patch is created as a - diff for two JSON values.,diff} - - @sa see @ref patch -- apply a JSON patch - @sa see @ref merge_patch -- apply a JSON Merge Patch - - @sa [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902) - - @since version 2.0.0 - */ - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json diff(const basic_json& source, const basic_json& target, - const std::string& path = "") - { - // the patch - basic_json result(value_t::array); - - // if the values are the same, return empty patch - if (source == target) - { - return result; - } - - if (source.type() != target.type()) - { - // different types: replace value - result.push_back( - { - {"op", "replace"}, {"path", path}, {"value", target} - }); - return result; - } - - switch (source.type()) - { - case value_t::array: - { - // first pass: traverse common elements - std::size_t i = 0; - while (i < source.size() && i < target.size()) - { - // recursive call to compare array values at index i - auto temp_diff = diff(source[i], target[i], path + "/" + std::to_string(i)); - result.insert(result.end(), temp_diff.begin(), temp_diff.end()); - ++i; - } - - // i now reached the end of at least one array - // in a second pass, traverse the remaining elements - - // remove my remaining elements - const auto end_index = static_cast(result.size()); - while (i < source.size()) - { - // add operations in reverse order to avoid invalid - // indices - result.insert(result.begin() + end_index, object( - { - {"op", "remove"}, - {"path", path + "/" + std::to_string(i)} - })); - ++i; - } - - // add other remaining elements - while (i < target.size()) - { - result.push_back( - { - {"op", "add"}, - {"path", path + "/-"}, - {"value", target[i]} - }); - ++i; - } - - break; - } - - case value_t::object: - { - // first pass: traverse this object's elements - for (auto it = source.cbegin(); it != source.cend(); ++it) - { - // escape the key name to be used in a JSON patch - const auto path_key = path + "/" + detail::escape(it.key()); - - if (target.find(it.key()) != target.end()) - { - // recursive call to compare object values at key it - auto temp_diff = diff(it.value(), target[it.key()], path_key); - result.insert(result.end(), temp_diff.begin(), temp_diff.end()); - } - else - { - // found a key that is not in o -> remove it - result.push_back(object( - { - {"op", "remove"}, {"path", path_key} - })); - } - } - - // second pass: traverse other object's elements - for (auto it = target.cbegin(); it != target.cend(); ++it) - { - if (source.find(it.key()) == source.end()) - { - // found a key that is not in this -> add it - const auto path_key = path + "/" + detail::escape(it.key()); - result.push_back( - { - {"op", "add"}, {"path", path_key}, - {"value", it.value()} - }); - } - } - - break; - } - - case value_t::null: - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - { - // both primitive type: replace value - result.push_back( - { - {"op", "replace"}, {"path", path}, {"value", target} - }); - break; - } - } - - return result; - } - - /// @} - - //////////////////////////////// - // JSON Merge Patch functions // - //////////////////////////////// - - /// @name JSON Merge Patch functions - /// @{ - - /*! - @brief applies a JSON Merge Patch - - The merge patch format is primarily intended for use with the HTTP PATCH - method as a means of describing a set of modifications to a target - resource's content. This function applies a merge patch to the current - JSON value. - - The function implements the following algorithm from Section 2 of - [RFC 7396 (JSON Merge Patch)](https://tools.ietf.org/html/rfc7396): - - ``` - define MergePatch(Target, Patch): - if Patch is an Object: - if Target is not an Object: - Target = {} // Ignore the contents and set it to an empty Object - for each Name/Value pair in Patch: - if Value is null: - if Name exists in Target: - remove the Name/Value pair from Target - else: - Target[Name] = MergePatch(Target[Name], Value) - return Target - else: - return Patch - ``` - - Thereby, `Target` is the current object; that is, the patch is applied to - the current value. - - @param[in] apply_patch the patch to apply - - @complexity Linear in the lengths of @a patch. - - @liveexample{The following code shows how a JSON Merge Patch is applied to - a JSON document.,merge_patch} - - @sa see @ref patch -- apply a JSON patch - @sa [RFC 7396 (JSON Merge Patch)](https://tools.ietf.org/html/rfc7396) - - @since version 3.0.0 - */ - void merge_patch(const basic_json& apply_patch) - { - if (apply_patch.is_object()) - { - if (!is_object()) - { - *this = object(); - } - for (auto it = apply_patch.begin(); it != apply_patch.end(); ++it) - { - if (it.value().is_null()) - { - erase(it.key()); - } - else - { - operator[](it.key()).merge_patch(it.value()); - } - } - } - else - { - *this = apply_patch; - } - } - - /// @} -}; - -/*! -@brief user-defined to_string function for JSON values - -This function implements a user-defined to_string for JSON objects. - -@param[in] j a JSON object -@return a std::string object -*/ - -NLOHMANN_BASIC_JSON_TPL_DECLARATION -std::string to_string(const NLOHMANN_BASIC_JSON_TPL& j) -{ - return j.dump(); -} -} // namespace nlohmann - -/////////////////////// -// nonmember support // -/////////////////////// - -// specialization of std::swap, and std::hash -namespace std -{ - -/// hash value for JSON objects -template<> -struct hash -{ - /*! - @brief return a hash value for a JSON object - - @since version 1.0.0 - */ - std::size_t operator()(const nlohmann::json& j) const - { - return nlohmann::detail::hash(j); - } -}; - -/// specialization for std::less -/// @note: do not remove the space after '<', -/// see https://github.com/nlohmann/json/pull/679 -template<> -struct less<::nlohmann::detail::value_t> -{ - /*! - @brief compare two value_t enum values - @since version 3.0.0 - */ - bool operator()(nlohmann::detail::value_t lhs, - nlohmann::detail::value_t rhs) const noexcept - { - return nlohmann::detail::operator<(lhs, rhs); - } -}; - -// C++20 prohibit function specialization in the std namespace. -#ifndef JSON_HAS_CPP_20 - -/*! -@brief exchanges the values of two JSON objects - -@since version 1.0.0 -*/ -template<> -inline void swap(nlohmann::json& j1, nlohmann::json& j2) noexcept( // NOLINT(readability-inconsistent-declaration-parameter-name) - is_nothrow_move_constructible::value&& // NOLINT(misc-redundant-expression) - is_nothrow_move_assignable::value - ) -{ - j1.swap(j2); -} - -#endif - -} // namespace std - -/*! -@brief user-defined string literal for JSON values - -This operator implements a user-defined string literal for JSON objects. It -can be used by adding `"_json"` to a string literal and returns a JSON object -if no parse error occurred. - -@param[in] s a string representation of a JSON object -@param[in] n the length of string @a s -@return a JSON object - -@since version 1.0.0 -*/ -JSON_HEDLEY_NON_NULL(1) -inline nlohmann::json operator "" _json(const char* s, std::size_t n) -{ - return nlohmann::json::parse(s, s + n); -} - -/*! -@brief user-defined string literal for JSON pointer - -This operator implements a user-defined string literal for JSON Pointers. It -can be used by adding `"_json_pointer"` to a string literal and returns a JSON pointer -object if no parse error occurred. - -@param[in] s a string representation of a JSON Pointer -@param[in] n the length of string @a s -@return a JSON pointer object - -@since version 2.0.0 -*/ -JSON_HEDLEY_NON_NULL(1) -inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t n) -{ - return nlohmann::json::json_pointer(std::string(s, n)); -} - -// #include - - -// restore clang diagnostic settings -#if defined(__clang__) - #pragma clang diagnostic pop -#endif - -// clean up -#undef JSON_ASSERT -#undef JSON_INTERNAL_CATCH -#undef JSON_CATCH -#undef JSON_THROW -#undef JSON_TRY -#undef JSON_PRIVATE_UNLESS_TESTED -#undef JSON_HAS_CPP_11 -#undef JSON_HAS_CPP_14 -#undef JSON_HAS_CPP_17 -#undef JSON_HAS_CPP_20 -#undef NLOHMANN_BASIC_JSON_TPL_DECLARATION -#undef NLOHMANN_BASIC_JSON_TPL -#undef JSON_EXPLICIT -#undef NLOHMANN_CAN_CALL_STD_FUNC_IMPL - -// #include - - -#undef JSON_HEDLEY_ALWAYS_INLINE -#undef JSON_HEDLEY_ARM_VERSION -#undef JSON_HEDLEY_ARM_VERSION_CHECK -#undef JSON_HEDLEY_ARRAY_PARAM -#undef JSON_HEDLEY_ASSUME -#undef JSON_HEDLEY_BEGIN_C_DECLS -#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE -#undef JSON_HEDLEY_CLANG_HAS_BUILTIN -#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE -#undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE -#undef JSON_HEDLEY_CLANG_HAS_EXTENSION -#undef JSON_HEDLEY_CLANG_HAS_FEATURE -#undef JSON_HEDLEY_CLANG_HAS_WARNING -#undef JSON_HEDLEY_COMPCERT_VERSION -#undef JSON_HEDLEY_COMPCERT_VERSION_CHECK -#undef JSON_HEDLEY_CONCAT -#undef JSON_HEDLEY_CONCAT3 -#undef JSON_HEDLEY_CONCAT3_EX -#undef JSON_HEDLEY_CONCAT_EX -#undef JSON_HEDLEY_CONST -#undef JSON_HEDLEY_CONSTEXPR -#undef JSON_HEDLEY_CONST_CAST -#undef JSON_HEDLEY_CPP_CAST -#undef JSON_HEDLEY_CRAY_VERSION -#undef JSON_HEDLEY_CRAY_VERSION_CHECK -#undef JSON_HEDLEY_C_DECL -#undef JSON_HEDLEY_DEPRECATED -#undef JSON_HEDLEY_DEPRECATED_FOR -#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL -#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ -#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED -#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES -#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS -#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION -#undef JSON_HEDLEY_DIAGNOSTIC_POP -#undef JSON_HEDLEY_DIAGNOSTIC_PUSH -#undef JSON_HEDLEY_DMC_VERSION -#undef JSON_HEDLEY_DMC_VERSION_CHECK -#undef JSON_HEDLEY_EMPTY_BASES -#undef JSON_HEDLEY_EMSCRIPTEN_VERSION -#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK -#undef JSON_HEDLEY_END_C_DECLS -#undef JSON_HEDLEY_FLAGS -#undef JSON_HEDLEY_FLAGS_CAST -#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE -#undef JSON_HEDLEY_GCC_HAS_BUILTIN -#undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE -#undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE -#undef JSON_HEDLEY_GCC_HAS_EXTENSION -#undef JSON_HEDLEY_GCC_HAS_FEATURE -#undef JSON_HEDLEY_GCC_HAS_WARNING -#undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK -#undef JSON_HEDLEY_GCC_VERSION -#undef JSON_HEDLEY_GCC_VERSION_CHECK -#undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE -#undef JSON_HEDLEY_GNUC_HAS_BUILTIN -#undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE -#undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE -#undef JSON_HEDLEY_GNUC_HAS_EXTENSION -#undef JSON_HEDLEY_GNUC_HAS_FEATURE -#undef JSON_HEDLEY_GNUC_HAS_WARNING -#undef JSON_HEDLEY_GNUC_VERSION -#undef JSON_HEDLEY_GNUC_VERSION_CHECK -#undef JSON_HEDLEY_HAS_ATTRIBUTE -#undef JSON_HEDLEY_HAS_BUILTIN -#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE -#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS -#undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE -#undef JSON_HEDLEY_HAS_EXTENSION -#undef JSON_HEDLEY_HAS_FEATURE -#undef JSON_HEDLEY_HAS_WARNING -#undef JSON_HEDLEY_IAR_VERSION -#undef JSON_HEDLEY_IAR_VERSION_CHECK -#undef JSON_HEDLEY_IBM_VERSION -#undef JSON_HEDLEY_IBM_VERSION_CHECK -#undef JSON_HEDLEY_IMPORT -#undef JSON_HEDLEY_INLINE -#undef JSON_HEDLEY_INTEL_CL_VERSION -#undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK -#undef JSON_HEDLEY_INTEL_VERSION -#undef JSON_HEDLEY_INTEL_VERSION_CHECK -#undef JSON_HEDLEY_IS_CONSTANT -#undef JSON_HEDLEY_IS_CONSTEXPR_ -#undef JSON_HEDLEY_LIKELY -#undef JSON_HEDLEY_MALLOC -#undef JSON_HEDLEY_MCST_LCC_VERSION -#undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK -#undef JSON_HEDLEY_MESSAGE -#undef JSON_HEDLEY_MSVC_VERSION -#undef JSON_HEDLEY_MSVC_VERSION_CHECK -#undef JSON_HEDLEY_NEVER_INLINE -#undef JSON_HEDLEY_NON_NULL -#undef JSON_HEDLEY_NO_ESCAPE -#undef JSON_HEDLEY_NO_RETURN -#undef JSON_HEDLEY_NO_THROW -#undef JSON_HEDLEY_NULL -#undef JSON_HEDLEY_PELLES_VERSION -#undef JSON_HEDLEY_PELLES_VERSION_CHECK -#undef JSON_HEDLEY_PGI_VERSION -#undef JSON_HEDLEY_PGI_VERSION_CHECK -#undef JSON_HEDLEY_PREDICT -#undef JSON_HEDLEY_PRINTF_FORMAT -#undef JSON_HEDLEY_PRIVATE -#undef JSON_HEDLEY_PUBLIC -#undef JSON_HEDLEY_PURE -#undef JSON_HEDLEY_REINTERPRET_CAST -#undef JSON_HEDLEY_REQUIRE -#undef JSON_HEDLEY_REQUIRE_CONSTEXPR -#undef JSON_HEDLEY_REQUIRE_MSG -#undef JSON_HEDLEY_RESTRICT -#undef JSON_HEDLEY_RETURNS_NON_NULL -#undef JSON_HEDLEY_SENTINEL -#undef JSON_HEDLEY_STATIC_ASSERT -#undef JSON_HEDLEY_STATIC_CAST -#undef JSON_HEDLEY_STRINGIFY -#undef JSON_HEDLEY_STRINGIFY_EX -#undef JSON_HEDLEY_SUNPRO_VERSION -#undef JSON_HEDLEY_SUNPRO_VERSION_CHECK -#undef JSON_HEDLEY_TINYC_VERSION -#undef JSON_HEDLEY_TINYC_VERSION_CHECK -#undef JSON_HEDLEY_TI_ARMCL_VERSION -#undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK -#undef JSON_HEDLEY_TI_CL2000_VERSION -#undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK -#undef JSON_HEDLEY_TI_CL430_VERSION -#undef JSON_HEDLEY_TI_CL430_VERSION_CHECK -#undef JSON_HEDLEY_TI_CL6X_VERSION -#undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK -#undef JSON_HEDLEY_TI_CL7X_VERSION -#undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK -#undef JSON_HEDLEY_TI_CLPRU_VERSION -#undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK -#undef JSON_HEDLEY_TI_VERSION -#undef JSON_HEDLEY_TI_VERSION_CHECK -#undef JSON_HEDLEY_UNAVAILABLE -#undef JSON_HEDLEY_UNLIKELY -#undef JSON_HEDLEY_UNPREDICTABLE -#undef JSON_HEDLEY_UNREACHABLE -#undef JSON_HEDLEY_UNREACHABLE_RETURN -#undef JSON_HEDLEY_VERSION -#undef JSON_HEDLEY_VERSION_DECODE_MAJOR -#undef JSON_HEDLEY_VERSION_DECODE_MINOR -#undef JSON_HEDLEY_VERSION_DECODE_REVISION -#undef JSON_HEDLEY_VERSION_ENCODE -#undef JSON_HEDLEY_WARNING -#undef JSON_HEDLEY_WARN_UNUSED_RESULT -#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG -#undef JSON_HEDLEY_FALL_THROUGH - - - -#endif // INCLUDE_NLOHMANN_JSON_HPP_ diff --git a/extern/ply/ply.cpp b/extern/ply/ply.cpp deleted file mode 100644 index aeb31d9..0000000 --- a/extern/ply/ply.cpp +++ /dev/null @@ -1,2838 +0,0 @@ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wmissing-variable-declarations" -#pragma clang diagnostic ignored "-Wcast-qual" -#pragma clang diagnostic ignored "-Wunused-macros" -#pragma clang diagnostic ignored "-Wextended-offsetof" -#pragma clang diagnostic ignored "-Wself-assign" - -/* - - The interface routines for reading and writing PLY polygon files. - - Greg Turk, February 1994 - - --------------------------------------------------------------- - - A PLY file contains a single polygonal _object_. - - An object is composed of lists of _elements_. Typical elements are - vertices, faces, edges and materials. - - Each type of element for a given object has one or more _properties_ - associated with the element type. For instance, a vertex element may - have as properties the floating-point values x,y,z and the three unsigned - chars representing red, green and blue. - - --------------------------------------------------------------- - - Copyright (c) 1994 The Board of Trustees of The Leland Stanford - Junior University. All rights reserved. - - Permission to use, copy, modify and distribute this software and its - documentation for any purpose is hereby granted without fee, provided - that the above copyright notice and this permission notice appear in - all copies of this software and that you do not sell the software. - - THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND, - EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - - */ - -#include -#include -#include -#include -#include "ply.h" - -#define FALSE 0 -#define TRUE 1 - -#define X 0 -#define Y 1 -#define Z 2 - - - double LAmag,LAsum; int LAi,LAj,LAk; -#define VEC3_ZERO(a) { a[0]=a[1]=a[2]=0; } -#define VEC3_NEG(a,b) { a[0]= -b[0]; a[1]= -b[1];a[2]= -b[2];} -#define VEC3_V_OP_V(a,b,op,c) { a[0] = b[0] op c[0]; \ - a[1] = b[1] op c[1]; \ - a[2] = b[2] op c[2]; \ - } -#define VEC3_ASN_OP(a,op,b) {a[0] op b[0]; a[1] op b[1]; a[2] op b[2];} - -#define DOTPROD3(a, b) (a[0]*b[0] + a[1]*b[1] + a[2]*b[2]) - -#define CROSSPROD3(a,b,c) {a[0]=b[1]*c[2]-b[2]*c[1]; \ - a[1]=b[2]*c[0]-b[0]*c[2]; \ - a[2]=b[0]*c[1]-b[1]*c[0];} - -#define NORMALIZE3(a) {LAmag=1./sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]); \ - a[0] *= LAmag; a[1] *= LAmag; a[2] *= LAmag;} - -#define ZERO3_TOL(a, tol) { a[0] = ((a[0]-tol))?0.0:a[0]; \ - a[1] = ((a[1]-tol))?0.0:a[1]; \ - a[2] = ((a[2]-tol))?0.0:a[2]; \ - } - - /* user's vertex and face definitions for a polygonal object */ - - typedef float Point[3]; - typedef float Vector[3]; - - typedef struct Vertex { - int id; - Point coord; /* coordinates of vertex */ - Point normal; /* normal of vertex */ - unsigned char red; - unsigned char green; - unsigned char blue; - unsigned char nfaces; /* number of face indices in list */ - int *faces; /* face index list */ - void *other_props; /* other properties */ - } Vertex; - - - typedef struct Face { - int id; - unsigned char nverts; /* number of vertex indices in list */ - int *verts; /* vertex index list */ - unsigned char red; - unsigned char green; - unsigned char blue; - - void *other_props; /* other properties */ - } Face; - - PlyProperty vert_props[] = { /* list of property information for a vertex */ - {(char*)"x", PLY_FLOAT, PLY_FLOAT, offsetof(::Vertex,coord[X]), 0, 0, 0, 0}, - {(char*)"y", PLY_FLOAT, PLY_FLOAT, offsetof(::Vertex,coord[Y]), 0, 0, 0, 0}, - {(char*)"z", PLY_FLOAT, PLY_FLOAT, offsetof(::Vertex,coord[Z]), 0, 0, 0, 0}, - {(char*)"nx", PLY_FLOAT, PLY_FLOAT, offsetof(::Vertex,normal[X]), 0, 0, 0, 0}, - {(char*)"ny", PLY_FLOAT, PLY_FLOAT, offsetof(::Vertex,normal[Y]), 0, 0, 0, 0}, - {(char*)"nz", PLY_FLOAT, PLY_FLOAT, offsetof(::Vertex,normal[Z]), 0, 0, 0, 0}, - {(char*)"diffuse_red", PLY_UCHAR, PLY_UCHAR, offsetof(::Vertex,red), 0, 0, 0, 0}, - {(char*)"diffuse_green", PLY_UCHAR, PLY_UCHAR, offsetof(::Vertex,green), 0, 0, 0, 0}, - {(char*)"diffuse_blue", PLY_UCHAR, PLY_UCHAR, offsetof(::Vertex,blue), 0, 0, 0, 0}, - }; - enum { - VTX_X = 0, - VTX_Y, - VTX_Z, - VTX_NX, - VTX_NY, - VTX_NZ, - VTX_RED, - VTX_GREEN, - VTX_BLUE - }; - - PlyProperty face_props[] = { /* list of property information for a face */ - {(char*)"vertex_indices", PLY_INT, PLY_INT, offsetof(Face,verts), - 1, PLY_UCHAR, PLY_UCHAR, offsetof(Face,nverts)}, - {(char*)"red", PLY_UCHAR, PLY_UCHAR, offsetof(Face,red), 0, 0, 0, 0}, - {(char*)"green", PLY_UCHAR, PLY_UCHAR, offsetof(Face,green), 0, 0, 0, 0}, - {(char*)"blue", PLY_UCHAR, PLY_UCHAR, offsetof(Face,blue), 0, 0, 0, 0}, - }; - - enum { - FACE_INDICES = 0, - FACE_RED, - FACE_GREEN, - FACE_BLUE - }; - - /*** the PLY object ***/ - int has_x, has_y, has_z; - int has_face_red=0; // face colors - int has_face_green=0; // face colors - int has_face_blue=0; // face colors - int has_vertex_red=0; // vertex colors - int has_vertex_green=0; // vertex colors - int has_vertex_blue=0; // vertex colors - int has_nx=0, has_ny=0, has_nz=0; - int has_fverts=0; - -#define PRINTPROP(o,var,prop,val,str,vals) \ - if (vals) o << ","; \ - if (has_##prop) { o << str << "=" << var . val; vals++; } -extern "C" { - -#define LION_HACK 1 - - const char *type_names[] = { - "invalid", - "char", "short", "int", - "uchar", "ushort", "uint", - "float", - "double", - }; - - int ply_type_size[] = { - 0, 1, 2, 4, 1, 2, 4, 4, - 8 - }; - - typedef union - { - int int_value; - char byte_values[sizeof(int)]; - } endian_test_type; - - - static int native_binary_type = -1; - static int types_checked = 0; - -#define NO_OTHER_PROPS -1 - -#define DONT_STORE_PROP 0 -#define STORE_PROP 1 - -#define OTHER_PROP 0 -#define NAMED_PROP 1 - - - /* returns 1 if strings are equal, 0 if not */ - int equal_strings(const char *, const char *); - - /* find an element in a plyfile's list */ - PlyElement *find_element(PlyFile *, char *); - - /* find a property in an element's list */ - PlyProperty *find_property(PlyElement *, char *, int *); - - /* write to a file the word describing a PLY file data type */ - void write_scalar_type (FILE *, int); - - /* read a line from a file and break it up into separate words */ - char **get_words(FILE *, int *, char **); - char **old_get_words(FILE *, int *); - - /* write an item to a file */ - void write_binary_item(FILE *, int, int, unsigned int, double, int); - void write_ascii_item(FILE *, int, unsigned int, double, int); - double old_write_ascii_item(FILE *, char *, int); - - /* add information to a PLY file descriptor */ - void add_element(PlyFile *, char **); - void add_property(PlyFile *, char **); - void add_comment(PlyFile *, char *); - void add_obj_info(PlyFile *, char *); - - /* copy a property */ - void copy_property(PlyProperty *, PlyProperty *); - - /* store a value into where a pointer and a type specify */ - void store_item(char *, int, int, unsigned int, double); - - /* return the value of a stored item */ - void get_stored_item( void *, int, int *, unsigned int *, double *); - - /* return the value stored in an item, given ptr to it and its type */ - double get_item_value(char *, int); - - /* get binary or ascii item and store it according to ptr and type */ - void get_ascii_item(char *, int, int *, unsigned int *, double *); - void get_binary_item(FILE *, int, int, int *, unsigned int *, double *); - - /* get a bunch of elements from a file */ - void ascii_get_element(PlyFile *, char *); - void binary_get_element(PlyFile *, char *); - - /* memory allocation */ - void *my_alloc(int, int, const char *); - - /* byte ordering */ - void get_native_binary_type(); - void swap_bytes(char *, int); - - void check_types(); - - /*************/ - /* Writing */ - /*************/ - - - /****************************************************************************** -Given a file pointer, get ready to write PLY data to the file. - -Entry: - fp - the given file pointer - nelems - number of elements in object - elem_names - list of element names - file_type - file type, either ascii or binary - -Exit: - returns a pointer to a PlyFile, used to refer to this file, or NULL if error - ******************************************************************************/ - - PlyFile *ply_write( - FILE *fp, - int nelems, - char **elem_names, - int file_type - ) - { - int i; - PlyFile *plyfile; - PlyElement *elem; - - /* check for NULL file pointer */ - if (fp == NULL) - return (NULL); - - if (native_binary_type == -1) - get_native_binary_type(); - if (!types_checked) - check_types(); - - /* create a record for this object */ - - plyfile = (PlyFile *) myalloc (sizeof (PlyFile)); - if (file_type == PLY_BINARY_NATIVE) - plyfile->file_type = native_binary_type; - else - plyfile->file_type = file_type; - plyfile->num_comments = 0; - plyfile->num_obj_info = 0; - plyfile->nelems = nelems; - plyfile->version = 1.0; - plyfile->fp = fp; - plyfile->other_elems = NULL; - - /* tuck aside the names of the elements */ - - plyfile->elems = (PlyElement **) myalloc (sizeof (PlyElement *) * nelems); - for (i = 0; i < nelems; i++) { - elem = (PlyElement *) myalloc (sizeof (PlyElement)); - plyfile->elems[i] = elem; - elem->name = strdup (elem_names[i]); - elem->num = 0; - elem->nprops = 0; - } - - /* return pointer to the file descriptor */ - return (plyfile); - } - - - /****************************************************************************** -Open a polygon file for writing. - -Entry: - filename - name of file to read from - nelems - number of elements in object - elem_names - list of element names - file_type - file type, either ascii or binary - -Exit: - version - version number of PLY file - returns a file identifier, used to refer to this file, or NULL if error - ******************************************************************************/ - - PlyFile *ply_open_for_writing( - char *filename, - int nelems, - char **elem_names, - int file_type, - float *version - ) - { - PlyFile *plyfile; - char *name; - FILE *fp; - - /* tack on the extension .ply, if necessary */ - - name = (char *) myalloc (sizeof (char) * (strlen (filename) + 5)); - strcpy (name, filename); - if (strlen (name) < 4 || - strcmp (name + strlen (name) - 4, ".ply") != 0) - strcat (name, ".ply"); - - /* open the file for writing */ - - fp = fopen (name, "w"); - if (fp == NULL) { - return (NULL); - } - - /* create the actual PlyFile structure */ - - plyfile = ply_write (fp, nelems, elem_names, file_type); - if (plyfile == NULL) - return (NULL); - - /* say what PLY file version number we're writing */ - *version = plyfile->version; - - /* return pointer to the file descriptor */ - return (plyfile); - } - - - /****************************************************************************** -Describe an element, including its properties and how many will be written -to the file. - -Entry: - plyfile - file identifier - elem_name - name of element that information is being specified about - nelems - number of elements of this type to be written - nprops - number of properties contained in the element - prop_list - list of properties - ******************************************************************************/ - - void ply_describe_element( - PlyFile *plyfile, - char *elem_name, - int nelems, - int nprops, - PlyProperty *prop_list - ) - { - int i; - PlyElement *elem; - PlyProperty *prop; - - /* look for appropriate element */ - elem = find_element (plyfile, elem_name); - if (elem == NULL) { - fprintf(stderr,"ply_describe_element: can't find element '%s'\n",elem_name); - exit (-1); - } - - elem->num = nelems; - - /* copy the list of properties */ - - elem->nprops = nprops; - elem->props = (PlyProperty **) myalloc (sizeof (PlyProperty *) * nprops); - elem->store_prop = (char *) myalloc (sizeof (char) * nprops); - - for (i = 0; i < nprops; i++) { - prop = (PlyProperty *) myalloc (sizeof (PlyProperty)); - elem->props[i] = prop; - elem->store_prop[i] = NAMED_PROP; - copy_property (prop, &prop_list[i]); - } - } - - - /****************************************************************************** -Describe a property of an element. - -Entry: - plyfile - file identifier - elem_name - name of element that information is being specified about - prop - the new property - ******************************************************************************/ - - void ply_describe_property( - PlyFile *plyfile, - char *elem_name, - PlyProperty *prop - ) - { - PlyElement *elem; - PlyProperty *elem_prop; - - /* look for appropriate element */ - elem = find_element (plyfile, elem_name); - if (elem == NULL) { - fprintf(stderr, "ply_describe_property: can't find element '%s'\n", - elem_name); - return; - } - - /* create room for new property */ - - if (elem->nprops == 0) { - elem->props = (PlyProperty **) myalloc (sizeof (PlyProperty *)); - elem->store_prop = (char *) myalloc (sizeof (char)); - elem->nprops = 1; - } - else { - elem->nprops++; - elem->props = (PlyProperty **) - realloc (elem->props, sizeof (PlyProperty *) * elem->nprops); - elem->store_prop = (char *) - realloc (elem->store_prop, sizeof (char) * elem->nprops); - - if(elem->props == nullptr || elem->store_prop == nullptr) { - fprintf(stderr, "ply_describe_property: can't alloc memory for props\n"); - exit(1); - } - } - - /* copy the new property */ - - elem_prop = (PlyProperty *) myalloc (sizeof (PlyProperty)); - elem->props[elem->nprops - 1] = elem_prop; - elem->store_prop[elem->nprops - 1] = NAMED_PROP; - copy_property (elem_prop, prop); - } - - - /****************************************************************************** -Describe what the "other" properties are that are to be stored, and where -they are in an element. - ******************************************************************************/ - - void ply_describe_other_properties( - PlyFile *plyfile, - PlyOtherProp *other, - int offset - ) - { - int i; - PlyElement *elem; - PlyProperty *prop; - - /* look for appropriate element */ - elem = find_element (plyfile, other->name); - if (elem == NULL) { - fprintf(stderr, "ply_describe_other_properties: can't find element '%s'\n", - other->name); - return; - } - - /* create room for other properties */ - - if (elem->nprops == 0) { - elem->props = (PlyProperty **) - myalloc (sizeof (PlyProperty *) * other->nprops); - elem->store_prop = (char *) myalloc (sizeof (char) * other->nprops); - elem->nprops = 0; - } - else { - int newsize; - newsize = elem->nprops + other->nprops; - elem->props = (PlyProperty **) - realloc (elem->props, sizeof (PlyProperty *) * newsize); - elem->store_prop = (char *) - realloc (elem->store_prop, sizeof (char) * newsize); - - if(elem->props == nullptr || elem->store_prop == nullptr) { - fprintf(stderr, "ply_describe_other_properties: can't alloc memory for props\n"); - exit(1); - } - } - - /* copy the other properties */ - - for (i = 0; i < other->nprops; i++) { - prop = (PlyProperty *) myalloc (sizeof (PlyProperty)); - copy_property (prop, other->props[i]); - elem->props[elem->nprops] = prop; - elem->store_prop[elem->nprops] = OTHER_PROP; - elem->nprops++; - } - - /* save other info about other properties */ - elem->other_size = other->size; - elem->other_offset = offset; - } - - - /****************************************************************************** -State how many of a given element will be written. - -Entry: - plyfile - file identifier - elem_name - name of element that information is being specified about - nelems - number of elements of this type to be written - ******************************************************************************/ - - void ply_element_count( - PlyFile *plyfile, - char *elem_name, - int nelems - ) - { - PlyElement *elem; - - /* look for appropriate element */ - elem = find_element (plyfile, elem_name); - if (elem == NULL) { - fprintf(stderr,"ply_element_count: can't find element '%s'\n",elem_name); - exit (-1); - } - - elem->num = nelems; - } - - - /****************************************************************************** -Signal that we've described everything a PLY file's header and that the -header should be written to the file. - -Entry: - plyfile - file identifier - ******************************************************************************/ - - void ply_header_complete(PlyFile *plyfile) - { - int i,j; - FILE *fp = plyfile->fp; - PlyElement *elem; - PlyProperty *prop; - - fprintf (fp, "ply\n"); - - switch (plyfile->file_type) { - case PLY_ASCII: - fprintf (fp, "format ascii 1.0\n"); - break; - case PLY_BINARY_BE: - fprintf (fp, "format binary_big_endian 1.0\n"); - break; - case PLY_BINARY_LE: - fprintf (fp, "format binary_little_endian 1.0\n"); - break; - default: - fprintf (stderr, "ply_header_complete: bad file type = %d\n", - plyfile->file_type); - exit (-1); - } - - /* write out the comments */ - - for (i = 0; i < plyfile->num_comments; i++) - fprintf (fp, "comment %s\n", plyfile->comments[i]); - - /* write out object information */ - - for (i = 0; i < plyfile->num_obj_info; i++) - fprintf (fp, "obj_info %s\n", plyfile->obj_info[i]); - - /* write out information about each element */ - - for (i = 0; i < plyfile->nelems; i++) { - - elem = plyfile->elems[i]; - fprintf (fp, "element %s %d\n", elem->name, elem->num); - - /* write out each property */ - for (j = 0; j < elem->nprops; j++) { - prop = elem->props[j]; - if (prop->is_list) { - fprintf (fp, "property list "); - write_scalar_type (fp, prop->count_external); - fprintf (fp, " "); - write_scalar_type (fp, prop->external_type); - fprintf (fp, " %s\n", prop->name); - } - else { - fprintf (fp, "property "); - write_scalar_type (fp, prop->external_type); - fprintf (fp, " %s\n", prop->name); - } - } - } - - fprintf (fp, "end_header\n"); - } - - - /****************************************************************************** -Specify which elements are going to be written. This should be called -before a call to the routine ply_put_element(). - -Entry: - plyfile - file identifier - elem_name - name of element we're talking about - ******************************************************************************/ - void ply_put_element_setup(PlyFile *plyfile, char *elem_name) - { - PlyElement *elem; - - elem = find_element (plyfile, elem_name); - if (elem == NULL) { - fprintf(stderr, "ply_elements_setup: can't find element '%s'\n", elem_name); - exit (-1); - } - - plyfile->which_elem = elem; - } - - - /****************************************************************************** -Write an element to the file. This routine assumes that we're -writing the type of element specified in the last call to the routine -ply_put_element_setup(). - -Entry: - plyfile - file identifier - elem_ptr - pointer to the element - ******************************************************************************/ - - void ply_put_element(PlyFile *plyfile, void *elem_ptr) - { - int j,k; - FILE *fp = plyfile->fp; - PlyElement *elem; - PlyProperty *prop; - char *elem_data,*item; - char **item_ptr; - int list_count; - int item_size; - int int_val; - unsigned int uint_val; - double double_val; - char **other_ptr; - - elem = plyfile->which_elem; - elem_data = (char *)elem_ptr; - other_ptr = (char **) (((char *) elem_ptr) + elem->other_offset); - - /* write out either to an ascii or binary file */ - - if (plyfile->file_type == PLY_ASCII) { - - /* write an ascii file */ - - /* write out each property of the element */ - for (j = 0; j < elem->nprops; j++) { - prop = elem->props[j]; - if (elem->store_prop[j] == OTHER_PROP) - elem_data = *other_ptr; - else - elem_data = (char *)elem_ptr; - if (prop->is_list) { - item = elem_data + prop->count_offset; - get_stored_item ((void *) item, prop->count_internal, - &int_val, &uint_val, &double_val); - write_ascii_item (fp, int_val, uint_val, double_val, - prop->count_external); - list_count = uint_val; - item_ptr = (char **) (elem_data + prop->offset); - item = item_ptr[0]; - item_size = ply_type_size[prop->internal_type]; - for (k = 0; k < list_count; k++) { - get_stored_item ((void *) item, prop->internal_type, - &int_val, &uint_val, &double_val); - write_ascii_item (fp, int_val, uint_val, double_val, - prop->external_type); - item += item_size; - } - } - else { - item = elem_data + prop->offset; - get_stored_item ((void *) item, prop->internal_type, - &int_val, &uint_val, &double_val); - write_ascii_item (fp, int_val, uint_val, double_val, - prop->external_type); - } - } - - fprintf (fp, "\n"); - } - else { - - /* write a binary file */ - - /* write out each property of the element */ - for (j = 0; j < elem->nprops; j++) { - prop = elem->props[j]; - if (elem->store_prop[j] == OTHER_PROP) - elem_data = *other_ptr; - else - elem_data = (char *)elem_ptr; - if (prop->is_list) { - item = elem_data + prop->count_offset; - item_size = ply_type_size[prop->count_internal]; - get_stored_item ((void *) item, prop->count_internal, - &int_val, &uint_val, &double_val); - write_binary_item (fp, plyfile->file_type, int_val, uint_val, - double_val, prop->count_external); - list_count = uint_val; - item_ptr = (char **) (elem_data + prop->offset); - item = item_ptr[0]; - item_size = ply_type_size[prop->internal_type]; - for (k = 0; k < list_count; k++) { - get_stored_item ((void *) item, prop->internal_type, - &int_val, &uint_val, &double_val); - write_binary_item (fp, plyfile->file_type, int_val, uint_val, - double_val, prop->external_type); - item += item_size; - } - } - else { - item = elem_data + prop->offset; - item_size = ply_type_size[prop->internal_type]; - get_stored_item ((void *) item, prop->internal_type, - &int_val, &uint_val, &double_val); - write_binary_item (fp, plyfile->file_type, int_val, uint_val, - double_val, prop->external_type); - } - } - - } - } - - - /****************************************************************************** -Specify a comment that will be written in the header. - -Entry: - plyfile - file identifier - comment - the comment to be written - ******************************************************************************/ - - void ply_put_comment(PlyFile *plyfile, char *comment) - { - /* (re)allocate space for new comment */ - if (plyfile->num_comments == 0) - plyfile->comments = (char **) myalloc (sizeof (char *)); - else - plyfile->comments = (char **) realloc (plyfile->comments, - sizeof (char *) * (plyfile->num_comments + 1)); - if(plyfile->comments == nullptr) { - fprintf(stderr, "ply_put_comment: can't alloc memory for plyfile->comments\n"); - exit(1); - } - /* add comment to list */ - plyfile->comments[plyfile->num_comments] = strdup (comment); - plyfile->num_comments++; - } - - - /****************************************************************************** -Specify a piece of object information (arbitrary text) that will be written -in the header. - -Entry: - plyfile - file identifier - obj_info - the text information to be written - ******************************************************************************/ - - void ply_put_obj_info(PlyFile *plyfile, char *obj_info) - { - /* (re)allocate space for new info */ - if (plyfile->num_obj_info == 0) - plyfile->obj_info = (char **) myalloc (sizeof (char *)); - else - plyfile->obj_info = (char **) realloc (plyfile->obj_info, - sizeof (char *) * (plyfile->num_obj_info + 1)); - if(plyfile->obj_info == nullptr) { - fprintf(stderr, "ply_put_obj_info: can't alloc memory for plyfile->obj_info\n"); - exit(1); - } - /* add info to list */ - plyfile->obj_info[plyfile->num_obj_info] = strdup (obj_info); - plyfile->num_obj_info++; - } - - - - - - - - /*************/ - /* Reading */ - /*************/ - - - - /****************************************************************************** -Given a file pointer, get ready to read PLY data from the file. - -Entry: - fp - the given file pointer - -Exit: - nelems - number of elements in object - elem_names - list of element names - returns a pointer to a PlyFile, used to refer to this file, or NULL if error - ******************************************************************************/ - - PlyFile *ply_read(FILE *fp, int *nelems, char ***elem_names) - { - int i,j; - PlyFile *plyfile; - int nwords; - char **words; - char **elist; - PlyElement *elem; - char *orig_line; - - /* check for NULL file pointer */ - if (fp == NULL) - return (NULL); - - if (native_binary_type == -1) - get_native_binary_type(); - if (!types_checked) - check_types(); - - /* create record for this object */ - - plyfile = (PlyFile *) myalloc (sizeof (PlyFile)); - plyfile->nelems = 0; - plyfile->comments = NULL; - plyfile->num_comments = 0; - plyfile->obj_info = NULL; - plyfile->num_obj_info = 0; - plyfile->fp = fp; - plyfile->other_elems = NULL; - - /* read and parse the file's header */ - - words = get_words (plyfile->fp, &nwords, &orig_line); - if (!words || !equal_strings (words[0], "ply")) - { - if (words) - free(words); - return (NULL); - } - - while (words) { - /* parse words */ - - if (equal_strings (words[0], "format")) { - if (nwords != 3) { - free(words); - return (NULL); - } - if (equal_strings (words[1], "ascii")) - plyfile->file_type = PLY_ASCII; - else if (equal_strings (words[1], "binary_big_endian")) - plyfile->file_type = PLY_BINARY_BE; - else if (equal_strings (words[1], "binary_little_endian")) - plyfile->file_type = PLY_BINARY_LE; - else { - free(words); - return (NULL); - } - plyfile->version = (float)atof (words[2]); - } - else if (equal_strings (words[0], "element")) - add_element (plyfile, words); - else if (equal_strings (words[0], "property")) - add_property (plyfile, words); - else if (equal_strings (words[0], "comment")) - add_comment (plyfile, orig_line); - else if (equal_strings (words[0], "obj_info")) - add_obj_info (plyfile, orig_line); - else if (equal_strings (words[0], "end_header")) { - free(words); - break; - } - - /* free up words space */ - free (words); - - words = get_words (plyfile->fp, &nwords, &orig_line); - } - - /* create tags for each property of each element, to be used */ - /* later to say whether or not to store each property for the user */ - - for (i = 0; i < plyfile->nelems; i++) { - elem = plyfile->elems[i]; - elem->store_prop = (char *) myalloc (sizeof (char) * elem->nprops); - for (j = 0; j < elem->nprops; j++) - elem->store_prop[j] = DONT_STORE_PROP; - elem->other_offset = NO_OTHER_PROPS; /* no "other" props by default */ - } - - /* set return values about the elements */ - - elist = (char **) myalloc (sizeof (char *) * plyfile->nelems); - for (i = 0; i < plyfile->nelems; i++) - elist[i] = strdup (plyfile->elems[i]->name); - - *elem_names = elist; - *nelems = plyfile->nelems; - - /* return a pointer to the file's information */ - - return (plyfile); - } - - - /****************************************************************************** -Open a polygon file for reading. - -Entry: - filename - name of file to read from - -Exit: - nelems - number of elements in object - elem_names - list of element names - file_type - file type, either ascii or binary - version - version number of PLY file - returns a file identifier, used to refer to this file, or NULL if error - ******************************************************************************/ - - PlyFile *ply_open_for_reading( - char *filename, - int *nelems, - char ***elem_names, - int *file_type, - float *version - ) - { - FILE *fp; - PlyFile *plyfile; - char *name; - - /* tack on the extension .ply, if necessary */ - - name = (char *) myalloc (sizeof (char) * (strlen (filename) + 5)); - strcpy (name, filename); - if (strlen (name) < 4 || - strcmp (name + strlen (name) - 4, ".ply") != 0) - strcat (name, ".ply"); - - /* open the file for reading */ - - fp = fopen (name, "r"); - if (fp == NULL) - return (NULL); - - /* create the PlyFile data structure */ - - plyfile = ply_read (fp, nelems, elem_names); - if (plyfile == nullptr) - return NULL; - - /* determine the file type and version */ - - *file_type = plyfile->file_type; - *version = plyfile->version; - - /* return a pointer to the file's information */ - - return (plyfile); - } - - - /****************************************************************************** -Get information about a particular element. - -Entry: - plyfile - file identifier - elem_name - name of element to get information about - -Exit: - nelems - number of elements of this type in the file - nprops - number of properties - returns a list of properties, or NULL if the file doesn't contain that elem - ******************************************************************************/ - - PlyProperty **ply_get_element_description( - PlyFile *plyfile, - char *elem_name, - int *nelems, - int *nprops - ) - { - int i; - PlyElement *elem; - PlyProperty *prop; - PlyProperty **prop_list; - - /* find information about the element */ - elem = find_element (plyfile, elem_name); - if (elem == NULL) - return (NULL); - - *nelems = elem->num; - *nprops = elem->nprops; - - /* make a copy of the element's property list */ - prop_list = (PlyProperty **) myalloc (sizeof (PlyProperty *) * elem->nprops); - for (i = 0; i < elem->nprops; i++) { - prop = (PlyProperty *) myalloc (sizeof (PlyProperty)); - copy_property (prop, elem->props[i]); - prop_list[i] = prop; - } - - /* return this duplicate property list */ - return (prop_list); - } - - - /****************************************************************************** -Specify which properties of an element are to be returned. This should be -called before a call to the routine ply_get_element(). - -Entry: - plyfile - file identifier - elem_name - which element we're talking about - nprops - number of properties - prop_list - list of properties - ******************************************************************************/ - - void ply_get_element_setup( - PlyFile *plyfile, - char *elem_name, - int nprops, - PlyProperty *prop_list - ) - { - int i; - PlyElement *elem; - PlyProperty *prop; - int index; - - /* find information about the element */ - elem = find_element (plyfile, elem_name); - if (elem == nullptr) { - fprintf (stderr, "Warning: Can't find element'%s'\n", - elem_name); - return; - } - plyfile->which_elem = elem; - - /* deposit the property information into the element's description */ - for (i = 0; i < nprops; i++) { - - /* look for actual property */ - prop = find_property (elem, prop_list[i].name, &index); - if (prop == nullptr) { - fprintf (stderr, "Warning: Can't find property '%s' in element '%s'\n", - prop_list[i].name, elem_name); - continue; - } - - /* store its description */ - prop->internal_type = prop_list[i].internal_type; - prop->offset = prop_list[i].offset; - prop->count_internal = prop_list[i].count_internal; - prop->count_offset = prop_list[i].count_offset; - - /* specify that the user wants this property */ - elem->store_prop[index] = STORE_PROP; - } - } - - - /****************************************************************************** -Specify a property of an element that is to be returned. This should be -called (usually multiple times) before a call to the routine ply_get_element(). -This routine should be used in preference to the less flexible old routine -called ply_get_element_setup(). - -Entry: - plyfile - file identifier - elem_name - which element we're talking about - prop - property to add to those that will be returned - ******************************************************************************/ - - void ply_get_property( - PlyFile *plyfile, - char *elem_name, - PlyProperty *prop - ) - { - PlyElement *elem; - PlyProperty *prop_ptr; - int index; - - /* find information about the element */ - elem = find_element (plyfile, elem_name); - if (elem == nullptr) { - fprintf (stderr, "Warning: Can't find element '%s'\n", - elem_name); - return; - } - - plyfile->which_elem = elem; - - /* deposit the property information into the element's description */ - - prop_ptr = find_property (elem, prop->name, &index); - if (prop_ptr == NULL) { - fprintf (stderr, "Warning: Can't find property '%s' in element '%s'\n", - prop->name, elem_name); - return; - } - prop_ptr->internal_type = prop->internal_type; - prop_ptr->offset = prop->offset; - prop_ptr->count_internal = prop->count_internal; - prop_ptr->count_offset = prop->count_offset; - - /* specify that the user wants this property */ - elem->store_prop[index] = STORE_PROP; - } - - - /****************************************************************************** -Read one element from the file. This routine assumes that we're reading -the type of element specified in the last call to the routine -ply_get_element_setup(). - -Entry: - plyfile - file identifier - elem_ptr - pointer to location where the element information should be put - ******************************************************************************/ - - void ply_get_element(PlyFile *plyfile, void *elem_ptr) - { - if (plyfile->file_type == PLY_ASCII) - ascii_get_element (plyfile, (char *) elem_ptr); - else - binary_get_element (plyfile, (char *) elem_ptr); - } - - - /****************************************************************************** -Extract the comments from the header information of a PLY file. - -Entry: - plyfile - file identifier - -Exit: - num_comments - number of comments returned - returns a pointer to a list of comments - ******************************************************************************/ - - char **ply_get_comments(PlyFile *plyfile, int *num_comments) - { - *num_comments = plyfile->num_comments; - return (plyfile->comments); - } - - - /****************************************************************************** -Extract the object information (arbitrary text) from the header information -of a PLY file. - -Entry: - plyfile - file identifier - -Exit: - num_obj_info - number of lines of text information returned - returns a pointer to a list of object info lines - ******************************************************************************/ - - char **ply_get_obj_info(PlyFile *plyfile, int *num_obj_info) - { - *num_obj_info = plyfile->num_obj_info; - return (plyfile->obj_info); - } - - - /****************************************************************************** -Make ready for "other" properties of an element-- those properties that -the user has not explicitly asked for, but that are to be stashed away -in a special structure to be carried along with the element's other -information. - -Entry: - plyfile - file identifier - elem - element for which we want to save away other properties - ******************************************************************************/ - - void setup_other_props(PlyElement *elem) - { - int i; - PlyProperty *prop; - int size = 0; - int type_size; - - /* Examine each property in decreasing order of size. */ - /* We do this so that all data types will be aligned by */ - /* word, half-word, or whatever within the structure. */ - - for (type_size = 8; type_size > 0; type_size /= 2) { - - /* add up the space taken by each property, and save this information */ - /* away in the property descriptor */ - - for (i = 0; i < elem->nprops; i++) { - - /* don't bother with properties we've been asked to store explicitly */ - if (elem->store_prop[i]) - continue; - - prop = elem->props[i]; - - /* internal types will be same as external */ - prop->internal_type = prop->external_type; - prop->count_internal = prop->count_external; - - /* check list case */ - if (prop->is_list) { - - /* pointer to list */ - if (type_size == sizeof (void *)) { - prop->offset = size; - size += sizeof (void *); /* always use size of a pointer here */ - } - - /* count of number of list elements */ - if (type_size == ply_type_size[prop->count_external]) { - prop->count_offset = size; - size += ply_type_size[prop->count_external]; - } - } - /* not list */ - else if (type_size == ply_type_size[prop->external_type]) { - prop->offset = size; - size += ply_type_size[prop->external_type]; - } - } - - } - - /* save the size for the other_props structure */ - elem->other_size = size; - } - - - /****************************************************************************** -Specify that we want the "other" properties of an element to be tucked -away within the user's structure. The user needn't be concerned for how -these properties are stored. - -Entry: - plyfile - file identifier - elem_name - name of element that we want to store other_props in - offset - offset to where other_props will be stored inside user's structure - -Exit: - returns pointer to structure containing description of other_props - ******************************************************************************/ - - PlyOtherProp *ply_get_other_properties( - PlyFile *plyfile, - char *elem_name, - int offset - ) - { - int i; - PlyElement *elem; - PlyOtherProp *other; - PlyProperty *prop; - int nprops; - - /* find information about the element */ - elem = find_element (plyfile, elem_name); - if (elem == NULL) { - fprintf (stderr, "ply_get_other_properties: Can't find element '%s'\n", - elem_name); - return (NULL); - } - - /* remember that this is the "current" element */ - plyfile->which_elem = elem; - - /* save the offset to where to store the other_props */ - elem->other_offset = offset; - - /* place the appropriate pointers, etc. in the element's property list */ - setup_other_props (elem); - - /* create structure for describing other_props */ - other = (PlyOtherProp *) myalloc (sizeof (PlyOtherProp)); - other->name = strdup (elem_name); -#if 0 - if (elem->other_offset == NO_OTHER_PROPS) { - other->size = 0; - other->props = NULL; - other->nprops = 0; - return (other); - } -#endif - other->size = elem->other_size; - other->props = (PlyProperty **) myalloc (sizeof(PlyProperty) * elem->nprops); - - /* save descriptions of each "other" property */ - nprops = 0; - for (i = 0; i < elem->nprops; i++) { - if (elem->store_prop[i]) - continue; - prop = (PlyProperty *) myalloc (sizeof (PlyProperty)); - copy_property (prop, elem->props[i]); - other->props[nprops] = prop; - nprops++; - } - other->nprops = nprops; - -#if 1 - /* set other_offset pointer appropriately if there are NO other properties */ - if (other->nprops == 0) { - elem->other_offset = NO_OTHER_PROPS; - } -#endif - - /* return structure */ - return (other); - } - - - - - /*************************/ - /* Other Element Stuff */ - /*************************/ - - - - - /****************************************************************************** -Grab all the data for an element that a user does not want to explicitly -read in. - -Entry: - plyfile - pointer to file - elem_name - name of element whose data is to be read in - elem_count - number of instances of this element stored in the file - -Exit: - returns pointer to ALL the "other" element data for this PLY file - ******************************************************************************/ - - PlyOtherElems *ply_get_other_element ( - PlyFile *plyfile, - char *elem_name, - int elem_count - ) - { - int i; - PlyElement *elem; - PlyOtherElems *other_elems; - OtherElem *other; - - /* look for appropriate element */ - elem = find_element (plyfile, elem_name); - if (elem == NULL) { - fprintf (stderr, - "ply_get_other_element: can't find element '%s'\n", elem_name); - exit (-1); - } - - /* create room for the new "other" element, initializing the */ - /* other data structure if necessary */ - - if (plyfile->other_elems == NULL) { - plyfile->other_elems = (PlyOtherElems *) myalloc (sizeof (PlyOtherElems)); - other_elems = plyfile->other_elems; - other_elems->other_list = (OtherElem *) myalloc (sizeof (OtherElem)); - other = &(other_elems->other_list[0]); - other_elems->num_elems = 1; - } - else { - other_elems = plyfile->other_elems; - other_elems->other_list = (OtherElem *) realloc (other_elems->other_list, - sizeof (OtherElem) * other_elems->num_elems + 1); - if (other_elems->other_list == nullptr) { - fprintf(stderr, "ply_get_other_element: can't alloc memory for other_elems->other_list\n"); - exit(1); - } - other = &(other_elems->other_list[other_elems->num_elems]); - other_elems->num_elems++; - } - - /* count of element instances in file */ - other->elem_count = elem_count; - - /* save name of element */ - other->elem_name = strdup (elem_name); - - /* create a list to hold all the current elements */ - other->other_data = (OtherData **) - malloc (sizeof (OtherData *) * other->elem_count); - if (other->other_data == nullptr) { - fprintf(stderr, "ply_get_other_element: can't alloc memory for other->other_data\n"); - exit(1); - } - - /* set up for getting elements */ - other->other_props = ply_get_other_properties (plyfile, elem_name, - offsetof(OtherData,other_props)); - - /* grab all these elements */ - for (i = 0; i < other->elem_count; i++) { - /* grab and element from the file */ - other->other_data[i] = (OtherData *) malloc (sizeof (OtherData)); - ply_get_element (plyfile, (void *) other->other_data[i]); - } - - /* return pointer to the other elements data */ - return (other_elems); - } - - - /****************************************************************************** -Pass along a pointer to "other" elements that we want to save in a given -PLY file. These other elements were presumably read from another PLY file. - -Entry: - plyfile - file pointer in which to store this other element info - other_elems - info about other elements that we want to store - ******************************************************************************/ - - void ply_describe_other_elements ( - PlyFile *plyfile, - PlyOtherElems *other_elems - ) - { - int i; - OtherElem *other; - PlyElement *elem; - - /* ignore this call if there is no other element */ - if (other_elems == NULL) - return; - - /* save pointer to this information */ - plyfile->other_elems = other_elems; - - /* describe the other properties of this element */ - /* store them in the main element list as elements with - only other properties */ - - REALLOCN(plyfile->elems, PlyElement *, - plyfile->nelems, plyfile->nelems + other_elems->num_elems); - if (plyfile->elems == nullptr) { - fprintf (stderr, "ply_describe_other_elements: Can't alloc memory for plyfile->elems\n"); - return; - } - - for (i = 0; i < other_elems->num_elems; i++) { - other = &(other_elems->other_list[i]); - elem = (PlyElement *) myalloc (sizeof (PlyElement)); - plyfile->elems[plyfile->nelems++] = elem; - elem->name = strdup (other->elem_name); - elem->num = other->elem_count; - elem->nprops = 0; - ply_describe_other_properties (plyfile, other->other_props, - offsetof(OtherData,other_props)); - } - } - - - /****************************************************************************** -Write out the "other" elements specified for this PLY file. - -Entry: - plyfile - pointer to PLY file to write out other elements for - ******************************************************************************/ - - void ply_put_other_elements (PlyFile *plyfile) - { - int i,j; - OtherElem *other; - - /* make sure we have other elements to write */ - if (plyfile->other_elems == NULL) - return; - - /* write out the data for each "other" element */ - - for (i = 0; i < plyfile->other_elems->num_elems; i++) { - - other = &(plyfile->other_elems->other_list[i]); - ply_put_element_setup (plyfile, other->elem_name); - - /* write out each instance of the current element */ - for (j = 0; j < other->elem_count; j++) - ply_put_element (plyfile, (void *) other->other_data[j]); - } - } - - - /****************************************************************************** -Free up storage used by an "other" elements data structure. - -Entry: - other_elems - data structure to free up - ******************************************************************************/ - - void ply_free_other_elements (PlyOtherElems *other_elems) - { - other_elems = other_elems; - } - - - - /*******************/ - /* Miscellaneous */ - /*******************/ - - - - /****************************************************************************** -Close a PLY file. - -Entry: - plyfile - identifier of file to close - ******************************************************************************/ - - void ply_close(PlyFile *plyfile) - { - fclose (plyfile->fp); - - /* free up memory associated with the PLY file */ - free (plyfile); - } - - - /****************************************************************************** -Get version number and file type of a PlyFile. - -Entry: - ply - pointer to PLY file - -Exit: - version - version of the file - file_type - PLY_ASCII, PLY_BINARY_BE, or PLY_BINARY_LE - ******************************************************************************/ - - void ply_get_info(PlyFile *ply, float *version, int *file_type) - { - if (ply == NULL) - return; - - *version = ply->version; - *file_type = ply->file_type; - } - - - /****************************************************************************** -Compare two strings. Returns 1 if they are the same, 0 if not. - ******************************************************************************/ - - int equal_strings(const char *s1, const char *s2) - { - - while (*s1 && *s2) - if (*s1++ != *s2++) - return (0); - - if (*s1 != *s2) - return (0); - else - return (1); - } - - - /****************************************************************************** -Find an element from the element list of a given PLY object. - -Entry: - plyfile - file id for PLY file - element - name of element we're looking for - -Exit: - returns the element, or NULL if not found - ******************************************************************************/ - - PlyElement *find_element(PlyFile *plyfile, char *element) - { - int i; - - for (i = 0; i < plyfile->nelems; i++) - if (equal_strings (element, plyfile->elems[i]->name)) - return (plyfile->elems[i]); - - return (NULL); - } - - - /****************************************************************************** -Find a property in the list of properties of a given element. - -Entry: - elem - pointer to element in which we want to find the property - prop_name - name of property to find - -Exit: - index - index to position in list - returns a pointer to the property, or NULL if not found - ******************************************************************************/ - - PlyProperty *find_property(PlyElement *elem, char *prop_name, int *index) - { - int i; - - for (i = 0; i < elem->nprops; i++) - if (equal_strings (prop_name, elem->props[i]->name)) { - *index = i; - return (elem->props[i]); - } - - *index = -1; - return (NULL); - } - - - /****************************************************************************** -Read an element from an ascii file. - -Entry: - plyfile - file identifier - elem_ptr - pointer to element - ******************************************************************************/ - - void ascii_get_element(PlyFile *plyfile, char *elem_ptr) - { - int j,k; - PlyElement *elem; - PlyProperty *prop; - char **words; - int nwords; - int which_word; - char *elem_data,*item=NULL; - char *item_ptr; - int item_size; - int int_val; - unsigned int uint_val; - double double_val; - int list_count; - int store_it; - char **store_array; - char *orig_line; - char *other_data=NULL; - int other_flag; - - /* the kind of element we're reading currently */ - elem = plyfile->which_elem; - - /* do we need to setup for other_props? */ - - if (elem->other_offset != NO_OTHER_PROPS) { - char **ptr; - other_flag = 1; - /* make room for other_props */ - other_data = (char *) myalloc (elem->other_size); - /* store pointer in user's structure to the other_props */ - ptr = (char **) (elem_ptr + elem->other_offset); - *ptr = other_data; - } - else - other_flag = 0; - - /* read in the element */ - - words = get_words (plyfile->fp, &nwords, &orig_line); - if (words == NULL) { - fprintf (stderr, "ply_get_element: unexpected end of file\n"); - exit (-1); - } - - which_word = 0; - - for (j = 0; j < elem->nprops; j++) { - - prop = elem->props[j]; - store_it = (elem->store_prop[j] | other_flag); - - /* store either in the user's structure or in other_props */ - if (elem->store_prop[j]) - elem_data = elem_ptr; - else if(other_data) - elem_data = other_data; - else { - fprintf (stderr, "binary_get_element: trying to use unallocated other_data\n"); - exit (-1); - } - - if (prop->is_list) { /* a list */ - - /* get and store the number of items in the list */ - get_ascii_item (words[which_word++], prop->count_external, - &int_val, &uint_val, &double_val); - if (store_it) { - item = elem_data + prop->count_offset; - store_item(item, prop->count_internal, int_val, uint_val, double_val); - } - - /* allocate space for an array of items and store a ptr to the array */ - list_count = int_val; - item_size = ply_type_size[prop->internal_type]; - store_array = (char **) (elem_data + prop->offset); - - if (list_count == 0) { - if (store_it) - *store_array = NULL; - } - else { - if (store_it) { - item_ptr = (char *) myalloc (sizeof (char) * item_size * list_count); - item = item_ptr; - *store_array = item_ptr; - } - - /* read items and store them into the array */ - for (k = 0; k < list_count; k++) { - get_ascii_item (words[which_word++], prop->external_type, - &int_val, &uint_val, &double_val); - if (store_it) { - store_item (item, prop->internal_type, - int_val, uint_val, double_val); - item += item_size; - } - } - } - - } - else { /* not a list */ - get_ascii_item (words[which_word++], prop->external_type, - &int_val, &uint_val, &double_val); - if (store_it) { - item = elem_data + prop->offset; - store_item (item, prop->internal_type, int_val, uint_val, double_val); - } - } - - } - - free (words); - } - - - /****************************************************************************** -Read an element from a binary file. - -Entry: - plyfile - file identifier - elem_ptr - pointer to an element - ******************************************************************************/ - - void binary_get_element(PlyFile *plyfile, char *elem_ptr) - { - int j,k; - PlyElement *elem; - PlyProperty *prop; - FILE *fp = plyfile->fp; - char *elem_data,*item=NULL; - char *item_ptr; - int item_size; - int int_val; - unsigned int uint_val; - double double_val; - int list_count; - int store_it; - char **store_array; - char *other_data=NULL; - int other_flag; - - /* the kind of element we're reading currently */ - elem = plyfile->which_elem; - - /* do we need to setup for other_props? */ - - if (elem->other_offset != NO_OTHER_PROPS) { - other_flag = 1; - /* make room for other_props */ - other_data = (char *) myalloc (elem->other_size); - } - else - other_flag = 0; - - /* read in a number of elements */ - - for (j = 0; j < elem->nprops; j++) { - - prop = elem->props[j]; - store_it = (elem->store_prop[j] | other_flag); - - /* store either in the user's structure or in other_props */ - if (elem->store_prop[j]) - elem_data = elem_ptr; - else if(other_data) - elem_data = other_data; - else { - fprintf (stderr, "binary_get_element: trying to use unallocated other_data\n"); - exit (-1); - } - - if (prop->is_list) { /* a list */ - - /* get and store the number of items in the list */ - get_binary_item (fp, plyfile->file_type, prop->count_external, - &int_val, &uint_val, &double_val); - if (store_it) { - item = elem_data + prop->count_offset; - store_item(item, prop->count_internal, int_val, uint_val, double_val); - } - - /* allocate space for an array of items and store a ptr to the array */ - list_count = int_val; - item_size = ply_type_size[prop->internal_type]; - store_array = (char **) (elem_data + prop->offset); - if (list_count == 0) { - if (store_it) - *store_array = NULL; - } - else { - if (store_it) { - item_ptr = (char *) myalloc (sizeof (char) * item_size * list_count); - item = item_ptr; - *store_array = item_ptr; - } - - /* read items and store them into the array */ - for (k = 0; k < list_count; k++) { - get_binary_item (fp, plyfile->file_type, prop->external_type, - &int_val, &uint_val, &double_val); - if (store_it) { - store_item (item, prop->internal_type, - int_val, uint_val, double_val); - item += item_size; - } - } - } - - } - else { /* not a list */ - get_binary_item (fp, plyfile->file_type, prop->external_type, - &int_val, &uint_val, &double_val); - if (store_it) { - item = elem_data + prop->offset; - store_item (item, prop->internal_type, int_val, uint_val, double_val); - } - } - - } - } - - - /****************************************************************************** -Write to a file the word that represents a PLY data type. - -Entry: - fp - file pointer - code - code for type - ******************************************************************************/ - - void write_scalar_type (FILE *fp, int code) - { - /* make sure this is a valid code */ - - if (code <= PLY_START_TYPE || code >= PLY_END_TYPE) { - fprintf (stderr, "write_scalar_type: bad data code = %d\n", code); - exit (-1); - } - - /* write the code to a file */ - - fprintf (fp, "%s", type_names[code]); - } - - /****************************************************************************** - Reverse the order in an array of bytes. This is the conversion from big - endian to little endian and vice versa - -Entry: - bytes - array of bytes to reverse (in place) - num_bytes - number of bytes in array - ******************************************************************************/ - - void swap_bytes(char *bytes, int num_bytes) - { - int i; - char temp; - - for (i=0; i < num_bytes/2; i++) - { - temp = bytes[i]; - bytes[i] = bytes[(num_bytes-1)-i]; - bytes[(num_bytes-1)-i] = temp; - } - } - - /****************************************************************************** - Find out if this machine is big endian or little endian - - Exit: - set global variable, native_binary_type = - either PLY_BINARY_BE or PLY_BINARY_LE - - ******************************************************************************/ - - void get_native_binary_type() - { - endian_test_type test; - - test.int_value = 0; - test.int_value = 1; - if (test.byte_values[0] == 1) - native_binary_type = PLY_BINARY_LE; - else if (test.byte_values[sizeof(int)-1] == 1) - native_binary_type = PLY_BINARY_BE; - else - { - fprintf(stderr, "ply: Couldn't determine machine endianness.\n"); - fprintf(stderr, "ply: Exiting...\n"); - exit(1); - } - } - - /****************************************************************************** - Verify that all the native types are the sizes we need - - - ******************************************************************************/ - - void check_types() - { - if ((ply_type_size[PLY_CHAR] != sizeof(char)) || - (ply_type_size[PLY_SHORT] != sizeof(short)) || - (ply_type_size[PLY_INT] != sizeof(int)) || - (ply_type_size[PLY_UCHAR] != sizeof(unsigned char)) || - (ply_type_size[PLY_USHORT] != sizeof(unsigned short)) || - (ply_type_size[PLY_UINT] != sizeof(unsigned int)) || - (ply_type_size[PLY_FLOAT] != sizeof(float)) || - (ply_type_size[PLY_DOUBLE] != sizeof(double))) - { - fprintf(stderr, "ply: Type sizes do not match built-in types\n"); - fprintf(stderr, "ply: Exiting...\n"); - exit(1); - } - - types_checked = 1; - } - - /****************************************************************************** -Get a text line from a file and break it up into words. - -IMPORTANT: The calling routine call "free" on the returned pointer once -finished with it. - -Entry: - fp - file to read from - -Exit: - nwords - number of words returned - orig_line - the original line of characters - returns a list of words from the line, or NULL if end-of-file - ******************************************************************************/ - - char **get_words(FILE *fp, int *nwords, char **orig_line) - { -#define BIG_STRING 4096 - static char str[BIG_STRING]; - static char str_copy[BIG_STRING]; - char **words; - int max_words = 10; - int num_words = 0; - char *ptr,*ptr2; - char *result; - - words = (char **) myalloc (sizeof (char *) * max_words); - - /* read in a line */ - result = fgets (str, BIG_STRING, fp); - if (result == NULL) { - *nwords = 0; - *orig_line = NULL; - return (NULL); - } - - /* convert line-feed and tabs into spaces */ - /* (this guarentees that there will be a space before the */ - /* null character at the end of the string) */ - - str[BIG_STRING-2] = ' '; - str[BIG_STRING-1] = '\0'; - - for (ptr = str, ptr2 = str_copy; *ptr != '\0'; ptr++, ptr2++) { - *ptr2 = *ptr; - if (*ptr == '\t') { - *ptr = ' '; - *ptr2 = ' '; - } - else if (*ptr == '\n') { - *ptr = ' '; - *ptr2 = '\0'; - break; - } - } - - /* find the words in the line */ - - ptr = str; - while (*ptr != '\0') { - - /* jump over leading spaces */ - while (*ptr == ' ') - ptr++; - - /* break if we reach the end */ - if (*ptr == '\0') - break; - - /* save pointer to beginning of word */ - if (num_words >= max_words) { - max_words += 10; - words = (char **) realloc (words, sizeof (char *) * max_words); - if (words == nullptr) { - fprintf(stderr, "get_words: can't alloc memory for words\n"); - exit(1); - } - } - words[num_words++] = ptr; - - /* jump over non-spaces */ - while (*ptr != ' ') - ptr++; - - /* place a null character here to mark the end of the word */ - *ptr++ = '\0'; - } - - /* return the list of words */ - *nwords = num_words; - *orig_line = str_copy; - return (words); - } - - - /****************************************************************************** -Return the value of an item, given a pointer to it and its type. - -Entry: - item - pointer to item - type - data type that "item" points to - -Exit: - returns a double-precision float that contains the value of the item - ******************************************************************************/ - - double get_item_value(char *item, int type) - { - unsigned char *puchar; - char *pchar; - short int *pshort; - unsigned short int *pushort; - int *pint; - unsigned int *puint; - float *pfloat; - double *pdouble; - int int_value; - unsigned int uint_value; - double double_value; - - switch (type) { - case PLY_CHAR: - pchar = (char *) item; - int_value = *pchar; - return ((double) int_value); - case PLY_UCHAR: - puchar = (unsigned char *) item; - int_value = *puchar; - return ((double) int_value); - case PLY_SHORT: - pshort = (short int *) item; - int_value = *pshort; - return ((double) int_value); - case PLY_USHORT: - pushort = (unsigned short int *) item; - int_value = *pushort; - return ((double) int_value); - case PLY_INT: - pint = (int *) item; - int_value = *pint; - return ((double) int_value); - case PLY_UINT: - puint = (unsigned int *) item; - uint_value = *puint; - return ((double) uint_value); - case PLY_FLOAT: - pfloat = (float *) item; - double_value = *pfloat; - return (double_value); - case PLY_DOUBLE: - pdouble = (double *) item; - double_value = *pdouble; - return (double_value); - default: - fprintf (stderr, "get_item_value: bad type = %d\n", type); - exit (-1); - } - } - - - /****************************************************************************** -Write out an item to a file as raw binary bytes. - -Entry: - fp - file to write to - int_val - integer version of item - uint_val - unsigned integer version of item - double_val - double-precision float version of item - type - data type to write out - ******************************************************************************/ - - void write_binary_item( - FILE *fp, - int file_type, - int int_val, - unsigned int uint_val, - double double_val, - int type - ) - { - unsigned char uchar_val; - char char_val; - unsigned short ushort_val; - short short_val; - float float_val; - void *value; - - switch (type) { - case PLY_CHAR: - char_val = int_val; - value = &char_val; - break; - case PLY_SHORT: - short_val = int_val; - value = &short_val; - break; - case PLY_INT: - value = &int_val; - break; - case PLY_UCHAR: - uchar_val = uint_val; - value = &uchar_val; - break; - case PLY_USHORT: - ushort_val = uint_val; - value = &ushort_val; - break; - case PLY_UINT: - value = &uint_val; - break; - case PLY_FLOAT: - float_val = (float)double_val; - value = &float_val; - break; - case PLY_DOUBLE: - value = &double_val; - break; - default: - fprintf (stderr, "write_binary_item: bad type = %d\n", type); - exit (-1); - } - - if ((file_type != native_binary_type) && (ply_type_size[type] > 1)) - swap_bytes((char *)value, ply_type_size[type]); - - if (fwrite (value, ply_type_size[type], 1, fp) != 1) - { - fprintf(stderr, "PLY ERROR: fwrite() failed -- aborting.\n"); - exit(1); - } - } - - - /****************************************************************************** -Write out an item to a file as ascii characters. - -Entry: - fp - file to write to - int_val - integer version of item - uint_val - unsigned integer version of item - double_val - double-precision float version of item - type - data type to write out - ******************************************************************************/ - - void write_ascii_item( - FILE *fp, - int int_val, - unsigned int uint_val, - double double_val, - int type - ) - { - switch (type) { - case PLY_CHAR: - case PLY_SHORT: - case PLY_INT: - if (fprintf (fp, "%d ", int_val) <= 0) - { - fprintf(stderr, "PLY ERROR: fprintf() failed -- aborting.\n"); - exit(1); - } - break; - case PLY_UCHAR: - case PLY_USHORT: - case PLY_UINT: - if (fprintf (fp, "%u ", uint_val) <= 0) - { - fprintf(stderr, "PLY ERROR: fprintf() failed -- aborting.\n"); - exit(1); - } - break; - case PLY_FLOAT: - case PLY_DOUBLE: - if (fprintf (fp, "%g ", double_val) <= 0) - { - fprintf(stderr, "PLY ERROR: fprintf() failed -- aborting.\n"); - exit(1); - } - break; - default: - fprintf (stderr, "write_ascii_item: bad type = %d\n", type); - exit (-1); - } - } - - - /****************************************************************************** -Write out an item to a file as ascii characters. - -Entry: - fp - file to write to - item - pointer to item to write - type - data type that "item" points to - -Exit: - returns a double-precision float that contains the value of the written item - ******************************************************************************/ - - double old_write_ascii_item(FILE *fp, char *item, int type) - { - unsigned char *puchar; - char *pchar; - short int *pshort; - unsigned short int *pushort; - int *pint; - unsigned int *puint; - float *pfloat; - double *pdouble; - int int_value; - unsigned int uint_value; - double double_value; - - switch (type) { - case PLY_CHAR: - pchar = (char *) item; - int_value = *pchar; - fprintf (fp, "%d ", int_value); - return ((double) int_value); - case PLY_UCHAR: - puchar = (unsigned char *) item; - int_value = *puchar; - fprintf (fp, "%d ", int_value); - return ((double) int_value); - case PLY_SHORT: - pshort = (short int *) item; - int_value = *pshort; - fprintf (fp, "%d ", int_value); - return ((double) int_value); - case PLY_USHORT: - pushort = (unsigned short int *) item; - int_value = *pushort; - fprintf (fp, "%d ", int_value); - return ((double) int_value); - case PLY_INT: - pint = (int *) item; - int_value = *pint; - fprintf (fp, "%d ", int_value); - return ((double) int_value); - case PLY_UINT: - puint = (unsigned int *) item; - uint_value = *puint; - fprintf (fp, "%u ", uint_value); - return ((double) uint_value); - case PLY_FLOAT: - pfloat = (float *) item; - double_value = *pfloat; - fprintf (fp, "%g ", double_value); - return (double_value); - case PLY_DOUBLE: - pdouble = (double *) item; - double_value = *pdouble; - fprintf (fp, "%g ", double_value); - return (double_value); - default: - fprintf (stderr, "old_write_ascii_item: bad type = %d\n", type); - exit (-1); - } - } - - - /****************************************************************************** -Get the value of an item that is in memory, and place the result -into an integer, an unsigned integer and a double. - -Entry: - ptr - pointer to the item - type - data type supposedly in the item - -Exit: - int_val - integer value - uint_val - unsigned integer value - double_val - double-precision floating point value - ******************************************************************************/ - - void get_stored_item( - void *ptr, - int type, - int *int_val, - unsigned int *uint_val, - double *double_val - ) - { - switch (type) { - case PLY_CHAR: - *int_val = *((char *) ptr); - *uint_val = *int_val; - *double_val = *int_val; - break; - case PLY_UCHAR: - *uint_val = *((unsigned char *) ptr); - *int_val = *uint_val; - *double_val = *uint_val; - break; - case PLY_SHORT: - *int_val = *((short int *) ptr); - *uint_val = *int_val; - *double_val = *int_val; - break; - case PLY_USHORT: - *uint_val = *((unsigned short int *) ptr); - *int_val = *uint_val; - *double_val = *uint_val; - break; - case PLY_INT: - *int_val = *((int *) ptr); - *uint_val = *int_val; - *double_val = *int_val; - break; - case PLY_UINT: - *uint_val = *((unsigned int *) ptr); - *int_val = *uint_val; - *double_val = *uint_val; - break; - case PLY_FLOAT: - *double_val = *((float *) ptr); - *int_val = (int) *double_val; - *uint_val = (unsigned int) *double_val; - break; - case PLY_DOUBLE: - *double_val = *((double *) ptr); - *int_val = (int) *double_val; - *uint_val = (unsigned int) *double_val; - break; - default: - fprintf (stderr, "get_stored_item: bad type = %d\n", type); - exit (-1); - } - } - - - /****************************************************************************** -Get the value of an item from a binary file, and place the result -into an integer, an unsigned integer and a double. - -Entry: - fp - file to get item from - type - data type supposedly in the word - -Exit: - int_val - integer value - uint_val - unsigned integer value - double_val - double-precision floating point value - ******************************************************************************/ - - void get_binary_item( - FILE *fp, - int file_type, - int type, - int *int_val, - unsigned int *uint_val, - double *double_val - ) - { - char c[8]; - void *ptr; - - ptr = (void *) c; - - if (fread (ptr, ply_type_size[type], 1, fp) != 1) - { - fprintf(stderr, "PLY ERROR: fread() failed -- aborting.\n"); - exit(1); - } - - - if ((file_type != native_binary_type) && (ply_type_size[type] > 1)) - swap_bytes((char *)ptr, ply_type_size[type]); - - switch (type) { - case PLY_CHAR: - *int_val = *((char *) ptr); - *uint_val = *int_val; - *double_val = *int_val; - break; - case PLY_UCHAR: - *uint_val = *((unsigned char *) ptr); - *int_val = *uint_val; - *double_val = *uint_val; - break; - case PLY_SHORT: - *int_val = *((short int *) ptr); - *uint_val = *int_val; - *double_val = *int_val; - break; - case PLY_USHORT: - *uint_val = *((unsigned short int *) ptr); - *int_val = *uint_val; - *double_val = *uint_val; - break; - case PLY_INT: - *int_val = *((int *) ptr); - *uint_val = *int_val; - *double_val = *int_val; - break; - case PLY_UINT: - *uint_val = *((unsigned int *) ptr); - *int_val = *uint_val; - *double_val = *uint_val; - break; - case PLY_FLOAT: - *double_val = *((float *) ptr); - *int_val = (int) *double_val; - *uint_val = (unsigned int) *double_val; - break; - case PLY_DOUBLE: - *double_val = *((double *) ptr); - *int_val = (int) *double_val; - *uint_val = (unsigned int) *double_val; - break; - default: - fprintf (stderr, "get_binary_item: bad type = %d\n", type); - exit (-1); - } - } - - - /****************************************************************************** -Extract the value of an item from an ascii word, and place the result -into an integer, an unsigned integer and a double. - -Entry: - word - word to extract value from - type - data type supposedly in the word - -Exit: - int_val - integer value - uint_val - unsigned integer value - double_val - double-precision floating point value - ******************************************************************************/ - - void get_ascii_item( - char *word, - int type, - int *int_val, - unsigned int *uint_val, - double *double_val - ) - { - switch (type) { - case PLY_CHAR: - case PLY_UCHAR: - case PLY_SHORT: - case PLY_USHORT: - case PLY_INT: - *int_val = atoi (word); - *uint_val = (unsigned int) *int_val; - *double_val = (double) *int_val; - break; - - case PLY_UINT: - *uint_val = strtol (word, (char **) NULL, 10); - *int_val = (int) *uint_val; - *double_val = (double) *uint_val; - break; - - case PLY_FLOAT: - case PLY_DOUBLE: - *double_val = atof (word); - *int_val = (int) *double_val; - *uint_val = (unsigned int) *double_val; - break; - - default: - fprintf (stderr, "get_ascii_item: bad type = %d\n", type); - exit (-1); - } - } - - - /****************************************************************************** -Store a value into a place being pointed to, guided by a data type. - -Entry: - item - place to store value - type - data type - int_val - integer version of value - uint_val - unsigned integer version of value - double_val - double version of value - -Exit: - item - pointer to stored value - ******************************************************************************/ - - void store_item ( - char *item, - int type, - int int_val, - unsigned int uint_val, - double double_val - ) - { - unsigned char *puchar; - short int *pshort; - unsigned short int *pushort; - int *pint; - unsigned int *puint; - float *pfloat; - double *pdouble; - - switch (type) { - case PLY_CHAR: - *item = int_val; - break; - case PLY_UCHAR: - puchar = (unsigned char *) item; - *puchar = uint_val; - break; - case PLY_SHORT: - pshort = (short *) item; - *pshort = int_val; - break; - case PLY_USHORT: - pushort = (unsigned short *) item; - *pushort = uint_val; - break; - case PLY_INT: - pint = (int *) item; - *pint = int_val; - break; - case PLY_UINT: - puint = (unsigned int *) item; - *puint = uint_val; - break; - case PLY_FLOAT: - pfloat = (float *) item; - *pfloat = (float)double_val; - break; - case PLY_DOUBLE: - pdouble = (double *) item; - *pdouble = double_val; - break; - default: - fprintf (stderr, "store_item: bad type = %d\n", type); - exit (-1); - } - } - - - /****************************************************************************** -Add an element to a PLY file descriptor. - -Entry: - plyfile - PLY file descriptor - words - list of words describing the element - nwords - number of words in the list - ******************************************************************************/ - - void add_element (PlyFile *plyfile, char **words) - { - PlyElement *elem; - - /* create the new element */ - elem = (PlyElement *) myalloc (sizeof (PlyElement)); - elem->name = strdup (words[1]); - elem->num = atoi (words[2]); - elem->nprops = 0; - - /* make room for new element in the object's list of elements */ - if (plyfile->nelems == 0) - plyfile->elems = (PlyElement **) myalloc (sizeof (PlyElement *)); - else - plyfile->elems = (PlyElement **) realloc (plyfile->elems, - sizeof (PlyElement *) * (plyfile->nelems + 1)); - if (plyfile->elems == nullptr) { - fprintf(stderr,"add_element: can't alloc memory for plyfile->elemens\n"); - exit (-1); - } - - /* add the new element to the object's list */ - plyfile->elems[plyfile->nelems] = elem; - plyfile->nelems++; - } - - - /****************************************************************************** -Return the type of a property, given the name of the property. - -Entry: - name - name of property type - -Exit: - returns integer code for property, or 0 if not found - ******************************************************************************/ - - int get_prop_type(char *type_name) - { - int i; - - for (i = PLY_START_TYPE + 1; i < PLY_END_TYPE; i++) { -#if 1 - if (equal_strings (type_name,"float32")) { - //printf - sprintf(type_name,"float"); - } - if (equal_strings (type_name,"int32")) { - //printf - sprintf(type_name,"int"); - } - if (equal_strings (type_name,"uint8")) { - //printf - sprintf(type_name,"uchar"); - } -#endif - if (equal_strings (type_name, type_names[i])) - return (i); - } - - /* if we get here, we didn't find the type */ - return (0); - } - - - /****************************************************************************** -Add a property to a PLY file descriptor. - -Entry: - plyfile - PLY file descriptor - words - list of words describing the property - nwords - number of words in the list - ******************************************************************************/ - - void add_property (PlyFile *plyfile, char **words) - { - PlyProperty *prop; - PlyElement *elem; - - /* create the new property */ - - prop = (PlyProperty *) myalloc (sizeof (PlyProperty)); - - if (equal_strings (words[1], "list")) { /* is a list */ - prop->count_external = get_prop_type (words[2]); - prop->external_type = get_prop_type (words[3]); - prop->name = strdup (words[4]); - prop->is_list = 1; - } - else { /* not a list */ - prop->external_type = get_prop_type (words[1]); - prop->name = strdup (words[2]); - prop->is_list = 0; - } - - /* add this property to the list of properties of the current element */ - - elem = plyfile->elems[plyfile->nelems - 1]; - - if (elem->nprops == 0) - elem->props = (PlyProperty **) myalloc (sizeof (PlyProperty *)); - else - elem->props = (PlyProperty **) realloc (elem->props, - sizeof (PlyProperty *) * (elem->nprops + 1)); - if(elem->props == nullptr) { - fprintf(stderr, "add_property: can't alloc memory for elem->props\n"); - exit(1); - } - elem->props[elem->nprops] = prop; - elem->nprops++; - } - - - /****************************************************************************** -Add a comment to a PLY file descriptor. - -Entry: - plyfile - PLY file descriptor - line - line containing comment - ******************************************************************************/ - - void add_comment (PlyFile *plyfile, char *line) - { - int i; - - /* skip over "comment" and leading spaces and tabs */ - i = 7; - while (line[i] == ' ' || line[i] == '\t') - i++; - - ply_put_comment (plyfile, &line[i]); - } - - - /****************************************************************************** -Add a some object information to a PLY file descriptor. - -Entry: - plyfile - PLY file descriptor - line - line containing text info - ******************************************************************************/ - - void add_obj_info (PlyFile *plyfile, char *line) - { - int i; - - /* skip over "obj_info" and leading spaces and tabs */ - i = 8; - while (line[i] == ' ' || line[i] == '\t') - i++; - - ply_put_obj_info (plyfile, &line[i]); - } - - - /****************************************************************************** -Copy a property. - ******************************************************************************/ - - void copy_property(PlyProperty *dest, PlyProperty *src) - { - dest->name = strdup (src->name); - dest->external_type = src->external_type; - dest->internal_type = src->internal_type; - dest->offset = src->offset; - - dest->is_list = src->is_list; - dest->count_external = src->count_external; - dest->count_internal = src->count_internal; - dest->count_offset = src->count_offset; - } - - - /****************************************************************************** -Allocate some memory. - -Entry: - size - amount of memory requested (in bytes) - lnum - line number from which memory was requested - fname - file name from which memory was requested - ******************************************************************************/ - - void *my_alloc(int size, int lnum, const char *fname) - { - char *ptr; - - ptr = (char *) malloc (size); - - if (ptr == 0) { - fprintf(stderr, "Memory allocation bombed on line %d in %s\n", lnum, fname); - } - - return (ptr); - } -} - -#pragma clang diagnostic pop diff --git a/extern/ply/ply.h b/extern/ply/ply.h deleted file mode 100644 index 0ba7aef..0000000 --- a/extern/ply/ply.h +++ /dev/null @@ -1,209 +0,0 @@ -/* - -Header for PLY polygon files. - -- Greg Turk, March 1994 - -A PLY file contains a single polygonal _object_. - -An object is composed of lists of _elements_. Typical elements are -vertices, faces, edges and materials. - -Each type of element for a given object has one or more _properties_ -associated with the element type. For instance, a vertex element may -have as properties three floating-point values x,y,z and three unsigned -chars for red, green and blue. - ---------------------------------------------------------------- - -Copyright (c) 1994 The Board of Trustees of The Leland Stanford -Junior University. All rights reserved. - -Permission to use, copy, modify and distribute this software and its -documentation for any purpose is hereby granted without fee, provided -that the above copyright notice and this permission notice appear in -all copies of this software and that you do not sell the software. - -THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND, -EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - -*/ - -#ifndef __PLY_H__ -#define __PLY_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include - -#define PLY_ASCII 1 /* ascii PLY file */ -#define PLY_BINARY_BE 2 /* binary PLY file, big endian */ -#define PLY_BINARY_LE 3 /* binary PLY file, little endian */ -#define PLY_BINARY_NATIVE 4 /* binary PLY file, same endianness as - current architecture */ - -#define PLY_OKAY 0 /* ply routine worked okay */ -#define PLY_ERROR -1 /* error in ply routine */ - -/* scalar data types supported by PLY format */ - -#define PLY_START_TYPE 0 -#define PLY_CHAR 1 -#define PLY_SHORT 2 -#define PLY_INT 3 -#define PLY_UCHAR 4 -#define PLY_USHORT 5 -#define PLY_UINT 6 -#define PLY_FLOAT 7 -#define PLY_DOUBLE 8 -#define PLY_END_TYPE 9 - -#define PLY_SCALAR 0 -#define PLY_LIST 1 - - -typedef struct PlyProperty { /* description of a property */ - - char *name; /* property name */ - int external_type; /* file's data type */ - int internal_type; /* program's data type */ - int offset; /* offset bytes of prop in a struct */ - - int is_list; /* 1 = list, 0 = scalar */ - int count_external; /* file's count type */ - int count_internal; /* program's count type */ - int count_offset; /* offset byte for list count */ - -} PlyProperty; - -typedef struct PlyElement { /* description of an element */ - char *name; /* element name */ - int num; /* number of elements in this object */ - int size; /* size of element (bytes) or -1 if variable */ - int nprops; /* number of properties for this element */ - PlyProperty **props; /* list of properties in the file */ - char *store_prop; /* flags: property wanted by user? */ - int other_offset; /* offset to un-asked-for props, or -1 if none*/ - int other_size; /* size of other_props structure */ -} -PlyElement; - -typedef struct PlyOtherProp { /* describes other properties in an element */ - char *name; /* element name */ - int size; /* size of other_props */ - int nprops; /* number of properties in other_props */ - PlyProperty **props; /* list of properties in other_props */ -} PlyOtherProp; - -typedef struct OtherData { /* for storing other_props for an other element */ - void *other_props; -} OtherData; - -typedef struct OtherElem { /* data for one "other" element */ - char *elem_name; /* names of other elements */ - int elem_count; /* count of instances of each element */ - OtherData **other_data; /* actual property data for the elements */ - PlyOtherProp *other_props; /* description of the property data */ -} OtherElem; - -typedef struct PlyOtherElems { /* "other" elements, not interpreted by user */ - int num_elems; /* number of other elements */ - OtherElem *other_list; /* list of data for other elements */ -} PlyOtherElems; - -typedef struct PlyFile { /* description of PLY file */ - FILE *fp; /* file pointer */ - int file_type; /* ascii or binary */ - float version; /* version number of file */ - int nelems; /* number of elements of object */ - PlyElement **elems; /* list of elements */ - int num_comments; /* number of comments */ - char **comments; /* list of comments */ - int num_obj_info; /* number of items of object information */ - char **obj_info; /* list of object info items */ - PlyElement *which_elem; /* which element we're currently writing */ - PlyOtherElems *other_elems; /* "other" elements from a PLY file */ -} PlyFile; - -/* memory allocation */ -extern void *my_alloc(int,int,const char *); -#define myalloc(mem_size) my_alloc((mem_size), __LINE__, __FILE__) - -#ifndef ALLOCN -#define REALLOCN(PTR,TYPE,OLD_N,NEW_N) \ - { \ - if ((OLD_N) == 0) \ - { ALLOCN((PTR),TYPE,(NEW_N));} \ - else \ - { \ - (PTR) = (TYPE *)realloc((PTR),(NEW_N)*sizeof(TYPE)); \ - if (((PTR) == NULL) && ((NEW_N) != 0)) \ - { \ - fprintf(stderr, "Memory reallocation failed on line %d in %s\n", \ - __LINE__, __FILE__); \ - fprintf(stderr, " tried to reallocate %d->%d\n", \ - (OLD_N), (NEW_N)); \ - exit(-1); \ - } \ - if ((NEW_N)>(OLD_N)) \ - memset((char *)(PTR)+(OLD_N)*sizeof(TYPE), 0, \ - ((NEW_N)-(OLD_N))*sizeof(TYPE)); \ - } \ - } - -#define ALLOCN(PTR,TYPE,N) \ - { (PTR) = (TYPE *) calloc(((unsigned)(N)),sizeof(TYPE));\ - if ((PTR) == NULL) { \ - fprintf(stderr, "Memory allocation failed on line %d in %s\n", \ - __LINE__, __FILE__); \ - exit(-1); \ - } \ - } - - -#define FREE(PTR) { free((PTR)); (PTR) = NULL; } -#endif - - -/*** delcaration of routines ***/ - -extern PlyFile *ply_write(FILE *, int, char **, int); -extern PlyFile *ply_open_for_writing(char *, int, char **, int, float *); -extern void ply_describe_element(PlyFile *, char *, int, int, PlyProperty *); -extern void ply_describe_property(PlyFile *, char *, PlyProperty *); -extern void ply_element_count(PlyFile *, char *, int); -extern void ply_header_complete(PlyFile *); -extern void ply_put_element_setup(PlyFile *, char *); -extern void ply_put_element(PlyFile *, void *); -extern void ply_put_comment(PlyFile *, char *); -extern void ply_put_obj_info(PlyFile *, char *); -extern PlyFile *ply_read(FILE *, int *, char ***); -extern PlyFile *ply_open_for_reading( char *, int *, char ***, int *, float *); -extern PlyProperty **ply_get_element_description(PlyFile *, char *, int*, int*); -extern void ply_get_element_setup( PlyFile *, char *, int, PlyProperty *); -extern void ply_get_property(PlyFile *, char *, PlyProperty *); -extern PlyOtherProp *ply_get_other_properties(PlyFile *, char *, int); -extern void ply_get_element(PlyFile *, void *); -extern char **ply_get_comments(PlyFile *, int *); -extern char **ply_get_obj_info(PlyFile *, int *); -extern void ply_close(PlyFile *); -extern void ply_get_info(PlyFile *, float *, int *); -extern PlyOtherElems *ply_get_other_element (PlyFile *, char *, int); -extern void ply_describe_other_elements ( PlyFile *, PlyOtherElems *); -extern void ply_put_other_elements (PlyFile *); -extern void ply_free_other_elements (PlyOtherElems *); -extern void ply_describe_other_properties(PlyFile *, PlyOtherProp *, int); - -extern int equal_strings(const char *, const char *); - -#ifdef __cplusplus -} -#endif -#endif /* !__PLY_H__ */ - diff --git a/extern/stbi/stb_image.h b/extern/stbi/stb_image.h deleted file mode 100644 index 2857f05..0000000 --- a/extern/stbi/stb_image.h +++ /dev/null @@ -1,7656 +0,0 @@ -/* stb_image - v2.25 - public domain image loader - http://nothings.org/stb - no warranty implied; use at your own risk - - Do this: - #define STB_IMAGE_IMPLEMENTATION - before you include this file in *one* C or C++ file to create the implementation. - - // i.e. it should look like this: - #include ... - #include ... - #include ... - #define STB_IMAGE_IMPLEMENTATION - #include "stb_image.h" - - You can #define STBI_ASSERT(x) before the #include to avoid using assert.h. - And #define STBI_MALLOC, STBI_REALLOC, and STBI_FREE to avoid using malloc,realloc,free - - - QUICK NOTES: - Primarily of interest to game developers and other people who can - avoid problematic images and only need the trivial interface - - JPEG baseline & progressive (12 bpc/arithmetic not supported, same as stock IJG lib) - PNG 1/2/4/8/16-bit-per-channel - - TGA (not sure what subset, if a subset) - BMP non-1bpp, non-RLE - PSD (composited view only, no extra channels, 8/16 bit-per-channel) - - GIF (*comp always reports as 4-channel) - HDR (radiance rgbE format) - PIC (Softimage PIC) - PNM (PPM and PGM binary only) - - Animated GIF still needs a proper API, but here's one way to do it: - http://gist.github.com/urraka/685d9a6340b26b830d49 - - - decode from memory or through FILE (define STBI_NO_STDIO to remove code) - - decode from arbitrary I/O callbacks - - SIMD acceleration on x86/x64 (SSE2) and ARM (NEON) - - Full documentation under "DOCUMENTATION" below. - - -LICENSE - - See end of file for license information. - -RECENT REVISION HISTORY: - - 2.25 (2020-02-02) fix warnings - 2.24 (2020-02-02) fix warnings; thread-local failure_reason and flip_vertically - 2.23 (2019-08-11) fix clang static analysis warning - 2.22 (2019-03-04) gif fixes, fix warnings - 2.21 (2019-02-25) fix typo in comment - 2.20 (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs - 2.19 (2018-02-11) fix warning - 2.18 (2018-01-30) fix warnings - 2.17 (2018-01-29) bugfix, 1-bit BMP, 16-bitness query, fix warnings - 2.16 (2017-07-23) all functions have 16-bit variants; optimizations; bugfixes - 2.15 (2017-03-18) fix png-1,2,4; all Imagenet JPGs; no runtime SSE detection on GCC - 2.14 (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for Imagenet JPGs - 2.13 (2016-12-04) experimental 16-bit API, only for PNG so far; fixes - 2.12 (2016-04-02) fix typo in 2.11 PSD fix that caused crashes - 2.11 (2016-04-02) 16-bit PNGS; enable SSE2 in non-gcc x64 - RGB-format JPEG; remove white matting in PSD; - allocate large structures on the stack; - correct channel count for PNG & BMP - 2.10 (2016-01-22) avoid warning introduced in 2.09 - 2.09 (2016-01-16) 16-bit TGA; comments in PNM files; STBI_REALLOC_SIZED - - See end of file for full revision history. - - - ============================ Contributors ========================= - - Image formats Extensions, features - Sean Barrett (jpeg, png, bmp) Jetro Lauha (stbi_info) - Nicolas Schulz (hdr, psd) Martin "SpartanJ" Golini (stbi_info) - Jonathan Dummer (tga) James "moose2000" Brown (iPhone PNG) - Jean-Marc Lienher (gif) Ben "Disch" Wenger (io callbacks) - Tom Seddon (pic) Omar Cornut (1/2/4-bit PNG) - Thatcher Ulrich (psd) Nicolas Guillemot (vertical flip) - Ken Miller (pgm, ppm) Richard Mitton (16-bit PSD) - github:urraka (animated gif) Junggon Kim (PNM comments) - Christopher Forseth (animated gif) Daniel Gibson (16-bit TGA) - socks-the-fox (16-bit PNG) - Jeremy Sawicki (handle all ImageNet JPGs) - Optimizations & bugfixes Mikhail Morozov (1-bit BMP) - Fabian "ryg" Giesen Anael Seghezzi (is-16-bit query) - Arseny Kapoulkine - John-Mark Allen - Carmelo J Fdez-Aguera - - Bug & warning fixes - Marc LeBlanc David Woo Guillaume George Martins Mozeiko - Christpher Lloyd Jerry Jansson Joseph Thomson Phil Jordan - Dave Moore Roy Eltham Hayaki Saito Nathan Reed - Won Chun Luke Graham Johan Duparc Nick Verigakis - the Horde3D community Thomas Ruf Ronny Chevalier github:rlyeh - Janez Zemva John Bartholomew Michal Cichon github:romigrou - Jonathan Blow Ken Hamada Tero Hanninen github:svdijk - Laurent Gomila Cort Stratton Sergio Gonzalez github:snagar - Aruelien Pocheville Thibault Reuille Cass Everitt github:Zelex - Ryamond Barbiero Paul Du Bois Engin Manap github:grim210 - Aldo Culquicondor Philipp Wiesemann Dale Weiler github:sammyhw - Oriol Ferrer Mesia Josh Tobin Matthew Gregan github:phprus - Julian Raschke Gregory Mullen Baldur Karlsson github:poppolopoppo - Christian Floisand Kevin Schmidt JR Smith github:darealshinji - Brad Weinberger Matvey Cherevko github:Michaelangel007 - Blazej Dariusz Roszkowski Alexander Veselov -*/ - -#ifndef STBI_INCLUDE_STB_IMAGE_H -#define STBI_INCLUDE_STB_IMAGE_H - -// DOCUMENTATION -// -// Limitations: -// - no 12-bit-per-channel JPEG -// - no JPEGs with arithmetic coding -// - GIF always returns *comp=4 -// -// Basic usage (see HDR discussion below for HDR usage): -// int x,y,n; -// unsigned char *data = stbi_load(filename, &x, &y, &n, 0); -// // ... process data if not NULL ... -// // ... x = width, y = height, n = # 8-bit components per pixel ... -// // ... replace '0' with '1'..'4' to force that many components per pixel -// // ... but 'n' will always be the number that it would have been if you said 0 -// stbi_image_free(data) -// -// Standard parameters: -// int *x -- outputs image width in pixels -// int *y -- outputs image height in pixels -// int *channels_in_file -- outputs # of image components in image file -// int desired_channels -- if non-zero, # of image components requested in result -// -// The return value from an image loader is an 'unsigned char *' which points -// to the pixel data, or NULL on an allocation failure or if the image is -// corrupt or invalid. The pixel data consists of *y scanlines of *x pixels, -// with each pixel consisting of N interleaved 8-bit components; the first -// pixel pointed to is top-left-most in the image. There is no padding between -// image scanlines or between pixels, regardless of format. The number of -// components N is 'desired_channels' if desired_channels is non-zero, or -// *channels_in_file otherwise. If desired_channels is non-zero, -// *channels_in_file has the number of components that _would_ have been -// output otherwise. E.g. if you set desired_channels to 4, you will always -// get RGBA output, but you can check *channels_in_file to see if it's trivially -// opaque because e.g. there were only 3 channels in the source image. -// -// An output image with N components has the following components interleaved -// in this order in each pixel: -// -// N=#comp components -// 1 grey -// 2 grey, alpha -// 3 red, green, blue -// 4 red, green, blue, alpha -// -// If image loading fails for any reason, the return value will be NULL, -// and *x, *y, *channels_in_file will be unchanged. The function -// stbi_failure_reason() can be queried for an extremely brief, end-user -// unfriendly explanation of why the load failed. Define STBI_NO_FAILURE_STRINGS -// to avoid compiling these strings at all, and STBI_FAILURE_USERMSG to get slightly -// more user-friendly ones. -// -// Paletted PNG, BMP, GIF, and PIC images are automatically depalettized. -// -// =========================================================================== -// -// UNICODE: -// -// If compiling for Windows and you wish to use Unicode filenames, compile -// with -// #define STBI_WINDOWS_UTF8 -// and pass utf8-encoded filenames. Call stbi_convert_wchar_to_utf8 to convert -// Windows wchar_t filenames to utf8. -// -// =========================================================================== -// -// Philosophy -// -// stb libraries are designed with the following priorities: -// -// 1. easy to use -// 2. easy to maintain -// 3. good performance -// -// Sometimes I let "good performance" creep up in priority over "easy to maintain", -// and for best performance I may provide less-easy-to-use APIs that give higher -// performance, in addition to the easy-to-use ones. Nevertheless, it's important -// to keep in mind that from the standpoint of you, a client of this library, -// all you care about is #1 and #3, and stb libraries DO NOT emphasize #3 above all. -// -// Some secondary priorities arise directly from the first two, some of which -// provide more explicit reasons why performance can't be emphasized. -// -// - Portable ("ease of use") -// - Small source code footprint ("easy to maintain") -// - No dependencies ("ease of use") -// -// =========================================================================== -// -// I/O callbacks -// -// I/O callbacks allow you to read from arbitrary sources, like packaged -// files or some other source. Data read from callbacks are processed -// through a small internal buffer (currently 128 bytes) to try to reduce -// overhead. -// -// The three functions you must define are "read" (reads some bytes of data), -// "skip" (skips some bytes of data), "eof" (reports if the stream is at the end). -// -// =========================================================================== -// -// SIMD support -// -// The JPEG decoder will try to automatically use SIMD kernels on x86 when -// supported by the compiler. For ARM Neon support, you must explicitly -// request it. -// -// (The old do-it-yourself SIMD API is no longer supported in the current -// code.) -// -// On x86, SSE2 will automatically be used when available based on a run-time -// test; if not, the generic C versions are used as a fall-back. On ARM targets, -// the typical path is to have separate builds for NEON and non-NEON devices -// (at least this is true for iOS and Android). Therefore, the NEON support is -// toggled by a build flag: define STBI_NEON to get NEON loops. -// -// If for some reason you do not want to use any of SIMD code, or if -// you have issues compiling it, you can disable it entirely by -// defining STBI_NO_SIMD. -// -// =========================================================================== -// -// HDR image support (disable by defining STBI_NO_HDR) -// -// stb_image supports loading HDR images in general, and currently the Radiance -// .HDR file format specifically. You can still load any file through the existing -// interface; if you attempt to load an HDR file, it will be automatically remapped -// to LDR, assuming gamma 2.2 and an arbitrary scale factor defaulting to 1; -// both of these constants can be reconfigured through this interface: -// -// stbi_hdr_to_ldr_gamma(2.2f); -// stbi_hdr_to_ldr_scale(1.0f); -// -// (note, do not use _inverse_ constants; stbi_image will invert them -// appropriately). -// -// Additionally, there is a new, parallel interface for loading files as -// (linear) floats to preserve the full dynamic range: -// -// float *data = stbi_loadf(filename, &x, &y, &n, 0); -// -// If you load LDR images through this interface, those images will -// be promoted to floating point values, run through the inverse of -// constants corresponding to the above: -// -// stbi_ldr_to_hdr_scale(1.0f); -// stbi_ldr_to_hdr_gamma(2.2f); -// -// Finally, given a filename (or an open file or memory block--see header -// file for details) containing image data, you can query for the "most -// appropriate" interface to use (that is, whether the image is HDR or -// not), using: -// -// stbi_is_hdr(char *filename); -// -// =========================================================================== -// -// iPhone PNG support: -// -// By default we convert iphone-formatted PNGs back to RGB, even though -// they are internally encoded differently. You can disable this conversion -// by calling stbi_convert_iphone_png_to_rgb(0), in which case -// you will always just get the native iphone "format" through (which -// is BGR stored in RGB). -// -// Call stbi_set_unpremultiply_on_load(1) as well to force a divide per -// pixel to remove any premultiplied alpha *only* if the image file explicitly -// says there's premultiplied data (currently only happens in iPhone images, -// and only if iPhone convert-to-rgb processing is on). -// -// =========================================================================== -// -// ADDITIONAL CONFIGURATION -// -// - You can suppress implementation of any of the decoders to reduce -// your code footprint by #defining one or more of the following -// symbols before creating the implementation. -// -// STBI_NO_JPEG -// STBI_NO_PNG -// STBI_NO_BMP -// STBI_NO_PSD -// STBI_NO_TGA -// STBI_NO_GIF -// STBI_NO_HDR -// STBI_NO_PIC -// STBI_NO_PNM (.ppm and .pgm) -// -// - You can request *only* certain decoders and suppress all other ones -// (this will be more forward-compatible, as addition of new decoders -// doesn't require you to disable them explicitly): -// -// STBI_ONLY_JPEG -// STBI_ONLY_PNG -// STBI_ONLY_BMP -// STBI_ONLY_PSD -// STBI_ONLY_TGA -// STBI_ONLY_GIF -// STBI_ONLY_HDR -// STBI_ONLY_PIC -// STBI_ONLY_PNM (.ppm and .pgm) -// -// - If you use STBI_NO_PNG (or _ONLY_ without PNG), and you still -// want the zlib decoder to be available, #define STBI_SUPPORT_ZLIB -// - - -#ifndef STBI_NO_STDIO -#include -#endif // STBI_NO_STDIO - -#define STBI_VERSION 1 - -enum -{ - STBI_default = 0, // only used for desired_channels - - STBI_grey = 1, - STBI_grey_alpha = 2, - STBI_rgb = 3, - STBI_rgb_alpha = 4 -}; - -#include -typedef unsigned char stbi_uc; -typedef unsigned short stbi_us; - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef STBIDEF -#ifdef STB_IMAGE_STATIC -#define STBIDEF static -#else -#define STBIDEF extern -#endif -#endif - -////////////////////////////////////////////////////////////////////////////// -// -// PRIMARY API - works on images of any type -// - -// -// load image by filename, open file, or memory buffer -// - -typedef struct -{ - int (*read) (void *user,char *data,int size); // fill 'data' with 'size' bytes. return number of bytes actually read - void (*skip) (void *user,int n); // skip the next 'n' bytes, or 'unget' the last -n bytes if negative - int (*eof) (void *user); // returns nonzero if we are at end of file/data -} stbi_io_callbacks; - -//////////////////////////////////// -// -// 8-bits-per-channel interface -// - -STBIDEF stbi_uc *stbi_load_from_memory (stbi_uc const *buffer, int len , int *x, int *y, int *channels_in_file, int desired_channels); -STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk , void *user, int *x, int *y, int *channels_in_file, int desired_channels); - -#ifndef STBI_NO_STDIO -STBIDEF stbi_uc *stbi_load (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels); -STBIDEF stbi_uc *stbi_load_from_file (FILE *f, int *x, int *y, int *channels_in_file, int desired_channels); -// for stbi_load_from_file, file pointer is left pointing immediately after image -#endif - -#ifndef STBI_NO_GIF -STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int **delays, int *x, int *y, int *z, int *comp, int req_comp); -#endif - -#ifdef STBI_WINDOWS_UTF8 -STBIDEF int stbi_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input); -#endif - -//////////////////////////////////// -// -// 16-bits-per-channel interface -// - -STBIDEF stbi_us *stbi_load_16_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels); -STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels); - -#ifndef STBI_NO_STDIO -STBIDEF stbi_us *stbi_load_16 (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels); -STBIDEF stbi_us *stbi_load_from_file_16(FILE *f, int *x, int *y, int *channels_in_file, int desired_channels); -#endif - -//////////////////////////////////// -// -// float-per-channel interface -// -#ifndef STBI_NO_LINEAR - STBIDEF float *stbi_loadf_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels); - STBIDEF float *stbi_loadf_from_callbacks (stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels); - - #ifndef STBI_NO_STDIO - STBIDEF float *stbi_loadf (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels); - STBIDEF float *stbi_loadf_from_file (FILE *f, int *x, int *y, int *channels_in_file, int desired_channels); - #endif -#endif - -#ifndef STBI_NO_HDR - STBIDEF void stbi_hdr_to_ldr_gamma(float gamma); - STBIDEF void stbi_hdr_to_ldr_scale(float scale); -#endif // STBI_NO_HDR - -#ifndef STBI_NO_LINEAR - STBIDEF void stbi_ldr_to_hdr_gamma(float gamma); - STBIDEF void stbi_ldr_to_hdr_scale(float scale); -#endif // STBI_NO_LINEAR - -// stbi_is_hdr is always defined, but always returns false if STBI_NO_HDR -STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user); -STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len); -#ifndef STBI_NO_STDIO -STBIDEF int stbi_is_hdr (char const *filename); -STBIDEF int stbi_is_hdr_from_file(FILE *f); -#endif // STBI_NO_STDIO - - -// get a VERY brief reason for failure -// on most compilers (and ALL modern mainstream compilers) this is threadsafe -STBIDEF const char *stbi_failure_reason (void); - -// free the loaded image -- this is just free() -STBIDEF void stbi_image_free (void *retval_from_stbi_load); - -// get image dimensions & components without fully decoding -STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp); -STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp); -STBIDEF int stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len); -STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *clbk, void *user); - -#ifndef STBI_NO_STDIO -STBIDEF int stbi_info (char const *filename, int *x, int *y, int *comp); -STBIDEF int stbi_info_from_file (FILE *f, int *x, int *y, int *comp); -STBIDEF int stbi_is_16_bit (char const *filename); -STBIDEF int stbi_is_16_bit_from_file(FILE *f); -#endif - - - -// for image formats that explicitly notate that they have premultiplied alpha, -// we just return the colors as stored in the file. set this flag to force -// unpremultiplication. results are undefined if the unpremultiply overflow. -STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply); - -// indicate whether we should process iphone images back to canonical format, -// or just pass them through "as-is" -STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert); - -// flip the image vertically, so the first pixel in the output array is the bottom left -STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip); - -// as above, but only applies to images loaded on the thread that calls the function -// this function is only available if your compiler supports thread-local variables; -// calling it will fail to link if your compiler doesn't -STBIDEF void stbi_set_flip_vertically_on_load_thread(int flag_true_if_should_flip); - -// ZLIB client - used by PNG, available for other purposes - -STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen); -STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header); -STBIDEF char *stbi_zlib_decode_malloc(const char *buffer, int len, int *outlen); -STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); - -STBIDEF char *stbi_zlib_decode_noheader_malloc(const char *buffer, int len, int *outlen); -STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); - - -#ifdef __cplusplus -} -#endif - -// -// -//// end header file ///////////////////////////////////////////////////// -#endif // STBI_INCLUDE_STB_IMAGE_H - -#ifdef STB_IMAGE_IMPLEMENTATION - -#if defined(STBI_ONLY_JPEG) || defined(STBI_ONLY_PNG) || defined(STBI_ONLY_BMP) \ - || defined(STBI_ONLY_TGA) || defined(STBI_ONLY_GIF) || defined(STBI_ONLY_PSD) \ - || defined(STBI_ONLY_HDR) || defined(STBI_ONLY_PIC) || defined(STBI_ONLY_PNM) \ - || defined(STBI_ONLY_ZLIB) - #ifndef STBI_ONLY_JPEG - #define STBI_NO_JPEG - #endif - #ifndef STBI_ONLY_PNG - #define STBI_NO_PNG - #endif - #ifndef STBI_ONLY_BMP - #define STBI_NO_BMP - #endif - #ifndef STBI_ONLY_PSD - #define STBI_NO_PSD - #endif - #ifndef STBI_ONLY_TGA - #define STBI_NO_TGA - #endif - #ifndef STBI_ONLY_GIF - #define STBI_NO_GIF - #endif - #ifndef STBI_ONLY_HDR - #define STBI_NO_HDR - #endif - #ifndef STBI_ONLY_PIC - #define STBI_NO_PIC - #endif - #ifndef STBI_ONLY_PNM - #define STBI_NO_PNM - #endif -#endif - -#if defined(STBI_NO_PNG) && !defined(STBI_SUPPORT_ZLIB) && !defined(STBI_NO_ZLIB) -#define STBI_NO_ZLIB -#endif - - -#include -#include // ptrdiff_t on osx -#include -#include -#include - -#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) -#include // ldexp, pow -#endif - -#ifndef STBI_NO_STDIO -#include -#endif - -#ifndef STBI_ASSERT -#include -#define STBI_ASSERT(x) assert(x) -#endif - -#ifdef __cplusplus -#define STBI_EXTERN extern "C" -#else -#define STBI_EXTERN extern -#endif - - -#ifndef _MSC_VER - #ifdef __cplusplus - #define stbi_inline inline - #else - #define stbi_inline - #endif -#else - #define stbi_inline __forceinline -#endif - -#ifndef STBI_NO_THREAD_LOCALS - #if defined(__cplusplus) && __cplusplus >= 201103L - #define STBI_THREAD_LOCAL thread_local - #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - #define STBI_THREAD_LOCAL _Thread_local - #elif defined(__GNUC__) - #define STBI_THREAD_LOCAL __thread - #elif defined(_MSC_VER) - #define STBI_THREAD_LOCAL __declspec(thread) -#endif -#endif - -#ifdef _MSC_VER -typedef unsigned short stbi__uint16; -typedef signed short stbi__int16; -typedef unsigned int stbi__uint32; -typedef signed int stbi__int32; -#else -#include -typedef uint16_t stbi__uint16; -typedef int16_t stbi__int16; -typedef uint32_t stbi__uint32; -typedef int32_t stbi__int32; -#endif - -// should produce compiler error if size is wrong -typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1]; - -#ifdef _MSC_VER -#define STBI_NOTUSED(v) (void)(v) -#else -#define STBI_NOTUSED(v) (void)sizeof(v) -#endif - -#ifdef _MSC_VER -#define STBI_HAS_LROTL -#endif - -#ifdef STBI_HAS_LROTL - #define stbi_lrot(x,y) _lrotl(x,y) -#else - #define stbi_lrot(x,y) (((x) << (y)) | ((x) >> (32 - (y)))) -#endif - -#if defined(STBI_MALLOC) && defined(STBI_FREE) && (defined(STBI_REALLOC) || defined(STBI_REALLOC_SIZED)) -// ok -#elif !defined(STBI_MALLOC) && !defined(STBI_FREE) && !defined(STBI_REALLOC) && !defined(STBI_REALLOC_SIZED) -// ok -#else -#error "Must define all or none of STBI_MALLOC, STBI_FREE, and STBI_REALLOC (or STBI_REALLOC_SIZED)." -#endif - -#ifndef STBI_MALLOC -#define STBI_MALLOC(sz) malloc(sz) -#define STBI_REALLOC(p,newsz) realloc(p,newsz) -#define STBI_FREE(p) free(p) -#endif - -#ifndef STBI_REALLOC_SIZED -#define STBI_REALLOC_SIZED(p,oldsz,newsz) STBI_REALLOC(p,newsz) -#endif - -// x86/x64 detection -#if defined(__x86_64__) || defined(_M_X64) -#define STBI__X64_TARGET -#elif defined(__i386) || defined(_M_IX86) -#define STBI__X86_TARGET -#endif - -#if defined(__GNUC__) && defined(STBI__X86_TARGET) && !defined(__SSE2__) && !defined(STBI_NO_SIMD) -// gcc doesn't support sse2 intrinsics unless you compile with -msse2, -// which in turn means it gets to use SSE2 everywhere. This is unfortunate, -// but previous attempts to provide the SSE2 functions with runtime -// detection caused numerous issues. The way architecture extensions are -// exposed in GCC/Clang is, sadly, not really suited for one-file libs. -// New behavior: if compiled with -msse2, we use SSE2 without any -// detection; if not, we don't use it at all. -#define STBI_NO_SIMD -#endif - -#if defined(__MINGW32__) && defined(STBI__X86_TARGET) && !defined(STBI_MINGW_ENABLE_SSE2) && !defined(STBI_NO_SIMD) -// Note that __MINGW32__ doesn't actually mean 32-bit, so we have to avoid STBI__X64_TARGET -// -// 32-bit MinGW wants ESP to be 16-byte aligned, but this is not in the -// Windows ABI and VC++ as well as Windows DLLs don't maintain that invariant. -// As a result, enabling SSE2 on 32-bit MinGW is dangerous when not -// simultaneously enabling "-mstackrealign". -// -// See https://github.com/nothings/stb/issues/81 for more information. -// -// So default to no SSE2 on 32-bit MinGW. If you've read this far and added -// -mstackrealign to your build settings, feel free to #define STBI_MINGW_ENABLE_SSE2. -#define STBI_NO_SIMD -#endif - -#if !defined(STBI_NO_SIMD) && (defined(STBI__X86_TARGET) || defined(STBI__X64_TARGET)) -#define STBI_SSE2 -#include - -#ifdef _MSC_VER - -#if _MSC_VER >= 1400 // not VC6 -#include // __cpuid -static int stbi__cpuid3(void) -{ - int info[4]; - __cpuid(info,1); - return info[3]; -} -#else -static int stbi__cpuid3(void) -{ - int res; - __asm { - mov eax,1 - cpuid - mov res,edx - } - return res; -} -#endif - -#define STBI_SIMD_ALIGN(type, name) __declspec(align(16)) type name - -#if !defined(STBI_NO_JPEG) && defined(STBI_SSE2) -static int stbi__sse2_available(void) -{ - int info3 = stbi__cpuid3(); - return ((info3 >> 26) & 1) != 0; -} -#endif - -#else // assume GCC-style if not VC++ -#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) - -#if !defined(STBI_NO_JPEG) && defined(STBI_SSE2) -static int stbi__sse2_available(void) -{ - // If we're even attempting to compile this on GCC/Clang, that means - // -msse2 is on, which means the compiler is allowed to use SSE2 - // instructions at will, and so are we. - return 1; -} -#endif - -#endif -#endif - -// ARM NEON -#if defined(STBI_NO_SIMD) && defined(STBI_NEON) -#undef STBI_NEON -#endif - -#ifdef STBI_NEON -#include -// assume GCC or Clang on ARM targets -#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) -#endif - -#ifndef STBI_SIMD_ALIGN -#define STBI_SIMD_ALIGN(type, name) type name -#endif - -/////////////////////////////////////////////// -// -// stbi__context struct and start_xxx functions - -// stbi__context structure is our basic context used by all images, so it -// contains all the IO context, plus some basic image information -typedef struct -{ - stbi__uint32 img_x, img_y; - int img_n, img_out_n; - - stbi_io_callbacks io; - void *io_user_data; - - int read_from_callbacks; - int buflen; - stbi_uc buffer_start[128]; - - stbi_uc *img_buffer, *img_buffer_end; - stbi_uc *img_buffer_original, *img_buffer_original_end; -} stbi__context; - - -static void stbi__refill_buffer(stbi__context *s); - -// initialize a memory-decode context -static void stbi__start_mem(stbi__context *s, stbi_uc const *buffer, int len) -{ - s->io.read = NULL; - s->read_from_callbacks = 0; - s->img_buffer = s->img_buffer_original = (stbi_uc *) buffer; - s->img_buffer_end = s->img_buffer_original_end = (stbi_uc *) buffer+len; -} - -// initialize a callback-based context -static void stbi__start_callbacks(stbi__context *s, stbi_io_callbacks *c, void *user) -{ - s->io = *c; - s->io_user_data = user; - s->buflen = sizeof(s->buffer_start); - s->read_from_callbacks = 1; - s->img_buffer_original = s->buffer_start; - stbi__refill_buffer(s); - s->img_buffer_original_end = s->img_buffer_end; -} - -#ifndef STBI_NO_STDIO - -static int stbi__stdio_read(void *user, char *data, int size) -{ - return (int) fread(data,1,size,(FILE*) user); -} - -static void stbi__stdio_skip(void *user, int n) -{ - fseek((FILE*) user, n, SEEK_CUR); -} - -static int stbi__stdio_eof(void *user) -{ - return feof((FILE*) user); -} - -static stbi_io_callbacks stbi__stdio_callbacks = -{ - stbi__stdio_read, - stbi__stdio_skip, - stbi__stdio_eof, -}; - -static void stbi__start_file(stbi__context *s, FILE *f) -{ - stbi__start_callbacks(s, &stbi__stdio_callbacks, (void *) f); -} - -//static void stop_file(stbi__context *s) { } - -#endif // !STBI_NO_STDIO - -static void stbi__rewind(stbi__context *s) -{ - // conceptually rewind SHOULD rewind to the beginning of the stream, - // but we just rewind to the beginning of the initial buffer, because - // we only use it after doing 'test', which only ever looks at at most 92 bytes - s->img_buffer = s->img_buffer_original; - s->img_buffer_end = s->img_buffer_original_end; -} - -enum -{ - STBI_ORDER_RGB, - STBI_ORDER_BGR -}; - -typedef struct -{ - int bits_per_channel; - int num_channels; - int channel_order; -} stbi__result_info; - -#ifndef STBI_NO_JPEG -static int stbi__jpeg_test(stbi__context *s); -static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); -static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp); -#endif - -#ifndef STBI_NO_PNG -static int stbi__png_test(stbi__context *s); -static void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); -static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp); -static int stbi__png_is16(stbi__context *s); -#endif - -#ifndef STBI_NO_BMP -static int stbi__bmp_test(stbi__context *s); -static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); -static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp); -#endif - -#ifndef STBI_NO_TGA -static int stbi__tga_test(stbi__context *s); -static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); -static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp); -#endif - -#ifndef STBI_NO_PSD -static int stbi__psd_test(stbi__context *s); -static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc); -static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp); -static int stbi__psd_is16(stbi__context *s); -#endif - -#ifndef STBI_NO_HDR -static int stbi__hdr_test(stbi__context *s); -static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); -static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp); -#endif - -#ifndef STBI_NO_PIC -static int stbi__pic_test(stbi__context *s); -static void *stbi__pic_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); -static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp); -#endif - -#ifndef STBI_NO_GIF -static int stbi__gif_test(stbi__context *s); -static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); -static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, int req_comp); -static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp); -#endif - -#ifndef STBI_NO_PNM -static int stbi__pnm_test(stbi__context *s); -static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); -static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp); -#endif - -static -#ifdef STBI_THREAD_LOCAL -STBI_THREAD_LOCAL -#endif -const char *stbi__g_failure_reason; - -STBIDEF const char *stbi_failure_reason(void) -{ - return stbi__g_failure_reason; -} - -#ifndef STBI_NO_FAILURE_STRINGS -static int stbi__err(const char *str) -{ - stbi__g_failure_reason = str; - return 0; -} -#endif - -static void *stbi__malloc(size_t size) -{ - return STBI_MALLOC(size); -} - -// stb_image uses ints pervasively, including for offset calculations. -// therefore the largest decoded image size we can support with the -// current code, even on 64-bit targets, is INT_MAX. this is not a -// significant limitation for the intended use case. -// -// we do, however, need to make sure our size calculations don't -// overflow. hence a few helper functions for size calculations that -// multiply integers together, making sure that they're non-negative -// and no overflow occurs. - -// return 1 if the sum is valid, 0 on overflow. -// negative terms are considered invalid. -static int stbi__addsizes_valid(int a, int b) -{ - if (b < 0) return 0; - // now 0 <= b <= INT_MAX, hence also - // 0 <= INT_MAX - b <= INTMAX. - // And "a + b <= INT_MAX" (which might overflow) is the - // same as a <= INT_MAX - b (no overflow) - return a <= INT_MAX - b; -} - -// returns 1 if the product is valid, 0 on overflow. -// negative factors are considered invalid. -static int stbi__mul2sizes_valid(int a, int b) -{ - if (a < 0 || b < 0) return 0; - if (b == 0) return 1; // mul-by-0 is always safe - // portable way to check for no overflows in a*b - return a <= INT_MAX/b; -} - -#if !defined(STBI_NO_JPEG) || !defined(STBI_NO_PNG) || !defined(STBI_NO_TGA) || !defined(STBI_NO_HDR) -// returns 1 if "a*b + add" has no negative terms/factors and doesn't overflow -static int stbi__mad2sizes_valid(int a, int b, int add) -{ - return stbi__mul2sizes_valid(a, b) && stbi__addsizes_valid(a*b, add); -} -#endif - -// returns 1 if "a*b*c + add" has no negative terms/factors and doesn't overflow -static int stbi__mad3sizes_valid(int a, int b, int c, int add) -{ - return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) && - stbi__addsizes_valid(a*b*c, add); -} - -// returns 1 if "a*b*c*d + add" has no negative terms/factors and doesn't overflow -#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) -static int stbi__mad4sizes_valid(int a, int b, int c, int d, int add) -{ - return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) && - stbi__mul2sizes_valid(a*b*c, d) && stbi__addsizes_valid(a*b*c*d, add); -} -#endif - -#if !defined(STBI_NO_JPEG) || !defined(STBI_NO_PNG) || !defined(STBI_NO_TGA) || !defined(STBI_NO_HDR) -// mallocs with size overflow checking -static void *stbi__malloc_mad2(int a, int b, int add) -{ - if (!stbi__mad2sizes_valid(a, b, add)) return NULL; - return stbi__malloc(a*b + add); -} -#endif - -static void *stbi__malloc_mad3(int a, int b, int c, int add) -{ - if (!stbi__mad3sizes_valid(a, b, c, add)) return NULL; - return stbi__malloc(a*b*c + add); -} - -#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) -static void *stbi__malloc_mad4(int a, int b, int c, int d, int add) -{ - if (!stbi__mad4sizes_valid(a, b, c, d, add)) return NULL; - return stbi__malloc(a*b*c*d + add); -} -#endif - -// stbi__err - error -// stbi__errpf - error returning pointer to float -// stbi__errpuc - error returning pointer to unsigned char - -#ifdef STBI_NO_FAILURE_STRINGS - #define stbi__err(x,y) 0 -#elif defined(STBI_FAILURE_USERMSG) - #define stbi__err(x,y) stbi__err(y) -#else - #define stbi__err(x,y) stbi__err(x) -#endif - -#define stbi__errpf(x,y) ((float *)(size_t) (stbi__err(x,y)?NULL:NULL)) -#define stbi__errpuc(x,y) ((unsigned char *)(size_t) (stbi__err(x,y)?NULL:NULL)) - -STBIDEF void stbi_image_free(void *retval_from_stbi_load) -{ - STBI_FREE(retval_from_stbi_load); -} - -#ifndef STBI_NO_LINEAR -static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp); -#endif - -#ifndef STBI_NO_HDR -static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp); -#endif - -static int stbi__vertically_flip_on_load_global = 0; - -STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip) -{ - stbi__vertically_flip_on_load_global = flag_true_if_should_flip; -} - -#ifndef STBI_THREAD_LOCAL -#define stbi__vertically_flip_on_load stbi__vertically_flip_on_load_global -#else -static STBI_THREAD_LOCAL int stbi__vertically_flip_on_load_local, stbi__vertically_flip_on_load_set; - -STBIDEF void stbi_set_flip_vertically_on_load_thread(int flag_true_if_should_flip) -{ - stbi__vertically_flip_on_load_local = flag_true_if_should_flip; - stbi__vertically_flip_on_load_set = 1; -} - -#define stbi__vertically_flip_on_load (stbi__vertically_flip_on_load_set \ - ? stbi__vertically_flip_on_load_local \ - : stbi__vertically_flip_on_load_global) -#endif // STBI_THREAD_LOCAL - -static void *stbi__load_main(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc) -{ - memset(ri, 0, sizeof(*ri)); // make sure it's initialized if we add new fields - ri->bits_per_channel = 8; // default is 8 so most paths don't have to be changed - ri->channel_order = STBI_ORDER_RGB; // all current input & output are this, but this is here so we can add BGR order - ri->num_channels = 0; - - #ifndef STBI_NO_JPEG - if (stbi__jpeg_test(s)) return stbi__jpeg_load(s,x,y,comp,req_comp, ri); - #endif - #ifndef STBI_NO_PNG - if (stbi__png_test(s)) return stbi__png_load(s,x,y,comp,req_comp, ri); - #endif - #ifndef STBI_NO_BMP - if (stbi__bmp_test(s)) return stbi__bmp_load(s,x,y,comp,req_comp, ri); - #endif - #ifndef STBI_NO_GIF - if (stbi__gif_test(s)) return stbi__gif_load(s,x,y,comp,req_comp, ri); - #endif - #ifndef STBI_NO_PSD - if (stbi__psd_test(s)) return stbi__psd_load(s,x,y,comp,req_comp, ri, bpc); - #else - STBI_NOTUSED(bpc); - #endif - #ifndef STBI_NO_PIC - if (stbi__pic_test(s)) return stbi__pic_load(s,x,y,comp,req_comp, ri); - #endif - #ifndef STBI_NO_PNM - if (stbi__pnm_test(s)) return stbi__pnm_load(s,x,y,comp,req_comp, ri); - #endif - - #ifndef STBI_NO_HDR - if (stbi__hdr_test(s)) { - float *hdr = stbi__hdr_load(s, x,y,comp,req_comp, ri); - return stbi__hdr_to_ldr(hdr, *x, *y, req_comp ? req_comp : *comp); - } - #endif - - #ifndef STBI_NO_TGA - // test tga last because it's a crappy test! - if (stbi__tga_test(s)) - return stbi__tga_load(s,x,y,comp,req_comp, ri); - #endif - - return stbi__errpuc("unknown image type", "Image not of any known type, or corrupt"); -} - -static stbi_uc *stbi__convert_16_to_8(stbi__uint16 *orig, int w, int h, int channels) -{ - int i; - int img_len = w * h * channels; - stbi_uc *reduced; - - reduced = (stbi_uc *) stbi__malloc(img_len); - if (reduced == NULL) return stbi__errpuc("outofmem", "Out of memory"); - - for (i = 0; i < img_len; ++i) - reduced[i] = (stbi_uc)((orig[i] >> 8) & 0xFF); // top half of each byte is sufficient approx of 16->8 bit scaling - - STBI_FREE(orig); - return reduced; -} - -static stbi__uint16 *stbi__convert_8_to_16(stbi_uc *orig, int w, int h, int channels) -{ - int i; - int img_len = w * h * channels; - stbi__uint16 *enlarged; - - enlarged = (stbi__uint16 *) stbi__malloc(img_len*2); - if (enlarged == NULL) return (stbi__uint16 *) stbi__errpuc("outofmem", "Out of memory"); - - for (i = 0; i < img_len; ++i) - enlarged[i] = (stbi__uint16)((orig[i] << 8) + orig[i]); // replicate to high and low byte, maps 0->0, 255->0xffff - - STBI_FREE(orig); - return enlarged; -} - -static void stbi__vertical_flip(void *image, int w, int h, int bytes_per_pixel) -{ - int row; - size_t bytes_per_row = (size_t)w * bytes_per_pixel; - stbi_uc temp[2048]; - stbi_uc *bytes = (stbi_uc *)image; - - for (row = 0; row < (h>>1); row++) { - stbi_uc *row0 = bytes + row*bytes_per_row; - stbi_uc *row1 = bytes + (h - row - 1)*bytes_per_row; - // swap row0 with row1 - size_t bytes_left = bytes_per_row; - while (bytes_left) { - size_t bytes_copy = (bytes_left < sizeof(temp)) ? bytes_left : sizeof(temp); - memcpy(temp, row0, bytes_copy); - memcpy(row0, row1, bytes_copy); - memcpy(row1, temp, bytes_copy); - row0 += bytes_copy; - row1 += bytes_copy; - bytes_left -= bytes_copy; - } - } -} - -#ifndef STBI_NO_GIF -static void stbi__vertical_flip_slices(void *image, int w, int h, int z, int bytes_per_pixel) -{ - int slice; - int slice_size = w * h * bytes_per_pixel; - - stbi_uc *bytes = (stbi_uc *)image; - for (slice = 0; slice < z; ++slice) { - stbi__vertical_flip(bytes, w, h, bytes_per_pixel); - bytes += slice_size; - } -} -#endif - -static unsigned char *stbi__load_and_postprocess_8bit(stbi__context *s, int *x, int *y, int *comp, int req_comp) -{ - stbi__result_info ri; - void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 8); - - if (result == NULL) - return NULL; - - if (ri.bits_per_channel != 8) { - STBI_ASSERT(ri.bits_per_channel == 16); - result = stbi__convert_16_to_8((stbi__uint16 *) result, *x, *y, req_comp == 0 ? *comp : req_comp); - ri.bits_per_channel = 8; - } - - // @TODO: move stbi__convert_format to here - - if (stbi__vertically_flip_on_load) { - int channels = req_comp ? req_comp : *comp; - stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi_uc)); - } - - return (unsigned char *) result; -} - -static stbi__uint16 *stbi__load_and_postprocess_16bit(stbi__context *s, int *x, int *y, int *comp, int req_comp) -{ - stbi__result_info ri; - void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 16); - - if (result == NULL) - return NULL; - - if (ri.bits_per_channel != 16) { - STBI_ASSERT(ri.bits_per_channel == 8); - result = stbi__convert_8_to_16((stbi_uc *) result, *x, *y, req_comp == 0 ? *comp : req_comp); - ri.bits_per_channel = 16; - } - - // @TODO: move stbi__convert_format16 to here - // @TODO: special case RGB-to-Y (and RGBA-to-YA) for 8-bit-to-16-bit case to keep more precision - - if (stbi__vertically_flip_on_load) { - int channels = req_comp ? req_comp : *comp; - stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi__uint16)); - } - - return (stbi__uint16 *) result; -} - -#if !defined(STBI_NO_HDR) && !defined(STBI_NO_LINEAR) -static void stbi__float_postprocess(float *result, int *x, int *y, int *comp, int req_comp) -{ - if (stbi__vertically_flip_on_load && result != NULL) { - int channels = req_comp ? req_comp : *comp; - stbi__vertical_flip(result, *x, *y, channels * sizeof(float)); - } -} -#endif - -#ifndef STBI_NO_STDIO - -#if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8) -STBI_EXTERN __declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int cp, unsigned long flags, const char *str, int cbmb, wchar_t *widestr, int cchwide); -STBI_EXTERN __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, char *str, int cbmb, const char *defchar, int *used_default); -#endif - -#if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8) -STBIDEF int stbi_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input) -{ - return WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, (int) bufferlen, NULL, NULL); -} -#endif - -static FILE *stbi__fopen(char const *filename, char const *mode) -{ - FILE *f; -#if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8) - wchar_t wMode[64]; - wchar_t wFilename[1024]; - if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, filename, -1, wFilename, sizeof(wFilename))) - return 0; - - if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode))) - return 0; - -#if _MSC_VER >= 1400 - if (0 != _wfopen_s(&f, wFilename, wMode)) - f = 0; -#else - f = _wfopen(wFilename, wMode); -#endif - -#elif defined(_MSC_VER) && _MSC_VER >= 1400 - if (0 != fopen_s(&f, filename, mode)) - f=0; -#else - f = fopen(filename, mode); -#endif - return f; -} - - -STBIDEF stbi_uc *stbi_load(char const *filename, int *x, int *y, int *comp, int req_comp) -{ - FILE *f = stbi__fopen(filename, "rb"); - unsigned char *result; - if (!f) return stbi__errpuc("can't fopen", "Unable to open file"); - result = stbi_load_from_file(f,x,y,comp,req_comp); - fclose(f); - return result; -} - -STBIDEF stbi_uc *stbi_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) -{ - unsigned char *result; - stbi__context s; - stbi__start_file(&s,f); - result = stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp); - if (result) { - // need to 'unget' all the characters in the IO buffer - fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR); - } - return result; -} - -STBIDEF stbi__uint16 *stbi_load_from_file_16(FILE *f, int *x, int *y, int *comp, int req_comp) -{ - stbi__uint16 *result; - stbi__context s; - stbi__start_file(&s,f); - result = stbi__load_and_postprocess_16bit(&s,x,y,comp,req_comp); - if (result) { - // need to 'unget' all the characters in the IO buffer - fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR); - } - return result; -} - -STBIDEF stbi_us *stbi_load_16(char const *filename, int *x, int *y, int *comp, int req_comp) -{ - FILE *f = stbi__fopen(filename, "rb"); - stbi__uint16 *result; - if (!f) return (stbi_us *) stbi__errpuc("can't fopen", "Unable to open file"); - result = stbi_load_from_file_16(f,x,y,comp,req_comp); - fclose(f); - return result; -} - - -#endif //!STBI_NO_STDIO - -STBIDEF stbi_us *stbi_load_16_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels) -{ - stbi__context s; - stbi__start_mem(&s,buffer,len); - return stbi__load_and_postprocess_16bit(&s,x,y,channels_in_file,desired_channels); -} - -STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels) -{ - stbi__context s; - stbi__start_callbacks(&s, (stbi_io_callbacks *)clbk, user); - return stbi__load_and_postprocess_16bit(&s,x,y,channels_in_file,desired_channels); -} - -STBIDEF stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) -{ - stbi__context s; - stbi__start_mem(&s,buffer,len); - return stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp); -} - -STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp) -{ - stbi__context s; - stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); - return stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp); -} - -#ifndef STBI_NO_GIF -STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int **delays, int *x, int *y, int *z, int *comp, int req_comp) -{ - unsigned char *result; - stbi__context s; - stbi__start_mem(&s,buffer,len); - - result = (unsigned char*) stbi__load_gif_main(&s, delays, x, y, z, comp, req_comp); - if (stbi__vertically_flip_on_load) { - stbi__vertical_flip_slices( result, *x, *y, *z, *comp ); - } - - return result; -} -#endif - -#ifndef STBI_NO_LINEAR -static float *stbi__loadf_main(stbi__context *s, int *x, int *y, int *comp, int req_comp) -{ - unsigned char *data; - #ifndef STBI_NO_HDR - if (stbi__hdr_test(s)) { - stbi__result_info ri; - float *hdr_data = stbi__hdr_load(s,x,y,comp,req_comp, &ri); - if (hdr_data) - stbi__float_postprocess(hdr_data,x,y,comp,req_comp); - return hdr_data; - } - #endif - data = stbi__load_and_postprocess_8bit(s, x, y, comp, req_comp); - if (data) - return stbi__ldr_to_hdr(data, *x, *y, req_comp ? req_comp : *comp); - return stbi__errpf("unknown image type", "Image not of any known type, or corrupt"); -} - -STBIDEF float *stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) -{ - stbi__context s; - stbi__start_mem(&s,buffer,len); - return stbi__loadf_main(&s,x,y,comp,req_comp); -} - -STBIDEF float *stbi_loadf_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp) -{ - stbi__context s; - stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); - return stbi__loadf_main(&s,x,y,comp,req_comp); -} - -#ifndef STBI_NO_STDIO -STBIDEF float *stbi_loadf(char const *filename, int *x, int *y, int *comp, int req_comp) -{ - float *result; - FILE *f = stbi__fopen(filename, "rb"); - if (!f) return stbi__errpf("can't fopen", "Unable to open file"); - result = stbi_loadf_from_file(f,x,y,comp,req_comp); - fclose(f); - return result; -} - -STBIDEF float *stbi_loadf_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) -{ - stbi__context s; - stbi__start_file(&s,f); - return stbi__loadf_main(&s,x,y,comp,req_comp); -} -#endif // !STBI_NO_STDIO - -#endif // !STBI_NO_LINEAR - -// these is-hdr-or-not is defined independent of whether STBI_NO_LINEAR is -// defined, for API simplicity; if STBI_NO_LINEAR is defined, it always -// reports false! - -STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len) -{ - #ifndef STBI_NO_HDR - stbi__context s; - stbi__start_mem(&s,buffer,len); - return stbi__hdr_test(&s); - #else - STBI_NOTUSED(buffer); - STBI_NOTUSED(len); - return 0; - #endif -} - -#ifndef STBI_NO_STDIO -STBIDEF int stbi_is_hdr (char const *filename) -{ - FILE *f = stbi__fopen(filename, "rb"); - int result=0; - if (f) { - result = stbi_is_hdr_from_file(f); - fclose(f); - } - return result; -} - -STBIDEF int stbi_is_hdr_from_file(FILE *f) -{ - #ifndef STBI_NO_HDR - long pos = ftell(f); - int res; - stbi__context s; - stbi__start_file(&s,f); - res = stbi__hdr_test(&s); - fseek(f, pos, SEEK_SET); - return res; - #else - STBI_NOTUSED(f); - return 0; - #endif -} -#endif // !STBI_NO_STDIO - -STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user) -{ - #ifndef STBI_NO_HDR - stbi__context s; - stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); - return stbi__hdr_test(&s); - #else - STBI_NOTUSED(clbk); - STBI_NOTUSED(user); - return 0; - #endif -} - -#ifndef STBI_NO_LINEAR -static float stbi__l2h_gamma=2.2f, stbi__l2h_scale=1.0f; - -STBIDEF void stbi_ldr_to_hdr_gamma(float gamma) { stbi__l2h_gamma = gamma; } -STBIDEF void stbi_ldr_to_hdr_scale(float scale) { stbi__l2h_scale = scale; } -#endif - -static float stbi__h2l_gamma_i=1.0f/2.2f, stbi__h2l_scale_i=1.0f; - -STBIDEF void stbi_hdr_to_ldr_gamma(float gamma) { stbi__h2l_gamma_i = 1/gamma; } -STBIDEF void stbi_hdr_to_ldr_scale(float scale) { stbi__h2l_scale_i = 1/scale; } - - -////////////////////////////////////////////////////////////////////////////// -// -// Common code used by all image loaders -// - -enum -{ - STBI__SCAN_load=0, - STBI__SCAN_type, - STBI__SCAN_header -}; - -static void stbi__refill_buffer(stbi__context *s) -{ - int n = (s->io.read)(s->io_user_data,(char*)s->buffer_start,s->buflen); - if (n == 0) { - // at end of file, treat same as if from memory, but need to handle case - // where s->img_buffer isn't pointing to safe memory, e.g. 0-byte file - s->read_from_callbacks = 0; - s->img_buffer = s->buffer_start; - s->img_buffer_end = s->buffer_start+1; - *s->img_buffer = 0; - } else { - s->img_buffer = s->buffer_start; - s->img_buffer_end = s->buffer_start + n; - } -} - -stbi_inline static stbi_uc stbi__get8(stbi__context *s) -{ - if (s->img_buffer < s->img_buffer_end) - return *s->img_buffer++; - if (s->read_from_callbacks) { - stbi__refill_buffer(s); - return *s->img_buffer++; - } - return 0; -} - -#if defined(STBI_NO_JPEG) && defined(STBI_NO_HDR) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM) -// nothing -#else -stbi_inline static int stbi__at_eof(stbi__context *s) -{ - if (s->io.read) { - if (!(s->io.eof)(s->io_user_data)) return 0; - // if feof() is true, check if buffer = end - // special case: we've only got the special 0 character at the end - if (s->read_from_callbacks == 0) return 1; - } - - return s->img_buffer >= s->img_buffer_end; -} -#endif - -#if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC) -// nothing -#else -static void stbi__skip(stbi__context *s, int n) -{ - if (n < 0) { - s->img_buffer = s->img_buffer_end; - return; - } - if (s->io.read) { - int blen = (int) (s->img_buffer_end - s->img_buffer); - if (blen < n) { - s->img_buffer = s->img_buffer_end; - (s->io.skip)(s->io_user_data, n - blen); - return; - } - } - s->img_buffer += n; -} -#endif - -#if defined(STBI_NO_PNG) && defined(STBI_NO_TGA) && defined(STBI_NO_HDR) && defined(STBI_NO_PNM) -// nothing -#else -static int stbi__getn(stbi__context *s, stbi_uc *buffer, int n) -{ - if (s->io.read) { - int blen = (int) (s->img_buffer_end - s->img_buffer); - if (blen < n) { - int res, count; - - memcpy(buffer, s->img_buffer, blen); - - count = (s->io.read)(s->io_user_data, (char*) buffer + blen, n - blen); - res = (count == (n-blen)); - s->img_buffer = s->img_buffer_end; - return res; - } - } - - if (s->img_buffer+n <= s->img_buffer_end) { - memcpy(buffer, s->img_buffer, n); - s->img_buffer += n; - return 1; - } else - return 0; -} -#endif - -#if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_PSD) && defined(STBI_NO_PIC) -// nothing -#else -static int stbi__get16be(stbi__context *s) -{ - int z = stbi__get8(s); - return (z << 8) + stbi__get8(s); -} -#endif - -#if defined(STBI_NO_PNG) && defined(STBI_NO_PSD) && defined(STBI_NO_PIC) -// nothing -#else -static stbi__uint32 stbi__get32be(stbi__context *s) -{ - stbi__uint32 z = stbi__get16be(s); - return (z << 16) + stbi__get16be(s); -} -#endif - -#if defined(STBI_NO_BMP) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) -// nothing -#else -static int stbi__get16le(stbi__context *s) -{ - int z = stbi__get8(s); - return z + (stbi__get8(s) << 8); -} -#endif - -#ifndef STBI_NO_BMP -static stbi__uint32 stbi__get32le(stbi__context *s) -{ - stbi__uint32 z = stbi__get16le(s); - return z + (stbi__get16le(s) << 16); -} -#endif - -#define STBI__BYTECAST(x) ((stbi_uc) ((x) & 255)) // truncate int to byte without warnings - -#if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM) -// nothing -#else -////////////////////////////////////////////////////////////////////////////// -// -// generic converter from built-in img_n to req_comp -// individual types do this automatically as much as possible (e.g. jpeg -// does all cases internally since it needs to colorspace convert anyway, -// and it never has alpha, so very few cases ). png can automatically -// interleave an alpha=255 channel, but falls back to this for other cases -// -// assume data buffer is malloced, so malloc a new one and free that one -// only failure mode is malloc failing - -static stbi_uc stbi__compute_y(int r, int g, int b) -{ - return (stbi_uc) (((r*77) + (g*150) + (29*b)) >> 8); -} -#endif - -#if defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM) -// nothing -#else -static unsigned char *stbi__convert_format(unsigned char *data, int img_n, int req_comp, unsigned int x, unsigned int y) -{ - int i,j; - unsigned char *good; - - if (req_comp == img_n) return data; - STBI_ASSERT(req_comp >= 1 && req_comp <= 4); - - good = (unsigned char *) stbi__malloc_mad3(req_comp, x, y, 0); - if (good == NULL) { - STBI_FREE(data); - return stbi__errpuc("outofmem", "Out of memory"); - } - - for (j=0; j < (int) y; ++j) { - unsigned char *src = data + j * x * img_n ; - unsigned char *dest = good + j * x * req_comp; - - #define STBI__COMBO(a,b) ((a)*8+(b)) - #define STBI__CASE(a,b) case STBI__COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b) - // convert source image with img_n components to one with req_comp components; - // avoid switch per pixel, so use switch per scanline and massive macros - switch (STBI__COMBO(img_n, req_comp)) { - STBI__CASE(1,2) { dest[0]=src[0]; dest[1]=255; } break; - STBI__CASE(1,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; - STBI__CASE(1,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=255; } break; - STBI__CASE(2,1) { dest[0]=src[0]; } break; - STBI__CASE(2,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; - STBI__CASE(2,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=src[1]; } break; - STBI__CASE(3,4) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];dest[3]=255; } break; - STBI__CASE(3,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); } break; - STBI__CASE(3,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); dest[1] = 255; } break; - STBI__CASE(4,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); } break; - STBI__CASE(4,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); dest[1] = src[3]; } break; - STBI__CASE(4,3) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2]; } break; - default: STBI_ASSERT(0); - } - #undef STBI__CASE - } - - STBI_FREE(data); - return good; -} -#endif - -#if defined(STBI_NO_PNG) && defined(STBI_NO_PSD) -// nothing -#else -static stbi__uint16 stbi__compute_y_16(int r, int g, int b) -{ - return (stbi__uint16) (((r*77) + (g*150) + (29*b)) >> 8); -} -#endif - -#if defined(STBI_NO_PNG) && defined(STBI_NO_PSD) -// nothing -#else -static stbi__uint16 *stbi__convert_format16(stbi__uint16 *data, int img_n, int req_comp, unsigned int x, unsigned int y) -{ - int i,j; - stbi__uint16 *good; - - if (req_comp == img_n) return data; - STBI_ASSERT(req_comp >= 1 && req_comp <= 4); - - good = (stbi__uint16 *) stbi__malloc(req_comp * x * y * 2); - if (good == NULL) { - STBI_FREE(data); - return (stbi__uint16 *) stbi__errpuc("outofmem", "Out of memory"); - } - - for (j=0; j < (int) y; ++j) { - stbi__uint16 *src = data + j * x * img_n ; - stbi__uint16 *dest = good + j * x * req_comp; - - #define STBI__COMBO(a,b) ((a)*8+(b)) - #define STBI__CASE(a,b) case STBI__COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b) - // convert source image with img_n components to one with req_comp components; - // avoid switch per pixel, so use switch per scanline and massive macros - switch (STBI__COMBO(img_n, req_comp)) { - STBI__CASE(1,2) { dest[0]=src[0]; dest[1]=0xffff; } break; - STBI__CASE(1,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; - STBI__CASE(1,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=0xffff; } break; - STBI__CASE(2,1) { dest[0]=src[0]; } break; - STBI__CASE(2,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; - STBI__CASE(2,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=src[1]; } break; - STBI__CASE(3,4) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];dest[3]=0xffff; } break; - STBI__CASE(3,1) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); } break; - STBI__CASE(3,2) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); dest[1] = 0xffff; } break; - STBI__CASE(4,1) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); } break; - STBI__CASE(4,2) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); dest[1] = src[3]; } break; - STBI__CASE(4,3) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2]; } break; - default: STBI_ASSERT(0); - } - #undef STBI__CASE - } - - STBI_FREE(data); - return good; -} -#endif - -#ifndef STBI_NO_LINEAR -static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp) -{ - int i,k,n; - float *output; - if (!data) return NULL; - output = (float *) stbi__malloc_mad4(x, y, comp, sizeof(float), 0); - if (output == NULL) { STBI_FREE(data); return stbi__errpf("outofmem", "Out of memory"); } - // compute number of non-alpha components - if (comp & 1) n = comp; else n = comp-1; - for (i=0; i < x*y; ++i) { - for (k=0; k < n; ++k) { - output[i*comp + k] = (float) (pow(data[i*comp+k]/255.0f, stbi__l2h_gamma) * stbi__l2h_scale); - } - } - if (n < comp) { - for (i=0; i < x*y; ++i) { - output[i*comp + n] = data[i*comp + n]/255.0f; - } - } - STBI_FREE(data); - return output; -} -#endif - -#ifndef STBI_NO_HDR -#define stbi__float2int(x) ((int) (x)) -static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp) -{ - int i,k,n; - stbi_uc *output; - if (!data) return NULL; - output = (stbi_uc *) stbi__malloc_mad3(x, y, comp, 0); - if (output == NULL) { STBI_FREE(data); return stbi__errpuc("outofmem", "Out of memory"); } - // compute number of non-alpha components - if (comp & 1) n = comp; else n = comp-1; - for (i=0; i < x*y; ++i) { - for (k=0; k < n; ++k) { - float z = (float) pow(data[i*comp+k]*stbi__h2l_scale_i, stbi__h2l_gamma_i) * 255 + 0.5f; - if (z < 0) z = 0; - if (z > 255) z = 255; - output[i*comp + k] = (stbi_uc) stbi__float2int(z); - } - if (k < comp) { - float z = data[i*comp+k] * 255 + 0.5f; - if (z < 0) z = 0; - if (z > 255) z = 255; - output[i*comp + k] = (stbi_uc) stbi__float2int(z); - } - } - STBI_FREE(data); - return output; -} -#endif - -////////////////////////////////////////////////////////////////////////////// -// -// "baseline" JPEG/JFIF decoder -// -// simple implementation -// - doesn't support delayed output of y-dimension -// - simple interface (only one output format: 8-bit interleaved RGB) -// - doesn't try to recover corrupt jpegs -// - doesn't allow partial loading, loading multiple at once -// - still fast on x86 (copying globals into locals doesn't help x86) -// - allocates lots of intermediate memory (full size of all components) -// - non-interleaved case requires this anyway -// - allows good upsampling (see next) -// high-quality -// - upsampled channels are bilinearly interpolated, even across blocks -// - quality integer IDCT derived from IJG's 'slow' -// performance -// - fast huffman; reasonable integer IDCT -// - some SIMD kernels for common paths on targets with SSE2/NEON -// - uses a lot of intermediate memory, could cache poorly - -#ifndef STBI_NO_JPEG - -// huffman decoding acceleration -#define FAST_BITS 9 // larger handles more cases; smaller stomps less cache - -typedef struct -{ - stbi_uc fast[1 << FAST_BITS]; - // weirdly, repacking this into AoS is a 10% speed loss, instead of a win - stbi__uint16 code[256]; - stbi_uc values[256]; - stbi_uc size[257]; - unsigned int maxcode[18]; - int delta[17]; // old 'firstsymbol' - old 'firstcode' -} stbi__huffman; - -typedef struct -{ - stbi__context *s; - stbi__huffman huff_dc[4]; - stbi__huffman huff_ac[4]; - stbi__uint16 dequant[4][64]; - stbi__int16 fast_ac[4][1 << FAST_BITS]; - -// sizes for components, interleaved MCUs - int img_h_max, img_v_max; - int img_mcu_x, img_mcu_y; - int img_mcu_w, img_mcu_h; - -// definition of jpeg image component - struct - { - int id; - int h,v; - int tq; - int hd,ha; - int dc_pred; - - int x,y,w2,h2; - stbi_uc *data; - void *raw_data, *raw_coeff; - stbi_uc *linebuf; - short *coeff; // progressive only - int coeff_w, coeff_h; // number of 8x8 coefficient blocks - } img_comp[4]; - - stbi__uint32 code_buffer; // jpeg entropy-coded buffer - int code_bits; // number of valid bits - unsigned char marker; // marker seen while filling entropy buffer - int nomore; // flag if we saw a marker so must stop - - int progressive; - int spec_start; - int spec_end; - int succ_high; - int succ_low; - int eob_run; - int jfif; - int app14_color_transform; // Adobe APP14 tag - int rgb; - - int scan_n, order[4]; - int restart_interval, todo; - -// kernels - void (*idct_block_kernel)(stbi_uc *out, int out_stride, short data[64]); - void (*YCbCr_to_RGB_kernel)(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step); - stbi_uc *(*resample_row_hv_2_kernel)(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs); -} stbi__jpeg; - -static int stbi__build_huffman(stbi__huffman *h, int *count) -{ - int i,j,k=0; - unsigned int code; - // build size list for each symbol (from JPEG spec) - for (i=0; i < 16; ++i) - for (j=0; j < count[i]; ++j) - h->size[k++] = (stbi_uc) (i+1); - h->size[k] = 0; - - // compute actual symbols (from jpeg spec) - code = 0; - k = 0; - for(j=1; j <= 16; ++j) { - // compute delta to add to code to compute symbol id - h->delta[j] = k - code; - if (h->size[k] == j) { - while (h->size[k] == j) - h->code[k++] = (stbi__uint16) (code++); - if (code-1 >= (1u << j)) return stbi__err("bad code lengths","Corrupt JPEG"); - } - // compute largest code + 1 for this size, preshifted as needed later - h->maxcode[j] = code << (16-j); - code <<= 1; - } - h->maxcode[j] = 0xffffffff; - - // build non-spec acceleration table; 255 is flag for not-accelerated - memset(h->fast, 255, 1 << FAST_BITS); - for (i=0; i < k; ++i) { - int s = h->size[i]; - if (s <= FAST_BITS) { - int c = h->code[i] << (FAST_BITS-s); - int m = 1 << (FAST_BITS-s); - for (j=0; j < m; ++j) { - h->fast[c+j] = (stbi_uc) i; - } - } - } - return 1; -} - -// build a table that decodes both magnitude and value of small ACs in -// one go. -static void stbi__build_fast_ac(stbi__int16 *fast_ac, stbi__huffman *h) -{ - int i; - for (i=0; i < (1 << FAST_BITS); ++i) { - stbi_uc fast = h->fast[i]; - fast_ac[i] = 0; - if (fast < 255) { - int rs = h->values[fast]; - int run = (rs >> 4) & 15; - int magbits = rs & 15; - int len = h->size[fast]; - - if (magbits && len + magbits <= FAST_BITS) { - // magnitude code followed by receive_extend code - int k = ((i << len) & ((1 << FAST_BITS) - 1)) >> (FAST_BITS - magbits); - int m = 1 << (magbits - 1); - if (k < m) k += (~0U << magbits) + 1; - // if the result is small enough, we can fit it in fast_ac table - if (k >= -128 && k <= 127) - fast_ac[i] = (stbi__int16) ((k * 256) + (run * 16) + (len + magbits)); - } - } - } -} - -static void stbi__grow_buffer_unsafe(stbi__jpeg *j) -{ - do { - unsigned int b = j->nomore ? 0 : stbi__get8(j->s); - if (b == 0xff) { - int c = stbi__get8(j->s); - while (c == 0xff) c = stbi__get8(j->s); // consume fill bytes - if (c != 0) { - j->marker = (unsigned char) c; - j->nomore = 1; - return; - } - } - j->code_buffer |= b << (24 - j->code_bits); - j->code_bits += 8; - } while (j->code_bits <= 24); -} - -// (1 << n) - 1 -static const stbi__uint32 stbi__bmask[17]={0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535}; - -// decode a jpeg huffman value from the bitstream -stbi_inline static int stbi__jpeg_huff_decode(stbi__jpeg *j, stbi__huffman *h) -{ - unsigned int temp; - int c,k; - - if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); - - // look at the top FAST_BITS and determine what symbol ID it is, - // if the code is <= FAST_BITS - c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); - k = h->fast[c]; - if (k < 255) { - int s = h->size[k]; - if (s > j->code_bits) - return -1; - j->code_buffer <<= s; - j->code_bits -= s; - return h->values[k]; - } - - // naive test is to shift the code_buffer down so k bits are - // valid, then test against maxcode. To speed this up, we've - // preshifted maxcode left so that it has (16-k) 0s at the - // end; in other words, regardless of the number of bits, it - // wants to be compared against something shifted to have 16; - // that way we don't need to shift inside the loop. - temp = j->code_buffer >> 16; - for (k=FAST_BITS+1 ; ; ++k) - if (temp < h->maxcode[k]) - break; - if (k == 17) { - // error! code not found - j->code_bits -= 16; - return -1; - } - - if (k > j->code_bits) - return -1; - - // convert the huffman code to the symbol id - c = ((j->code_buffer >> (32 - k)) & stbi__bmask[k]) + h->delta[k]; - STBI_ASSERT((((j->code_buffer) >> (32 - h->size[c])) & stbi__bmask[h->size[c]]) == h->code[c]); - - // convert the id to a symbol - j->code_bits -= k; - j->code_buffer <<= k; - return h->values[c]; -} - -// bias[n] = (-1<code_bits < n) stbi__grow_buffer_unsafe(j); - - sgn = (stbi__int32)j->code_buffer >> 31; // sign bit is always in MSB - k = stbi_lrot(j->code_buffer, n); - STBI_ASSERT(n >= 0 && n < (int) (sizeof(stbi__bmask)/sizeof(*stbi__bmask))); - j->code_buffer = k & ~stbi__bmask[n]; - k &= stbi__bmask[n]; - j->code_bits -= n; - return k + (stbi__jbias[n] & ~sgn); -} - -// get some unsigned bits -stbi_inline static int stbi__jpeg_get_bits(stbi__jpeg *j, int n) -{ - unsigned int k; - if (j->code_bits < n) stbi__grow_buffer_unsafe(j); - k = stbi_lrot(j->code_buffer, n); - j->code_buffer = k & ~stbi__bmask[n]; - k &= stbi__bmask[n]; - j->code_bits -= n; - return k; -} - -stbi_inline static int stbi__jpeg_get_bit(stbi__jpeg *j) -{ - unsigned int k; - if (j->code_bits < 1) stbi__grow_buffer_unsafe(j); - k = j->code_buffer; - j->code_buffer <<= 1; - --j->code_bits; - return k & 0x80000000; -} - -// given a value that's at position X in the zigzag stream, -// where does it appear in the 8x8 matrix coded as row-major? -static const stbi_uc stbi__jpeg_dezigzag[64+15] = -{ - 0, 1, 8, 16, 9, 2, 3, 10, - 17, 24, 32, 25, 18, 11, 4, 5, - 12, 19, 26, 33, 40, 48, 41, 34, - 27, 20, 13, 6, 7, 14, 21, 28, - 35, 42, 49, 56, 57, 50, 43, 36, - 29, 22, 15, 23, 30, 37, 44, 51, - 58, 59, 52, 45, 38, 31, 39, 46, - 53, 60, 61, 54, 47, 55, 62, 63, - // let corrupt input sample past end - 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63 -}; - -// decode one 64-entry block-- -static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman *hdc, stbi__huffman *hac, stbi__int16 *fac, int b, stbi__uint16 *dequant) -{ - int diff,dc,k; - int t; - - if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); - t = stbi__jpeg_huff_decode(j, hdc); - if (t < 0) return stbi__err("bad huffman code","Corrupt JPEG"); - - // 0 all the ac values now so we can do it 32-bits at a time - memset(data,0,64*sizeof(data[0])); - - diff = t ? stbi__extend_receive(j, t) : 0; - dc = j->img_comp[b].dc_pred + diff; - j->img_comp[b].dc_pred = dc; - data[0] = (short) (dc * dequant[0]); - - // decode AC components, see JPEG spec - k = 1; - do { - unsigned int zig; - int c,r,s; - if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); - c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); - r = fac[c]; - if (r) { // fast-AC path - k += (r >> 4) & 15; // run - s = r & 15; // combined length - j->code_buffer <<= s; - j->code_bits -= s; - // decode into unzigzag'd location - zig = stbi__jpeg_dezigzag[k++]; - data[zig] = (short) ((r >> 8) * dequant[zig]); - } else { - int rs = stbi__jpeg_huff_decode(j, hac); - if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); - s = rs & 15; - r = rs >> 4; - if (s == 0) { - if (rs != 0xf0) break; // end block - k += 16; - } else { - k += r; - // decode into unzigzag'd location - zig = stbi__jpeg_dezigzag[k++]; - data[zig] = (short) (stbi__extend_receive(j,s) * dequant[zig]); - } - } - } while (k < 64); - return 1; -} - -static int stbi__jpeg_decode_block_prog_dc(stbi__jpeg *j, short data[64], stbi__huffman *hdc, int b) -{ - int diff,dc; - int t; - if (j->spec_end != 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); - - if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); - - if (j->succ_high == 0) { - // first scan for DC coefficient, must be first - memset(data,0,64*sizeof(data[0])); // 0 all the ac values now - t = stbi__jpeg_huff_decode(j, hdc); - diff = t ? stbi__extend_receive(j, t) : 0; - - dc = j->img_comp[b].dc_pred + diff; - j->img_comp[b].dc_pred = dc; - data[0] = (short) (dc << j->succ_low); - } else { - // refinement scan for DC coefficient - if (stbi__jpeg_get_bit(j)) - data[0] += (short) (1 << j->succ_low); - } - return 1; -} - -// @OPTIMIZE: store non-zigzagged during the decode passes, -// and only de-zigzag when dequantizing -static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__huffman *hac, stbi__int16 *fac) -{ - int k; - if (j->spec_start == 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); - - if (j->succ_high == 0) { - int shift = j->succ_low; - - if (j->eob_run) { - --j->eob_run; - return 1; - } - - k = j->spec_start; - do { - unsigned int zig; - int c,r,s; - if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); - c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); - r = fac[c]; - if (r) { // fast-AC path - k += (r >> 4) & 15; // run - s = r & 15; // combined length - j->code_buffer <<= s; - j->code_bits -= s; - zig = stbi__jpeg_dezigzag[k++]; - data[zig] = (short) ((r >> 8) << shift); - } else { - int rs = stbi__jpeg_huff_decode(j, hac); - if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); - s = rs & 15; - r = rs >> 4; - if (s == 0) { - if (r < 15) { - j->eob_run = (1 << r); - if (r) - j->eob_run += stbi__jpeg_get_bits(j, r); - --j->eob_run; - break; - } - k += 16; - } else { - k += r; - zig = stbi__jpeg_dezigzag[k++]; - data[zig] = (short) (stbi__extend_receive(j,s) << shift); - } - } - } while (k <= j->spec_end); - } else { - // refinement scan for these AC coefficients - - short bit = (short) (1 << j->succ_low); - - if (j->eob_run) { - --j->eob_run; - for (k = j->spec_start; k <= j->spec_end; ++k) { - short *p = &data[stbi__jpeg_dezigzag[k]]; - if (*p != 0) - if (stbi__jpeg_get_bit(j)) - if ((*p & bit)==0) { - if (*p > 0) - *p += bit; - else - *p -= bit; - } - } - } else { - k = j->spec_start; - do { - int r,s; - int rs = stbi__jpeg_huff_decode(j, hac); // @OPTIMIZE see if we can use the fast path here, advance-by-r is so slow, eh - if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); - s = rs & 15; - r = rs >> 4; - if (s == 0) { - if (r < 15) { - j->eob_run = (1 << r) - 1; - if (r) - j->eob_run += stbi__jpeg_get_bits(j, r); - r = 64; // force end of block - } else { - // r=15 s=0 should write 16 0s, so we just do - // a run of 15 0s and then write s (which is 0), - // so we don't have to do anything special here - } - } else { - if (s != 1) return stbi__err("bad huffman code", "Corrupt JPEG"); - // sign bit - if (stbi__jpeg_get_bit(j)) - s = bit; - else - s = -bit; - } - - // advance by r - while (k <= j->spec_end) { - short *p = &data[stbi__jpeg_dezigzag[k++]]; - if (*p != 0) { - if (stbi__jpeg_get_bit(j)) - if ((*p & bit)==0) { - if (*p > 0) - *p += bit; - else - *p -= bit; - } - } else { - if (r == 0) { - *p = (short) s; - break; - } - --r; - } - } - } while (k <= j->spec_end); - } - } - return 1; -} - -// take a -128..127 value and stbi__clamp it and convert to 0..255 -stbi_inline static stbi_uc stbi__clamp(int x) -{ - // trick to use a single test to catch both cases - if ((unsigned int) x > 255) { - if (x < 0) return 0; - if (x > 255) return 255; - } - return (stbi_uc) x; -} - -#define stbi__f2f(x) ((int) (((x) * 4096 + 0.5))) -#define stbi__fsh(x) ((x) * 4096) - -// derived from jidctint -- DCT_ISLOW -#define STBI__IDCT_1D(s0,s1,s2,s3,s4,s5,s6,s7) \ - int t0,t1,t2,t3,p1,p2,p3,p4,p5,x0,x1,x2,x3; \ - p2 = s2; \ - p3 = s6; \ - p1 = (p2+p3) * stbi__f2f(0.5411961f); \ - t2 = p1 + p3*stbi__f2f(-1.847759065f); \ - t3 = p1 + p2*stbi__f2f( 0.765366865f); \ - p2 = s0; \ - p3 = s4; \ - t0 = stbi__fsh(p2+p3); \ - t1 = stbi__fsh(p2-p3); \ - x0 = t0+t3; \ - x3 = t0-t3; \ - x1 = t1+t2; \ - x2 = t1-t2; \ - t0 = s7; \ - t1 = s5; \ - t2 = s3; \ - t3 = s1; \ - p3 = t0+t2; \ - p4 = t1+t3; \ - p1 = t0+t3; \ - p2 = t1+t2; \ - p5 = (p3+p4)*stbi__f2f( 1.175875602f); \ - t0 = t0*stbi__f2f( 0.298631336f); \ - t1 = t1*stbi__f2f( 2.053119869f); \ - t2 = t2*stbi__f2f( 3.072711026f); \ - t3 = t3*stbi__f2f( 1.501321110f); \ - p1 = p5 + p1*stbi__f2f(-0.899976223f); \ - p2 = p5 + p2*stbi__f2f(-2.562915447f); \ - p3 = p3*stbi__f2f(-1.961570560f); \ - p4 = p4*stbi__f2f(-0.390180644f); \ - t3 += p1+p4; \ - t2 += p2+p3; \ - t1 += p2+p4; \ - t0 += p1+p3; - -static void stbi__idct_block(stbi_uc *out, int out_stride, short data[64]) -{ - int i,val[64],*v=val; - stbi_uc *o; - short *d = data; - - // columns - for (i=0; i < 8; ++i,++d, ++v) { - // if all zeroes, shortcut -- this avoids dequantizing 0s and IDCTing - if (d[ 8]==0 && d[16]==0 && d[24]==0 && d[32]==0 - && d[40]==0 && d[48]==0 && d[56]==0) { - // no shortcut 0 seconds - // (1|2|3|4|5|6|7)==0 0 seconds - // all separate -0.047 seconds - // 1 && 2|3 && 4|5 && 6|7: -0.047 seconds - int dcterm = d[0]*4; - v[0] = v[8] = v[16] = v[24] = v[32] = v[40] = v[48] = v[56] = dcterm; - } else { - STBI__IDCT_1D(d[ 0],d[ 8],d[16],d[24],d[32],d[40],d[48],d[56]) - // constants scaled things up by 1<<12; let's bring them back - // down, but keep 2 extra bits of precision - x0 += 512; x1 += 512; x2 += 512; x3 += 512; - v[ 0] = (x0+t3) >> 10; - v[56] = (x0-t3) >> 10; - v[ 8] = (x1+t2) >> 10; - v[48] = (x1-t2) >> 10; - v[16] = (x2+t1) >> 10; - v[40] = (x2-t1) >> 10; - v[24] = (x3+t0) >> 10; - v[32] = (x3-t0) >> 10; - } - } - - for (i=0, v=val, o=out; i < 8; ++i,v+=8,o+=out_stride) { - // no fast case since the first 1D IDCT spread components out - STBI__IDCT_1D(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7]) - // constants scaled things up by 1<<12, plus we had 1<<2 from first - // loop, plus horizontal and vertical each scale by sqrt(8) so together - // we've got an extra 1<<3, so 1<<17 total we need to remove. - // so we want to round that, which means adding 0.5 * 1<<17, - // aka 65536. Also, we'll end up with -128 to 127 that we want - // to encode as 0..255 by adding 128, so we'll add that before the shift - x0 += 65536 + (128<<17); - x1 += 65536 + (128<<17); - x2 += 65536 + (128<<17); - x3 += 65536 + (128<<17); - // tried computing the shifts into temps, or'ing the temps to see - // if any were out of range, but that was slower - o[0] = stbi__clamp((x0+t3) >> 17); - o[7] = stbi__clamp((x0-t3) >> 17); - o[1] = stbi__clamp((x1+t2) >> 17); - o[6] = stbi__clamp((x1-t2) >> 17); - o[2] = stbi__clamp((x2+t1) >> 17); - o[5] = stbi__clamp((x2-t1) >> 17); - o[3] = stbi__clamp((x3+t0) >> 17); - o[4] = stbi__clamp((x3-t0) >> 17); - } -} - -#ifdef STBI_SSE2 -// sse2 integer IDCT. not the fastest possible implementation but it -// produces bit-identical results to the generic C version so it's -// fully "transparent". -static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) -{ - // This is constructed to match our regular (generic) integer IDCT exactly. - __m128i row0, row1, row2, row3, row4, row5, row6, row7; - __m128i tmp; - - // dot product constant: even elems=x, odd elems=y - #define dct_const(x,y) _mm_setr_epi16((x),(y),(x),(y),(x),(y),(x),(y)) - - // out(0) = c0[even]*x + c0[odd]*y (c0, x, y 16-bit, out 32-bit) - // out(1) = c1[even]*x + c1[odd]*y - #define dct_rot(out0,out1, x,y,c0,c1) \ - __m128i c0##lo = _mm_unpacklo_epi16((x),(y)); \ - __m128i c0##hi = _mm_unpackhi_epi16((x),(y)); \ - __m128i out0##_l = _mm_madd_epi16(c0##lo, c0); \ - __m128i out0##_h = _mm_madd_epi16(c0##hi, c0); \ - __m128i out1##_l = _mm_madd_epi16(c0##lo, c1); \ - __m128i out1##_h = _mm_madd_epi16(c0##hi, c1) - - // out = in << 12 (in 16-bit, out 32-bit) - #define dct_widen(out, in) \ - __m128i out##_l = _mm_srai_epi32(_mm_unpacklo_epi16(_mm_setzero_si128(), (in)), 4); \ - __m128i out##_h = _mm_srai_epi32(_mm_unpackhi_epi16(_mm_setzero_si128(), (in)), 4) - - // wide add - #define dct_wadd(out, a, b) \ - __m128i out##_l = _mm_add_epi32(a##_l, b##_l); \ - __m128i out##_h = _mm_add_epi32(a##_h, b##_h) - - // wide sub - #define dct_wsub(out, a, b) \ - __m128i out##_l = _mm_sub_epi32(a##_l, b##_l); \ - __m128i out##_h = _mm_sub_epi32(a##_h, b##_h) - - // butterfly a/b, add bias, then shift by "s" and pack - #define dct_bfly32o(out0, out1, a,b,bias,s) \ - { \ - __m128i abiased_l = _mm_add_epi32(a##_l, bias); \ - __m128i abiased_h = _mm_add_epi32(a##_h, bias); \ - dct_wadd(sum, abiased, b); \ - dct_wsub(dif, abiased, b); \ - out0 = _mm_packs_epi32(_mm_srai_epi32(sum_l, s), _mm_srai_epi32(sum_h, s)); \ - out1 = _mm_packs_epi32(_mm_srai_epi32(dif_l, s), _mm_srai_epi32(dif_h, s)); \ - } - - // 8-bit interleave step (for transposes) - #define dct_interleave8(a, b) \ - tmp = a; \ - a = _mm_unpacklo_epi8(a, b); \ - b = _mm_unpackhi_epi8(tmp, b) - - // 16-bit interleave step (for transposes) - #define dct_interleave16(a, b) \ - tmp = a; \ - a = _mm_unpacklo_epi16(a, b); \ - b = _mm_unpackhi_epi16(tmp, b) - - #define dct_pass(bias,shift) \ - { \ - /* even part */ \ - dct_rot(t2e,t3e, row2,row6, rot0_0,rot0_1); \ - __m128i sum04 = _mm_add_epi16(row0, row4); \ - __m128i dif04 = _mm_sub_epi16(row0, row4); \ - dct_widen(t0e, sum04); \ - dct_widen(t1e, dif04); \ - dct_wadd(x0, t0e, t3e); \ - dct_wsub(x3, t0e, t3e); \ - dct_wadd(x1, t1e, t2e); \ - dct_wsub(x2, t1e, t2e); \ - /* odd part */ \ - dct_rot(y0o,y2o, row7,row3, rot2_0,rot2_1); \ - dct_rot(y1o,y3o, row5,row1, rot3_0,rot3_1); \ - __m128i sum17 = _mm_add_epi16(row1, row7); \ - __m128i sum35 = _mm_add_epi16(row3, row5); \ - dct_rot(y4o,y5o, sum17,sum35, rot1_0,rot1_1); \ - dct_wadd(x4, y0o, y4o); \ - dct_wadd(x5, y1o, y5o); \ - dct_wadd(x6, y2o, y5o); \ - dct_wadd(x7, y3o, y4o); \ - dct_bfly32o(row0,row7, x0,x7,bias,shift); \ - dct_bfly32o(row1,row6, x1,x6,bias,shift); \ - dct_bfly32o(row2,row5, x2,x5,bias,shift); \ - dct_bfly32o(row3,row4, x3,x4,bias,shift); \ - } - - __m128i rot0_0 = dct_const(stbi__f2f(0.5411961f), stbi__f2f(0.5411961f) + stbi__f2f(-1.847759065f)); - __m128i rot0_1 = dct_const(stbi__f2f(0.5411961f) + stbi__f2f( 0.765366865f), stbi__f2f(0.5411961f)); - __m128i rot1_0 = dct_const(stbi__f2f(1.175875602f) + stbi__f2f(-0.899976223f), stbi__f2f(1.175875602f)); - __m128i rot1_1 = dct_const(stbi__f2f(1.175875602f), stbi__f2f(1.175875602f) + stbi__f2f(-2.562915447f)); - __m128i rot2_0 = dct_const(stbi__f2f(-1.961570560f) + stbi__f2f( 0.298631336f), stbi__f2f(-1.961570560f)); - __m128i rot2_1 = dct_const(stbi__f2f(-1.961570560f), stbi__f2f(-1.961570560f) + stbi__f2f( 3.072711026f)); - __m128i rot3_0 = dct_const(stbi__f2f(-0.390180644f) + stbi__f2f( 2.053119869f), stbi__f2f(-0.390180644f)); - __m128i rot3_1 = dct_const(stbi__f2f(-0.390180644f), stbi__f2f(-0.390180644f) + stbi__f2f( 1.501321110f)); - - // rounding biases in column/row passes, see stbi__idct_block for explanation. - __m128i bias_0 = _mm_set1_epi32(512); - __m128i bias_1 = _mm_set1_epi32(65536 + (128<<17)); - - // load - row0 = _mm_load_si128((const __m128i *) (data + 0*8)); - row1 = _mm_load_si128((const __m128i *) (data + 1*8)); - row2 = _mm_load_si128((const __m128i *) (data + 2*8)); - row3 = _mm_load_si128((const __m128i *) (data + 3*8)); - row4 = _mm_load_si128((const __m128i *) (data + 4*8)); - row5 = _mm_load_si128((const __m128i *) (data + 5*8)); - row6 = _mm_load_si128((const __m128i *) (data + 6*8)); - row7 = _mm_load_si128((const __m128i *) (data + 7*8)); - - // column pass - dct_pass(bias_0, 10); - - { - // 16bit 8x8 transpose pass 1 - dct_interleave16(row0, row4); - dct_interleave16(row1, row5); - dct_interleave16(row2, row6); - dct_interleave16(row3, row7); - - // transpose pass 2 - dct_interleave16(row0, row2); - dct_interleave16(row1, row3); - dct_interleave16(row4, row6); - dct_interleave16(row5, row7); - - // transpose pass 3 - dct_interleave16(row0, row1); - dct_interleave16(row2, row3); - dct_interleave16(row4, row5); - dct_interleave16(row6, row7); - } - - // row pass - dct_pass(bias_1, 17); - - { - // pack - __m128i p0 = _mm_packus_epi16(row0, row1); // a0a1a2a3...a7b0b1b2b3...b7 - __m128i p1 = _mm_packus_epi16(row2, row3); - __m128i p2 = _mm_packus_epi16(row4, row5); - __m128i p3 = _mm_packus_epi16(row6, row7); - - // 8bit 8x8 transpose pass 1 - dct_interleave8(p0, p2); // a0e0a1e1... - dct_interleave8(p1, p3); // c0g0c1g1... - - // transpose pass 2 - dct_interleave8(p0, p1); // a0c0e0g0... - dct_interleave8(p2, p3); // b0d0f0h0... - - // transpose pass 3 - dct_interleave8(p0, p2); // a0b0c0d0... - dct_interleave8(p1, p3); // a4b4c4d4... - - // store - _mm_storel_epi64((__m128i *) out, p0); out += out_stride; - _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p0, 0x4e)); out += out_stride; - _mm_storel_epi64((__m128i *) out, p2); out += out_stride; - _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p2, 0x4e)); out += out_stride; - _mm_storel_epi64((__m128i *) out, p1); out += out_stride; - _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p1, 0x4e)); out += out_stride; - _mm_storel_epi64((__m128i *) out, p3); out += out_stride; - _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p3, 0x4e)); - } - -#undef dct_const -#undef dct_rot -#undef dct_widen -#undef dct_wadd -#undef dct_wsub -#undef dct_bfly32o -#undef dct_interleave8 -#undef dct_interleave16 -#undef dct_pass -} - -#endif // STBI_SSE2 - -#ifdef STBI_NEON - -// NEON integer IDCT. should produce bit-identical -// results to the generic C version. -static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) -{ - int16x8_t row0, row1, row2, row3, row4, row5, row6, row7; - - int16x4_t rot0_0 = vdup_n_s16(stbi__f2f(0.5411961f)); - int16x4_t rot0_1 = vdup_n_s16(stbi__f2f(-1.847759065f)); - int16x4_t rot0_2 = vdup_n_s16(stbi__f2f( 0.765366865f)); - int16x4_t rot1_0 = vdup_n_s16(stbi__f2f( 1.175875602f)); - int16x4_t rot1_1 = vdup_n_s16(stbi__f2f(-0.899976223f)); - int16x4_t rot1_2 = vdup_n_s16(stbi__f2f(-2.562915447f)); - int16x4_t rot2_0 = vdup_n_s16(stbi__f2f(-1.961570560f)); - int16x4_t rot2_1 = vdup_n_s16(stbi__f2f(-0.390180644f)); - int16x4_t rot3_0 = vdup_n_s16(stbi__f2f( 0.298631336f)); - int16x4_t rot3_1 = vdup_n_s16(stbi__f2f( 2.053119869f)); - int16x4_t rot3_2 = vdup_n_s16(stbi__f2f( 3.072711026f)); - int16x4_t rot3_3 = vdup_n_s16(stbi__f2f( 1.501321110f)); - -#define dct_long_mul(out, inq, coeff) \ - int32x4_t out##_l = vmull_s16(vget_low_s16(inq), coeff); \ - int32x4_t out##_h = vmull_s16(vget_high_s16(inq), coeff) - -#define dct_long_mac(out, acc, inq, coeff) \ - int32x4_t out##_l = vmlal_s16(acc##_l, vget_low_s16(inq), coeff); \ - int32x4_t out##_h = vmlal_s16(acc##_h, vget_high_s16(inq), coeff) - -#define dct_widen(out, inq) \ - int32x4_t out##_l = vshll_n_s16(vget_low_s16(inq), 12); \ - int32x4_t out##_h = vshll_n_s16(vget_high_s16(inq), 12) - -// wide add -#define dct_wadd(out, a, b) \ - int32x4_t out##_l = vaddq_s32(a##_l, b##_l); \ - int32x4_t out##_h = vaddq_s32(a##_h, b##_h) - -// wide sub -#define dct_wsub(out, a, b) \ - int32x4_t out##_l = vsubq_s32(a##_l, b##_l); \ - int32x4_t out##_h = vsubq_s32(a##_h, b##_h) - -// butterfly a/b, then shift using "shiftop" by "s" and pack -#define dct_bfly32o(out0,out1, a,b,shiftop,s) \ - { \ - dct_wadd(sum, a, b); \ - dct_wsub(dif, a, b); \ - out0 = vcombine_s16(shiftop(sum_l, s), shiftop(sum_h, s)); \ - out1 = vcombine_s16(shiftop(dif_l, s), shiftop(dif_h, s)); \ - } - -#define dct_pass(shiftop, shift) \ - { \ - /* even part */ \ - int16x8_t sum26 = vaddq_s16(row2, row6); \ - dct_long_mul(p1e, sum26, rot0_0); \ - dct_long_mac(t2e, p1e, row6, rot0_1); \ - dct_long_mac(t3e, p1e, row2, rot0_2); \ - int16x8_t sum04 = vaddq_s16(row0, row4); \ - int16x8_t dif04 = vsubq_s16(row0, row4); \ - dct_widen(t0e, sum04); \ - dct_widen(t1e, dif04); \ - dct_wadd(x0, t0e, t3e); \ - dct_wsub(x3, t0e, t3e); \ - dct_wadd(x1, t1e, t2e); \ - dct_wsub(x2, t1e, t2e); \ - /* odd part */ \ - int16x8_t sum15 = vaddq_s16(row1, row5); \ - int16x8_t sum17 = vaddq_s16(row1, row7); \ - int16x8_t sum35 = vaddq_s16(row3, row5); \ - int16x8_t sum37 = vaddq_s16(row3, row7); \ - int16x8_t sumodd = vaddq_s16(sum17, sum35); \ - dct_long_mul(p5o, sumodd, rot1_0); \ - dct_long_mac(p1o, p5o, sum17, rot1_1); \ - dct_long_mac(p2o, p5o, sum35, rot1_2); \ - dct_long_mul(p3o, sum37, rot2_0); \ - dct_long_mul(p4o, sum15, rot2_1); \ - dct_wadd(sump13o, p1o, p3o); \ - dct_wadd(sump24o, p2o, p4o); \ - dct_wadd(sump23o, p2o, p3o); \ - dct_wadd(sump14o, p1o, p4o); \ - dct_long_mac(x4, sump13o, row7, rot3_0); \ - dct_long_mac(x5, sump24o, row5, rot3_1); \ - dct_long_mac(x6, sump23o, row3, rot3_2); \ - dct_long_mac(x7, sump14o, row1, rot3_3); \ - dct_bfly32o(row0,row7, x0,x7,shiftop,shift); \ - dct_bfly32o(row1,row6, x1,x6,shiftop,shift); \ - dct_bfly32o(row2,row5, x2,x5,shiftop,shift); \ - dct_bfly32o(row3,row4, x3,x4,shiftop,shift); \ - } - - // load - row0 = vld1q_s16(data + 0*8); - row1 = vld1q_s16(data + 1*8); - row2 = vld1q_s16(data + 2*8); - row3 = vld1q_s16(data + 3*8); - row4 = vld1q_s16(data + 4*8); - row5 = vld1q_s16(data + 5*8); - row6 = vld1q_s16(data + 6*8); - row7 = vld1q_s16(data + 7*8); - - // add DC bias - row0 = vaddq_s16(row0, vsetq_lane_s16(1024, vdupq_n_s16(0), 0)); - - // column pass - dct_pass(vrshrn_n_s32, 10); - - // 16bit 8x8 transpose - { -// these three map to a single VTRN.16, VTRN.32, and VSWP, respectively. -// whether compilers actually get this is another story, sadly. -#define dct_trn16(x, y) { int16x8x2_t t = vtrnq_s16(x, y); x = t.val[0]; y = t.val[1]; } -#define dct_trn32(x, y) { int32x4x2_t t = vtrnq_s32(vreinterpretq_s32_s16(x), vreinterpretq_s32_s16(y)); x = vreinterpretq_s16_s32(t.val[0]); y = vreinterpretq_s16_s32(t.val[1]); } -#define dct_trn64(x, y) { int16x8_t x0 = x; int16x8_t y0 = y; x = vcombine_s16(vget_low_s16(x0), vget_low_s16(y0)); y = vcombine_s16(vget_high_s16(x0), vget_high_s16(y0)); } - - // pass 1 - dct_trn16(row0, row1); // a0b0a2b2a4b4a6b6 - dct_trn16(row2, row3); - dct_trn16(row4, row5); - dct_trn16(row6, row7); - - // pass 2 - dct_trn32(row0, row2); // a0b0c0d0a4b4c4d4 - dct_trn32(row1, row3); - dct_trn32(row4, row6); - dct_trn32(row5, row7); - - // pass 3 - dct_trn64(row0, row4); // a0b0c0d0e0f0g0h0 - dct_trn64(row1, row5); - dct_trn64(row2, row6); - dct_trn64(row3, row7); - -#undef dct_trn16 -#undef dct_trn32 -#undef dct_trn64 - } - - // row pass - // vrshrn_n_s32 only supports shifts up to 16, we need - // 17. so do a non-rounding shift of 16 first then follow - // up with a rounding shift by 1. - dct_pass(vshrn_n_s32, 16); - - { - // pack and round - uint8x8_t p0 = vqrshrun_n_s16(row0, 1); - uint8x8_t p1 = vqrshrun_n_s16(row1, 1); - uint8x8_t p2 = vqrshrun_n_s16(row2, 1); - uint8x8_t p3 = vqrshrun_n_s16(row3, 1); - uint8x8_t p4 = vqrshrun_n_s16(row4, 1); - uint8x8_t p5 = vqrshrun_n_s16(row5, 1); - uint8x8_t p6 = vqrshrun_n_s16(row6, 1); - uint8x8_t p7 = vqrshrun_n_s16(row7, 1); - - // again, these can translate into one instruction, but often don't. -#define dct_trn8_8(x, y) { uint8x8x2_t t = vtrn_u8(x, y); x = t.val[0]; y = t.val[1]; } -#define dct_trn8_16(x, y) { uint16x4x2_t t = vtrn_u16(vreinterpret_u16_u8(x), vreinterpret_u16_u8(y)); x = vreinterpret_u8_u16(t.val[0]); y = vreinterpret_u8_u16(t.val[1]); } -#define dct_trn8_32(x, y) { uint32x2x2_t t = vtrn_u32(vreinterpret_u32_u8(x), vreinterpret_u32_u8(y)); x = vreinterpret_u8_u32(t.val[0]); y = vreinterpret_u8_u32(t.val[1]); } - - // sadly can't use interleaved stores here since we only write - // 8 bytes to each scan line! - - // 8x8 8-bit transpose pass 1 - dct_trn8_8(p0, p1); - dct_trn8_8(p2, p3); - dct_trn8_8(p4, p5); - dct_trn8_8(p6, p7); - - // pass 2 - dct_trn8_16(p0, p2); - dct_trn8_16(p1, p3); - dct_trn8_16(p4, p6); - dct_trn8_16(p5, p7); - - // pass 3 - dct_trn8_32(p0, p4); - dct_trn8_32(p1, p5); - dct_trn8_32(p2, p6); - dct_trn8_32(p3, p7); - - // store - vst1_u8(out, p0); out += out_stride; - vst1_u8(out, p1); out += out_stride; - vst1_u8(out, p2); out += out_stride; - vst1_u8(out, p3); out += out_stride; - vst1_u8(out, p4); out += out_stride; - vst1_u8(out, p5); out += out_stride; - vst1_u8(out, p6); out += out_stride; - vst1_u8(out, p7); - -#undef dct_trn8_8 -#undef dct_trn8_16 -#undef dct_trn8_32 - } - -#undef dct_long_mul -#undef dct_long_mac -#undef dct_widen -#undef dct_wadd -#undef dct_wsub -#undef dct_bfly32o -#undef dct_pass -} - -#endif // STBI_NEON - -#define STBI__MARKER_none 0xff -// if there's a pending marker from the entropy stream, return that -// otherwise, fetch from the stream and get a marker. if there's no -// marker, return 0xff, which is never a valid marker value -static stbi_uc stbi__get_marker(stbi__jpeg *j) -{ - stbi_uc x; - if (j->marker != STBI__MARKER_none) { x = j->marker; j->marker = STBI__MARKER_none; return x; } - x = stbi__get8(j->s); - if (x != 0xff) return STBI__MARKER_none; - while (x == 0xff) - x = stbi__get8(j->s); // consume repeated 0xff fill bytes - return x; -} - -// in each scan, we'll have scan_n components, and the order -// of the components is specified by order[] -#define STBI__RESTART(x) ((x) >= 0xd0 && (x) <= 0xd7) - -// after a restart interval, stbi__jpeg_reset the entropy decoder and -// the dc prediction -static void stbi__jpeg_reset(stbi__jpeg *j) -{ - j->code_bits = 0; - j->code_buffer = 0; - j->nomore = 0; - j->img_comp[0].dc_pred = j->img_comp[1].dc_pred = j->img_comp[2].dc_pred = j->img_comp[3].dc_pred = 0; - j->marker = STBI__MARKER_none; - j->todo = j->restart_interval ? j->restart_interval : 0x7fffffff; - j->eob_run = 0; - // no more than 1<<31 MCUs if no restart_interal? that's plenty safe, - // since we don't even allow 1<<30 pixels -} - -static int stbi__parse_entropy_coded_data(stbi__jpeg *z) -{ - stbi__jpeg_reset(z); - if (!z->progressive) { - if (z->scan_n == 1) { - int i,j; - STBI_SIMD_ALIGN(short, data[64]); - int n = z->order[0]; - // non-interleaved data, we just need to process one block at a time, - // in trivial scanline order - // number of blocks to do just depends on how many actual "pixels" this - // component has, independent of interleaved MCU blocking and such - int w = (z->img_comp[n].x+7) >> 3; - int h = (z->img_comp[n].y+7) >> 3; - for (j=0; j < h; ++j) { - for (i=0; i < w; ++i) { - int ha = z->img_comp[n].ha; - if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; - z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data); - // every data block is an MCU, so countdown the restart interval - if (--z->todo <= 0) { - if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); - // if it's NOT a restart, then just bail, so we get corrupt data - // rather than no data - if (!STBI__RESTART(z->marker)) return 1; - stbi__jpeg_reset(z); - } - } - } - return 1; - } else { // interleaved - int i,j,k,x,y; - STBI_SIMD_ALIGN(short, data[64]); - for (j=0; j < z->img_mcu_y; ++j) { - for (i=0; i < z->img_mcu_x; ++i) { - // scan an interleaved mcu... process scan_n components in order - for (k=0; k < z->scan_n; ++k) { - int n = z->order[k]; - // scan out an mcu's worth of this component; that's just determined - // by the basic H and V specified for the component - for (y=0; y < z->img_comp[n].v; ++y) { - for (x=0; x < z->img_comp[n].h; ++x) { - int x2 = (i*z->img_comp[n].h + x)*8; - int y2 = (j*z->img_comp[n].v + y)*8; - int ha = z->img_comp[n].ha; - if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; - z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*y2+x2, z->img_comp[n].w2, data); - } - } - } - // after all interleaved components, that's an interleaved MCU, - // so now count down the restart interval - if (--z->todo <= 0) { - if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); - if (!STBI__RESTART(z->marker)) return 1; - stbi__jpeg_reset(z); - } - } - } - return 1; - } - } else { - if (z->scan_n == 1) { - int i,j; - int n = z->order[0]; - // non-interleaved data, we just need to process one block at a time, - // in trivial scanline order - // number of blocks to do just depends on how many actual "pixels" this - // component has, independent of interleaved MCU blocking and such - int w = (z->img_comp[n].x+7) >> 3; - int h = (z->img_comp[n].y+7) >> 3; - for (j=0; j < h; ++j) { - for (i=0; i < w; ++i) { - short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); - if (z->spec_start == 0) { - if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) - return 0; - } else { - int ha = z->img_comp[n].ha; - if (!stbi__jpeg_decode_block_prog_ac(z, data, &z->huff_ac[ha], z->fast_ac[ha])) - return 0; - } - // every data block is an MCU, so countdown the restart interval - if (--z->todo <= 0) { - if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); - if (!STBI__RESTART(z->marker)) return 1; - stbi__jpeg_reset(z); - } - } - } - return 1; - } else { // interleaved - int i,j,k,x,y; - for (j=0; j < z->img_mcu_y; ++j) { - for (i=0; i < z->img_mcu_x; ++i) { - // scan an interleaved mcu... process scan_n components in order - for (k=0; k < z->scan_n; ++k) { - int n = z->order[k]; - // scan out an mcu's worth of this component; that's just determined - // by the basic H and V specified for the component - for (y=0; y < z->img_comp[n].v; ++y) { - for (x=0; x < z->img_comp[n].h; ++x) { - int x2 = (i*z->img_comp[n].h + x); - int y2 = (j*z->img_comp[n].v + y); - short *data = z->img_comp[n].coeff + 64 * (x2 + y2 * z->img_comp[n].coeff_w); - if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) - return 0; - } - } - } - // after all interleaved components, that's an interleaved MCU, - // so now count down the restart interval - if (--z->todo <= 0) { - if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); - if (!STBI__RESTART(z->marker)) return 1; - stbi__jpeg_reset(z); - } - } - } - return 1; - } - } -} - -static void stbi__jpeg_dequantize(short *data, stbi__uint16 *dequant) -{ - int i; - for (i=0; i < 64; ++i) - data[i] *= dequant[i]; -} - -static void stbi__jpeg_finish(stbi__jpeg *z) -{ - if (z->progressive) { - // dequantize and idct the data - int i,j,n; - for (n=0; n < z->s->img_n; ++n) { - int w = (z->img_comp[n].x+7) >> 3; - int h = (z->img_comp[n].y+7) >> 3; - for (j=0; j < h; ++j) { - for (i=0; i < w; ++i) { - short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); - stbi__jpeg_dequantize(data, z->dequant[z->img_comp[n].tq]); - z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data); - } - } - } - } -} - -static int stbi__process_marker(stbi__jpeg *z, int m) -{ - int L; - switch (m) { - case STBI__MARKER_none: // no marker found - return stbi__err("expected marker","Corrupt JPEG"); - - case 0xDD: // DRI - specify restart interval - if (stbi__get16be(z->s) != 4) return stbi__err("bad DRI len","Corrupt JPEG"); - z->restart_interval = stbi__get16be(z->s); - return 1; - - case 0xDB: // DQT - define quantization table - L = stbi__get16be(z->s)-2; - while (L > 0) { - int q = stbi__get8(z->s); - int p = q >> 4, sixteen = (p != 0); - int t = q & 15,i; - if (p != 0 && p != 1) return stbi__err("bad DQT type","Corrupt JPEG"); - if (t > 3) return stbi__err("bad DQT table","Corrupt JPEG"); - - for (i=0; i < 64; ++i) - z->dequant[t][stbi__jpeg_dezigzag[i]] = (stbi__uint16)(sixteen ? stbi__get16be(z->s) : stbi__get8(z->s)); - L -= (sixteen ? 129 : 65); - } - return L==0; - - case 0xC4: // DHT - define huffman table - L = stbi__get16be(z->s)-2; - while (L > 0) { - stbi_uc *v; - int sizes[16],i,n=0; - int q = stbi__get8(z->s); - int tc = q >> 4; - int th = q & 15; - if (tc > 1 || th > 3) return stbi__err("bad DHT header","Corrupt JPEG"); - for (i=0; i < 16; ++i) { - sizes[i] = stbi__get8(z->s); - n += sizes[i]; - } - L -= 17; - if (tc == 0) { - if (!stbi__build_huffman(z->huff_dc+th, sizes)) return 0; - v = z->huff_dc[th].values; - } else { - if (!stbi__build_huffman(z->huff_ac+th, sizes)) return 0; - v = z->huff_ac[th].values; - } - for (i=0; i < n; ++i) - v[i] = stbi__get8(z->s); - if (tc != 0) - stbi__build_fast_ac(z->fast_ac[th], z->huff_ac + th); - L -= n; - } - return L==0; - } - - // check for comment block or APP blocks - if ((m >= 0xE0 && m <= 0xEF) || m == 0xFE) { - L = stbi__get16be(z->s); - if (L < 2) { - if (m == 0xFE) - return stbi__err("bad COM len","Corrupt JPEG"); - else - return stbi__err("bad APP len","Corrupt JPEG"); - } - L -= 2; - - if (m == 0xE0 && L >= 5) { // JFIF APP0 segment - static const unsigned char tag[5] = {'J','F','I','F','\0'}; - int ok = 1; - int i; - for (i=0; i < 5; ++i) - if (stbi__get8(z->s) != tag[i]) - ok = 0; - L -= 5; - if (ok) - z->jfif = 1; - } else if (m == 0xEE && L >= 12) { // Adobe APP14 segment - static const unsigned char tag[6] = {'A','d','o','b','e','\0'}; - int ok = 1; - int i; - for (i=0; i < 6; ++i) - if (stbi__get8(z->s) != tag[i]) - ok = 0; - L -= 6; - if (ok) { - stbi__get8(z->s); // version - stbi__get16be(z->s); // flags0 - stbi__get16be(z->s); // flags1 - z->app14_color_transform = stbi__get8(z->s); // color transform - L -= 6; - } - } - - stbi__skip(z->s, L); - return 1; - } - - return stbi__err("unknown marker","Corrupt JPEG"); -} - -// after we see SOS -static int stbi__process_scan_header(stbi__jpeg *z) -{ - int i; - int Ls = stbi__get16be(z->s); - z->scan_n = stbi__get8(z->s); - if (z->scan_n < 1 || z->scan_n > 4 || z->scan_n > (int) z->s->img_n) return stbi__err("bad SOS component count","Corrupt JPEG"); - if (Ls != 6+2*z->scan_n) return stbi__err("bad SOS len","Corrupt JPEG"); - for (i=0; i < z->scan_n; ++i) { - int id = stbi__get8(z->s), which; - int q = stbi__get8(z->s); - for (which = 0; which < z->s->img_n; ++which) - if (z->img_comp[which].id == id) - break; - if (which == z->s->img_n) return 0; // no match - z->img_comp[which].hd = q >> 4; if (z->img_comp[which].hd > 3) return stbi__err("bad DC huff","Corrupt JPEG"); - z->img_comp[which].ha = q & 15; if (z->img_comp[which].ha > 3) return stbi__err("bad AC huff","Corrupt JPEG"); - z->order[i] = which; - } - - { - int aa; - z->spec_start = stbi__get8(z->s); - z->spec_end = stbi__get8(z->s); // should be 63, but might be 0 - aa = stbi__get8(z->s); - z->succ_high = (aa >> 4); - z->succ_low = (aa & 15); - if (z->progressive) { - if (z->spec_start > 63 || z->spec_end > 63 || z->spec_start > z->spec_end || z->succ_high > 13 || z->succ_low > 13) - return stbi__err("bad SOS", "Corrupt JPEG"); - } else { - if (z->spec_start != 0) return stbi__err("bad SOS","Corrupt JPEG"); - if (z->succ_high != 0 || z->succ_low != 0) return stbi__err("bad SOS","Corrupt JPEG"); - z->spec_end = 63; - } - } - - return 1; -} - -static int stbi__free_jpeg_components(stbi__jpeg *z, int ncomp, int why) -{ - int i; - for (i=0; i < ncomp; ++i) { - if (z->img_comp[i].raw_data) { - STBI_FREE(z->img_comp[i].raw_data); - z->img_comp[i].raw_data = NULL; - z->img_comp[i].data = NULL; - } - if (z->img_comp[i].raw_coeff) { - STBI_FREE(z->img_comp[i].raw_coeff); - z->img_comp[i].raw_coeff = 0; - z->img_comp[i].coeff = 0; - } - if (z->img_comp[i].linebuf) { - STBI_FREE(z->img_comp[i].linebuf); - z->img_comp[i].linebuf = NULL; - } - } - return why; -} - -static int stbi__process_frame_header(stbi__jpeg *z, int scan) -{ - stbi__context *s = z->s; - int Lf,p,i,q, h_max=1,v_max=1,c; - Lf = stbi__get16be(s); if (Lf < 11) return stbi__err("bad SOF len","Corrupt JPEG"); // JPEG - p = stbi__get8(s); if (p != 8) return stbi__err("only 8-bit","JPEG format not supported: 8-bit only"); // JPEG baseline - s->img_y = stbi__get16be(s); if (s->img_y == 0) return stbi__err("no header height", "JPEG format not supported: delayed height"); // Legal, but we don't handle it--but neither does IJG - s->img_x = stbi__get16be(s); if (s->img_x == 0) return stbi__err("0 width","Corrupt JPEG"); // JPEG requires - c = stbi__get8(s); - if (c != 3 && c != 1 && c != 4) return stbi__err("bad component count","Corrupt JPEG"); - s->img_n = c; - for (i=0; i < c; ++i) { - z->img_comp[i].data = NULL; - z->img_comp[i].linebuf = NULL; - } - - if (Lf != 8+3*s->img_n) return stbi__err("bad SOF len","Corrupt JPEG"); - - z->rgb = 0; - for (i=0; i < s->img_n; ++i) { - static const unsigned char rgb[3] = { 'R', 'G', 'B' }; - z->img_comp[i].id = stbi__get8(s); - if (s->img_n == 3 && z->img_comp[i].id == rgb[i]) - ++z->rgb; - q = stbi__get8(s); - z->img_comp[i].h = (q >> 4); if (!z->img_comp[i].h || z->img_comp[i].h > 4) return stbi__err("bad H","Corrupt JPEG"); - z->img_comp[i].v = q & 15; if (!z->img_comp[i].v || z->img_comp[i].v > 4) return stbi__err("bad V","Corrupt JPEG"); - z->img_comp[i].tq = stbi__get8(s); if (z->img_comp[i].tq > 3) return stbi__err("bad TQ","Corrupt JPEG"); - } - - if (scan != STBI__SCAN_load) return 1; - - if (!stbi__mad3sizes_valid(s->img_x, s->img_y, s->img_n, 0)) return stbi__err("too large", "Image too large to decode"); - - for (i=0; i < s->img_n; ++i) { - if (z->img_comp[i].h > h_max) h_max = z->img_comp[i].h; - if (z->img_comp[i].v > v_max) v_max = z->img_comp[i].v; - } - - // compute interleaved mcu info - z->img_h_max = h_max; - z->img_v_max = v_max; - z->img_mcu_w = h_max * 8; - z->img_mcu_h = v_max * 8; - // these sizes can't be more than 17 bits - z->img_mcu_x = (s->img_x + z->img_mcu_w-1) / z->img_mcu_w; - z->img_mcu_y = (s->img_y + z->img_mcu_h-1) / z->img_mcu_h; - - for (i=0; i < s->img_n; ++i) { - // number of effective pixels (e.g. for non-interleaved MCU) - z->img_comp[i].x = (s->img_x * z->img_comp[i].h + h_max-1) / h_max; - z->img_comp[i].y = (s->img_y * z->img_comp[i].v + v_max-1) / v_max; - // to simplify generation, we'll allocate enough memory to decode - // the bogus oversized data from using interleaved MCUs and their - // big blocks (e.g. a 16x16 iMCU on an image of width 33); we won't - // discard the extra data until colorspace conversion - // - // img_mcu_x, img_mcu_y: <=17 bits; comp[i].h and .v are <=4 (checked earlier) - // so these muls can't overflow with 32-bit ints (which we require) - z->img_comp[i].w2 = z->img_mcu_x * z->img_comp[i].h * 8; - z->img_comp[i].h2 = z->img_mcu_y * z->img_comp[i].v * 8; - z->img_comp[i].coeff = 0; - z->img_comp[i].raw_coeff = 0; - z->img_comp[i].linebuf = NULL; - z->img_comp[i].raw_data = stbi__malloc_mad2(z->img_comp[i].w2, z->img_comp[i].h2, 15); - if (z->img_comp[i].raw_data == NULL) - return stbi__free_jpeg_components(z, i+1, stbi__err("outofmem", "Out of memory")); - // align blocks for idct using mmx/sse - z->img_comp[i].data = (stbi_uc*) (((size_t) z->img_comp[i].raw_data + 15) & ~15); - if (z->progressive) { - // w2, h2 are multiples of 8 (see above) - z->img_comp[i].coeff_w = z->img_comp[i].w2 / 8; - z->img_comp[i].coeff_h = z->img_comp[i].h2 / 8; - z->img_comp[i].raw_coeff = stbi__malloc_mad3(z->img_comp[i].w2, z->img_comp[i].h2, sizeof(short), 15); - if (z->img_comp[i].raw_coeff == NULL) - return stbi__free_jpeg_components(z, i+1, stbi__err("outofmem", "Out of memory")); - z->img_comp[i].coeff = (short*) (((size_t) z->img_comp[i].raw_coeff + 15) & ~15); - } - } - - return 1; -} - -// use comparisons since in some cases we handle more than one case (e.g. SOF) -#define stbi__DNL(x) ((x) == 0xdc) -#define stbi__SOI(x) ((x) == 0xd8) -#define stbi__EOI(x) ((x) == 0xd9) -#define stbi__SOF(x) ((x) == 0xc0 || (x) == 0xc1 || (x) == 0xc2) -#define stbi__SOS(x) ((x) == 0xda) - -#define stbi__SOF_progressive(x) ((x) == 0xc2) - -static int stbi__decode_jpeg_header(stbi__jpeg *z, int scan) -{ - int m; - z->jfif = 0; - z->app14_color_transform = -1; // valid values are 0,1,2 - z->marker = STBI__MARKER_none; // initialize cached marker to empty - m = stbi__get_marker(z); - if (!stbi__SOI(m)) return stbi__err("no SOI","Corrupt JPEG"); - if (scan == STBI__SCAN_type) return 1; - m = stbi__get_marker(z); - while (!stbi__SOF(m)) { - if (!stbi__process_marker(z,m)) return 0; - m = stbi__get_marker(z); - while (m == STBI__MARKER_none) { - // some files have extra padding after their blocks, so ok, we'll scan - if (stbi__at_eof(z->s)) return stbi__err("no SOF", "Corrupt JPEG"); - m = stbi__get_marker(z); - } - } - z->progressive = stbi__SOF_progressive(m); - if (!stbi__process_frame_header(z, scan)) return 0; - return 1; -} - -// decode image to YCbCr format -static int stbi__decode_jpeg_image(stbi__jpeg *j) -{ - int m; - for (m = 0; m < 4; m++) { - j->img_comp[m].raw_data = NULL; - j->img_comp[m].raw_coeff = NULL; - } - j->restart_interval = 0; - if (!stbi__decode_jpeg_header(j, STBI__SCAN_load)) return 0; - m = stbi__get_marker(j); - while (!stbi__EOI(m)) { - if (stbi__SOS(m)) { - if (!stbi__process_scan_header(j)) return 0; - if (!stbi__parse_entropy_coded_data(j)) return 0; - if (j->marker == STBI__MARKER_none ) { - // handle 0s at the end of image data from IP Kamera 9060 - while (!stbi__at_eof(j->s)) { - int x = stbi__get8(j->s); - if (x == 255) { - j->marker = stbi__get8(j->s); - break; - } - } - // if we reach eof without hitting a marker, stbi__get_marker() below will fail and we'll eventually return 0 - } - } else if (stbi__DNL(m)) { - int Ld = stbi__get16be(j->s); - stbi__uint32 NL = stbi__get16be(j->s); - if (Ld != 4) return stbi__err("bad DNL len", "Corrupt JPEG"); - if (NL != j->s->img_y) return stbi__err("bad DNL height", "Corrupt JPEG"); - } else { - if (!stbi__process_marker(j, m)) return 0; - } - m = stbi__get_marker(j); - } - if (j->progressive) - stbi__jpeg_finish(j); - return 1; -} - -// static jfif-centered resampling (across block boundaries) - -typedef stbi_uc *(*resample_row_func)(stbi_uc *out, stbi_uc *in0, stbi_uc *in1, - int w, int hs); - -#define stbi__div4(x) ((stbi_uc) ((x) >> 2)) - -static stbi_uc *resample_row_1(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) -{ - STBI_NOTUSED(out); - STBI_NOTUSED(in_far); - STBI_NOTUSED(w); - STBI_NOTUSED(hs); - return in_near; -} - -static stbi_uc* stbi__resample_row_v_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) -{ - // need to generate two samples vertically for every one in input - int i; - STBI_NOTUSED(hs); - for (i=0; i < w; ++i) - out[i] = stbi__div4(3*in_near[i] + in_far[i] + 2); - return out; -} - -static stbi_uc* stbi__resample_row_h_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) -{ - // need to generate two samples horizontally for every one in input - int i; - stbi_uc *input = in_near; - - if (w == 1) { - // if only one sample, can't do any interpolation - out[0] = out[1] = input[0]; - return out; - } - - out[0] = input[0]; - out[1] = stbi__div4(input[0]*3 + input[1] + 2); - for (i=1; i < w-1; ++i) { - int n = 3*input[i]+2; - out[i*2+0] = stbi__div4(n+input[i-1]); - out[i*2+1] = stbi__div4(n+input[i+1]); - } - out[i*2+0] = stbi__div4(input[w-2]*3 + input[w-1] + 2); - out[i*2+1] = input[w-1]; - - STBI_NOTUSED(in_far); - STBI_NOTUSED(hs); - - return out; -} - -#define stbi__div16(x) ((stbi_uc) ((x) >> 4)) - -static stbi_uc *stbi__resample_row_hv_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) -{ - // need to generate 2x2 samples for every one in input - int i,t0,t1; - if (w == 1) { - out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2); - return out; - } - - t1 = 3*in_near[0] + in_far[0]; - out[0] = stbi__div4(t1+2); - for (i=1; i < w; ++i) { - t0 = t1; - t1 = 3*in_near[i]+in_far[i]; - out[i*2-1] = stbi__div16(3*t0 + t1 + 8); - out[i*2 ] = stbi__div16(3*t1 + t0 + 8); - } - out[w*2-1] = stbi__div4(t1+2); - - STBI_NOTUSED(hs); - - return out; -} - -#if defined(STBI_SSE2) || defined(STBI_NEON) -static stbi_uc *stbi__resample_row_hv_2_simd(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) -{ - // need to generate 2x2 samples for every one in input - int i=0,t0,t1; - - if (w == 1) { - out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2); - return out; - } - - t1 = 3*in_near[0] + in_far[0]; - // process groups of 8 pixels for as long as we can. - // note we can't handle the last pixel in a row in this loop - // because we need to handle the filter boundary conditions. - for (; i < ((w-1) & ~7); i += 8) { -#if defined(STBI_SSE2) - // load and perform the vertical filtering pass - // this uses 3*x + y = 4*x + (y - x) - __m128i zero = _mm_setzero_si128(); - __m128i farb = _mm_loadl_epi64((__m128i *) (in_far + i)); - __m128i nearb = _mm_loadl_epi64((__m128i *) (in_near + i)); - __m128i farw = _mm_unpacklo_epi8(farb, zero); - __m128i nearw = _mm_unpacklo_epi8(nearb, zero); - __m128i diff = _mm_sub_epi16(farw, nearw); - __m128i nears = _mm_slli_epi16(nearw, 2); - __m128i curr = _mm_add_epi16(nears, diff); // current row - - // horizontal filter works the same based on shifted vers of current - // row. "prev" is current row shifted right by 1 pixel; we need to - // insert the previous pixel value (from t1). - // "next" is current row shifted left by 1 pixel, with first pixel - // of next block of 8 pixels added in. - __m128i prv0 = _mm_slli_si128(curr, 2); - __m128i nxt0 = _mm_srli_si128(curr, 2); - __m128i prev = _mm_insert_epi16(prv0, t1, 0); - __m128i next = _mm_insert_epi16(nxt0, 3*in_near[i+8] + in_far[i+8], 7); - - // horizontal filter, polyphase implementation since it's convenient: - // even pixels = 3*cur + prev = cur*4 + (prev - cur) - // odd pixels = 3*cur + next = cur*4 + (next - cur) - // note the shared term. - __m128i bias = _mm_set1_epi16(8); - __m128i curs = _mm_slli_epi16(curr, 2); - __m128i prvd = _mm_sub_epi16(prev, curr); - __m128i nxtd = _mm_sub_epi16(next, curr); - __m128i curb = _mm_add_epi16(curs, bias); - __m128i even = _mm_add_epi16(prvd, curb); - __m128i odd = _mm_add_epi16(nxtd, curb); - - // interleave even and odd pixels, then undo scaling. - __m128i int0 = _mm_unpacklo_epi16(even, odd); - __m128i int1 = _mm_unpackhi_epi16(even, odd); - __m128i de0 = _mm_srli_epi16(int0, 4); - __m128i de1 = _mm_srli_epi16(int1, 4); - - // pack and write output - __m128i outv = _mm_packus_epi16(de0, de1); - _mm_storeu_si128((__m128i *) (out + i*2), outv); -#elif defined(STBI_NEON) - // load and perform the vertical filtering pass - // this uses 3*x + y = 4*x + (y - x) - uint8x8_t farb = vld1_u8(in_far + i); - uint8x8_t nearb = vld1_u8(in_near + i); - int16x8_t diff = vreinterpretq_s16_u16(vsubl_u8(farb, nearb)); - int16x8_t nears = vreinterpretq_s16_u16(vshll_n_u8(nearb, 2)); - int16x8_t curr = vaddq_s16(nears, diff); // current row - - // horizontal filter works the same based on shifted vers of current - // row. "prev" is current row shifted right by 1 pixel; we need to - // insert the previous pixel value (from t1). - // "next" is current row shifted left by 1 pixel, with first pixel - // of next block of 8 pixels added in. - int16x8_t prv0 = vextq_s16(curr, curr, 7); - int16x8_t nxt0 = vextq_s16(curr, curr, 1); - int16x8_t prev = vsetq_lane_s16(t1, prv0, 0); - int16x8_t next = vsetq_lane_s16(3*in_near[i+8] + in_far[i+8], nxt0, 7); - - // horizontal filter, polyphase implementation since it's convenient: - // even pixels = 3*cur + prev = cur*4 + (prev - cur) - // odd pixels = 3*cur + next = cur*4 + (next - cur) - // note the shared term. - int16x8_t curs = vshlq_n_s16(curr, 2); - int16x8_t prvd = vsubq_s16(prev, curr); - int16x8_t nxtd = vsubq_s16(next, curr); - int16x8_t even = vaddq_s16(curs, prvd); - int16x8_t odd = vaddq_s16(curs, nxtd); - - // undo scaling and round, then store with even/odd phases interleaved - uint8x8x2_t o; - o.val[0] = vqrshrun_n_s16(even, 4); - o.val[1] = vqrshrun_n_s16(odd, 4); - vst2_u8(out + i*2, o); -#endif - - // "previous" value for next iter - t1 = 3*in_near[i+7] + in_far[i+7]; - } - - t0 = t1; - t1 = 3*in_near[i] + in_far[i]; - out[i*2] = stbi__div16(3*t1 + t0 + 8); - - for (++i; i < w; ++i) { - t0 = t1; - t1 = 3*in_near[i]+in_far[i]; - out[i*2-1] = stbi__div16(3*t0 + t1 + 8); - out[i*2 ] = stbi__div16(3*t1 + t0 + 8); - } - out[w*2-1] = stbi__div4(t1+2); - - STBI_NOTUSED(hs); - - return out; -} -#endif - -static stbi_uc *stbi__resample_row_generic(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) -{ - // resample with nearest-neighbor - int i,j; - STBI_NOTUSED(in_far); - for (i=0; i < w; ++i) - for (j=0; j < hs; ++j) - out[i*hs+j] = in_near[i]; - return out; -} - -// this is a reduced-precision calculation of YCbCr-to-RGB introduced -// to make sure the code produces the same results in both SIMD and scalar -#define stbi__float2fixed(x) (((int) ((x) * 4096.0f + 0.5f)) << 8) -static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step) -{ - int i; - for (i=0; i < count; ++i) { - int y_fixed = (y[i] << 20) + (1<<19); // rounding - int r,g,b; - int cr = pcr[i] - 128; - int cb = pcb[i] - 128; - r = y_fixed + cr* stbi__float2fixed(1.40200f); - g = y_fixed + (cr*-stbi__float2fixed(0.71414f)) + ((cb*-stbi__float2fixed(0.34414f)) & 0xffff0000); - b = y_fixed + cb* stbi__float2fixed(1.77200f); - r >>= 20; - g >>= 20; - b >>= 20; - if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } - if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } - if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } - out[0] = (stbi_uc)r; - out[1] = (stbi_uc)g; - out[2] = (stbi_uc)b; - out[3] = 255; - out += step; - } -} - -#if defined(STBI_SSE2) || defined(STBI_NEON) -static void stbi__YCbCr_to_RGB_simd(stbi_uc *out, stbi_uc const *y, stbi_uc const *pcb, stbi_uc const *pcr, int count, int step) -{ - int i = 0; - -#ifdef STBI_SSE2 - // step == 3 is pretty ugly on the final interleave, and i'm not convinced - // it's useful in practice (you wouldn't use it for textures, for example). - // so just accelerate step == 4 case. - if (step == 4) { - // this is a fairly straightforward implementation and not super-optimized. - __m128i signflip = _mm_set1_epi8(-0x80); - __m128i cr_const0 = _mm_set1_epi16( (short) ( 1.40200f*4096.0f+0.5f)); - __m128i cr_const1 = _mm_set1_epi16( - (short) ( 0.71414f*4096.0f+0.5f)); - __m128i cb_const0 = _mm_set1_epi16( - (short) ( 0.34414f*4096.0f+0.5f)); - __m128i cb_const1 = _mm_set1_epi16( (short) ( 1.77200f*4096.0f+0.5f)); - __m128i y_bias = _mm_set1_epi8((char) (unsigned char) 128); - __m128i xw = _mm_set1_epi16(255); // alpha channel - - for (; i+7 < count; i += 8) { - // load - __m128i y_bytes = _mm_loadl_epi64((__m128i *) (y+i)); - __m128i cr_bytes = _mm_loadl_epi64((__m128i *) (pcr+i)); - __m128i cb_bytes = _mm_loadl_epi64((__m128i *) (pcb+i)); - __m128i cr_biased = _mm_xor_si128(cr_bytes, signflip); // -128 - __m128i cb_biased = _mm_xor_si128(cb_bytes, signflip); // -128 - - // unpack to short (and left-shift cr, cb by 8) - __m128i yw = _mm_unpacklo_epi8(y_bias, y_bytes); - __m128i crw = _mm_unpacklo_epi8(_mm_setzero_si128(), cr_biased); - __m128i cbw = _mm_unpacklo_epi8(_mm_setzero_si128(), cb_biased); - - // color transform - __m128i yws = _mm_srli_epi16(yw, 4); - __m128i cr0 = _mm_mulhi_epi16(cr_const0, crw); - __m128i cb0 = _mm_mulhi_epi16(cb_const0, cbw); - __m128i cb1 = _mm_mulhi_epi16(cbw, cb_const1); - __m128i cr1 = _mm_mulhi_epi16(crw, cr_const1); - __m128i rws = _mm_add_epi16(cr0, yws); - __m128i gwt = _mm_add_epi16(cb0, yws); - __m128i bws = _mm_add_epi16(yws, cb1); - __m128i gws = _mm_add_epi16(gwt, cr1); - - // descale - __m128i rw = _mm_srai_epi16(rws, 4); - __m128i bw = _mm_srai_epi16(bws, 4); - __m128i gw = _mm_srai_epi16(gws, 4); - - // back to byte, set up for transpose - __m128i brb = _mm_packus_epi16(rw, bw); - __m128i gxb = _mm_packus_epi16(gw, xw); - - // transpose to interleave channels - __m128i t0 = _mm_unpacklo_epi8(brb, gxb); - __m128i t1 = _mm_unpackhi_epi8(brb, gxb); - __m128i o0 = _mm_unpacklo_epi16(t0, t1); - __m128i o1 = _mm_unpackhi_epi16(t0, t1); - - // store - _mm_storeu_si128((__m128i *) (out + 0), o0); - _mm_storeu_si128((__m128i *) (out + 16), o1); - out += 32; - } - } -#endif - -#ifdef STBI_NEON - // in this version, step=3 support would be easy to add. but is there demand? - if (step == 4) { - // this is a fairly straightforward implementation and not super-optimized. - uint8x8_t signflip = vdup_n_u8(0x80); - int16x8_t cr_const0 = vdupq_n_s16( (short) ( 1.40200f*4096.0f+0.5f)); - int16x8_t cr_const1 = vdupq_n_s16( - (short) ( 0.71414f*4096.0f+0.5f)); - int16x8_t cb_const0 = vdupq_n_s16( - (short) ( 0.34414f*4096.0f+0.5f)); - int16x8_t cb_const1 = vdupq_n_s16( (short) ( 1.77200f*4096.0f+0.5f)); - - for (; i+7 < count; i += 8) { - // load - uint8x8_t y_bytes = vld1_u8(y + i); - uint8x8_t cr_bytes = vld1_u8(pcr + i); - uint8x8_t cb_bytes = vld1_u8(pcb + i); - int8x8_t cr_biased = vreinterpret_s8_u8(vsub_u8(cr_bytes, signflip)); - int8x8_t cb_biased = vreinterpret_s8_u8(vsub_u8(cb_bytes, signflip)); - - // expand to s16 - int16x8_t yws = vreinterpretq_s16_u16(vshll_n_u8(y_bytes, 4)); - int16x8_t crw = vshll_n_s8(cr_biased, 7); - int16x8_t cbw = vshll_n_s8(cb_biased, 7); - - // color transform - int16x8_t cr0 = vqdmulhq_s16(crw, cr_const0); - int16x8_t cb0 = vqdmulhq_s16(cbw, cb_const0); - int16x8_t cr1 = vqdmulhq_s16(crw, cr_const1); - int16x8_t cb1 = vqdmulhq_s16(cbw, cb_const1); - int16x8_t rws = vaddq_s16(yws, cr0); - int16x8_t gws = vaddq_s16(vaddq_s16(yws, cb0), cr1); - int16x8_t bws = vaddq_s16(yws, cb1); - - // undo scaling, round, convert to byte - uint8x8x4_t o; - o.val[0] = vqrshrun_n_s16(rws, 4); - o.val[1] = vqrshrun_n_s16(gws, 4); - o.val[2] = vqrshrun_n_s16(bws, 4); - o.val[3] = vdup_n_u8(255); - - // store, interleaving r/g/b/a - vst4_u8(out, o); - out += 8*4; - } - } -#endif - - for (; i < count; ++i) { - int y_fixed = (y[i] << 20) + (1<<19); // rounding - int r,g,b; - int cr = pcr[i] - 128; - int cb = pcb[i] - 128; - r = y_fixed + cr* stbi__float2fixed(1.40200f); - g = y_fixed + cr*-stbi__float2fixed(0.71414f) + ((cb*-stbi__float2fixed(0.34414f)) & 0xffff0000); - b = y_fixed + cb* stbi__float2fixed(1.77200f); - r >>= 20; - g >>= 20; - b >>= 20; - if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } - if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } - if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } - out[0] = (stbi_uc)r; - out[1] = (stbi_uc)g; - out[2] = (stbi_uc)b; - out[3] = 255; - out += step; - } -} -#endif - -// set up the kernels -static void stbi__setup_jpeg(stbi__jpeg *j) -{ - j->idct_block_kernel = stbi__idct_block; - j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_row; - j->resample_row_hv_2_kernel = stbi__resample_row_hv_2; - -#ifdef STBI_SSE2 - if (stbi__sse2_available()) { - j->idct_block_kernel = stbi__idct_simd; - j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; - j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; - } -#endif - -#ifdef STBI_NEON - j->idct_block_kernel = stbi__idct_simd; - j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; - j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; -#endif -} - -// clean up the temporary component buffers -static void stbi__cleanup_jpeg(stbi__jpeg *j) -{ - stbi__free_jpeg_components(j, j->s->img_n, 0); -} - -typedef struct -{ - resample_row_func resample; - stbi_uc *line0,*line1; - int hs,vs; // expansion factor in each axis - int w_lores; // horizontal pixels pre-expansion - int ystep; // how far through vertical expansion we are - int ypos; // which pre-expansion row we're on -} stbi__resample; - -// fast 0..255 * 0..255 => 0..255 rounded multiplication -static stbi_uc stbi__blinn_8x8(stbi_uc x, stbi_uc y) -{ - unsigned int t = x*y + 128; - return (stbi_uc) ((t + (t >>8)) >> 8); -} - -static stbi_uc *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp, int req_comp) -{ - int n, decode_n, is_rgb; - z->s->img_n = 0; // make stbi__cleanup_jpeg safe - - // validate req_comp - if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error"); - - // load a jpeg image from whichever source, but leave in YCbCr format - if (!stbi__decode_jpeg_image(z)) { stbi__cleanup_jpeg(z); return NULL; } - - // determine actual number of components to generate - n = req_comp ? req_comp : z->s->img_n >= 3 ? 3 : 1; - - is_rgb = z->s->img_n == 3 && (z->rgb == 3 || (z->app14_color_transform == 0 && !z->jfif)); - - if (z->s->img_n == 3 && n < 3 && !is_rgb) - decode_n = 1; - else - decode_n = z->s->img_n; - - // resample and color-convert - { - int k; - unsigned int i,j; - stbi_uc *output; - stbi_uc *coutput[4] = { NULL, NULL, NULL, NULL }; - - stbi__resample res_comp[4]; - - for (k=0; k < decode_n; ++k) { - stbi__resample *r = &res_comp[k]; - - // allocate line buffer big enough for upsampling off the edges - // with upsample factor of 4 - z->img_comp[k].linebuf = (stbi_uc *) stbi__malloc(z->s->img_x + 3); - if (!z->img_comp[k].linebuf) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); } - - r->hs = z->img_h_max / z->img_comp[k].h; - r->vs = z->img_v_max / z->img_comp[k].v; - r->ystep = r->vs >> 1; - r->w_lores = (z->s->img_x + r->hs-1) / r->hs; - r->ypos = 0; - r->line0 = r->line1 = z->img_comp[k].data; - - if (r->hs == 1 && r->vs == 1) r->resample = resample_row_1; - else if (r->hs == 1 && r->vs == 2) r->resample = stbi__resample_row_v_2; - else if (r->hs == 2 && r->vs == 1) r->resample = stbi__resample_row_h_2; - else if (r->hs == 2 && r->vs == 2) r->resample = z->resample_row_hv_2_kernel; - else r->resample = stbi__resample_row_generic; - } - - // can't error after this so, this is safe - output = (stbi_uc *) stbi__malloc_mad3(n, z->s->img_x, z->s->img_y, 1); - if (!output) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); } - - // now go ahead and resample - for (j=0; j < z->s->img_y; ++j) { - stbi_uc *out = output + n * z->s->img_x * j; - for (k=0; k < decode_n; ++k) { - stbi__resample *r = &res_comp[k]; - int y_bot = r->ystep >= (r->vs >> 1); - coutput[k] = r->resample(z->img_comp[k].linebuf, - y_bot ? r->line1 : r->line0, - y_bot ? r->line0 : r->line1, - r->w_lores, r->hs); - if (++r->ystep >= r->vs) { - r->ystep = 0; - r->line0 = r->line1; - if (++r->ypos < z->img_comp[k].y) - r->line1 += z->img_comp[k].w2; - } - } - if (n >= 3) { - stbi_uc *y = coutput[0]; - if (z->s->img_n == 3) { - if (is_rgb) { - for (i=0; i < z->s->img_x; ++i) { - out[0] = y[i]; - out[1] = coutput[1][i]; - out[2] = coutput[2][i]; - out[3] = 255; - out += n; - } - } else { - z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); - } - } else if (z->s->img_n == 4) { - if (z->app14_color_transform == 0) { // CMYK - for (i=0; i < z->s->img_x; ++i) { - stbi_uc m = coutput[3][i]; - out[0] = stbi__blinn_8x8(coutput[0][i], m); - out[1] = stbi__blinn_8x8(coutput[1][i], m); - out[2] = stbi__blinn_8x8(coutput[2][i], m); - out[3] = 255; - out += n; - } - } else if (z->app14_color_transform == 2) { // YCCK - z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); - for (i=0; i < z->s->img_x; ++i) { - stbi_uc m = coutput[3][i]; - out[0] = stbi__blinn_8x8(255 - out[0], m); - out[1] = stbi__blinn_8x8(255 - out[1], m); - out[2] = stbi__blinn_8x8(255 - out[2], m); - out += n; - } - } else { // YCbCr + alpha? Ignore the fourth channel for now - z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); - } - } else - for (i=0; i < z->s->img_x; ++i) { - out[0] = out[1] = out[2] = y[i]; - out[3] = 255; // not used if n==3 - out += n; - } - } else { - if (is_rgb) { - if (n == 1) - for (i=0; i < z->s->img_x; ++i) - *out++ = stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]); - else { - for (i=0; i < z->s->img_x; ++i, out += 2) { - out[0] = stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]); - out[1] = 255; - } - } - } else if (z->s->img_n == 4 && z->app14_color_transform == 0) { - for (i=0; i < z->s->img_x; ++i) { - stbi_uc m = coutput[3][i]; - stbi_uc r = stbi__blinn_8x8(coutput[0][i], m); - stbi_uc g = stbi__blinn_8x8(coutput[1][i], m); - stbi_uc b = stbi__blinn_8x8(coutput[2][i], m); - out[0] = stbi__compute_y(r, g, b); - out[1] = 255; - out += n; - } - } else if (z->s->img_n == 4 && z->app14_color_transform == 2) { - for (i=0; i < z->s->img_x; ++i) { - out[0] = stbi__blinn_8x8(255 - coutput[0][i], coutput[3][i]); - out[1] = 255; - out += n; - } - } else { - stbi_uc *y = coutput[0]; - if (n == 1) - for (i=0; i < z->s->img_x; ++i) out[i] = y[i]; - else - for (i=0; i < z->s->img_x; ++i) { *out++ = y[i]; *out++ = 255; } - } - } - } - stbi__cleanup_jpeg(z); - *out_x = z->s->img_x; - *out_y = z->s->img_y; - if (comp) *comp = z->s->img_n >= 3 ? 3 : 1; // report original components, not output - return output; - } -} - -static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) -{ - unsigned char* result; - stbi__jpeg* j = (stbi__jpeg*) stbi__malloc(sizeof(stbi__jpeg)); - STBI_NOTUSED(ri); - j->s = s; - stbi__setup_jpeg(j); - result = load_jpeg_image(j, x,y,comp,req_comp); - STBI_FREE(j); - return result; -} - -static int stbi__jpeg_test(stbi__context *s) -{ - int r; - stbi__jpeg* j = (stbi__jpeg*)stbi__malloc(sizeof(stbi__jpeg)); - j->s = s; - stbi__setup_jpeg(j); - r = stbi__decode_jpeg_header(j, STBI__SCAN_type); - stbi__rewind(s); - STBI_FREE(j); - return r; -} - -static int stbi__jpeg_info_raw(stbi__jpeg *j, int *x, int *y, int *comp) -{ - if (!stbi__decode_jpeg_header(j, STBI__SCAN_header)) { - stbi__rewind( j->s ); - return 0; - } - if (x) *x = j->s->img_x; - if (y) *y = j->s->img_y; - if (comp) *comp = j->s->img_n >= 3 ? 3 : 1; - return 1; -} - -static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp) -{ - int result; - stbi__jpeg* j = (stbi__jpeg*) (stbi__malloc(sizeof(stbi__jpeg))); - j->s = s; - result = stbi__jpeg_info_raw(j, x, y, comp); - STBI_FREE(j); - return result; -} -#endif - -// public domain zlib decode v0.2 Sean Barrett 2006-11-18 -// simple implementation -// - all input must be provided in an upfront buffer -// - all output is written to a single output buffer (can malloc/realloc) -// performance -// - fast huffman - -#ifndef STBI_NO_ZLIB - -// fast-way is faster to check than jpeg huffman, but slow way is slower -#define STBI__ZFAST_BITS 9 // accelerate all cases in default tables -#define STBI__ZFAST_MASK ((1 << STBI__ZFAST_BITS) - 1) - -// zlib-style huffman encoding -// (jpegs packs from left, zlib from right, so can't share code) -typedef struct -{ - stbi__uint16 fast[1 << STBI__ZFAST_BITS]; - stbi__uint16 firstcode[16]; - int maxcode[17]; - stbi__uint16 firstsymbol[16]; - stbi_uc size[288]; - stbi__uint16 value[288]; -} stbi__zhuffman; - -stbi_inline static int stbi__bitreverse16(int n) -{ - n = ((n & 0xAAAA) >> 1) | ((n & 0x5555) << 1); - n = ((n & 0xCCCC) >> 2) | ((n & 0x3333) << 2); - n = ((n & 0xF0F0) >> 4) | ((n & 0x0F0F) << 4); - n = ((n & 0xFF00) >> 8) | ((n & 0x00FF) << 8); - return n; -} - -stbi_inline static int stbi__bit_reverse(int v, int bits) -{ - STBI_ASSERT(bits <= 16); - // to bit reverse n bits, reverse 16 and shift - // e.g. 11 bits, bit reverse and shift away 5 - return stbi__bitreverse16(v) >> (16-bits); -} - -static int stbi__zbuild_huffman(stbi__zhuffman *z, const stbi_uc *sizelist, int num) -{ - int i,k=0; - int code, next_code[16], sizes[17]; - - // DEFLATE spec for generating codes - memset(sizes, 0, sizeof(sizes)); - memset(z->fast, 0, sizeof(z->fast)); - for (i=0; i < num; ++i) - ++sizes[sizelist[i]]; - sizes[0] = 0; - for (i=1; i < 16; ++i) - if (sizes[i] > (1 << i)) - return stbi__err("bad sizes", "Corrupt PNG"); - code = 0; - for (i=1; i < 16; ++i) { - next_code[i] = code; - z->firstcode[i] = (stbi__uint16) code; - z->firstsymbol[i] = (stbi__uint16) k; - code = (code + sizes[i]); - if (sizes[i]) - if (code-1 >= (1 << i)) return stbi__err("bad codelengths","Corrupt PNG"); - z->maxcode[i] = code << (16-i); // preshift for inner loop - code <<= 1; - k += sizes[i]; - } - z->maxcode[16] = 0x10000; // sentinel - for (i=0; i < num; ++i) { - int s = sizelist[i]; - if (s) { - int c = next_code[s] - z->firstcode[s] + z->firstsymbol[s]; - stbi__uint16 fastv = (stbi__uint16) ((s << 9) | i); - z->size [c] = (stbi_uc ) s; - z->value[c] = (stbi__uint16) i; - if (s <= STBI__ZFAST_BITS) { - int j = stbi__bit_reverse(next_code[s],s); - while (j < (1 << STBI__ZFAST_BITS)) { - z->fast[j] = fastv; - j += (1 << s); - } - } - ++next_code[s]; - } - } - return 1; -} - -// zlib-from-memory implementation for PNG reading -// because PNG allows splitting the zlib stream arbitrarily, -// and it's annoying structurally to have PNG call ZLIB call PNG, -// we require PNG read all the IDATs and combine them into a single -// memory buffer - -typedef struct -{ - stbi_uc *zbuffer, *zbuffer_end; - int num_bits; - stbi__uint32 code_buffer; - - char *zout; - char *zout_start; - char *zout_end; - int z_expandable; - - stbi__zhuffman z_length, z_distance; -} stbi__zbuf; - -stbi_inline static stbi_uc stbi__zget8(stbi__zbuf *z) -{ - if (z->zbuffer >= z->zbuffer_end) return 0; - return *z->zbuffer++; -} - -static void stbi__fill_bits(stbi__zbuf *z) -{ - do { - STBI_ASSERT(z->code_buffer < (1U << z->num_bits)); - z->code_buffer |= (unsigned int) stbi__zget8(z) << z->num_bits; - z->num_bits += 8; - } while (z->num_bits <= 24); -} - -stbi_inline static unsigned int stbi__zreceive(stbi__zbuf *z, int n) -{ - unsigned int k; - if (z->num_bits < n) stbi__fill_bits(z); - k = z->code_buffer & ((1 << n) - 1); - z->code_buffer >>= n; - z->num_bits -= n; - return k; -} - -static int stbi__zhuffman_decode_slowpath(stbi__zbuf *a, stbi__zhuffman *z) -{ - int b,s,k; - // not resolved by fast table, so compute it the slow way - // use jpeg approach, which requires MSbits at top - k = stbi__bit_reverse(a->code_buffer, 16); - for (s=STBI__ZFAST_BITS+1; ; ++s) - if (k < z->maxcode[s]) - break; - if (s == 16) return -1; // invalid code! - // code size is s, so: - b = (k >> (16-s)) - z->firstcode[s] + z->firstsymbol[s]; - STBI_ASSERT(z->size[b] == s); - a->code_buffer >>= s; - a->num_bits -= s; - return z->value[b]; -} - -stbi_inline static int stbi__zhuffman_decode(stbi__zbuf *a, stbi__zhuffman *z) -{ - int b,s; - if (a->num_bits < 16) stbi__fill_bits(a); - b = z->fast[a->code_buffer & STBI__ZFAST_MASK]; - if (b) { - s = b >> 9; - a->code_buffer >>= s; - a->num_bits -= s; - return b & 511; - } - return stbi__zhuffman_decode_slowpath(a, z); -} - -static int stbi__zexpand(stbi__zbuf *z, char *zout, int n) // need to make room for n bytes -{ - char *q; - int cur, limit, old_limit; - z->zout = zout; - if (!z->z_expandable) return stbi__err("output buffer limit","Corrupt PNG"); - cur = (int) (z->zout - z->zout_start); - limit = old_limit = (int) (z->zout_end - z->zout_start); - while (cur + n > limit) - limit *= 2; - q = (char *) STBI_REALLOC_SIZED(z->zout_start, old_limit, limit); - STBI_NOTUSED(old_limit); - if (q == NULL) return stbi__err("outofmem", "Out of memory"); - z->zout_start = q; - z->zout = q + cur; - z->zout_end = q + limit; - return 1; -} - -static const int stbi__zlength_base[31] = { - 3,4,5,6,7,8,9,10,11,13, - 15,17,19,23,27,31,35,43,51,59, - 67,83,99,115,131,163,195,227,258,0,0 }; - -static const int stbi__zlength_extra[31]= -{ 0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0 }; - -static const int stbi__zdist_base[32] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193, -257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0}; - -static const int stbi__zdist_extra[32] = -{ 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; - -static int stbi__parse_huffman_block(stbi__zbuf *a) -{ - char *zout = a->zout; - for(;;) { - int z = stbi__zhuffman_decode(a, &a->z_length); - if (z < 256) { - if (z < 0) return stbi__err("bad huffman code","Corrupt PNG"); // error in huffman codes - if (zout >= a->zout_end) { - if (!stbi__zexpand(a, zout, 1)) return 0; - zout = a->zout; - } - *zout++ = (char) z; - } else { - stbi_uc *p; - int len,dist; - if (z == 256) { - a->zout = zout; - return 1; - } - z -= 257; - len = stbi__zlength_base[z]; - if (stbi__zlength_extra[z]) len += stbi__zreceive(a, stbi__zlength_extra[z]); - z = stbi__zhuffman_decode(a, &a->z_distance); - if (z < 0) return stbi__err("bad huffman code","Corrupt PNG"); - dist = stbi__zdist_base[z]; - if (stbi__zdist_extra[z]) dist += stbi__zreceive(a, stbi__zdist_extra[z]); - if (zout - a->zout_start < dist) return stbi__err("bad dist","Corrupt PNG"); - if (zout + len > a->zout_end) { - if (!stbi__zexpand(a, zout, len)) return 0; - zout = a->zout; - } - p = (stbi_uc *) (zout - dist); - if (dist == 1) { // run of one byte; common in images. - stbi_uc v = *p; - if (len) { do *zout++ = v; while (--len); } - } else { - if (len) { do *zout++ = *p++; while (--len); } - } - } - } -} - -static int stbi__compute_huffman_codes(stbi__zbuf *a) -{ - static const stbi_uc length_dezigzag[19] = { 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 }; - stbi__zhuffman z_codelength; - stbi_uc lencodes[286+32+137];//padding for maximum single op - stbi_uc codelength_sizes[19]; - int i,n; - - int hlit = stbi__zreceive(a,5) + 257; - int hdist = stbi__zreceive(a,5) + 1; - int hclen = stbi__zreceive(a,4) + 4; - int ntot = hlit + hdist; - - memset(codelength_sizes, 0, sizeof(codelength_sizes)); - for (i=0; i < hclen; ++i) { - int s = stbi__zreceive(a,3); - codelength_sizes[length_dezigzag[i]] = (stbi_uc) s; - } - if (!stbi__zbuild_huffman(&z_codelength, codelength_sizes, 19)) return 0; - - n = 0; - while (n < ntot) { - int c = stbi__zhuffman_decode(a, &z_codelength); - if (c < 0 || c >= 19) return stbi__err("bad codelengths", "Corrupt PNG"); - if (c < 16) - lencodes[n++] = (stbi_uc) c; - else { - stbi_uc fill = 0; - if (c == 16) { - c = stbi__zreceive(a,2)+3; - if (n == 0) return stbi__err("bad codelengths", "Corrupt PNG"); - fill = lencodes[n-1]; - } else if (c == 17) - c = stbi__zreceive(a,3)+3; - else { - STBI_ASSERT(c == 18); - c = stbi__zreceive(a,7)+11; - } - if (ntot - n < c) return stbi__err("bad codelengths", "Corrupt PNG"); - memset(lencodes+n, fill, c); - n += c; - } - } - if (n != ntot) return stbi__err("bad codelengths","Corrupt PNG"); - if (!stbi__zbuild_huffman(&a->z_length, lencodes, hlit)) return 0; - if (!stbi__zbuild_huffman(&a->z_distance, lencodes+hlit, hdist)) return 0; - return 1; -} - -static int stbi__parse_uncompressed_block(stbi__zbuf *a) -{ - stbi_uc header[4]; - int len,nlen,k; - if (a->num_bits & 7) - stbi__zreceive(a, a->num_bits & 7); // discard - // drain the bit-packed data into header - k = 0; - while (a->num_bits > 0) { - header[k++] = (stbi_uc) (a->code_buffer & 255); // suppress MSVC run-time check - a->code_buffer >>= 8; - a->num_bits -= 8; - } - STBI_ASSERT(a->num_bits == 0); - // now fill header the normal way - while (k < 4) - header[k++] = stbi__zget8(a); - len = header[1] * 256 + header[0]; - nlen = header[3] * 256 + header[2]; - if (nlen != (len ^ 0xffff)) return stbi__err("zlib corrupt","Corrupt PNG"); - if (a->zbuffer + len > a->zbuffer_end) return stbi__err("read past buffer","Corrupt PNG"); - if (a->zout + len > a->zout_end) - if (!stbi__zexpand(a, a->zout, len)) return 0; - memcpy(a->zout, a->zbuffer, len); - a->zbuffer += len; - a->zout += len; - return 1; -} - -static int stbi__parse_zlib_header(stbi__zbuf *a) -{ - int cmf = stbi__zget8(a); - int cm = cmf & 15; - /* int cinfo = cmf >> 4; */ - int flg = stbi__zget8(a); - if ((cmf*256+flg) % 31 != 0) return stbi__err("bad zlib header","Corrupt PNG"); // zlib spec - if (flg & 32) return stbi__err("no preset dict","Corrupt PNG"); // preset dictionary not allowed in png - if (cm != 8) return stbi__err("bad compression","Corrupt PNG"); // DEFLATE required for png - // window = 1 << (8 + cinfo)... but who cares, we fully buffer output - return 1; -} - -static const stbi_uc stbi__zdefault_length[288] = -{ - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, - 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, - 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, - 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8 -}; -static const stbi_uc stbi__zdefault_distance[32] = -{ - 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5 -}; -/* -Init algorithm: -{ - int i; // use <= to match clearly with spec - for (i=0; i <= 143; ++i) stbi__zdefault_length[i] = 8; - for ( ; i <= 255; ++i) stbi__zdefault_length[i] = 9; - for ( ; i <= 279; ++i) stbi__zdefault_length[i] = 7; - for ( ; i <= 287; ++i) stbi__zdefault_length[i] = 8; - - for (i=0; i <= 31; ++i) stbi__zdefault_distance[i] = 5; -} -*/ - -static int stbi__parse_zlib(stbi__zbuf *a, int parse_header) -{ - int final, type; - if (parse_header) - if (!stbi__parse_zlib_header(a)) return 0; - a->num_bits = 0; - a->code_buffer = 0; - do { - final = stbi__zreceive(a,1); - type = stbi__zreceive(a,2); - if (type == 0) { - if (!stbi__parse_uncompressed_block(a)) return 0; - } else if (type == 3) { - return 0; - } else { - if (type == 1) { - // use fixed code lengths - if (!stbi__zbuild_huffman(&a->z_length , stbi__zdefault_length , 288)) return 0; - if (!stbi__zbuild_huffman(&a->z_distance, stbi__zdefault_distance, 32)) return 0; - } else { - if (!stbi__compute_huffman_codes(a)) return 0; - } - if (!stbi__parse_huffman_block(a)) return 0; - } - } while (!final); - return 1; -} - -static int stbi__do_zlib(stbi__zbuf *a, char *obuf, int olen, int exp, int parse_header) -{ - a->zout_start = obuf; - a->zout = obuf; - a->zout_end = obuf + olen; - a->z_expandable = exp; - - return stbi__parse_zlib(a, parse_header); -} - -STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen) -{ - stbi__zbuf a; - char *p = (char *) stbi__malloc(initial_size); - if (p == NULL) return NULL; - a.zbuffer = (stbi_uc *) buffer; - a.zbuffer_end = (stbi_uc *) buffer + len; - if (stbi__do_zlib(&a, p, initial_size, 1, 1)) { - if (outlen) *outlen = (int) (a.zout - a.zout_start); - return a.zout_start; - } else { - STBI_FREE(a.zout_start); - return NULL; - } -} - -STBIDEF char *stbi_zlib_decode_malloc(char const *buffer, int len, int *outlen) -{ - return stbi_zlib_decode_malloc_guesssize(buffer, len, 16384, outlen); -} - -STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header) -{ - stbi__zbuf a; - char *p = (char *) stbi__malloc(initial_size); - if (p == NULL) return NULL; - a.zbuffer = (stbi_uc *) buffer; - a.zbuffer_end = (stbi_uc *) buffer + len; - if (stbi__do_zlib(&a, p, initial_size, 1, parse_header)) { - if (outlen) *outlen = (int) (a.zout - a.zout_start); - return a.zout_start; - } else { - STBI_FREE(a.zout_start); - return NULL; - } -} - -STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, char const *ibuffer, int ilen) -{ - stbi__zbuf a; - a.zbuffer = (stbi_uc *) ibuffer; - a.zbuffer_end = (stbi_uc *) ibuffer + ilen; - if (stbi__do_zlib(&a, obuffer, olen, 0, 1)) - return (int) (a.zout - a.zout_start); - else - return -1; -} - -STBIDEF char *stbi_zlib_decode_noheader_malloc(char const *buffer, int len, int *outlen) -{ - stbi__zbuf a; - char *p = (char *) stbi__malloc(16384); - if (p == NULL) return NULL; - a.zbuffer = (stbi_uc *) buffer; - a.zbuffer_end = (stbi_uc *) buffer+len; - if (stbi__do_zlib(&a, p, 16384, 1, 0)) { - if (outlen) *outlen = (int) (a.zout - a.zout_start); - return a.zout_start; - } else { - STBI_FREE(a.zout_start); - return NULL; - } -} - -STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen) -{ - stbi__zbuf a; - a.zbuffer = (stbi_uc *) ibuffer; - a.zbuffer_end = (stbi_uc *) ibuffer + ilen; - if (stbi__do_zlib(&a, obuffer, olen, 0, 0)) - return (int) (a.zout - a.zout_start); - else - return -1; -} -#endif - -// public domain "baseline" PNG decoder v0.10 Sean Barrett 2006-11-18 -// simple implementation -// - only 8-bit samples -// - no CRC checking -// - allocates lots of intermediate memory -// - avoids problem of streaming data between subsystems -// - avoids explicit window management -// performance -// - uses stb_zlib, a PD zlib implementation with fast huffman decoding - -#ifndef STBI_NO_PNG -typedef struct -{ - stbi__uint32 length; - stbi__uint32 type; -} stbi__pngchunk; - -static stbi__pngchunk stbi__get_chunk_header(stbi__context *s) -{ - stbi__pngchunk c; - c.length = stbi__get32be(s); - c.type = stbi__get32be(s); - return c; -} - -static int stbi__check_png_header(stbi__context *s) -{ - static const stbi_uc png_sig[8] = { 137,80,78,71,13,10,26,10 }; - int i; - for (i=0; i < 8; ++i) - if (stbi__get8(s) != png_sig[i]) return stbi__err("bad png sig","Not a PNG"); - return 1; -} - -typedef struct -{ - stbi__context *s; - stbi_uc *idata, *expanded, *out; - int depth; -} stbi__png; - - -enum { - STBI__F_none=0, - STBI__F_sub=1, - STBI__F_up=2, - STBI__F_avg=3, - STBI__F_paeth=4, - // synthetic filters used for first scanline to avoid needing a dummy row of 0s - STBI__F_avg_first, - STBI__F_paeth_first -}; - -static stbi_uc first_row_filter[5] = -{ - STBI__F_none, - STBI__F_sub, - STBI__F_none, - STBI__F_avg_first, - STBI__F_paeth_first -}; - -static int stbi__paeth(int a, int b, int c) -{ - int p = a + b - c; - int pa = abs(p-a); - int pb = abs(p-b); - int pc = abs(p-c); - if (pa <= pb && pa <= pc) return a; - if (pb <= pc) return b; - return c; -} - -static const stbi_uc stbi__depth_scale_table[9] = { 0, 0xff, 0x55, 0, 0x11, 0,0,0, 0x01 }; - -// create the png data from post-deflated data -static int stbi__create_png_image_raw(stbi__png *a, stbi_uc *raw, stbi__uint32 raw_len, int out_n, stbi__uint32 x, stbi__uint32 y, int depth, int color) -{ - int bytes = (depth == 16? 2 : 1); - stbi__context *s = a->s; - stbi__uint32 i,j,stride = x*out_n*bytes; - stbi__uint32 img_len, img_width_bytes; - int k; - int img_n = s->img_n; // copy it into a local for later - - int output_bytes = out_n*bytes; - int filter_bytes = img_n*bytes; - int width = x; - - STBI_ASSERT(out_n == s->img_n || out_n == s->img_n+1); - a->out = (stbi_uc *) stbi__malloc_mad3(x, y, output_bytes, 0); // extra bytes to write off the end into - if (!a->out) return stbi__err("outofmem", "Out of memory"); - - if (!stbi__mad3sizes_valid(img_n, x, depth, 7)) return stbi__err("too large", "Corrupt PNG"); - img_width_bytes = (((img_n * x * depth) + 7) >> 3); - img_len = (img_width_bytes + 1) * y; - - // we used to check for exact match between raw_len and img_len on non-interlaced PNGs, - // but issue #276 reported a PNG in the wild that had extra data at the end (all zeros), - // so just check for raw_len < img_len always. - if (raw_len < img_len) return stbi__err("not enough pixels","Corrupt PNG"); - - for (j=0; j < y; ++j) { - stbi_uc *cur = a->out + stride*j; - stbi_uc *prior; - int filter = *raw++; - - if (filter > 4) - return stbi__err("invalid filter","Corrupt PNG"); - - if (depth < 8) { - STBI_ASSERT(img_width_bytes <= x); - cur += x*out_n - img_width_bytes; // store output to the rightmost img_len bytes, so we can decode in place - filter_bytes = 1; - width = img_width_bytes; - } - prior = cur - stride; // bugfix: need to compute this after 'cur +=' computation above - - // if first row, use special filter that doesn't sample previous row - if (j == 0) filter = first_row_filter[filter]; - - // handle first byte explicitly - for (k=0; k < filter_bytes; ++k) { - switch (filter) { - case STBI__F_none : cur[k] = raw[k]; break; - case STBI__F_sub : cur[k] = raw[k]; break; - case STBI__F_up : cur[k] = STBI__BYTECAST(raw[k] + prior[k]); break; - case STBI__F_avg : cur[k] = STBI__BYTECAST(raw[k] + (prior[k]>>1)); break; - case STBI__F_paeth : cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(0,prior[k],0)); break; - case STBI__F_avg_first : cur[k] = raw[k]; break; - case STBI__F_paeth_first: cur[k] = raw[k]; break; - } - } - - if (depth == 8) { - if (img_n != out_n) - cur[img_n] = 255; // first pixel - raw += img_n; - cur += out_n; - prior += out_n; - } else if (depth == 16) { - if (img_n != out_n) { - cur[filter_bytes] = 255; // first pixel top byte - cur[filter_bytes+1] = 255; // first pixel bottom byte - } - raw += filter_bytes; - cur += output_bytes; - prior += output_bytes; - } else { - raw += 1; - cur += 1; - prior += 1; - } - - // this is a little gross, so that we don't switch per-pixel or per-component - if (depth < 8 || img_n == out_n) { - int nk = (width - 1)*filter_bytes; - #define STBI__CASE(f) \ - case f: \ - for (k=0; k < nk; ++k) - switch (filter) { - // "none" filter turns into a memcpy here; make that explicit. - case STBI__F_none: memcpy(cur, raw, nk); break; - STBI__CASE(STBI__F_sub) { cur[k] = STBI__BYTECAST(raw[k] + cur[k-filter_bytes]); } break; - STBI__CASE(STBI__F_up) { cur[k] = STBI__BYTECAST(raw[k] + prior[k]); } break; - STBI__CASE(STBI__F_avg) { cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k-filter_bytes])>>1)); } break; - STBI__CASE(STBI__F_paeth) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],prior[k],prior[k-filter_bytes])); } break; - STBI__CASE(STBI__F_avg_first) { cur[k] = STBI__BYTECAST(raw[k] + (cur[k-filter_bytes] >> 1)); } break; - STBI__CASE(STBI__F_paeth_first) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],0,0)); } break; - } - #undef STBI__CASE - raw += nk; - } else { - STBI_ASSERT(img_n+1 == out_n); - #define STBI__CASE(f) \ - case f: \ - for (i=x-1; i >= 1; --i, cur[filter_bytes]=255,raw+=filter_bytes,cur+=output_bytes,prior+=output_bytes) \ - for (k=0; k < filter_bytes; ++k) - switch (filter) { - STBI__CASE(STBI__F_none) { cur[k] = raw[k]; } break; - STBI__CASE(STBI__F_sub) { cur[k] = STBI__BYTECAST(raw[k] + cur[k- output_bytes]); } break; - STBI__CASE(STBI__F_up) { cur[k] = STBI__BYTECAST(raw[k] + prior[k]); } break; - STBI__CASE(STBI__F_avg) { cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k- output_bytes])>>1)); } break; - STBI__CASE(STBI__F_paeth) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k- output_bytes],prior[k],prior[k- output_bytes])); } break; - STBI__CASE(STBI__F_avg_first) { cur[k] = STBI__BYTECAST(raw[k] + (cur[k- output_bytes] >> 1)); } break; - STBI__CASE(STBI__F_paeth_first) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k- output_bytes],0,0)); } break; - } - #undef STBI__CASE - - // the loop above sets the high byte of the pixels' alpha, but for - // 16 bit png files we also need the low byte set. we'll do that here. - if (depth == 16) { - cur = a->out + stride*j; // start at the beginning of the row again - for (i=0; i < x; ++i,cur+=output_bytes) { - cur[filter_bytes+1] = 255; - } - } - } - } - - // we make a separate pass to expand bits to pixels; for performance, - // this could run two scanlines behind the above code, so it won't - // intefere with filtering but will still be in the cache. - if (depth < 8) { - for (j=0; j < y; ++j) { - stbi_uc *cur = a->out + stride*j; - stbi_uc *in = a->out + stride*j + x*out_n - img_width_bytes; - // unpack 1/2/4-bit into a 8-bit buffer. allows us to keep the common 8-bit path optimal at minimal cost for 1/2/4-bit - // png guarante byte alignment, if width is not multiple of 8/4/2 we'll decode dummy trailing data that will be skipped in the later loop - stbi_uc scale = (color == 0) ? stbi__depth_scale_table[depth] : 1; // scale grayscale values to 0..255 range - - // note that the final byte might overshoot and write more data than desired. - // we can allocate enough data that this never writes out of memory, but it - // could also overwrite the next scanline. can it overwrite non-empty data - // on the next scanline? yes, consider 1-pixel-wide scanlines with 1-bit-per-pixel. - // so we need to explicitly clamp the final ones - - if (depth == 4) { - for (k=x*img_n; k >= 2; k-=2, ++in) { - *cur++ = scale * ((*in >> 4) ); - *cur++ = scale * ((*in ) & 0x0f); - } - if (k > 0) *cur++ = scale * ((*in >> 4) ); - } else if (depth == 2) { - for (k=x*img_n; k >= 4; k-=4, ++in) { - *cur++ = scale * ((*in >> 6) ); - *cur++ = scale * ((*in >> 4) & 0x03); - *cur++ = scale * ((*in >> 2) & 0x03); - *cur++ = scale * ((*in ) & 0x03); - } - if (k > 0) *cur++ = scale * ((*in >> 6) ); - if (k > 1) *cur++ = scale * ((*in >> 4) & 0x03); - if (k > 2) *cur++ = scale * ((*in >> 2) & 0x03); - } else if (depth == 1) { - for (k=x*img_n; k >= 8; k-=8, ++in) { - *cur++ = scale * ((*in >> 7) ); - *cur++ = scale * ((*in >> 6) & 0x01); - *cur++ = scale * ((*in >> 5) & 0x01); - *cur++ = scale * ((*in >> 4) & 0x01); - *cur++ = scale * ((*in >> 3) & 0x01); - *cur++ = scale * ((*in >> 2) & 0x01); - *cur++ = scale * ((*in >> 1) & 0x01); - *cur++ = scale * ((*in ) & 0x01); - } - if (k > 0) *cur++ = scale * ((*in >> 7) ); - if (k > 1) *cur++ = scale * ((*in >> 6) & 0x01); - if (k > 2) *cur++ = scale * ((*in >> 5) & 0x01); - if (k > 3) *cur++ = scale * ((*in >> 4) & 0x01); - if (k > 4) *cur++ = scale * ((*in >> 3) & 0x01); - if (k > 5) *cur++ = scale * ((*in >> 2) & 0x01); - if (k > 6) *cur++ = scale * ((*in >> 1) & 0x01); - } - if (img_n != out_n) { - int q; - // insert alpha = 255 - cur = a->out + stride*j; - if (img_n == 1) { - for (q=x-1; q >= 0; --q) { - cur[q*2+1] = 255; - cur[q*2+0] = cur[q]; - } - } else { - STBI_ASSERT(img_n == 3); - for (q=x-1; q >= 0; --q) { - cur[q*4+3] = 255; - cur[q*4+2] = cur[q*3+2]; - cur[q*4+1] = cur[q*3+1]; - cur[q*4+0] = cur[q*3+0]; - } - } - } - } - } else if (depth == 16) { - // force the image data from big-endian to platform-native. - // this is done in a separate pass due to the decoding relying - // on the data being untouched, but could probably be done - // per-line during decode if care is taken. - stbi_uc *cur = a->out; - stbi__uint16 *cur16 = (stbi__uint16*)cur; - - for(i=0; i < x*y*out_n; ++i,cur16++,cur+=2) { - *cur16 = (cur[0] << 8) | cur[1]; - } - } - - return 1; -} - -static int stbi__create_png_image(stbi__png *a, stbi_uc *image_data, stbi__uint32 image_data_len, int out_n, int depth, int color, int interlaced) -{ - int bytes = (depth == 16 ? 2 : 1); - int out_bytes = out_n * bytes; - stbi_uc *final; - int p; - if (!interlaced) - return stbi__create_png_image_raw(a, image_data, image_data_len, out_n, a->s->img_x, a->s->img_y, depth, color); - - // de-interlacing - final = (stbi_uc *) stbi__malloc_mad3(a->s->img_x, a->s->img_y, out_bytes, 0); - for (p=0; p < 7; ++p) { - int xorig[] = { 0,4,0,2,0,1,0 }; - int yorig[] = { 0,0,4,0,2,0,1 }; - int xspc[] = { 8,8,4,4,2,2,1 }; - int yspc[] = { 8,8,8,4,4,2,2 }; - int i,j,x,y; - // pass1_x[4] = 0, pass1_x[5] = 1, pass1_x[12] = 1 - x = (a->s->img_x - xorig[p] + xspc[p]-1) / xspc[p]; - y = (a->s->img_y - yorig[p] + yspc[p]-1) / yspc[p]; - if (x && y) { - stbi__uint32 img_len = ((((a->s->img_n * x * depth) + 7) >> 3) + 1) * y; - if (!stbi__create_png_image_raw(a, image_data, image_data_len, out_n, x, y, depth, color)) { - STBI_FREE(final); - return 0; - } - for (j=0; j < y; ++j) { - for (i=0; i < x; ++i) { - int out_y = j*yspc[p]+yorig[p]; - int out_x = i*xspc[p]+xorig[p]; - memcpy(final + out_y*a->s->img_x*out_bytes + out_x*out_bytes, - a->out + (j*x+i)*out_bytes, out_bytes); - } - } - STBI_FREE(a->out); - image_data += img_len; - image_data_len -= img_len; - } - } - a->out = final; - - return 1; -} - -static int stbi__compute_transparency(stbi__png *z, stbi_uc tc[3], int out_n) -{ - stbi__context *s = z->s; - stbi__uint32 i, pixel_count = s->img_x * s->img_y; - stbi_uc *p = z->out; - - // compute color-based transparency, assuming we've - // already got 255 as the alpha value in the output - STBI_ASSERT(out_n == 2 || out_n == 4); - - if (out_n == 2) { - for (i=0; i < pixel_count; ++i) { - p[1] = (p[0] == tc[0] ? 0 : 255); - p += 2; - } - } else { - for (i=0; i < pixel_count; ++i) { - if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2]) - p[3] = 0; - p += 4; - } - } - return 1; -} - -static int stbi__compute_transparency16(stbi__png *z, stbi__uint16 tc[3], int out_n) -{ - stbi__context *s = z->s; - stbi__uint32 i, pixel_count = s->img_x * s->img_y; - stbi__uint16 *p = (stbi__uint16*) z->out; - - // compute color-based transparency, assuming we've - // already got 65535 as the alpha value in the output - STBI_ASSERT(out_n == 2 || out_n == 4); - - if (out_n == 2) { - for (i = 0; i < pixel_count; ++i) { - p[1] = (p[0] == tc[0] ? 0 : 65535); - p += 2; - } - } else { - for (i = 0; i < pixel_count; ++i) { - if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2]) - p[3] = 0; - p += 4; - } - } - return 1; -} - -static int stbi__expand_png_palette(stbi__png *a, stbi_uc *palette, int len, int pal_img_n) -{ - stbi__uint32 i, pixel_count = a->s->img_x * a->s->img_y; - stbi_uc *p, *temp_out, *orig = a->out; - - p = (stbi_uc *) stbi__malloc_mad2(pixel_count, pal_img_n, 0); - if (p == NULL) return stbi__err("outofmem", "Out of memory"); - - // between here and free(out) below, exitting would leak - temp_out = p; - - if (pal_img_n == 3) { - for (i=0; i < pixel_count; ++i) { - int n = orig[i]*4; - p[0] = palette[n ]; - p[1] = palette[n+1]; - p[2] = palette[n+2]; - p += 3; - } - } else { - for (i=0; i < pixel_count; ++i) { - int n = orig[i]*4; - p[0] = palette[n ]; - p[1] = palette[n+1]; - p[2] = palette[n+2]; - p[3] = palette[n+3]; - p += 4; - } - } - STBI_FREE(a->out); - a->out = temp_out; - - STBI_NOTUSED(len); - - return 1; -} - -static int stbi__unpremultiply_on_load = 0; -static int stbi__de_iphone_flag = 0; - -STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply) -{ - stbi__unpremultiply_on_load = flag_true_if_should_unpremultiply; -} - -STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert) -{ - stbi__de_iphone_flag = flag_true_if_should_convert; -} - -static void stbi__de_iphone(stbi__png *z) -{ - stbi__context *s = z->s; - stbi__uint32 i, pixel_count = s->img_x * s->img_y; - stbi_uc *p = z->out; - - if (s->img_out_n == 3) { // convert bgr to rgb - for (i=0; i < pixel_count; ++i) { - stbi_uc t = p[0]; - p[0] = p[2]; - p[2] = t; - p += 3; - } - } else { - STBI_ASSERT(s->img_out_n == 4); - if (stbi__unpremultiply_on_load) { - // convert bgr to rgb and unpremultiply - for (i=0; i < pixel_count; ++i) { - stbi_uc a = p[3]; - stbi_uc t = p[0]; - if (a) { - stbi_uc half = a / 2; - p[0] = (p[2] * 255 + half) / a; - p[1] = (p[1] * 255 + half) / a; - p[2] = ( t * 255 + half) / a; - } else { - p[0] = p[2]; - p[2] = t; - } - p += 4; - } - } else { - // convert bgr to rgb - for (i=0; i < pixel_count; ++i) { - stbi_uc t = p[0]; - p[0] = p[2]; - p[2] = t; - p += 4; - } - } - } -} - -#define STBI__PNG_TYPE(a,b,c,d) (((unsigned) (a) << 24) + ((unsigned) (b) << 16) + ((unsigned) (c) << 8) + (unsigned) (d)) - -static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp) -{ - stbi_uc palette[1024], pal_img_n=0; - stbi_uc has_trans=0, tc[3]={0}; - stbi__uint16 tc16[3]; - stbi__uint32 ioff=0, idata_limit=0, i, pal_len=0; - int first=1,k,interlace=0, color=0, is_iphone=0; - stbi__context *s = z->s; - - z->expanded = NULL; - z->idata = NULL; - z->out = NULL; - - if (!stbi__check_png_header(s)) return 0; - - if (scan == STBI__SCAN_type) return 1; - - for (;;) { - stbi__pngchunk c = stbi__get_chunk_header(s); - switch (c.type) { - case STBI__PNG_TYPE('C','g','B','I'): - is_iphone = 1; - stbi__skip(s, c.length); - break; - case STBI__PNG_TYPE('I','H','D','R'): { - int comp,filter; - if (!first) return stbi__err("multiple IHDR","Corrupt PNG"); - first = 0; - if (c.length != 13) return stbi__err("bad IHDR len","Corrupt PNG"); - s->img_x = stbi__get32be(s); if (s->img_x > (1 << 24)) return stbi__err("too large","Very large image (corrupt?)"); - s->img_y = stbi__get32be(s); if (s->img_y > (1 << 24)) return stbi__err("too large","Very large image (corrupt?)"); - z->depth = stbi__get8(s); if (z->depth != 1 && z->depth != 2 && z->depth != 4 && z->depth != 8 && z->depth != 16) return stbi__err("1/2/4/8/16-bit only","PNG not supported: 1/2/4/8/16-bit only"); - color = stbi__get8(s); if (color > 6) return stbi__err("bad ctype","Corrupt PNG"); - if (color == 3 && z->depth == 16) return stbi__err("bad ctype","Corrupt PNG"); - if (color == 3) pal_img_n = 3; else if (color & 1) return stbi__err("bad ctype","Corrupt PNG"); - comp = stbi__get8(s); if (comp) return stbi__err("bad comp method","Corrupt PNG"); - filter= stbi__get8(s); if (filter) return stbi__err("bad filter method","Corrupt PNG"); - interlace = stbi__get8(s); if (interlace>1) return stbi__err("bad interlace method","Corrupt PNG"); - if (!s->img_x || !s->img_y) return stbi__err("0-pixel image","Corrupt PNG"); - if (!pal_img_n) { - s->img_n = (color & 2 ? 3 : 1) + (color & 4 ? 1 : 0); - if ((1 << 30) / s->img_x / s->img_n < s->img_y) return stbi__err("too large", "Image too large to decode"); - if (scan == STBI__SCAN_header) return 1; - } else { - // if paletted, then pal_n is our final components, and - // img_n is # components to decompress/filter. - s->img_n = 1; - if ((1 << 30) / s->img_x / 4 < s->img_y) return stbi__err("too large","Corrupt PNG"); - // if SCAN_header, have to scan to see if we have a tRNS - } - break; - } - - case STBI__PNG_TYPE('P','L','T','E'): { - if (first) return stbi__err("first not IHDR", "Corrupt PNG"); - if (c.length > 256*3) return stbi__err("invalid PLTE","Corrupt PNG"); - pal_len = c.length / 3; - if (pal_len * 3 != c.length) return stbi__err("invalid PLTE","Corrupt PNG"); - for (i=0; i < pal_len; ++i) { - palette[i*4+0] = stbi__get8(s); - palette[i*4+1] = stbi__get8(s); - palette[i*4+2] = stbi__get8(s); - palette[i*4+3] = 255; - } - break; - } - - case STBI__PNG_TYPE('t','R','N','S'): { - if (first) return stbi__err("first not IHDR", "Corrupt PNG"); - if (z->idata) return stbi__err("tRNS after IDAT","Corrupt PNG"); - if (pal_img_n) { - if (scan == STBI__SCAN_header) { s->img_n = 4; return 1; } - if (pal_len == 0) return stbi__err("tRNS before PLTE","Corrupt PNG"); - if (c.length > pal_len) return stbi__err("bad tRNS len","Corrupt PNG"); - pal_img_n = 4; - for (i=0; i < c.length; ++i) - palette[i*4+3] = stbi__get8(s); - } else { - if (!(s->img_n & 1)) return stbi__err("tRNS with alpha","Corrupt PNG"); - if (c.length != (stbi__uint32) s->img_n*2) return stbi__err("bad tRNS len","Corrupt PNG"); - has_trans = 1; - if (z->depth == 16) { - for (k = 0; k < s->img_n; ++k) tc16[k] = (stbi__uint16)stbi__get16be(s); // copy the values as-is - } else { - for (k = 0; k < s->img_n; ++k) tc[k] = (stbi_uc)(stbi__get16be(s) & 255) * stbi__depth_scale_table[z->depth]; // non 8-bit images will be larger - } - } - break; - } - - case STBI__PNG_TYPE('I','D','A','T'): { - if (first) return stbi__err("first not IHDR", "Corrupt PNG"); - if (pal_img_n && !pal_len) return stbi__err("no PLTE","Corrupt PNG"); - if (scan == STBI__SCAN_header) { s->img_n = pal_img_n; return 1; } - if ((int)(ioff + c.length) < (int)ioff) return 0; - if (ioff + c.length > idata_limit) { - stbi__uint32 idata_limit_old = idata_limit; - stbi_uc *p; - if (idata_limit == 0) idata_limit = c.length > 4096 ? c.length : 4096; - while (ioff + c.length > idata_limit) - idata_limit *= 2; - STBI_NOTUSED(idata_limit_old); - p = (stbi_uc *) STBI_REALLOC_SIZED(z->idata, idata_limit_old, idata_limit); if (p == NULL) return stbi__err("outofmem", "Out of memory"); - z->idata = p; - } - if (!stbi__getn(s, z->idata+ioff,c.length)) return stbi__err("outofdata","Corrupt PNG"); - ioff += c.length; - break; - } - - case STBI__PNG_TYPE('I','E','N','D'): { - stbi__uint32 raw_len, bpl; - if (first) return stbi__err("first not IHDR", "Corrupt PNG"); - if (scan != STBI__SCAN_load) return 1; - if (z->idata == NULL) return stbi__err("no IDAT","Corrupt PNG"); - // initial guess for decoded data size to avoid unnecessary reallocs - bpl = (s->img_x * z->depth + 7) / 8; // bytes per line, per component - raw_len = bpl * s->img_y * s->img_n /* pixels */ + s->img_y /* filter mode per row */; - z->expanded = (stbi_uc *) stbi_zlib_decode_malloc_guesssize_headerflag((char *) z->idata, ioff, raw_len, (int *) &raw_len, !is_iphone); - if (z->expanded == NULL) return 0; // zlib should set error - STBI_FREE(z->idata); z->idata = NULL; - if ((req_comp == s->img_n+1 && req_comp != 3 && !pal_img_n) || has_trans) - s->img_out_n = s->img_n+1; - else - s->img_out_n = s->img_n; - if (!stbi__create_png_image(z, z->expanded, raw_len, s->img_out_n, z->depth, color, interlace)) return 0; - if (has_trans) { - if (z->depth == 16) { - if (!stbi__compute_transparency16(z, tc16, s->img_out_n)) return 0; - } else { - if (!stbi__compute_transparency(z, tc, s->img_out_n)) return 0; - } - } - if (is_iphone && stbi__de_iphone_flag && s->img_out_n > 2) - stbi__de_iphone(z); - if (pal_img_n) { - // pal_img_n == 3 or 4 - s->img_n = pal_img_n; // record the actual colors we had - s->img_out_n = pal_img_n; - if (req_comp >= 3) s->img_out_n = req_comp; - if (!stbi__expand_png_palette(z, palette, pal_len, s->img_out_n)) - return 0; - } else if (has_trans) { - // non-paletted image with tRNS -> source image has (constant) alpha - ++s->img_n; - } - STBI_FREE(z->expanded); z->expanded = NULL; - // end of PNG chunk, read and skip CRC - stbi__get32be(s); - return 1; - } - - default: - // if critical, fail - if (first) return stbi__err("first not IHDR", "Corrupt PNG"); - if ((c.type & (1 << 29)) == 0) { - #ifndef STBI_NO_FAILURE_STRINGS - // not threadsafe - static char invalid_chunk[] = "XXXX PNG chunk not known"; - invalid_chunk[0] = STBI__BYTECAST(c.type >> 24); - invalid_chunk[1] = STBI__BYTECAST(c.type >> 16); - invalid_chunk[2] = STBI__BYTECAST(c.type >> 8); - invalid_chunk[3] = STBI__BYTECAST(c.type >> 0); - #endif - return stbi__err(invalid_chunk, "PNG not supported: unknown PNG chunk type"); - } - stbi__skip(s, c.length); - break; - } - // end of PNG chunk, read and skip CRC - stbi__get32be(s); - } -} - -static void *stbi__do_png(stbi__png *p, int *x, int *y, int *n, int req_comp, stbi__result_info *ri) -{ - void *result=NULL; - if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error"); - if (stbi__parse_png_file(p, STBI__SCAN_load, req_comp)) { - if (p->depth < 8) - ri->bits_per_channel = 8; - else - ri->bits_per_channel = p->depth; - result = p->out; - p->out = NULL; - if (req_comp && req_comp != p->s->img_out_n) { - if (ri->bits_per_channel == 8) - result = stbi__convert_format((unsigned char *) result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y); - else - result = stbi__convert_format16((stbi__uint16 *) result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y); - p->s->img_out_n = req_comp; - if (result == NULL) return result; - } - *x = p->s->img_x; - *y = p->s->img_y; - if (n) *n = p->s->img_n; - } - STBI_FREE(p->out); p->out = NULL; - STBI_FREE(p->expanded); p->expanded = NULL; - STBI_FREE(p->idata); p->idata = NULL; - - return result; -} - -static void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) -{ - stbi__png p; - p.s = s; - return stbi__do_png(&p, x,y,comp,req_comp, ri); -} - -static int stbi__png_test(stbi__context *s) -{ - int r; - r = stbi__check_png_header(s); - stbi__rewind(s); - return r; -} - -static int stbi__png_info_raw(stbi__png *p, int *x, int *y, int *comp) -{ - if (!stbi__parse_png_file(p, STBI__SCAN_header, 0)) { - stbi__rewind( p->s ); - return 0; - } - if (x) *x = p->s->img_x; - if (y) *y = p->s->img_y; - if (comp) *comp = p->s->img_n; - return 1; -} - -static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp) -{ - stbi__png p; - p.s = s; - return stbi__png_info_raw(&p, x, y, comp); -} - -static int stbi__png_is16(stbi__context *s) -{ - stbi__png p; - p.s = s; - if (!stbi__png_info_raw(&p, NULL, NULL, NULL)) - return 0; - if (p.depth != 16) { - stbi__rewind(p.s); - return 0; - } - return 1; -} -#endif - -// Microsoft/Windows BMP image - -#ifndef STBI_NO_BMP -static int stbi__bmp_test_raw(stbi__context *s) -{ - int r; - int sz; - if (stbi__get8(s) != 'B') return 0; - if (stbi__get8(s) != 'M') return 0; - stbi__get32le(s); // discard filesize - stbi__get16le(s); // discard reserved - stbi__get16le(s); // discard reserved - stbi__get32le(s); // discard data offset - sz = stbi__get32le(s); - r = (sz == 12 || sz == 40 || sz == 56 || sz == 108 || sz == 124); - return r; -} - -static int stbi__bmp_test(stbi__context *s) -{ - int r = stbi__bmp_test_raw(s); - stbi__rewind(s); - return r; -} - - -// returns 0..31 for the highest set bit -static int stbi__high_bit(unsigned int z) -{ - int n=0; - if (z == 0) return -1; - if (z >= 0x10000) { n += 16; z >>= 16; } - if (z >= 0x00100) { n += 8; z >>= 8; } - if (z >= 0x00010) { n += 4; z >>= 4; } - if (z >= 0x00004) { n += 2; z >>= 2; } - if (z >= 0x00002) { n += 1;/* >>= 1;*/ } - return n; -} - -static int stbi__bitcount(unsigned int a) -{ - a = (a & 0x55555555) + ((a >> 1) & 0x55555555); // max 2 - a = (a & 0x33333333) + ((a >> 2) & 0x33333333); // max 4 - a = (a + (a >> 4)) & 0x0f0f0f0f; // max 8 per 4, now 8 bits - a = (a + (a >> 8)); // max 16 per 8 bits - a = (a + (a >> 16)); // max 32 per 8 bits - return a & 0xff; -} - -// extract an arbitrarily-aligned N-bit value (N=bits) -// from v, and then make it 8-bits long and fractionally -// extend it to full full range. -static int stbi__shiftsigned(unsigned int v, int shift, int bits) -{ - static unsigned int mul_table[9] = { - 0, - 0xff/*0b11111111*/, 0x55/*0b01010101*/, 0x49/*0b01001001*/, 0x11/*0b00010001*/, - 0x21/*0b00100001*/, 0x41/*0b01000001*/, 0x81/*0b10000001*/, 0x01/*0b00000001*/, - }; - static unsigned int shift_table[9] = { - 0, 0,0,1,0,2,4,6,0, - }; - if (shift < 0) - v <<= -shift; - else - v >>= shift; - STBI_ASSERT(v < 256); - v >>= (8-bits); - STBI_ASSERT(bits >= 0 && bits <= 8); - return (int) ((unsigned) v * mul_table[bits]) >> shift_table[bits]; -} - -typedef struct -{ - int bpp, offset, hsz; - unsigned int mr,mg,mb,ma, all_a; - int extra_read; -} stbi__bmp_data; - -static void *stbi__bmp_parse_header(stbi__context *s, stbi__bmp_data *info) -{ - int hsz; - if (stbi__get8(s) != 'B' || stbi__get8(s) != 'M') return stbi__errpuc("not BMP", "Corrupt BMP"); - stbi__get32le(s); // discard filesize - stbi__get16le(s); // discard reserved - stbi__get16le(s); // discard reserved - info->offset = stbi__get32le(s); - info->hsz = hsz = stbi__get32le(s); - info->mr = info->mg = info->mb = info->ma = 0; - info->extra_read = 14; - - if (hsz != 12 && hsz != 40 && hsz != 56 && hsz != 108 && hsz != 124) return stbi__errpuc("unknown BMP", "BMP type not supported: unknown"); - if (hsz == 12) { - s->img_x = stbi__get16le(s); - s->img_y = stbi__get16le(s); - } else { - s->img_x = stbi__get32le(s); - s->img_y = stbi__get32le(s); - } - if (stbi__get16le(s) != 1) return stbi__errpuc("bad BMP", "bad BMP"); - info->bpp = stbi__get16le(s); - if (hsz != 12) { - int compress = stbi__get32le(s); - if (compress == 1 || compress == 2) return stbi__errpuc("BMP RLE", "BMP type not supported: RLE"); - stbi__get32le(s); // discard sizeof - stbi__get32le(s); // discard hres - stbi__get32le(s); // discard vres - stbi__get32le(s); // discard colorsused - stbi__get32le(s); // discard max important - if (hsz == 40 || hsz == 56) { - if (hsz == 56) { - stbi__get32le(s); - stbi__get32le(s); - stbi__get32le(s); - stbi__get32le(s); - } - if (info->bpp == 16 || info->bpp == 32) { - if (compress == 0) { - if (info->bpp == 32) { - info->mr = 0xffu << 16; - info->mg = 0xffu << 8; - info->mb = 0xffu << 0; - info->ma = 0xffu << 24; - info->all_a = 0; // if all_a is 0 at end, then we loaded alpha channel but it was all 0 - } else { - info->mr = 31u << 10; - info->mg = 31u << 5; - info->mb = 31u << 0; - } - } else if (compress == 3) { - info->mr = stbi__get32le(s); - info->mg = stbi__get32le(s); - info->mb = stbi__get32le(s); - info->extra_read += 12; - // not documented, but generated by photoshop and handled by mspaint - if (info->mr == info->mg && info->mg == info->mb) { - // ?!?!? - return stbi__errpuc("bad BMP", "bad BMP"); - } - } else - return stbi__errpuc("bad BMP", "bad BMP"); - } - } else { - int i; - if (hsz != 108 && hsz != 124) - return stbi__errpuc("bad BMP", "bad BMP"); - info->mr = stbi__get32le(s); - info->mg = stbi__get32le(s); - info->mb = stbi__get32le(s); - info->ma = stbi__get32le(s); - stbi__get32le(s); // discard color space - for (i=0; i < 12; ++i) - stbi__get32le(s); // discard color space parameters - if (hsz == 124) { - stbi__get32le(s); // discard rendering intent - stbi__get32le(s); // discard offset of profile data - stbi__get32le(s); // discard size of profile data - stbi__get32le(s); // discard reserved - } - } - } - return (void *) 1; -} - - -static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) -{ - stbi_uc *out; - unsigned int mr=0,mg=0,mb=0,ma=0, all_a; - stbi_uc pal[256][4]; - int psize=0,i,j,width; - int flip_vertically, pad, target; - stbi__bmp_data info; - STBI_NOTUSED(ri); - - info.all_a = 255; - if (stbi__bmp_parse_header(s, &info) == NULL) - return NULL; // error code already set - - flip_vertically = ((int) s->img_y) > 0; - s->img_y = abs((int) s->img_y); - - mr = info.mr; - mg = info.mg; - mb = info.mb; - ma = info.ma; - all_a = info.all_a; - - if (info.hsz == 12) { - if (info.bpp < 24) - psize = (info.offset - info.extra_read - 24) / 3; - } else { - if (info.bpp < 16) - psize = (info.offset - info.extra_read - info.hsz) >> 2; - } - if (psize == 0) { - STBI_ASSERT(info.offset == (s->img_buffer - s->buffer_start)); - } - - if (info.bpp == 24 && ma == 0xff000000) - s->img_n = 3; - else - s->img_n = ma ? 4 : 3; - if (req_comp && req_comp >= 3) // we can directly decode 3 or 4 - target = req_comp; - else - target = s->img_n; // if they want monochrome, we'll post-convert - - // sanity-check size - if (!stbi__mad3sizes_valid(target, s->img_x, s->img_y, 0)) - return stbi__errpuc("too large", "Corrupt BMP"); - - out = (stbi_uc *) stbi__malloc_mad3(target, s->img_x, s->img_y, 0); - if (!out) return stbi__errpuc("outofmem", "Out of memory"); - if (info.bpp < 16) { - int z=0; - if (psize == 0 || psize > 256) { STBI_FREE(out); return stbi__errpuc("invalid", "Corrupt BMP"); } - for (i=0; i < psize; ++i) { - pal[i][2] = stbi__get8(s); - pal[i][1] = stbi__get8(s); - pal[i][0] = stbi__get8(s); - if (info.hsz != 12) stbi__get8(s); - pal[i][3] = 255; - } - stbi__skip(s, info.offset - info.extra_read - info.hsz - psize * (info.hsz == 12 ? 3 : 4)); - if (info.bpp == 1) width = (s->img_x + 7) >> 3; - else if (info.bpp == 4) width = (s->img_x + 1) >> 1; - else if (info.bpp == 8) width = s->img_x; - else { STBI_FREE(out); return stbi__errpuc("bad bpp", "Corrupt BMP"); } - pad = (-width)&3; - if (info.bpp == 1) { - for (j=0; j < (int) s->img_y; ++j) { - int bit_offset = 7, v = stbi__get8(s); - for (i=0; i < (int) s->img_x; ++i) { - int color = (v>>bit_offset)&0x1; - out[z++] = pal[color][0]; - out[z++] = pal[color][1]; - out[z++] = pal[color][2]; - if (target == 4) out[z++] = 255; - if (i+1 == (int) s->img_x) break; - if((--bit_offset) < 0) { - bit_offset = 7; - v = stbi__get8(s); - } - } - stbi__skip(s, pad); - } - } else { - for (j=0; j < (int) s->img_y; ++j) { - for (i=0; i < (int) s->img_x; i += 2) { - int v=stbi__get8(s),v2=0; - if (info.bpp == 4) { - v2 = v & 15; - v >>= 4; - } - out[z++] = pal[v][0]; - out[z++] = pal[v][1]; - out[z++] = pal[v][2]; - if (target == 4) out[z++] = 255; - if (i+1 == (int) s->img_x) break; - v = (info.bpp == 8) ? stbi__get8(s) : v2; - out[z++] = pal[v][0]; - out[z++] = pal[v][1]; - out[z++] = pal[v][2]; - if (target == 4) out[z++] = 255; - } - stbi__skip(s, pad); - } - } - } else { - int rshift=0,gshift=0,bshift=0,ashift=0,rcount=0,gcount=0,bcount=0,acount=0; - int z = 0; - int easy=0; - stbi__skip(s, info.offset - info.extra_read - info.hsz); - if (info.bpp == 24) width = 3 * s->img_x; - else if (info.bpp == 16) width = 2*s->img_x; - else /* bpp = 32 and pad = 0 */ width=0; - pad = (-width) & 3; - if (info.bpp == 24) { - easy = 1; - } else if (info.bpp == 32) { - if (mb == 0xff && mg == 0xff00 && mr == 0x00ff0000 && ma == 0xff000000) - easy = 2; - } - if (!easy) { - if (!mr || !mg || !mb) { STBI_FREE(out); return stbi__errpuc("bad masks", "Corrupt BMP"); } - // right shift amt to put high bit in position #7 - rshift = stbi__high_bit(mr)-7; rcount = stbi__bitcount(mr); - gshift = stbi__high_bit(mg)-7; gcount = stbi__bitcount(mg); - bshift = stbi__high_bit(mb)-7; bcount = stbi__bitcount(mb); - ashift = stbi__high_bit(ma)-7; acount = stbi__bitcount(ma); - } - for (j=0; j < (int) s->img_y; ++j) { - if (easy) { - for (i=0; i < (int) s->img_x; ++i) { - unsigned char a; - out[z+2] = stbi__get8(s); - out[z+1] = stbi__get8(s); - out[z+0] = stbi__get8(s); - z += 3; - a = (easy == 2 ? stbi__get8(s) : 255); - all_a |= a; - if (target == 4) out[z++] = a; - } - } else { - int bpp = info.bpp; - for (i=0; i < (int) s->img_x; ++i) { - stbi__uint32 v = (bpp == 16 ? (stbi__uint32) stbi__get16le(s) : stbi__get32le(s)); - unsigned int a; - out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mr, rshift, rcount)); - out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mg, gshift, gcount)); - out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mb, bshift, bcount)); - a = (ma ? stbi__shiftsigned(v & ma, ashift, acount) : 255); - all_a |= a; - if (target == 4) out[z++] = STBI__BYTECAST(a); - } - } - stbi__skip(s, pad); - } - } - - // if alpha channel is all 0s, replace with all 255s - if (target == 4 && all_a == 0) - for (i=4*s->img_x*s->img_y-1; i >= 0; i -= 4) - out[i] = 255; - - if (flip_vertically) { - stbi_uc t; - for (j=0; j < (int) s->img_y>>1; ++j) { - stbi_uc *p1 = out + j *s->img_x*target; - stbi_uc *p2 = out + (s->img_y-1-j)*s->img_x*target; - for (i=0; i < (int) s->img_x*target; ++i) { - t = p1[i]; p1[i] = p2[i]; p2[i] = t; - } - } - } - - if (req_comp && req_comp != target) { - out = stbi__convert_format(out, target, req_comp, s->img_x, s->img_y); - if (out == NULL) return out; // stbi__convert_format frees input on failure - } - - *x = s->img_x; - *y = s->img_y; - if (comp) *comp = s->img_n; - return out; -} -#endif - -// Targa Truevision - TGA -// by Jonathan Dummer -#ifndef STBI_NO_TGA -// returns STBI_rgb or whatever, 0 on error -static int stbi__tga_get_comp(int bits_per_pixel, int is_grey, int* is_rgb16) -{ - // only RGB or RGBA (incl. 16bit) or grey allowed - if (is_rgb16) *is_rgb16 = 0; - switch(bits_per_pixel) { - case 8: return STBI_grey; - case 16: if(is_grey) return STBI_grey_alpha; - // fallthrough - case 15: if(is_rgb16) *is_rgb16 = 1; - return STBI_rgb; - case 24: // fallthrough - case 32: return bits_per_pixel/8; - default: return 0; - } -} - -static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp) -{ - int tga_w, tga_h, tga_comp, tga_image_type, tga_bits_per_pixel, tga_colormap_bpp; - int sz, tga_colormap_type; - stbi__get8(s); // discard Offset - tga_colormap_type = stbi__get8(s); // colormap type - if( tga_colormap_type > 1 ) { - stbi__rewind(s); - return 0; // only RGB or indexed allowed - } - tga_image_type = stbi__get8(s); // image type - if ( tga_colormap_type == 1 ) { // colormapped (paletted) image - if (tga_image_type != 1 && tga_image_type != 9) { - stbi__rewind(s); - return 0; - } - stbi__skip(s,4); // skip index of first colormap entry and number of entries - sz = stbi__get8(s); // check bits per palette color entry - if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) { - stbi__rewind(s); - return 0; - } - stbi__skip(s,4); // skip image x and y origin - tga_colormap_bpp = sz; - } else { // "normal" image w/o colormap - only RGB or grey allowed, +/- RLE - if ( (tga_image_type != 2) && (tga_image_type != 3) && (tga_image_type != 10) && (tga_image_type != 11) ) { - stbi__rewind(s); - return 0; // only RGB or grey allowed, +/- RLE - } - stbi__skip(s,9); // skip colormap specification and image x/y origin - tga_colormap_bpp = 0; - } - tga_w = stbi__get16le(s); - if( tga_w < 1 ) { - stbi__rewind(s); - return 0; // test width - } - tga_h = stbi__get16le(s); - if( tga_h < 1 ) { - stbi__rewind(s); - return 0; // test height - } - tga_bits_per_pixel = stbi__get8(s); // bits per pixel - stbi__get8(s); // ignore alpha bits - if (tga_colormap_bpp != 0) { - if((tga_bits_per_pixel != 8) && (tga_bits_per_pixel != 16)) { - // when using a colormap, tga_bits_per_pixel is the size of the indexes - // I don't think anything but 8 or 16bit indexes makes sense - stbi__rewind(s); - return 0; - } - tga_comp = stbi__tga_get_comp(tga_colormap_bpp, 0, NULL); - } else { - tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3) || (tga_image_type == 11), NULL); - } - if(!tga_comp) { - stbi__rewind(s); - return 0; - } - if (x) *x = tga_w; - if (y) *y = tga_h; - if (comp) *comp = tga_comp; - return 1; // seems to have passed everything -} - -static int stbi__tga_test(stbi__context *s) -{ - int res = 0; - int sz, tga_color_type; - stbi__get8(s); // discard Offset - tga_color_type = stbi__get8(s); // color type - if ( tga_color_type > 1 ) goto errorEnd; // only RGB or indexed allowed - sz = stbi__get8(s); // image type - if ( tga_color_type == 1 ) { // colormapped (paletted) image - if (sz != 1 && sz != 9) goto errorEnd; // colortype 1 demands image type 1 or 9 - stbi__skip(s,4); // skip index of first colormap entry and number of entries - sz = stbi__get8(s); // check bits per palette color entry - if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd; - stbi__skip(s,4); // skip image x and y origin - } else { // "normal" image w/o colormap - if ( (sz != 2) && (sz != 3) && (sz != 10) && (sz != 11) ) goto errorEnd; // only RGB or grey allowed, +/- RLE - stbi__skip(s,9); // skip colormap specification and image x/y origin - } - if ( stbi__get16le(s) < 1 ) goto errorEnd; // test width - if ( stbi__get16le(s) < 1 ) goto errorEnd; // test height - sz = stbi__get8(s); // bits per pixel - if ( (tga_color_type == 1) && (sz != 8) && (sz != 16) ) goto errorEnd; // for colormapped images, bpp is size of an index - if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd; - - res = 1; // if we got this far, everything's good and we can return 1 instead of 0 - -errorEnd: - stbi__rewind(s); - return res; -} - -// read 16bit value and convert to 24bit RGB -static void stbi__tga_read_rgb16(stbi__context *s, stbi_uc* out) -{ - stbi__uint16 px = (stbi__uint16)stbi__get16le(s); - stbi__uint16 fiveBitMask = 31; - // we have 3 channels with 5bits each - int r = (px >> 10) & fiveBitMask; - int g = (px >> 5) & fiveBitMask; - int b = px & fiveBitMask; - // Note that this saves the data in RGB(A) order, so it doesn't need to be swapped later - out[0] = (stbi_uc)((r * 255)/31); - out[1] = (stbi_uc)((g * 255)/31); - out[2] = (stbi_uc)((b * 255)/31); - - // some people claim that the most significant bit might be used for alpha - // (possibly if an alpha-bit is set in the "image descriptor byte") - // but that only made 16bit test images completely translucent.. - // so let's treat all 15 and 16bit TGAs as RGB with no alpha. -} - -static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) -{ - // read in the TGA header stuff - int tga_offset = stbi__get8(s); - int tga_indexed = stbi__get8(s); - int tga_image_type = stbi__get8(s); - int tga_is_RLE = 0; - int tga_palette_start = stbi__get16le(s); - int tga_palette_len = stbi__get16le(s); - int tga_palette_bits = stbi__get8(s); - int tga_x_origin = stbi__get16le(s); - int tga_y_origin = stbi__get16le(s); - int tga_width = stbi__get16le(s); - int tga_height = stbi__get16le(s); - int tga_bits_per_pixel = stbi__get8(s); - int tga_comp, tga_rgb16=0; - int tga_inverted = stbi__get8(s); - // int tga_alpha_bits = tga_inverted & 15; // the 4 lowest bits - unused (useless?) - // image data - unsigned char *tga_data; - unsigned char *tga_palette = NULL; - int i, j; - unsigned char raw_data[4] = {0}; - int RLE_count = 0; - int RLE_repeating = 0; - int read_next_pixel = 1; - STBI_NOTUSED(ri); - STBI_NOTUSED(tga_x_origin); // @TODO - STBI_NOTUSED(tga_y_origin); // @TODO - - // do a tiny bit of precessing - if ( tga_image_type >= 8 ) - { - tga_image_type -= 8; - tga_is_RLE = 1; - } - tga_inverted = 1 - ((tga_inverted >> 5) & 1); - - // If I'm paletted, then I'll use the number of bits from the palette - if ( tga_indexed ) tga_comp = stbi__tga_get_comp(tga_palette_bits, 0, &tga_rgb16); - else tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3), &tga_rgb16); - - if(!tga_comp) // shouldn't really happen, stbi__tga_test() should have ensured basic consistency - return stbi__errpuc("bad format", "Can't find out TGA pixelformat"); - - // tga info - *x = tga_width; - *y = tga_height; - if (comp) *comp = tga_comp; - - if (!stbi__mad3sizes_valid(tga_width, tga_height, tga_comp, 0)) - return stbi__errpuc("too large", "Corrupt TGA"); - - tga_data = (unsigned char*)stbi__malloc_mad3(tga_width, tga_height, tga_comp, 0); - if (!tga_data) return stbi__errpuc("outofmem", "Out of memory"); - - // skip to the data's starting position (offset usually = 0) - stbi__skip(s, tga_offset ); - - if ( !tga_indexed && !tga_is_RLE && !tga_rgb16 ) { - for (i=0; i < tga_height; ++i) { - int row = tga_inverted ? tga_height -i - 1 : i; - stbi_uc *tga_row = tga_data + row*tga_width*tga_comp; - stbi__getn(s, tga_row, tga_width * tga_comp); - } - } else { - // do I need to load a palette? - if ( tga_indexed) - { - // any data to skip? (offset usually = 0) - stbi__skip(s, tga_palette_start ); - // load the palette - tga_palette = (unsigned char*)stbi__malloc_mad2(tga_palette_len, tga_comp, 0); - if (!tga_palette) { - STBI_FREE(tga_data); - return stbi__errpuc("outofmem", "Out of memory"); - } - if (tga_rgb16) { - stbi_uc *pal_entry = tga_palette; - STBI_ASSERT(tga_comp == STBI_rgb); - for (i=0; i < tga_palette_len; ++i) { - stbi__tga_read_rgb16(s, pal_entry); - pal_entry += tga_comp; - } - } else if (!stbi__getn(s, tga_palette, tga_palette_len * tga_comp)) { - STBI_FREE(tga_data); - STBI_FREE(tga_palette); - return stbi__errpuc("bad palette", "Corrupt TGA"); - } - } - // load the data - for (i=0; i < tga_width * tga_height; ++i) - { - // if I'm in RLE mode, do I need to get a RLE stbi__pngchunk? - if ( tga_is_RLE ) - { - if ( RLE_count == 0 ) - { - // yep, get the next byte as a RLE command - int RLE_cmd = stbi__get8(s); - RLE_count = 1 + (RLE_cmd & 127); - RLE_repeating = RLE_cmd >> 7; - read_next_pixel = 1; - } else if ( !RLE_repeating ) - { - read_next_pixel = 1; - } - } else - { - read_next_pixel = 1; - } - // OK, if I need to read a pixel, do it now - if ( read_next_pixel ) - { - // load however much data we did have - if ( tga_indexed ) - { - // read in index, then perform the lookup - int pal_idx = (tga_bits_per_pixel == 8) ? stbi__get8(s) : stbi__get16le(s); - if ( pal_idx >= tga_palette_len ) { - // invalid index - pal_idx = 0; - } - pal_idx *= tga_comp; - for (j = 0; j < tga_comp; ++j) { - raw_data[j] = tga_palette[pal_idx+j]; - } - } else if(tga_rgb16) { - STBI_ASSERT(tga_comp == STBI_rgb); - stbi__tga_read_rgb16(s, raw_data); - } else { - // read in the data raw - for (j = 0; j < tga_comp; ++j) { - raw_data[j] = stbi__get8(s); - } - } - // clear the reading flag for the next pixel - read_next_pixel = 0; - } // end of reading a pixel - - // copy data - for (j = 0; j < tga_comp; ++j) - tga_data[i*tga_comp+j] = raw_data[j]; - - // in case we're in RLE mode, keep counting down - --RLE_count; - } - // do I need to invert the image? - if ( tga_inverted ) - { - for (j = 0; j*2 < tga_height; ++j) - { - int index1 = j * tga_width * tga_comp; - int index2 = (tga_height - 1 - j) * tga_width * tga_comp; - for (i = tga_width * tga_comp; i > 0; --i) - { - unsigned char temp = tga_data[index1]; - tga_data[index1] = tga_data[index2]; - tga_data[index2] = temp; - ++index1; - ++index2; - } - } - } - // clear my palette, if I had one - if ( tga_palette != NULL ) - { - STBI_FREE( tga_palette ); - } - } - - // swap RGB - if the source data was RGB16, it already is in the right order - if (tga_comp >= 3 && !tga_rgb16) - { - unsigned char* tga_pixel = tga_data; - for (i=0; i < tga_width * tga_height; ++i) - { - unsigned char temp = tga_pixel[0]; - tga_pixel[0] = tga_pixel[2]; - tga_pixel[2] = temp; - tga_pixel += tga_comp; - } - } - - // convert to target component count - if (req_comp && req_comp != tga_comp) - tga_data = stbi__convert_format(tga_data, tga_comp, req_comp, tga_width, tga_height); - - // the things I do to get rid of an error message, and yet keep - // Microsoft's C compilers happy... [8^( - tga_palette_start = tga_palette_len = tga_palette_bits = - tga_x_origin = tga_y_origin = 0; - STBI_NOTUSED(tga_palette_start); - // OK, done - return tga_data; -} -#endif - -// ************************************************************************************************* -// Photoshop PSD loader -- PD by Thatcher Ulrich, integration by Nicolas Schulz, tweaked by STB - -#ifndef STBI_NO_PSD -static int stbi__psd_test(stbi__context *s) -{ - int r = (stbi__get32be(s) == 0x38425053); - stbi__rewind(s); - return r; -} - -static int stbi__psd_decode_rle(stbi__context *s, stbi_uc *p, int pixelCount) -{ - int count, nleft, len; - - count = 0; - while ((nleft = pixelCount - count) > 0) { - len = stbi__get8(s); - if (len == 128) { - // No-op. - } else if (len < 128) { - // Copy next len+1 bytes literally. - len++; - if (len > nleft) return 0; // corrupt data - count += len; - while (len) { - *p = stbi__get8(s); - p += 4; - len--; - } - } else if (len > 128) { - stbi_uc val; - // Next -len+1 bytes in the dest are replicated from next source byte. - // (Interpret len as a negative 8-bit int.) - len = 257 - len; - if (len > nleft) return 0; // corrupt data - val = stbi__get8(s); - count += len; - while (len) { - *p = val; - p += 4; - len--; - } - } - } - - return 1; -} - -static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc) -{ - int pixelCount; - int channelCount, compression; - int channel, i; - int bitdepth; - int w,h; - stbi_uc *out; - STBI_NOTUSED(ri); - - // Check identifier - if (stbi__get32be(s) != 0x38425053) // "8BPS" - return stbi__errpuc("not PSD", "Corrupt PSD image"); - - // Check file type version. - if (stbi__get16be(s) != 1) - return stbi__errpuc("wrong version", "Unsupported version of PSD image"); - - // Skip 6 reserved bytes. - stbi__skip(s, 6 ); - - // Read the number of channels (R, G, B, A, etc). - channelCount = stbi__get16be(s); - if (channelCount < 0 || channelCount > 16) - return stbi__errpuc("wrong channel count", "Unsupported number of channels in PSD image"); - - // Read the rows and columns of the image. - h = stbi__get32be(s); - w = stbi__get32be(s); - - // Make sure the depth is 8 bits. - bitdepth = stbi__get16be(s); - if (bitdepth != 8 && bitdepth != 16) - return stbi__errpuc("unsupported bit depth", "PSD bit depth is not 8 or 16 bit"); - - // Make sure the color mode is RGB. - // Valid options are: - // 0: Bitmap - // 1: Grayscale - // 2: Indexed color - // 3: RGB color - // 4: CMYK color - // 7: Multichannel - // 8: Duotone - // 9: Lab color - if (stbi__get16be(s) != 3) - return stbi__errpuc("wrong color format", "PSD is not in RGB color format"); - - // Skip the Mode Data. (It's the palette for indexed color; other info for other modes.) - stbi__skip(s,stbi__get32be(s) ); - - // Skip the image resources. (resolution, pen tool paths, etc) - stbi__skip(s, stbi__get32be(s) ); - - // Skip the reserved data. - stbi__skip(s, stbi__get32be(s) ); - - // Find out if the data is compressed. - // Known values: - // 0: no compression - // 1: RLE compressed - compression = stbi__get16be(s); - if (compression > 1) - return stbi__errpuc("bad compression", "PSD has an unknown compression format"); - - // Check size - if (!stbi__mad3sizes_valid(4, w, h, 0)) - return stbi__errpuc("too large", "Corrupt PSD"); - - // Create the destination image. - - if (!compression && bitdepth == 16 && bpc == 16) { - out = (stbi_uc *) stbi__malloc_mad3(8, w, h, 0); - ri->bits_per_channel = 16; - } else - out = (stbi_uc *) stbi__malloc(4 * w*h); - - if (!out) return stbi__errpuc("outofmem", "Out of memory"); - pixelCount = w*h; - - // Initialize the data to zero. - //memset( out, 0, pixelCount * 4 ); - - // Finally, the image data. - if (compression) { - // RLE as used by .PSD and .TIFF - // Loop until you get the number of unpacked bytes you are expecting: - // Read the next source byte into n. - // If n is between 0 and 127 inclusive, copy the next n+1 bytes literally. - // Else if n is between -127 and -1 inclusive, copy the next byte -n+1 times. - // Else if n is 128, noop. - // Endloop - - // The RLE-compressed data is preceded by a 2-byte data count for each row in the data, - // which we're going to just skip. - stbi__skip(s, h * channelCount * 2 ); - - // Read the RLE data by channel. - for (channel = 0; channel < 4; channel++) { - stbi_uc *p; - - p = out+channel; - if (channel >= channelCount) { - // Fill this channel with default data. - for (i = 0; i < pixelCount; i++, p += 4) - *p = (channel == 3 ? 255 : 0); - } else { - // Read the RLE data. - if (!stbi__psd_decode_rle(s, p, pixelCount)) { - STBI_FREE(out); - return stbi__errpuc("corrupt", "bad RLE data"); - } - } - } - - } else { - // We're at the raw image data. It's each channel in order (Red, Green, Blue, Alpha, ...) - // where each channel consists of an 8-bit (or 16-bit) value for each pixel in the image. - - // Read the data by channel. - for (channel = 0; channel < 4; channel++) { - if (channel >= channelCount) { - // Fill this channel with default data. - if (bitdepth == 16 && bpc == 16) { - stbi__uint16 *q = ((stbi__uint16 *) out) + channel; - stbi__uint16 val = channel == 3 ? 65535 : 0; - for (i = 0; i < pixelCount; i++, q += 4) - *q = val; - } else { - stbi_uc *p = out+channel; - stbi_uc val = channel == 3 ? 255 : 0; - for (i = 0; i < pixelCount; i++, p += 4) - *p = val; - } - } else { - if (ri->bits_per_channel == 16) { // output bpc - stbi__uint16 *q = ((stbi__uint16 *) out) + channel; - for (i = 0; i < pixelCount; i++, q += 4) - *q = (stbi__uint16) stbi__get16be(s); - } else { - stbi_uc *p = out+channel; - if (bitdepth == 16) { // input bpc - for (i = 0; i < pixelCount; i++, p += 4) - *p = (stbi_uc) (stbi__get16be(s) >> 8); - } else { - for (i = 0; i < pixelCount; i++, p += 4) - *p = stbi__get8(s); - } - } - } - } - } - - // remove weird white matte from PSD - if (channelCount >= 4) { - if (ri->bits_per_channel == 16) { - for (i=0; i < w*h; ++i) { - stbi__uint16 *pixel = (stbi__uint16 *) out + 4*i; - if (pixel[3] != 0 && pixel[3] != 65535) { - float a = pixel[3] / 65535.0f; - float ra = 1.0f / a; - float inv_a = 65535.0f * (1 - ra); - pixel[0] = (stbi__uint16) (pixel[0]*ra + inv_a); - pixel[1] = (stbi__uint16) (pixel[1]*ra + inv_a); - pixel[2] = (stbi__uint16) (pixel[2]*ra + inv_a); - } - } - } else { - for (i=0; i < w*h; ++i) { - unsigned char *pixel = out + 4*i; - if (pixel[3] != 0 && pixel[3] != 255) { - float a = pixel[3] / 255.0f; - float ra = 1.0f / a; - float inv_a = 255.0f * (1 - ra); - pixel[0] = (unsigned char) (pixel[0]*ra + inv_a); - pixel[1] = (unsigned char) (pixel[1]*ra + inv_a); - pixel[2] = (unsigned char) (pixel[2]*ra + inv_a); - } - } - } - } - - // convert to desired output format - if (req_comp && req_comp != 4) { - if (ri->bits_per_channel == 16) - out = (stbi_uc *) stbi__convert_format16((stbi__uint16 *) out, 4, req_comp, w, h); - else - out = stbi__convert_format(out, 4, req_comp, w, h); - if (out == NULL) return out; // stbi__convert_format frees input on failure - } - - if (comp) *comp = 4; - *y = h; - *x = w; - - return out; -} -#endif - -// ************************************************************************************************* -// Softimage PIC loader -// by Tom Seddon -// -// See http://softimage.wiki.softimage.com/index.php/INFO:_PIC_file_format -// See http://ozviz.wasp.uwa.edu.au/~pbourke/dataformats/softimagepic/ - -#ifndef STBI_NO_PIC -static int stbi__pic_is4(stbi__context *s,const char *str) -{ - int i; - for (i=0; i<4; ++i) - if (stbi__get8(s) != (stbi_uc)str[i]) - return 0; - - return 1; -} - -static int stbi__pic_test_core(stbi__context *s) -{ - int i; - - if (!stbi__pic_is4(s,"\x53\x80\xF6\x34")) - return 0; - - for(i=0;i<84;++i) - stbi__get8(s); - - if (!stbi__pic_is4(s,"PICT")) - return 0; - - return 1; -} - -typedef struct -{ - stbi_uc size,type,channel; -} stbi__pic_packet; - -static stbi_uc *stbi__readval(stbi__context *s, int channel, stbi_uc *dest) -{ - int mask=0x80, i; - - for (i=0; i<4; ++i, mask>>=1) { - if (channel & mask) { - if (stbi__at_eof(s)) return stbi__errpuc("bad file","PIC file too short"); - dest[i]=stbi__get8(s); - } - } - - return dest; -} - -static void stbi__copyval(int channel,stbi_uc *dest,const stbi_uc *src) -{ - int mask=0x80,i; - - for (i=0;i<4; ++i, mask>>=1) - if (channel&mask) - dest[i]=src[i]; -} - -static stbi_uc *stbi__pic_load_core(stbi__context *s,int width,int height,int *comp, stbi_uc *result) -{ - int act_comp=0,num_packets=0,y,chained; - stbi__pic_packet packets[10]; - - // this will (should...) cater for even some bizarre stuff like having data - // for the same channel in multiple packets. - do { - stbi__pic_packet *packet; - - if (num_packets==sizeof(packets)/sizeof(packets[0])) - return stbi__errpuc("bad format","too many packets"); - - packet = &packets[num_packets++]; - - chained = stbi__get8(s); - packet->size = stbi__get8(s); - packet->type = stbi__get8(s); - packet->channel = stbi__get8(s); - - act_comp |= packet->channel; - - if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (reading packets)"); - if (packet->size != 8) return stbi__errpuc("bad format","packet isn't 8bpp"); - } while (chained); - - *comp = (act_comp & 0x10 ? 4 : 3); // has alpha channel? - - for(y=0; ytype) { - default: - return stbi__errpuc("bad format","packet has bad compression type"); - - case 0: {//uncompressed - int x; - - for(x=0;xchannel,dest)) - return 0; - break; - } - - case 1://Pure RLE - { - int left=width, i; - - while (left>0) { - stbi_uc count,value[4]; - - count=stbi__get8(s); - if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (pure read count)"); - - if (count > left) - count = (stbi_uc) left; - - if (!stbi__readval(s,packet->channel,value)) return 0; - - for(i=0; ichannel,dest,value); - left -= count; - } - } - break; - - case 2: {//Mixed RLE - int left=width; - while (left>0) { - int count = stbi__get8(s), i; - if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (mixed read count)"); - - if (count >= 128) { // Repeated - stbi_uc value[4]; - - if (count==128) - count = stbi__get16be(s); - else - count -= 127; - if (count > left) - return stbi__errpuc("bad file","scanline overrun"); - - if (!stbi__readval(s,packet->channel,value)) - return 0; - - for(i=0;ichannel,dest,value); - } else { // Raw - ++count; - if (count>left) return stbi__errpuc("bad file","scanline overrun"); - - for(i=0;ichannel,dest)) - return 0; - } - left-=count; - } - break; - } - } - } - } - - return result; -} - -static void *stbi__pic_load(stbi__context *s,int *px,int *py,int *comp,int req_comp, stbi__result_info *ri) -{ - stbi_uc *result; - int i, x,y, internal_comp; - STBI_NOTUSED(ri); - - if (!comp) comp = &internal_comp; - - for (i=0; i<92; ++i) - stbi__get8(s); - - x = stbi__get16be(s); - y = stbi__get16be(s); - if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (pic header)"); - if (!stbi__mad3sizes_valid(x, y, 4, 0)) return stbi__errpuc("too large", "PIC image too large to decode"); - - stbi__get32be(s); //skip `ratio' - stbi__get16be(s); //skip `fields' - stbi__get16be(s); //skip `pad' - - // intermediate buffer is RGBA - result = (stbi_uc *) stbi__malloc_mad3(x, y, 4, 0); - memset(result, 0xff, x*y*4); - - if (!stbi__pic_load_core(s,x,y,comp, result)) { - STBI_FREE(result); - result=0; - } - *px = x; - *py = y; - if (req_comp == 0) req_comp = *comp; - result=stbi__convert_format(result,4,req_comp,x,y); - - return result; -} - -static int stbi__pic_test(stbi__context *s) -{ - int r = stbi__pic_test_core(s); - stbi__rewind(s); - return r; -} -#endif - -// ************************************************************************************************* -// GIF loader -- public domain by Jean-Marc Lienher -- simplified/shrunk by stb - -#ifndef STBI_NO_GIF -typedef struct -{ - stbi__int16 prefix; - stbi_uc first; - stbi_uc suffix; -} stbi__gif_lzw; - -typedef struct -{ - int w,h; - stbi_uc *out; // output buffer (always 4 components) - stbi_uc *background; // The current "background" as far as a gif is concerned - stbi_uc *history; - int flags, bgindex, ratio, transparent, eflags; - stbi_uc pal[256][4]; - stbi_uc lpal[256][4]; - stbi__gif_lzw codes[8192]; - stbi_uc *color_table; - int parse, step; - int lflags; - int start_x, start_y; - int max_x, max_y; - int cur_x, cur_y; - int line_size; - int delay; -} stbi__gif; - -static int stbi__gif_test_raw(stbi__context *s) -{ - int sz; - if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') return 0; - sz = stbi__get8(s); - if (sz != '9' && sz != '7') return 0; - if (stbi__get8(s) != 'a') return 0; - return 1; -} - -static int stbi__gif_test(stbi__context *s) -{ - int r = stbi__gif_test_raw(s); - stbi__rewind(s); - return r; -} - -static void stbi__gif_parse_colortable(stbi__context *s, stbi_uc pal[256][4], int num_entries, int transp) -{ - int i; - for (i=0; i < num_entries; ++i) { - pal[i][2] = stbi__get8(s); - pal[i][1] = stbi__get8(s); - pal[i][0] = stbi__get8(s); - pal[i][3] = transp == i ? 0 : 255; - } -} - -static int stbi__gif_header(stbi__context *s, stbi__gif *g, int *comp, int is_info) -{ - stbi_uc version; - if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') - return stbi__err("not GIF", "Corrupt GIF"); - - version = stbi__get8(s); - if (version != '7' && version != '9') return stbi__err("not GIF", "Corrupt GIF"); - if (stbi__get8(s) != 'a') return stbi__err("not GIF", "Corrupt GIF"); - - stbi__g_failure_reason = ""; - g->w = stbi__get16le(s); - g->h = stbi__get16le(s); - g->flags = stbi__get8(s); - g->bgindex = stbi__get8(s); - g->ratio = stbi__get8(s); - g->transparent = -1; - - if (comp != 0) *comp = 4; // can't actually tell whether it's 3 or 4 until we parse the comments - - if (is_info) return 1; - - if (g->flags & 0x80) - stbi__gif_parse_colortable(s,g->pal, 2 << (g->flags & 7), -1); - - return 1; -} - -static int stbi__gif_info_raw(stbi__context *s, int *x, int *y, int *comp) -{ - stbi__gif* g = (stbi__gif*) stbi__malloc(sizeof(stbi__gif)); - if (!stbi__gif_header(s, g, comp, 1)) { - STBI_FREE(g); - stbi__rewind( s ); - return 0; - } - if (x) *x = g->w; - if (y) *y = g->h; - STBI_FREE(g); - return 1; -} - -static void stbi__out_gif_code(stbi__gif *g, stbi__uint16 code) -{ - stbi_uc *p, *c; - int idx; - - // recurse to decode the prefixes, since the linked-list is backwards, - // and working backwards through an interleaved image would be nasty - if (g->codes[code].prefix >= 0) - stbi__out_gif_code(g, g->codes[code].prefix); - - if (g->cur_y >= g->max_y) return; - - idx = g->cur_x + g->cur_y; - p = &g->out[idx]; - g->history[idx / 4] = 1; - - c = &g->color_table[g->codes[code].suffix * 4]; - if (c[3] > 128) { // don't render transparent pixels; - p[0] = c[2]; - p[1] = c[1]; - p[2] = c[0]; - p[3] = c[3]; - } - g->cur_x += 4; - - if (g->cur_x >= g->max_x) { - g->cur_x = g->start_x; - g->cur_y += g->step; - - while (g->cur_y >= g->max_y && g->parse > 0) { - g->step = (1 << g->parse) * g->line_size; - g->cur_y = g->start_y + (g->step >> 1); - --g->parse; - } - } -} - -static stbi_uc *stbi__process_gif_raster(stbi__context *s, stbi__gif *g) -{ - stbi_uc lzw_cs; - stbi__int32 len, init_code; - stbi__uint32 first; - stbi__int32 codesize, codemask, avail, oldcode, bits, valid_bits, clear; - stbi__gif_lzw *p; - - lzw_cs = stbi__get8(s); - if (lzw_cs > 12) return NULL; - clear = 1 << lzw_cs; - first = 1; - codesize = lzw_cs + 1; - codemask = (1 << codesize) - 1; - bits = 0; - valid_bits = 0; - for (init_code = 0; init_code < clear; init_code++) { - g->codes[init_code].prefix = -1; - g->codes[init_code].first = (stbi_uc) init_code; - g->codes[init_code].suffix = (stbi_uc) init_code; - } - - // support no starting clear code - avail = clear+2; - oldcode = -1; - - len = 0; - for(;;) { - if (valid_bits < codesize) { - if (len == 0) { - len = stbi__get8(s); // start new block - if (len == 0) - return g->out; - } - --len; - bits |= (stbi__int32) stbi__get8(s) << valid_bits; - valid_bits += 8; - } else { - stbi__int32 code = bits & codemask; - bits >>= codesize; - valid_bits -= codesize; - // @OPTIMIZE: is there some way we can accelerate the non-clear path? - if (code == clear) { // clear code - codesize = lzw_cs + 1; - codemask = (1 << codesize) - 1; - avail = clear + 2; - oldcode = -1; - first = 0; - } else if (code == clear + 1) { // end of stream code - stbi__skip(s, len); - while ((len = stbi__get8(s)) > 0) - stbi__skip(s,len); - return g->out; - } else if (code <= avail) { - if (first) { - return stbi__errpuc("no clear code", "Corrupt GIF"); - } - - if (oldcode >= 0) { - p = &g->codes[avail++]; - if (avail > 8192) { - return stbi__errpuc("too many codes", "Corrupt GIF"); - } - - p->prefix = (stbi__int16) oldcode; - p->first = g->codes[oldcode].first; - p->suffix = (code == avail) ? p->first : g->codes[code].first; - } else if (code == avail) - return stbi__errpuc("illegal code in raster", "Corrupt GIF"); - - stbi__out_gif_code(g, (stbi__uint16) code); - - if ((avail & codemask) == 0 && avail <= 0x0FFF) { - codesize++; - codemask = (1 << codesize) - 1; - } - - oldcode = code; - } else { - return stbi__errpuc("illegal code in raster", "Corrupt GIF"); - } - } - } -} - -// this function is designed to support animated gifs, although stb_image doesn't support it -// two back is the image from two frames ago, used for a very specific disposal format -static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, int req_comp, stbi_uc *two_back) -{ - int dispose; - int first_frame; - int pi; - int pcount; - STBI_NOTUSED(req_comp); - - // on first frame, any non-written pixels get the background colour (non-transparent) - first_frame = 0; - if (g->out == 0) { - if (!stbi__gif_header(s, g, comp,0)) return 0; // stbi__g_failure_reason set by stbi__gif_header - if (!stbi__mad3sizes_valid(4, g->w, g->h, 0)) - return stbi__errpuc("too large", "GIF image is too large"); - pcount = g->w * g->h; - g->out = (stbi_uc *) stbi__malloc(4 * pcount); - g->background = (stbi_uc *) stbi__malloc(4 * pcount); - g->history = (stbi_uc *) stbi__malloc(pcount); - if (!g->out || !g->background || !g->history) - return stbi__errpuc("outofmem", "Out of memory"); - - // image is treated as "transparent" at the start - ie, nothing overwrites the current background; - // background colour is only used for pixels that are not rendered first frame, after that "background" - // color refers to the color that was there the previous frame. - memset(g->out, 0x00, 4 * pcount); - memset(g->background, 0x00, 4 * pcount); // state of the background (starts transparent) - memset(g->history, 0x00, pcount); // pixels that were affected previous frame - first_frame = 1; - } else { - // second frame - how do we dispoase of the previous one? - dispose = (g->eflags & 0x1C) >> 2; - pcount = g->w * g->h; - - if ((dispose == 3) && (two_back == 0)) { - dispose = 2; // if I don't have an image to revert back to, default to the old background - } - - if (dispose == 3) { // use previous graphic - for (pi = 0; pi < pcount; ++pi) { - if (g->history[pi]) { - memcpy( &g->out[pi * 4], &two_back[pi * 4], 4 ); - } - } - } else if (dispose == 2) { - // restore what was changed last frame to background before that frame; - for (pi = 0; pi < pcount; ++pi) { - if (g->history[pi]) { - memcpy( &g->out[pi * 4], &g->background[pi * 4], 4 ); - } - } - } else { - // This is a non-disposal case eithe way, so just - // leave the pixels as is, and they will become the new background - // 1: do not dispose - // 0: not specified. - } - - // background is what out is after the undoing of the previou frame; - memcpy( g->background, g->out, 4 * g->w * g->h ); - } - - // clear my history; - memset( g->history, 0x00, g->w * g->h ); // pixels that were affected previous frame - - for (;;) { - int tag = stbi__get8(s); - switch (tag) { - case 0x2C: /* Image Descriptor */ - { - stbi__int32 x, y, w, h; - stbi_uc *o; - - x = stbi__get16le(s); - y = stbi__get16le(s); - w = stbi__get16le(s); - h = stbi__get16le(s); - if (((x + w) > (g->w)) || ((y + h) > (g->h))) - return stbi__errpuc("bad Image Descriptor", "Corrupt GIF"); - - g->line_size = g->w * 4; - g->start_x = x * 4; - g->start_y = y * g->line_size; - g->max_x = g->start_x + w * 4; - g->max_y = g->start_y + h * g->line_size; - g->cur_x = g->start_x; - g->cur_y = g->start_y; - - // if the width of the specified rectangle is 0, that means - // we may not see *any* pixels or the image is malformed; - // to make sure this is caught, move the current y down to - // max_y (which is what out_gif_code checks). - if (w == 0) - g->cur_y = g->max_y; - - g->lflags = stbi__get8(s); - - if (g->lflags & 0x40) { - g->step = 8 * g->line_size; // first interlaced spacing - g->parse = 3; - } else { - g->step = g->line_size; - g->parse = 0; - } - - if (g->lflags & 0x80) { - stbi__gif_parse_colortable(s,g->lpal, 2 << (g->lflags & 7), g->eflags & 0x01 ? g->transparent : -1); - g->color_table = (stbi_uc *) g->lpal; - } else if (g->flags & 0x80) { - g->color_table = (stbi_uc *) g->pal; - } else - return stbi__errpuc("missing color table", "Corrupt GIF"); - - o = stbi__process_gif_raster(s, g); - if (!o) return NULL; - - // if this was the first frame, - pcount = g->w * g->h; - if (first_frame && (g->bgindex > 0)) { - // if first frame, any pixel not drawn to gets the background color - for (pi = 0; pi < pcount; ++pi) { - if (g->history[pi] == 0) { - g->pal[g->bgindex][3] = 255; // just in case it was made transparent, undo that; It will be reset next frame if need be; - memcpy( &g->out[pi * 4], &g->pal[g->bgindex], 4 ); - } - } - } - - return o; - } - - case 0x21: // Comment Extension. - { - int len; - int ext = stbi__get8(s); - if (ext == 0xF9) { // Graphic Control Extension. - len = stbi__get8(s); - if (len == 4) { - g->eflags = stbi__get8(s); - g->delay = 10 * stbi__get16le(s); // delay - 1/100th of a second, saving as 1/1000ths. - - // unset old transparent - if (g->transparent >= 0) { - g->pal[g->transparent][3] = 255; - } - if (g->eflags & 0x01) { - g->transparent = stbi__get8(s); - if (g->transparent >= 0) { - g->pal[g->transparent][3] = 0; - } - } else { - // don't need transparent - stbi__skip(s, 1); - g->transparent = -1; - } - } else { - stbi__skip(s, len); - break; - } - } - while ((len = stbi__get8(s)) != 0) { - stbi__skip(s, len); - } - break; - } - - case 0x3B: // gif stream termination code - return (stbi_uc *) s; // using '1' causes warning on some compilers - - default: - return stbi__errpuc("unknown code", "Corrupt GIF"); - } - } -} - -static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, int req_comp) -{ - if (stbi__gif_test(s)) { - int layers = 0; - stbi_uc *u = 0; - stbi_uc *out = 0; - stbi_uc *two_back = 0; - stbi__gif g; - int stride; - memset(&g, 0, sizeof(g)); - if (delays) { - *delays = 0; - } - - do { - u = stbi__gif_load_next(s, &g, comp, req_comp, two_back); - if (u == (stbi_uc *) s) u = 0; // end of animated gif marker - - if (u) { - *x = g.w; - *y = g.h; - ++layers; - stride = g.w * g.h * 4; - - if (out) { - void *tmp = (stbi_uc*) STBI_REALLOC( out, layers * stride ); - if (NULL == tmp) { - STBI_FREE(g.out); - STBI_FREE(g.history); - STBI_FREE(g.background); - return stbi__errpuc("outofmem", "Out of memory"); - } - else - out = (stbi_uc*) tmp; - if (delays) { - *delays = (int*) STBI_REALLOC( *delays, sizeof(int) * layers ); - } - } else { - out = (stbi_uc*)stbi__malloc( layers * stride ); - if (delays) { - *delays = (int*) stbi__malloc( layers * sizeof(int) ); - } - } - memcpy( out + ((layers - 1) * stride), u, stride ); - if (layers >= 2) { - two_back = out - 2 * stride; - } - - if (delays) { - (*delays)[layers - 1U] = g.delay; - } - } - } while (u != 0); - - // free temp buffer; - STBI_FREE(g.out); - STBI_FREE(g.history); - STBI_FREE(g.background); - - // do the final conversion after loading everything; - if (req_comp && req_comp != 4) - out = stbi__convert_format(out, 4, req_comp, layers * g.w, g.h); - - *z = layers; - return out; - } else { - return stbi__errpuc("not GIF", "Image was not as a gif type."); - } -} - -static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) -{ - stbi_uc *u = 0; - stbi__gif g; - memset(&g, 0, sizeof(g)); - STBI_NOTUSED(ri); - - u = stbi__gif_load_next(s, &g, comp, req_comp, 0); - if (u == (stbi_uc *) s) u = 0; // end of animated gif marker - if (u) { - *x = g.w; - *y = g.h; - - // moved conversion to after successful load so that the same - // can be done for multiple frames. - if (req_comp && req_comp != 4) - u = stbi__convert_format(u, 4, req_comp, g.w, g.h); - } else if (g.out) { - // if there was an error and we allocated an image buffer, free it! - STBI_FREE(g.out); - } - - // free buffers needed for multiple frame loading; - STBI_FREE(g.history); - STBI_FREE(g.background); - - return u; -} - -static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp) -{ - return stbi__gif_info_raw(s,x,y,comp); -} -#endif - -// ************************************************************************************************* -// Radiance RGBE HDR loader -// originally by Nicolas Schulz -#ifndef STBI_NO_HDR -static int stbi__hdr_test_core(stbi__context *s, const char *signature) -{ - int i; - for (i=0; signature[i]; ++i) - if (stbi__get8(s) != signature[i]) - return 0; - stbi__rewind(s); - return 1; -} - -static int stbi__hdr_test(stbi__context* s) -{ - int r = stbi__hdr_test_core(s, "#?RADIANCE\n"); - stbi__rewind(s); - if(!r) { - r = stbi__hdr_test_core(s, "#?RGBE\n"); - stbi__rewind(s); - } - return r; -} - -#define STBI__HDR_BUFLEN 1024 -static char *stbi__hdr_gettoken(stbi__context *z, char *buffer) -{ - int len=0; - char c = '\0'; - - c = (char) stbi__get8(z); - - while (!stbi__at_eof(z) && c != '\n') { - buffer[len++] = c; - if (len == STBI__HDR_BUFLEN-1) { - // flush to end of line - while (!stbi__at_eof(z) && stbi__get8(z) != '\n') - ; - break; - } - c = (char) stbi__get8(z); - } - - buffer[len] = 0; - return buffer; -} - -static void stbi__hdr_convert(float *output, stbi_uc *input, int req_comp) -{ - if ( input[3] != 0 ) { - float f1; - // Exponent - f1 = (float) ldexp(1.0f, input[3] - (int)(128 + 8)); - if (req_comp <= 2) - output[0] = (input[0] + input[1] + input[2]) * f1 / 3; - else { - output[0] = input[0] * f1; - output[1] = input[1] * f1; - output[2] = input[2] * f1; - } - if (req_comp == 2) output[1] = 1; - if (req_comp == 4) output[3] = 1; - } else { - switch (req_comp) { - case 4: output[3] = 1; /* fallthrough */ - case 3: output[0] = output[1] = output[2] = 0; - break; - case 2: output[1] = 1; /* fallthrough */ - case 1: output[0] = 0; - break; - } - } -} - -static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) -{ - char buffer[STBI__HDR_BUFLEN]; - char *token; - int valid = 0; - int width, height; - stbi_uc *scanline; - float *hdr_data; - int len; - unsigned char count, value; - int i, j, k, c1,c2, z; - const char *headerToken; - STBI_NOTUSED(ri); - - // Check identifier - headerToken = stbi__hdr_gettoken(s,buffer); - if (strcmp(headerToken, "#?RADIANCE") != 0 && strcmp(headerToken, "#?RGBE") != 0) - return stbi__errpf("not HDR", "Corrupt HDR image"); - - // Parse header - for(;;) { - token = stbi__hdr_gettoken(s,buffer); - if (token[0] == 0) break; - if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; - } - - if (!valid) return stbi__errpf("unsupported format", "Unsupported HDR format"); - - // Parse width and height - // can't use sscanf() if we're not using stdio! - token = stbi__hdr_gettoken(s,buffer); - if (strncmp(token, "-Y ", 3)) return stbi__errpf("unsupported data layout", "Unsupported HDR format"); - token += 3; - height = (int) strtol(token, &token, 10); - while (*token == ' ') ++token; - if (strncmp(token, "+X ", 3)) return stbi__errpf("unsupported data layout", "Unsupported HDR format"); - token += 3; - width = (int) strtol(token, NULL, 10); - - *x = width; - *y = height; - - if (comp) *comp = 3; - if (req_comp == 0) req_comp = 3; - - if (!stbi__mad4sizes_valid(width, height, req_comp, sizeof(float), 0)) - return stbi__errpf("too large", "HDR image is too large"); - - // Read data - hdr_data = (float *) stbi__malloc_mad4(width, height, req_comp, sizeof(float), 0); - if (!hdr_data) - return stbi__errpf("outofmem", "Out of memory"); - - // Load image data - // image data is stored as some number of sca - if ( width < 8 || width >= 32768) { - // Read flat data - for (j=0; j < height; ++j) { - for (i=0; i < width; ++i) { - stbi_uc rgbe[4]; - main_decode_loop: - stbi__getn(s, rgbe, 4); - stbi__hdr_convert(hdr_data + j * width * req_comp + i * req_comp, rgbe, req_comp); - } - } - } else { - // Read RLE-encoded data - scanline = NULL; - - for (j = 0; j < height; ++j) { - c1 = stbi__get8(s); - c2 = stbi__get8(s); - len = stbi__get8(s); - if (c1 != 2 || c2 != 2 || (len & 0x80)) { - // not run-length encoded, so we have to actually use THIS data as a decoded - // pixel (note this can't be a valid pixel--one of RGB must be >= 128) - stbi_uc rgbe[4]; - rgbe[0] = (stbi_uc) c1; - rgbe[1] = (stbi_uc) c2; - rgbe[2] = (stbi_uc) len; - rgbe[3] = (stbi_uc) stbi__get8(s); - stbi__hdr_convert(hdr_data, rgbe, req_comp); - i = 1; - j = 0; - STBI_FREE(scanline); - goto main_decode_loop; // yes, this makes no sense - } - len <<= 8; - len |= stbi__get8(s); - if (len != width) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("invalid decoded scanline length", "corrupt HDR"); } - if (scanline == NULL) { - scanline = (stbi_uc *) stbi__malloc_mad2(width, 4, 0); - if (!scanline) { - STBI_FREE(hdr_data); - return stbi__errpf("outofmem", "Out of memory"); - } - } - - for (k = 0; k < 4; ++k) { - int nleft; - i = 0; - while ((nleft = width - i) > 0) { - count = stbi__get8(s); - if (count > 128) { - // Run - value = stbi__get8(s); - count -= 128; - if (count > nleft) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); } - for (z = 0; z < count; ++z) - scanline[i++ * 4 + k] = value; - } else { - // Dump - if (count > nleft) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); } - for (z = 0; z < count; ++z) - scanline[i++ * 4 + k] = stbi__get8(s); - } - } - } - for (i=0; i < width; ++i) - stbi__hdr_convert(hdr_data+(j*width + i)*req_comp, scanline + i*4, req_comp); - } - if (scanline) - STBI_FREE(scanline); - } - - return hdr_data; -} - -static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp) -{ - char buffer[STBI__HDR_BUFLEN]; - char *token; - int valid = 0; - int dummy; - - if (!x) x = &dummy; - if (!y) y = &dummy; - if (!comp) comp = &dummy; - - if (stbi__hdr_test(s) == 0) { - stbi__rewind( s ); - return 0; - } - - for(;;) { - token = stbi__hdr_gettoken(s,buffer); - if (token[0] == 0) break; - if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; - } - - if (!valid) { - stbi__rewind( s ); - return 0; - } - token = stbi__hdr_gettoken(s,buffer); - if (strncmp(token, "-Y ", 3)) { - stbi__rewind( s ); - return 0; - } - token += 3; - *y = (int) strtol(token, &token, 10); - while (*token == ' ') ++token; - if (strncmp(token, "+X ", 3)) { - stbi__rewind( s ); - return 0; - } - token += 3; - *x = (int) strtol(token, NULL, 10); - *comp = 3; - return 1; -} -#endif // STBI_NO_HDR - -#ifndef STBI_NO_BMP -static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp) -{ - void *p; - stbi__bmp_data info; - - info.all_a = 255; - p = stbi__bmp_parse_header(s, &info); - stbi__rewind( s ); - if (p == NULL) - return 0; - if (x) *x = s->img_x; - if (y) *y = s->img_y; - if (comp) { - if (info.bpp == 24 && info.ma == 0xff000000) - *comp = 3; - else - *comp = info.ma ? 4 : 3; - } - return 1; -} -#endif - -#ifndef STBI_NO_PSD -static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp) -{ - int channelCount, dummy, depth; - if (!x) x = &dummy; - if (!y) y = &dummy; - if (!comp) comp = &dummy; - if (stbi__get32be(s) != 0x38425053) { - stbi__rewind( s ); - return 0; - } - if (stbi__get16be(s) != 1) { - stbi__rewind( s ); - return 0; - } - stbi__skip(s, 6); - channelCount = stbi__get16be(s); - if (channelCount < 0 || channelCount > 16) { - stbi__rewind( s ); - return 0; - } - *y = stbi__get32be(s); - *x = stbi__get32be(s); - depth = stbi__get16be(s); - if (depth != 8 && depth != 16) { - stbi__rewind( s ); - return 0; - } - if (stbi__get16be(s) != 3) { - stbi__rewind( s ); - return 0; - } - *comp = 4; - return 1; -} - -static int stbi__psd_is16(stbi__context *s) -{ - int channelCount, depth; - if (stbi__get32be(s) != 0x38425053) { - stbi__rewind( s ); - return 0; - } - if (stbi__get16be(s) != 1) { - stbi__rewind( s ); - return 0; - } - stbi__skip(s, 6); - channelCount = stbi__get16be(s); - if (channelCount < 0 || channelCount > 16) { - stbi__rewind( s ); - return 0; - } - (void) stbi__get32be(s); - (void) stbi__get32be(s); - depth = stbi__get16be(s); - if (depth != 16) { - stbi__rewind( s ); - return 0; - } - return 1; -} -#endif - -#ifndef STBI_NO_PIC -static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp) -{ - int act_comp=0,num_packets=0,chained,dummy; - stbi__pic_packet packets[10]; - - if (!x) x = &dummy; - if (!y) y = &dummy; - if (!comp) comp = &dummy; - - if (!stbi__pic_is4(s,"\x53\x80\xF6\x34")) { - stbi__rewind(s); - return 0; - } - - stbi__skip(s, 88); - - *x = stbi__get16be(s); - *y = stbi__get16be(s); - if (stbi__at_eof(s)) { - stbi__rewind( s); - return 0; - } - if ( (*x) != 0 && (1 << 28) / (*x) < (*y)) { - stbi__rewind( s ); - return 0; - } - - stbi__skip(s, 8); - - do { - stbi__pic_packet *packet; - - if (num_packets==sizeof(packets)/sizeof(packets[0])) - return 0; - - packet = &packets[num_packets++]; - chained = stbi__get8(s); - packet->size = stbi__get8(s); - packet->type = stbi__get8(s); - packet->channel = stbi__get8(s); - act_comp |= packet->channel; - - if (stbi__at_eof(s)) { - stbi__rewind( s ); - return 0; - } - if (packet->size != 8) { - stbi__rewind( s ); - return 0; - } - } while (chained); - - *comp = (act_comp & 0x10 ? 4 : 3); - - return 1; -} -#endif - -// ************************************************************************************************* -// Portable Gray Map and Portable Pixel Map loader -// by Ken Miller -// -// PGM: http://netpbm.sourceforge.net/doc/pgm.html -// PPM: http://netpbm.sourceforge.net/doc/ppm.html -// -// Known limitations: -// Does not support comments in the header section -// Does not support ASCII image data (formats P2 and P3) -// Does not support 16-bit-per-channel - -#ifndef STBI_NO_PNM - -static int stbi__pnm_test(stbi__context *s) -{ - char p, t; - p = (char) stbi__get8(s); - t = (char) stbi__get8(s); - if (p != 'P' || (t != '5' && t != '6')) { - stbi__rewind( s ); - return 0; - } - return 1; -} - -static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) -{ - stbi_uc *out; - STBI_NOTUSED(ri); - - if (!stbi__pnm_info(s, (int *)&s->img_x, (int *)&s->img_y, (int *)&s->img_n)) - return 0; - - *x = s->img_x; - *y = s->img_y; - if (comp) *comp = s->img_n; - - if (!stbi__mad3sizes_valid(s->img_n, s->img_x, s->img_y, 0)) - return stbi__errpuc("too large", "PNM too large"); - - out = (stbi_uc *) stbi__malloc_mad3(s->img_n, s->img_x, s->img_y, 0); - if (!out) return stbi__errpuc("outofmem", "Out of memory"); - stbi__getn(s, out, s->img_n * s->img_x * s->img_y); - - if (req_comp && req_comp != s->img_n) { - out = stbi__convert_format(out, s->img_n, req_comp, s->img_x, s->img_y); - if (out == NULL) return out; // stbi__convert_format frees input on failure - } - return out; -} - -static int stbi__pnm_isspace(char c) -{ - return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r'; -} - -static void stbi__pnm_skip_whitespace(stbi__context *s, char *c) -{ - for (;;) { - while (!stbi__at_eof(s) && stbi__pnm_isspace(*c)) - *c = (char) stbi__get8(s); - - if (stbi__at_eof(s) || *c != '#') - break; - - while (!stbi__at_eof(s) && *c != '\n' && *c != '\r' ) - *c = (char) stbi__get8(s); - } -} - -static int stbi__pnm_isdigit(char c) -{ - return c >= '0' && c <= '9'; -} - -static int stbi__pnm_getinteger(stbi__context *s, char *c) -{ - int value = 0; - - while (!stbi__at_eof(s) && stbi__pnm_isdigit(*c)) { - value = value*10 + (*c - '0'); - *c = (char) stbi__get8(s); - } - - return value; -} - -static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp) -{ - int maxv, dummy; - char c, p, t; - - if (!x) x = &dummy; - if (!y) y = &dummy; - if (!comp) comp = &dummy; - - stbi__rewind(s); - - // Get identifier - p = (char) stbi__get8(s); - t = (char) stbi__get8(s); - if (p != 'P' || (t != '5' && t != '6')) { - stbi__rewind(s); - return 0; - } - - *comp = (t == '6') ? 3 : 1; // '5' is 1-component .pgm; '6' is 3-component .ppm - - c = (char) stbi__get8(s); - stbi__pnm_skip_whitespace(s, &c); - - *x = stbi__pnm_getinteger(s, &c); // read width - stbi__pnm_skip_whitespace(s, &c); - - *y = stbi__pnm_getinteger(s, &c); // read height - stbi__pnm_skip_whitespace(s, &c); - - maxv = stbi__pnm_getinteger(s, &c); // read max value - - if (maxv > 255) - return stbi__err("max value > 255", "PPM image not 8-bit"); - else - return 1; -} -#endif - -static int stbi__info_main(stbi__context *s, int *x, int *y, int *comp) -{ - #ifndef STBI_NO_JPEG - if (stbi__jpeg_info(s, x, y, comp)) return 1; - #endif - - #ifndef STBI_NO_PNG - if (stbi__png_info(s, x, y, comp)) return 1; - #endif - - #ifndef STBI_NO_GIF - if (stbi__gif_info(s, x, y, comp)) return 1; - #endif - - #ifndef STBI_NO_BMP - if (stbi__bmp_info(s, x, y, comp)) return 1; - #endif - - #ifndef STBI_NO_PSD - if (stbi__psd_info(s, x, y, comp)) return 1; - #endif - - #ifndef STBI_NO_PIC - if (stbi__pic_info(s, x, y, comp)) return 1; - #endif - - #ifndef STBI_NO_PNM - if (stbi__pnm_info(s, x, y, comp)) return 1; - #endif - - #ifndef STBI_NO_HDR - if (stbi__hdr_info(s, x, y, comp)) return 1; - #endif - - // test tga last because it's a crappy test! - #ifndef STBI_NO_TGA - if (stbi__tga_info(s, x, y, comp)) - return 1; - #endif - return stbi__err("unknown image type", "Image not of any known type, or corrupt"); -} - -static int stbi__is_16_main(stbi__context *s) -{ - #ifndef STBI_NO_PNG - if (stbi__png_is16(s)) return 1; - #endif - - #ifndef STBI_NO_PSD - if (stbi__psd_is16(s)) return 1; - #endif - - return 0; -} - -#ifndef STBI_NO_STDIO -STBIDEF int stbi_info(char const *filename, int *x, int *y, int *comp) -{ - FILE *f = stbi__fopen(filename, "rb"); - int result; - if (!f) return stbi__err("can't fopen", "Unable to open file"); - result = stbi_info_from_file(f, x, y, comp); - fclose(f); - return result; -} - -STBIDEF int stbi_info_from_file(FILE *f, int *x, int *y, int *comp) -{ - int r; - stbi__context s; - long pos = ftell(f); - stbi__start_file(&s, f); - r = stbi__info_main(&s,x,y,comp); - fseek(f,pos,SEEK_SET); - return r; -} - -STBIDEF int stbi_is_16_bit(char const *filename) -{ - FILE *f = stbi__fopen(filename, "rb"); - int result; - if (!f) return stbi__err("can't fopen", "Unable to open file"); - result = stbi_is_16_bit_from_file(f); - fclose(f); - return result; -} - -STBIDEF int stbi_is_16_bit_from_file(FILE *f) -{ - int r; - stbi__context s; - long pos = ftell(f); - stbi__start_file(&s, f); - r = stbi__is_16_main(&s); - fseek(f,pos,SEEK_SET); - return r; -} -#endif // !STBI_NO_STDIO - -STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp) -{ - stbi__context s; - stbi__start_mem(&s,buffer,len); - return stbi__info_main(&s,x,y,comp); -} - -STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *c, void *user, int *x, int *y, int *comp) -{ - stbi__context s; - stbi__start_callbacks(&s, (stbi_io_callbacks *) c, user); - return stbi__info_main(&s,x,y,comp); -} - -STBIDEF int stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len) -{ - stbi__context s; - stbi__start_mem(&s,buffer,len); - return stbi__is_16_main(&s); -} - -STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *c, void *user) -{ - stbi__context s; - stbi__start_callbacks(&s, (stbi_io_callbacks *) c, user); - return stbi__is_16_main(&s); -} - -#endif // STB_IMAGE_IMPLEMENTATION - -/* - revision history: - 2.20 (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs - 2.19 (2018-02-11) fix warning - 2.18 (2018-01-30) fix warnings - 2.17 (2018-01-29) change sbti__shiftsigned to avoid clang -O2 bug - 1-bit BMP - *_is_16_bit api - avoid warnings - 2.16 (2017-07-23) all functions have 16-bit variants; - STBI_NO_STDIO works again; - compilation fixes; - fix rounding in unpremultiply; - optimize vertical flip; - disable raw_len validation; - documentation fixes - 2.15 (2017-03-18) fix png-1,2,4 bug; now all Imagenet JPGs decode; - warning fixes; disable run-time SSE detection on gcc; - uniform handling of optional "return" values; - thread-safe initialization of zlib tables - 2.14 (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for Imagenet JPGs - 2.13 (2016-11-29) add 16-bit API, only supported for PNG right now - 2.12 (2016-04-02) fix typo in 2.11 PSD fix that caused crashes - 2.11 (2016-04-02) allocate large structures on the stack - remove white matting for transparent PSD - fix reported channel count for PNG & BMP - re-enable SSE2 in non-gcc 64-bit - support RGB-formatted JPEG - read 16-bit PNGs (only as 8-bit) - 2.10 (2016-01-22) avoid warning introduced in 2.09 by STBI_REALLOC_SIZED - 2.09 (2016-01-16) allow comments in PNM files - 16-bit-per-pixel TGA (not bit-per-component) - info() for TGA could break due to .hdr handling - info() for BMP to shares code instead of sloppy parse - can use STBI_REALLOC_SIZED if allocator doesn't support realloc - code cleanup - 2.08 (2015-09-13) fix to 2.07 cleanup, reading RGB PSD as RGBA - 2.07 (2015-09-13) fix compiler warnings - partial animated GIF support - limited 16-bpc PSD support - #ifdef unused functions - bug with < 92 byte PIC,PNM,HDR,TGA - 2.06 (2015-04-19) fix bug where PSD returns wrong '*comp' value - 2.05 (2015-04-19) fix bug in progressive JPEG handling, fix warning - 2.04 (2015-04-15) try to re-enable SIMD on MinGW 64-bit - 2.03 (2015-04-12) extra corruption checking (mmozeiko) - stbi_set_flip_vertically_on_load (nguillemot) - fix NEON support; fix mingw support - 2.02 (2015-01-19) fix incorrect assert, fix warning - 2.01 (2015-01-17) fix various warnings; suppress SIMD on gcc 32-bit without -msse2 - 2.00b (2014-12-25) fix STBI_MALLOC in progressive JPEG - 2.00 (2014-12-25) optimize JPG, including x86 SSE2 & NEON SIMD (ryg) - progressive JPEG (stb) - PGM/PPM support (Ken Miller) - STBI_MALLOC,STBI_REALLOC,STBI_FREE - GIF bugfix -- seemingly never worked - STBI_NO_*, STBI_ONLY_* - 1.48 (2014-12-14) fix incorrectly-named assert() - 1.47 (2014-12-14) 1/2/4-bit PNG support, both direct and paletted (Omar Cornut & stb) - optimize PNG (ryg) - fix bug in interlaced PNG with user-specified channel count (stb) - 1.46 (2014-08-26) - fix broken tRNS chunk (colorkey-style transparency) in non-paletted PNG - 1.45 (2014-08-16) - fix MSVC-ARM internal compiler error by wrapping malloc - 1.44 (2014-08-07) - various warning fixes from Ronny Chevalier - 1.43 (2014-07-15) - fix MSVC-only compiler problem in code changed in 1.42 - 1.42 (2014-07-09) - don't define _CRT_SECURE_NO_WARNINGS (affects user code) - fixes to stbi__cleanup_jpeg path - added STBI_ASSERT to avoid requiring assert.h - 1.41 (2014-06-25) - fix search&replace from 1.36 that messed up comments/error messages - 1.40 (2014-06-22) - fix gcc struct-initialization warning - 1.39 (2014-06-15) - fix to TGA optimization when req_comp != number of components in TGA; - fix to GIF loading because BMP wasn't rewinding (whoops, no GIFs in my test suite) - add support for BMP version 5 (more ignored fields) - 1.38 (2014-06-06) - suppress MSVC warnings on integer casts truncating values - fix accidental rename of 'skip' field of I/O - 1.37 (2014-06-04) - remove duplicate typedef - 1.36 (2014-06-03) - convert to header file single-file library - if de-iphone isn't set, load iphone images color-swapped instead of returning NULL - 1.35 (2014-05-27) - various warnings - fix broken STBI_SIMD path - fix bug where stbi_load_from_file no longer left file pointer in correct place - fix broken non-easy path for 32-bit BMP (possibly never used) - TGA optimization by Arseny Kapoulkine - 1.34 (unknown) - use STBI_NOTUSED in stbi__resample_row_generic(), fix one more leak in tga failure case - 1.33 (2011-07-14) - make stbi_is_hdr work in STBI_NO_HDR (as specified), minor compiler-friendly improvements - 1.32 (2011-07-13) - support for "info" function for all supported filetypes (SpartanJ) - 1.31 (2011-06-20) - a few more leak fixes, bug in PNG handling (SpartanJ) - 1.30 (2011-06-11) - added ability to load files via callbacks to accomidate custom input streams (Ben Wenger) - removed deprecated format-specific test/load functions - removed support for installable file formats (stbi_loader) -- would have been broken for IO callbacks anyway - error cases in bmp and tga give messages and don't leak (Raymond Barbiero, grisha) - fix inefficiency in decoding 32-bit BMP (David Woo) - 1.29 (2010-08-16) - various warning fixes from Aurelien Pocheville - 1.28 (2010-08-01) - fix bug in GIF palette transparency (SpartanJ) - 1.27 (2010-08-01) - cast-to-stbi_uc to fix warnings - 1.26 (2010-07-24) - fix bug in file buffering for PNG reported by SpartanJ - 1.25 (2010-07-17) - refix trans_data warning (Won Chun) - 1.24 (2010-07-12) - perf improvements reading from files on platforms with lock-heavy fgetc() - minor perf improvements for jpeg - deprecated type-specific functions so we'll get feedback if they're needed - attempt to fix trans_data warning (Won Chun) - 1.23 fixed bug in iPhone support - 1.22 (2010-07-10) - removed image *writing* support - stbi_info support from Jetro Lauha - GIF support from Jean-Marc Lienher - iPhone PNG-extensions from James Brown - warning-fixes from Nicolas Schulz and Janez Zemva (i.stbi__err. Janez (U+017D)emva) - 1.21 fix use of 'stbi_uc' in header (reported by jon blow) - 1.20 added support for Softimage PIC, by Tom Seddon - 1.19 bug in interlaced PNG corruption check (found by ryg) - 1.18 (2008-08-02) - fix a threading bug (local mutable static) - 1.17 support interlaced PNG - 1.16 major bugfix - stbi__convert_format converted one too many pixels - 1.15 initialize some fields for thread safety - 1.14 fix threadsafe conversion bug - header-file-only version (#define STBI_HEADER_FILE_ONLY before including) - 1.13 threadsafe - 1.12 const qualifiers in the API - 1.11 Support installable IDCT, colorspace conversion routines - 1.10 Fixes for 64-bit (don't use "unsigned long") - optimized upsampling by Fabian "ryg" Giesen - 1.09 Fix format-conversion for PSD code (bad global variables!) - 1.08 Thatcher Ulrich's PSD code integrated by Nicolas Schulz - 1.07 attempt to fix C++ warning/errors again - 1.06 attempt to fix C++ warning/errors again - 1.05 fix TGA loading to return correct *comp and use good luminance calc - 1.04 default float alpha is 1, not 255; use 'void *' for stbi_image_free - 1.03 bugfixes to STBI_NO_STDIO, STBI_NO_HDR - 1.02 support for (subset of) HDR files, float interface for preferred access to them - 1.01 fix bug: possible bug in handling right-side up bmps... not sure - fix bug: the stbi__bmp_load() and stbi__tga_load() functions didn't work at all - 1.00 interface to zlib that skips zlib header - 0.99 correct handling of alpha in palette - 0.98 TGA loader by lonesock; dynamically add loaders (untested) - 0.97 jpeg errors on too large a file; also catch another malloc failure - 0.96 fix detection of invalid v value - particleman@mollyrocket forum - 0.95 during header scan, seek to markers in case of padding - 0.94 STBI_NO_STDIO to disable stdio usage; rename all #defines the same - 0.93 handle jpegtran output; verbose errors - 0.92 read 4,8,16,24,32-bit BMP files of several formats - 0.91 output 24-bit Windows 3.0 BMP files - 0.90 fix a few more warnings; bump version number to approach 1.0 - 0.61 bugfixes due to Marc LeBlanc, Christopher Lloyd - 0.60 fix compiling as c++ - 0.59 fix warnings: merge Dave Moore's -Wall fixes - 0.58 fix bug: zlib uncompressed mode len/nlen was wrong endian - 0.57 fix bug: jpg last huffman symbol before marker was >9 bits but less than 16 available - 0.56 fix bug: zlib uncompressed mode len vs. nlen - 0.55 fix bug: restart_interval not initialized to 0 - 0.54 allow NULL for 'int *comp' - 0.53 fix bug in png 3->4; speedup png decoding - 0.52 png handles req_comp=3,4 directly; minor cleanup; jpeg comments - 0.51 obey req_comp requests, 1-component jpegs return as 1-component, - on 'test' only check type, not whether we support this variant - 0.50 (2006-11-19) - first released version -*/ - - -/* ------------------------------------------------------------------------------- -This software is available under 2 licenses -- choose whichever you prefer. ------------------------------------------------------------------------------- -ALTERNATIVE A - MIT License -Copyright (c) 2017 Sean Barrett -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. ------------------------------------------------------------------------------- -ALTERNATIVE B - Public Domain (www.unlicense.org) -This is free and unencumbered software released into the public domain. -Anyone is free to copy, modify, publish, use, compile, sell, or distribute this -software, either in source code form or as a compiled binary, for any purpose, -commercial or non-commercial, and by any means. -In jurisdictions that recognize copyright laws, the author or authors of this -software dedicate any and all copyright interest in the software to the public -domain. We make this dedication for the benefit of the public at large and to -the detriment of our heirs and successors. We intend this dedication to be an -overt act of relinquishment in perpetuity of all present and future rights to -this software under copyright law. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------- -*/ diff --git a/extern/stbi/stb_image_write.h b/extern/stbi/stb_image_write.h deleted file mode 100644 index cffd473..0000000 --- a/extern/stbi/stb_image_write.h +++ /dev/null @@ -1,1666 +0,0 @@ -/* stb_image_write - v1.14 - public domain - http://nothings.org/stb - writes out PNG/BMP/TGA/JPEG/HDR images to C stdio - Sean Barrett 2010-2015 - no warranty implied; use at your own risk - - Before #including, - - #define STB_IMAGE_WRITE_IMPLEMENTATION - - in the file that you want to have the implementation. - - Will probably not work correctly with strict-aliasing optimizations. - -ABOUT: - - This header file is a library for writing images to C stdio or a callback. - - The PNG output is not optimal; it is 20-50% larger than the file - written by a decent optimizing implementation; though providing a custom - zlib compress function (see STBIW_ZLIB_COMPRESS) can mitigate that. - This library is designed for source code compactness and simplicity, - not optimal image file size or run-time performance. - -BUILDING: - - You can #define STBIW_ASSERT(x) before the #include to avoid using assert.h. - You can #define STBIW_MALLOC(), STBIW_REALLOC(), and STBIW_FREE() to replace - malloc,realloc,free. - You can #define STBIW_MEMMOVE() to replace memmove() - You can #define STBIW_ZLIB_COMPRESS to use a custom zlib-style compress function - for PNG compression (instead of the builtin one), it must have the following signature: - unsigned char * my_compress(unsigned char *data, int data_len, int *out_len, int quality); - The returned data will be freed with STBIW_FREE() (free() by default), - so it must be heap allocated with STBIW_MALLOC() (malloc() by default), - -UNICODE: - - If compiling for Windows and you wish to use Unicode filenames, compile - with - #define STBIW_WINDOWS_UTF8 - and pass utf8-encoded filenames. Call stbiw_convert_wchar_to_utf8 to convert - Windows wchar_t filenames to utf8. - -USAGE: - - There are five functions, one for each image file format: - - int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes); - int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data); - int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data); - int stbi_write_jpg(char const *filename, int w, int h, int comp, const void *data, int quality); - int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data); - - void stbi_flip_vertically_on_write(int flag); // flag is non-zero to flip data vertically - - There are also five equivalent functions that use an arbitrary write function. You are - expected to open/close your file-equivalent before and after calling these: - - int stbi_write_png_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data, int stride_in_bytes); - int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); - int stbi_write_tga_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); - int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const float *data); - int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality); - - where the callback is: - void stbi_write_func(void *context, void *data, int size); - - You can configure it with these global variables: - int stbi_write_tga_with_rle; // defaults to true; set to 0 to disable RLE - int stbi_write_png_compression_level; // defaults to 8; set to higher for more compression - int stbi_write_force_png_filter; // defaults to -1; set to 0..5 to force a filter mode - - - You can define STBI_WRITE_NO_STDIO to disable the file variant of these - functions, so the library will not use stdio.h at all. However, this will - also disable HDR writing, because it requires stdio for formatted output. - - Each function returns 0 on failure and non-0 on success. - - The functions create an image file defined by the parameters. The image - is a rectangle of pixels stored from left-to-right, top-to-bottom. - Each pixel contains 'comp' channels of data stored interleaved with 8-bits - per channel, in the following order: 1=Y, 2=YA, 3=RGB, 4=RGBA. (Y is - monochrome color.) The rectangle is 'w' pixels wide and 'h' pixels tall. - The *data pointer points to the first byte of the top-left-most pixel. - For PNG, "stride_in_bytes" is the distance in bytes from the first byte of - a row of pixels to the first byte of the next row of pixels. - - PNG creates output files with the same number of components as the input. - The BMP format expands Y to RGB in the file format and does not - output alpha. - - PNG supports writing rectangles of data even when the bytes storing rows of - data are not consecutive in memory (e.g. sub-rectangles of a larger image), - by supplying the stride between the beginning of adjacent rows. The other - formats do not. (Thus you cannot write a native-format BMP through the BMP - writer, both because it is in BGR order and because it may have padding - at the end of the line.) - - PNG allows you to set the deflate compression level by setting the global - variable 'stbi_write_png_compression_level' (it defaults to 8). - - HDR expects linear float data. Since the format is always 32-bit rgb(e) - data, alpha (if provided) is discarded, and for monochrome data it is - replicated across all three channels. - - TGA supports RLE or non-RLE compressed data. To use non-RLE-compressed - data, set the global variable 'stbi_write_tga_with_rle' to 0. - - JPEG does ignore alpha channels in input data; quality is between 1 and 100. - Higher quality looks better but results in a bigger image. - JPEG baseline (no JPEG progressive). - -CREDITS: - - - Sean Barrett - PNG/BMP/TGA - Baldur Karlsson - HDR - Jean-Sebastien Guay - TGA monochrome - Tim Kelsey - misc enhancements - Alan Hickman - TGA RLE - Emmanuel Julien - initial file IO callback implementation - Jon Olick - original jo_jpeg.cpp code - Daniel Gibson - integrate JPEG, allow external zlib - Aarni Koskela - allow choosing PNG filter - - bugfixes: - github:Chribba - Guillaume Chereau - github:jry2 - github:romigrou - Sergio Gonzalez - Jonas Karlsson - Filip Wasil - Thatcher Ulrich - github:poppolopoppo - Patrick Boettcher - github:xeekworx - Cap Petschulat - Simon Rodriguez - Ivan Tikhonov - github:ignotion - Adam Schackart - -LICENSE - - See end of file for license information. - -*/ - -#ifndef INCLUDE_STB_IMAGE_WRITE_H -#define INCLUDE_STB_IMAGE_WRITE_H - -#include - -// if STB_IMAGE_WRITE_STATIC causes problems, try defining STBIWDEF to 'inline' or 'static inline' -#ifndef STBIWDEF -#ifdef STB_IMAGE_WRITE_STATIC -#define STBIWDEF static -#else -#ifdef __cplusplus -#define STBIWDEF extern "C" -#else -#define STBIWDEF extern -#endif -#endif -#endif - -#ifndef STB_IMAGE_WRITE_STATIC // C++ forbids static forward declarations -extern int stbi_write_tga_with_rle; -extern int stbi_write_png_compression_level; -extern int stbi_write_force_png_filter; -#endif - -#ifndef STBI_WRITE_NO_STDIO -STBIWDEF int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes); -STBIWDEF int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data); -STBIWDEF int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data); -STBIWDEF int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data); -STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality); - -#ifdef STBI_WINDOWS_UTF8 -STBIWDEF int stbiw_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input); -#endif -#endif - -typedef void stbi_write_func(void *context, void *data, int size); - -STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data, int stride_in_bytes); -STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); -STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data); -STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const float *data); -STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality); - -STBIWDEF void stbi_flip_vertically_on_write(int flip_boolean); - -#endif//INCLUDE_STB_IMAGE_WRITE_H - -#ifdef STB_IMAGE_WRITE_IMPLEMENTATION - -#ifdef _WIN32 - #ifndef _CRT_SECURE_NO_WARNINGS - #define _CRT_SECURE_NO_WARNINGS - #endif - #ifndef _CRT_NONSTDC_NO_DEPRECATE - #define _CRT_NONSTDC_NO_DEPRECATE - #endif -#endif - -#ifndef STBI_WRITE_NO_STDIO -#include -#endif // STBI_WRITE_NO_STDIO - -#include -#include -#include -#include - -#if defined(STBIW_MALLOC) && defined(STBIW_FREE) && (defined(STBIW_REALLOC) || defined(STBIW_REALLOC_SIZED)) -// ok -#elif !defined(STBIW_MALLOC) && !defined(STBIW_FREE) && !defined(STBIW_REALLOC) && !defined(STBIW_REALLOC_SIZED) -// ok -#else -#error "Must define all or none of STBIW_MALLOC, STBIW_FREE, and STBIW_REALLOC (or STBIW_REALLOC_SIZED)." -#endif - -#ifndef STBIW_MALLOC -#define STBIW_MALLOC(sz) malloc(sz) -#define STBIW_REALLOC(p,newsz) realloc(p,newsz) -#define STBIW_FREE(p) free(p) -#endif - -#ifndef STBIW_REALLOC_SIZED -#define STBIW_REALLOC_SIZED(p,oldsz,newsz) STBIW_REALLOC(p,newsz) -#endif - - -#ifndef STBIW_MEMMOVE -#define STBIW_MEMMOVE(a,b,sz) memmove(a,b,sz) -#endif - - -#ifndef STBIW_ASSERT -#include -#define STBIW_ASSERT(x) assert(x) -#endif - -#define STBIW_UCHAR(x) (unsigned char) ((x) & 0xff) - -#ifdef STB_IMAGE_WRITE_STATIC -static int stbi_write_png_compression_level = 8; -static int stbi_write_tga_with_rle = 1; -static int stbi_write_force_png_filter = -1; -#else -int stbi_write_png_compression_level = 8; -int stbi_write_tga_with_rle = 1; -int stbi_write_force_png_filter = -1; -#endif - -static int stbi__flip_vertically_on_write = 0; - -STBIWDEF void stbi_flip_vertically_on_write(int flag) -{ - stbi__flip_vertically_on_write = flag; -} - -typedef struct -{ - stbi_write_func *func; - void *context; -} stbi__write_context; - -// initialize a callback-based context -static void stbi__start_write_callbacks(stbi__write_context *s, stbi_write_func *c, void *context) -{ - s->func = c; - s->context = context; -} - -#ifndef STBI_WRITE_NO_STDIO - -static void stbi__stdio_write(void *context, void *data, int size) -{ - fwrite(data,1,size,(FILE*) context); -} - -#if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8) -#ifdef __cplusplus -#define STBIW_EXTERN extern "C" -#else -#define STBIW_EXTERN extern -#endif -STBIW_EXTERN __declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int cp, unsigned long flags, const char *str, int cbmb, wchar_t *widestr, int cchwide); -STBIW_EXTERN __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, char *str, int cbmb, const char *defchar, int *used_default); - -STBIWDEF int stbiw_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input) -{ - return WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, (int) bufferlen, NULL, NULL); -} -#endif - -static FILE *stbiw__fopen(char const *filename, char const *mode) -{ - FILE *f; -#if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8) - wchar_t wMode[64]; - wchar_t wFilename[1024]; - if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, filename, -1, wFilename, sizeof(wFilename))) - return 0; - - if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode))) - return 0; - -#if _MSC_VER >= 1400 - if (0 != _wfopen_s(&f, wFilename, wMode)) - f = 0; -#else - f = _wfopen(wFilename, wMode); -#endif - -#elif defined(_MSC_VER) && _MSC_VER >= 1400 - if (0 != fopen_s(&f, filename, mode)) - f=0; -#else - f = fopen(filename, mode); -#endif - return f; -} - -static int stbi__start_write_file(stbi__write_context *s, const char *filename) -{ - FILE *f = stbiw__fopen(filename, "wb"); - stbi__start_write_callbacks(s, stbi__stdio_write, (void *) f); - return f != NULL; -} - -static void stbi__end_write_file(stbi__write_context *s) -{ - fclose((FILE *)s->context); -} - -#endif // !STBI_WRITE_NO_STDIO - -typedef unsigned int stbiw_uint32; -typedef int stb_image_write_test[sizeof(stbiw_uint32)==4 ? 1 : -1]; - -static void stbiw__writefv(stbi__write_context *s, const char *fmt, va_list v) -{ - while (*fmt) { - switch (*fmt++) { - case ' ': break; - case '1': { unsigned char x = STBIW_UCHAR(va_arg(v, int)); - s->func(s->context,&x,1); - break; } - case '2': { int x = va_arg(v,int); - unsigned char b[2]; - b[0] = STBIW_UCHAR(x); - b[1] = STBIW_UCHAR(x>>8); - s->func(s->context,b,2); - break; } - case '4': { stbiw_uint32 x = va_arg(v,int); - unsigned char b[4]; - b[0]=STBIW_UCHAR(x); - b[1]=STBIW_UCHAR(x>>8); - b[2]=STBIW_UCHAR(x>>16); - b[3]=STBIW_UCHAR(x>>24); - s->func(s->context,b,4); - break; } - default: - STBIW_ASSERT(0); - return; - } - } -} - -static void stbiw__writef(stbi__write_context *s, const char *fmt, ...) -{ - va_list v; - va_start(v, fmt); - stbiw__writefv(s, fmt, v); - va_end(v); -} - -static void stbiw__putc(stbi__write_context *s, unsigned char c) -{ - s->func(s->context, &c, 1); -} - -static void stbiw__write3(stbi__write_context *s, unsigned char a, unsigned char b, unsigned char c) -{ - unsigned char arr[3]; - arr[0] = a; arr[1] = b; arr[2] = c; - s->func(s->context, arr, 3); -} - -static void stbiw__write_pixel(stbi__write_context *s, int rgb_dir, int comp, int write_alpha, int expand_mono, unsigned char *d) -{ - unsigned char bg[3] = { 255, 0, 255}, px[3]; - int k; - - if (write_alpha < 0) - s->func(s->context, &d[comp - 1], 1); - - switch (comp) { - case 2: // 2 pixels = mono + alpha, alpha is written separately, so same as 1-channel case - case 1: - if (expand_mono) - stbiw__write3(s, d[0], d[0], d[0]); // monochrome bmp - else - s->func(s->context, d, 1); // monochrome TGA - break; - case 4: - if (!write_alpha) { - // composite against pink background - for (k = 0; k < 3; ++k) - px[k] = bg[k] + ((d[k] - bg[k]) * d[3]) / 255; - stbiw__write3(s, px[1 - rgb_dir], px[1], px[1 + rgb_dir]); - break; - } - /* FALLTHROUGH */ - case 3: - stbiw__write3(s, d[1 - rgb_dir], d[1], d[1 + rgb_dir]); - break; - } - if (write_alpha > 0) - s->func(s->context, &d[comp - 1], 1); -} - -static void stbiw__write_pixels(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, void *data, int write_alpha, int scanline_pad, int expand_mono) -{ - stbiw_uint32 zero = 0; - int i,j, j_end; - - if (y <= 0) - return; - - if (stbi__flip_vertically_on_write) - vdir *= -1; - - if (vdir < 0) { - j_end = -1; j = y-1; - } else { - j_end = y; j = 0; - } - - for (; j != j_end; j += vdir) { - for (i=0; i < x; ++i) { - unsigned char *d = (unsigned char *) data + (j*x+i)*comp; - stbiw__write_pixel(s, rgb_dir, comp, write_alpha, expand_mono, d); - } - s->func(s->context, &zero, scanline_pad); - } -} - -static int stbiw__outfile(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, int expand_mono, void *data, int alpha, int pad, const char *fmt, ...) -{ - if (y < 0 || x < 0) { - return 0; - } else { - va_list v; - va_start(v, fmt); - stbiw__writefv(s, fmt, v); - va_end(v); - stbiw__write_pixels(s,rgb_dir,vdir,x,y,comp,data,alpha,pad, expand_mono); - return 1; - } -} - -static int stbi_write_bmp_core(stbi__write_context *s, int x, int y, int comp, const void *data) -{ - int pad = (-x*3) & 3; - return stbiw__outfile(s,-1,-1,x,y,comp,1,(void *) data,0,pad, - "11 4 22 4" "4 44 22 444444", - 'B', 'M', 14+40+(x*3+pad)*y, 0,0, 14+40, // file header - 40, x,y, 1,24, 0,0,0,0,0,0); // bitmap header -} - -STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data) -{ - stbi__write_context s; - stbi__start_write_callbacks(&s, func, context); - return stbi_write_bmp_core(&s, x, y, comp, data); -} - -#ifndef STBI_WRITE_NO_STDIO -STBIWDEF int stbi_write_bmp(char const *filename, int x, int y, int comp, const void *data) -{ - stbi__write_context s; - if (stbi__start_write_file(&s,filename)) { - int r = stbi_write_bmp_core(&s, x, y, comp, data); - stbi__end_write_file(&s); - return r; - } else - return 0; -} -#endif //!STBI_WRITE_NO_STDIO - -static int stbi_write_tga_core(stbi__write_context *s, int x, int y, int comp, void *data) -{ - int has_alpha = (comp == 2 || comp == 4); - int colorbytes = has_alpha ? comp-1 : comp; - int format = colorbytes < 2 ? 3 : 2; // 3 color channels (RGB/RGBA) = 2, 1 color channel (Y/YA) = 3 - - if (y < 0 || x < 0) - return 0; - - if (!stbi_write_tga_with_rle) { - return stbiw__outfile(s, -1, -1, x, y, comp, 0, (void *) data, has_alpha, 0, - "111 221 2222 11", 0, 0, format, 0, 0, 0, 0, 0, x, y, (colorbytes + has_alpha) * 8, has_alpha * 8); - } else { - int i,j,k; - int jend, jdir; - - stbiw__writef(s, "111 221 2222 11", 0,0,format+8, 0,0,0, 0,0,x,y, (colorbytes + has_alpha) * 8, has_alpha * 8); - - if (stbi__flip_vertically_on_write) { - j = 0; - jend = y; - jdir = 1; - } else { - j = y-1; - jend = -1; - jdir = -1; - } - for (; j != jend; j += jdir) { - unsigned char *row = (unsigned char *) data + j * x * comp; - int len; - - for (i = 0; i < x; i += len) { - unsigned char *begin = row + i * comp; - int diff = 1; - len = 1; - - if (i < x - 1) { - ++len; - diff = memcmp(begin, row + (i + 1) * comp, comp); - if (diff) { - const unsigned char *prev = begin; - for (k = i + 2; k < x && len < 128; ++k) { - if (memcmp(prev, row + k * comp, comp)) { - prev += comp; - ++len; - } else { - --len; - break; - } - } - } else { - for (k = i + 2; k < x && len < 128; ++k) { - if (!memcmp(begin, row + k * comp, comp)) { - ++len; - } else { - break; - } - } - } - } - - if (diff) { - unsigned char header = STBIW_UCHAR(len - 1); - s->func(s->context, &header, 1); - for (k = 0; k < len; ++k) { - stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin + k * comp); - } - } else { - unsigned char header = STBIW_UCHAR(len - 129); - s->func(s->context, &header, 1); - stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin); - } - } - } - } - return 1; -} - -STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data) -{ - stbi__write_context s; - stbi__start_write_callbacks(&s, func, context); - return stbi_write_tga_core(&s, x, y, comp, (void *) data); -} - -#ifndef STBI_WRITE_NO_STDIO -STBIWDEF int stbi_write_tga(char const *filename, int x, int y, int comp, const void *data) -{ - stbi__write_context s; - if (stbi__start_write_file(&s,filename)) { - int r = stbi_write_tga_core(&s, x, y, comp, (void *) data); - stbi__end_write_file(&s); - return r; - } else - return 0; -} -#endif - -// ************************************************************************************************* -// Radiance RGBE HDR writer -// by Baldur Karlsson - -#define stbiw__max(a, b) ((a) > (b) ? (a) : (b)) - -static void stbiw__linear_to_rgbe(unsigned char *rgbe, float *linear) -{ - int exponent; - float maxcomp = stbiw__max(linear[0], stbiw__max(linear[1], linear[2])); - - if (maxcomp < 1e-32f) { - rgbe[0] = rgbe[1] = rgbe[2] = rgbe[3] = 0; - } else { - float normalize = (float) frexp(maxcomp, &exponent) * 256.0f/maxcomp; - - rgbe[0] = (unsigned char)(linear[0] * normalize); - rgbe[1] = (unsigned char)(linear[1] * normalize); - rgbe[2] = (unsigned char)(linear[2] * normalize); - rgbe[3] = (unsigned char)(exponent + 128); - } -} - -static void stbiw__write_run_data(stbi__write_context *s, int length, unsigned char databyte) -{ - unsigned char lengthbyte = STBIW_UCHAR(length+128); - STBIW_ASSERT(length+128 <= 255); - s->func(s->context, &lengthbyte, 1); - s->func(s->context, &databyte, 1); -} - -static void stbiw__write_dump_data(stbi__write_context *s, int length, unsigned char *data) -{ - unsigned char lengthbyte = STBIW_UCHAR(length); - STBIW_ASSERT(length <= 128); // inconsistent with spec but consistent with official code - s->func(s->context, &lengthbyte, 1); - s->func(s->context, data, length); -} - -static void stbiw__write_hdr_scanline(stbi__write_context *s, int width, int ncomp, unsigned char *scratch, float *scanline) -{ - unsigned char scanlineheader[4] = { 2, 2, 0, 0 }; - unsigned char rgbe[4]; - float linear[3]; - int x; - - scanlineheader[2] = (width&0xff00)>>8; - scanlineheader[3] = (width&0x00ff); - - /* skip RLE for images too small or large */ - if (width < 8 || width >= 32768) { - for (x=0; x < width; x++) { - switch (ncomp) { - case 4: /* fallthrough */ - case 3: linear[2] = scanline[x*ncomp + 2]; - linear[1] = scanline[x*ncomp + 1]; - linear[0] = scanline[x*ncomp + 0]; - break; - default: - linear[0] = linear[1] = linear[2] = scanline[x*ncomp + 0]; - break; - } - stbiw__linear_to_rgbe(rgbe, linear); - s->func(s->context, rgbe, 4); - } - } else { - int c,r; - /* encode into scratch buffer */ - for (x=0; x < width; x++) { - switch(ncomp) { - case 4: /* fallthrough */ - case 3: linear[2] = scanline[x*ncomp + 2]; - linear[1] = scanline[x*ncomp + 1]; - linear[0] = scanline[x*ncomp + 0]; - break; - default: - linear[0] = linear[1] = linear[2] = scanline[x*ncomp + 0]; - break; - } - stbiw__linear_to_rgbe(rgbe, linear); - scratch[x + width*0] = rgbe[0]; - scratch[x + width*1] = rgbe[1]; - scratch[x + width*2] = rgbe[2]; - scratch[x + width*3] = rgbe[3]; - } - - s->func(s->context, scanlineheader, 4); - - /* RLE each component separately */ - for (c=0; c < 4; c++) { - unsigned char *comp = &scratch[width*c]; - - x = 0; - while (x < width) { - // find first run - r = x; - while (r+2 < width) { - if (comp[r] == comp[r+1] && comp[r] == comp[r+2]) - break; - ++r; - } - if (r+2 >= width) - r = width; - // dump up to first run - while (x < r) { - int len = r-x; - if (len > 128) len = 128; - stbiw__write_dump_data(s, len, &comp[x]); - x += len; - } - // if there's a run, output it - if (r+2 < width) { // same test as what we break out of in search loop, so only true if we break'd - // find next byte after run - while (r < width && comp[r] == comp[x]) - ++r; - // output run up to r - while (x < r) { - int len = r-x; - if (len > 127) len = 127; - stbiw__write_run_data(s, len, comp[x]); - x += len; - } - } - } - } - } -} - -static int stbi_write_hdr_core(stbi__write_context *s, int x, int y, int comp, float *data) -{ - if (y <= 0 || x <= 0 || data == NULL) - return 0; - else { - // Each component is stored separately. Allocate scratch space for full output scanline. - unsigned char *scratch = (unsigned char *) STBIW_MALLOC(x*4); - int i, len; - char buffer[128]; - char header[] = "#?RADIANCE\n# Written by stb_image_write.h\nFORMAT=32-bit_rle_rgbe\n"; - s->func(s->context, header, sizeof(header)-1); - -#ifdef __STDC_WANT_SECURE_LIB__ - len = sprintf_s(buffer, sizeof(buffer), "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x); -#else - len = sprintf(buffer, "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x); -#endif - s->func(s->context, buffer, len); - - for(i=0; i < y; i++) - stbiw__write_hdr_scanline(s, x, comp, scratch, data + comp*x*(stbi__flip_vertically_on_write ? y-1-i : i)); - STBIW_FREE(scratch); - return 1; - } -} - -STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const float *data) -{ - stbi__write_context s; - stbi__start_write_callbacks(&s, func, context); - return stbi_write_hdr_core(&s, x, y, comp, (float *) data); -} - -#ifndef STBI_WRITE_NO_STDIO -STBIWDEF int stbi_write_hdr(char const *filename, int x, int y, int comp, const float *data) -{ - stbi__write_context s; - if (stbi__start_write_file(&s,filename)) { - int r = stbi_write_hdr_core(&s, x, y, comp, (float *) data); - stbi__end_write_file(&s); - return r; - } else - return 0; -} -#endif // STBI_WRITE_NO_STDIO - - -////////////////////////////////////////////////////////////////////////////// -// -// PNG writer -// - -#ifndef STBIW_ZLIB_COMPRESS -// stretchy buffer; stbiw__sbpush() == vector<>::push_back() -- stbiw__sbcount() == vector<>::size() -#define stbiw__sbraw(a) ((int *) (void *) (a) - 2) -#define stbiw__sbm(a) stbiw__sbraw(a)[0] -#define stbiw__sbn(a) stbiw__sbraw(a)[1] - -#define stbiw__sbneedgrow(a,n) ((a)==0 || stbiw__sbn(a)+n >= stbiw__sbm(a)) -#define stbiw__sbmaybegrow(a,n) (stbiw__sbneedgrow(a,(n)) ? stbiw__sbgrow(a,n) : 0) -#define stbiw__sbgrow(a,n) stbiw__sbgrowf((void **) &(a), (n), sizeof(*(a))) - -#define stbiw__sbpush(a, v) (stbiw__sbmaybegrow(a,1), (a)[stbiw__sbn(a)++] = (v)) -#define stbiw__sbcount(a) ((a) ? stbiw__sbn(a) : 0) -#define stbiw__sbfree(a) ((a) ? STBIW_FREE(stbiw__sbraw(a)),0 : 0) - -static void *stbiw__sbgrowf(void **arr, int increment, int itemsize) -{ - int m = *arr ? 2*stbiw__sbm(*arr)+increment : increment+1; - void *p = STBIW_REALLOC_SIZED(*arr ? stbiw__sbraw(*arr) : 0, *arr ? (stbiw__sbm(*arr)*itemsize + sizeof(int)*2) : 0, itemsize * m + sizeof(int)*2); - STBIW_ASSERT(p); - if (p) { - if (!*arr) ((int *) p)[1] = 0; - *arr = (void *) ((int *) p + 2); - stbiw__sbm(*arr) = m; - } - return *arr; -} - -static unsigned char *stbiw__zlib_flushf(unsigned char *data, unsigned int *bitbuffer, int *bitcount) -{ - while (*bitcount >= 8) { - stbiw__sbpush(data, STBIW_UCHAR(*bitbuffer)); - *bitbuffer >>= 8; - *bitcount -= 8; - } - return data; -} - -static int stbiw__zlib_bitrev(int code, int codebits) -{ - int res=0; - while (codebits--) { - res = (res << 1) | (code & 1); - code >>= 1; - } - return res; -} - -static unsigned int stbiw__zlib_countm(unsigned char *a, unsigned char *b, int limit) -{ - int i; - for (i=0; i < limit && i < 258; ++i) - if (a[i] != b[i]) break; - return i; -} - -static unsigned int stbiw__zhash(unsigned char *data) -{ - stbiw_uint32 hash = data[0] + (data[1] << 8) + (data[2] << 16); - hash ^= hash << 3; - hash += hash >> 5; - hash ^= hash << 4; - hash += hash >> 17; - hash ^= hash << 25; - hash += hash >> 6; - return hash; -} - -#define stbiw__zlib_flush() (out = stbiw__zlib_flushf(out, &bitbuf, &bitcount)) -#define stbiw__zlib_add(code,codebits) \ - (bitbuf |= (code) << bitcount, bitcount += (codebits), stbiw__zlib_flush()) -#define stbiw__zlib_huffa(b,c) stbiw__zlib_add(stbiw__zlib_bitrev(b,c),c) -// default huffman tables -#define stbiw__zlib_huff1(n) stbiw__zlib_huffa(0x30 + (n), 8) -#define stbiw__zlib_huff2(n) stbiw__zlib_huffa(0x190 + (n)-144, 9) -#define stbiw__zlib_huff3(n) stbiw__zlib_huffa(0 + (n)-256,7) -#define stbiw__zlib_huff4(n) stbiw__zlib_huffa(0xc0 + (n)-280,8) -#define stbiw__zlib_huff(n) ((n) <= 143 ? stbiw__zlib_huff1(n) : (n) <= 255 ? stbiw__zlib_huff2(n) : (n) <= 279 ? stbiw__zlib_huff3(n) : stbiw__zlib_huff4(n)) -#define stbiw__zlib_huffb(n) ((n) <= 143 ? stbiw__zlib_huff1(n) : stbiw__zlib_huff2(n)) - -#define stbiw__ZHASH 16384 - -#endif // STBIW_ZLIB_COMPRESS - -STBIWDEF unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, int *out_len, int quality) -{ -#ifdef STBIW_ZLIB_COMPRESS - // user provided a zlib compress implementation, use that - return STBIW_ZLIB_COMPRESS(data, data_len, out_len, quality); -#else // use builtin - static unsigned short lengthc[] = { 3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258, 259 }; - static unsigned char lengtheb[]= { 0,0,0,0,0,0,0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0 }; - static unsigned short distc[] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577, 32768 }; - static unsigned char disteb[] = { 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13 }; - unsigned int bitbuf=0; - int i,j, bitcount=0; - unsigned char *out = NULL; - unsigned char ***hash_table = (unsigned char***) STBIW_MALLOC(stbiw__ZHASH * sizeof(unsigned char**)); - if (hash_table == NULL) - return NULL; - if (quality < 5) quality = 5; - - stbiw__sbpush(out, 0x78); // DEFLATE 32K window - stbiw__sbpush(out, 0x5e); // FLEVEL = 1 - stbiw__zlib_add(1,1); // BFINAL = 1 - stbiw__zlib_add(1,2); // BTYPE = 1 -- fixed huffman - - for (i=0; i < stbiw__ZHASH; ++i) - hash_table[i] = NULL; - - i=0; - while (i < data_len-3) { - // hash next 3 bytes of data to be compressed - int h = stbiw__zhash(data+i)&(stbiw__ZHASH-1), best=3; - unsigned char *bestloc = 0; - unsigned char **hlist = hash_table[h]; - int n = stbiw__sbcount(hlist); - for (j=0; j < n; ++j) { - if (hlist[j]-data > i-32768) { // if entry lies within window - int d = stbiw__zlib_countm(hlist[j], data+i, data_len-i); - if (d >= best) { best=d; bestloc=hlist[j]; } - } - } - // when hash table entry is too long, delete half the entries - if (hash_table[h] && stbiw__sbn(hash_table[h]) == 2*quality) { - STBIW_MEMMOVE(hash_table[h], hash_table[h]+quality, sizeof(hash_table[h][0])*quality); - stbiw__sbn(hash_table[h]) = quality; - } - stbiw__sbpush(hash_table[h],data+i); - - if (bestloc) { - // "lazy matching" - check match at *next* byte, and if it's better, do cur byte as literal - h = stbiw__zhash(data+i+1)&(stbiw__ZHASH-1); - hlist = hash_table[h]; - n = stbiw__sbcount(hlist); - for (j=0; j < n; ++j) { - if (hlist[j]-data > i-32767) { - int e = stbiw__zlib_countm(hlist[j], data+i+1, data_len-i-1); - if (e > best) { // if next match is better, bail on current match - bestloc = NULL; - break; - } - } - } - } - - if (bestloc) { - int d = (int) (data+i - bestloc); // distance back - STBIW_ASSERT(d <= 32767 && best <= 258); - for (j=0; best > lengthc[j+1]-1; ++j); - stbiw__zlib_huff(j+257); - if (lengtheb[j]) stbiw__zlib_add(best - lengthc[j], lengtheb[j]); - for (j=0; d > distc[j+1]-1; ++j); - stbiw__zlib_add(stbiw__zlib_bitrev(j,5),5); - if (disteb[j]) stbiw__zlib_add(d - distc[j], disteb[j]); - i += best; - } else { - stbiw__zlib_huffb(data[i]); - ++i; - } - } - // write out final bytes - for (;i < data_len; ++i) - stbiw__zlib_huffb(data[i]); - stbiw__zlib_huff(256); // end of block - // pad with 0 bits to byte boundary - while (bitcount) - stbiw__zlib_add(0,1); - - for (i=0; i < stbiw__ZHASH; ++i) - (void) stbiw__sbfree(hash_table[i]); - STBIW_FREE(hash_table); - - { - // compute adler32 on input - unsigned int s1=1, s2=0; - int blocklen = (int) (data_len % 5552); - j=0; - while (j < data_len) { - for (i=0; i < blocklen; ++i) { s1 += data[j+i]; s2 += s1; } - s1 %= 65521; s2 %= 65521; - j += blocklen; - blocklen = 5552; - } - stbiw__sbpush(out, STBIW_UCHAR(s2 >> 8)); - stbiw__sbpush(out, STBIW_UCHAR(s2)); - stbiw__sbpush(out, STBIW_UCHAR(s1 >> 8)); - stbiw__sbpush(out, STBIW_UCHAR(s1)); - } - *out_len = stbiw__sbn(out); - // make returned pointer freeable - STBIW_MEMMOVE(stbiw__sbraw(out), out, *out_len); - return (unsigned char *) stbiw__sbraw(out); -#endif // STBIW_ZLIB_COMPRESS -} - -static unsigned int stbiw__crc32(unsigned char *buffer, int len) -{ -#ifdef STBIW_CRC32 - return STBIW_CRC32(buffer, len); -#else - static unsigned int crc_table[256] = - { - 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, - 0x0eDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, - 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, - 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, - 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, - 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, - 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, - 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, - 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, - 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, - 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, - 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, - 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, - 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, - 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, - 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, - 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, - 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, - 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, - 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, - 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, - 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, - 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, - 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, - 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, - 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, - 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, - 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, - 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, - 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, - 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, - 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D - }; - - unsigned int crc = ~0u; - int i; - for (i=0; i < len; ++i) - crc = (crc >> 8) ^ crc_table[buffer[i] ^ (crc & 0xff)]; - return ~crc; -#endif -} - -#define stbiw__wpng4(o,a,b,c,d) ((o)[0]=STBIW_UCHAR(a),(o)[1]=STBIW_UCHAR(b),(o)[2]=STBIW_UCHAR(c),(o)[3]=STBIW_UCHAR(d),(o)+=4) -#define stbiw__wp32(data,v) stbiw__wpng4(data, (v)>>24,(v)>>16,(v)>>8,(v)); -#define stbiw__wptag(data,s) stbiw__wpng4(data, s[0],s[1],s[2],s[3]) - -static void stbiw__wpcrc(unsigned char **data, int len) -{ - unsigned int crc = stbiw__crc32(*data - len - 4, len+4); - stbiw__wp32(*data, crc); -} - -static unsigned char stbiw__paeth(int a, int b, int c) -{ - int p = a + b - c, pa = abs(p-a), pb = abs(p-b), pc = abs(p-c); - if (pa <= pb && pa <= pc) return STBIW_UCHAR(a); - if (pb <= pc) return STBIW_UCHAR(b); - return STBIW_UCHAR(c); -} - -// @OPTIMIZE: provide an option that always forces left-predict or paeth predict -static void stbiw__encode_png_line(unsigned char *pixels, int stride_bytes, int width, int height, int y, int n, int filter_type, signed char *line_buffer) -{ - static int mapping[] = { 0,1,2,3,4 }; - static int firstmap[] = { 0,1,0,5,6 }; - int *mymap = (y != 0) ? mapping : firstmap; - int i; - int type = mymap[filter_type]; - unsigned char *z = pixels + stride_bytes * (stbi__flip_vertically_on_write ? height-1-y : y); - int signed_stride = stbi__flip_vertically_on_write ? -stride_bytes : stride_bytes; - - if (type==0) { - memcpy(line_buffer, z, width*n); - return; - } - - // first loop isn't optimized since it's just one pixel - for (i = 0; i < n; ++i) { - switch (type) { - case 1: line_buffer[i] = z[i]; break; - case 2: line_buffer[i] = z[i] - z[i-signed_stride]; break; - case 3: line_buffer[i] = z[i] - (z[i-signed_stride]>>1); break; - case 4: line_buffer[i] = (signed char) (z[i] - stbiw__paeth(0,z[i-signed_stride],0)); break; - case 5: line_buffer[i] = z[i]; break; - case 6: line_buffer[i] = z[i]; break; - } - } - switch (type) { - case 1: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - z[i-n]; break; - case 2: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - z[i-signed_stride]; break; - case 3: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - ((z[i-n] + z[i-signed_stride])>>1); break; - case 4: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - stbiw__paeth(z[i-n], z[i-signed_stride], z[i-signed_stride-n]); break; - case 5: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - (z[i-n]>>1); break; - case 6: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - stbiw__paeth(z[i-n], 0,0); break; - } -} - -STBIWDEF unsigned char *stbi_write_png_to_mem(const unsigned char *pixels, int stride_bytes, int x, int y, int n, int *out_len) -{ - int force_filter = stbi_write_force_png_filter; - int ctype[5] = { -1, 0, 4, 2, 6 }; - unsigned char sig[8] = { 137,80,78,71,13,10,26,10 }; - unsigned char *out,*o, *filt, *zlib; - signed char *line_buffer; - int j,zlen; - - if (stride_bytes == 0) - stride_bytes = x * n; - - if (force_filter >= 5) { - force_filter = -1; - } - - filt = (unsigned char *) STBIW_MALLOC((x*n+1) * y); if (!filt) return 0; - line_buffer = (signed char *) STBIW_MALLOC(x * n); if (!line_buffer) { STBIW_FREE(filt); return 0; } - for (j=0; j < y; ++j) { - int filter_type; - if (force_filter > -1) { - filter_type = force_filter; - stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, force_filter, line_buffer); - } else { // Estimate the best filter by running through all of them: - int best_filter = 0, best_filter_val = 0x7fffffff, est, i; - for (filter_type = 0; filter_type < 5; filter_type++) { - stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, filter_type, line_buffer); - - // Estimate the entropy of the line using this filter; the less, the better. - est = 0; - for (i = 0; i < x*n; ++i) { - est += abs((signed char) line_buffer[i]); - } - if (est < best_filter_val) { - best_filter_val = est; - best_filter = filter_type; - } - } - if (filter_type != best_filter) { // If the last iteration already got us the best filter, don't redo it - stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, best_filter, line_buffer); - filter_type = best_filter; - } - } - // when we get here, filter_type contains the filter type, and line_buffer contains the data - filt[j*(x*n+1)] = (unsigned char) filter_type; - STBIW_MEMMOVE(filt+j*(x*n+1)+1, line_buffer, x*n); - } - STBIW_FREE(line_buffer); - zlib = stbi_zlib_compress(filt, y*( x*n+1), &zlen, stbi_write_png_compression_level); - STBIW_FREE(filt); - if (!zlib) return 0; - - // each tag requires 12 bytes of overhead - out = (unsigned char *) STBIW_MALLOC(8 + 12+13 + 12+zlen + 12); - if (!out) return 0; - *out_len = 8 + 12+13 + 12+zlen + 12; - - o=out; - STBIW_MEMMOVE(o,sig,8); o+= 8; - stbiw__wp32(o, 13); // header length - stbiw__wptag(o, "IHDR"); - stbiw__wp32(o, x); - stbiw__wp32(o, y); - *o++ = 8; - *o++ = STBIW_UCHAR(ctype[n]); - *o++ = 0; - *o++ = 0; - *o++ = 0; - stbiw__wpcrc(&o,13); - - stbiw__wp32(o, zlen); - stbiw__wptag(o, "IDAT"); - STBIW_MEMMOVE(o, zlib, zlen); - o += zlen; - STBIW_FREE(zlib); - stbiw__wpcrc(&o, zlen); - - stbiw__wp32(o,0); - stbiw__wptag(o, "IEND"); - stbiw__wpcrc(&o,0); - - STBIW_ASSERT(o == out + *out_len); - - return out; -} - -#ifndef STBI_WRITE_NO_STDIO -STBIWDEF int stbi_write_png(char const *filename, int x, int y, int comp, const void *data, int stride_bytes) -{ - FILE *f; - int len; - unsigned char *png = stbi_write_png_to_mem((const unsigned char *) data, stride_bytes, x, y, comp, &len); - if (png == NULL) return 0; - - f = stbiw__fopen(filename, "wb"); - if (!f) { STBIW_FREE(png); return 0; } - fwrite(png, 1, len, f); - fclose(f); - STBIW_FREE(png); - return 1; -} -#endif - -STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int stride_bytes) -{ - int len; - unsigned char *png = stbi_write_png_to_mem((const unsigned char *) data, stride_bytes, x, y, comp, &len); - if (png == NULL) return 0; - func(context, png, len); - STBIW_FREE(png); - return 1; -} - - -/* *************************************************************************** - * - * JPEG writer - * - * This is based on Jon Olick's jo_jpeg.cpp: - * public domain Simple, Minimalistic JPEG writer - http://www.jonolick.com/code.html - */ - -static const unsigned char stbiw__jpg_ZigZag[] = { 0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18, - 24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63 }; - -static void stbiw__jpg_writeBits(stbi__write_context *s, int *bitBufP, int *bitCntP, const unsigned short *bs) { - int bitBuf = *bitBufP, bitCnt = *bitCntP; - bitCnt += bs[1]; - bitBuf |= bs[0] << (24 - bitCnt); - while(bitCnt >= 8) { - unsigned char c = (bitBuf >> 16) & 255; - stbiw__putc(s, c); - if(c == 255) { - stbiw__putc(s, 0); - } - bitBuf <<= 8; - bitCnt -= 8; - } - *bitBufP = bitBuf; - *bitCntP = bitCnt; -} - -static void stbiw__jpg_DCT(float *d0p, float *d1p, float *d2p, float *d3p, float *d4p, float *d5p, float *d6p, float *d7p) { - float d0 = *d0p, d1 = *d1p, d2 = *d2p, d3 = *d3p, d4 = *d4p, d5 = *d5p, d6 = *d6p, d7 = *d7p; - float z1, z2, z3, z4, z5, z11, z13; - - float tmp0 = d0 + d7; - float tmp7 = d0 - d7; - float tmp1 = d1 + d6; - float tmp6 = d1 - d6; - float tmp2 = d2 + d5; - float tmp5 = d2 - d5; - float tmp3 = d3 + d4; - float tmp4 = d3 - d4; - - // Even part - float tmp10 = tmp0 + tmp3; // phase 2 - float tmp13 = tmp0 - tmp3; - float tmp11 = tmp1 + tmp2; - float tmp12 = tmp1 - tmp2; - - d0 = tmp10 + tmp11; // phase 3 - d4 = tmp10 - tmp11; - - z1 = (tmp12 + tmp13) * 0.707106781f; // c4 - d2 = tmp13 + z1; // phase 5 - d6 = tmp13 - z1; - - // Odd part - tmp10 = tmp4 + tmp5; // phase 2 - tmp11 = tmp5 + tmp6; - tmp12 = tmp6 + tmp7; - - // The rotator is modified from fig 4-8 to avoid extra negations. - z5 = (tmp10 - tmp12) * 0.382683433f; // c6 - z2 = tmp10 * 0.541196100f + z5; // c2-c6 - z4 = tmp12 * 1.306562965f + z5; // c2+c6 - z3 = tmp11 * 0.707106781f; // c4 - - z11 = tmp7 + z3; // phase 5 - z13 = tmp7 - z3; - - *d5p = z13 + z2; // phase 6 - *d3p = z13 - z2; - *d1p = z11 + z4; - *d7p = z11 - z4; - - *d0p = d0; *d2p = d2; *d4p = d4; *d6p = d6; -} - -static void stbiw__jpg_calcBits(int val, unsigned short bits[2]) { - int tmp1 = val < 0 ? -val : val; - val = val < 0 ? val-1 : val; - bits[1] = 1; - while(tmp1 >>= 1) { - ++bits[1]; - } - bits[0] = val & ((1<0)&&(DU[end0pos]==0); --end0pos) { - } - // end0pos = first element in reverse order !=0 - if(end0pos == 0) { - stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB); - return DU[0]; - } - for(i = 1; i <= end0pos; ++i) { - int startpos = i; - int nrzeroes; - unsigned short bits[2]; - for (; DU[i]==0 && i<=end0pos; ++i) { - } - nrzeroes = i-startpos; - if ( nrzeroes >= 16 ) { - int lng = nrzeroes>>4; - int nrmarker; - for (nrmarker=1; nrmarker <= lng; ++nrmarker) - stbiw__jpg_writeBits(s, bitBuf, bitCnt, M16zeroes); - nrzeroes &= 15; - } - stbiw__jpg_calcBits(DU[i], bits); - stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTAC[(nrzeroes<<4)+bits[1]]); - stbiw__jpg_writeBits(s, bitBuf, bitCnt, bits); - } - if(end0pos != 63) { - stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB); - } - return DU[0]; -} - -static int stbi_write_jpg_core(stbi__write_context *s, int width, int height, int comp, const void* data, int quality) { - // Constants that don't pollute global namespace - static const unsigned char std_dc_luminance_nrcodes[] = {0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0}; - static const unsigned char std_dc_luminance_values[] = {0,1,2,3,4,5,6,7,8,9,10,11}; - static const unsigned char std_ac_luminance_nrcodes[] = {0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,0x7d}; - static const unsigned char std_ac_luminance_values[] = { - 0x01,0x02,0x03,0x00,0x04,0x11,0x05,0x12,0x21,0x31,0x41,0x06,0x13,0x51,0x61,0x07,0x22,0x71,0x14,0x32,0x81,0x91,0xa1,0x08, - 0x23,0x42,0xb1,0xc1,0x15,0x52,0xd1,0xf0,0x24,0x33,0x62,0x72,0x82,0x09,0x0a,0x16,0x17,0x18,0x19,0x1a,0x25,0x26,0x27,0x28, - 0x29,0x2a,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58,0x59, - 0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x83,0x84,0x85,0x86,0x87,0x88,0x89, - 0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4,0xb5,0xb6, - 0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xe1,0xe2, - 0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa - }; - static const unsigned char std_dc_chrominance_nrcodes[] = {0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0}; - static const unsigned char std_dc_chrominance_values[] = {0,1,2,3,4,5,6,7,8,9,10,11}; - static const unsigned char std_ac_chrominance_nrcodes[] = {0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,0x77}; - static const unsigned char std_ac_chrominance_values[] = { - 0x00,0x01,0x02,0x03,0x11,0x04,0x05,0x21,0x31,0x06,0x12,0x41,0x51,0x07,0x61,0x71,0x13,0x22,0x32,0x81,0x08,0x14,0x42,0x91, - 0xa1,0xb1,0xc1,0x09,0x23,0x33,0x52,0xf0,0x15,0x62,0x72,0xd1,0x0a,0x16,0x24,0x34,0xe1,0x25,0xf1,0x17,0x18,0x19,0x1a,0x26, - 0x27,0x28,0x29,0x2a,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58, - 0x59,0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x82,0x83,0x84,0x85,0x86,0x87, - 0x88,0x89,0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4, - 0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda, - 0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa - }; - // Huffman tables - static const unsigned short YDC_HT[256][2] = { {0,2},{2,3},{3,3},{4,3},{5,3},{6,3},{14,4},{30,5},{62,6},{126,7},{254,8},{510,9}}; - static const unsigned short UVDC_HT[256][2] = { {0,2},{1,2},{2,2},{6,3},{14,4},{30,5},{62,6},{126,7},{254,8},{510,9},{1022,10},{2046,11}}; - static const unsigned short YAC_HT[256][2] = { - {10,4},{0,2},{1,2},{4,3},{11,4},{26,5},{120,7},{248,8},{1014,10},{65410,16},{65411,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {12,4},{27,5},{121,7},{502,9},{2038,11},{65412,16},{65413,16},{65414,16},{65415,16},{65416,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {28,5},{249,8},{1015,10},{4084,12},{65417,16},{65418,16},{65419,16},{65420,16},{65421,16},{65422,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {58,6},{503,9},{4085,12},{65423,16},{65424,16},{65425,16},{65426,16},{65427,16},{65428,16},{65429,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {59,6},{1016,10},{65430,16},{65431,16},{65432,16},{65433,16},{65434,16},{65435,16},{65436,16},{65437,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {122,7},{2039,11},{65438,16},{65439,16},{65440,16},{65441,16},{65442,16},{65443,16},{65444,16},{65445,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {123,7},{4086,12},{65446,16},{65447,16},{65448,16},{65449,16},{65450,16},{65451,16},{65452,16},{65453,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {250,8},{4087,12},{65454,16},{65455,16},{65456,16},{65457,16},{65458,16},{65459,16},{65460,16},{65461,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {504,9},{32704,15},{65462,16},{65463,16},{65464,16},{65465,16},{65466,16},{65467,16},{65468,16},{65469,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {505,9},{65470,16},{65471,16},{65472,16},{65473,16},{65474,16},{65475,16},{65476,16},{65477,16},{65478,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {506,9},{65479,16},{65480,16},{65481,16},{65482,16},{65483,16},{65484,16},{65485,16},{65486,16},{65487,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {1017,10},{65488,16},{65489,16},{65490,16},{65491,16},{65492,16},{65493,16},{65494,16},{65495,16},{65496,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {1018,10},{65497,16},{65498,16},{65499,16},{65500,16},{65501,16},{65502,16},{65503,16},{65504,16},{65505,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {2040,11},{65506,16},{65507,16},{65508,16},{65509,16},{65510,16},{65511,16},{65512,16},{65513,16},{65514,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {65515,16},{65516,16},{65517,16},{65518,16},{65519,16},{65520,16},{65521,16},{65522,16},{65523,16},{65524,16},{0,0},{0,0},{0,0},{0,0},{0,0}, - {2041,11},{65525,16},{65526,16},{65527,16},{65528,16},{65529,16},{65530,16},{65531,16},{65532,16},{65533,16},{65534,16},{0,0},{0,0},{0,0},{0,0},{0,0} - }; - static const unsigned short UVAC_HT[256][2] = { - {0,2},{1,2},{4,3},{10,4},{24,5},{25,5},{56,6},{120,7},{500,9},{1014,10},{4084,12},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {11,4},{57,6},{246,8},{501,9},{2038,11},{4085,12},{65416,16},{65417,16},{65418,16},{65419,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {26,5},{247,8},{1015,10},{4086,12},{32706,15},{65420,16},{65421,16},{65422,16},{65423,16},{65424,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {27,5},{248,8},{1016,10},{4087,12},{65425,16},{65426,16},{65427,16},{65428,16},{65429,16},{65430,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {58,6},{502,9},{65431,16},{65432,16},{65433,16},{65434,16},{65435,16},{65436,16},{65437,16},{65438,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {59,6},{1017,10},{65439,16},{65440,16},{65441,16},{65442,16},{65443,16},{65444,16},{65445,16},{65446,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {121,7},{2039,11},{65447,16},{65448,16},{65449,16},{65450,16},{65451,16},{65452,16},{65453,16},{65454,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {122,7},{2040,11},{65455,16},{65456,16},{65457,16},{65458,16},{65459,16},{65460,16},{65461,16},{65462,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {249,8},{65463,16},{65464,16},{65465,16},{65466,16},{65467,16},{65468,16},{65469,16},{65470,16},{65471,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {503,9},{65472,16},{65473,16},{65474,16},{65475,16},{65476,16},{65477,16},{65478,16},{65479,16},{65480,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {504,9},{65481,16},{65482,16},{65483,16},{65484,16},{65485,16},{65486,16},{65487,16},{65488,16},{65489,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {505,9},{65490,16},{65491,16},{65492,16},{65493,16},{65494,16},{65495,16},{65496,16},{65497,16},{65498,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {506,9},{65499,16},{65500,16},{65501,16},{65502,16},{65503,16},{65504,16},{65505,16},{65506,16},{65507,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {2041,11},{65508,16},{65509,16},{65510,16},{65511,16},{65512,16},{65513,16},{65514,16},{65515,16},{65516,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}, - {16352,14},{65517,16},{65518,16},{65519,16},{65520,16},{65521,16},{65522,16},{65523,16},{65524,16},{65525,16},{0,0},{0,0},{0,0},{0,0},{0,0}, - {1018,10},{32707,15},{65526,16},{65527,16},{65528,16},{65529,16},{65530,16},{65531,16},{65532,16},{65533,16},{65534,16},{0,0},{0,0},{0,0},{0,0},{0,0} - }; - static const int YQT[] = {16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22, - 37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99}; - static const int UVQT[] = {17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99, - 99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99}; - static const float aasf[] = { 1.0f * 2.828427125f, 1.387039845f * 2.828427125f, 1.306562965f * 2.828427125f, 1.175875602f * 2.828427125f, - 1.0f * 2.828427125f, 0.785694958f * 2.828427125f, 0.541196100f * 2.828427125f, 0.275899379f * 2.828427125f }; - - int row, col, i, k, subsample; - float fdtbl_Y[64], fdtbl_UV[64]; - unsigned char YTable[64], UVTable[64]; - - if(!data || !width || !height || comp > 4 || comp < 1) { - return 0; - } - - quality = quality ? quality : 90; - subsample = quality <= 90 ? 1 : 0; - quality = quality < 1 ? 1 : quality > 100 ? 100 : quality; - quality = quality < 50 ? 5000 / quality : 200 - quality * 2; - - for(i = 0; i < 64; ++i) { - int uvti, yti = (YQT[i]*quality+50)/100; - YTable[stbiw__jpg_ZigZag[i]] = (unsigned char) (yti < 1 ? 1 : yti > 255 ? 255 : yti); - uvti = (UVQT[i]*quality+50)/100; - UVTable[stbiw__jpg_ZigZag[i]] = (unsigned char) (uvti < 1 ? 1 : uvti > 255 ? 255 : uvti); - } - - for(row = 0, k = 0; row < 8; ++row) { - for(col = 0; col < 8; ++col, ++k) { - fdtbl_Y[k] = 1 / (YTable [stbiw__jpg_ZigZag[k]] * aasf[row] * aasf[col]); - fdtbl_UV[k] = 1 / (UVTable[stbiw__jpg_ZigZag[k]] * aasf[row] * aasf[col]); - } - } - - // Write Headers - { - static const unsigned char head0[] = { 0xFF,0xD8,0xFF,0xE0,0,0x10,'J','F','I','F',0,1,1,0,0,1,0,1,0,0,0xFF,0xDB,0,0x84,0 }; - static const unsigned char head2[] = { 0xFF,0xDA,0,0xC,3,1,0,2,0x11,3,0x11,0,0x3F,0 }; - const unsigned char head1[] = { 0xFF,0xC0,0,0x11,8,(unsigned char)(height>>8),STBIW_UCHAR(height),(unsigned char)(width>>8),STBIW_UCHAR(width), - 3,1,(unsigned char)(subsample?0x22:0x11),0,2,0x11,1,3,0x11,1,0xFF,0xC4,0x01,0xA2,0 }; - s->func(s->context, (void*)head0, sizeof(head0)); - s->func(s->context, (void*)YTable, sizeof(YTable)); - stbiw__putc(s, 1); - s->func(s->context, UVTable, sizeof(UVTable)); - s->func(s->context, (void*)head1, sizeof(head1)); - s->func(s->context, (void*)(std_dc_luminance_nrcodes+1), sizeof(std_dc_luminance_nrcodes)-1); - s->func(s->context, (void*)std_dc_luminance_values, sizeof(std_dc_luminance_values)); - stbiw__putc(s, 0x10); // HTYACinfo - s->func(s->context, (void*)(std_ac_luminance_nrcodes+1), sizeof(std_ac_luminance_nrcodes)-1); - s->func(s->context, (void*)std_ac_luminance_values, sizeof(std_ac_luminance_values)); - stbiw__putc(s, 1); // HTUDCinfo - s->func(s->context, (void*)(std_dc_chrominance_nrcodes+1), sizeof(std_dc_chrominance_nrcodes)-1); - s->func(s->context, (void*)std_dc_chrominance_values, sizeof(std_dc_chrominance_values)); - stbiw__putc(s, 0x11); // HTUACinfo - s->func(s->context, (void*)(std_ac_chrominance_nrcodes+1), sizeof(std_ac_chrominance_nrcodes)-1); - s->func(s->context, (void*)std_ac_chrominance_values, sizeof(std_ac_chrominance_values)); - s->func(s->context, (void*)head2, sizeof(head2)); - } - - // Encode 8x8 macroblocks - { - static const unsigned short fillBits[] = {0x7F, 7}; - int DCY=0, DCU=0, DCV=0; - int bitBuf=0, bitCnt=0; - // comp == 2 is grey+alpha (alpha is ignored) - int ofsG = comp > 2 ? 1 : 0, ofsB = comp > 2 ? 2 : 0; - const unsigned char *dataR = (const unsigned char *)data; - const unsigned char *dataG = dataR + ofsG; - const unsigned char *dataB = dataR + ofsB; - int x, y, pos; - if(subsample) { - for(y = 0; y < height; y += 16) { - for(x = 0; x < width; x += 16) { - float Y[256], U[256], V[256]; - for(row = y, pos = 0; row < y+16; ++row) { - // row >= height => use last input row - int clamped_row = (row < height) ? row : height - 1; - int base_p = (stbi__flip_vertically_on_write ? (height-1-clamped_row) : clamped_row)*width*comp; - for(col = x; col < x+16; ++col, ++pos) { - // if col >= width => use pixel from last input column - int p = base_p + ((col < width) ? col : (width-1))*comp; - float r = dataR[p], g = dataG[p], b = dataB[p]; - Y[pos]= +0.29900f*r + 0.58700f*g + 0.11400f*b - 128; - U[pos]= -0.16874f*r - 0.33126f*g + 0.50000f*b; - V[pos]= +0.50000f*r - 0.41869f*g - 0.08131f*b; - } - } - DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+0, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT); - DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+8, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT); - DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+128, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT); - DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+136, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT); - - // subsample U,V - { - float subU[64], subV[64]; - int yy, xx; - for(yy = 0, pos = 0; yy < 8; ++yy) { - for(xx = 0; xx < 8; ++xx, ++pos) { - int j = yy*32+xx*2; - subU[pos] = (U[j+0] + U[j+1] + U[j+16] + U[j+17]) * 0.25f; - subV[pos] = (V[j+0] + V[j+1] + V[j+16] + V[j+17]) * 0.25f; - } - } - DCU = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, subU, 8, fdtbl_UV, DCU, UVDC_HT, UVAC_HT); - DCV = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, subV, 8, fdtbl_UV, DCV, UVDC_HT, UVAC_HT); - } - } - } - } else { - for(y = 0; y < height; y += 8) { - for(x = 0; x < width; x += 8) { - float Y[64], U[64], V[64]; - for(row = y, pos = 0; row < y+8; ++row) { - // row >= height => use last input row - int clamped_row = (row < height) ? row : height - 1; - int base_p = (stbi__flip_vertically_on_write ? (height-1-clamped_row) : clamped_row)*width*comp; - for(col = x; col < x+8; ++col, ++pos) { - // if col >= width => use pixel from last input column - int p = base_p + ((col < width) ? col : (width-1))*comp; - float r = dataR[p], g = dataG[p], b = dataB[p]; - Y[pos]= +0.29900f*r + 0.58700f*g + 0.11400f*b - 128; - U[pos]= -0.16874f*r - 0.33126f*g + 0.50000f*b; - V[pos]= +0.50000f*r - 0.41869f*g - 0.08131f*b; - } - } - - DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y, 8, fdtbl_Y, DCY, YDC_HT, YAC_HT); - DCU = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, U, 8, fdtbl_UV, DCU, UVDC_HT, UVAC_HT); - DCV = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, V, 8, fdtbl_UV, DCV, UVDC_HT, UVAC_HT); - } - } - } - - // Do the bit alignment of the EOI marker - stbiw__jpg_writeBits(s, &bitBuf, &bitCnt, fillBits); - } - - // EOI - stbiw__putc(s, 0xFF); - stbiw__putc(s, 0xD9); - - return 1; -} - -STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality) -{ - stbi__write_context s; - stbi__start_write_callbacks(&s, func, context); - return stbi_write_jpg_core(&s, x, y, comp, (void *) data, quality); -} - - -#ifndef STBI_WRITE_NO_STDIO -STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality) -{ - stbi__write_context s; - if (stbi__start_write_file(&s,filename)) { - int r = stbi_write_jpg_core(&s, x, y, comp, data, quality); - stbi__end_write_file(&s); - return r; - } else - return 0; -} -#endif - -#endif // STB_IMAGE_WRITE_IMPLEMENTATION - -/* Revision history - 1.14 (2020-02-02) updated JPEG writer to downsample chroma channels - 1.13 - 1.12 - 1.11 (2019-08-11) - - 1.10 (2019-02-07) - support utf8 filenames in Windows; fix warnings and platform ifdefs - 1.09 (2018-02-11) - fix typo in zlib quality API, improve STB_I_W_STATIC in C++ - 1.08 (2018-01-29) - add stbi__flip_vertically_on_write, external zlib, zlib quality, choose PNG filter - 1.07 (2017-07-24) - doc fix - 1.06 (2017-07-23) - writing JPEG (using Jon Olick's code) - 1.05 ??? - 1.04 (2017-03-03) - monochrome BMP expansion - 1.03 ??? - 1.02 (2016-04-02) - avoid allocating large structures on the stack - 1.01 (2016-01-16) - STBIW_REALLOC_SIZED: support allocators with no realloc support - avoid race-condition in crc initialization - minor compile issues - 1.00 (2015-09-14) - installable file IO function - 0.99 (2015-09-13) - warning fixes; TGA rle support - 0.98 (2015-04-08) - added STBIW_MALLOC, STBIW_ASSERT etc - 0.97 (2015-01-18) - fixed HDR asserts, rewrote HDR rle logic - 0.96 (2015-01-17) - add HDR output - fix monochrome BMP - 0.95 (2014-08-17) - add monochrome TGA output - 0.94 (2014-05-31) - rename private functions to avoid conflicts with stb_image.h - 0.93 (2014-05-27) - warning fixes - 0.92 (2010-08-01) - casts to unsigned char to fix warnings - 0.91 (2010-07-17) - first public release - 0.90 first internal release -*/ - -/* ------------------------------------------------------------------------------- -This software is available under 2 licenses -- choose whichever you prefer. ------------------------------------------------------------------------------- -ALTERNATIVE A - MIT License -Copyright (c) 2017 Sean Barrett -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. ------------------------------------------------------------------------------- -ALTERNATIVE B - Public Domain (www.unlicense.org) -This is free and unencumbered software released into the public domain. -Anyone is free to copy, modify, publish, use, compile, sell, or distribute this -software, either in source code form or as a compiled binary, for any purpose, -commercial or non-commercial, and by any means. -In jurisdictions that recognize copyright laws, the author or authors of this -software dedicate any and all copyright interest in the software to the public -domain. We make this dedication for the benefit of the public at large and to -the detriment of our heirs and successors. We intend this dedication to be an -overt act of relinquishment in perpetuity of all present and future rights to -this software under copyright law. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------- -*/ diff --git a/extern/tfn/.clang-format b/extern/tfn/.clang-format deleted file mode 100644 index 6fb9f88..0000000 --- a/extern/tfn/.clang-format +++ /dev/null @@ -1,95 +0,0 @@ ---- -Language: Cpp -# BasedOnStyle: Google -AccessModifierOffset: -1 -AlignAfterOpenBracket: DontAlign -AlignConsecutiveAssignments: false -AlignConsecutiveDeclarations: false -#EscapedNewlineAlignmentStyle: Right -AlignEscapedNewlines: Right -AlignOperands: false -AlignTrailingComments: false -AllowAllParametersOfDeclarationOnNextLine: true -AllowShortBlocksOnASingleLine: false -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: Empty -#AllowShortLambdasOnASingleLine: Empty -AllowShortIfStatementsOnASingleLine: false -AllowShortLoopsOnASingleLine: false -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: true -AlwaysBreakTemplateDeclarations: true -BinPackArguments: true -BinPackParameters: true -BraceWrapping: - AfterClass: true - AfterControlStatement: false - AfterEnum: true - AfterFunction: true - AfterNamespace: false - AfterStruct: true - AfterUnion: true - BeforeCatch: false - BeforeElse: false - IndentBraces: false - SplitEmptyFunction: false -BreakBeforeBinaryOperators: All -BreakBeforeBraces: Custom -BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: false -#BreakConstructorInitializersStyle: BeforeComma -BreakStringLiterals: false -ColumnLimit: 160 -CommentPragmas: '^ IWYU pragma:' -ConstructorInitializerAllOnOneLineOrOnePerLine: true -ConstructorInitializerIndentWidth: 4 -ContinuationIndentWidth: 4 -Cpp11BracedListStyle: true -DerivePointerAlignment: false -DisableFormat: false -ExperimentalAutoDetectBinPacking: true -FixNamespaceComments: true -ForEachMacros: [ foreach, foreach_active, foreach_tiled, foreach_unique, cdo, cfor, cif, cwhile ] -IncludeCategories: - - Regex: '^<.*\.i?h>' - Priority: 1 - - Regex: '^<.*' - Priority: 2 - - Regex: '.*' - Priority: 3 -IncludeIsMainRegex: '([-_](test|unittest))?$' -IndentCaseLabels: false -IndentWidth: 2 -IndentWrappedFunctionNames: false -KeepEmptyLinesAtTheStartOfBlocks: false -MacroBlockBegin: '' -MacroBlockEnd: '' -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: None -PenaltyBreakBeforeFirstCallParameter: 1 -PenaltyBreakComment: 300 -PenaltyBreakFirstLessLess: 120 -PenaltyBreakString: 1000 -PenaltyExcessCharacter: 1000000 -PenaltyReturnTypeOnItsOwnLine: 200 -#PPDirectiveIndentStyle: AfterHash -PointerAlignment: Right -ReflowComments: true -SortIncludes: true -SpaceAfterCStyleCast: false -SpaceAfterTemplateKeyword: true -SpaceBeforeAssignmentOperators: true -SpaceBeforeParens: ControlStatements -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 1 -SpacesInAngles: false -SpacesInContainerLiterals: false -SpacesInCStyleCastParentheses: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -Standard: Cpp11 -TabWidth: 2 -UseTab: Never -... - diff --git a/extern/tfn/colormaps/CMakeLists.txt b/extern/tfn/colormaps/CMakeLists.txt deleted file mode 100644 index 777fcaf..0000000 --- a/extern/tfn/colormaps/CMakeLists.txt +++ /dev/null @@ -1,72 +0,0 @@ -# -# Automatically generated file, do not modify. -# -# ======================================================================== # -# Copyright 2019-2020 Qi Wu # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -# ======================================================================== # -set(embedded_colormap -${CMAKE_CURRENT_LIST_DIR}/colormap.cpp -${CMAKE_CURRENT_LIST_DIR}/colormap.h -${CMAKE_CURRENT_LIST_DIR}/diverging/BrBG.cpp -${CMAKE_CURRENT_LIST_DIR}/diverging/RdYlGn.cpp -${CMAKE_CURRENT_LIST_DIR}/diverging/RdBu.cpp -${CMAKE_CURRENT_LIST_DIR}/diverging/RdYlBu.cpp -${CMAKE_CURRENT_LIST_DIR}/diverging/bwr.cpp -${CMAKE_CURRENT_LIST_DIR}/diverging/Spectral.cpp -${CMAKE_CURRENT_LIST_DIR}/diverging/RdGy.cpp -${CMAKE_CURRENT_LIST_DIR}/diverging/seismic.cpp -${CMAKE_CURRENT_LIST_DIR}/diverging/coolwarm.cpp -${CMAKE_CURRENT_LIST_DIR}/diverging/PRGn.cpp -${CMAKE_CURRENT_LIST_DIR}/diverging/PuOr.cpp -${CMAKE_CURRENT_LIST_DIR}/diverging/PiYG.cpp -${CMAKE_CURRENT_LIST_DIR}/perceptual/magma.cpp -${CMAKE_CURRENT_LIST_DIR}/perceptual/inferno.cpp -${CMAKE_CURRENT_LIST_DIR}/perceptual/viridis.cpp -${CMAKE_CURRENT_LIST_DIR}/perceptual/plasma.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential/Purples.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential/PuBuGn.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential/Oranges.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential/Blues.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential/YlGn.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential/PuBu.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential/GnBu.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential/Greens.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential/PuRd.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential/BuPu.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential/Greys.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential/YlOrBr.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential/RdPu.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential/YlOrRd.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential/Reds.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential/YlGnBu.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential/BuGn.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential/OrRd.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential2/hot.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential2/Wistia.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential2/gist_gray.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential2/bone.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential2/winter.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential2/pink.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential2/binary.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential2/autumn.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential2/spring.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential2/gist_yarg.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential2/copper.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential2/gray.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential2/afmhot.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential2/cool.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential2/gist_heat.cpp -${CMAKE_CURRENT_LIST_DIR}/sequential2/summer.cpp -PARENT_SCOPE) diff --git a/extern/tfn/colormaps/colormap.cpp b/extern/tfn/colormaps/colormap.cpp deleted file mode 100644 index 8d49fed..0000000 --- a/extern/tfn/colormaps/colormap.cpp +++ /dev/null @@ -1,195 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::unordered_map*> data; -extern const std::vector name; -bool has(const char* name); -const std::vector& get(const char* name); -extern const std::vector data_diverging_BrBG; -extern const std::vector data_diverging_RdYlGn; -extern const std::vector data_diverging_RdBu; -extern const std::vector data_diverging_RdYlBu; -extern const std::vector data_diverging_bwr; -extern const std::vector data_diverging_Spectral; -extern const std::vector data_diverging_RdGy; -extern const std::vector data_diverging_seismic; -extern const std::vector data_diverging_coolwarm; -extern const std::vector data_diverging_PRGn; -extern const std::vector data_diverging_PuOr; -extern const std::vector data_diverging_PiYG; -extern const std::vector data_perceptual_magma; -extern const std::vector data_perceptual_inferno; -extern const std::vector data_perceptual_viridis; -extern const std::vector data_perceptual_plasma; -extern const std::vector data_sequential_Purples; -extern const std::vector data_sequential_PuBuGn; -extern const std::vector data_sequential_Oranges; -extern const std::vector data_sequential_Blues; -extern const std::vector data_sequential_YlGn; -extern const std::vector data_sequential_PuBu; -extern const std::vector data_sequential_GnBu; -extern const std::vector data_sequential_Greens; -extern const std::vector data_sequential_PuRd; -extern const std::vector data_sequential_BuPu; -extern const std::vector data_sequential_Greys; -extern const std::vector data_sequential_YlOrBr; -extern const std::vector data_sequential_RdPu; -extern const std::vector data_sequential_YlOrRd; -extern const std::vector data_sequential_Reds; -extern const std::vector data_sequential_YlGnBu; -extern const std::vector data_sequential_BuGn; -extern const std::vector data_sequential_OrRd; -extern const std::vector data_sequential2_hot; -extern const std::vector data_sequential2_Wistia; -extern const std::vector data_sequential2_gist_gray; -extern const std::vector data_sequential2_bone; -extern const std::vector data_sequential2_winter; -extern const std::vector data_sequential2_pink; -extern const std::vector data_sequential2_binary; -extern const std::vector data_sequential2_autumn; -extern const std::vector data_sequential2_spring; -extern const std::vector data_sequential2_gist_yarg; -extern const std::vector data_sequential2_copper; -extern const std::vector data_sequential2_gray; -extern const std::vector data_sequential2_afmhot; -extern const std::vector data_sequential2_cool; -extern const std::vector data_sequential2_gist_heat; -extern const std::vector data_sequential2_summer; -} -// definitions -const std::unordered_map*> - colormap::data = /* NOLINT(cert-err58-cpp) */ -{ -{ "diverging/BrBG", &colormap::data_diverging_BrBG }, -{ "diverging/RdYlGn", &colormap::data_diverging_RdYlGn }, -{ "diverging/RdBu", &colormap::data_diverging_RdBu }, -{ "diverging/RdYlBu", &colormap::data_diverging_RdYlBu }, -{ "diverging/bwr", &colormap::data_diverging_bwr }, -{ "diverging/Spectral", &colormap::data_diverging_Spectral }, -{ "diverging/RdGy", &colormap::data_diverging_RdGy }, -{ "diverging/seismic", &colormap::data_diverging_seismic }, -{ "diverging/coolwarm", &colormap::data_diverging_coolwarm }, -{ "diverging/PRGn", &colormap::data_diverging_PRGn }, -{ "diverging/PuOr", &colormap::data_diverging_PuOr }, -{ "diverging/PiYG", &colormap::data_diverging_PiYG }, -{ "perceptual/magma", &colormap::data_perceptual_magma }, -{ "perceptual/inferno", &colormap::data_perceptual_inferno }, -{ "perceptual/viridis", &colormap::data_perceptual_viridis }, -{ "perceptual/plasma", &colormap::data_perceptual_plasma }, -{ "sequential/Purples", &colormap::data_sequential_Purples }, -{ "sequential/PuBuGn", &colormap::data_sequential_PuBuGn }, -{ "sequential/Oranges", &colormap::data_sequential_Oranges }, -{ "sequential/Blues", &colormap::data_sequential_Blues }, -{ "sequential/YlGn", &colormap::data_sequential_YlGn }, -{ "sequential/PuBu", &colormap::data_sequential_PuBu }, -{ "sequential/GnBu", &colormap::data_sequential_GnBu }, -{ "sequential/Greens", &colormap::data_sequential_Greens }, -{ "sequential/PuRd", &colormap::data_sequential_PuRd }, -{ "sequential/BuPu", &colormap::data_sequential_BuPu }, -{ "sequential/Greys", &colormap::data_sequential_Greys }, -{ "sequential/YlOrBr", &colormap::data_sequential_YlOrBr }, -{ "sequential/RdPu", &colormap::data_sequential_RdPu }, -{ "sequential/YlOrRd", &colormap::data_sequential_YlOrRd }, -{ "sequential/Reds", &colormap::data_sequential_Reds }, -{ "sequential/YlGnBu", &colormap::data_sequential_YlGnBu }, -{ "sequential/BuGn", &colormap::data_sequential_BuGn }, -{ "sequential/OrRd", &colormap::data_sequential_OrRd }, -{ "sequential2/hot", &colormap::data_sequential2_hot }, -{ "sequential2/Wistia", &colormap::data_sequential2_Wistia }, -{ "sequential2/gist_gray", &colormap::data_sequential2_gist_gray }, -{ "sequential2/bone", &colormap::data_sequential2_bone }, -{ "sequential2/winter", &colormap::data_sequential2_winter }, -{ "sequential2/pink", &colormap::data_sequential2_pink }, -{ "sequential2/binary", &colormap::data_sequential2_binary }, -{ "sequential2/autumn", &colormap::data_sequential2_autumn }, -{ "sequential2/spring", &colormap::data_sequential2_spring }, -{ "sequential2/gist_yarg", &colormap::data_sequential2_gist_yarg }, -{ "sequential2/copper", &colormap::data_sequential2_copper }, -{ "sequential2/gray", &colormap::data_sequential2_gray }, -{ "sequential2/afmhot", &colormap::data_sequential2_afmhot }, -{ "sequential2/cool", &colormap::data_sequential2_cool }, -{ "sequential2/gist_heat", &colormap::data_sequential2_gist_heat }, -{ "sequential2/summer", &colormap::data_sequential2_summer }, -}; -const std::vector colormap::name = /* NOLINT(cert-err58-cpp) */ -{ -"diverging/BrBG", -"diverging/RdYlGn", -"diverging/RdBu", -"diverging/RdYlBu", -"diverging/bwr", -"diverging/Spectral", -"diverging/RdGy", -"diverging/seismic", -"diverging/coolwarm", -"diverging/PRGn", -"diverging/PuOr", -"diverging/PiYG", -"perceptual/magma", -"perceptual/inferno", -"perceptual/viridis", -"perceptual/plasma", -"sequential/Purples", -"sequential/PuBuGn", -"sequential/Oranges", -"sequential/Blues", -"sequential/YlGn", -"sequential/PuBu", -"sequential/GnBu", -"sequential/Greens", -"sequential/PuRd", -"sequential/BuPu", -"sequential/Greys", -"sequential/YlOrBr", -"sequential/RdPu", -"sequential/YlOrRd", -"sequential/Reds", -"sequential/YlGnBu", -"sequential/BuGn", -"sequential/OrRd", -"sequential2/hot", -"sequential2/Wistia", -"sequential2/gist_gray", -"sequential2/bone", -"sequential2/winter", -"sequential2/pink", -"sequential2/binary", -"sequential2/autumn", -"sequential2/spring", -"sequential2/gist_yarg", -"sequential2/copper", -"sequential2/gray", -"sequential2/afmhot", -"sequential2/cool", -"sequential2/gist_heat", -"sequential2/summer", -}; -bool colormap::has(const char* name) { - return data.find(std::string(name)) != data.end(); -} -const std::vector& colormap::get(const char* name) { - return *data.at(std::string(name)); -} diff --git a/extern/tfn/colormaps/colormap.h b/extern/tfn/colormaps/colormap.h deleted file mode 100644 index ca46fd4..0000000 --- a/extern/tfn/colormaps/colormap.h +++ /dev/null @@ -1,88 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -// available colormap keys: -// -// diverging/BrBG -// diverging/RdYlGn -// diverging/RdBu -// diverging/RdYlBu -// diverging/bwr -// diverging/Spectral -// diverging/RdGy -// diverging/seismic -// diverging/coolwarm -// diverging/PRGn -// diverging/PuOr -// diverging/PiYG -// perceptual/magma -// perceptual/inferno -// perceptual/viridis -// perceptual/plasma -// sequential/Purples -// sequential/PuBuGn -// sequential/Oranges -// sequential/Blues -// sequential/YlGn -// sequential/PuBu -// sequential/GnBu -// sequential/Greens -// sequential/PuRd -// sequential/BuPu -// sequential/Greys -// sequential/YlOrBr -// sequential/RdPu -// sequential/YlOrRd -// sequential/Reds -// sequential/YlGnBu -// sequential/BuGn -// sequential/OrRd -// sequential2/hot -// sequential2/Wistia -// sequential2/gist_gray -// sequential2/bone -// sequential2/winter -// sequential2/pink -// sequential2/binary -// sequential2/autumn -// sequential2/spring -// sequential2/gist_yarg -// sequential2/copper -// sequential2/gray -// sequential2/afmhot -// sequential2/cool -// sequential2/gist_heat -// sequential2/summer - -#ifndef TFN_COLORMAP_H -#define TFN_COLORMAP_H - -#include -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -bool has(const char* name); -const std::vector& get(const char* name); -} - -#endif // TFN_COLORMAP_H diff --git a/extern/tfn/colormaps/create.sh b/extern/tfn/colormaps/create.sh deleted file mode 100644 index d3ca18e..0000000 --- a/extern/tfn/colormaps/create.sh +++ /dev/null @@ -1,180 +0,0 @@ -#!/bin/bash - -FILES=$(find * -type f -iname "*.txt" ! -iname "CMakeLists.txt") -ROOT=${PWD}/../ -BASE=colormap - -# Generate one source for each map -for f in ${FILES}; do - DATA=$(sed -e 's/,/f,/g' -e 's/)/f},/g' -e 's/(/{/g' ${f}) # replace '(' and ')' - NAME=${f%.*} # sequence/hot - NVAR=$(echo ${NAME} | sed -e 's/\//\_/g') # sequence/hot -> sequence_hot - cat > ${PWD}/${NAME}.cpp << EOF -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_${NVAR}; -} -const std::vector colormap::data_${NVAR} = /* NOLINT(cert-err58-cpp) */ -{ -${DATA} -}; -EOF -done - -# Generate the header file first -DATA=$(for f in ${FILES}; do NAME=${f%.*}; echo "// ${NAME}"; done) -cat > ${BASE}.h << EOF -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -// available colormap keys: -// -${DATA} - -#ifndef TFN_COLORMAP_H -#define TFN_COLORMAP_H - -#include -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -bool has(const std::string& name); -const std::vector& get(const std::string& name); -} - -#endif // TFN_COLORMAP_H -EOF - -# Now the Source File -DATA1=$(for f in ${FILES}; \ - do NVAR=$(echo ${f%.*} | sed -e 's/\//\_/g'); \ - echo "extern const std::vector data_${NVAR};"; \ - done) -DATA2=$(for f in ${FILES}; \ - do NAME=${f%.*}; \ - NVAR=$(echo ${NAME} | sed -e 's/\//\_/g'); \ - echo "{ \"${NAME}\", &colormap::data_${NVAR} },"; \ - done) -DATA3=$(for f in ${FILES}; do echo "\"${f%.*}\","; done) -cat > ${BASE}.cpp << EOF -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::unordered_map*> data; -extern const std::vector name; -bool has(const std::string& name); -const std::vector& get(const std::string& name); -${DATA1} -} -// definitions -const std::unordered_map*> - colormap::data = /* NOLINT(cert-err58-cpp) */ -{ -${DATA2} -}; -const std::vector colormap::name = /* NOLINT(cert-err58-cpp) */ -{ -${DATA3} -}; -bool colormap::has(const std::string& name) { - return data.find(name) != data.end(); -} -const std::vector& colormap::get(const std::string& name) { - return *data.at(name); -} -EOF - -# add cmake files -DATA=$(for f in ${FILES}; do echo "\${CMAKE_CURRENT_LIST_DIR}/${f%.*}.cpp"; done) -cat > CMakeLists.txt << EOF -# -# Automatically generated file, do not modify. -# -# ======================================================================== # -# Copyright 2019-2020 Qi Wu # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -# ======================================================================== # -set(embedded_colormap -\${CMAKE_CURRENT_LIST_DIR}/${BASE}.cpp -\${CMAKE_CURRENT_LIST_DIR}/${BASE}.h -${DATA} -PARENT_SCOPE) -EOF diff --git a/extern/tfn/colormaps/diverging/BrBG.cpp b/extern/tfn/colormaps/diverging/BrBG.cpp deleted file mode 100644 index 8e224aa..0000000 --- a/extern/tfn/colormaps/diverging/BrBG.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_diverging_BrBG; -} -const std::vector colormap::data_diverging_BrBG = /* NOLINT(cert-err58-cpp) */ -{ -{0.32941176470588235f, 0.18823529411764706f, 0.019607843137254902f, 1.0f}, -{0.33802383698577471f, 0.1933102652825836f, 0.020376778162245292f, 1.0f}, -{0.34663590926566706f, 0.19838523644752018f, 0.021145713187235678f, 1.0f}, -{0.35524798154555942f, 0.20346020761245676f, 0.021914648212226065f, 1.0f}, -{0.36386005382545172f, 0.2085351787773933f, 0.022683583237216455f, 1.0f}, -{0.37247212610534408f, 0.21361014994232985f, 0.023452518262206842f, 1.0f}, -{0.38108419838523644f, 0.21868512110726643f, 0.024221453287197232f, 1.0f}, -{0.3896962706651288f, 0.223760092272203f, 0.024990388312187618f, 1.0f}, -{0.39830834294502115f, 0.22883506343713955f, 0.025759323337178008f, 1.0f}, -{0.40692041522491351f, 0.23391003460207613f, 0.026528258362168398f, 1.0f}, -{0.41553248750480587f, 0.23898500576701268f, 0.027297193387158785f, 1.0f}, -{0.42414455978469823f, 0.24405997693194925f, 0.028066128412149172f, 1.0f}, -{0.43275663206459059f, 0.2491349480968858f, 0.028835063437139562f, 1.0f}, -{0.44136870434448289f, 0.25420991926182235f, 0.029603998462129948f, 1.0f}, -{0.4499807766243753f, 0.25928489042675895f, 0.030372933487120338f, 1.0f}, -{0.45859284890426766f, 0.2643598615916955f, 0.031141868512110725f, 1.0f}, -{0.46720492118415996f, 0.26943483275663205f, 0.031910803537101115f, 1.0f}, -{0.47581699346405232f, 0.2745098039215686f, 0.032679738562091498f, 1.0f}, -{0.48442906574394468f, 0.2795847750865052f, 0.033448673587081895f, 1.0f}, -{0.49304113802383703f, 0.28465974625144175f, 0.034217608612072278f, 1.0f}, -{0.50165321030372934f, 0.2897347174163783f, 0.034986543637062668f, 1.0f}, -{0.51026528258362169f, 0.29480968858131484f, 0.035755478662053058f, 1.0f}, -{0.51887735486351405f, 0.29988465974625145f, 0.036524413687043442f, 1.0f}, -{0.52748942714340641f, 0.304959630911188f, 0.037293348712033832f, 1.0f}, -{0.53610149942329877f, 0.31003460207612454f, 0.038062283737024222f, 1.0f}, -{0.54471357170319112f, 0.31510957324106115f, 0.038831218762014605f, 1.0f}, -{0.55294117647058827f, 0.32133794694348328f, 0.041906958861976165f, 1.0f}, -{0.5607843137254902f, 0.32871972318339099f, 0.047289504036908882f, 1.0f}, -{0.56862745098039225f, 0.3361014994232987f, 0.052672049211841598f, 1.0f}, -{0.57647058823529418f, 0.34348327566320647f, 0.058054594386774322f, 1.0f}, -{0.58431372549019611f, 0.35086505190311418f, 0.063437139561707045f, 1.0f}, -{0.59215686274509804f, 0.35824682814302189f, 0.068819684736639755f, 1.0f}, -{0.60000000000000009f, 0.3656286043829296f, 0.074202229911572465f, 1.0f}, -{0.60784313725490191f, 0.37301038062283731f, 0.079584775086505161f, 1.0f}, -{0.61568627450980395f, 0.38039215686274508f, 0.084967320261437912f, 1.0f}, -{0.62352941176470589f, 0.38777393310265279f, 0.090349865436370635f, 1.0f}, -{0.63137254901960782f, 0.3951557093425605f, 0.095732410611303345f, 1.0f}, -{0.63921568627450975f, 0.40253748558246821f, 0.10111495578623603f, 1.0f}, -{0.6470588235294118f, 0.40991926182237598f, 0.10649750096116878f, 1.0f}, -{0.65490196078431373f, 0.41730103806228369f, 0.1118800461361015f, 1.0f}, -{0.66274509803921566f, 0.42468281430219146f, 0.11726259131103423f, 1.0f}, -{0.6705882352941176f, 0.43206459054209911f, 0.12264513648596691f, 1.0f}, -{0.67843137254901964f, 0.43944636678200688f, 0.12802768166089967f, 1.0f}, -{0.68627450980392157f, 0.44682814302191465f, 0.13341022683583237f, 1.0f}, -{0.69411764705882351f, 0.45420991926182236f, 0.13879277201076509f, 1.0f}, -{0.70196078431372544f, 0.46159169550173007f, 0.14417531718569776f, 1.0f}, -{0.70980392156862748f, 0.46897347174163784f, 0.14955786236063054f, 1.0f}, -{0.71764705882352942f, 0.47635524798154555f, 0.15494040753556326f, 1.0f}, -{0.72549019607843135f, 0.48373702422145326f, 0.16032295271049596f, 1.0f}, -{0.73333333333333328f, 0.49111880046136092f, 0.16570549788542865f, 1.0f}, -{0.74117647058823533f, 0.49850057670126874f, 0.17108804306036141f, 1.0f}, -{0.74901960784313726f, 0.50588235294117645f, 0.17647058823529413f, 1.0f}, -{0.75394079200307573f, 0.51587850826605153f, 0.18877354863514034f, 1.0f}, -{0.75886197616301421f, 0.52587466359092649f, 0.20107650903498644f, 1.0f}, -{0.76378316032295268f, 0.53587081891580157f, 0.21337946943483274f, 1.0f}, -{0.76870434448289116f, 0.54586697424067665f, 0.22568242983467895f, 1.0f}, -{0.77362552864282963f, 0.55586312956555162f, 0.23798539023452514f, 1.0f}, -{0.7785467128027681f, 0.56585928489042658f, 0.25028835063437127f, 1.0f}, -{0.78346789696270669f, 0.57585544021530177f, 0.26259131103421757f, 1.0f}, -{0.78838908112264516f, 0.58585159554017674f, 0.27489427143406375f, 1.0f}, -{0.79331026528258364f, 0.59584775086505182f, 0.28719723183390999f, 1.0f}, -{0.798231449442522f, 0.60584390618992678f, 0.29950019223375612f, 1.0f}, -{0.80315263360246059f, 0.61584006151480186f, 0.31180315263360237f, 1.0f}, -{0.80807381776239906f, 0.62583621683967694f, 0.32410611303344861f, 1.0f}, -{0.81299500192233753f, 0.63583237216455202f, 0.33640907343329485f, 1.0f}, -{0.81791618608227601f, 0.6458285274894271f, 0.34871203383314103f, 1.0f}, -{0.82283737024221448f, 0.65582468281430195f, 0.36101499423298705f, 1.0f}, -{0.82775855440215296f, 0.66582083813917714f, 0.37331795463283346f, 1.0f}, -{0.83267973856209143f, 0.67581699346405211f, 0.38562091503267959f, 1.0f}, -{0.83760092272202991f, 0.68581314878892718f, 0.39792387543252583f, 1.0f}, -{0.84252210688196838f, 0.69580930411380226f, 0.41022683583237207f, 1.0f}, -{0.84744329104190697f, 0.70580545943867734f, 0.4225297962322182f, 1.0f}, -{0.85236447520184533f, 0.71580161476355231f, 0.43483275663206444f, 1.0f}, -{0.85728565936178391f, 0.72579777008842739f, 0.44713571703191068f, 1.0f}, -{0.86220684352172228f, 0.73579392541330224f, 0.4594386774317567f, 1.0f}, -{0.86712802768166086f, 0.74579008073817743f, 0.47174163783160306f, 1.0f}, -{0.87204921184159934f, 0.75578623606305251f, 0.4840445982314493f, 1.0f}, -{0.87627835447904645f, 0.76370626682045351f, 0.49557862360630511f, 1.0f}, -{0.87981545559400232f, 0.76955017301038053f, 0.5063437139561705f, 1.0f}, -{0.88335255670895807f, 0.77539407920030745f, 0.51710880430603601f, 1.0f}, -{0.88688965782391382f, 0.78123798539023437f, 0.5278738946559014f, 1.0f}, -{0.89042675893886958f, 0.7870818915801614f, 0.5386389850057669f, 1.0f}, -{0.89396386005382533f, 0.7929257977700882f, 0.54940407535563218f, 1.0f}, -{0.8975009611687812f, 0.79876970396001523f, 0.56016916570549768f, 1.0f}, -{0.90103806228373695f, 0.80461361014994226f, 0.57093425605536319f, 1.0f}, -{0.90457516339869282f, 0.81045751633986918f, 0.58169934640522869f, 1.0f}, -{0.90811226451364857f, 0.81630142252979621f, 0.59246443675509408f, 1.0f}, -{0.91164936562860432f, 0.82214532871972312f, 0.60322952710495947f, 1.0f}, -{0.91518646674356019f, 0.82798923490965004f, 0.61399461745482498f, 1.0f}, -{0.91872356785851594f, 0.83383314109957696f, 0.62475970780469037f, 1.0f}, -{0.9222606689734717f, 0.83967704728950388f, 0.63552479815455576f, 1.0f}, -{0.92579777008842756f, 0.8455209534794309f, 0.64628988850442126f, 1.0f}, -{0.92933487120338332f, 0.85136485966935793f, 0.65705497885428676f, 1.0f}, -{0.93287197231833907f, 0.85720876585928485f, 0.66782006920415216f, 1.0f}, -{0.93640907343329483f, 0.86305267204921177f, 0.67858515955401755f, 1.0f}, -{0.93994617454825069f, 0.86889657823913879f, 0.68935024990388305f, 1.0f}, -{0.94348327566320644f, 0.87474048442906571f, 0.70011534025374844f, 1.0f}, -{0.9470203767781622f, 0.88058439061899263f, 0.71088043060361394f, 1.0f}, -{0.95055747789311795f, 0.88642829680891955f, 0.72164552095347922f, 1.0f}, -{0.95409457900807382f, 0.89227220299884658f, 0.73241061130334484f, 1.0f}, -{0.95763168012302957f, 0.89811610918877349f, 0.74317570165321023f, 1.0f}, -{0.96116878123798544f, 0.90396001537870052f, 0.75394079200307562f, 1.0f}, -{0.96470588235294119f, 0.90980392156862744f, 0.76470588235294112f, 1.0f}, -{0.96455209534794306f, 0.91180315263360245f, 0.77239523260284504f, 1.0f}, -{0.96439830834294504f, 0.91380238369857747f, 0.78008458285274884f, 1.0f}, -{0.96424452133794691f, 0.91580161476355249f, 0.78777393310265276f, 1.0f}, -{0.9640907343329489f, 0.9178008458285275f, 0.79546328335255656f, 1.0f}, -{0.96393694732795077f, 0.91980007689350252f, 0.80315263360246059f, 1.0f}, -{0.96378316032295275f, 0.92179930795847753f, 0.81084198385236439f, 1.0f}, -{0.96362937331795462f, 0.92379853902345255f, 0.8185313341022683f, 1.0f}, -{0.9634755863129566f, 0.92579777008842756f, 0.82622068435217222f, 1.0f}, -{0.96332179930795847f, 0.92779700115340258f, 0.83391003460207613f, 1.0f}, -{0.96316801230296045f, 0.92979623221837759f, 0.84159938485198005f, 1.0f}, -{0.96301422529796232f, 0.93179546328335261f, 0.84928873510188385f, 1.0f}, -{0.9628604382929643f, 0.93379469434832751f, 0.85697808535178766f, 1.0f}, -{0.96270665128796618f, 0.93579392541330253f, 0.86466743560169168f, 1.0f}, -{0.96255286428296816f, 0.93779315647827755f, 0.87235678585159548f, 1.0f}, -{0.96239907727797003f, 0.93979238754325256f, 0.8800461361014994f, 1.0f}, -{0.96224529027297201f, 0.94179161860822758f, 0.88773548635140331f, 1.0f}, -{0.96209150326797388f, 0.94379084967320259f, 0.89542483660130712f, 1.0f}, -{0.96193771626297575f, 0.94579008073817761f, 0.90311418685121114f, 1.0f}, -{0.96178392925797773f, 0.94778931180315262f, 0.91080353710111495f, 1.0f}, -{0.9616301422529796f, 0.94978854286812764f, 0.91849288735101875f, 1.0f}, -{0.96147635524798158f, 0.95178777393310265f, 0.92618223760092278f, 1.0f}, -{0.96132256824298346f, 0.95378700499807767f, 0.93387158785082658f, 1.0f}, -{0.96116878123798544f, 0.95578623606305269f, 0.94156093810073049f, 1.0f}, -{0.96101499423298731f, 0.9577854671280277f, 0.94925028835063441f, 1.0f}, -{0.96086120722798929f, 0.95978469819300272f, 0.95693963860053821f, 1.0f}, -{0.95724721261053447f, 0.95993848519800085f, 0.95955401768550563f, 1.0f}, -{0.95017301038062285f, 0.95824682814302198f, 0.95709342560553634f, 1.0f}, -{0.94309880815071134f, 0.95655517108804311f, 0.95463283352556716f, 1.0f}, -{0.93602460592079972f, 0.95486351403306424f, 0.95217224144559787f, 1.0f}, -{0.92895040369088844f, 0.95317185697808537f, 0.94971164936562869f, 1.0f}, -{0.9218762014609766f, 0.95148019992310651f, 0.94725105728565939f, 1.0f}, -{0.91480199923106509f, 0.94978854286812764f, 0.94479046520569021f, 1.0f}, -{0.90772779700115347f, 0.94809688581314877f, 0.94232987312572092f, 1.0f}, -{0.90065359477124196f, 0.9464052287581699f, 0.93986928104575174f, 1.0f}, -{0.89357939254133034f, 0.94471357170319115f, 0.93740868896578244f, 1.0f}, -{0.88650519031141883f, 0.94302191464821228f, 0.93494809688581326f, 1.0f}, -{0.87943098808150721f, 0.94133025759323341f, 0.93248750480584397f, 1.0f}, -{0.87235678585159571f, 0.93963860053825454f, 0.93002691272587468f, 1.0f}, -{0.86528258362168409f, 0.93794694348327567f, 0.9275663206459055f, 1.0f}, -{0.85820838139177258f, 0.93625528642829681f, 0.9251057285659362f, 1.0f}, -{0.85113417916186096f, 0.93456362937331794f, 0.92264513648596702f, 1.0f}, -{0.84405997693194945f, 0.93287197231833907f, 0.92018454440599773f, 1.0f}, -{0.83698577470203783f, 0.93118031526336031f, 0.91772395232602855f, 1.0f}, -{0.82991157247212621f, 0.92948865820838145f, 0.91526336024605925f, 1.0f}, -{0.82283737024221471f, 0.92779700115340258f, 0.91280276816609007f, 1.0f}, -{0.81576316801230331f, 0.92610534409842371f, 0.91034217608612089f, 1.0f}, -{0.80868896578239158f, 0.92441368704344484f, 0.9078815840061516f, 1.0f}, -{0.80161476355247996f, 0.92272202998846597f, 0.90542099192618231f, 1.0f}, -{0.79454056132256845f, 0.92103037293348711f, 0.90296039984621312f, 1.0f}, -{0.78746635909265683f, 0.91933871587850824f, 0.90049980776624383f, 1.0f}, -{0.78039215686274532f, 0.91764705882352937f, 0.89803921568627465f, 1.0f}, -{0.76947327950788191f, 0.91318723567858529f, 0.89250288350634388f, 1.0f}, -{0.75855440215301839f, 0.90872741253364098f, 0.88696655132641311f, 1.0f}, -{0.74763552479815487f, 0.90426758938869678f, 0.88143021914648234f, 1.0f}, -{0.73671664744329135f, 0.89980776624375247f, 0.87589388696655146f, 1.0f}, -{0.72579777008842783f, 0.89534794309880827f, 0.87035755478662069f, 1.0f}, -{0.71487889273356431f, 0.89088811995386397f, 0.86482122260668992f, 1.0f}, -{0.70396001537870079f, 0.88642829680891977f, 0.85928489042675915f, 1.0f}, -{0.69304113802383727f, 0.88196847366397546f, 0.85374855824682827f, 1.0f}, -{0.68212226066897375f, 0.87750865051903126f, 0.8482122260668975f, 1.0f}, -{0.67120338331411022f, 0.87304882737408696f, 0.84267589388696673f, 1.0f}, -{0.66028450595924704f, 0.86858900422914287f, 0.83713956170703607f, 1.0f}, -{0.64936562860438318f, 0.86412918108419845f, 0.83160322952710508f, 1.0f}, -{0.63844675124951977f, 0.85966935793925425f, 0.82606689734717431f, 1.0f}, -{0.62752787389465614f, 0.85520953479431006f, 0.82053056516724354f, 1.0f}, -{0.61660899653979273f, 0.85074971164936575f, 0.81499423298731277f, 1.0f}, -{0.60569011918492921f, 0.84628988850442155f, 0.80945790080738189f, 1.0f}, -{0.59477124183006569f, 0.84183006535947724f, 0.80392156862745112f, 1.0f}, -{0.58385236447520217f, 0.83737024221453304f, 0.79838523644752035f, 1.0f}, -{0.57293348712033865f, 0.83291041906958874f, 0.79284890426758947f, 1.0f}, -{0.56201460976547513f, 0.82845059592464454f, 0.7873125720876587f, 1.0f}, -{0.55109573241061161f, 0.82399077277970023f, 0.78177623990772793f, 1.0f}, -{0.54017685505574808f, 0.81953094963475603f, 0.77623990772779716f, 1.0f}, -{0.52925797770088456f, 0.81507112648981173f, 0.77070357554786639f, 1.0f}, -{0.51833910034602104f, 0.81061130334486753f, 0.76516724336793551f, 1.0f}, -{0.50742022299115752f, 0.80615148019992322f, 0.75963091118800474f, 1.0f}, -{0.49619377162629791f, 0.79976931949250318f, 0.75301806997308751f, 1.0f}, -{0.48465974625144237f, 0.7914648212226072f, 0.74532871972318382f, 1.0f}, -{0.47312572087658622f, 0.78316032295271076f, 0.73763936947327968f, 1.0f}, -{0.4615916955017304f, 0.77485582468281455f, 0.72995001922337577f, 1.0f}, -{0.45005767012687453f, 0.76655132641291834f, 0.72226066897347185f, 1.0f}, -{0.43852364475201872f, 0.75824682814302213f, 0.71457131872356805f, 1.0f}, -{0.4269896193771629f, 0.74994232987312592f, 0.70688196847366414f, 1.0f}, -{0.41545559400230703f, 0.74163783160322971f, 0.69919261822376022f, 1.0f}, -{0.40392156862745121f, 0.7333333333333335f, 0.69150326797385631f, 1.0f}, -{0.39238754325259539f, 0.72502883506343729f, 0.68381391772395239f, 1.0f}, -{0.38085351787773952f, 0.71672433679354108f, 0.67612456747404859f, 1.0f}, -{0.36931949250288371f, 0.70841983852364487f, 0.66843521722414467f, 1.0f}, -{0.35778546712802783f, 0.70011534025374866f, 0.66074586697424076f, 1.0f}, -{0.34625144175317202f, 0.69181084198385245f, 0.65305651672433696f, 1.0f}, -{0.3347174163783162f, 0.68350634371395624f, 0.64536716647443304f, 1.0f}, -{0.32318339100346033f, 0.67520184544406003f, 0.63767781622452913f, 1.0f}, -{0.31164936562860451f, 0.66689734717416393f, 0.62998846597462521f, 1.0f}, -{0.30011534025374897f, 0.65859284890426795f, 0.62229911572472152f, 1.0f}, -{0.28858131487889283f, 0.65028835063437151f, 0.61460976547481749f, 1.0f}, -{0.27704728950403701f, 0.6419838523644753f, 0.60692041522491358f, 1.0f}, -{0.26551326412918119f, 0.63367935409457909f, 0.59923106497500966f, 1.0f}, -{0.25397923875432538f, 0.62537485582468288f, 0.59154171472510575f, 1.0f}, -{0.2424452133794695f, 0.61707035755478667f, 0.58385236447520183f, 1.0f}, -{0.23091118800461369f, 0.60876585928489046f, 0.57616301422529803f, 1.0f}, -{0.21937716262975787f, 0.60046136101499425f, 0.56847366397539412f, 1.0f}, -{0.207843137254902f, 0.59215686274509804f, 0.5607843137254902f, 1.0f}, -{0.19984621299500194f, 0.58462129950019226f, 0.55324875048058442f, 1.0f}, -{0.1918492887351019f, 0.57708573625528647f, 0.54571318723567863f, 1.0f}, -{0.18385236447520187f, 0.56955017301038058f, 0.53817762399077274f, 1.0f}, -{0.17585544021530181f, 0.56201460976547479f, 0.53064206074586695f, 1.0f}, -{0.16785851595540177f, 0.55447904652056901f, 0.52310649750096117f, 1.0f}, -{0.15986159169550174f, 0.54694348327566322f, 0.51557093425605538f, 1.0f}, -{0.1518646674356017f, 0.53940792003075744f, 0.50803537101114959f, 1.0f}, -{0.14386774317570189f, 0.53187235678585187f, 0.50049980776624392f, 1.0f}, -{0.13587081891580161f, 0.52433679354094576f, 0.49296424452133797f, 1.0f}, -{0.1278738946559016f, 0.51680123029603997f, 0.48542868127643213f, 1.0f}, -{0.11987697039600155f, 0.50926566705113419f, 0.47789311803152634f, 1.0f}, -{0.11188004613610152f, 0.5017301038062284f, 0.47035755478662056f, 1.0f}, -{0.10388312187620148f, 0.49419454056132261f, 0.46282199154171477f, 1.0f}, -{0.095886197616301419f, 0.48665897731641677f, 0.45528642829680893f, 1.0f}, -{0.087889273356401398f, 0.47912341407151099f, 0.44775086505190315f, 1.0f}, -{0.079892349096501364f, 0.47158785082660515f, 0.44021530180699731f, 1.0f}, -{0.071895424836601329f, 0.46405228758169936f, 0.43267973856209152f, 1.0f}, -{0.063898500576701267f, 0.45651672433679358f, 0.42514417531718574f, 1.0f}, -{0.055901576316801233f, 0.44898116109188774f, 0.41760861207227989f, 1.0f}, -{0.047904652056901198f, 0.44144559784698195f, 0.41007304882737411f, 1.0f}, -{0.039907727797001163f, 0.43391003460207611f, 0.40253748558246827f, 1.0f}, -{0.031910803537101129f, 0.42637447135717033f, 0.39500192233756248f, 1.0f}, -{0.023913879277201094f, 0.41883890811226454f, 0.3874663590926567f, 1.0f}, -{0.015916955017301282f, 0.41130334486735898f, 0.37993079584775113f, 1.0f}, -{0.0079200307574010254f, 0.40376778162245297f, 0.37239523260284513f, 1.0f}, -{0.0038446751249519417f, 0.39677047289504042f, 0.36509034986543637f, 1.0f}, -{0.0036908881199538639f, 0.39031141868512115f, 0.35801614763552481f, 1.0f}, -{0.0035371011149557862f, 0.38385236447520188f, 0.35094194540561324f, 1.0f}, -{0.0033833141099577084f, 0.37739331026528261f, 0.34386774317570168f, 1.0f}, -{0.0032295271049596307f, 0.37093425605536334f, 0.33679354094579012f, 1.0f}, -{0.0030757400999615533f, 0.36447520184544407f, 0.32971933871587855f, 1.0f}, -{0.0029219530949634756f, 0.35801614763552481f, 0.32264513648596693f, 1.0f}, -{0.0027681660899653978f, 0.35155709342560554f, 0.31557093425605537f, 1.0f}, -{0.0026143790849673205f, 0.34509803921568627f, 0.30849673202614381f, 1.0f}, -{0.0024605920799692423f, 0.338638985005767f, 0.30142252979623224f, 1.0f}, -{0.002306805074971165f, 0.33217993079584773f, 0.29434832756632068f, 1.0f}, -{0.0021530180699730873f, 0.32572087658592852f, 0.28727412533640906f, 1.0f}, -{0.0019992310649750095f, 0.31926182237600925f, 0.28019992310649749f, 1.0f}, -{0.0018454440599769317f, 0.31280276816608998f, 0.27312572087658593f, 1.0f}, -{0.0016916570549788588f, 0.30634371395617088f, 0.26605151864667453f, 1.0f}, -{0.0015378700499807767f, 0.29988465974625145f, 0.2589773164167628f, 1.0f}, -{0.0013840830449826989f, 0.29342560553633218f, 0.25190311418685118f, 1.0f}, -{0.0012302960399846212f, 0.28696655132641291f, 0.24482891195693965f, 1.0f}, -{0.0010765090349865438f, 0.2805074971164937f, 0.23775470972702809f, 1.0f}, -{0.00092272202998846609f, 0.27404844290657437f, 0.23068050749711649f, 1.0f}, -{0.00076893502499038834f, 0.26758938869665516f, 0.22360630526720493f, 1.0f}, -{0.00061514801999231058f, 0.26113033448673584f, 0.21653210303729334f, 1.0f}, -{0.00046136101499423326f, 0.25467128027681663f, 0.20945790080738177f, 1.0f}, -{0.00030757400999615551f, 0.24821222606689736f, 0.20238369857747021f, 1.0f}, -{0.00015378700499807775f, 0.24175317185697809f, 0.19530949634755862f, 1.0f}, -{0.0f, 0.23529411764705882f, 0.18823529411764706f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/diverging/BrBG.txt b/extern/tfn/colormaps/diverging/BrBG.txt deleted file mode 100644 index 2398c3d..0000000 --- a/extern/tfn/colormaps/diverging/BrBG.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.32941176470588235, 0.18823529411764706, 0.019607843137254902, 1.0) -(0.33802383698577471, 0.1933102652825836, 0.020376778162245292, 1.0) -(0.34663590926566706, 0.19838523644752018, 0.021145713187235678, 1.0) -(0.35524798154555942, 0.20346020761245676, 0.021914648212226065, 1.0) -(0.36386005382545172, 0.2085351787773933, 0.022683583237216455, 1.0) -(0.37247212610534408, 0.21361014994232985, 0.023452518262206842, 1.0) -(0.38108419838523644, 0.21868512110726643, 0.024221453287197232, 1.0) -(0.3896962706651288, 0.223760092272203, 0.024990388312187618, 1.0) -(0.39830834294502115, 0.22883506343713955, 0.025759323337178008, 1.0) -(0.40692041522491351, 0.23391003460207613, 0.026528258362168398, 1.0) -(0.41553248750480587, 0.23898500576701268, 0.027297193387158785, 1.0) -(0.42414455978469823, 0.24405997693194925, 0.028066128412149172, 1.0) -(0.43275663206459059, 0.2491349480968858, 0.028835063437139562, 1.0) -(0.44136870434448289, 0.25420991926182235, 0.029603998462129948, 1.0) -(0.4499807766243753, 0.25928489042675895, 0.030372933487120338, 1.0) -(0.45859284890426766, 0.2643598615916955, 0.031141868512110725, 1.0) -(0.46720492118415996, 0.26943483275663205, 0.031910803537101115, 1.0) -(0.47581699346405232, 0.2745098039215686, 0.032679738562091498, 1.0) -(0.48442906574394468, 0.2795847750865052, 0.033448673587081895, 1.0) -(0.49304113802383703, 0.28465974625144175, 0.034217608612072278, 1.0) -(0.50165321030372934, 0.2897347174163783, 0.034986543637062668, 1.0) -(0.51026528258362169, 0.29480968858131484, 0.035755478662053058, 1.0) -(0.51887735486351405, 0.29988465974625145, 0.036524413687043442, 1.0) -(0.52748942714340641, 0.304959630911188, 0.037293348712033832, 1.0) -(0.53610149942329877, 0.31003460207612454, 0.038062283737024222, 1.0) -(0.54471357170319112, 0.31510957324106115, 0.038831218762014605, 1.0) -(0.55294117647058827, 0.32133794694348328, 0.041906958861976165, 1.0) -(0.5607843137254902, 0.32871972318339099, 0.047289504036908882, 1.0) -(0.56862745098039225, 0.3361014994232987, 0.052672049211841598, 1.0) -(0.57647058823529418, 0.34348327566320647, 0.058054594386774322, 1.0) -(0.58431372549019611, 0.35086505190311418, 0.063437139561707045, 1.0) -(0.59215686274509804, 0.35824682814302189, 0.068819684736639755, 1.0) -(0.60000000000000009, 0.3656286043829296, 0.074202229911572465, 1.0) -(0.60784313725490191, 0.37301038062283731, 0.079584775086505161, 1.0) -(0.61568627450980395, 0.38039215686274508, 0.084967320261437912, 1.0) -(0.62352941176470589, 0.38777393310265279, 0.090349865436370635, 1.0) -(0.63137254901960782, 0.3951557093425605, 0.095732410611303345, 1.0) -(0.63921568627450975, 0.40253748558246821, 0.10111495578623603, 1.0) -(0.6470588235294118, 0.40991926182237598, 0.10649750096116878, 1.0) -(0.65490196078431373, 0.41730103806228369, 0.1118800461361015, 1.0) -(0.66274509803921566, 0.42468281430219146, 0.11726259131103423, 1.0) -(0.6705882352941176, 0.43206459054209911, 0.12264513648596691, 1.0) -(0.67843137254901964, 0.43944636678200688, 0.12802768166089967, 1.0) -(0.68627450980392157, 0.44682814302191465, 0.13341022683583237, 1.0) -(0.69411764705882351, 0.45420991926182236, 0.13879277201076509, 1.0) -(0.70196078431372544, 0.46159169550173007, 0.14417531718569776, 1.0) -(0.70980392156862748, 0.46897347174163784, 0.14955786236063054, 1.0) -(0.71764705882352942, 0.47635524798154555, 0.15494040753556326, 1.0) -(0.72549019607843135, 0.48373702422145326, 0.16032295271049596, 1.0) -(0.73333333333333328, 0.49111880046136092, 0.16570549788542865, 1.0) -(0.74117647058823533, 0.49850057670126874, 0.17108804306036141, 1.0) -(0.74901960784313726, 0.50588235294117645, 0.17647058823529413, 1.0) -(0.75394079200307573, 0.51587850826605153, 0.18877354863514034, 1.0) -(0.75886197616301421, 0.52587466359092649, 0.20107650903498644, 1.0) -(0.76378316032295268, 0.53587081891580157, 0.21337946943483274, 1.0) -(0.76870434448289116, 0.54586697424067665, 0.22568242983467895, 1.0) -(0.77362552864282963, 0.55586312956555162, 0.23798539023452514, 1.0) -(0.7785467128027681, 0.56585928489042658, 0.25028835063437127, 1.0) -(0.78346789696270669, 0.57585544021530177, 0.26259131103421757, 1.0) -(0.78838908112264516, 0.58585159554017674, 0.27489427143406375, 1.0) -(0.79331026528258364, 0.59584775086505182, 0.28719723183390999, 1.0) -(0.798231449442522, 0.60584390618992678, 0.29950019223375612, 1.0) -(0.80315263360246059, 0.61584006151480186, 0.31180315263360237, 1.0) -(0.80807381776239906, 0.62583621683967694, 0.32410611303344861, 1.0) -(0.81299500192233753, 0.63583237216455202, 0.33640907343329485, 1.0) -(0.81791618608227601, 0.6458285274894271, 0.34871203383314103, 1.0) -(0.82283737024221448, 0.65582468281430195, 0.36101499423298705, 1.0) -(0.82775855440215296, 0.66582083813917714, 0.37331795463283346, 1.0) -(0.83267973856209143, 0.67581699346405211, 0.38562091503267959, 1.0) -(0.83760092272202991, 0.68581314878892718, 0.39792387543252583, 1.0) -(0.84252210688196838, 0.69580930411380226, 0.41022683583237207, 1.0) -(0.84744329104190697, 0.70580545943867734, 0.4225297962322182, 1.0) -(0.85236447520184533, 0.71580161476355231, 0.43483275663206444, 1.0) -(0.85728565936178391, 0.72579777008842739, 0.44713571703191068, 1.0) -(0.86220684352172228, 0.73579392541330224, 0.4594386774317567, 1.0) -(0.86712802768166086, 0.74579008073817743, 0.47174163783160306, 1.0) -(0.87204921184159934, 0.75578623606305251, 0.4840445982314493, 1.0) -(0.87627835447904645, 0.76370626682045351, 0.49557862360630511, 1.0) -(0.87981545559400232, 0.76955017301038053, 0.5063437139561705, 1.0) -(0.88335255670895807, 0.77539407920030745, 0.51710880430603601, 1.0) -(0.88688965782391382, 0.78123798539023437, 0.5278738946559014, 1.0) -(0.89042675893886958, 0.7870818915801614, 0.5386389850057669, 1.0) -(0.89396386005382533, 0.7929257977700882, 0.54940407535563218, 1.0) -(0.8975009611687812, 0.79876970396001523, 0.56016916570549768, 1.0) -(0.90103806228373695, 0.80461361014994226, 0.57093425605536319, 1.0) -(0.90457516339869282, 0.81045751633986918, 0.58169934640522869, 1.0) -(0.90811226451364857, 0.81630142252979621, 0.59246443675509408, 1.0) -(0.91164936562860432, 0.82214532871972312, 0.60322952710495947, 1.0) -(0.91518646674356019, 0.82798923490965004, 0.61399461745482498, 1.0) -(0.91872356785851594, 0.83383314109957696, 0.62475970780469037, 1.0) -(0.9222606689734717, 0.83967704728950388, 0.63552479815455576, 1.0) -(0.92579777008842756, 0.8455209534794309, 0.64628988850442126, 1.0) -(0.92933487120338332, 0.85136485966935793, 0.65705497885428676, 1.0) -(0.93287197231833907, 0.85720876585928485, 0.66782006920415216, 1.0) -(0.93640907343329483, 0.86305267204921177, 0.67858515955401755, 1.0) -(0.93994617454825069, 0.86889657823913879, 0.68935024990388305, 1.0) -(0.94348327566320644, 0.87474048442906571, 0.70011534025374844, 1.0) -(0.9470203767781622, 0.88058439061899263, 0.71088043060361394, 1.0) -(0.95055747789311795, 0.88642829680891955, 0.72164552095347922, 1.0) -(0.95409457900807382, 0.89227220299884658, 0.73241061130334484, 1.0) -(0.95763168012302957, 0.89811610918877349, 0.74317570165321023, 1.0) -(0.96116878123798544, 0.90396001537870052, 0.75394079200307562, 1.0) -(0.96470588235294119, 0.90980392156862744, 0.76470588235294112, 1.0) -(0.96455209534794306, 0.91180315263360245, 0.77239523260284504, 1.0) -(0.96439830834294504, 0.91380238369857747, 0.78008458285274884, 1.0) -(0.96424452133794691, 0.91580161476355249, 0.78777393310265276, 1.0) -(0.9640907343329489, 0.9178008458285275, 0.79546328335255656, 1.0) -(0.96393694732795077, 0.91980007689350252, 0.80315263360246059, 1.0) -(0.96378316032295275, 0.92179930795847753, 0.81084198385236439, 1.0) -(0.96362937331795462, 0.92379853902345255, 0.8185313341022683, 1.0) -(0.9634755863129566, 0.92579777008842756, 0.82622068435217222, 1.0) -(0.96332179930795847, 0.92779700115340258, 0.83391003460207613, 1.0) -(0.96316801230296045, 0.92979623221837759, 0.84159938485198005, 1.0) -(0.96301422529796232, 0.93179546328335261, 0.84928873510188385, 1.0) -(0.9628604382929643, 0.93379469434832751, 0.85697808535178766, 1.0) -(0.96270665128796618, 0.93579392541330253, 0.86466743560169168, 1.0) -(0.96255286428296816, 0.93779315647827755, 0.87235678585159548, 1.0) -(0.96239907727797003, 0.93979238754325256, 0.8800461361014994, 1.0) -(0.96224529027297201, 0.94179161860822758, 0.88773548635140331, 1.0) -(0.96209150326797388, 0.94379084967320259, 0.89542483660130712, 1.0) -(0.96193771626297575, 0.94579008073817761, 0.90311418685121114, 1.0) -(0.96178392925797773, 0.94778931180315262, 0.91080353710111495, 1.0) -(0.9616301422529796, 0.94978854286812764, 0.91849288735101875, 1.0) -(0.96147635524798158, 0.95178777393310265, 0.92618223760092278, 1.0) -(0.96132256824298346, 0.95378700499807767, 0.93387158785082658, 1.0) -(0.96116878123798544, 0.95578623606305269, 0.94156093810073049, 1.0) -(0.96101499423298731, 0.9577854671280277, 0.94925028835063441, 1.0) -(0.96086120722798929, 0.95978469819300272, 0.95693963860053821, 1.0) -(0.95724721261053447, 0.95993848519800085, 0.95955401768550563, 1.0) -(0.95017301038062285, 0.95824682814302198, 0.95709342560553634, 1.0) -(0.94309880815071134, 0.95655517108804311, 0.95463283352556716, 1.0) -(0.93602460592079972, 0.95486351403306424, 0.95217224144559787, 1.0) -(0.92895040369088844, 0.95317185697808537, 0.94971164936562869, 1.0) -(0.9218762014609766, 0.95148019992310651, 0.94725105728565939, 1.0) -(0.91480199923106509, 0.94978854286812764, 0.94479046520569021, 1.0) -(0.90772779700115347, 0.94809688581314877, 0.94232987312572092, 1.0) -(0.90065359477124196, 0.9464052287581699, 0.93986928104575174, 1.0) -(0.89357939254133034, 0.94471357170319115, 0.93740868896578244, 1.0) -(0.88650519031141883, 0.94302191464821228, 0.93494809688581326, 1.0) -(0.87943098808150721, 0.94133025759323341, 0.93248750480584397, 1.0) -(0.87235678585159571, 0.93963860053825454, 0.93002691272587468, 1.0) -(0.86528258362168409, 0.93794694348327567, 0.9275663206459055, 1.0) -(0.85820838139177258, 0.93625528642829681, 0.9251057285659362, 1.0) -(0.85113417916186096, 0.93456362937331794, 0.92264513648596702, 1.0) -(0.84405997693194945, 0.93287197231833907, 0.92018454440599773, 1.0) -(0.83698577470203783, 0.93118031526336031, 0.91772395232602855, 1.0) -(0.82991157247212621, 0.92948865820838145, 0.91526336024605925, 1.0) -(0.82283737024221471, 0.92779700115340258, 0.91280276816609007, 1.0) -(0.81576316801230331, 0.92610534409842371, 0.91034217608612089, 1.0) -(0.80868896578239158, 0.92441368704344484, 0.9078815840061516, 1.0) -(0.80161476355247996, 0.92272202998846597, 0.90542099192618231, 1.0) -(0.79454056132256845, 0.92103037293348711, 0.90296039984621312, 1.0) -(0.78746635909265683, 0.91933871587850824, 0.90049980776624383, 1.0) -(0.78039215686274532, 0.91764705882352937, 0.89803921568627465, 1.0) -(0.76947327950788191, 0.91318723567858529, 0.89250288350634388, 1.0) -(0.75855440215301839, 0.90872741253364098, 0.88696655132641311, 1.0) -(0.74763552479815487, 0.90426758938869678, 0.88143021914648234, 1.0) -(0.73671664744329135, 0.89980776624375247, 0.87589388696655146, 1.0) -(0.72579777008842783, 0.89534794309880827, 0.87035755478662069, 1.0) -(0.71487889273356431, 0.89088811995386397, 0.86482122260668992, 1.0) -(0.70396001537870079, 0.88642829680891977, 0.85928489042675915, 1.0) -(0.69304113802383727, 0.88196847366397546, 0.85374855824682827, 1.0) -(0.68212226066897375, 0.87750865051903126, 0.8482122260668975, 1.0) -(0.67120338331411022, 0.87304882737408696, 0.84267589388696673, 1.0) -(0.66028450595924704, 0.86858900422914287, 0.83713956170703607, 1.0) -(0.64936562860438318, 0.86412918108419845, 0.83160322952710508, 1.0) -(0.63844675124951977, 0.85966935793925425, 0.82606689734717431, 1.0) -(0.62752787389465614, 0.85520953479431006, 0.82053056516724354, 1.0) -(0.61660899653979273, 0.85074971164936575, 0.81499423298731277, 1.0) -(0.60569011918492921, 0.84628988850442155, 0.80945790080738189, 1.0) -(0.59477124183006569, 0.84183006535947724, 0.80392156862745112, 1.0) -(0.58385236447520217, 0.83737024221453304, 0.79838523644752035, 1.0) -(0.57293348712033865, 0.83291041906958874, 0.79284890426758947, 1.0) -(0.56201460976547513, 0.82845059592464454, 0.7873125720876587, 1.0) -(0.55109573241061161, 0.82399077277970023, 0.78177623990772793, 1.0) -(0.54017685505574808, 0.81953094963475603, 0.77623990772779716, 1.0) -(0.52925797770088456, 0.81507112648981173, 0.77070357554786639, 1.0) -(0.51833910034602104, 0.81061130334486753, 0.76516724336793551, 1.0) -(0.50742022299115752, 0.80615148019992322, 0.75963091118800474, 1.0) -(0.49619377162629791, 0.79976931949250318, 0.75301806997308751, 1.0) -(0.48465974625144237, 0.7914648212226072, 0.74532871972318382, 1.0) -(0.47312572087658622, 0.78316032295271076, 0.73763936947327968, 1.0) -(0.4615916955017304, 0.77485582468281455, 0.72995001922337577, 1.0) -(0.45005767012687453, 0.76655132641291834, 0.72226066897347185, 1.0) -(0.43852364475201872, 0.75824682814302213, 0.71457131872356805, 1.0) -(0.4269896193771629, 0.74994232987312592, 0.70688196847366414, 1.0) -(0.41545559400230703, 0.74163783160322971, 0.69919261822376022, 1.0) -(0.40392156862745121, 0.7333333333333335, 0.69150326797385631, 1.0) -(0.39238754325259539, 0.72502883506343729, 0.68381391772395239, 1.0) -(0.38085351787773952, 0.71672433679354108, 0.67612456747404859, 1.0) -(0.36931949250288371, 0.70841983852364487, 0.66843521722414467, 1.0) -(0.35778546712802783, 0.70011534025374866, 0.66074586697424076, 1.0) -(0.34625144175317202, 0.69181084198385245, 0.65305651672433696, 1.0) -(0.3347174163783162, 0.68350634371395624, 0.64536716647443304, 1.0) -(0.32318339100346033, 0.67520184544406003, 0.63767781622452913, 1.0) -(0.31164936562860451, 0.66689734717416393, 0.62998846597462521, 1.0) -(0.30011534025374897, 0.65859284890426795, 0.62229911572472152, 1.0) -(0.28858131487889283, 0.65028835063437151, 0.61460976547481749, 1.0) -(0.27704728950403701, 0.6419838523644753, 0.60692041522491358, 1.0) -(0.26551326412918119, 0.63367935409457909, 0.59923106497500966, 1.0) -(0.25397923875432538, 0.62537485582468288, 0.59154171472510575, 1.0) -(0.2424452133794695, 0.61707035755478667, 0.58385236447520183, 1.0) -(0.23091118800461369, 0.60876585928489046, 0.57616301422529803, 1.0) -(0.21937716262975787, 0.60046136101499425, 0.56847366397539412, 1.0) -(0.207843137254902, 0.59215686274509804, 0.5607843137254902, 1.0) -(0.19984621299500194, 0.58462129950019226, 0.55324875048058442, 1.0) -(0.1918492887351019, 0.57708573625528647, 0.54571318723567863, 1.0) -(0.18385236447520187, 0.56955017301038058, 0.53817762399077274, 1.0) -(0.17585544021530181, 0.56201460976547479, 0.53064206074586695, 1.0) -(0.16785851595540177, 0.55447904652056901, 0.52310649750096117, 1.0) -(0.15986159169550174, 0.54694348327566322, 0.51557093425605538, 1.0) -(0.1518646674356017, 0.53940792003075744, 0.50803537101114959, 1.0) -(0.14386774317570189, 0.53187235678585187, 0.50049980776624392, 1.0) -(0.13587081891580161, 0.52433679354094576, 0.49296424452133797, 1.0) -(0.1278738946559016, 0.51680123029603997, 0.48542868127643213, 1.0) -(0.11987697039600155, 0.50926566705113419, 0.47789311803152634, 1.0) -(0.11188004613610152, 0.5017301038062284, 0.47035755478662056, 1.0) -(0.10388312187620148, 0.49419454056132261, 0.46282199154171477, 1.0) -(0.095886197616301419, 0.48665897731641677, 0.45528642829680893, 1.0) -(0.087889273356401398, 0.47912341407151099, 0.44775086505190315, 1.0) -(0.079892349096501364, 0.47158785082660515, 0.44021530180699731, 1.0) -(0.071895424836601329, 0.46405228758169936, 0.43267973856209152, 1.0) -(0.063898500576701267, 0.45651672433679358, 0.42514417531718574, 1.0) -(0.055901576316801233, 0.44898116109188774, 0.41760861207227989, 1.0) -(0.047904652056901198, 0.44144559784698195, 0.41007304882737411, 1.0) -(0.039907727797001163, 0.43391003460207611, 0.40253748558246827, 1.0) -(0.031910803537101129, 0.42637447135717033, 0.39500192233756248, 1.0) -(0.023913879277201094, 0.41883890811226454, 0.3874663590926567, 1.0) -(0.015916955017301282, 0.41130334486735898, 0.37993079584775113, 1.0) -(0.0079200307574010254, 0.40376778162245297, 0.37239523260284513, 1.0) -(0.0038446751249519417, 0.39677047289504042, 0.36509034986543637, 1.0) -(0.0036908881199538639, 0.39031141868512115, 0.35801614763552481, 1.0) -(0.0035371011149557862, 0.38385236447520188, 0.35094194540561324, 1.0) -(0.0033833141099577084, 0.37739331026528261, 0.34386774317570168, 1.0) -(0.0032295271049596307, 0.37093425605536334, 0.33679354094579012, 1.0) -(0.0030757400999615533, 0.36447520184544407, 0.32971933871587855, 1.0) -(0.0029219530949634756, 0.35801614763552481, 0.32264513648596693, 1.0) -(0.0027681660899653978, 0.35155709342560554, 0.31557093425605537, 1.0) -(0.0026143790849673205, 0.34509803921568627, 0.30849673202614381, 1.0) -(0.0024605920799692423, 0.338638985005767, 0.30142252979623224, 1.0) -(0.002306805074971165, 0.33217993079584773, 0.29434832756632068, 1.0) -(0.0021530180699730873, 0.32572087658592852, 0.28727412533640906, 1.0) -(0.0019992310649750095, 0.31926182237600925, 0.28019992310649749, 1.0) -(0.0018454440599769317, 0.31280276816608998, 0.27312572087658593, 1.0) -(0.0016916570549788588, 0.30634371395617088, 0.26605151864667453, 1.0) -(0.0015378700499807767, 0.29988465974625145, 0.2589773164167628, 1.0) -(0.0013840830449826989, 0.29342560553633218, 0.25190311418685118, 1.0) -(0.0012302960399846212, 0.28696655132641291, 0.24482891195693965, 1.0) -(0.0010765090349865438, 0.2805074971164937, 0.23775470972702809, 1.0) -(0.00092272202998846609, 0.27404844290657437, 0.23068050749711649, 1.0) -(0.00076893502499038834, 0.26758938869665516, 0.22360630526720493, 1.0) -(0.00061514801999231058, 0.26113033448673584, 0.21653210303729334, 1.0) -(0.00046136101499423326, 0.25467128027681663, 0.20945790080738177, 1.0) -(0.00030757400999615551, 0.24821222606689736, 0.20238369857747021, 1.0) -(0.00015378700499807775, 0.24175317185697809, 0.19530949634755862, 1.0) -(0.0, 0.23529411764705882, 0.18823529411764706, 1.0) diff --git a/extern/tfn/colormaps/diverging/PRGn.cpp b/extern/tfn/colormaps/diverging/PRGn.cpp deleted file mode 100644 index 91c00aa..0000000 --- a/extern/tfn/colormaps/diverging/PRGn.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_diverging_PRGn; -} -const std::vector colormap::data_diverging_PRGn = /* NOLINT(cert-err58-cpp) */ -{ -{0.25098039215686274f, 0.0f, 0.29411764705882354f, 1.0f}, -{0.25928489042675895f, 0.0064590542099192613f, 0.3027297193387159f, 1.0f}, -{0.26758938869665511f, 0.012918108419838523f, 0.31134179161860825f, 1.0f}, -{0.27589388696655132f, 0.019377162629757784f, 0.31995386389850056f, 1.0f}, -{0.28419838523644753f, 0.025836216839677045f, 0.32856593617839291f, 1.0f}, -{0.29250288350634374f, 0.032295271049596307f, 0.33717800845828527f, 1.0f}, -{0.30080738177623989f, 0.038754325259515568f, 0.34579008073817763f, 1.0f}, -{0.3091118800461361f, 0.045213379469434836f, 0.35440215301806999f, 1.0f}, -{0.31741637831603231f, 0.051672433679354091f, 0.36301422529796235f, 1.0f}, -{0.32572087658592852f, 0.058131487889273359f, 0.37162629757785465f, 1.0f}, -{0.33402537485582467f, 0.064590542099192613f, 0.38023836985774701f, 1.0f}, -{0.34232987312572088f, 0.071049596309111882f, 0.38885044213763936f, 1.0f}, -{0.35063437139561709f, 0.077508650519031136f, 0.39746251441753166f, 1.0f}, -{0.35893886966551325f, 0.08396770472895039f, 0.40607458669742402f, 1.0f}, -{0.36724336793540946f, 0.090426758938869672f, 0.41468665897731638f, 1.0f}, -{0.37554786620530567f, 0.096885813148788927f, 0.42329873125720874f, 1.0f}, -{0.38385236447520188f, 0.10334486735870818f, 0.4319108035371011f, 1.0f}, -{0.39215686274509803f, 0.10980392156862745f, 0.44052287581699345f, 1.0f}, -{0.40046136101499424f, 0.11626297577854672f, 0.44913494809688581f, 1.0f}, -{0.40876585928489045f, 0.12272202998846597f, 0.45774702037677817f, 1.0f}, -{0.41707035755478661f, 0.12918108419838523f, 0.46635909265667047f, 1.0f}, -{0.42537485582468282f, 0.13564013840830449f, 0.47497116493656277f, 1.0f}, -{0.43367935409457903f, 0.14209919261822376f, 0.48358323721645519f, 1.0f}, -{0.44198385236447524f, 0.14855824682814303f, 0.49219530949634749f, 1.0f}, -{0.45028835063437145f, 0.15501730103806227f, 0.50080738177623985f, 1.0f}, -{0.4585928489042676f, 0.16147635524798154f, 0.5094194540561322f, 1.0f}, -{0.46543637062668208f, 0.1700884275278739f, 0.51680123029603997f, 1.0f}, -{0.47081891580161478f, 0.18085351787773934f, 0.52295271049596304f, 1.0f}, -{0.47620146097654747f, 0.19161860822760476f, 0.5291041906958861f, 1.0f}, -{0.48158400615148023f, 0.20238369857747021f, 0.53525567089580928f, 1.0f}, -{0.48696655132641292f, 0.21314878892733563f, 0.54140715109573234f, 1.0f}, -{0.49234909650134567f, 0.22391387927720108f, 0.54755863129565552f, 1.0f}, -{0.49773164167627837f, 0.23467896962706652f, 0.55371011149557858f, 1.0f}, -{0.50311418685121101f, 0.24544405997693186f, 0.55986159169550165f, 1.0f}, -{0.50849673202614376f, 0.25620915032679736f, 0.56601307189542482f, 1.0f}, -{0.51387927720107651f, 0.26697424067666281f, 0.57216455209534789f, 1.0f}, -{0.51926182237600926f, 0.27773933102652826f, 0.57831603229527095f, 1.0f}, -{0.5246443675509419f, 0.28850442137639365f, 0.58446751249519402f, 1.0f}, -{0.53002691272587465f, 0.29926951172625915f, 0.5906189926951172f, 1.0f}, -{0.53540945790080741f, 0.31003460207612454f, 0.59677047289504026f, 1.0f}, -{0.54079200307574005f, 0.32079969242599005f, 0.60292195309496344f, 1.0f}, -{0.5461745482506728f, 0.33156478277585538f, 0.6090734332948865f, 1.0f}, -{0.55155709342560555f, 0.34232987312572088f, 0.61522491349480968f, 1.0f}, -{0.5569396386005383f, 0.35309496347558633f, 0.62137639369473274f, 1.0f}, -{0.56232218377547094f, 0.36386005382545172f, 0.62752787389465581f, 1.0f}, -{0.56770472895040358f, 0.37462514417531712f, 0.63367935409457887f, 1.0f}, -{0.57308727412533644f, 0.38539023452518262f, 0.63983083429450205f, 1.0f}, -{0.57846981930026908f, 0.39615532487504806f, 0.64598231449442522f, 1.0f}, -{0.58385236447520183f, 0.40692041522491351f, 0.65213379469434829f, 1.0f}, -{0.58923490965013448f, 0.4176855055747789f, 0.65828527489427135f, 1.0f}, -{0.59461745482506723f, 0.42845059592464441f, 0.66443675509419453f, 1.0f}, -{0.59999999999999998f, 0.4392156862745098f, 0.6705882352941176f, 1.0f}, -{0.60630526720492117f, 0.44736639753940793f, 0.67612456747404837f, 1.0f}, -{0.61261053440984226f, 0.45551710880430596f, 0.68166089965397914f, 1.0f}, -{0.61891580161476356f, 0.46366782006920415f, 0.68719723183391002f, 1.0f}, -{0.62522106881968464f, 0.47181853133410223f, 0.69273356401384079f, 1.0f}, -{0.63152633602460584f, 0.47996924259900037f, 0.69826989619377156f, 1.0f}, -{0.63783160322952703f, 0.48811995386389839f, 0.70380622837370233f, 1.0f}, -{0.64413687043444823f, 0.49627066512879658f, 0.70934256055363321f, 1.0f}, -{0.65044213763936942f, 0.50442137639369466f, 0.71487889273356398f, 1.0f}, -{0.65674740484429062f, 0.51257208765859286f, 0.72041522491349474f, 1.0f}, -{0.6630526720492117f, 0.52072279892349083f, 0.72595155709342551f, 1.0f}, -{0.66935793925413289f, 0.52887351018838902f, 0.73148788927335628f, 1.0f}, -{0.67566320645905409f, 0.53702422145328721f, 0.73702422145328716f, 1.0f}, -{0.68196847366397528f, 0.54517493271818529f, 0.74256055363321793f, 1.0f}, -{0.68827374086889648f, 0.55332564398308337f, 0.7480968858131487f, 1.0f}, -{0.69457900807381756f, 0.56147635524798134f, 0.75363321799307947f, 1.0f}, -{0.70088427527873887f, 0.56962706651287964f, 0.75916955017301035f, 1.0f}, -{0.70718954248366006f, 0.57777777777777772f, 0.76470588235294112f, 1.0f}, -{0.71349480968858126f, 0.5859284890426758f, 0.77024221453287189f, 1.0f}, -{0.71980007689350245f, 0.59407920030757388f, 0.77577854671280266f, 1.0f}, -{0.72610534409842353f, 0.60222991157247208f, 0.78131487889273354f, 1.0f}, -{0.73241061130334473f, 0.61038062283737016f, 0.78685121107266431f, 1.0f}, -{0.73871587850826592f, 0.61853133410226824f, 0.79238754325259508f, 1.0f}, -{0.74502114571318701f, 0.62668204536716621f, 0.79792387543252574f, 1.0f}, -{0.75132641291810831f, 0.63483275663206451f, 0.80346020761245662f, 1.0f}, -{0.75763168012302951f, 0.64298346789696259f, 0.8089965397923875f, 1.0f}, -{0.76362937331795455f, 0.65067281814686651f, 0.81368704344482889f, 1.0f}, -{0.76931949250288345f, 0.65790080738177614f, 0.8175317185697808f, 1.0f}, -{0.77500961168781224f, 0.66512879661668578f, 0.8213763936947327f, 1.0f}, -{0.78069973087274114f, 0.67235678585159553f, 0.82522106881968471f, 1.0f}, -{0.78638985005767004f, 0.67958477508650517f, 0.82906574394463661f, 1.0f}, -{0.79207996924259882f, 0.68681276432141469f, 0.83291041906958851f, 1.0f}, -{0.79777008842752783f, 0.69404075355632444f, 0.83675509419454053f, 1.0f}, -{0.80346020761245662f, 0.70126874279123408f, 0.84059976931949243f, 1.0f}, -{0.80915032679738552f, 0.70849673202614372f, 0.84444444444444444f, 1.0f}, -{0.81484044598231442f, 0.71572472126105346f, 0.84828911956939634f, 1.0f}, -{0.82053056516724332f, 0.7229527104959631f, 0.85213379469434825f, 1.0f}, -{0.82622068435217222f, 0.73018069973087274f, 0.85597846981930026f, 1.0f}, -{0.83191080353710101f, 0.73740868896578238f, 0.85982314494425216f, 1.0f}, -{0.83760092272202991f, 0.7446366782006919f, 0.86366782006920406f, 1.0f}, -{0.8432910419069588f, 0.75186466743560165f, 0.86751249519415607f, 1.0f}, -{0.8489811610918877f, 0.75909265667051129f, 0.87135717031910798f, 1.0f}, -{0.8546712802768166f, 0.76632064590542104f, 0.87520184544405999f, 1.0f}, -{0.86036139946174539f, 0.77354863514033068f, 0.87904652056901189f, 1.0f}, -{0.86605151864667429f, 0.78077662437524031f, 0.88289119569396379f, 1.0f}, -{0.87174163783160319f, 0.78800461361014995f, 0.88673587081891581f, 1.0f}, -{0.87743175701653209f, 0.79523260284505959f, 0.89058054594386771f, 1.0f}, -{0.88312187620146088f, 0.80246059207996923f, 0.89442522106881961f, 1.0f}, -{0.88881199538638977f, 0.80968858131487886f, 0.89826989619377162f, 1.0f}, -{0.89450211457131867f, 0.81691657054978861f, 0.90211457131872352f, 1.0f}, -{0.90019223375624757f, 0.82414455978469825f, 0.90595924644367554f, 1.0f}, -{0.90588235294117647f, 0.83137254901960789f, 0.90980392156862744f, 1.0f}, -{0.90834294502114576f, 0.83675509419454064f, 0.9121107266435986f, 1.0f}, -{0.91080353710111495f, 0.84213763936947328f, 0.91441753171856976f, 1.0f}, -{0.91326412918108424f, 0.84752018454440603f, 0.91672433679354093f, 1.0f}, -{0.91572472126105342f, 0.85290272971933867f, 0.91903114186851209f, 1.0f}, -{0.91818531334102271f, 0.85828527489427142f, 0.92133794694348325f, 1.0f}, -{0.92064590542099189f, 0.86366782006920417f, 0.92364475201845442f, 1.0f}, -{0.92310649750096119f, 0.86905036524413692f, 0.92595155709342558f, 1.0f}, -{0.92556708958093037f, 0.87443291041906956f, 0.92825836216839674f, 1.0f}, -{0.92802768166089966f, 0.87981545559400232f, 0.93056516724336791f, 1.0f}, -{0.93048827374086884f, 0.88519800076893507f, 0.93287197231833907f, 1.0f}, -{0.93294886582083814f, 0.89058054594386782f, 0.93517877739331023f, 1.0f}, -{0.93540945790080732f, 0.89596309111880035f, 0.9374855824682814f, 1.0f}, -{0.93787004998077661f, 0.90134563629373321f, 0.93979238754325256f, 1.0f}, -{0.9403306420607459f, 0.90672818146866596f, 0.94209919261822372f, 1.0f}, -{0.94279123414071508f, 0.9121107266435986f, 0.94440599769319489f, 1.0f}, -{0.94525182622068438f, 0.91749327181853135f, 0.94671280276816605f, 1.0f}, -{0.94771241830065356f, 0.9228758169934641f, 0.94901960784313721f, 1.0f}, -{0.95017301038062285f, 0.92825836216839674f, 0.95132641291810838f, 1.0f}, -{0.95263360246059203f, 0.9336409073433295f, 0.95363321799307954f, 1.0f}, -{0.95509419454056133f, 0.93902345251826214f, 0.9559400230680507f, 1.0f}, -{0.95755478662053051f, 0.94440599769319489f, 0.95824682814302187f, 1.0f}, -{0.9600153787004998f, 0.94978854286812764f, 0.96055363321799303f, 1.0f}, -{0.96247597078046909f, 0.95517108804306039f, 0.96286043829296419f, 1.0f}, -{0.96493656286043827f, 0.96055363321799314f, 0.96516724336793536f, 1.0f}, -{0.96739715494040757f, 0.96593617839292578f, 0.96747404844290652f, 1.0f}, -{0.96632064590542099f, 0.96808919646289893f, 0.96585928489042672f, 1.0f}, -{0.96170703575547867f, 0.96701268742791235f, 0.96032295271049595f, 1.0f}, -{0.95709342560553634f, 0.96593617839292578f, 0.95478662053056518f, 1.0f}, -{0.95247981545559401f, 0.96485966935793921f, 0.94925028835063441f, 1.0f}, -{0.9478662053056518f, 0.96378316032295275f, 0.94371395617070375f, 1.0f}, -{0.94325259515570936f, 0.96270665128796618f, 0.93817762399077276f, 1.0f}, -{0.93863898500576703f, 0.9616301422529796f, 0.93264129181084199f, 1.0f}, -{0.93402537485582471f, 0.96055363321799303f, 0.92710495963091122f, 1.0f}, -{0.92941176470588238f, 0.95947712418300657f, 0.92156862745098045f, 1.0f}, -{0.92479815455594006f, 0.95840061514802f, 0.91603229527104968f, 1.0f}, -{0.92018454440599773f, 0.95732410611303342f, 0.9104959630911188f, 1.0f}, -{0.9155709342560554f, 0.95624759707804696f, 0.90495963091118803f, 1.0f}, -{0.91095732410611308f, 0.95517108804306039f, 0.89942329873125726f, 1.0f}, -{0.90634371395617075f, 0.95409457900807382f, 0.89388696655132649f, 1.0f}, -{0.90173010380622842f, 0.95301806997308725f, 0.88835063437139572f, 1.0f}, -{0.8971164936562861f, 0.95194156093810078f, 0.88281430219146495f, 1.0f}, -{0.89250288350634377f, 0.95086505190311421f, 0.87727797001153407f, 1.0f}, -{0.88788927335640144f, 0.94978854286812764f, 0.8717416378316033f, 1.0f}, -{0.88327566320645912f, 0.94871203383314107f, 0.86620530565167253f, 1.0f}, -{0.87866205305651679f, 0.9476355247981546f, 0.86066897347174176f, 1.0f}, -{0.87404844290657457f, 0.94655901576316803f, 0.8551326412918111f, 1.0f}, -{0.86943483275663214f, 0.94548250672818146f, 0.84959630911188011f, 1.0f}, -{0.86482122260668981f, 0.94440599769319489f, 0.84405997693194934f, 1.0f}, -{0.86020761245674748f, 0.94332948865820843f, 0.83852364475201857f, 1.0f}, -{0.85559400230680516f, 0.94225297962322185f, 0.8329873125720878f, 1.0f}, -{0.85098039215686283f, 0.94117647058823528f, 0.82745098039215703f, 1.0f}, -{0.84313725490196101f, 0.93794694348327579f, 0.8196078431372551f, 1.0f}, -{0.83529411764705908f, 0.93471741637831607f, 0.81176470588235317f, 1.0f}, -{0.82745098039215703f, 0.93148788927335646f, 0.80392156862745112f, 1.0f}, -{0.8196078431372551f, 0.92825836216839686f, 0.79607843137254919f, 1.0f}, -{0.81176470588235317f, 0.92502883506343725f, 0.78823529411764726f, 1.0f}, -{0.80392156862745123f, 0.92179930795847753f, 0.78039215686274532f, 1.0f}, -{0.79607843137254919f, 0.91856978085351793f, 0.77254901960784328f, 1.0f}, -{0.78823529411764726f, 0.91534025374855832f, 0.76470588235294135f, 1.0f}, -{0.78039215686274532f, 0.91211072664359871f, 0.75686274509803941f, 1.0f}, -{0.77254901960784339f, 0.908881199538639f, 0.74901960784313748f, 1.0f}, -{0.76470588235294157f, 0.9056516724336795f, 0.74117647058823577f, 1.0f}, -{0.75686274509803941f, 0.90242214532871978f, 0.7333333333333335f, 1.0f}, -{0.74901960784313748f, 0.89919261822376018f, 0.72549019607843157f, 1.0f}, -{0.74117647058823555f, 0.89596309111880057f, 0.71764705882352964f, 1.0f}, -{0.7333333333333335f, 0.89273356401384085f, 0.70980392156862759f, 1.0f}, -{0.72549019607843157f, 0.88950403690888125f, 0.70196078431372566f, 1.0f}, -{0.71764705882352964f, 0.88627450980392164f, 0.69411764705882373f, 1.0f}, -{0.7098039215686277f, 0.88304498269896203f, 0.6862745098039218f, 1.0f}, -{0.70196078431372566f, 0.87981545559400232f, 0.67843137254901986f, 1.0f}, -{0.69411764705882373f, 0.87658592848904271f, 0.67058823529411782f, 1.0f}, -{0.6862745098039218f, 0.8733564013840831f, 0.66274509803921589f, 1.0f}, -{0.67843137254901986f, 0.8701268742791235f, 0.65490196078431395f, 1.0f}, -{0.67058823529411793f, 0.86689734717416378f, 0.64705882352941191f, 1.0f}, -{0.662745098039216f, 0.86366782006920417f, 0.63921568627450998f, 1.0f}, -{0.65490196078431395f, 0.86043829296424457f, 0.63137254901960804f, 1.0f}, -{0.64513648596693618f, 0.85536332179930807f, 0.62260668973471767f, 1.0f}, -{0.63344867358708257f, 0.84844290657439481f, 0.61291810841983907f, 1.0f}, -{0.62176086120722829f, 0.84152249134948109f, 0.60322952710495992f, 1.0f}, -{0.61007304882737434f, 0.8346020761245676f, 0.59354094579008099f, 1.0f}, -{0.59838523644752051f, 0.82768166089965411f, 0.58385236447520206f, 1.0f}, -{0.58669742406766656f, 0.82076124567474062f, 0.57416378316032313f, 1.0f}, -{0.57500961168781262f, 0.81384083044982714f, 0.5644752018454442f, 1.0f}, -{0.56332179930795867f, 0.80692041522491365f, 0.55478662053056538f, 1.0f}, -{0.55163398692810484f, 0.80000000000000004f, 0.54509803921568645f, 1.0f}, -{0.53994617454825089f, 0.79307958477508667f, 0.53540945790080752f, 1.0f}, -{0.52825836216839694f, 0.78615916955017306f, 0.52572087658592859f, 1.0f}, -{0.51657054978854311f, 0.77923875432525957f, 0.51603229527104977f, 1.0f}, -{0.50488273740868916f, 0.77231833910034609f, 0.50634371395617084f, 1.0f}, -{0.49319492502883522f, 0.7653979238754326f, 0.49665513264129191f, 1.0f}, -{0.48150711264898133f, 0.75847750865051911f, 0.48696655132641298f, 1.0f}, -{0.46981930026912738f, 0.75155709342560562f, 0.4772779700115341f, 1.0f}, -{0.45813148788927349f, 0.74463667820069213f, 0.46758938869665523f, 1.0f}, -{0.44644367550941988f, 0.73771626297577875f, 0.45790080738177658f, 1.0f}, -{0.43475586312956571f, 0.73079584775086515f, 0.44821222606689742f, 1.0f}, -{0.42306805074971177f, 0.72387543252595155f, 0.43852364475201849f, 1.0f}, -{0.41138023836985782f, 0.71695501730103817f, 0.42883506343713962f, 1.0f}, -{0.39969242599000393f, 0.71003460207612457f, 0.41914648212226069f, 1.0f}, -{0.38800461361014998f, 0.70311418685121108f, 0.40945790080738176f, 1.0f}, -{0.37631680123029609f, 0.69619377162629759f, 0.39976931949250288f, 1.0f}, -{0.3646289888504422f, 0.6892733564013841f, 0.39008073817762401f, 1.0f}, -{0.35294117647058826f, 0.68235294117647061f, 0.38039215686274508f, 1.0f}, -{0.34325259515570938f, 0.6740484429065744f, 0.37393310265282581f, 1.0f}, -{0.33356401384083045f, 0.66574394463667819f, 0.36747404844290654f, 1.0f}, -{0.32387543252595158f, 0.65743944636678198f, 0.36101499423298727f, 1.0f}, -{0.3141868512110727f, 0.64913494809688588f, 0.35455594002306806f, 1.0f}, -{0.30449826989619377f, 0.64083044982698967f, 0.34809688581314879f, 1.0f}, -{0.2948096885813149f, 0.63252595155709346f, 0.34163783160322952f, 1.0f}, -{0.28512110726643602f, 0.62422145328719725f, 0.33517877739331026f, 1.0f}, -{0.27543252595155737f, 0.61591695501730126f, 0.32871972318339115f, 1.0f}, -{0.26574394463667822f, 0.60761245674740483f, 0.32226066897347172f, 1.0f}, -{0.25605536332179935f, 0.59930795847750862f, 0.31580161476355251f, 1.0f}, -{0.24636678200692042f, 0.59100346020761241f, 0.30934256055363318f, 1.0f}, -{0.23667820069204154f, 0.58269896193771631f, 0.30288350634371397f, 1.0f}, -{0.22698961937716267f, 0.5743944636678201f, 0.2964244521337947f, 1.0f}, -{0.21730103806228374f, 0.56608996539792389f, 0.28996539792387543f, 1.0f}, -{0.20761245674740486f, 0.55778546712802768f, 0.28350634371395617f, 1.0f}, -{0.19792387543252596f, 0.54948096885813147f, 0.2770472895040369f, 1.0f}, -{0.18823529411764708f, 0.54117647058823537f, 0.27058823529411768f, 1.0f}, -{0.17854671280276818f, 0.53287197231833905f, 0.26412918108419836f, 1.0f}, -{0.16885813148788928f, 0.52456747404844295f, 0.25767012687427915f, 1.0f}, -{0.1591695501730104f, 0.51626297577854674f, 0.25121107266435988f, 1.0f}, -{0.1494809688581315f, 0.50795847750865053f, 0.24475201845444061f, 1.0f}, -{0.1397923875432526f, 0.49965397923875432f, 0.23829296424452134f, 1.0f}, -{0.13010380622837373f, 0.49134948096885811f, 0.23183391003460208f, 1.0f}, -{0.1204152249134951f, 0.48304498269896218f, 0.225374855824683f, 1.0f}, -{0.11072664359861595f, 0.47474048442906575f, 0.21891580161476357f, 1.0f}, -{0.10380622837370242f, 0.46658977316416761f, 0.21353325643983084f, 1.0f}, -{0.099653979238754326f, 0.4585928489042676f, 0.20922722029988466f, 1.0f}, -{0.095501730103806221f, 0.45059592464436754f, 0.20492118415993849f, 1.0f}, -{0.091349480968858129f, 0.44259900038446748f, 0.20061514801999231f, 1.0f}, -{0.087197231833910038f, 0.43460207612456747f, 0.19630911188004616f, 1.0f}, -{0.083044982698961933f, 0.42660515186466741f, 0.19200307574009998f, 1.0f}, -{0.078892733564013842f, 0.4186082276047674f, 0.1876970396001538f, 1.0f}, -{0.074740484429065737f, 0.41061130334486734f, 0.18339100346020762f, 1.0f}, -{0.070588235294117646f, 0.40261437908496733f, 0.17908496732026144f, 1.0f}, -{0.066435986159169541f, 0.39461745482506727f, 0.17477893118031526f, 1.0f}, -{0.062283737024221457f, 0.38662053056516721f, 0.17047289504036911f, 1.0f}, -{0.058131487889273352f, 0.3786236063052672f, 0.16616685890042293f, 1.0f}, -{0.053979238754325261f, 0.3706266820453672f, 0.16186082276047675f, 1.0f}, -{0.049826989619377163f, 0.36262975778546713f, 0.15755478662053057f, 1.0f}, -{0.045674740484429183f, 0.35463283352556729f, 0.15324875048058451f, 1.0f}, -{0.041522491349480967f, 0.34663590926566706f, 0.14894271434063822f, 1.0f}, -{0.037370242214532862f, 0.338638985005767f, 0.14463667820069204f, 1.0f}, -{0.033217993079584771f, 0.33064206074586699f, 0.14033064206074586f, 1.0f}, -{0.029065743944636679f, 0.32264513648596693f, 0.13602460592079968f, 1.0f}, -{0.024913494809688588f, 0.31464821222606687f, 0.13171856978085353f, 1.0f}, -{0.020761245674740483f, 0.30665128796616681f, 0.12741253364090732f, 1.0f}, -{0.016608996539792392f, 0.29865436370626686f, 0.12310649750096117f, 1.0f}, -{0.012456747404844287f, 0.29065743944636679f, 0.11880046136101499f, 1.0f}, -{0.0083044982698961961f, 0.28266051518646673f, 0.11449442522106883f, 1.0f}, -{0.0041522491349480911f, 0.27466359092656667f, 0.11018838908112265f, 1.0f}, -{0.0f, 0.26666666666666666f, 0.10588235294117647f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/diverging/PRGn.txt b/extern/tfn/colormaps/diverging/PRGn.txt deleted file mode 100644 index 391953c..0000000 --- a/extern/tfn/colormaps/diverging/PRGn.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.25098039215686274, 0.0, 0.29411764705882354, 1.0) -(0.25928489042675895, 0.0064590542099192613, 0.3027297193387159, 1.0) -(0.26758938869665511, 0.012918108419838523, 0.31134179161860825, 1.0) -(0.27589388696655132, 0.019377162629757784, 0.31995386389850056, 1.0) -(0.28419838523644753, 0.025836216839677045, 0.32856593617839291, 1.0) -(0.29250288350634374, 0.032295271049596307, 0.33717800845828527, 1.0) -(0.30080738177623989, 0.038754325259515568, 0.34579008073817763, 1.0) -(0.3091118800461361, 0.045213379469434836, 0.35440215301806999, 1.0) -(0.31741637831603231, 0.051672433679354091, 0.36301422529796235, 1.0) -(0.32572087658592852, 0.058131487889273359, 0.37162629757785465, 1.0) -(0.33402537485582467, 0.064590542099192613, 0.38023836985774701, 1.0) -(0.34232987312572088, 0.071049596309111882, 0.38885044213763936, 1.0) -(0.35063437139561709, 0.077508650519031136, 0.39746251441753166, 1.0) -(0.35893886966551325, 0.08396770472895039, 0.40607458669742402, 1.0) -(0.36724336793540946, 0.090426758938869672, 0.41468665897731638, 1.0) -(0.37554786620530567, 0.096885813148788927, 0.42329873125720874, 1.0) -(0.38385236447520188, 0.10334486735870818, 0.4319108035371011, 1.0) -(0.39215686274509803, 0.10980392156862745, 0.44052287581699345, 1.0) -(0.40046136101499424, 0.11626297577854672, 0.44913494809688581, 1.0) -(0.40876585928489045, 0.12272202998846597, 0.45774702037677817, 1.0) -(0.41707035755478661, 0.12918108419838523, 0.46635909265667047, 1.0) -(0.42537485582468282, 0.13564013840830449, 0.47497116493656277, 1.0) -(0.43367935409457903, 0.14209919261822376, 0.48358323721645519, 1.0) -(0.44198385236447524, 0.14855824682814303, 0.49219530949634749, 1.0) -(0.45028835063437145, 0.15501730103806227, 0.50080738177623985, 1.0) -(0.4585928489042676, 0.16147635524798154, 0.5094194540561322, 1.0) -(0.46543637062668208, 0.1700884275278739, 0.51680123029603997, 1.0) -(0.47081891580161478, 0.18085351787773934, 0.52295271049596304, 1.0) -(0.47620146097654747, 0.19161860822760476, 0.5291041906958861, 1.0) -(0.48158400615148023, 0.20238369857747021, 0.53525567089580928, 1.0) -(0.48696655132641292, 0.21314878892733563, 0.54140715109573234, 1.0) -(0.49234909650134567, 0.22391387927720108, 0.54755863129565552, 1.0) -(0.49773164167627837, 0.23467896962706652, 0.55371011149557858, 1.0) -(0.50311418685121101, 0.24544405997693186, 0.55986159169550165, 1.0) -(0.50849673202614376, 0.25620915032679736, 0.56601307189542482, 1.0) -(0.51387927720107651, 0.26697424067666281, 0.57216455209534789, 1.0) -(0.51926182237600926, 0.27773933102652826, 0.57831603229527095, 1.0) -(0.5246443675509419, 0.28850442137639365, 0.58446751249519402, 1.0) -(0.53002691272587465, 0.29926951172625915, 0.5906189926951172, 1.0) -(0.53540945790080741, 0.31003460207612454, 0.59677047289504026, 1.0) -(0.54079200307574005, 0.32079969242599005, 0.60292195309496344, 1.0) -(0.5461745482506728, 0.33156478277585538, 0.6090734332948865, 1.0) -(0.55155709342560555, 0.34232987312572088, 0.61522491349480968, 1.0) -(0.5569396386005383, 0.35309496347558633, 0.62137639369473274, 1.0) -(0.56232218377547094, 0.36386005382545172, 0.62752787389465581, 1.0) -(0.56770472895040358, 0.37462514417531712, 0.63367935409457887, 1.0) -(0.57308727412533644, 0.38539023452518262, 0.63983083429450205, 1.0) -(0.57846981930026908, 0.39615532487504806, 0.64598231449442522, 1.0) -(0.58385236447520183, 0.40692041522491351, 0.65213379469434829, 1.0) -(0.58923490965013448, 0.4176855055747789, 0.65828527489427135, 1.0) -(0.59461745482506723, 0.42845059592464441, 0.66443675509419453, 1.0) -(0.59999999999999998, 0.4392156862745098, 0.6705882352941176, 1.0) -(0.60630526720492117, 0.44736639753940793, 0.67612456747404837, 1.0) -(0.61261053440984226, 0.45551710880430596, 0.68166089965397914, 1.0) -(0.61891580161476356, 0.46366782006920415, 0.68719723183391002, 1.0) -(0.62522106881968464, 0.47181853133410223, 0.69273356401384079, 1.0) -(0.63152633602460584, 0.47996924259900037, 0.69826989619377156, 1.0) -(0.63783160322952703, 0.48811995386389839, 0.70380622837370233, 1.0) -(0.64413687043444823, 0.49627066512879658, 0.70934256055363321, 1.0) -(0.65044213763936942, 0.50442137639369466, 0.71487889273356398, 1.0) -(0.65674740484429062, 0.51257208765859286, 0.72041522491349474, 1.0) -(0.6630526720492117, 0.52072279892349083, 0.72595155709342551, 1.0) -(0.66935793925413289, 0.52887351018838902, 0.73148788927335628, 1.0) -(0.67566320645905409, 0.53702422145328721, 0.73702422145328716, 1.0) -(0.68196847366397528, 0.54517493271818529, 0.74256055363321793, 1.0) -(0.68827374086889648, 0.55332564398308337, 0.7480968858131487, 1.0) -(0.69457900807381756, 0.56147635524798134, 0.75363321799307947, 1.0) -(0.70088427527873887, 0.56962706651287964, 0.75916955017301035, 1.0) -(0.70718954248366006, 0.57777777777777772, 0.76470588235294112, 1.0) -(0.71349480968858126, 0.5859284890426758, 0.77024221453287189, 1.0) -(0.71980007689350245, 0.59407920030757388, 0.77577854671280266, 1.0) -(0.72610534409842353, 0.60222991157247208, 0.78131487889273354, 1.0) -(0.73241061130334473, 0.61038062283737016, 0.78685121107266431, 1.0) -(0.73871587850826592, 0.61853133410226824, 0.79238754325259508, 1.0) -(0.74502114571318701, 0.62668204536716621, 0.79792387543252574, 1.0) -(0.75132641291810831, 0.63483275663206451, 0.80346020761245662, 1.0) -(0.75763168012302951, 0.64298346789696259, 0.8089965397923875, 1.0) -(0.76362937331795455, 0.65067281814686651, 0.81368704344482889, 1.0) -(0.76931949250288345, 0.65790080738177614, 0.8175317185697808, 1.0) -(0.77500961168781224, 0.66512879661668578, 0.8213763936947327, 1.0) -(0.78069973087274114, 0.67235678585159553, 0.82522106881968471, 1.0) -(0.78638985005767004, 0.67958477508650517, 0.82906574394463661, 1.0) -(0.79207996924259882, 0.68681276432141469, 0.83291041906958851, 1.0) -(0.79777008842752783, 0.69404075355632444, 0.83675509419454053, 1.0) -(0.80346020761245662, 0.70126874279123408, 0.84059976931949243, 1.0) -(0.80915032679738552, 0.70849673202614372, 0.84444444444444444, 1.0) -(0.81484044598231442, 0.71572472126105346, 0.84828911956939634, 1.0) -(0.82053056516724332, 0.7229527104959631, 0.85213379469434825, 1.0) -(0.82622068435217222, 0.73018069973087274, 0.85597846981930026, 1.0) -(0.83191080353710101, 0.73740868896578238, 0.85982314494425216, 1.0) -(0.83760092272202991, 0.7446366782006919, 0.86366782006920406, 1.0) -(0.8432910419069588, 0.75186466743560165, 0.86751249519415607, 1.0) -(0.8489811610918877, 0.75909265667051129, 0.87135717031910798, 1.0) -(0.8546712802768166, 0.76632064590542104, 0.87520184544405999, 1.0) -(0.86036139946174539, 0.77354863514033068, 0.87904652056901189, 1.0) -(0.86605151864667429, 0.78077662437524031, 0.88289119569396379, 1.0) -(0.87174163783160319, 0.78800461361014995, 0.88673587081891581, 1.0) -(0.87743175701653209, 0.79523260284505959, 0.89058054594386771, 1.0) -(0.88312187620146088, 0.80246059207996923, 0.89442522106881961, 1.0) -(0.88881199538638977, 0.80968858131487886, 0.89826989619377162, 1.0) -(0.89450211457131867, 0.81691657054978861, 0.90211457131872352, 1.0) -(0.90019223375624757, 0.82414455978469825, 0.90595924644367554, 1.0) -(0.90588235294117647, 0.83137254901960789, 0.90980392156862744, 1.0) -(0.90834294502114576, 0.83675509419454064, 0.9121107266435986, 1.0) -(0.91080353710111495, 0.84213763936947328, 0.91441753171856976, 1.0) -(0.91326412918108424, 0.84752018454440603, 0.91672433679354093, 1.0) -(0.91572472126105342, 0.85290272971933867, 0.91903114186851209, 1.0) -(0.91818531334102271, 0.85828527489427142, 0.92133794694348325, 1.0) -(0.92064590542099189, 0.86366782006920417, 0.92364475201845442, 1.0) -(0.92310649750096119, 0.86905036524413692, 0.92595155709342558, 1.0) -(0.92556708958093037, 0.87443291041906956, 0.92825836216839674, 1.0) -(0.92802768166089966, 0.87981545559400232, 0.93056516724336791, 1.0) -(0.93048827374086884, 0.88519800076893507, 0.93287197231833907, 1.0) -(0.93294886582083814, 0.89058054594386782, 0.93517877739331023, 1.0) -(0.93540945790080732, 0.89596309111880035, 0.9374855824682814, 1.0) -(0.93787004998077661, 0.90134563629373321, 0.93979238754325256, 1.0) -(0.9403306420607459, 0.90672818146866596, 0.94209919261822372, 1.0) -(0.94279123414071508, 0.9121107266435986, 0.94440599769319489, 1.0) -(0.94525182622068438, 0.91749327181853135, 0.94671280276816605, 1.0) -(0.94771241830065356, 0.9228758169934641, 0.94901960784313721, 1.0) -(0.95017301038062285, 0.92825836216839674, 0.95132641291810838, 1.0) -(0.95263360246059203, 0.9336409073433295, 0.95363321799307954, 1.0) -(0.95509419454056133, 0.93902345251826214, 0.9559400230680507, 1.0) -(0.95755478662053051, 0.94440599769319489, 0.95824682814302187, 1.0) -(0.9600153787004998, 0.94978854286812764, 0.96055363321799303, 1.0) -(0.96247597078046909, 0.95517108804306039, 0.96286043829296419, 1.0) -(0.96493656286043827, 0.96055363321799314, 0.96516724336793536, 1.0) -(0.96739715494040757, 0.96593617839292578, 0.96747404844290652, 1.0) -(0.96632064590542099, 0.96808919646289893, 0.96585928489042672, 1.0) -(0.96170703575547867, 0.96701268742791235, 0.96032295271049595, 1.0) -(0.95709342560553634, 0.96593617839292578, 0.95478662053056518, 1.0) -(0.95247981545559401, 0.96485966935793921, 0.94925028835063441, 1.0) -(0.9478662053056518, 0.96378316032295275, 0.94371395617070375, 1.0) -(0.94325259515570936, 0.96270665128796618, 0.93817762399077276, 1.0) -(0.93863898500576703, 0.9616301422529796, 0.93264129181084199, 1.0) -(0.93402537485582471, 0.96055363321799303, 0.92710495963091122, 1.0) -(0.92941176470588238, 0.95947712418300657, 0.92156862745098045, 1.0) -(0.92479815455594006, 0.95840061514802, 0.91603229527104968, 1.0) -(0.92018454440599773, 0.95732410611303342, 0.9104959630911188, 1.0) -(0.9155709342560554, 0.95624759707804696, 0.90495963091118803, 1.0) -(0.91095732410611308, 0.95517108804306039, 0.89942329873125726, 1.0) -(0.90634371395617075, 0.95409457900807382, 0.89388696655132649, 1.0) -(0.90173010380622842, 0.95301806997308725, 0.88835063437139572, 1.0) -(0.8971164936562861, 0.95194156093810078, 0.88281430219146495, 1.0) -(0.89250288350634377, 0.95086505190311421, 0.87727797001153407, 1.0) -(0.88788927335640144, 0.94978854286812764, 0.8717416378316033, 1.0) -(0.88327566320645912, 0.94871203383314107, 0.86620530565167253, 1.0) -(0.87866205305651679, 0.9476355247981546, 0.86066897347174176, 1.0) -(0.87404844290657457, 0.94655901576316803, 0.8551326412918111, 1.0) -(0.86943483275663214, 0.94548250672818146, 0.84959630911188011, 1.0) -(0.86482122260668981, 0.94440599769319489, 0.84405997693194934, 1.0) -(0.86020761245674748, 0.94332948865820843, 0.83852364475201857, 1.0) -(0.85559400230680516, 0.94225297962322185, 0.8329873125720878, 1.0) -(0.85098039215686283, 0.94117647058823528, 0.82745098039215703, 1.0) -(0.84313725490196101, 0.93794694348327579, 0.8196078431372551, 1.0) -(0.83529411764705908, 0.93471741637831607, 0.81176470588235317, 1.0) -(0.82745098039215703, 0.93148788927335646, 0.80392156862745112, 1.0) -(0.8196078431372551, 0.92825836216839686, 0.79607843137254919, 1.0) -(0.81176470588235317, 0.92502883506343725, 0.78823529411764726, 1.0) -(0.80392156862745123, 0.92179930795847753, 0.78039215686274532, 1.0) -(0.79607843137254919, 0.91856978085351793, 0.77254901960784328, 1.0) -(0.78823529411764726, 0.91534025374855832, 0.76470588235294135, 1.0) -(0.78039215686274532, 0.91211072664359871, 0.75686274509803941, 1.0) -(0.77254901960784339, 0.908881199538639, 0.74901960784313748, 1.0) -(0.76470588235294157, 0.9056516724336795, 0.74117647058823577, 1.0) -(0.75686274509803941, 0.90242214532871978, 0.7333333333333335, 1.0) -(0.74901960784313748, 0.89919261822376018, 0.72549019607843157, 1.0) -(0.74117647058823555, 0.89596309111880057, 0.71764705882352964, 1.0) -(0.7333333333333335, 0.89273356401384085, 0.70980392156862759, 1.0) -(0.72549019607843157, 0.88950403690888125, 0.70196078431372566, 1.0) -(0.71764705882352964, 0.88627450980392164, 0.69411764705882373, 1.0) -(0.7098039215686277, 0.88304498269896203, 0.6862745098039218, 1.0) -(0.70196078431372566, 0.87981545559400232, 0.67843137254901986, 1.0) -(0.69411764705882373, 0.87658592848904271, 0.67058823529411782, 1.0) -(0.6862745098039218, 0.8733564013840831, 0.66274509803921589, 1.0) -(0.67843137254901986, 0.8701268742791235, 0.65490196078431395, 1.0) -(0.67058823529411793, 0.86689734717416378, 0.64705882352941191, 1.0) -(0.662745098039216, 0.86366782006920417, 0.63921568627450998, 1.0) -(0.65490196078431395, 0.86043829296424457, 0.63137254901960804, 1.0) -(0.64513648596693618, 0.85536332179930807, 0.62260668973471767, 1.0) -(0.63344867358708257, 0.84844290657439481, 0.61291810841983907, 1.0) -(0.62176086120722829, 0.84152249134948109, 0.60322952710495992, 1.0) -(0.61007304882737434, 0.8346020761245676, 0.59354094579008099, 1.0) -(0.59838523644752051, 0.82768166089965411, 0.58385236447520206, 1.0) -(0.58669742406766656, 0.82076124567474062, 0.57416378316032313, 1.0) -(0.57500961168781262, 0.81384083044982714, 0.5644752018454442, 1.0) -(0.56332179930795867, 0.80692041522491365, 0.55478662053056538, 1.0) -(0.55163398692810484, 0.80000000000000004, 0.54509803921568645, 1.0) -(0.53994617454825089, 0.79307958477508667, 0.53540945790080752, 1.0) -(0.52825836216839694, 0.78615916955017306, 0.52572087658592859, 1.0) -(0.51657054978854311, 0.77923875432525957, 0.51603229527104977, 1.0) -(0.50488273740868916, 0.77231833910034609, 0.50634371395617084, 1.0) -(0.49319492502883522, 0.7653979238754326, 0.49665513264129191, 1.0) -(0.48150711264898133, 0.75847750865051911, 0.48696655132641298, 1.0) -(0.46981930026912738, 0.75155709342560562, 0.4772779700115341, 1.0) -(0.45813148788927349, 0.74463667820069213, 0.46758938869665523, 1.0) -(0.44644367550941988, 0.73771626297577875, 0.45790080738177658, 1.0) -(0.43475586312956571, 0.73079584775086515, 0.44821222606689742, 1.0) -(0.42306805074971177, 0.72387543252595155, 0.43852364475201849, 1.0) -(0.41138023836985782, 0.71695501730103817, 0.42883506343713962, 1.0) -(0.39969242599000393, 0.71003460207612457, 0.41914648212226069, 1.0) -(0.38800461361014998, 0.70311418685121108, 0.40945790080738176, 1.0) -(0.37631680123029609, 0.69619377162629759, 0.39976931949250288, 1.0) -(0.3646289888504422, 0.6892733564013841, 0.39008073817762401, 1.0) -(0.35294117647058826, 0.68235294117647061, 0.38039215686274508, 1.0) -(0.34325259515570938, 0.6740484429065744, 0.37393310265282581, 1.0) -(0.33356401384083045, 0.66574394463667819, 0.36747404844290654, 1.0) -(0.32387543252595158, 0.65743944636678198, 0.36101499423298727, 1.0) -(0.3141868512110727, 0.64913494809688588, 0.35455594002306806, 1.0) -(0.30449826989619377, 0.64083044982698967, 0.34809688581314879, 1.0) -(0.2948096885813149, 0.63252595155709346, 0.34163783160322952, 1.0) -(0.28512110726643602, 0.62422145328719725, 0.33517877739331026, 1.0) -(0.27543252595155737, 0.61591695501730126, 0.32871972318339115, 1.0) -(0.26574394463667822, 0.60761245674740483, 0.32226066897347172, 1.0) -(0.25605536332179935, 0.59930795847750862, 0.31580161476355251, 1.0) -(0.24636678200692042, 0.59100346020761241, 0.30934256055363318, 1.0) -(0.23667820069204154, 0.58269896193771631, 0.30288350634371397, 1.0) -(0.22698961937716267, 0.5743944636678201, 0.2964244521337947, 1.0) -(0.21730103806228374, 0.56608996539792389, 0.28996539792387543, 1.0) -(0.20761245674740486, 0.55778546712802768, 0.28350634371395617, 1.0) -(0.19792387543252596, 0.54948096885813147, 0.2770472895040369, 1.0) -(0.18823529411764708, 0.54117647058823537, 0.27058823529411768, 1.0) -(0.17854671280276818, 0.53287197231833905, 0.26412918108419836, 1.0) -(0.16885813148788928, 0.52456747404844295, 0.25767012687427915, 1.0) -(0.1591695501730104, 0.51626297577854674, 0.25121107266435988, 1.0) -(0.1494809688581315, 0.50795847750865053, 0.24475201845444061, 1.0) -(0.1397923875432526, 0.49965397923875432, 0.23829296424452134, 1.0) -(0.13010380622837373, 0.49134948096885811, 0.23183391003460208, 1.0) -(0.1204152249134951, 0.48304498269896218, 0.225374855824683, 1.0) -(0.11072664359861595, 0.47474048442906575, 0.21891580161476357, 1.0) -(0.10380622837370242, 0.46658977316416761, 0.21353325643983084, 1.0) -(0.099653979238754326, 0.4585928489042676, 0.20922722029988466, 1.0) -(0.095501730103806221, 0.45059592464436754, 0.20492118415993849, 1.0) -(0.091349480968858129, 0.44259900038446748, 0.20061514801999231, 1.0) -(0.087197231833910038, 0.43460207612456747, 0.19630911188004616, 1.0) -(0.083044982698961933, 0.42660515186466741, 0.19200307574009998, 1.0) -(0.078892733564013842, 0.4186082276047674, 0.1876970396001538, 1.0) -(0.074740484429065737, 0.41061130334486734, 0.18339100346020762, 1.0) -(0.070588235294117646, 0.40261437908496733, 0.17908496732026144, 1.0) -(0.066435986159169541, 0.39461745482506727, 0.17477893118031526, 1.0) -(0.062283737024221457, 0.38662053056516721, 0.17047289504036911, 1.0) -(0.058131487889273352, 0.3786236063052672, 0.16616685890042293, 1.0) -(0.053979238754325261, 0.3706266820453672, 0.16186082276047675, 1.0) -(0.049826989619377163, 0.36262975778546713, 0.15755478662053057, 1.0) -(0.045674740484429183, 0.35463283352556729, 0.15324875048058451, 1.0) -(0.041522491349480967, 0.34663590926566706, 0.14894271434063822, 1.0) -(0.037370242214532862, 0.338638985005767, 0.14463667820069204, 1.0) -(0.033217993079584771, 0.33064206074586699, 0.14033064206074586, 1.0) -(0.029065743944636679, 0.32264513648596693, 0.13602460592079968, 1.0) -(0.024913494809688588, 0.31464821222606687, 0.13171856978085353, 1.0) -(0.020761245674740483, 0.30665128796616681, 0.12741253364090732, 1.0) -(0.016608996539792392, 0.29865436370626686, 0.12310649750096117, 1.0) -(0.012456747404844287, 0.29065743944636679, 0.11880046136101499, 1.0) -(0.0083044982698961961, 0.28266051518646673, 0.11449442522106883, 1.0) -(0.0041522491349480911, 0.27466359092656667, 0.11018838908112265, 1.0) -(0.0, 0.26666666666666666, 0.10588235294117647, 1.0) diff --git a/extern/tfn/colormaps/diverging/PiYG.cpp b/extern/tfn/colormaps/diverging/PiYG.cpp deleted file mode 100644 index a6b40e7..0000000 --- a/extern/tfn/colormaps/diverging/PiYG.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_diverging_PiYG; -} -const std::vector colormap::data_diverging_PiYG = /* NOLINT(cert-err58-cpp) */ -{ -{0.55686274509803924f, 0.0039215686274509803f, 0.32156862745098042f, 1.0f}, -{0.56532103037293346f, 0.0079200307574009993f, 0.32818146866589776f, 1.0f}, -{0.5737793156478278f, 0.011918492887351018f, 0.3347943098808151f, 1.0f}, -{0.58223760092272203f, 0.015916955017301039f, 0.34140715109573244f, 1.0f}, -{0.59069588619761637f, 0.019915417147251056f, 0.34801999231064978f, 1.0f}, -{0.5991541714725106f, 0.023913879277201077f, 0.35463283352556713f, 1.0f}, -{0.60761245674740483f, 0.027912341407151094f, 0.36124567474048441f, 1.0f}, -{0.61607074202229917f, 0.031910803537101115f, 0.36785851595540175f, 1.0f}, -{0.6245290272971934f, 0.035909265667051132f, 0.3744713571703191f, 1.0f}, -{0.63298731257208773f, 0.039907727797001157f, 0.38108419838523644f, 1.0f}, -{0.64144559784698196f, 0.043906189926951174f, 0.38769703960015378f, 1.0f}, -{0.64990388312187619f, 0.047904652056901191f, 0.39430988081507112f, 1.0f}, -{0.65836216839677053f, 0.051903114186851208f, 0.40092272202998847f, 1.0f}, -{0.66682045367166476f, 0.055901576316801226f, 0.40753556324490581f, 1.0f}, -{0.6752787389465591f, 0.059900038446751257f, 0.41414840445982315f, 1.0f}, -{0.68373702422145333f, 0.063898500576701267f, 0.42076124567474049f, 1.0f}, -{0.69219530949634756f, 0.067896962706651284f, 0.42737408688965783f, 1.0f}, -{0.70065359477124178f, 0.071895424836601302f, 0.43398692810457518f, 1.0f}, -{0.70911188004613612f, 0.075893886966551333f, 0.44059976931949252f, 1.0f}, -{0.71757016532103046f, 0.07989234909650135f, 0.44721261053440986f, 1.0f}, -{0.72602845059592469f, 0.083890811226451367f, 0.4538254517493272f, 1.0f}, -{0.73448673587081892f, 0.087889273356401384f, 0.46043829296424449f, 1.0f}, -{0.74294502114571326f, 0.091887735486351402f, 0.46705113417916189f, 1.0f}, -{0.75140330642060749f, 0.095886197616301419f, 0.47366397539407917f, 1.0f}, -{0.75986159169550183f, 0.099884659746251436f, 0.48027681660899652f, 1.0f}, -{0.76831987697039605f, 0.10388312187620145f, 0.48688965782391386f, 1.0f}, -{0.77447135717031912f, 0.11295655517108805f, 0.49396386005382542f, 1.0f}, -{0.77831603229527113f, 0.12710495963091117f, 0.50149942329873121f, 1.0f}, -{0.78216070742022303f, 0.14125336409073433f, 0.50903498654363699f, 1.0f}, -{0.78600538254517494f, 0.15540176855055748f, 0.51657054978854289f, 1.0f}, -{0.78985005767012695f, 0.16955017301038061f, 0.52410611303344867f, 1.0f}, -{0.79369473279507885f, 0.18369857747020377f, 0.53164167627835446f, 1.0f}, -{0.79753940792003075f, 0.19784698193002692f, 0.53917723952326024f, 1.0f}, -{0.80138408304498265f, 0.21199538638984994f, 0.54671280276816603f, 1.0f}, -{0.80522875816993467f, 0.22614379084967318f, 0.55424836601307192f, 1.0f}, -{0.80907343329488657f, 0.24029219530949636f, 0.56178392925797771f, 1.0f}, -{0.81291810841983858f, 0.25444059976931949f, 0.5693194925028835f, 1.0f}, -{0.81676278354479048f, 0.26858900422914256f, 0.57685505574778928f, 1.0f}, -{0.82060745866974238f, 0.2827374086889658f, 0.58439061899269507f, 1.0f}, -{0.8244521337946944f, 0.29688581314878892f, 0.59192618223760096f, 1.0f}, -{0.8282968089196463f, 0.31103421760861205f, 0.59946174548250675f, 1.0f}, -{0.8321414840445982f, 0.32518262206843512f, 0.60699730872741253f, 1.0f}, -{0.83598615916955021f, 0.33933102652825836f, 0.61453287197231832f, 1.0f}, -{0.83983083429450212f, 0.35347943098808149f, 0.6220684352172241f, 1.0f}, -{0.84367550941945413f, 0.36762783544790467f, 0.62960399846213f, 1.0f}, -{0.84752018454440603f, 0.38177623990772769f, 0.63713956170703567f, 1.0f}, -{0.85136485966935793f, 0.39592464436755098f, 0.64467512495194157f, 1.0f}, -{0.85520953479430994f, 0.41007304882737411f, 0.65221068819684735f, 1.0f}, -{0.85905420991926185f, 0.42422145328719724f, 0.65974625144175314f, 1.0f}, -{0.86289888504421375f, 0.43836985774702031f, 0.66728181468665893f, 1.0f}, -{0.86674356016916576f, 0.45251826220684355f, 0.67481737793156482f, 1.0f}, -{0.87058823529411766f, 0.46666666666666667f, 0.68235294117647061f, 1.0f}, -{0.87351018838908112f, 0.47635524798154555f, 0.68911956939638597f, 1.0f}, -{0.87643214148404458f, 0.48604382929642437f, 0.69588619761630133f, 1.0f}, -{0.87935409457900804f, 0.49573241061130335f, 0.7026528258362168f, 1.0f}, -{0.8822760476739715f, 0.50542099192618228f, 0.70941945405613227f, 1.0f}, -{0.88519800076893507f, 0.5151095732410611f, 0.71618608227604763f, 1.0f}, -{0.88811995386389853f, 0.52479815455593992f, 0.72295271049596299f, 1.0f}, -{0.89104190695886198f, 0.53448673587081885f, 0.72971933871587846f, 1.0f}, -{0.89396386005382544f, 0.54417531718569778f, 0.73648596693579393f, 1.0f}, -{0.8968858131487889f, 0.5538638985005766f, 0.74325259515570929f, 1.0f}, -{0.89980776624375236f, 0.56355247981545542f, 0.75001922337562466f, 1.0f}, -{0.90272971933871582f, 0.57324106113033446f, 0.75678585159554013f, 1.0f}, -{0.90565167243367928f, 0.58292964244521328f, 0.7635524798154556f, 1.0f}, -{0.90857362552864285f, 0.59261822376009221f, 0.77031910803537096f, 1.0f}, -{0.91149557862360631f, 0.60230680507497114f, 0.77708573625528632f, 1.0f}, -{0.91441753171856965f, 0.61199538638984985f, 0.78385236447520168f, 1.0f}, -{0.91733948481353322f, 0.62168396770472889f, 0.79061899269511715f, 1.0f}, -{0.92026143790849668f, 0.63137254901960782f, 0.79738562091503262f, 1.0f}, -{0.92318339100346014f, 0.64106113033448664f, 0.80415224913494798f, 1.0f}, -{0.9261053440984236f, 0.65074971164936557f, 0.81091887735486345f, 1.0f}, -{0.92902729719338706f, 0.66043829296424439f, 0.81768550557477881f, 1.0f}, -{0.93194925028835063f, 0.67012687427912332f, 0.82445213379469418f, 1.0f}, -{0.93487120338331409f, 0.67981545559400214f, 0.83121876201460965f, 1.0f}, -{0.93779315647827743f, 0.68950403690888096f, 0.8379853902345249f, 1.0f}, -{0.940715109573241f, 0.69919261822376f, 0.84475201845444048f, 1.0f}, -{0.94363706266820446f, 0.70888119953863882f, 0.85151864667435584f, 1.0f}, -{0.94602076124567469f, 0.71695501730103794f, 0.85651672433679349f, 1.0f}, -{0.94786620530565158f, 0.72341407151095727f, 0.8597462514417531f, 1.0f}, -{0.94971164936562857f, 0.72987312572087648f, 0.8629757785467127f, 1.0f}, -{0.95155709342560546f, 0.7363321799307958f, 0.86620530565167231f, 1.0f}, -{0.95340253748558246f, 0.74279123414071502f, 0.86943483275663203f, 1.0f}, -{0.95524798154555934f, 0.74925028835063423f, 0.87266435986159163f, 1.0f}, -{0.95709342560553634f, 0.75570934256055355f, 0.87589388696655124f, 1.0f}, -{0.95893886966551323f, 0.76216839677047288f, 0.87912341407151084f, 1.0f}, -{0.96078431372549022f, 0.76862745098039209f, 0.88235294117647056f, 1.0f}, -{0.96262975778546711f, 0.77508650519031141f, 0.88558246828143017f, 1.0f}, -{0.964475201845444f, 0.78154555940023063f, 0.88881199538638977f, 1.0f}, -{0.96632064590542099f, 0.78800461361014995f, 0.89204152249134938f, 1.0f}, -{0.96816608996539788f, 0.79446366782006916f, 0.8952710495963091f, 1.0f}, -{0.97001153402537477f, 0.80092272202998838f, 0.89850057670126871f, 1.0f}, -{0.97185697808535176f, 0.8073817762399077f, 0.90173010380622831f, 1.0f}, -{0.97370242214532876f, 0.81384083044982691f, 0.90495963091118792f, 1.0f}, -{0.97554786620530565f, 0.82029988465974624f, 0.90818915801614764f, 1.0f}, -{0.97739331026528253f, 0.82675893886966545f, 0.91141868512110724f, 1.0f}, -{0.97923875432525953f, 0.83321799307958477f, 0.91464821222606685f, 1.0f}, -{0.98108419838523642f, 0.83967704728950399f, 0.91787773933102645f, 1.0f}, -{0.98292964244521341f, 0.84613610149942331f, 0.92110726643598617f, 1.0f}, -{0.9847750865051903f, 0.85259515570934241f, 0.92433679354094578f, 1.0f}, -{0.9866205305651673f, 0.85905420991926185f, 0.92756632064590538f, 1.0f}, -{0.98846597462514418f, 0.86551326412918106f, 0.9307958477508651f, 1.0f}, -{0.99031141868512118f, 0.87197231833910038f, 0.93402537485582471f, 1.0f}, -{0.99215686274509807f, 0.8784313725490196f, 0.93725490196078431f, 1.0f}, -{0.99123414071510962f, 0.88196847366397535f, 0.93848519800076891f, 1.0f}, -{0.99031141868512118f, 0.88550557477893121f, 0.93971549404075361f, 1.0f}, -{0.98938869665513263f, 0.88904267589388697f, 0.9409457900807382f, 1.0f}, -{0.98846597462514418f, 0.89257977700884272f, 0.94217608612072279f, 1.0f}, -{0.98754325259515574f, 0.89611687812379848f, 0.94340638216070738f, 1.0f}, -{0.9866205305651673f, 0.89965397923875434f, 0.94463667820069208f, 1.0f}, -{0.98569780853517874f, 0.9031910803537101f, 0.94586697424067667f, 1.0f}, -{0.9847750865051903f, 0.90672818146866585f, 0.94709727028066126f, 1.0f}, -{0.98385236447520186f, 0.91026528258362172f, 0.94832756632064585f, 1.0f}, -{0.98292964244521341f, 0.91380238369857747f, 0.94955786236063056f, 1.0f}, -{0.98200692041522497f, 0.91733948481353322f, 0.95078815840061515f, 1.0f}, -{0.98108419838523653f, 0.92087658592848898f, 0.95201845444059974f, 1.0f}, -{0.98016147635524797f, 0.92441368704344484f, 0.95324875048058444f, 1.0f}, -{0.97923875432525953f, 0.9279507881584006f, 0.95447904652056903f, 1.0f}, -{0.97831603229527109f, 0.93148788927335635f, 0.95570934256055362f, 1.0f}, -{0.97739331026528264f, 0.93502499038831222f, 0.95693963860053821f, 1.0f}, -{0.97647058823529409f, 0.93856209150326797f, 0.95816993464052291f, 1.0f}, -{0.97554786620530565f, 0.94209919261822372f, 0.9594002306805075f, 1.0f}, -{0.9746251441753172f, 0.94563629373317959f, 0.9606305267204921f, 1.0f}, -{0.97370242214532876f, 0.94917339484813523f, 0.96186082276047669f, 1.0f}, -{0.97277970011534021f, 0.9527104959630911f, 0.96309111880046139f, 1.0f}, -{0.97185697808535176f, 0.95624759707804685f, 0.96432141484044598f, 1.0f}, -{0.97093425605536332f, 0.95978469819300272f, 0.96555171088043057f, 1.0f}, -{0.97001153402537488f, 0.96332179930795847f, 0.96678200692041527f, 1.0f}, -{0.96908881199538643f, 0.96685890042291422f, 0.96801230296039986f, 1.0f}, -{0.9673202614379085f, 0.96847366397539403f, 0.96562860438292963f, 1.0f}, -{0.96470588235294119f, 0.96816608996539788f, 0.95963091118800459f, 1.0f}, -{0.96209150326797388f, 0.96785851595540173f, 0.95363321799307965f, 1.0f}, -{0.95947712418300657f, 0.96755094194540558f, 0.9476355247981546f, 1.0f}, -{0.95686274509803926f, 0.96724336793540944f, 0.94163783160322978f, 1.0f}, -{0.95424836601307195f, 0.96693579392541329f, 0.93564013840830451f, 1.0f}, -{0.95163398692810464f, 0.96662821991541714f, 0.92964244521337946f, 1.0f}, -{0.94901960784313732f, 0.96632064590542099f, 0.92364475201845453f, 1.0f}, -{0.94640522875817001f, 0.96601307189542485f, 0.91764705882352948f, 1.0f}, -{0.9437908496732027f, 0.9657054978854287f, 0.91164936562860444f, 1.0f}, -{0.94117647058823528f, 0.96539792387543255f, 0.90565167243367939f, 1.0f}, -{0.93856209150326797f, 0.9650903498654364f, 0.89965397923875434f, 1.0f}, -{0.93594771241830066f, 0.96478277585544026f, 0.89365628604382941f, 1.0f}, -{0.93333333333333335f, 0.96447520184544411f, 0.88765859284890436f, 1.0f}, -{0.93071895424836604f, 0.96416762783544796f, 0.88166089965397931f, 1.0f}, -{0.92810457516339873f, 0.96386005382545181f, 0.87566320645905427f, 1.0f}, -{0.92549019607843142f, 0.96355247981545566f, 0.86966551326412933f, 1.0f}, -{0.9228758169934641f, 0.96324490580545952f, 0.86366782006920428f, 1.0f}, -{0.92026143790849679f, 0.96293733179546326f, 0.85767012687427924f, 1.0f}, -{0.91764705882352948f, 0.96262975778546711f, 0.85167243367935419f, 1.0f}, -{0.91503267973856228f, 0.96232218377547096f, 0.84567474048442937f, 1.0f}, -{0.91241830065359486f, 0.96201460976547482f, 0.8396770472895041f, 1.0f}, -{0.90980392156862755f, 0.96170703575547867f, 0.83367935409457916f, 1.0f}, -{0.90718954248366024f, 0.96139946174548252f, 0.82768166089965411f, 1.0f}, -{0.90457516339869293f, 0.96109188773548637f, 0.82168396770472907f, 1.0f}, -{0.90196078431372562f, 0.96078431372549022f, 0.81568627450980413f, 1.0f}, -{0.89488658208381411f, 0.95770857362552875f, 0.80430603613994645f, 1.0f}, -{0.8878123798539026f, 0.95463283352556716f, 0.79292579777008876f, 1.0f}, -{0.88073817762399098f, 0.95155709342560568f, 0.78154555940023096f, 1.0f}, -{0.87366397539407936f, 0.94848135332564409f, 0.77016532103037327f, 1.0f}, -{0.86658977316416785f, 0.94540561322568251f, 0.75878508266051548f, 1.0f}, -{0.85951557093425623f, 0.94232987312572103f, 0.74740484429065779f, 1.0f}, -{0.85244136870434473f, 0.93925413302575944f, 0.73602460592079999f, 1.0f}, -{0.84536716647443311f, 0.93617839292579785f, 0.7246443675509423f, 1.0f}, -{0.8382929642445216f, 0.93310265282583627f, 0.71326412918108451f, 1.0f}, -{0.83121876201460998f, 0.93002691272587479f, 0.70188389081122682f, 1.0f}, -{0.82414455978469858f, 0.92695117262591331f, 0.69050365244136935f, 1.0f}, -{0.81707035755478685f, 0.92387543252595161f, 0.67912341407151122f, 1.0f}, -{0.80999615532487523f, 0.92079969242599014f, 0.66774317570165354f, 1.0f}, -{0.80292195309496361f, 0.91772395232602855f, 0.65636293733179574f, 1.0f}, -{0.79584775086505211f, 0.91464821222606696f, 0.64498269896193805f, 1.0f}, -{0.78877354863514049f, 0.91157247212610537f, 0.63360246059208025f, 1.0f}, -{0.78169934640522898f, 0.90849673202614389f, 0.62222222222222257f, 1.0f}, -{0.77462514417531736f, 0.90542099192618231f, 0.61084198385236477f, 1.0f}, -{0.76755094194540585f, 0.90234525182622072f, 0.59946174548250708f, 1.0f}, -{0.76047673971549423f, 0.89926951172625924f, 0.58808150711264928f, 1.0f}, -{0.75340253748558261f, 0.89619377162629765f, 0.5767012687427916f, 1.0f}, -{0.7463283352556711f, 0.89311803152633606f, 0.5653210303729338f, 1.0f}, -{0.73925413302575949f, 0.89004229142637459f, 0.55394079200307611f, 1.0f}, -{0.73217993079584798f, 0.886966551326413f, 0.54256055363321831f, 1.0f}, -{0.72510572856593636f, 0.88389081122645141f, 0.53118031526336063f, 1.0f}, -{0.71718569780853536f, 0.87950788158400628f, 0.52018454440599804f, 1.0f}, -{0.70841983852364521f, 0.8738177623990776f, 0.50957324106113089f, 1.0f}, -{0.6996539792387545f, 0.86812764321414848f, 0.49896193771626324f, 1.0f}, -{0.69088811995386412f, 0.86243752402921969f, 0.48835063437139592f, 1.0f}, -{0.68212226066897363f, 0.85674740484429079f, 0.47773933102652855f, 1.0f}, -{0.67335640138408326f, 0.8510572856593619f, 0.46712802768166117f, 1.0f}, -{0.66459054209919277f, 0.845367166474433f, 0.4565167243367938f, 1.0f}, -{0.6558246828143024f, 0.8396770472895041f, 0.44590542099192643f, 1.0f}, -{0.64705882352941191f, 0.83398692810457531f, 0.43529411764705905f, 1.0f}, -{0.63829296424452153f, 0.82829680891964641f, 0.42468281430219168f, 1.0f}, -{0.62952710495963105f, 0.82260668973471751f, 0.41407151095732431f, 1.0f}, -{0.62076124567474067f, 0.81691657054978861f, 0.40346020761245693f, 1.0f}, -{0.61199538638985018f, 0.81122645136485971f, 0.39284890426758956f, 1.0f}, -{0.6032295271049597f, 0.80553633217993093f, 0.38223760092272219f, 1.0f}, -{0.59446366782006932f, 0.79984621299500203f, 0.37162629757785481f, 1.0f}, -{0.58569780853517883f, 0.79415609381007313f, 0.36101499423298744f, 1.0f}, -{0.57693194925028846f, 0.78846597462514423f, 0.35040369088812007f, 1.0f}, -{0.56816608996539819f, 0.78277585544021555f, 0.33979238754325297f, 1.0f}, -{0.55940023068050759f, 0.77708573625528654f, 0.32918108419838532f, 1.0f}, -{0.55063437139561711f, 0.77139561707035764f, 0.31856978085351795f, 1.0f}, -{0.54186851211072673f, 0.76570549788542874f, 0.30795847750865057f, 1.0f}, -{0.53310265282583624f, 0.76001537870049984f, 0.2973471741637832f, 1.0f}, -{0.52433679354094587f, 0.75432525951557095f, 0.28673587081891583f, 1.0f}, -{0.51557093425605538f, 0.74863514033064216f, 0.27612456747404845f, 1.0f}, -{0.506805074971165f, 0.74294502114571326f, 0.26551326412918108f, 1.0f}, -{0.49803921568627452f, 0.73725490196078436f, 0.25490196078431371f, 1.0f}, -{0.49034986543637066f, 0.73079584775086515f, 0.24998077662437523f, 1.0f}, -{0.48266051518646674f, 0.72433679354094582f, 0.24505959246443673f, 1.0f}, -{0.47497116493656288f, 0.71787773933102661f, 0.24013840830449826f, 1.0f}, -{0.46728181468665897f, 0.71141868512110729f, 0.23521722414455978f, 1.0f}, -{0.45959246443675511f, 0.70495963091118807f, 0.23029603998462128f, 1.0f}, -{0.4519031141868512f, 0.69850057670126875f, 0.22537485582468281f, 1.0f}, -{0.44421376393694734f, 0.69204152249134954f, 0.22045367166474433f, 1.0f}, -{0.43652441368704364f, 0.68558246828143043f, 0.21553248750480597f, 1.0f}, -{0.42883506343713956f, 0.679123414071511f, 0.21061130334486736f, 1.0f}, -{0.4211457131872357f, 0.67266435986159168f, 0.20569011918492885f, 1.0f}, -{0.41345636293733179f, 0.66620530565167246f, 0.20076893502499038f, 1.0f}, -{0.40576701268742787f, 0.65974625144175314f, 0.19584775086505191f, 1.0f}, -{0.39807766243752402f, 0.65328719723183393f, 0.19092656670511343f, 1.0f}, -{0.39038831218762016f, 0.6468281430219146f, 0.18600538254517493f, 1.0f}, -{0.38269896193771624f, 0.64036908881199539f, 0.18108419838523643f, 1.0f}, -{0.37500961168781238f, 0.63391003460207607f, 0.17616301422529795f, 1.0f}, -{0.36732026143790852f, 0.62745098039215685f, 0.17124183006535948f, 1.0f}, -{0.35963091118800461f, 0.62099192618223764f, 0.16632064590542101f, 1.0f}, -{0.35194156093810069f, 0.61453287197231832f, 0.1613994617454825f, 1.0f}, -{0.34425221068819684f, 0.60807381776239899f, 0.15647827758554403f, 1.0f}, -{0.33656286043829298f, 0.60161476355247978f, 0.15155709342560555f, 1.0f}, -{0.32887351018838906f, 0.59515570934256057f, 0.14663590926566705f, 1.0f}, -{0.32118415993848515f, 0.58869665513264124f, 0.14171472510572858f, 1.0f}, -{0.31349480968858151f, 0.58223760092272214f, 0.13679354094579022f, 1.0f}, -{0.30580545943867743f, 0.57577854671280271f, 0.13187235678585163f, 1.0f}, -{0.29903883121876201f, 0.56901191849288735f, 0.12879661668589004f, 1.0f}, -{0.29319492502883504f, 0.56193771626297573f, 0.12756632064590542f, 1.0f}, -{0.28735101883890812f, 0.55486351403306422f, 0.1263360246059208f, 1.0f}, -{0.28150711264898115f, 0.5477893118031526f, 0.12510572856593619f, 1.0f}, -{0.27566320645905418f, 0.54071510957324098f, 0.12387543252595157f, 1.0f}, -{0.26981930026912726f, 0.53364090734332947f, 0.12264513648596695f, 1.0f}, -{0.26397539407920029f, 0.52656670511341785f, 0.12141484044598233f, 1.0f}, -{0.25813148788927331f, 0.51949250288350635f, 0.1201845444059977f, 1.0f}, -{0.2522875816993464f, 0.51241830065359473f, 0.11895424836601308f, 1.0f}, -{0.24644367550941945f, 0.50534409842368322f, 0.11772395232602846f, 1.0f}, -{0.24059976931949251f, 0.4982698961937716f, 0.11649365628604384f, 1.0f}, -{0.23475586312956553f, 0.49119569396386004f, 0.11526336024605921f, 1.0f}, -{0.22891195693963862f, 0.48412149173394847f, 0.11403306420607459f, 1.0f}, -{0.22306805074971164f, 0.47704728950403691f, 0.11280276816608997f, 1.0f}, -{0.21722414455978487f, 0.46997308727412551f, 0.11157247212610538f, 1.0f}, -{0.21138023836985775f, 0.46289888504421373f, 0.11034217608612074f, 1.0f}, -{0.20553633217993078f, 0.45582468281430216f, 0.1091118800461361f, 1.0f}, -{0.19969242599000386f, 0.4487504805843906f, 0.10788158400615148f, 1.0f}, -{0.19384851980007689f, 0.44167627835447903f, 0.10665128796616687f, 1.0f}, -{0.18800461361014997f, 0.43460207612456747f, 0.10542099192618223f, 1.0f}, -{0.182160707420223f, 0.42752787389465585f, 0.10419069588619762f, 1.0f}, -{0.17631680123029606f, 0.42045367166474434f, 0.102960399846213f, 1.0f}, -{0.17047289504036911f, 0.41337946943483272f, 0.10173010380622838f, 1.0f}, -{0.16462898885044217f, 0.40630526720492122f, 0.10049980776624376f, 1.0f}, -{0.15878508266051519f, 0.3992310649750096f, 0.099269511726259127f, 1.0f}, -{0.15294117647058825f, 0.39215686274509803f, 0.098039215686274508f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/diverging/PiYG.txt b/extern/tfn/colormaps/diverging/PiYG.txt deleted file mode 100644 index 381333b..0000000 --- a/extern/tfn/colormaps/diverging/PiYG.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.55686274509803924, 0.0039215686274509803, 0.32156862745098042, 1.0) -(0.56532103037293346, 0.0079200307574009993, 0.32818146866589776, 1.0) -(0.5737793156478278, 0.011918492887351018, 0.3347943098808151, 1.0) -(0.58223760092272203, 0.015916955017301039, 0.34140715109573244, 1.0) -(0.59069588619761637, 0.019915417147251056, 0.34801999231064978, 1.0) -(0.5991541714725106, 0.023913879277201077, 0.35463283352556713, 1.0) -(0.60761245674740483, 0.027912341407151094, 0.36124567474048441, 1.0) -(0.61607074202229917, 0.031910803537101115, 0.36785851595540175, 1.0) -(0.6245290272971934, 0.035909265667051132, 0.3744713571703191, 1.0) -(0.63298731257208773, 0.039907727797001157, 0.38108419838523644, 1.0) -(0.64144559784698196, 0.043906189926951174, 0.38769703960015378, 1.0) -(0.64990388312187619, 0.047904652056901191, 0.39430988081507112, 1.0) -(0.65836216839677053, 0.051903114186851208, 0.40092272202998847, 1.0) -(0.66682045367166476, 0.055901576316801226, 0.40753556324490581, 1.0) -(0.6752787389465591, 0.059900038446751257, 0.41414840445982315, 1.0) -(0.68373702422145333, 0.063898500576701267, 0.42076124567474049, 1.0) -(0.69219530949634756, 0.067896962706651284, 0.42737408688965783, 1.0) -(0.70065359477124178, 0.071895424836601302, 0.43398692810457518, 1.0) -(0.70911188004613612, 0.075893886966551333, 0.44059976931949252, 1.0) -(0.71757016532103046, 0.07989234909650135, 0.44721261053440986, 1.0) -(0.72602845059592469, 0.083890811226451367, 0.4538254517493272, 1.0) -(0.73448673587081892, 0.087889273356401384, 0.46043829296424449, 1.0) -(0.74294502114571326, 0.091887735486351402, 0.46705113417916189, 1.0) -(0.75140330642060749, 0.095886197616301419, 0.47366397539407917, 1.0) -(0.75986159169550183, 0.099884659746251436, 0.48027681660899652, 1.0) -(0.76831987697039605, 0.10388312187620145, 0.48688965782391386, 1.0) -(0.77447135717031912, 0.11295655517108805, 0.49396386005382542, 1.0) -(0.77831603229527113, 0.12710495963091117, 0.50149942329873121, 1.0) -(0.78216070742022303, 0.14125336409073433, 0.50903498654363699, 1.0) -(0.78600538254517494, 0.15540176855055748, 0.51657054978854289, 1.0) -(0.78985005767012695, 0.16955017301038061, 0.52410611303344867, 1.0) -(0.79369473279507885, 0.18369857747020377, 0.53164167627835446, 1.0) -(0.79753940792003075, 0.19784698193002692, 0.53917723952326024, 1.0) -(0.80138408304498265, 0.21199538638984994, 0.54671280276816603, 1.0) -(0.80522875816993467, 0.22614379084967318, 0.55424836601307192, 1.0) -(0.80907343329488657, 0.24029219530949636, 0.56178392925797771, 1.0) -(0.81291810841983858, 0.25444059976931949, 0.5693194925028835, 1.0) -(0.81676278354479048, 0.26858900422914256, 0.57685505574778928, 1.0) -(0.82060745866974238, 0.2827374086889658, 0.58439061899269507, 1.0) -(0.8244521337946944, 0.29688581314878892, 0.59192618223760096, 1.0) -(0.8282968089196463, 0.31103421760861205, 0.59946174548250675, 1.0) -(0.8321414840445982, 0.32518262206843512, 0.60699730872741253, 1.0) -(0.83598615916955021, 0.33933102652825836, 0.61453287197231832, 1.0) -(0.83983083429450212, 0.35347943098808149, 0.6220684352172241, 1.0) -(0.84367550941945413, 0.36762783544790467, 0.62960399846213, 1.0) -(0.84752018454440603, 0.38177623990772769, 0.63713956170703567, 1.0) -(0.85136485966935793, 0.39592464436755098, 0.64467512495194157, 1.0) -(0.85520953479430994, 0.41007304882737411, 0.65221068819684735, 1.0) -(0.85905420991926185, 0.42422145328719724, 0.65974625144175314, 1.0) -(0.86289888504421375, 0.43836985774702031, 0.66728181468665893, 1.0) -(0.86674356016916576, 0.45251826220684355, 0.67481737793156482, 1.0) -(0.87058823529411766, 0.46666666666666667, 0.68235294117647061, 1.0) -(0.87351018838908112, 0.47635524798154555, 0.68911956939638597, 1.0) -(0.87643214148404458, 0.48604382929642437, 0.69588619761630133, 1.0) -(0.87935409457900804, 0.49573241061130335, 0.7026528258362168, 1.0) -(0.8822760476739715, 0.50542099192618228, 0.70941945405613227, 1.0) -(0.88519800076893507, 0.5151095732410611, 0.71618608227604763, 1.0) -(0.88811995386389853, 0.52479815455593992, 0.72295271049596299, 1.0) -(0.89104190695886198, 0.53448673587081885, 0.72971933871587846, 1.0) -(0.89396386005382544, 0.54417531718569778, 0.73648596693579393, 1.0) -(0.8968858131487889, 0.5538638985005766, 0.74325259515570929, 1.0) -(0.89980776624375236, 0.56355247981545542, 0.75001922337562466, 1.0) -(0.90272971933871582, 0.57324106113033446, 0.75678585159554013, 1.0) -(0.90565167243367928, 0.58292964244521328, 0.7635524798154556, 1.0) -(0.90857362552864285, 0.59261822376009221, 0.77031910803537096, 1.0) -(0.91149557862360631, 0.60230680507497114, 0.77708573625528632, 1.0) -(0.91441753171856965, 0.61199538638984985, 0.78385236447520168, 1.0) -(0.91733948481353322, 0.62168396770472889, 0.79061899269511715, 1.0) -(0.92026143790849668, 0.63137254901960782, 0.79738562091503262, 1.0) -(0.92318339100346014, 0.64106113033448664, 0.80415224913494798, 1.0) -(0.9261053440984236, 0.65074971164936557, 0.81091887735486345, 1.0) -(0.92902729719338706, 0.66043829296424439, 0.81768550557477881, 1.0) -(0.93194925028835063, 0.67012687427912332, 0.82445213379469418, 1.0) -(0.93487120338331409, 0.67981545559400214, 0.83121876201460965, 1.0) -(0.93779315647827743, 0.68950403690888096, 0.8379853902345249, 1.0) -(0.940715109573241, 0.69919261822376, 0.84475201845444048, 1.0) -(0.94363706266820446, 0.70888119953863882, 0.85151864667435584, 1.0) -(0.94602076124567469, 0.71695501730103794, 0.85651672433679349, 1.0) -(0.94786620530565158, 0.72341407151095727, 0.8597462514417531, 1.0) -(0.94971164936562857, 0.72987312572087648, 0.8629757785467127, 1.0) -(0.95155709342560546, 0.7363321799307958, 0.86620530565167231, 1.0) -(0.95340253748558246, 0.74279123414071502, 0.86943483275663203, 1.0) -(0.95524798154555934, 0.74925028835063423, 0.87266435986159163, 1.0) -(0.95709342560553634, 0.75570934256055355, 0.87589388696655124, 1.0) -(0.95893886966551323, 0.76216839677047288, 0.87912341407151084, 1.0) -(0.96078431372549022, 0.76862745098039209, 0.88235294117647056, 1.0) -(0.96262975778546711, 0.77508650519031141, 0.88558246828143017, 1.0) -(0.964475201845444, 0.78154555940023063, 0.88881199538638977, 1.0) -(0.96632064590542099, 0.78800461361014995, 0.89204152249134938, 1.0) -(0.96816608996539788, 0.79446366782006916, 0.8952710495963091, 1.0) -(0.97001153402537477, 0.80092272202998838, 0.89850057670126871, 1.0) -(0.97185697808535176, 0.8073817762399077, 0.90173010380622831, 1.0) -(0.97370242214532876, 0.81384083044982691, 0.90495963091118792, 1.0) -(0.97554786620530565, 0.82029988465974624, 0.90818915801614764, 1.0) -(0.97739331026528253, 0.82675893886966545, 0.91141868512110724, 1.0) -(0.97923875432525953, 0.83321799307958477, 0.91464821222606685, 1.0) -(0.98108419838523642, 0.83967704728950399, 0.91787773933102645, 1.0) -(0.98292964244521341, 0.84613610149942331, 0.92110726643598617, 1.0) -(0.9847750865051903, 0.85259515570934241, 0.92433679354094578, 1.0) -(0.9866205305651673, 0.85905420991926185, 0.92756632064590538, 1.0) -(0.98846597462514418, 0.86551326412918106, 0.9307958477508651, 1.0) -(0.99031141868512118, 0.87197231833910038, 0.93402537485582471, 1.0) -(0.99215686274509807, 0.8784313725490196, 0.93725490196078431, 1.0) -(0.99123414071510962, 0.88196847366397535, 0.93848519800076891, 1.0) -(0.99031141868512118, 0.88550557477893121, 0.93971549404075361, 1.0) -(0.98938869665513263, 0.88904267589388697, 0.9409457900807382, 1.0) -(0.98846597462514418, 0.89257977700884272, 0.94217608612072279, 1.0) -(0.98754325259515574, 0.89611687812379848, 0.94340638216070738, 1.0) -(0.9866205305651673, 0.89965397923875434, 0.94463667820069208, 1.0) -(0.98569780853517874, 0.9031910803537101, 0.94586697424067667, 1.0) -(0.9847750865051903, 0.90672818146866585, 0.94709727028066126, 1.0) -(0.98385236447520186, 0.91026528258362172, 0.94832756632064585, 1.0) -(0.98292964244521341, 0.91380238369857747, 0.94955786236063056, 1.0) -(0.98200692041522497, 0.91733948481353322, 0.95078815840061515, 1.0) -(0.98108419838523653, 0.92087658592848898, 0.95201845444059974, 1.0) -(0.98016147635524797, 0.92441368704344484, 0.95324875048058444, 1.0) -(0.97923875432525953, 0.9279507881584006, 0.95447904652056903, 1.0) -(0.97831603229527109, 0.93148788927335635, 0.95570934256055362, 1.0) -(0.97739331026528264, 0.93502499038831222, 0.95693963860053821, 1.0) -(0.97647058823529409, 0.93856209150326797, 0.95816993464052291, 1.0) -(0.97554786620530565, 0.94209919261822372, 0.9594002306805075, 1.0) -(0.9746251441753172, 0.94563629373317959, 0.9606305267204921, 1.0) -(0.97370242214532876, 0.94917339484813523, 0.96186082276047669, 1.0) -(0.97277970011534021, 0.9527104959630911, 0.96309111880046139, 1.0) -(0.97185697808535176, 0.95624759707804685, 0.96432141484044598, 1.0) -(0.97093425605536332, 0.95978469819300272, 0.96555171088043057, 1.0) -(0.97001153402537488, 0.96332179930795847, 0.96678200692041527, 1.0) -(0.96908881199538643, 0.96685890042291422, 0.96801230296039986, 1.0) -(0.9673202614379085, 0.96847366397539403, 0.96562860438292963, 1.0) -(0.96470588235294119, 0.96816608996539788, 0.95963091118800459, 1.0) -(0.96209150326797388, 0.96785851595540173, 0.95363321799307965, 1.0) -(0.95947712418300657, 0.96755094194540558, 0.9476355247981546, 1.0) -(0.95686274509803926, 0.96724336793540944, 0.94163783160322978, 1.0) -(0.95424836601307195, 0.96693579392541329, 0.93564013840830451, 1.0) -(0.95163398692810464, 0.96662821991541714, 0.92964244521337946, 1.0) -(0.94901960784313732, 0.96632064590542099, 0.92364475201845453, 1.0) -(0.94640522875817001, 0.96601307189542485, 0.91764705882352948, 1.0) -(0.9437908496732027, 0.9657054978854287, 0.91164936562860444, 1.0) -(0.94117647058823528, 0.96539792387543255, 0.90565167243367939, 1.0) -(0.93856209150326797, 0.9650903498654364, 0.89965397923875434, 1.0) -(0.93594771241830066, 0.96478277585544026, 0.89365628604382941, 1.0) -(0.93333333333333335, 0.96447520184544411, 0.88765859284890436, 1.0) -(0.93071895424836604, 0.96416762783544796, 0.88166089965397931, 1.0) -(0.92810457516339873, 0.96386005382545181, 0.87566320645905427, 1.0) -(0.92549019607843142, 0.96355247981545566, 0.86966551326412933, 1.0) -(0.9228758169934641, 0.96324490580545952, 0.86366782006920428, 1.0) -(0.92026143790849679, 0.96293733179546326, 0.85767012687427924, 1.0) -(0.91764705882352948, 0.96262975778546711, 0.85167243367935419, 1.0) -(0.91503267973856228, 0.96232218377547096, 0.84567474048442937, 1.0) -(0.91241830065359486, 0.96201460976547482, 0.8396770472895041, 1.0) -(0.90980392156862755, 0.96170703575547867, 0.83367935409457916, 1.0) -(0.90718954248366024, 0.96139946174548252, 0.82768166089965411, 1.0) -(0.90457516339869293, 0.96109188773548637, 0.82168396770472907, 1.0) -(0.90196078431372562, 0.96078431372549022, 0.81568627450980413, 1.0) -(0.89488658208381411, 0.95770857362552875, 0.80430603613994645, 1.0) -(0.8878123798539026, 0.95463283352556716, 0.79292579777008876, 1.0) -(0.88073817762399098, 0.95155709342560568, 0.78154555940023096, 1.0) -(0.87366397539407936, 0.94848135332564409, 0.77016532103037327, 1.0) -(0.86658977316416785, 0.94540561322568251, 0.75878508266051548, 1.0) -(0.85951557093425623, 0.94232987312572103, 0.74740484429065779, 1.0) -(0.85244136870434473, 0.93925413302575944, 0.73602460592079999, 1.0) -(0.84536716647443311, 0.93617839292579785, 0.7246443675509423, 1.0) -(0.8382929642445216, 0.93310265282583627, 0.71326412918108451, 1.0) -(0.83121876201460998, 0.93002691272587479, 0.70188389081122682, 1.0) -(0.82414455978469858, 0.92695117262591331, 0.69050365244136935, 1.0) -(0.81707035755478685, 0.92387543252595161, 0.67912341407151122, 1.0) -(0.80999615532487523, 0.92079969242599014, 0.66774317570165354, 1.0) -(0.80292195309496361, 0.91772395232602855, 0.65636293733179574, 1.0) -(0.79584775086505211, 0.91464821222606696, 0.64498269896193805, 1.0) -(0.78877354863514049, 0.91157247212610537, 0.63360246059208025, 1.0) -(0.78169934640522898, 0.90849673202614389, 0.62222222222222257, 1.0) -(0.77462514417531736, 0.90542099192618231, 0.61084198385236477, 1.0) -(0.76755094194540585, 0.90234525182622072, 0.59946174548250708, 1.0) -(0.76047673971549423, 0.89926951172625924, 0.58808150711264928, 1.0) -(0.75340253748558261, 0.89619377162629765, 0.5767012687427916, 1.0) -(0.7463283352556711, 0.89311803152633606, 0.5653210303729338, 1.0) -(0.73925413302575949, 0.89004229142637459, 0.55394079200307611, 1.0) -(0.73217993079584798, 0.886966551326413, 0.54256055363321831, 1.0) -(0.72510572856593636, 0.88389081122645141, 0.53118031526336063, 1.0) -(0.71718569780853536, 0.87950788158400628, 0.52018454440599804, 1.0) -(0.70841983852364521, 0.8738177623990776, 0.50957324106113089, 1.0) -(0.6996539792387545, 0.86812764321414848, 0.49896193771626324, 1.0) -(0.69088811995386412, 0.86243752402921969, 0.48835063437139592, 1.0) -(0.68212226066897363, 0.85674740484429079, 0.47773933102652855, 1.0) -(0.67335640138408326, 0.8510572856593619, 0.46712802768166117, 1.0) -(0.66459054209919277, 0.845367166474433, 0.4565167243367938, 1.0) -(0.6558246828143024, 0.8396770472895041, 0.44590542099192643, 1.0) -(0.64705882352941191, 0.83398692810457531, 0.43529411764705905, 1.0) -(0.63829296424452153, 0.82829680891964641, 0.42468281430219168, 1.0) -(0.62952710495963105, 0.82260668973471751, 0.41407151095732431, 1.0) -(0.62076124567474067, 0.81691657054978861, 0.40346020761245693, 1.0) -(0.61199538638985018, 0.81122645136485971, 0.39284890426758956, 1.0) -(0.6032295271049597, 0.80553633217993093, 0.38223760092272219, 1.0) -(0.59446366782006932, 0.79984621299500203, 0.37162629757785481, 1.0) -(0.58569780853517883, 0.79415609381007313, 0.36101499423298744, 1.0) -(0.57693194925028846, 0.78846597462514423, 0.35040369088812007, 1.0) -(0.56816608996539819, 0.78277585544021555, 0.33979238754325297, 1.0) -(0.55940023068050759, 0.77708573625528654, 0.32918108419838532, 1.0) -(0.55063437139561711, 0.77139561707035764, 0.31856978085351795, 1.0) -(0.54186851211072673, 0.76570549788542874, 0.30795847750865057, 1.0) -(0.53310265282583624, 0.76001537870049984, 0.2973471741637832, 1.0) -(0.52433679354094587, 0.75432525951557095, 0.28673587081891583, 1.0) -(0.51557093425605538, 0.74863514033064216, 0.27612456747404845, 1.0) -(0.506805074971165, 0.74294502114571326, 0.26551326412918108, 1.0) -(0.49803921568627452, 0.73725490196078436, 0.25490196078431371, 1.0) -(0.49034986543637066, 0.73079584775086515, 0.24998077662437523, 1.0) -(0.48266051518646674, 0.72433679354094582, 0.24505959246443673, 1.0) -(0.47497116493656288, 0.71787773933102661, 0.24013840830449826, 1.0) -(0.46728181468665897, 0.71141868512110729, 0.23521722414455978, 1.0) -(0.45959246443675511, 0.70495963091118807, 0.23029603998462128, 1.0) -(0.4519031141868512, 0.69850057670126875, 0.22537485582468281, 1.0) -(0.44421376393694734, 0.69204152249134954, 0.22045367166474433, 1.0) -(0.43652441368704364, 0.68558246828143043, 0.21553248750480597, 1.0) -(0.42883506343713956, 0.679123414071511, 0.21061130334486736, 1.0) -(0.4211457131872357, 0.67266435986159168, 0.20569011918492885, 1.0) -(0.41345636293733179, 0.66620530565167246, 0.20076893502499038, 1.0) -(0.40576701268742787, 0.65974625144175314, 0.19584775086505191, 1.0) -(0.39807766243752402, 0.65328719723183393, 0.19092656670511343, 1.0) -(0.39038831218762016, 0.6468281430219146, 0.18600538254517493, 1.0) -(0.38269896193771624, 0.64036908881199539, 0.18108419838523643, 1.0) -(0.37500961168781238, 0.63391003460207607, 0.17616301422529795, 1.0) -(0.36732026143790852, 0.62745098039215685, 0.17124183006535948, 1.0) -(0.35963091118800461, 0.62099192618223764, 0.16632064590542101, 1.0) -(0.35194156093810069, 0.61453287197231832, 0.1613994617454825, 1.0) -(0.34425221068819684, 0.60807381776239899, 0.15647827758554403, 1.0) -(0.33656286043829298, 0.60161476355247978, 0.15155709342560555, 1.0) -(0.32887351018838906, 0.59515570934256057, 0.14663590926566705, 1.0) -(0.32118415993848515, 0.58869665513264124, 0.14171472510572858, 1.0) -(0.31349480968858151, 0.58223760092272214, 0.13679354094579022, 1.0) -(0.30580545943867743, 0.57577854671280271, 0.13187235678585163, 1.0) -(0.29903883121876201, 0.56901191849288735, 0.12879661668589004, 1.0) -(0.29319492502883504, 0.56193771626297573, 0.12756632064590542, 1.0) -(0.28735101883890812, 0.55486351403306422, 0.1263360246059208, 1.0) -(0.28150711264898115, 0.5477893118031526, 0.12510572856593619, 1.0) -(0.27566320645905418, 0.54071510957324098, 0.12387543252595157, 1.0) -(0.26981930026912726, 0.53364090734332947, 0.12264513648596695, 1.0) -(0.26397539407920029, 0.52656670511341785, 0.12141484044598233, 1.0) -(0.25813148788927331, 0.51949250288350635, 0.1201845444059977, 1.0) -(0.2522875816993464, 0.51241830065359473, 0.11895424836601308, 1.0) -(0.24644367550941945, 0.50534409842368322, 0.11772395232602846, 1.0) -(0.24059976931949251, 0.4982698961937716, 0.11649365628604384, 1.0) -(0.23475586312956553, 0.49119569396386004, 0.11526336024605921, 1.0) -(0.22891195693963862, 0.48412149173394847, 0.11403306420607459, 1.0) -(0.22306805074971164, 0.47704728950403691, 0.11280276816608997, 1.0) -(0.21722414455978487, 0.46997308727412551, 0.11157247212610538, 1.0) -(0.21138023836985775, 0.46289888504421373, 0.11034217608612074, 1.0) -(0.20553633217993078, 0.45582468281430216, 0.1091118800461361, 1.0) -(0.19969242599000386, 0.4487504805843906, 0.10788158400615148, 1.0) -(0.19384851980007689, 0.44167627835447903, 0.10665128796616687, 1.0) -(0.18800461361014997, 0.43460207612456747, 0.10542099192618223, 1.0) -(0.182160707420223, 0.42752787389465585, 0.10419069588619762, 1.0) -(0.17631680123029606, 0.42045367166474434, 0.102960399846213, 1.0) -(0.17047289504036911, 0.41337946943483272, 0.10173010380622838, 1.0) -(0.16462898885044217, 0.40630526720492122, 0.10049980776624376, 1.0) -(0.15878508266051519, 0.3992310649750096, 0.099269511726259127, 1.0) -(0.15294117647058825, 0.39215686274509803, 0.098039215686274508, 1.0) diff --git a/extern/tfn/colormaps/diverging/PuOr.cpp b/extern/tfn/colormaps/diverging/PuOr.cpp deleted file mode 100644 index 060f25e..0000000 --- a/extern/tfn/colormaps/diverging/PuOr.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_diverging_PuOr; -} -const std::vector colormap::data_diverging_PuOr = /* NOLINT(cert-err58-cpp) */ -{ -{0.49803921568627452f, 0.23137254901960785f, 0.031372549019607843f, 1.0f}, -{0.50603613994617458f, 0.23583237216455211f, 0.031064975009611688f, 1.0f}, -{0.51403306420607464f, 0.24029219530949636f, 0.030757400999615533f, 1.0f}, -{0.52202998846597459f, 0.24475201845444061f, 0.030449826989619375f, 1.0f}, -{0.53002691272587465f, 0.24921184159938486f, 0.030142252979623221f, 1.0f}, -{0.53802383698577472f, 0.25367166474432912f, 0.029834678969627066f, 1.0f}, -{0.54602076124567478f, 0.25813148788927337f, 0.029527104959630911f, 1.0f}, -{0.55401768550557473f, 0.26259131103421762f, 0.029219530949634753f, 1.0f}, -{0.56201460976547479f, 0.26705113417916188f, 0.028911956939638599f, 1.0f}, -{0.57001153402537486f, 0.27151095732410613f, 0.028604382929642444f, 1.0f}, -{0.57800845828527492f, 0.27597078046905038f, 0.028296808919646289f, 1.0f}, -{0.58600538254517498f, 0.28043060361399463f, 0.027989234909650131f, 1.0f}, -{0.59400230680507493f, 0.28489042675893889f, 0.027681660899653977f, 1.0f}, -{0.60199923106497499f, 0.28935024990388314f, 0.027374086889657822f, 1.0f}, -{0.60999615532487506f, 0.29381007304882739f, 0.027066512879661664f, 1.0f}, -{0.61799307958477501f, 0.29826989619377164f, 0.026758938869665509f, 1.0f}, -{0.62599000384467507f, 0.3027297193387159f, 0.026451364859669355f, 1.0f}, -{0.63398692810457513f, 0.30718954248366015f, 0.0261437908496732f, 1.0f}, -{0.64198385236447519f, 0.3116493656286044f, 0.025836216839677045f, 1.0f}, -{0.64998077662437526f, 0.31610918877354865f, 0.025528642829680891f, 1.0f}, -{0.65797770088427521f, 0.32056901191849285f, 0.025221068819684733f, 1.0f}, -{0.66597462514417527f, 0.32502883506343716f, 0.024913494809688578f, 1.0f}, -{0.67397154940407533f, 0.32948865820838141f, 0.024605920799692423f, 1.0f}, -{0.68196847366397528f, 0.33394848135332567f, 0.024298346789696265f, 1.0f}, -{0.68996539792387535f, 0.33840830449826986f, 0.023990772779700111f, 1.0f}, -{0.69796232218377541f, 0.34286812764321417f, 0.023683198769703956f, 1.0f}, -{0.70542099192618224f, 0.34832756632064588f, 0.024605920799692423f, 1.0f}, -{0.71234140715109573f, 0.35478662053056514f, 0.026758938869665509f, 1.0f}, -{0.71926182237600922f, 0.36124567474048441f, 0.028911956939638599f, 1.0f}, -{0.72618223760092271f, 0.36770472895040368f, 0.031064975009611685f, 1.0f}, -{0.7331026528258362f, 0.37416378316032295f, 0.033217993079584771f, 1.0f}, -{0.74002306805074969f, 0.38062283737024222f, 0.03537101114955786f, 1.0f}, -{0.74694348327566318f, 0.38708189158016149f, 0.037524029219530942f, 1.0f}, -{0.75386389850057656f, 0.3935409457900807f, 0.039677047289504018f, 1.0f}, -{0.76078431372549016f, 0.39999999999999997f, 0.041830065359477114f, 1.0f}, -{0.76770472895040365f, 0.40645905420991923f, 0.043983083429450204f, 1.0f}, -{0.77462514417531714f, 0.4129181084198385f, 0.046136101499423293f, 1.0f}, -{0.78154555940023063f, 0.41937716262975772f, 0.048289119569396369f, 1.0f}, -{0.78846597462514412f, 0.42583621683967704f, 0.050442137639369472f, 1.0f}, -{0.79538638985005761f, 0.43229527104959631f, 0.052595155709342561f, 1.0f}, -{0.8023068050749711f, 0.43875432525951552f, 0.054748173779315644f, 1.0f}, -{0.80922722029988459f, 0.44521337946943473f, 0.056901191849288713f, 1.0f}, -{0.81614763552479808f, 0.45167243367935406f, 0.059054209919261816f, 1.0f}, -{0.82306805074971168f, 0.45813148788927333f, 0.061207227989234905f, 1.0f}, -{0.82998846597462506f, 0.46459054209919259f, 0.063360246059207995f, 1.0f}, -{0.83690888119953855f, 0.47104959630911181f, 0.06551326412918107f, 1.0f}, -{0.84382929642445215f, 0.47750865051903113f, 0.067666282199154174f, 1.0f}, -{0.85074971164936564f, 0.48396770472895034f, 0.069819300269127249f, 1.0f}, -{0.85767012687427913f, 0.49042675893886967f, 0.071972318339100338f, 1.0f}, -{0.86459054209919262f, 0.49688581314878888f, 0.074125336409073414f, 1.0f}, -{0.87151095732410611f, 0.5033448673587082f, 0.076278354479046517f, 1.0f}, -{0.8784313725490196f, 0.50980392156862742f, 0.078431372549019607f, 1.0f}, -{0.88289119569396379f, 0.51810841983852363f, 0.090580545943867732f, 1.0f}, -{0.8873510188389081f, 0.52641291810841973f, 0.10272971933871577f, 1.0f}, -{0.8918108419838523f, 0.53471741637831594f, 0.114878892733564f, 1.0f}, -{0.89627066512879661f, 0.54302191464821215f, 0.12702806612841211f, 1.0f}, -{0.9007304882737408f, 0.55132641291810836f, 0.13917723952326025f, 1.0f}, -{0.90519031141868511f, 0.55963091118800445f, 0.15132641291810828f, 1.0f}, -{0.90965013456362931f, 0.56793540945790078f, 0.1634755863129565f, 1.0f}, -{0.91410995770857362f, 0.57623990772779698f, 0.17562475970780464f, 1.0f}, -{0.91856978085351781f, 0.58454440599769308f, 0.18777393310265278f, 1.0f}, -{0.92302960399846212f, 0.59284890426758929f, 0.19992310649750081f, 1.0f}, -{0.92748942714340632f, 0.6011534025374855f, 0.21207227989234903f, 1.0f}, -{0.93194925028835063f, 0.60945790080738171f, 0.22422145328719714f, 1.0f}, -{0.93640907343329483f, 0.61776239907727792f, 0.23637062668204528f, 1.0f}, -{0.94086889657823913f, 0.62606689734717413f, 0.24851980007689342f, 1.0f}, -{0.94532871972318333f, 0.63437139561707012f, 0.26066897347174134f, 1.0f}, -{0.94978854286812764f, 0.64267589388696644f, 0.27281814686658967f, 1.0f}, -{0.95424836601307184f, 0.65098039215686265f, 0.28496732026143778f, 1.0f}, -{0.95870818915801614f, 0.65928489042675886f, 0.2971164936562859f, 1.0f}, -{0.96316801230296034f, 0.66758938869665507f, 0.30926566705113406f, 1.0f}, -{0.96762783544790465f, 0.67589388696655117f, 0.32141484044598218f, 1.0f}, -{0.97208765859284885f, 0.68419838523644738f, 0.33356401384083029f, 1.0f}, -{0.97654748173779315f, 0.69250288350634359f, 0.34571318723567845f, 1.0f}, -{0.98100730488273735f, 0.70080738177623969f, 0.3578623606305264f, 1.0f}, -{0.98546712802768166f, 0.70911188004613601f, 0.37001153402537468f, 1.0f}, -{0.98992695117262586f, 0.71741637831603211f, 0.38216070742022279f, 1.0f}, -{0.99223375624759713f, 0.72464436755094186f, 0.3946174548250671f, 1.0f}, -{0.99238754325259515f, 0.73079584775086492f, 0.40738177623990757f, 1.0f}, -{0.99254133025759328f, 0.7369473279507881f, 0.42014609765474803f, 1.0f}, -{0.9926951172625913f, 0.74309880815071117f, 0.43291041906958849f, 1.0f}, -{0.99284890426758943f, 0.74925028835063434f, 0.4456747404844289f, 1.0f}, -{0.99300269127258745f, 0.7554017685505573f, 0.4584390618992692f, 1.0f}, -{0.99315647827758557f, 0.76155324875048047f, 0.47120338331410982f, 1.0f}, -{0.99331026528258359f, 0.76770472895040365f, 0.48396770472895029f, 1.0f}, -{0.99346405228758172f, 0.77385620915032671f, 0.49673202614379075f, 1.0f}, -{0.99361783929257985f, 0.78000768935024989f, 0.50949634755863116f, 1.0f}, -{0.99377162629757787f, 0.78615916955017295f, 0.52226066897347168f, 1.0f}, -{0.993925413302576f, 0.79231064975009602f, 0.53502499038831208f, 1.0f}, -{0.99407920030757402f, 0.79846212995001919f, 0.54778931180315249f, 1.0f}, -{0.99423298731257215f, 0.80461361014994215f, 0.56055363321799279f, 1.0f}, -{0.99438677431757017f, 0.81076509034986532f, 0.57331795463283353f, 1.0f}, -{0.9945405613225683f, 0.8169165705497885f, 0.58608227604767393f, 1.0f}, -{0.99469434832756631f, 0.82306805074971157f, 0.59884659746251434f, 1.0f}, -{0.99484813533256444f, 0.82921953094963474f, 0.61161091887735486f, 1.0f}, -{0.99500192233756246f, 0.83537101114955781f, 0.62437524029219527f, 1.0f}, -{0.99515570934256059f, 0.84152249134948098f, 0.63713956170703567f, 1.0f}, -{0.99530949634755861f, 0.84767397154940405f, 0.64990388312187619f, 1.0f}, -{0.99546328335255674f, 0.85382545174932711f, 0.66266820453671649f, 1.0f}, -{0.99561707035755476f, 0.85997693194925029f, 0.67543252595155712f, 1.0f}, -{0.99577085736255289f, 0.86612841214917335f, 0.68819684736639752f, 1.0f}, -{0.9959246443675509f, 0.87227989234909653f, 0.70096116878123804f, 1.0f}, -{0.99607843137254903f, 0.8784313725490196f, 0.71372549019607845f, 1.0f}, -{0.99500192233756246f, 0.88196847366397535f, 0.72372164552095353f, 1.0f}, -{0.993925413302576f, 0.88550557477893121f, 0.73371780084582849f, 1.0f}, -{0.99284890426758943f, 0.88904267589388697f, 0.74371395617070357f, 1.0f}, -{0.99177239523260285f, 0.89257977700884272f, 0.75371011149557854f, 1.0f}, -{0.99069588619761628f, 0.89611687812379848f, 0.76370626682045373f, 1.0f}, -{0.98961937716262982f, 0.89965397923875434f, 0.77370242214532869f, 1.0f}, -{0.98854286812764325f, 0.9031910803537101f, 0.78369857747020377f, 1.0f}, -{0.98746635909265668f, 0.90672818146866585f, 0.79369473279507885f, 1.0f}, -{0.9863898500576701f, 0.91026528258362172f, 0.80369088811995393f, 1.0f}, -{0.98531334102268364f, 0.91380238369857747f, 0.81368704344482889f, 1.0f}, -{0.98423683198769707f, 0.91733948481353322f, 0.82368319876970397f, 1.0f}, -{0.9831603229527105f, 0.92087658592848898f, 0.83367935409457883f, 1.0f}, -{0.98208381391772392f, 0.92441368704344484f, 0.84367550941945402f, 1.0f}, -{0.98100730488273746f, 0.9279507881584006f, 0.8536716647443291f, 1.0f}, -{0.97993079584775089f, 0.93148788927335635f, 0.86366782006920417f, 1.0f}, -{0.97885428681276432f, 0.93502499038831222f, 0.87366397539407914f, 1.0f}, -{0.97777777777777775f, 0.93856209150326797f, 0.88366013071895422f, 1.0f}, -{0.97670126874279128f, 0.94209919261822372f, 0.8936562860438293f, 1.0f}, -{0.97562475970780471f, 0.94563629373317959f, 0.90365244136870437f, 1.0f}, -{0.97454825067281814f, 0.94917339484813523f, 0.91364859669357923f, 1.0f}, -{0.97347174163783157f, 0.9527104959630911f, 0.92364475201845442f, 1.0f}, -{0.97239523260284511f, 0.95624759707804685f, 0.9336409073433295f, 1.0f}, -{0.97131872356785853f, 0.95978469819300272f, 0.94363706266820457f, 1.0f}, -{0.97024221453287196f, 0.96332179930795847f, 0.95363321799307954f, 1.0f}, -{0.96916570549788539f, 0.96685890042291422f, 0.96362937331795462f, 1.0f}, -{0.96624375240292193f, 0.96639753940792006f, 0.96770472895040371f, 1.0f}, -{0.96147635524798158f, 0.96193771626297575f, 0.96585928489042672f, 1.0f}, -{0.95670895809304113f, 0.95747789311803155f, 0.96401384083044983f, 1.0f}, -{0.95194156093810078f, 0.95301806997308725f, 0.96216839677047294f, 1.0f}, -{0.94717416378316044f, 0.94855824682814316f, 0.96032295271049606f, 1.0f}, -{0.94240676662821998f, 0.94409842368319874f, 0.95847750865051906f, 1.0f}, -{0.93763936947327953f, 0.93963860053825454f, 0.95663206459054206f, 1.0f}, -{0.93287197231833918f, 0.93517877739331023f, 0.95478662053056518f, 1.0f}, -{0.92810457516339873f, 0.93071895424836604f, 0.95294117647058818f, 1.0f}, -{0.92333717800845838f, 0.92625913110342184f, 0.95109573241061129f, 1.0f}, -{0.91856978085351793f, 0.92179930795847753f, 0.94925028835063441f, 1.0f}, -{0.91380238369857758f, 0.91733948481353333f, 0.94740484429065741f, 1.0f}, -{0.90903498654363712f, 0.91287966166858903f, 0.94555940023068052f, 1.0f}, -{0.90426758938869667f, 0.90841983852364483f, 0.94371395617070353f, 1.0f}, -{0.89950019223375632f, 0.90396001537870052f, 0.94186851211072664f, 1.0f}, -{0.89473279507881598f, 0.89950019223375632f, 0.94002306805074975f, 1.0f}, -{0.88996539792387552f, 0.89504036908881202f, 0.93817762399077276f, 1.0f}, -{0.88519800076893507f, 0.89058054594386782f, 0.93633217993079587f, 1.0f}, -{0.88043060361399472f, 0.88612072279892351f, 0.93448673587081887f, 1.0f}, -{0.87566320645905427f, 0.88166089965397931f, 0.93264129181084199f, 1.0f}, -{0.87089580930411403f, 0.87720107650903523f, 0.9307958477508651f, 1.0f}, -{0.86612841214917347f, 0.87274125336409081f, 0.9289504036908881f, 1.0f}, -{0.86136101499423312f, 0.86828143021914661f, 0.92710495963091122f, 1.0f}, -{0.85659361783929266f, 0.8638216070742023f, 0.92525951557093422f, 1.0f}, -{0.85182622068435232f, 0.85936178392925811f, 0.92341407151095733f, 1.0f}, -{0.84705882352941186f, 0.8549019607843138f, 0.92156862745098045f, 1.0f}, -{0.84121491733948495f, 0.84767397154940427f, 0.91772395232602855f, 1.0f}, -{0.83537101114955803f, 0.84044598231449463f, 0.91387927720107653f, 1.0f}, -{0.82952710495963111f, 0.83321799307958488f, 0.91003460207612463f, 1.0f}, -{0.82368319876970408f, 0.82599000384467525f, 0.90618992695117273f, 1.0f}, -{0.81783929257977717f, 0.81876201460976561f, 0.90234525182622072f, 1.0f}, -{0.81199538638985025f, 0.81153402537485597f, 0.89850057670126882f, 1.0f}, -{0.80615148019992322f, 0.80430603613994633f, 0.89465590157631691f, 1.0f}, -{0.8003075740099963f, 0.7970780469050367f, 0.8908112264513649f, 1.0f}, -{0.79446366782006939f, 0.78985005767012706f, 0.886966551326413f, 1.0f}, -{0.78861976163014236f, 0.78262206843521742f, 0.88312187620146099f, 1.0f}, -{0.78277585544021566f, 0.77539407920030801f, 0.8792772010765092f, 1.0f}, -{0.77693194925028852f, 0.76816608996539815f, 0.87543252595155718f, 1.0f}, -{0.77108804306036149f, 0.7609381007304884f, 0.87158785082660517f, 1.0f}, -{0.76524413687043458f, 0.75371011149557876f, 0.86774317570165327f, 1.0f}, -{0.75940023068050766f, 0.74648212226066912f, 0.86389850057670137f, 1.0f}, -{0.75355632449058074f, 0.73925413302575949f, 0.86005382545174935f, 1.0f}, -{0.74771241830065371f, 0.73202614379084985f, 0.85620915032679745f, 1.0f}, -{0.7418685121107268f, 0.72479815455594021f, 0.85236447520184555f, 1.0f}, -{0.73602460592079977f, 0.71757016532103046f, 0.84851980007689354f, 1.0f}, -{0.73018069973087285f, 0.71034217608612082f, 0.84467512495194164f, 1.0f}, -{0.72433679354094593f, 0.70311418685121119f, 0.84083044982698973f, 1.0f}, -{0.71849288735101902f, 0.69588619761630155f, 0.83698577470203772f, 1.0f}, -{0.71264898116109199f, 0.68865820838139191f, 0.83314109957708582f, 1.0f}, -{0.70680507497116507f, 0.68143021914648227f, 0.82929642445213392f, 1.0f}, -{0.70096116878123815f, 0.67420222991157264f, 0.82545174932718191f, 1.0f}, -{0.69419454056132279f, 0.66628219915417164f, 0.8206074586697425f, 1.0f}, -{0.6865051903114191f, 0.6576701268742795f, 0.8147635524798158f, 1.0f}, -{0.67881584006151496f, 0.64905805459438692f, 0.80891964628988866f, 1.0f}, -{0.67112648981161105f, 0.64044598231449457f, 0.80307574009996163f, 1.0f}, -{0.66343713956170713f, 0.63183391003460221f, 0.79723183391003472f, 1.0f}, -{0.65574778931180333f, 0.62322183775470985f, 0.7913879277201078f, 1.0f}, -{0.64805843906189942f, 0.61460976547481749f, 0.78554402153018077f, 1.0f}, -{0.6403690888119955f, 0.60599769319492514f, 0.77970011534025385f, 1.0f}, -{0.63267973856209159f, 0.59738562091503278f, 0.77385620915032693f, 1.0f}, -{0.62499038831218767f, 0.58877354863514042f, 0.76801230296039991f, 1.0f}, -{0.61730103806228387f, 0.58016147635524806f, 0.76216839677047299f, 1.0f}, -{0.60961168781237995f, 0.5715494040753557f, 0.75632449058054607f, 1.0f}, -{0.60192233756247604f, 0.56293733179546335f, 0.75048058439061904f, 1.0f}, -{0.59423298731257224f, 0.55432525951557099f, 0.74463667820069213f, 1.0f}, -{0.58654363706266832f, 0.54571318723567863f, 0.73879277201076521f, 1.0f}, -{0.57885428681276441f, 0.53710111495578627f, 0.73294886582083818f, 1.0f}, -{0.57116493656286049f, 0.52848904267589392f, 0.72710495963091126f, 1.0f}, -{0.5634755863129568f, 0.51987697039600178f, 0.72126105344098446f, 1.0f}, -{0.55578623606305277f, 0.5112648981161092f, 0.71541714725105732f, 1.0f}, -{0.54809688581314886f, 0.50265282583621684f, 0.7095732410611304f, 1.0f}, -{0.54040753556324495f, 0.49404075355632454f, 0.70372933487120348f, 1.0f}, -{0.53271818531334103f, 0.48542868127643218f, 0.69788542868127657f, 1.0f}, -{0.52502883506343712f, 0.47681660899653983f, 0.69204152249134954f, 1.0f}, -{0.51733948481353331f, 0.46820453671664747f, 0.68619761630142251f, 1.0f}, -{0.5096501345636294f, 0.45959246443675511f, 0.68035371011149559f, 1.0f}, -{0.50196078431372548f, 0.45098039215686275f, 0.67450980392156867f, 1.0f}, -{0.49519415609381007f, 0.43929257977700886f, 0.6689734717416379f, 1.0f}, -{0.48842752787389465f, 0.42760476739715497f, 0.66343713956170702f, 1.0f}, -{0.48166089965397924f, 0.41591695501730103f, 0.65790080738177625f, 1.0f}, -{0.47489427143406382f, 0.40422914263744714f, 0.65236447520184548f, 1.0f}, -{0.4681276432141484f, 0.39254133025759325f, 0.64682814302191471f, 1.0f}, -{0.46136101499423299f, 0.38085351787773936f, 0.64129181084198383f, 1.0f}, -{0.45459438677431757f, 0.36916570549788541f, 0.63575547866205306f, 1.0f}, -{0.44782775855440232f, 0.35747789311803185f, 0.63021914648212241f, 1.0f}, -{0.44106113033448674f, 0.34579008073817763f, 0.62468281430219152f, 1.0f}, -{0.43429450211457132f, 0.33410226835832374f, 0.61914648212226064f, 1.0f}, -{0.42752787389465591f, 0.32241445597846985f, 0.61361014994232987f, 1.0f}, -{0.42076124567474049f, 0.3107266435986159f, 0.6080738177623991f, 1.0f}, -{0.41399461745482508f, 0.29903883121876207f, 0.60253748558246834f, 1.0f}, -{0.40722798923490966f, 0.28735101883890812f, 0.59700115340253745f, 1.0f}, -{0.40046136101499424f, 0.27566320645905418f, 0.59146482122260668f, 1.0f}, -{0.39369473279507883f, 0.26397539407920034f, 0.58592848904267592f, 1.0f}, -{0.38692810457516341f, 0.2522875816993464f, 0.58039215686274515f, 1.0f}, -{0.380161476355248f, 0.24059976931949251f, 0.57485582468281426f, 1.0f}, -{0.37339484813533252f, 0.22891195693963862f, 0.5693194925028835f, 1.0f}, -{0.36662821991541716f, 0.2172241445597847f, 0.56378316032295273f, 1.0f}, -{0.35986159169550169f, 0.20553633217993081f, 0.55824682814302196f, 1.0f}, -{0.35309496347558633f, 0.19384851980007689f, 0.55271049596309108f, 1.0f}, -{0.34632833525567086f, 0.182160707420223f, 0.54717416378316031f, 1.0f}, -{0.33956170703575567f, 0.17047289504036944f, 0.54163783160322965f, 1.0f}, -{0.33279507881584003f, 0.15878508266051522f, 0.53610149942329877f, 1.0f}, -{0.32641291810841983f, 0.14994232987312572f, 0.52864282968089193f, 1.0f}, -{0.32041522491349483f, 0.1439446366782007f, 0.51926182237600926f, 1.0f}, -{0.31441753171856979f, 0.13794694348327569f, 0.50988081507112648f, 1.0f}, -{0.30841983852364474f, 0.13194925028835064f, 0.5004998077662437f, 1.0f}, -{0.30242214532871969f, 0.12595155709342562f, 0.49111880046136103f, 1.0f}, -{0.2964244521337947f, 0.11995386389850059f, 0.48173779315647824f, 1.0f}, -{0.29042675893886966f, 0.11395617070357555f, 0.47235678585159552f, 1.0f}, -{0.28442906574394466f, 0.10795847750865054f, 0.46297577854671279f, 1.0f}, -{0.27843137254901962f, 0.1019607843137255f, 0.45359477124183006f, 1.0f}, -{0.27243367935409457f, 0.09596309111880047f, 0.44421376393694734f, 1.0f}, -{0.26643598615916952f, 0.089965397923875437f, 0.43483275663206461f, 1.0f}, -{0.26043829296424453f, 0.083967704728950404f, 0.42545174932718188f, 1.0f}, -{0.25444059976931949f, 0.077970011534025385f, 0.4160707420222991f, 1.0f}, -{0.24844290657439447f, 0.071972318339100352f, 0.40668973471741637f, 1.0f}, -{0.24244521337946962f, 0.0659746251441755f, 0.39730872741253392f, 1.0f}, -{0.2364475201845444f, 0.059976931949250301f, 0.38792772010765092f, 1.0f}, -{0.23044982698961938f, 0.053979238754325254f, 0.37854671280276819f, 1.0f}, -{0.22445213379469436f, 0.047981545559400235f, 0.36916570549788541f, 1.0f}, -{0.21845444059976932f, 0.041983852364475202f, 0.35978469819300274f, 1.0f}, -{0.21245674740484433f, 0.035986159169550183f, 0.35040369088811996f, 1.0f}, -{0.20645905420991928f, 0.029988465974625136f, 0.34102268358323723f, 1.0f}, -{0.20046136101499423f, 0.023990772779700104f, 0.3316416762783545f, 1.0f}, -{0.19446366782006921f, 0.017993079584775085f, 0.32226066897347172f, 1.0f}, -{0.18846597462514419f, 0.011995386389850066f, 0.31287966166858905f, 1.0f}, -{0.18246828143021915f, 0.005997693194925019f, 0.30349865436370627f, 1.0f}, -{0.17647058823529413f, 0.0f, 0.29411764705882354f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/diverging/PuOr.txt b/extern/tfn/colormaps/diverging/PuOr.txt deleted file mode 100644 index bc1fb2f..0000000 --- a/extern/tfn/colormaps/diverging/PuOr.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.49803921568627452, 0.23137254901960785, 0.031372549019607843, 1.0) -(0.50603613994617458, 0.23583237216455211, 0.031064975009611688, 1.0) -(0.51403306420607464, 0.24029219530949636, 0.030757400999615533, 1.0) -(0.52202998846597459, 0.24475201845444061, 0.030449826989619375, 1.0) -(0.53002691272587465, 0.24921184159938486, 0.030142252979623221, 1.0) -(0.53802383698577472, 0.25367166474432912, 0.029834678969627066, 1.0) -(0.54602076124567478, 0.25813148788927337, 0.029527104959630911, 1.0) -(0.55401768550557473, 0.26259131103421762, 0.029219530949634753, 1.0) -(0.56201460976547479, 0.26705113417916188, 0.028911956939638599, 1.0) -(0.57001153402537486, 0.27151095732410613, 0.028604382929642444, 1.0) -(0.57800845828527492, 0.27597078046905038, 0.028296808919646289, 1.0) -(0.58600538254517498, 0.28043060361399463, 0.027989234909650131, 1.0) -(0.59400230680507493, 0.28489042675893889, 0.027681660899653977, 1.0) -(0.60199923106497499, 0.28935024990388314, 0.027374086889657822, 1.0) -(0.60999615532487506, 0.29381007304882739, 0.027066512879661664, 1.0) -(0.61799307958477501, 0.29826989619377164, 0.026758938869665509, 1.0) -(0.62599000384467507, 0.3027297193387159, 0.026451364859669355, 1.0) -(0.63398692810457513, 0.30718954248366015, 0.0261437908496732, 1.0) -(0.64198385236447519, 0.3116493656286044, 0.025836216839677045, 1.0) -(0.64998077662437526, 0.31610918877354865, 0.025528642829680891, 1.0) -(0.65797770088427521, 0.32056901191849285, 0.025221068819684733, 1.0) -(0.66597462514417527, 0.32502883506343716, 0.024913494809688578, 1.0) -(0.67397154940407533, 0.32948865820838141, 0.024605920799692423, 1.0) -(0.68196847366397528, 0.33394848135332567, 0.024298346789696265, 1.0) -(0.68996539792387535, 0.33840830449826986, 0.023990772779700111, 1.0) -(0.69796232218377541, 0.34286812764321417, 0.023683198769703956, 1.0) -(0.70542099192618224, 0.34832756632064588, 0.024605920799692423, 1.0) -(0.71234140715109573, 0.35478662053056514, 0.026758938869665509, 1.0) -(0.71926182237600922, 0.36124567474048441, 0.028911956939638599, 1.0) -(0.72618223760092271, 0.36770472895040368, 0.031064975009611685, 1.0) -(0.7331026528258362, 0.37416378316032295, 0.033217993079584771, 1.0) -(0.74002306805074969, 0.38062283737024222, 0.03537101114955786, 1.0) -(0.74694348327566318, 0.38708189158016149, 0.037524029219530942, 1.0) -(0.75386389850057656, 0.3935409457900807, 0.039677047289504018, 1.0) -(0.76078431372549016, 0.39999999999999997, 0.041830065359477114, 1.0) -(0.76770472895040365, 0.40645905420991923, 0.043983083429450204, 1.0) -(0.77462514417531714, 0.4129181084198385, 0.046136101499423293, 1.0) -(0.78154555940023063, 0.41937716262975772, 0.048289119569396369, 1.0) -(0.78846597462514412, 0.42583621683967704, 0.050442137639369472, 1.0) -(0.79538638985005761, 0.43229527104959631, 0.052595155709342561, 1.0) -(0.8023068050749711, 0.43875432525951552, 0.054748173779315644, 1.0) -(0.80922722029988459, 0.44521337946943473, 0.056901191849288713, 1.0) -(0.81614763552479808, 0.45167243367935406, 0.059054209919261816, 1.0) -(0.82306805074971168, 0.45813148788927333, 0.061207227989234905, 1.0) -(0.82998846597462506, 0.46459054209919259, 0.063360246059207995, 1.0) -(0.83690888119953855, 0.47104959630911181, 0.06551326412918107, 1.0) -(0.84382929642445215, 0.47750865051903113, 0.067666282199154174, 1.0) -(0.85074971164936564, 0.48396770472895034, 0.069819300269127249, 1.0) -(0.85767012687427913, 0.49042675893886967, 0.071972318339100338, 1.0) -(0.86459054209919262, 0.49688581314878888, 0.074125336409073414, 1.0) -(0.87151095732410611, 0.5033448673587082, 0.076278354479046517, 1.0) -(0.8784313725490196, 0.50980392156862742, 0.078431372549019607, 1.0) -(0.88289119569396379, 0.51810841983852363, 0.090580545943867732, 1.0) -(0.8873510188389081, 0.52641291810841973, 0.10272971933871577, 1.0) -(0.8918108419838523, 0.53471741637831594, 0.114878892733564, 1.0) -(0.89627066512879661, 0.54302191464821215, 0.12702806612841211, 1.0) -(0.9007304882737408, 0.55132641291810836, 0.13917723952326025, 1.0) -(0.90519031141868511, 0.55963091118800445, 0.15132641291810828, 1.0) -(0.90965013456362931, 0.56793540945790078, 0.1634755863129565, 1.0) -(0.91410995770857362, 0.57623990772779698, 0.17562475970780464, 1.0) -(0.91856978085351781, 0.58454440599769308, 0.18777393310265278, 1.0) -(0.92302960399846212, 0.59284890426758929, 0.19992310649750081, 1.0) -(0.92748942714340632, 0.6011534025374855, 0.21207227989234903, 1.0) -(0.93194925028835063, 0.60945790080738171, 0.22422145328719714, 1.0) -(0.93640907343329483, 0.61776239907727792, 0.23637062668204528, 1.0) -(0.94086889657823913, 0.62606689734717413, 0.24851980007689342, 1.0) -(0.94532871972318333, 0.63437139561707012, 0.26066897347174134, 1.0) -(0.94978854286812764, 0.64267589388696644, 0.27281814686658967, 1.0) -(0.95424836601307184, 0.65098039215686265, 0.28496732026143778, 1.0) -(0.95870818915801614, 0.65928489042675886, 0.2971164936562859, 1.0) -(0.96316801230296034, 0.66758938869665507, 0.30926566705113406, 1.0) -(0.96762783544790465, 0.67589388696655117, 0.32141484044598218, 1.0) -(0.97208765859284885, 0.68419838523644738, 0.33356401384083029, 1.0) -(0.97654748173779315, 0.69250288350634359, 0.34571318723567845, 1.0) -(0.98100730488273735, 0.70080738177623969, 0.3578623606305264, 1.0) -(0.98546712802768166, 0.70911188004613601, 0.37001153402537468, 1.0) -(0.98992695117262586, 0.71741637831603211, 0.38216070742022279, 1.0) -(0.99223375624759713, 0.72464436755094186, 0.3946174548250671, 1.0) -(0.99238754325259515, 0.73079584775086492, 0.40738177623990757, 1.0) -(0.99254133025759328, 0.7369473279507881, 0.42014609765474803, 1.0) -(0.9926951172625913, 0.74309880815071117, 0.43291041906958849, 1.0) -(0.99284890426758943, 0.74925028835063434, 0.4456747404844289, 1.0) -(0.99300269127258745, 0.7554017685505573, 0.4584390618992692, 1.0) -(0.99315647827758557, 0.76155324875048047, 0.47120338331410982, 1.0) -(0.99331026528258359, 0.76770472895040365, 0.48396770472895029, 1.0) -(0.99346405228758172, 0.77385620915032671, 0.49673202614379075, 1.0) -(0.99361783929257985, 0.78000768935024989, 0.50949634755863116, 1.0) -(0.99377162629757787, 0.78615916955017295, 0.52226066897347168, 1.0) -(0.993925413302576, 0.79231064975009602, 0.53502499038831208, 1.0) -(0.99407920030757402, 0.79846212995001919, 0.54778931180315249, 1.0) -(0.99423298731257215, 0.80461361014994215, 0.56055363321799279, 1.0) -(0.99438677431757017, 0.81076509034986532, 0.57331795463283353, 1.0) -(0.9945405613225683, 0.8169165705497885, 0.58608227604767393, 1.0) -(0.99469434832756631, 0.82306805074971157, 0.59884659746251434, 1.0) -(0.99484813533256444, 0.82921953094963474, 0.61161091887735486, 1.0) -(0.99500192233756246, 0.83537101114955781, 0.62437524029219527, 1.0) -(0.99515570934256059, 0.84152249134948098, 0.63713956170703567, 1.0) -(0.99530949634755861, 0.84767397154940405, 0.64990388312187619, 1.0) -(0.99546328335255674, 0.85382545174932711, 0.66266820453671649, 1.0) -(0.99561707035755476, 0.85997693194925029, 0.67543252595155712, 1.0) -(0.99577085736255289, 0.86612841214917335, 0.68819684736639752, 1.0) -(0.9959246443675509, 0.87227989234909653, 0.70096116878123804, 1.0) -(0.99607843137254903, 0.8784313725490196, 0.71372549019607845, 1.0) -(0.99500192233756246, 0.88196847366397535, 0.72372164552095353, 1.0) -(0.993925413302576, 0.88550557477893121, 0.73371780084582849, 1.0) -(0.99284890426758943, 0.88904267589388697, 0.74371395617070357, 1.0) -(0.99177239523260285, 0.89257977700884272, 0.75371011149557854, 1.0) -(0.99069588619761628, 0.89611687812379848, 0.76370626682045373, 1.0) -(0.98961937716262982, 0.89965397923875434, 0.77370242214532869, 1.0) -(0.98854286812764325, 0.9031910803537101, 0.78369857747020377, 1.0) -(0.98746635909265668, 0.90672818146866585, 0.79369473279507885, 1.0) -(0.9863898500576701, 0.91026528258362172, 0.80369088811995393, 1.0) -(0.98531334102268364, 0.91380238369857747, 0.81368704344482889, 1.0) -(0.98423683198769707, 0.91733948481353322, 0.82368319876970397, 1.0) -(0.9831603229527105, 0.92087658592848898, 0.83367935409457883, 1.0) -(0.98208381391772392, 0.92441368704344484, 0.84367550941945402, 1.0) -(0.98100730488273746, 0.9279507881584006, 0.8536716647443291, 1.0) -(0.97993079584775089, 0.93148788927335635, 0.86366782006920417, 1.0) -(0.97885428681276432, 0.93502499038831222, 0.87366397539407914, 1.0) -(0.97777777777777775, 0.93856209150326797, 0.88366013071895422, 1.0) -(0.97670126874279128, 0.94209919261822372, 0.8936562860438293, 1.0) -(0.97562475970780471, 0.94563629373317959, 0.90365244136870437, 1.0) -(0.97454825067281814, 0.94917339484813523, 0.91364859669357923, 1.0) -(0.97347174163783157, 0.9527104959630911, 0.92364475201845442, 1.0) -(0.97239523260284511, 0.95624759707804685, 0.9336409073433295, 1.0) -(0.97131872356785853, 0.95978469819300272, 0.94363706266820457, 1.0) -(0.97024221453287196, 0.96332179930795847, 0.95363321799307954, 1.0) -(0.96916570549788539, 0.96685890042291422, 0.96362937331795462, 1.0) -(0.96624375240292193, 0.96639753940792006, 0.96770472895040371, 1.0) -(0.96147635524798158, 0.96193771626297575, 0.96585928489042672, 1.0) -(0.95670895809304113, 0.95747789311803155, 0.96401384083044983, 1.0) -(0.95194156093810078, 0.95301806997308725, 0.96216839677047294, 1.0) -(0.94717416378316044, 0.94855824682814316, 0.96032295271049606, 1.0) -(0.94240676662821998, 0.94409842368319874, 0.95847750865051906, 1.0) -(0.93763936947327953, 0.93963860053825454, 0.95663206459054206, 1.0) -(0.93287197231833918, 0.93517877739331023, 0.95478662053056518, 1.0) -(0.92810457516339873, 0.93071895424836604, 0.95294117647058818, 1.0) -(0.92333717800845838, 0.92625913110342184, 0.95109573241061129, 1.0) -(0.91856978085351793, 0.92179930795847753, 0.94925028835063441, 1.0) -(0.91380238369857758, 0.91733948481353333, 0.94740484429065741, 1.0) -(0.90903498654363712, 0.91287966166858903, 0.94555940023068052, 1.0) -(0.90426758938869667, 0.90841983852364483, 0.94371395617070353, 1.0) -(0.89950019223375632, 0.90396001537870052, 0.94186851211072664, 1.0) -(0.89473279507881598, 0.89950019223375632, 0.94002306805074975, 1.0) -(0.88996539792387552, 0.89504036908881202, 0.93817762399077276, 1.0) -(0.88519800076893507, 0.89058054594386782, 0.93633217993079587, 1.0) -(0.88043060361399472, 0.88612072279892351, 0.93448673587081887, 1.0) -(0.87566320645905427, 0.88166089965397931, 0.93264129181084199, 1.0) -(0.87089580930411403, 0.87720107650903523, 0.9307958477508651, 1.0) -(0.86612841214917347, 0.87274125336409081, 0.9289504036908881, 1.0) -(0.86136101499423312, 0.86828143021914661, 0.92710495963091122, 1.0) -(0.85659361783929266, 0.8638216070742023, 0.92525951557093422, 1.0) -(0.85182622068435232, 0.85936178392925811, 0.92341407151095733, 1.0) -(0.84705882352941186, 0.8549019607843138, 0.92156862745098045, 1.0) -(0.84121491733948495, 0.84767397154940427, 0.91772395232602855, 1.0) -(0.83537101114955803, 0.84044598231449463, 0.91387927720107653, 1.0) -(0.82952710495963111, 0.83321799307958488, 0.91003460207612463, 1.0) -(0.82368319876970408, 0.82599000384467525, 0.90618992695117273, 1.0) -(0.81783929257977717, 0.81876201460976561, 0.90234525182622072, 1.0) -(0.81199538638985025, 0.81153402537485597, 0.89850057670126882, 1.0) -(0.80615148019992322, 0.80430603613994633, 0.89465590157631691, 1.0) -(0.8003075740099963, 0.7970780469050367, 0.8908112264513649, 1.0) -(0.79446366782006939, 0.78985005767012706, 0.886966551326413, 1.0) -(0.78861976163014236, 0.78262206843521742, 0.88312187620146099, 1.0) -(0.78277585544021566, 0.77539407920030801, 0.8792772010765092, 1.0) -(0.77693194925028852, 0.76816608996539815, 0.87543252595155718, 1.0) -(0.77108804306036149, 0.7609381007304884, 0.87158785082660517, 1.0) -(0.76524413687043458, 0.75371011149557876, 0.86774317570165327, 1.0) -(0.75940023068050766, 0.74648212226066912, 0.86389850057670137, 1.0) -(0.75355632449058074, 0.73925413302575949, 0.86005382545174935, 1.0) -(0.74771241830065371, 0.73202614379084985, 0.85620915032679745, 1.0) -(0.7418685121107268, 0.72479815455594021, 0.85236447520184555, 1.0) -(0.73602460592079977, 0.71757016532103046, 0.84851980007689354, 1.0) -(0.73018069973087285, 0.71034217608612082, 0.84467512495194164, 1.0) -(0.72433679354094593, 0.70311418685121119, 0.84083044982698973, 1.0) -(0.71849288735101902, 0.69588619761630155, 0.83698577470203772, 1.0) -(0.71264898116109199, 0.68865820838139191, 0.83314109957708582, 1.0) -(0.70680507497116507, 0.68143021914648227, 0.82929642445213392, 1.0) -(0.70096116878123815, 0.67420222991157264, 0.82545174932718191, 1.0) -(0.69419454056132279, 0.66628219915417164, 0.8206074586697425, 1.0) -(0.6865051903114191, 0.6576701268742795, 0.8147635524798158, 1.0) -(0.67881584006151496, 0.64905805459438692, 0.80891964628988866, 1.0) -(0.67112648981161105, 0.64044598231449457, 0.80307574009996163, 1.0) -(0.66343713956170713, 0.63183391003460221, 0.79723183391003472, 1.0) -(0.65574778931180333, 0.62322183775470985, 0.7913879277201078, 1.0) -(0.64805843906189942, 0.61460976547481749, 0.78554402153018077, 1.0) -(0.6403690888119955, 0.60599769319492514, 0.77970011534025385, 1.0) -(0.63267973856209159, 0.59738562091503278, 0.77385620915032693, 1.0) -(0.62499038831218767, 0.58877354863514042, 0.76801230296039991, 1.0) -(0.61730103806228387, 0.58016147635524806, 0.76216839677047299, 1.0) -(0.60961168781237995, 0.5715494040753557, 0.75632449058054607, 1.0) -(0.60192233756247604, 0.56293733179546335, 0.75048058439061904, 1.0) -(0.59423298731257224, 0.55432525951557099, 0.74463667820069213, 1.0) -(0.58654363706266832, 0.54571318723567863, 0.73879277201076521, 1.0) -(0.57885428681276441, 0.53710111495578627, 0.73294886582083818, 1.0) -(0.57116493656286049, 0.52848904267589392, 0.72710495963091126, 1.0) -(0.5634755863129568, 0.51987697039600178, 0.72126105344098446, 1.0) -(0.55578623606305277, 0.5112648981161092, 0.71541714725105732, 1.0) -(0.54809688581314886, 0.50265282583621684, 0.7095732410611304, 1.0) -(0.54040753556324495, 0.49404075355632454, 0.70372933487120348, 1.0) -(0.53271818531334103, 0.48542868127643218, 0.69788542868127657, 1.0) -(0.52502883506343712, 0.47681660899653983, 0.69204152249134954, 1.0) -(0.51733948481353331, 0.46820453671664747, 0.68619761630142251, 1.0) -(0.5096501345636294, 0.45959246443675511, 0.68035371011149559, 1.0) -(0.50196078431372548, 0.45098039215686275, 0.67450980392156867, 1.0) -(0.49519415609381007, 0.43929257977700886, 0.6689734717416379, 1.0) -(0.48842752787389465, 0.42760476739715497, 0.66343713956170702, 1.0) -(0.48166089965397924, 0.41591695501730103, 0.65790080738177625, 1.0) -(0.47489427143406382, 0.40422914263744714, 0.65236447520184548, 1.0) -(0.4681276432141484, 0.39254133025759325, 0.64682814302191471, 1.0) -(0.46136101499423299, 0.38085351787773936, 0.64129181084198383, 1.0) -(0.45459438677431757, 0.36916570549788541, 0.63575547866205306, 1.0) -(0.44782775855440232, 0.35747789311803185, 0.63021914648212241, 1.0) -(0.44106113033448674, 0.34579008073817763, 0.62468281430219152, 1.0) -(0.43429450211457132, 0.33410226835832374, 0.61914648212226064, 1.0) -(0.42752787389465591, 0.32241445597846985, 0.61361014994232987, 1.0) -(0.42076124567474049, 0.3107266435986159, 0.6080738177623991, 1.0) -(0.41399461745482508, 0.29903883121876207, 0.60253748558246834, 1.0) -(0.40722798923490966, 0.28735101883890812, 0.59700115340253745, 1.0) -(0.40046136101499424, 0.27566320645905418, 0.59146482122260668, 1.0) -(0.39369473279507883, 0.26397539407920034, 0.58592848904267592, 1.0) -(0.38692810457516341, 0.2522875816993464, 0.58039215686274515, 1.0) -(0.380161476355248, 0.24059976931949251, 0.57485582468281426, 1.0) -(0.37339484813533252, 0.22891195693963862, 0.5693194925028835, 1.0) -(0.36662821991541716, 0.2172241445597847, 0.56378316032295273, 1.0) -(0.35986159169550169, 0.20553633217993081, 0.55824682814302196, 1.0) -(0.35309496347558633, 0.19384851980007689, 0.55271049596309108, 1.0) -(0.34632833525567086, 0.182160707420223, 0.54717416378316031, 1.0) -(0.33956170703575567, 0.17047289504036944, 0.54163783160322965, 1.0) -(0.33279507881584003, 0.15878508266051522, 0.53610149942329877, 1.0) -(0.32641291810841983, 0.14994232987312572, 0.52864282968089193, 1.0) -(0.32041522491349483, 0.1439446366782007, 0.51926182237600926, 1.0) -(0.31441753171856979, 0.13794694348327569, 0.50988081507112648, 1.0) -(0.30841983852364474, 0.13194925028835064, 0.5004998077662437, 1.0) -(0.30242214532871969, 0.12595155709342562, 0.49111880046136103, 1.0) -(0.2964244521337947, 0.11995386389850059, 0.48173779315647824, 1.0) -(0.29042675893886966, 0.11395617070357555, 0.47235678585159552, 1.0) -(0.28442906574394466, 0.10795847750865054, 0.46297577854671279, 1.0) -(0.27843137254901962, 0.1019607843137255, 0.45359477124183006, 1.0) -(0.27243367935409457, 0.09596309111880047, 0.44421376393694734, 1.0) -(0.26643598615916952, 0.089965397923875437, 0.43483275663206461, 1.0) -(0.26043829296424453, 0.083967704728950404, 0.42545174932718188, 1.0) -(0.25444059976931949, 0.077970011534025385, 0.4160707420222991, 1.0) -(0.24844290657439447, 0.071972318339100352, 0.40668973471741637, 1.0) -(0.24244521337946962, 0.0659746251441755, 0.39730872741253392, 1.0) -(0.2364475201845444, 0.059976931949250301, 0.38792772010765092, 1.0) -(0.23044982698961938, 0.053979238754325254, 0.37854671280276819, 1.0) -(0.22445213379469436, 0.047981545559400235, 0.36916570549788541, 1.0) -(0.21845444059976932, 0.041983852364475202, 0.35978469819300274, 1.0) -(0.21245674740484433, 0.035986159169550183, 0.35040369088811996, 1.0) -(0.20645905420991928, 0.029988465974625136, 0.34102268358323723, 1.0) -(0.20046136101499423, 0.023990772779700104, 0.3316416762783545, 1.0) -(0.19446366782006921, 0.017993079584775085, 0.32226066897347172, 1.0) -(0.18846597462514419, 0.011995386389850066, 0.31287966166858905, 1.0) -(0.18246828143021915, 0.005997693194925019, 0.30349865436370627, 1.0) -(0.17647058823529413, 0.0, 0.29411764705882354, 1.0) diff --git a/extern/tfn/colormaps/diverging/RdBu.cpp b/extern/tfn/colormaps/diverging/RdBu.cpp deleted file mode 100644 index a3cb018..0000000 --- a/extern/tfn/colormaps/diverging/RdBu.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_diverging_RdBu; -} -const std::vector colormap::data_diverging_RdBu = /* NOLINT(cert-err58-cpp) */ -{ -{0.40392156862745099f, 0.0f, 0.12156862745098039f, 1.0f}, -{0.41545559400230681f, 0.0036908881199538639f, 0.12341407151095732f, 1.0f}, -{0.42698961937716262f, 0.0073817762399077278f, 0.12525951557093426f, 1.0f}, -{0.43852364475201844f, 0.011072664359861591f, 0.12710495963091117f, 1.0f}, -{0.45005767012687425f, 0.014763552479815456f, 0.12895040369088812f, 1.0f}, -{0.46159169550173013f, 0.01845444059976932f, 0.13079584775086506f, 1.0f}, -{0.47312572087658594f, 0.022145328719723183f, 0.132641291810842f, 1.0f}, -{0.48465974625144176f, 0.025836216839677049f, 0.13448673587081891f, 1.0f}, -{0.49619377162629758f, 0.029527104959630911f, 0.13633217993079585f, 1.0f}, -{0.50772779700115345f, 0.033217993079584777f, 0.13817762399077277f, 1.0f}, -{0.51926182237600926f, 0.03690888119953864f, 0.14002306805074971f, 1.0f}, -{0.53079584775086508f, 0.040599769319492503f, 0.14186851211072665f, 1.0f}, -{0.5423298731257209f, 0.044290657439446365f, 0.14371395617070359f, 1.0f}, -{0.55386389850057671f, 0.047981545559400228f, 0.14555940023068051f, 1.0f}, -{0.56539792387543253f, 0.051672433679354098f, 0.14740484429065745f, 1.0f}, -{0.57693194925028835f, 0.05536332179930796f, 0.14925028835063436f, 1.0f}, -{0.58846597462514416f, 0.059054209919261823f, 0.15109573241061131f, 1.0f}, -{0.59999999999999998f, 0.062745098039215685f, 0.15294117647058825f, 1.0f}, -{0.61153402537485579f, 0.066435986159169555f, 0.15478662053056519f, 1.0f}, -{0.62306805074971161f, 0.070126874279123411f, 0.1566320645905421f, 1.0f}, -{0.63460207612456743f, 0.07381776239907728f, 0.15847750865051904f, 1.0f}, -{0.64613610149942324f, 0.077508650519031136f, 0.16032295271049596f, 1.0f}, -{0.65767012687427906f, 0.081199538638985005f, 0.1621683967704729f, 1.0f}, -{0.66920415224913499f, 0.084890426758938875f, 0.16401384083044984f, 1.0f}, -{0.68073817762399069f, 0.088581314878892731f, 0.16585928489042678f, 1.0f}, -{0.69227220299884662f, 0.092272202998846586f, 0.1677047289504037f, 1.0f}, -{0.70080738177623991f, 0.099653979238754326f, 0.17124183006535948f, 1.0f}, -{0.70634371395617068f, 0.11072664359861592f, 0.17647058823529413f, 1.0f}, -{0.71188004613610145f, 0.12179930795847752f, 0.18169934640522878f, 1.0f}, -{0.71741637831603222f, 0.13287197231833911f, 0.1869281045751634f, 1.0f}, -{0.7229527104959631f, 0.14394463667820068f, 0.19215686274509805f, 1.0f}, -{0.72848904267589387f, 0.15501730103806227f, 0.1973856209150327f, 1.0f}, -{0.73402537485582464f, 0.16608996539792387f, 0.20261437908496732f, 1.0f}, -{0.73956170703575541f, 0.17716262975778541f, 0.20784313725490194f, 1.0f}, -{0.74509803921568629f, 0.18823529411764706f, 0.21307189542483659f, 1.0f}, -{0.75063437139561706f, 0.19930795847750865f, 0.21830065359477124f, 1.0f}, -{0.75617070357554783f, 0.21038062283737025f, 0.22352941176470587f, 1.0f}, -{0.7617070357554786f, 0.22145328719723176f, 0.22875816993464049f, 1.0f}, -{0.76724336793540948f, 0.23252595155709341f, 0.23398692810457516f, 1.0f}, -{0.77277970011534025f, 0.243598615916955f, 0.23921568627450979f, 1.0f}, -{0.77831603229527102f, 0.25467128027681663f, 0.24444444444444444f, 1.0f}, -{0.78385236447520179f, 0.26574394463667811f, 0.24967320261437903f, 1.0f}, -{0.78938869665513267f, 0.27681660899653981f, 0.25490196078431371f, 1.0f}, -{0.79492502883506344f, 0.28788927335640135f, 0.26013071895424833f, 1.0f}, -{0.80046136101499421f, 0.298961937716263f, 0.26535947712418301f, 1.0f}, -{0.80599769319492498f, 0.31003460207612449f, 0.27058823529411757f, 1.0f}, -{0.81153402537485586f, 0.32110726643598619f, 0.27581699346405231f, 1.0f}, -{0.81707035755478663f, 0.33217993079584773f, 0.28104575163398693f, 1.0f}, -{0.8226066897347174f, 0.34325259515570933f, 0.28627450980392155f, 1.0f}, -{0.82814302191464817f, 0.35432525951557087f, 0.29150326797385617f, 1.0f}, -{0.83367935409457905f, 0.36539792387543252f, 0.29673202614379085f, 1.0f}, -{0.83921568627450982f, 0.37647058823529411f, 0.30196078431372547f, 1.0f}, -{0.84382929642445215f, 0.38708189158016149f, 0.31011149557862361f, 1.0f}, -{0.84844290657439447f, 0.39769319492502875f, 0.31826220684352163f, 1.0f}, -{0.8530565167243368f, 0.40830449826989618f, 0.32641291810841983f, 1.0f}, -{0.85767012687427913f, 0.41891580161476355f, 0.33456362937331791f, 1.0f}, -{0.86228373702422145f, 0.42952710495963087f, 0.34271434063821604f, 1.0f}, -{0.86689734717416378f, 0.44013840830449813f, 0.35086505190311407f, 1.0f}, -{0.87151095732410611f, 0.45074971164936561f, 0.35901576316801226f, 1.0f}, -{0.87612456747404843f, 0.46136101499423293f, 0.36716647443291039f, 1.0f}, -{0.88073817762399076f, 0.47197231833910031f, 0.37531718569780848f, 1.0f}, -{0.88535178777393309f, 0.48258362168396757f, 0.38346789696270656f, 1.0f}, -{0.88996539792387541f, 0.493194925028835f, 0.39161860822760469f, 1.0f}, -{0.89457900807381774f, 0.50380622837370237f, 0.39976931949250283f, 1.0f}, -{0.89919261822376007f, 0.51441753171856974f, 0.40792003075740091f, 1.0f}, -{0.90380622837370239f, 0.52502883506343712f, 0.41607074202229904f, 1.0f}, -{0.90841983852364472f, 0.53564013840830427f, 0.42422145328719701f, 1.0f}, -{0.91303344867358704f, 0.54625144175317175f, 0.43237216455209526f, 1.0f}, -{0.91764705882352937f, 0.55686274509803912f, 0.44052287581699334f, 1.0f}, -{0.9222606689734717f, 0.5674740484429065f, 0.44867358708189148f, 1.0f}, -{0.92687427912341402f, 0.57808535178777387f, 0.45682429834678961f, 1.0f}, -{0.93148788927335635f, 0.58869665513264113f, 0.4649750096116877f, 1.0f}, -{0.93610149942329868f, 0.59930795847750851f, 0.47312572087658578f, 1.0f}, -{0.940715109573241f, 0.60991926182237588f, 0.48127643214148391f, 1.0f}, -{0.94532871972318333f, 0.62053056516724314f, 0.48942714340638194f, 1.0f}, -{0.94994232987312566f, 0.63114186851211063f, 0.49757785467128013f, 1.0f}, -{0.95455594002306798f, 0.641753171856978f, 0.50572856593617821f, 1.0f}, -{0.95755478662053062f, 0.65121107266435974f, 0.51510957324106099f, 1.0f}, -{0.95893886966551334f, 0.65951557093425595f, 0.52572087658592837f, 1.0f}, -{0.96032295271049595f, 0.66782006920415216f, 0.53633217993079563f, 1.0f}, -{0.96170703575547867f, 0.67612456747404837f, 0.546943483275663f, 1.0f}, -{0.96309111880046139f, 0.68442906574394458f, 0.55755478662053037f, 1.0f}, -{0.96447520184544411f, 0.69273356401384067f, 0.56816608996539764f, 1.0f}, -{0.96585928489042683f, 0.701038062283737f, 0.57877739331026512f, 1.0f}, -{0.96724336793540944f, 0.70934256055363309f, 0.58938869665513249f, 1.0f}, -{0.96862745098039216f, 0.7176470588235293f, 0.59999999999999987f, 1.0f}, -{0.97001153402537488f, 0.72595155709342551f, 0.61061130334486724f, 1.0f}, -{0.9713956170703576f, 0.73425605536332172f, 0.62122260668973461f, 1.0f}, -{0.97277970011534032f, 0.74256055363321793f, 0.63183391003460199f, 1.0f}, -{0.97416378316032293f, 0.75086505190311414f, 0.64244521337946936f, 1.0f}, -{0.97554786620530565f, 0.75916955017301024f, 0.65305651672433651f, 1.0f}, -{0.97693194925028837f, 0.76747404844290656f, 0.66366782006920411f, 1.0f}, -{0.97831603229527109f, 0.77577854671280266f, 0.67427912341407148f, 1.0f}, -{0.97970011534025381f, 0.78408304498269887f, 0.68489042675893885f, 1.0f}, -{0.98108419838523653f, 0.79238754325259508f, 0.69550173010380623f, 1.0f}, -{0.98246828143021914f, 0.80069204152249129f, 0.7061130334486736f, 1.0f}, -{0.98385236447520186f, 0.8089965397923875f, 0.71672433679354086f, 1.0f}, -{0.98523644752018458f, 0.81730103806228371f, 0.72733564013840835f, 1.0f}, -{0.9866205305651673f, 0.8256055363321797f, 0.7379469434832755f, 1.0f}, -{0.98800461361015002f, 0.83391003460207602f, 0.74855824682814298f, 1.0f}, -{0.98938869665513263f, 0.84221453287197223f, 0.75916955017301035f, 1.0f}, -{0.99077277970011535f, 0.85051903114186844f, 0.76978085351787773f, 1.0f}, -{0.99215686274509807f, 0.85882352941176465f, 0.7803921568627451f, 1.0f}, -{0.99123414071510962f, 0.86312956555171083f, 0.78777393310265287f, 1.0f}, -{0.99031141868512118f, 0.86743560169165701f, 0.79515570934256052f, 1.0f}, -{0.98938869665513263f, 0.87174163783160319f, 0.80253748558246829f, 1.0f}, -{0.98846597462514418f, 0.87604767397154926f, 0.80991926182237595f, 1.0f}, -{0.98754325259515574f, 0.88035371011149555f, 0.81730103806228371f, 1.0f}, -{0.9866205305651673f, 0.88465974625144173f, 0.82468281430219148f, 1.0f}, -{0.98569780853517874f, 0.8889657823913879f, 0.83206459054209925f, 1.0f}, -{0.9847750865051903f, 0.89327181853133408f, 0.8394463667820069f, 1.0f}, -{0.98385236447520186f, 0.89757785467128026f, 0.84682814302191467f, 1.0f}, -{0.98292964244521341f, 0.90188389081122644f, 0.85420991926182244f, 1.0f}, -{0.98200692041522497f, 0.90618992695117262f, 0.86159169550173009f, 1.0f}, -{0.98108419838523653f, 0.91049596309111869f, 0.86897347174163775f, 1.0f}, -{0.98016147635524797f, 0.91480199923106498f, 0.87635524798154552f, 1.0f}, -{0.97923875432525953f, 0.91910803537101116f, 0.88373702422145328f, 1.0f}, -{0.97831603229527109f, 0.92341407151095733f, 0.89111880046136105f, 1.0f}, -{0.97739331026528264f, 0.92772010765090351f, 0.89850057670126871f, 1.0f}, -{0.97647058823529409f, 0.93202614379084969f, 0.90588235294117647f, 1.0f}, -{0.97554786620530565f, 0.93633217993079587f, 0.91326412918108424f, 1.0f}, -{0.9746251441753172f, 0.94063821607074205f, 0.92064590542099189f, 1.0f}, -{0.97370242214532876f, 0.94494425221068812f, 0.92802768166089955f, 1.0f}, -{0.97277970011534021f, 0.94925028835063441f, 0.93540945790080743f, 1.0f}, -{0.97185697808535176f, 0.95355632449058059f, 0.94279123414071508f, 1.0f}, -{0.97093425605536332f, 0.95786236063052677f, 0.95017301038062285f, 1.0f}, -{0.97001153402537488f, 0.96216839677047283f, 0.95755478662053051f, 1.0f}, -{0.96908881199538643f, 0.96647443291041912f, 0.96493656286043827f, 1.0f}, -{0.9657054978854287f, 0.96724336793540944f, 0.96808919646289893f, 1.0f}, -{0.95986159169550178f, 0.96447520184544411f, 0.96701268742791235f, 1.0f}, -{0.95401768550557475f, 0.96170703575547867f, 0.96593617839292578f, 1.0f}, -{0.94817377931564784f, 0.95893886966551323f, 0.96485966935793921f, 1.0f}, -{0.94232987312572103f, 0.95617070357554801f, 0.96378316032295275f, 1.0f}, -{0.936485966935794f, 0.95340253748558246f, 0.96270665128796618f, 1.0f}, -{0.93064206074586697f, 0.95063437139561713f, 0.9616301422529796f, 1.0f}, -{0.92479815455594006f, 0.94786620530565169f, 0.96055363321799303f, 1.0f}, -{0.91895424836601314f, 0.94509803921568636f, 0.95947712418300657f, 1.0f}, -{0.91311034217608622f, 0.94232987312572092f, 0.95840061514802f, 1.0f}, -{0.90726643598615919f, 0.93956170703575548f, 0.95732410611303342f, 1.0f}, -{0.90142252979623227f, 0.93679354094579015f, 0.95624759707804696f, 1.0f}, -{0.89557862360630536f, 0.93402537485582471f, 0.95517108804306039f, 1.0f}, -{0.88973471741637833f, 0.93125720876585938f, 0.95409457900807382f, 1.0f}, -{0.88389081122645141f, 0.92848904267589394f, 0.95301806997308725f, 1.0f}, -{0.87804690503652449f, 0.92572087658592861f, 0.95194156093810078f, 1.0f}, -{0.87220299884659758f, 0.92295271049596317f, 0.95086505190311421f, 1.0f}, -{0.86635909265667066f, 0.92018454440599773f, 0.94978854286812764f, 1.0f}, -{0.86051518646674363f, 0.9174163783160324f, 0.94871203383314107f, 1.0f}, -{0.85467128027681671f, 0.91464821222606696f, 0.9476355247981546f, 1.0f}, -{0.84882737408688991f, 0.91188004613610163f, 0.94655901576316803f, 1.0f}, -{0.84298346789696277f, 0.90911188004613619f, 0.94548250672818146f, 1.0f}, -{0.83713956170703585f, 0.90634371395617075f, 0.94440599769319489f, 1.0f}, -{0.83129565551710893f, 0.90357554786620542f, 0.94332948865820843f, 1.0f}, -{0.82545174932718202f, 0.90080738177623998f, 0.94225297962322185f, 1.0f}, -{0.8196078431372551f, 0.89803921568627465f, 0.94117647058823528f, 1.0f}, -{0.80991926182237628f, 0.89311803152633618f, 0.93840830449826995f, 1.0f}, -{0.80023068050749735f, 0.8881968473663977f, 0.93564013840830451f, 1.0f}, -{0.79054209919261842f, 0.88327566320645923f, 0.93287197231833918f, 1.0f}, -{0.7808535178777396f, 0.87835447904652075f, 0.93010380622837374f, 1.0f}, -{0.77116493656286067f, 0.87343329488658228f, 0.92733564013840841f, 1.0f}, -{0.76147635524798174f, 0.8685121107266438f, 0.92456747404844297f, 1.0f}, -{0.75178777393310292f, 0.86359092656670533f, 0.92179930795847753f, 1.0f}, -{0.74209919261822399f, 0.85866974240676686f, 0.9190311418685122f, 1.0f}, -{0.73241061130334506f, 0.85374855824682827f, 0.91626297577854676f, 1.0f}, -{0.72272202998846624f, 0.8488273740868898f, 0.91349480968858143f, 1.0f}, -{0.71303344867358764f, 0.84390618992695154f, 0.9107266435986161f, 1.0f}, -{0.70334486735870838f, 0.83898500576701285f, 0.90795847750865055f, 1.0f}, -{0.69365628604382956f, 0.83406382160707437f, 0.90519031141868522f, 1.0f}, -{0.68396770472895063f, 0.8291426374471359f, 0.90242214532871978f, 1.0f}, -{0.6742791234140717f, 0.82422145328719743f, 0.89965397923875445f, 1.0f}, -{0.66459054209919288f, 0.81930026912725895f, 0.89688581314878901f, 1.0f}, -{0.65490196078431395f, 0.81437908496732048f, 0.89411764705882357f, 1.0f}, -{0.64521337946943502f, 0.80945790080738189f, 0.89134948096885824f, 1.0f}, -{0.6355247981545562f, 0.80453671664744342f, 0.8885813148788928f, 1.0f}, -{0.62583621683967727f, 0.79961553248750494f, 0.88581314878892747f, 1.0f}, -{0.61614763552479834f, 0.79469434832756647f, 0.88304498269896203f, 1.0f}, -{0.60645905420991952f, 0.78977316416762799f, 0.88027681660899659f, 1.0f}, -{0.59677047289504059f, 0.78485198000768952f, 0.87750865051903126f, 1.0f}, -{0.58708189158016166f, 0.77993079584775105f, 0.87474048442906582f, 1.0f}, -{0.57739331026528284f, 0.77500961168781257f, 0.87197231833910038f, 1.0f}, -{0.56647443291041932f, 0.76870434448289149f, 0.86851211072664369f, 1.0f}, -{0.55432525951557154f, 0.7610149942329878f, 0.86435986159169576f, 1.0f}, -{0.5421760861207231f, 0.75332564398308366f, 0.86020761245674748f, 1.0f}, -{0.53002691272587499f, 0.74563629373317974f, 0.85605536332179943f, 1.0f}, -{0.51787773933102677f, 0.73794694348327583f, 0.85190311418685127f, 1.0f}, -{0.50572856593617865f, 0.73025759323337192f, 0.84775086505190322f, 1.0f}, -{0.49357939254133049f, 0.72256824298346811f, 0.84359861591695506f, 1.0f}, -{0.48143021914648232f, 0.7148788927335642f, 0.83944636678200701f, 1.0f}, -{0.46928104575163421f, 0.70718954248366028f, 0.83529411764705885f, 1.0f}, -{0.45713187235678604f, 0.69950019223375637f, 0.8311418685121108f, 1.0f}, -{0.44498269896193787f, 0.69181084198385245f, 0.82698961937716264f, 1.0f}, -{0.43283352556708976f, 0.68412149173394865f, 0.82283737024221459f, 1.0f}, -{0.42068435217224165f, 0.67643214148404474f, 0.81868512110726643f, 1.0f}, -{0.40853517877739348f, 0.66874279123414082f, 0.81453287197231838f, 1.0f}, -{0.39638600538254531f, 0.66105344098423691f, 0.81038062283737022f, 1.0f}, -{0.38423683198769715f, 0.65336409073433299f, 0.80622837370242217f, 1.0f}, -{0.37208765859284904f, 0.64567474048442919f, 0.80207612456747412f, 1.0f}, -{0.3599384851980012f, 0.63798539023452538f, 0.79792387543252608f, 1.0f}, -{0.34778931180315276f, 0.63029603998462136f, 0.7937716262975778f, 1.0f}, -{0.33564013840830459f, 0.62260668973471744f, 0.78961937716262975f, 1.0f}, -{0.32349096501345642f, 0.61491733948481353f, 0.7854671280276817f, 1.0f}, -{0.31134179161860831f, 0.60722798923490962f, 0.78131487889273354f, 1.0f}, -{0.29919261822376014f, 0.5995386389850057f, 0.77716262975778538f, 1.0f}, -{0.28704344482891198f, 0.5918492887351019f, 0.77301038062283733f, 1.0f}, -{0.27489427143406386f, 0.58415993848519798f, 0.76885813148788928f, 1.0f}, -{0.2627450980392157f, 0.57647058823529407f, 0.76470588235294112f, 1.0f}, -{0.25751633986928107f, 0.56955017301038058f, 0.76116878123798537f, 1.0f}, -{0.2522875816993464f, 0.56262975778546709f, 0.75763168012302951f, 1.0f}, -{0.24705882352941178f, 0.5557093425605536f, 0.75409457900807375f, 1.0f}, -{0.24183006535947713f, 0.54878892733564011f, 0.750557477893118f, 1.0f}, -{0.2366013071895425f, 0.54186851211072662f, 0.74702037677816224f, 1.0f}, -{0.23137254901960785f, 0.53494809688581313f, 0.74348327566320638f, 1.0f}, -{0.2261437908496732f, 0.52802768166089964f, 0.73994617454825062f, 1.0f}, -{0.22091503267973872f, 0.52110726643598637f, 0.73640907343329498f, 1.0f}, -{0.21568627450980393f, 0.51418685121107266f, 0.73287197231833912f, 1.0f}, -{0.21045751633986928f, 0.50726643598615917f, 0.72933487120338325f, 1.0f}, -{0.20522875816993463f, 0.50034602076124568f, 0.7257977700884275f, 1.0f}, -{0.20000000000000001f, 0.49342560553633219f, 0.72226066897347174f, 1.0f}, -{0.19477124183006539f, 0.4865051903114187f, 0.71872356785851599f, 1.0f}, -{0.18954248366013071f, 0.47958477508650516f, 0.71518646674356012f, 1.0f}, -{0.18431372549019609f, 0.47266435986159167f, 0.71164936562860437f, 1.0f}, -{0.17908496732026147f, 0.46574394463667823f, 0.70811226451364861f, 1.0f}, -{0.17385620915032682f, 0.45882352941176474f, 0.70457516339869286f, 1.0f}, -{0.16862745098039217f, 0.4519031141868512f, 0.701038062283737f, 1.0f}, -{0.16339869281045752f, 0.44498269896193771f, 0.69750096116878124f, 1.0f}, -{0.15816993464052287f, 0.43806228373702427f, 0.69396386005382549f, 1.0f}, -{0.15294117647058825f, 0.43114186851211078f, 0.69042675893886973f, 1.0f}, -{0.1477124183006536f, 0.42422145328719724f, 0.68688965782391387f, 1.0f}, -{0.14248366013071895f, 0.41730103806228375f, 0.68335255670895811f, 1.0f}, -{0.13725490196078446f, 0.41038062283737042f, 0.67981545559400247f, 1.0f}, -{0.1320261437908497f, 0.40346020761245677f, 0.67627835447904661f, 1.0f}, -{0.12725874663590928f, 0.39584775086505192f, 0.66874279123414071f, 1.0f}, -{0.1229527104959631f, 0.38754325259515571f, 0.65720876585928489f, 1.0f}, -{0.11864667435601693f, 0.37923875432525955f, 0.64567474048442908f, 1.0f}, -{0.11434063821607075f, 0.37093425605536334f, 0.63414071510957326f, 1.0f}, -{0.11003460207612457f, 0.36262975778546713f, 0.62260668973471744f, 1.0f}, -{0.10572856593617841f, 0.35432525951557092f, 0.61107266435986163f, 1.0f}, -{0.10142252979623223f, 0.34602076124567477f, 0.59953863898500581f, 1.0f}, -{0.097116493656286051f, 0.33771626297577856f, 0.58800461361015f, 1.0f}, -{0.092810457516339873f, 0.3294117647058824f, 0.57647058823529418f, 1.0f}, -{0.088504421376393694f, 0.32110726643598619f, 0.56493656286043836f, 1.0f}, -{0.084198385236447529f, 0.31280276816608998f, 0.55340253748558244f, 1.0f}, -{0.07989234909650135f, 0.30449826989619377f, 0.54186851211072662f, 1.0f}, -{0.075586312956555185f, 0.29619377162629756f, 0.5303344867358708f, 1.0f}, -{0.071280276816609006f, 0.28788927335640141f, 0.51880046136101499f, 1.0f}, -{0.066974240676662952f, 0.27958477508650542f, 0.5072664359861595f, 1.0f}, -{0.062668204536716662f, 0.27128027681660905f, 0.49573241061130335f, 1.0f}, -{0.05836216839677047f, 0.26297577854671284f, 0.48419838523644754f, 1.0f}, -{0.054056132256824305f, 0.25467128027681663f, 0.47266435986159172f, 1.0f}, -{0.049750096116878126f, 0.24636678200692042f, 0.4611303344867359f, 1.0f}, -{0.045444059976931961f, 0.23806228373702423f, 0.44959630911188009f, 1.0f}, -{0.041138023836985768f, 0.22975778546712802f, 0.43806228373702422f, 1.0f}, -{0.036831987697039603f, 0.22145328719723184f, 0.4265282583621684f, 1.0f}, -{0.032525951557093424f, 0.21314878892733566f, 0.41499423298731258f, 1.0f}, -{0.028219915417147259f, 0.20484429065743945f, 0.40346020761245677f, 1.0f}, -{0.023913879277201081f, 0.19653979238754324f, 0.3919261822376009f, 1.0f}, -{0.019607843137254902f, 0.18823529411764706f, 0.38039215686274508f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/diverging/RdBu.txt b/extern/tfn/colormaps/diverging/RdBu.txt deleted file mode 100644 index 2e94db9..0000000 --- a/extern/tfn/colormaps/diverging/RdBu.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.40392156862745099, 0.0, 0.12156862745098039, 1.0) -(0.41545559400230681, 0.0036908881199538639, 0.12341407151095732, 1.0) -(0.42698961937716262, 0.0073817762399077278, 0.12525951557093426, 1.0) -(0.43852364475201844, 0.011072664359861591, 0.12710495963091117, 1.0) -(0.45005767012687425, 0.014763552479815456, 0.12895040369088812, 1.0) -(0.46159169550173013, 0.01845444059976932, 0.13079584775086506, 1.0) -(0.47312572087658594, 0.022145328719723183, 0.132641291810842, 1.0) -(0.48465974625144176, 0.025836216839677049, 0.13448673587081891, 1.0) -(0.49619377162629758, 0.029527104959630911, 0.13633217993079585, 1.0) -(0.50772779700115345, 0.033217993079584777, 0.13817762399077277, 1.0) -(0.51926182237600926, 0.03690888119953864, 0.14002306805074971, 1.0) -(0.53079584775086508, 0.040599769319492503, 0.14186851211072665, 1.0) -(0.5423298731257209, 0.044290657439446365, 0.14371395617070359, 1.0) -(0.55386389850057671, 0.047981545559400228, 0.14555940023068051, 1.0) -(0.56539792387543253, 0.051672433679354098, 0.14740484429065745, 1.0) -(0.57693194925028835, 0.05536332179930796, 0.14925028835063436, 1.0) -(0.58846597462514416, 0.059054209919261823, 0.15109573241061131, 1.0) -(0.59999999999999998, 0.062745098039215685, 0.15294117647058825, 1.0) -(0.61153402537485579, 0.066435986159169555, 0.15478662053056519, 1.0) -(0.62306805074971161, 0.070126874279123411, 0.1566320645905421, 1.0) -(0.63460207612456743, 0.07381776239907728, 0.15847750865051904, 1.0) -(0.64613610149942324, 0.077508650519031136, 0.16032295271049596, 1.0) -(0.65767012687427906, 0.081199538638985005, 0.1621683967704729, 1.0) -(0.66920415224913499, 0.084890426758938875, 0.16401384083044984, 1.0) -(0.68073817762399069, 0.088581314878892731, 0.16585928489042678, 1.0) -(0.69227220299884662, 0.092272202998846586, 0.1677047289504037, 1.0) -(0.70080738177623991, 0.099653979238754326, 0.17124183006535948, 1.0) -(0.70634371395617068, 0.11072664359861592, 0.17647058823529413, 1.0) -(0.71188004613610145, 0.12179930795847752, 0.18169934640522878, 1.0) -(0.71741637831603222, 0.13287197231833911, 0.1869281045751634, 1.0) -(0.7229527104959631, 0.14394463667820068, 0.19215686274509805, 1.0) -(0.72848904267589387, 0.15501730103806227, 0.1973856209150327, 1.0) -(0.73402537485582464, 0.16608996539792387, 0.20261437908496732, 1.0) -(0.73956170703575541, 0.17716262975778541, 0.20784313725490194, 1.0) -(0.74509803921568629, 0.18823529411764706, 0.21307189542483659, 1.0) -(0.75063437139561706, 0.19930795847750865, 0.21830065359477124, 1.0) -(0.75617070357554783, 0.21038062283737025, 0.22352941176470587, 1.0) -(0.7617070357554786, 0.22145328719723176, 0.22875816993464049, 1.0) -(0.76724336793540948, 0.23252595155709341, 0.23398692810457516, 1.0) -(0.77277970011534025, 0.243598615916955, 0.23921568627450979, 1.0) -(0.77831603229527102, 0.25467128027681663, 0.24444444444444444, 1.0) -(0.78385236447520179, 0.26574394463667811, 0.24967320261437903, 1.0) -(0.78938869665513267, 0.27681660899653981, 0.25490196078431371, 1.0) -(0.79492502883506344, 0.28788927335640135, 0.26013071895424833, 1.0) -(0.80046136101499421, 0.298961937716263, 0.26535947712418301, 1.0) -(0.80599769319492498, 0.31003460207612449, 0.27058823529411757, 1.0) -(0.81153402537485586, 0.32110726643598619, 0.27581699346405231, 1.0) -(0.81707035755478663, 0.33217993079584773, 0.28104575163398693, 1.0) -(0.8226066897347174, 0.34325259515570933, 0.28627450980392155, 1.0) -(0.82814302191464817, 0.35432525951557087, 0.29150326797385617, 1.0) -(0.83367935409457905, 0.36539792387543252, 0.29673202614379085, 1.0) -(0.83921568627450982, 0.37647058823529411, 0.30196078431372547, 1.0) -(0.84382929642445215, 0.38708189158016149, 0.31011149557862361, 1.0) -(0.84844290657439447, 0.39769319492502875, 0.31826220684352163, 1.0) -(0.8530565167243368, 0.40830449826989618, 0.32641291810841983, 1.0) -(0.85767012687427913, 0.41891580161476355, 0.33456362937331791, 1.0) -(0.86228373702422145, 0.42952710495963087, 0.34271434063821604, 1.0) -(0.86689734717416378, 0.44013840830449813, 0.35086505190311407, 1.0) -(0.87151095732410611, 0.45074971164936561, 0.35901576316801226, 1.0) -(0.87612456747404843, 0.46136101499423293, 0.36716647443291039, 1.0) -(0.88073817762399076, 0.47197231833910031, 0.37531718569780848, 1.0) -(0.88535178777393309, 0.48258362168396757, 0.38346789696270656, 1.0) -(0.88996539792387541, 0.493194925028835, 0.39161860822760469, 1.0) -(0.89457900807381774, 0.50380622837370237, 0.39976931949250283, 1.0) -(0.89919261822376007, 0.51441753171856974, 0.40792003075740091, 1.0) -(0.90380622837370239, 0.52502883506343712, 0.41607074202229904, 1.0) -(0.90841983852364472, 0.53564013840830427, 0.42422145328719701, 1.0) -(0.91303344867358704, 0.54625144175317175, 0.43237216455209526, 1.0) -(0.91764705882352937, 0.55686274509803912, 0.44052287581699334, 1.0) -(0.9222606689734717, 0.5674740484429065, 0.44867358708189148, 1.0) -(0.92687427912341402, 0.57808535178777387, 0.45682429834678961, 1.0) -(0.93148788927335635, 0.58869665513264113, 0.4649750096116877, 1.0) -(0.93610149942329868, 0.59930795847750851, 0.47312572087658578, 1.0) -(0.940715109573241, 0.60991926182237588, 0.48127643214148391, 1.0) -(0.94532871972318333, 0.62053056516724314, 0.48942714340638194, 1.0) -(0.94994232987312566, 0.63114186851211063, 0.49757785467128013, 1.0) -(0.95455594002306798, 0.641753171856978, 0.50572856593617821, 1.0) -(0.95755478662053062, 0.65121107266435974, 0.51510957324106099, 1.0) -(0.95893886966551334, 0.65951557093425595, 0.52572087658592837, 1.0) -(0.96032295271049595, 0.66782006920415216, 0.53633217993079563, 1.0) -(0.96170703575547867, 0.67612456747404837, 0.546943483275663, 1.0) -(0.96309111880046139, 0.68442906574394458, 0.55755478662053037, 1.0) -(0.96447520184544411, 0.69273356401384067, 0.56816608996539764, 1.0) -(0.96585928489042683, 0.701038062283737, 0.57877739331026512, 1.0) -(0.96724336793540944, 0.70934256055363309, 0.58938869665513249, 1.0) -(0.96862745098039216, 0.7176470588235293, 0.59999999999999987, 1.0) -(0.97001153402537488, 0.72595155709342551, 0.61061130334486724, 1.0) -(0.9713956170703576, 0.73425605536332172, 0.62122260668973461, 1.0) -(0.97277970011534032, 0.74256055363321793, 0.63183391003460199, 1.0) -(0.97416378316032293, 0.75086505190311414, 0.64244521337946936, 1.0) -(0.97554786620530565, 0.75916955017301024, 0.65305651672433651, 1.0) -(0.97693194925028837, 0.76747404844290656, 0.66366782006920411, 1.0) -(0.97831603229527109, 0.77577854671280266, 0.67427912341407148, 1.0) -(0.97970011534025381, 0.78408304498269887, 0.68489042675893885, 1.0) -(0.98108419838523653, 0.79238754325259508, 0.69550173010380623, 1.0) -(0.98246828143021914, 0.80069204152249129, 0.7061130334486736, 1.0) -(0.98385236447520186, 0.8089965397923875, 0.71672433679354086, 1.0) -(0.98523644752018458, 0.81730103806228371, 0.72733564013840835, 1.0) -(0.9866205305651673, 0.8256055363321797, 0.7379469434832755, 1.0) -(0.98800461361015002, 0.83391003460207602, 0.74855824682814298, 1.0) -(0.98938869665513263, 0.84221453287197223, 0.75916955017301035, 1.0) -(0.99077277970011535, 0.85051903114186844, 0.76978085351787773, 1.0) -(0.99215686274509807, 0.85882352941176465, 0.7803921568627451, 1.0) -(0.99123414071510962, 0.86312956555171083, 0.78777393310265287, 1.0) -(0.99031141868512118, 0.86743560169165701, 0.79515570934256052, 1.0) -(0.98938869665513263, 0.87174163783160319, 0.80253748558246829, 1.0) -(0.98846597462514418, 0.87604767397154926, 0.80991926182237595, 1.0) -(0.98754325259515574, 0.88035371011149555, 0.81730103806228371, 1.0) -(0.9866205305651673, 0.88465974625144173, 0.82468281430219148, 1.0) -(0.98569780853517874, 0.8889657823913879, 0.83206459054209925, 1.0) -(0.9847750865051903, 0.89327181853133408, 0.8394463667820069, 1.0) -(0.98385236447520186, 0.89757785467128026, 0.84682814302191467, 1.0) -(0.98292964244521341, 0.90188389081122644, 0.85420991926182244, 1.0) -(0.98200692041522497, 0.90618992695117262, 0.86159169550173009, 1.0) -(0.98108419838523653, 0.91049596309111869, 0.86897347174163775, 1.0) -(0.98016147635524797, 0.91480199923106498, 0.87635524798154552, 1.0) -(0.97923875432525953, 0.91910803537101116, 0.88373702422145328, 1.0) -(0.97831603229527109, 0.92341407151095733, 0.89111880046136105, 1.0) -(0.97739331026528264, 0.92772010765090351, 0.89850057670126871, 1.0) -(0.97647058823529409, 0.93202614379084969, 0.90588235294117647, 1.0) -(0.97554786620530565, 0.93633217993079587, 0.91326412918108424, 1.0) -(0.9746251441753172, 0.94063821607074205, 0.92064590542099189, 1.0) -(0.97370242214532876, 0.94494425221068812, 0.92802768166089955, 1.0) -(0.97277970011534021, 0.94925028835063441, 0.93540945790080743, 1.0) -(0.97185697808535176, 0.95355632449058059, 0.94279123414071508, 1.0) -(0.97093425605536332, 0.95786236063052677, 0.95017301038062285, 1.0) -(0.97001153402537488, 0.96216839677047283, 0.95755478662053051, 1.0) -(0.96908881199538643, 0.96647443291041912, 0.96493656286043827, 1.0) -(0.9657054978854287, 0.96724336793540944, 0.96808919646289893, 1.0) -(0.95986159169550178, 0.96447520184544411, 0.96701268742791235, 1.0) -(0.95401768550557475, 0.96170703575547867, 0.96593617839292578, 1.0) -(0.94817377931564784, 0.95893886966551323, 0.96485966935793921, 1.0) -(0.94232987312572103, 0.95617070357554801, 0.96378316032295275, 1.0) -(0.936485966935794, 0.95340253748558246, 0.96270665128796618, 1.0) -(0.93064206074586697, 0.95063437139561713, 0.9616301422529796, 1.0) -(0.92479815455594006, 0.94786620530565169, 0.96055363321799303, 1.0) -(0.91895424836601314, 0.94509803921568636, 0.95947712418300657, 1.0) -(0.91311034217608622, 0.94232987312572092, 0.95840061514802, 1.0) -(0.90726643598615919, 0.93956170703575548, 0.95732410611303342, 1.0) -(0.90142252979623227, 0.93679354094579015, 0.95624759707804696, 1.0) -(0.89557862360630536, 0.93402537485582471, 0.95517108804306039, 1.0) -(0.88973471741637833, 0.93125720876585938, 0.95409457900807382, 1.0) -(0.88389081122645141, 0.92848904267589394, 0.95301806997308725, 1.0) -(0.87804690503652449, 0.92572087658592861, 0.95194156093810078, 1.0) -(0.87220299884659758, 0.92295271049596317, 0.95086505190311421, 1.0) -(0.86635909265667066, 0.92018454440599773, 0.94978854286812764, 1.0) -(0.86051518646674363, 0.9174163783160324, 0.94871203383314107, 1.0) -(0.85467128027681671, 0.91464821222606696, 0.9476355247981546, 1.0) -(0.84882737408688991, 0.91188004613610163, 0.94655901576316803, 1.0) -(0.84298346789696277, 0.90911188004613619, 0.94548250672818146, 1.0) -(0.83713956170703585, 0.90634371395617075, 0.94440599769319489, 1.0) -(0.83129565551710893, 0.90357554786620542, 0.94332948865820843, 1.0) -(0.82545174932718202, 0.90080738177623998, 0.94225297962322185, 1.0) -(0.8196078431372551, 0.89803921568627465, 0.94117647058823528, 1.0) -(0.80991926182237628, 0.89311803152633618, 0.93840830449826995, 1.0) -(0.80023068050749735, 0.8881968473663977, 0.93564013840830451, 1.0) -(0.79054209919261842, 0.88327566320645923, 0.93287197231833918, 1.0) -(0.7808535178777396, 0.87835447904652075, 0.93010380622837374, 1.0) -(0.77116493656286067, 0.87343329488658228, 0.92733564013840841, 1.0) -(0.76147635524798174, 0.8685121107266438, 0.92456747404844297, 1.0) -(0.75178777393310292, 0.86359092656670533, 0.92179930795847753, 1.0) -(0.74209919261822399, 0.85866974240676686, 0.9190311418685122, 1.0) -(0.73241061130334506, 0.85374855824682827, 0.91626297577854676, 1.0) -(0.72272202998846624, 0.8488273740868898, 0.91349480968858143, 1.0) -(0.71303344867358764, 0.84390618992695154, 0.9107266435986161, 1.0) -(0.70334486735870838, 0.83898500576701285, 0.90795847750865055, 1.0) -(0.69365628604382956, 0.83406382160707437, 0.90519031141868522, 1.0) -(0.68396770472895063, 0.8291426374471359, 0.90242214532871978, 1.0) -(0.6742791234140717, 0.82422145328719743, 0.89965397923875445, 1.0) -(0.66459054209919288, 0.81930026912725895, 0.89688581314878901, 1.0) -(0.65490196078431395, 0.81437908496732048, 0.89411764705882357, 1.0) -(0.64521337946943502, 0.80945790080738189, 0.89134948096885824, 1.0) -(0.6355247981545562, 0.80453671664744342, 0.8885813148788928, 1.0) -(0.62583621683967727, 0.79961553248750494, 0.88581314878892747, 1.0) -(0.61614763552479834, 0.79469434832756647, 0.88304498269896203, 1.0) -(0.60645905420991952, 0.78977316416762799, 0.88027681660899659, 1.0) -(0.59677047289504059, 0.78485198000768952, 0.87750865051903126, 1.0) -(0.58708189158016166, 0.77993079584775105, 0.87474048442906582, 1.0) -(0.57739331026528284, 0.77500961168781257, 0.87197231833910038, 1.0) -(0.56647443291041932, 0.76870434448289149, 0.86851211072664369, 1.0) -(0.55432525951557154, 0.7610149942329878, 0.86435986159169576, 1.0) -(0.5421760861207231, 0.75332564398308366, 0.86020761245674748, 1.0) -(0.53002691272587499, 0.74563629373317974, 0.85605536332179943, 1.0) -(0.51787773933102677, 0.73794694348327583, 0.85190311418685127, 1.0) -(0.50572856593617865, 0.73025759323337192, 0.84775086505190322, 1.0) -(0.49357939254133049, 0.72256824298346811, 0.84359861591695506, 1.0) -(0.48143021914648232, 0.7148788927335642, 0.83944636678200701, 1.0) -(0.46928104575163421, 0.70718954248366028, 0.83529411764705885, 1.0) -(0.45713187235678604, 0.69950019223375637, 0.8311418685121108, 1.0) -(0.44498269896193787, 0.69181084198385245, 0.82698961937716264, 1.0) -(0.43283352556708976, 0.68412149173394865, 0.82283737024221459, 1.0) -(0.42068435217224165, 0.67643214148404474, 0.81868512110726643, 1.0) -(0.40853517877739348, 0.66874279123414082, 0.81453287197231838, 1.0) -(0.39638600538254531, 0.66105344098423691, 0.81038062283737022, 1.0) -(0.38423683198769715, 0.65336409073433299, 0.80622837370242217, 1.0) -(0.37208765859284904, 0.64567474048442919, 0.80207612456747412, 1.0) -(0.3599384851980012, 0.63798539023452538, 0.79792387543252608, 1.0) -(0.34778931180315276, 0.63029603998462136, 0.7937716262975778, 1.0) -(0.33564013840830459, 0.62260668973471744, 0.78961937716262975, 1.0) -(0.32349096501345642, 0.61491733948481353, 0.7854671280276817, 1.0) -(0.31134179161860831, 0.60722798923490962, 0.78131487889273354, 1.0) -(0.29919261822376014, 0.5995386389850057, 0.77716262975778538, 1.0) -(0.28704344482891198, 0.5918492887351019, 0.77301038062283733, 1.0) -(0.27489427143406386, 0.58415993848519798, 0.76885813148788928, 1.0) -(0.2627450980392157, 0.57647058823529407, 0.76470588235294112, 1.0) -(0.25751633986928107, 0.56955017301038058, 0.76116878123798537, 1.0) -(0.2522875816993464, 0.56262975778546709, 0.75763168012302951, 1.0) -(0.24705882352941178, 0.5557093425605536, 0.75409457900807375, 1.0) -(0.24183006535947713, 0.54878892733564011, 0.750557477893118, 1.0) -(0.2366013071895425, 0.54186851211072662, 0.74702037677816224, 1.0) -(0.23137254901960785, 0.53494809688581313, 0.74348327566320638, 1.0) -(0.2261437908496732, 0.52802768166089964, 0.73994617454825062, 1.0) -(0.22091503267973872, 0.52110726643598637, 0.73640907343329498, 1.0) -(0.21568627450980393, 0.51418685121107266, 0.73287197231833912, 1.0) -(0.21045751633986928, 0.50726643598615917, 0.72933487120338325, 1.0) -(0.20522875816993463, 0.50034602076124568, 0.7257977700884275, 1.0) -(0.20000000000000001, 0.49342560553633219, 0.72226066897347174, 1.0) -(0.19477124183006539, 0.4865051903114187, 0.71872356785851599, 1.0) -(0.18954248366013071, 0.47958477508650516, 0.71518646674356012, 1.0) -(0.18431372549019609, 0.47266435986159167, 0.71164936562860437, 1.0) -(0.17908496732026147, 0.46574394463667823, 0.70811226451364861, 1.0) -(0.17385620915032682, 0.45882352941176474, 0.70457516339869286, 1.0) -(0.16862745098039217, 0.4519031141868512, 0.701038062283737, 1.0) -(0.16339869281045752, 0.44498269896193771, 0.69750096116878124, 1.0) -(0.15816993464052287, 0.43806228373702427, 0.69396386005382549, 1.0) -(0.15294117647058825, 0.43114186851211078, 0.69042675893886973, 1.0) -(0.1477124183006536, 0.42422145328719724, 0.68688965782391387, 1.0) -(0.14248366013071895, 0.41730103806228375, 0.68335255670895811, 1.0) -(0.13725490196078446, 0.41038062283737042, 0.67981545559400247, 1.0) -(0.1320261437908497, 0.40346020761245677, 0.67627835447904661, 1.0) -(0.12725874663590928, 0.39584775086505192, 0.66874279123414071, 1.0) -(0.1229527104959631, 0.38754325259515571, 0.65720876585928489, 1.0) -(0.11864667435601693, 0.37923875432525955, 0.64567474048442908, 1.0) -(0.11434063821607075, 0.37093425605536334, 0.63414071510957326, 1.0) -(0.11003460207612457, 0.36262975778546713, 0.62260668973471744, 1.0) -(0.10572856593617841, 0.35432525951557092, 0.61107266435986163, 1.0) -(0.10142252979623223, 0.34602076124567477, 0.59953863898500581, 1.0) -(0.097116493656286051, 0.33771626297577856, 0.58800461361015, 1.0) -(0.092810457516339873, 0.3294117647058824, 0.57647058823529418, 1.0) -(0.088504421376393694, 0.32110726643598619, 0.56493656286043836, 1.0) -(0.084198385236447529, 0.31280276816608998, 0.55340253748558244, 1.0) -(0.07989234909650135, 0.30449826989619377, 0.54186851211072662, 1.0) -(0.075586312956555185, 0.29619377162629756, 0.5303344867358708, 1.0) -(0.071280276816609006, 0.28788927335640141, 0.51880046136101499, 1.0) -(0.066974240676662952, 0.27958477508650542, 0.5072664359861595, 1.0) -(0.062668204536716662, 0.27128027681660905, 0.49573241061130335, 1.0) -(0.05836216839677047, 0.26297577854671284, 0.48419838523644754, 1.0) -(0.054056132256824305, 0.25467128027681663, 0.47266435986159172, 1.0) -(0.049750096116878126, 0.24636678200692042, 0.4611303344867359, 1.0) -(0.045444059976931961, 0.23806228373702423, 0.44959630911188009, 1.0) -(0.041138023836985768, 0.22975778546712802, 0.43806228373702422, 1.0) -(0.036831987697039603, 0.22145328719723184, 0.4265282583621684, 1.0) -(0.032525951557093424, 0.21314878892733566, 0.41499423298731258, 1.0) -(0.028219915417147259, 0.20484429065743945, 0.40346020761245677, 1.0) -(0.023913879277201081, 0.19653979238754324, 0.3919261822376009, 1.0) -(0.019607843137254902, 0.18823529411764706, 0.38039215686274508, 1.0) diff --git a/extern/tfn/colormaps/diverging/RdGy.cpp b/extern/tfn/colormaps/diverging/RdGy.cpp deleted file mode 100644 index 3263a56..0000000 --- a/extern/tfn/colormaps/diverging/RdGy.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_diverging_RdGy; -} -const std::vector colormap::data_diverging_RdGy = /* NOLINT(cert-err58-cpp) */ -{ -{0.40392156862745099f, 0.0f, 0.12156862745098039f, 1.0f}, -{0.41545559400230681f, 0.0036908881199538639f, 0.12341407151095732f, 1.0f}, -{0.42698961937716262f, 0.0073817762399077278f, 0.12525951557093426f, 1.0f}, -{0.43852364475201844f, 0.011072664359861591f, 0.12710495963091117f, 1.0f}, -{0.45005767012687425f, 0.014763552479815456f, 0.12895040369088812f, 1.0f}, -{0.46159169550173013f, 0.01845444059976932f, 0.13079584775086506f, 1.0f}, -{0.47312572087658594f, 0.022145328719723183f, 0.132641291810842f, 1.0f}, -{0.48465974625144176f, 0.025836216839677049f, 0.13448673587081891f, 1.0f}, -{0.49619377162629758f, 0.029527104959630911f, 0.13633217993079585f, 1.0f}, -{0.50772779700115345f, 0.033217993079584777f, 0.13817762399077277f, 1.0f}, -{0.51926182237600926f, 0.03690888119953864f, 0.14002306805074971f, 1.0f}, -{0.53079584775086508f, 0.040599769319492503f, 0.14186851211072665f, 1.0f}, -{0.5423298731257209f, 0.044290657439446365f, 0.14371395617070359f, 1.0f}, -{0.55386389850057671f, 0.047981545559400228f, 0.14555940023068051f, 1.0f}, -{0.56539792387543253f, 0.051672433679354098f, 0.14740484429065745f, 1.0f}, -{0.57693194925028835f, 0.05536332179930796f, 0.14925028835063436f, 1.0f}, -{0.58846597462514416f, 0.059054209919261823f, 0.15109573241061131f, 1.0f}, -{0.59999999999999998f, 0.062745098039215685f, 0.15294117647058825f, 1.0f}, -{0.61153402537485579f, 0.066435986159169555f, 0.15478662053056519f, 1.0f}, -{0.62306805074971161f, 0.070126874279123411f, 0.1566320645905421f, 1.0f}, -{0.63460207612456743f, 0.07381776239907728f, 0.15847750865051904f, 1.0f}, -{0.64613610149942324f, 0.077508650519031136f, 0.16032295271049596f, 1.0f}, -{0.65767012687427906f, 0.081199538638985005f, 0.1621683967704729f, 1.0f}, -{0.66920415224913499f, 0.084890426758938875f, 0.16401384083044984f, 1.0f}, -{0.68073817762399069f, 0.088581314878892731f, 0.16585928489042678f, 1.0f}, -{0.69227220299884662f, 0.092272202998846586f, 0.1677047289504037f, 1.0f}, -{0.70080738177623991f, 0.099653979238754326f, 0.17124183006535948f, 1.0f}, -{0.70634371395617068f, 0.11072664359861592f, 0.17647058823529413f, 1.0f}, -{0.71188004613610145f, 0.12179930795847752f, 0.18169934640522878f, 1.0f}, -{0.71741637831603222f, 0.13287197231833911f, 0.1869281045751634f, 1.0f}, -{0.7229527104959631f, 0.14394463667820068f, 0.19215686274509805f, 1.0f}, -{0.72848904267589387f, 0.15501730103806227f, 0.1973856209150327f, 1.0f}, -{0.73402537485582464f, 0.16608996539792387f, 0.20261437908496732f, 1.0f}, -{0.73956170703575541f, 0.17716262975778541f, 0.20784313725490194f, 1.0f}, -{0.74509803921568629f, 0.18823529411764706f, 0.21307189542483659f, 1.0f}, -{0.75063437139561706f, 0.19930795847750865f, 0.21830065359477124f, 1.0f}, -{0.75617070357554783f, 0.21038062283737025f, 0.22352941176470587f, 1.0f}, -{0.7617070357554786f, 0.22145328719723176f, 0.22875816993464049f, 1.0f}, -{0.76724336793540948f, 0.23252595155709341f, 0.23398692810457516f, 1.0f}, -{0.77277970011534025f, 0.243598615916955f, 0.23921568627450979f, 1.0f}, -{0.77831603229527102f, 0.25467128027681663f, 0.24444444444444444f, 1.0f}, -{0.78385236447520179f, 0.26574394463667811f, 0.24967320261437903f, 1.0f}, -{0.78938869665513267f, 0.27681660899653981f, 0.25490196078431371f, 1.0f}, -{0.79492502883506344f, 0.28788927335640135f, 0.26013071895424833f, 1.0f}, -{0.80046136101499421f, 0.298961937716263f, 0.26535947712418301f, 1.0f}, -{0.80599769319492498f, 0.31003460207612449f, 0.27058823529411757f, 1.0f}, -{0.81153402537485586f, 0.32110726643598619f, 0.27581699346405231f, 1.0f}, -{0.81707035755478663f, 0.33217993079584773f, 0.28104575163398693f, 1.0f}, -{0.8226066897347174f, 0.34325259515570933f, 0.28627450980392155f, 1.0f}, -{0.82814302191464817f, 0.35432525951557087f, 0.29150326797385617f, 1.0f}, -{0.83367935409457905f, 0.36539792387543252f, 0.29673202614379085f, 1.0f}, -{0.83921568627450982f, 0.37647058823529411f, 0.30196078431372547f, 1.0f}, -{0.84382929642445215f, 0.38708189158016149f, 0.31011149557862361f, 1.0f}, -{0.84844290657439447f, 0.39769319492502875f, 0.31826220684352163f, 1.0f}, -{0.8530565167243368f, 0.40830449826989618f, 0.32641291810841983f, 1.0f}, -{0.85767012687427913f, 0.41891580161476355f, 0.33456362937331791f, 1.0f}, -{0.86228373702422145f, 0.42952710495963087f, 0.34271434063821604f, 1.0f}, -{0.86689734717416378f, 0.44013840830449813f, 0.35086505190311407f, 1.0f}, -{0.87151095732410611f, 0.45074971164936561f, 0.35901576316801226f, 1.0f}, -{0.87612456747404843f, 0.46136101499423293f, 0.36716647443291039f, 1.0f}, -{0.88073817762399076f, 0.47197231833910031f, 0.37531718569780848f, 1.0f}, -{0.88535178777393309f, 0.48258362168396757f, 0.38346789696270656f, 1.0f}, -{0.88996539792387541f, 0.493194925028835f, 0.39161860822760469f, 1.0f}, -{0.89457900807381774f, 0.50380622837370237f, 0.39976931949250283f, 1.0f}, -{0.89919261822376007f, 0.51441753171856974f, 0.40792003075740091f, 1.0f}, -{0.90380622837370239f, 0.52502883506343712f, 0.41607074202229904f, 1.0f}, -{0.90841983852364472f, 0.53564013840830427f, 0.42422145328719701f, 1.0f}, -{0.91303344867358704f, 0.54625144175317175f, 0.43237216455209526f, 1.0f}, -{0.91764705882352937f, 0.55686274509803912f, 0.44052287581699334f, 1.0f}, -{0.9222606689734717f, 0.5674740484429065f, 0.44867358708189148f, 1.0f}, -{0.92687427912341402f, 0.57808535178777387f, 0.45682429834678961f, 1.0f}, -{0.93148788927335635f, 0.58869665513264113f, 0.4649750096116877f, 1.0f}, -{0.93610149942329868f, 0.59930795847750851f, 0.47312572087658578f, 1.0f}, -{0.940715109573241f, 0.60991926182237588f, 0.48127643214148391f, 1.0f}, -{0.94532871972318333f, 0.62053056516724314f, 0.48942714340638194f, 1.0f}, -{0.94994232987312566f, 0.63114186851211063f, 0.49757785467128013f, 1.0f}, -{0.95455594002306798f, 0.641753171856978f, 0.50572856593617821f, 1.0f}, -{0.95755478662053062f, 0.65121107266435974f, 0.51510957324106099f, 1.0f}, -{0.95893886966551334f, 0.65951557093425595f, 0.52572087658592837f, 1.0f}, -{0.96032295271049595f, 0.66782006920415216f, 0.53633217993079563f, 1.0f}, -{0.96170703575547867f, 0.67612456747404837f, 0.546943483275663f, 1.0f}, -{0.96309111880046139f, 0.68442906574394458f, 0.55755478662053037f, 1.0f}, -{0.96447520184544411f, 0.69273356401384067f, 0.56816608996539764f, 1.0f}, -{0.96585928489042683f, 0.701038062283737f, 0.57877739331026512f, 1.0f}, -{0.96724336793540944f, 0.70934256055363309f, 0.58938869665513249f, 1.0f}, -{0.96862745098039216f, 0.7176470588235293f, 0.59999999999999987f, 1.0f}, -{0.97001153402537488f, 0.72595155709342551f, 0.61061130334486724f, 1.0f}, -{0.9713956170703576f, 0.73425605536332172f, 0.62122260668973461f, 1.0f}, -{0.97277970011534032f, 0.74256055363321793f, 0.63183391003460199f, 1.0f}, -{0.97416378316032293f, 0.75086505190311414f, 0.64244521337946936f, 1.0f}, -{0.97554786620530565f, 0.75916955017301024f, 0.65305651672433651f, 1.0f}, -{0.97693194925028837f, 0.76747404844290656f, 0.66366782006920411f, 1.0f}, -{0.97831603229527109f, 0.77577854671280266f, 0.67427912341407148f, 1.0f}, -{0.97970011534025381f, 0.78408304498269887f, 0.68489042675893885f, 1.0f}, -{0.98108419838523653f, 0.79238754325259508f, 0.69550173010380623f, 1.0f}, -{0.98246828143021914f, 0.80069204152249129f, 0.7061130334486736f, 1.0f}, -{0.98385236447520186f, 0.8089965397923875f, 0.71672433679354086f, 1.0f}, -{0.98523644752018458f, 0.81730103806228371f, 0.72733564013840835f, 1.0f}, -{0.9866205305651673f, 0.8256055363321797f, 0.7379469434832755f, 1.0f}, -{0.98800461361015002f, 0.83391003460207602f, 0.74855824682814298f, 1.0f}, -{0.98938869665513263f, 0.84221453287197223f, 0.75916955017301035f, 1.0f}, -{0.99077277970011535f, 0.85051903114186844f, 0.76978085351787773f, 1.0f}, -{0.99215686274509807f, 0.85882352941176465f, 0.7803921568627451f, 1.0f}, -{0.99246443675509421f, 0.86435986159169542f, 0.78900422914263746f, 1.0f}, -{0.99277201076509036f, 0.8698961937716263f, 0.79761630142252982f, 1.0f}, -{0.99307958477508651f, 0.87543252595155707f, 0.80622837370242217f, 1.0f}, -{0.99338715878508266f, 0.88096885813148773f, 0.81484044598231442f, 1.0f}, -{0.99369473279507881f, 0.88650519031141861f, 0.82345251826220689f, 1.0f}, -{0.99400230680507495f, 0.89204152249134938f, 0.83206459054209914f, 1.0f}, -{0.9943098808150711f, 0.89757785467128026f, 0.84067666282199149f, 1.0f}, -{0.99461745482506725f, 0.90311418685121103f, 0.84928873510188385f, 1.0f}, -{0.99492502883506351f, 0.9086505190311418f, 0.85790080738177621f, 1.0f}, -{0.99523260284505966f, 0.91418685121107268f, 0.86651287966166857f, 1.0f}, -{0.9955401768550558f, 0.91972318339100345f, 0.87512495194156092f, 1.0f}, -{0.99584775086505195f, 0.92525951557093411f, 0.88373702422145317f, 1.0f}, -{0.9961553248750481f, 0.93079584775086499f, 0.89234909650134564f, 1.0f}, -{0.99646289888504425f, 0.93633217993079587f, 0.900961168781238f, 1.0f}, -{0.99677047289504039f, 0.94186851211072664f, 0.90957324106113036f, 1.0f}, -{0.99707804690503654f, 0.94740484429065741f, 0.91818531334102271f, 1.0f}, -{0.99738562091503269f, 0.95294117647058818f, 0.92679738562091507f, 1.0f}, -{0.99769319492502884f, 0.95847750865051906f, 0.93540945790080743f, 1.0f}, -{0.99800076893502498f, 0.96401384083044983f, 0.94402153018069979f, 1.0f}, -{0.99830834294502113f, 0.96955017301038049f, 0.95263360246059192f, 1.0f}, -{0.99861591695501728f, 0.97508650519031137f, 0.96124567474048439f, 1.0f}, -{0.99892349096501343f, 0.98062283737024225f, 0.96985774702037675f, 1.0f}, -{0.99923106497500958f, 0.98615916955017302f, 0.97846981930026911f, 1.0f}, -{0.99953863898500572f, 0.99169550173010379f, 0.98708189158016146f, 1.0f}, -{0.99984621299500187f, 0.99723183391003456f, 0.99569396386005382f, 1.0f}, -{0.99761630142252977f, 0.99761630142252977f, 0.99761630142252977f, 1.0f}, -{0.99284890426758943f, 0.99284890426758943f, 0.99284890426758943f, 1.0f}, -{0.98808150711264897f, 0.98808150711264897f, 0.98808150711264897f, 1.0f}, -{0.98331410995770863f, 0.98331410995770863f, 0.98331410995770863f, 1.0f}, -{0.97854671280276828f, 0.97854671280276828f, 0.97854671280276828f, 1.0f}, -{0.97377931564782783f, 0.97377931564782783f, 0.97377931564782783f, 1.0f}, -{0.96901191849288737f, 0.96901191849288737f, 0.96901191849288737f, 1.0f}, -{0.96424452133794702f, 0.96424452133794702f, 0.96424452133794702f, 1.0f}, -{0.95947712418300657f, 0.95947712418300657f, 0.95947712418300657f, 1.0f}, -{0.95470972702806622f, 0.95470972702806622f, 0.95470972702806622f, 1.0f}, -{0.94994232987312577f, 0.94994232987312577f, 0.94994232987312577f, 1.0f}, -{0.94517493271818531f, 0.94517493271818531f, 0.94517493271818531f, 1.0f}, -{0.94040753556324497f, 0.94040753556324497f, 0.94040753556324497f, 1.0f}, -{0.93564013840830451f, 0.93564013840830451f, 0.93564013840830451f, 1.0f}, -{0.93087274125336417f, 0.93087274125336417f, 0.93087274125336417f, 1.0f}, -{0.92610534409842371f, 0.92610534409842371f, 0.92610534409842371f, 1.0f}, -{0.92133794694348337f, 0.92133794694348337f, 0.92133794694348337f, 1.0f}, -{0.91657054978854291f, 0.91657054978854291f, 0.91657054978854291f, 1.0f}, -{0.91180315263360256f, 0.91180315263360256f, 0.91180315263360256f, 1.0f}, -{0.90703575547866211f, 0.90703575547866211f, 0.90703575547866211f, 1.0f}, -{0.90226835832372188f, 0.90226835832372188f, 0.90226835832372188f, 1.0f}, -{0.89750096116878131f, 0.89750096116878131f, 0.89750096116878131f, 1.0f}, -{0.89273356401384096f, 0.89273356401384096f, 0.89273356401384096f, 1.0f}, -{0.88796616685890051f, 0.88796616685890051f, 0.88796616685890051f, 1.0f}, -{0.88319876970396016f, 0.88319876970396016f, 0.88319876970396016f, 1.0f}, -{0.87843137254901971f, 0.87843137254901971f, 0.87843137254901971f, 1.0f}, -{0.87258746635909279f, 0.87258746635909279f, 0.87258746635909279f, 1.0f}, -{0.86674356016916587f, 0.86674356016916587f, 0.86674356016916587f, 1.0f}, -{0.86089965397923895f, 0.86089965397923895f, 0.86089965397923895f, 1.0f}, -{0.85505574778931193f, 0.85505574778931193f, 0.85505574778931193f, 1.0f}, -{0.84921184159938501f, 0.84921184159938501f, 0.84921184159938501f, 1.0f}, -{0.84336793540945809f, 0.84336793540945809f, 0.84336793540945809f, 1.0f}, -{0.83752402921953106f, 0.83752402921953106f, 0.83752402921953106f, 1.0f}, -{0.83168012302960415f, 0.83168012302960415f, 0.83168012302960415f, 1.0f}, -{0.82583621683967723f, 0.82583621683967723f, 0.82583621683967723f, 1.0f}, -{0.8199923106497502f, 0.8199923106497502f, 0.8199923106497502f, 1.0f}, -{0.8141484044598235f, 0.8141484044598235f, 0.8141484044598235f, 1.0f}, -{0.80830449826989637f, 0.80830449826989637f, 0.80830449826989637f, 1.0f}, -{0.80246059207996945f, 0.80246059207996945f, 0.80246059207996945f, 1.0f}, -{0.79661668589004242f, 0.79661668589004242f, 0.79661668589004242f, 1.0f}, -{0.7907727797001155f, 0.7907727797001155f, 0.7907727797001155f, 1.0f}, -{0.78492887351018847f, 0.78492887351018847f, 0.78492887351018847f, 1.0f}, -{0.77908496732026156f, 0.77908496732026156f, 0.77908496732026156f, 1.0f}, -{0.77324106113033464f, 0.77324106113033464f, 0.77324106113033464f, 1.0f}, -{0.76739715494040772f, 0.76739715494040772f, 0.76739715494040772f, 1.0f}, -{0.76155324875048069f, 0.76155324875048069f, 0.76155324875048069f, 1.0f}, -{0.75570934256055378f, 0.75570934256055378f, 0.75570934256055378f, 1.0f}, -{0.74986543637062675f, 0.74986543637062675f, 0.74986543637062675f, 1.0f}, -{0.74402153018069983f, 0.74402153018069983f, 0.74402153018069983f, 1.0f}, -{0.73817762399077291f, 0.73817762399077291f, 0.73817762399077291f, 1.0f}, -{0.732333717800846f, 0.732333717800846f, 0.732333717800846f, 1.0f}, -{0.72549019607843157f, 0.72549019607843157f, 0.72549019607843157f, 1.0f}, -{0.71764705882352986f, 0.71764705882352986f, 0.71764705882352986f, 1.0f}, -{0.70980392156862759f, 0.70980392156862759f, 0.70980392156862759f, 1.0f}, -{0.70196078431372566f, 0.70196078431372566f, 0.70196078431372566f, 1.0f}, -{0.69411764705882373f, 0.69411764705882373f, 0.69411764705882373f, 1.0f}, -{0.68627450980392168f, 0.68627450980392168f, 0.68627450980392168f, 1.0f}, -{0.67843137254901975f, 0.67843137254901975f, 0.67843137254901975f, 1.0f}, -{0.67058823529411782f, 0.67058823529411782f, 0.67058823529411782f, 1.0f}, -{0.66274509803921577f, 0.66274509803921577f, 0.66274509803921577f, 1.0f}, -{0.65490196078431384f, 0.65490196078431384f, 0.65490196078431384f, 1.0f}, -{0.64705882352941191f, 0.64705882352941191f, 0.64705882352941191f, 1.0f}, -{0.63921568627450986f, 0.63921568627450986f, 0.63921568627450986f, 1.0f}, -{0.63137254901960793f, 0.63137254901960793f, 0.63137254901960793f, 1.0f}, -{0.623529411764706f, 0.623529411764706f, 0.623529411764706f, 1.0f}, -{0.61568627450980395f, 0.61568627450980395f, 0.61568627450980395f, 1.0f}, -{0.60784313725490202f, 0.60784313725490202f, 0.60784313725490202f, 1.0f}, -{0.60000000000000009f, 0.60000000000000009f, 0.60000000000000009f, 1.0f}, -{0.59215686274509838f, 0.59215686274509838f, 0.59215686274509838f, 1.0f}, -{0.58431372549019611f, 0.58431372549019611f, 0.58431372549019611f, 1.0f}, -{0.57647058823529418f, 0.57647058823529418f, 0.57647058823529418f, 1.0f}, -{0.56862745098039214f, 0.56862745098039214f, 0.56862745098039214f, 1.0f}, -{0.5607843137254902f, 0.5607843137254902f, 0.5607843137254902f, 1.0f}, -{0.55294117647058827f, 0.55294117647058827f, 0.55294117647058827f, 1.0f}, -{0.54509803921568634f, 0.54509803921568634f, 0.54509803921568634f, 1.0f}, -{0.5372549019607844f, 0.5372549019607844f, 0.5372549019607844f, 1.0f}, -{0.52941176470588236f, 0.52941176470588236f, 0.52941176470588236f, 1.0f}, -{0.52049211841599385f, 0.52049211841599385f, 0.52049211841599385f, 1.0f}, -{0.51157247212610535f, 0.51157247212610535f, 0.51157247212610535f, 1.0f}, -{0.50265282583621684f, 0.50265282583621684f, 0.50265282583621684f, 1.0f}, -{0.49373317954632834f, 0.49373317954632834f, 0.49373317954632834f, 1.0f}, -{0.48481353325643983f, 0.48481353325643983f, 0.48481353325643983f, 1.0f}, -{0.47589388696655133f, 0.47589388696655133f, 0.47589388696655133f, 1.0f}, -{0.46697424067666282f, 0.46697424067666282f, 0.46697424067666282f, 1.0f}, -{0.45805459438677454f, 0.45805459438677454f, 0.45805459438677454f, 1.0f}, -{0.44913494809688581f, 0.44913494809688581f, 0.44913494809688581f, 1.0f}, -{0.44021530180699731f, 0.44021530180699731f, 0.44021530180699731f, 1.0f}, -{0.4312956555171088f, 0.4312956555171088f, 0.4312956555171088f, 1.0f}, -{0.42237600922722029f, 0.42237600922722029f, 0.42237600922722029f, 1.0f}, -{0.41345636293733179f, 0.41345636293733179f, 0.41345636293733179f, 1.0f}, -{0.40453671664744328f, 0.40453671664744328f, 0.40453671664744328f, 1.0f}, -{0.39561707035755478f, 0.39561707035755478f, 0.39561707035755478f, 1.0f}, -{0.38669742406766627f, 0.38669742406766627f, 0.38669742406766627f, 1.0f}, -{0.37777777777777777f, 0.37777777777777777f, 0.37777777777777777f, 1.0f}, -{0.36885813148788926f, 0.36885813148788926f, 0.36885813148788926f, 1.0f}, -{0.35993848519800076f, 0.35993848519800076f, 0.35993848519800076f, 1.0f}, -{0.35101883890811225f, 0.35101883890811225f, 0.35101883890811225f, 1.0f}, -{0.34209919261822375f, 0.34209919261822375f, 0.34209919261822375f, 1.0f}, -{0.33317954632833524f, 0.33317954632833524f, 0.33317954632833524f, 1.0f}, -{0.32425990003844674f, 0.32425990003844674f, 0.32425990003844674f, 1.0f}, -{0.31534025374855845f, 0.31534025374855845f, 0.31534025374855845f, 1.0f}, -{0.30642060745866972f, 0.30642060745866972f, 0.30642060745866972f, 1.0f}, -{0.29803921568627451f, 0.29803921568627451f, 0.29803921568627451f, 1.0f}, -{0.29019607843137252f, 0.29019607843137252f, 0.29019607843137252f, 1.0f}, -{0.28235294117647058f, 0.28235294117647058f, 0.28235294117647058f, 1.0f}, -{0.2745098039215686f, 0.2745098039215686f, 0.2745098039215686f, 1.0f}, -{0.26666666666666666f, 0.26666666666666666f, 0.26666666666666666f, 1.0f}, -{0.25882352941176467f, 0.25882352941176467f, 0.25882352941176467f, 1.0f}, -{0.25098039215686274f, 0.25098039215686274f, 0.25098039215686274f, 1.0f}, -{0.24313725490196075f, 0.24313725490196075f, 0.24313725490196075f, 1.0f}, -{0.23529411764705882f, 0.23529411764705882f, 0.23529411764705882f, 1.0f}, -{0.22745098039215683f, 0.22745098039215683f, 0.22745098039215683f, 1.0f}, -{0.2196078431372549f, 0.2196078431372549f, 0.2196078431372549f, 1.0f}, -{0.21176470588235291f, 0.21176470588235291f, 0.21176470588235291f, 1.0f}, -{0.20392156862745098f, 0.20392156862745098f, 0.20392156862745098f, 1.0f}, -{0.19607843137254899f, 0.19607843137254899f, 0.19607843137254899f, 1.0f}, -{0.18823529411764728f, 0.18823529411764728f, 0.18823529411764728f, 1.0f}, -{0.1803921568627451f, 0.1803921568627451f, 0.1803921568627451f, 1.0f}, -{0.17254901960784313f, 0.17254901960784313f, 0.17254901960784313f, 1.0f}, -{0.16470588235294117f, 0.16470588235294117f, 0.16470588235294117f, 1.0f}, -{0.15686274509803921f, 0.15686274509803921f, 0.15686274509803921f, 1.0f}, -{0.14901960784313725f, 0.14901960784313725f, 0.14901960784313725f, 1.0f}, -{0.14117647058823529f, 0.14117647058823529f, 0.14117647058823529f, 1.0f}, -{0.13333333333333333f, 0.13333333333333333f, 0.13333333333333333f, 1.0f}, -{0.12549019607843137f, 0.12549019607843137f, 0.12549019607843137f, 1.0f}, -{0.11764705882352941f, 0.11764705882352941f, 0.11764705882352941f, 1.0f}, -{0.10980392156862745f, 0.10980392156862745f, 0.10980392156862745f, 1.0f}, -{0.10196078431372549f, 0.10196078431372549f, 0.10196078431372549f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/diverging/RdGy.txt b/extern/tfn/colormaps/diverging/RdGy.txt deleted file mode 100644 index 15d6df1..0000000 --- a/extern/tfn/colormaps/diverging/RdGy.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.40392156862745099, 0.0, 0.12156862745098039, 1.0) -(0.41545559400230681, 0.0036908881199538639, 0.12341407151095732, 1.0) -(0.42698961937716262, 0.0073817762399077278, 0.12525951557093426, 1.0) -(0.43852364475201844, 0.011072664359861591, 0.12710495963091117, 1.0) -(0.45005767012687425, 0.014763552479815456, 0.12895040369088812, 1.0) -(0.46159169550173013, 0.01845444059976932, 0.13079584775086506, 1.0) -(0.47312572087658594, 0.022145328719723183, 0.132641291810842, 1.0) -(0.48465974625144176, 0.025836216839677049, 0.13448673587081891, 1.0) -(0.49619377162629758, 0.029527104959630911, 0.13633217993079585, 1.0) -(0.50772779700115345, 0.033217993079584777, 0.13817762399077277, 1.0) -(0.51926182237600926, 0.03690888119953864, 0.14002306805074971, 1.0) -(0.53079584775086508, 0.040599769319492503, 0.14186851211072665, 1.0) -(0.5423298731257209, 0.044290657439446365, 0.14371395617070359, 1.0) -(0.55386389850057671, 0.047981545559400228, 0.14555940023068051, 1.0) -(0.56539792387543253, 0.051672433679354098, 0.14740484429065745, 1.0) -(0.57693194925028835, 0.05536332179930796, 0.14925028835063436, 1.0) -(0.58846597462514416, 0.059054209919261823, 0.15109573241061131, 1.0) -(0.59999999999999998, 0.062745098039215685, 0.15294117647058825, 1.0) -(0.61153402537485579, 0.066435986159169555, 0.15478662053056519, 1.0) -(0.62306805074971161, 0.070126874279123411, 0.1566320645905421, 1.0) -(0.63460207612456743, 0.07381776239907728, 0.15847750865051904, 1.0) -(0.64613610149942324, 0.077508650519031136, 0.16032295271049596, 1.0) -(0.65767012687427906, 0.081199538638985005, 0.1621683967704729, 1.0) -(0.66920415224913499, 0.084890426758938875, 0.16401384083044984, 1.0) -(0.68073817762399069, 0.088581314878892731, 0.16585928489042678, 1.0) -(0.69227220299884662, 0.092272202998846586, 0.1677047289504037, 1.0) -(0.70080738177623991, 0.099653979238754326, 0.17124183006535948, 1.0) -(0.70634371395617068, 0.11072664359861592, 0.17647058823529413, 1.0) -(0.71188004613610145, 0.12179930795847752, 0.18169934640522878, 1.0) -(0.71741637831603222, 0.13287197231833911, 0.1869281045751634, 1.0) -(0.7229527104959631, 0.14394463667820068, 0.19215686274509805, 1.0) -(0.72848904267589387, 0.15501730103806227, 0.1973856209150327, 1.0) -(0.73402537485582464, 0.16608996539792387, 0.20261437908496732, 1.0) -(0.73956170703575541, 0.17716262975778541, 0.20784313725490194, 1.0) -(0.74509803921568629, 0.18823529411764706, 0.21307189542483659, 1.0) -(0.75063437139561706, 0.19930795847750865, 0.21830065359477124, 1.0) -(0.75617070357554783, 0.21038062283737025, 0.22352941176470587, 1.0) -(0.7617070357554786, 0.22145328719723176, 0.22875816993464049, 1.0) -(0.76724336793540948, 0.23252595155709341, 0.23398692810457516, 1.0) -(0.77277970011534025, 0.243598615916955, 0.23921568627450979, 1.0) -(0.77831603229527102, 0.25467128027681663, 0.24444444444444444, 1.0) -(0.78385236447520179, 0.26574394463667811, 0.24967320261437903, 1.0) -(0.78938869665513267, 0.27681660899653981, 0.25490196078431371, 1.0) -(0.79492502883506344, 0.28788927335640135, 0.26013071895424833, 1.0) -(0.80046136101499421, 0.298961937716263, 0.26535947712418301, 1.0) -(0.80599769319492498, 0.31003460207612449, 0.27058823529411757, 1.0) -(0.81153402537485586, 0.32110726643598619, 0.27581699346405231, 1.0) -(0.81707035755478663, 0.33217993079584773, 0.28104575163398693, 1.0) -(0.8226066897347174, 0.34325259515570933, 0.28627450980392155, 1.0) -(0.82814302191464817, 0.35432525951557087, 0.29150326797385617, 1.0) -(0.83367935409457905, 0.36539792387543252, 0.29673202614379085, 1.0) -(0.83921568627450982, 0.37647058823529411, 0.30196078431372547, 1.0) -(0.84382929642445215, 0.38708189158016149, 0.31011149557862361, 1.0) -(0.84844290657439447, 0.39769319492502875, 0.31826220684352163, 1.0) -(0.8530565167243368, 0.40830449826989618, 0.32641291810841983, 1.0) -(0.85767012687427913, 0.41891580161476355, 0.33456362937331791, 1.0) -(0.86228373702422145, 0.42952710495963087, 0.34271434063821604, 1.0) -(0.86689734717416378, 0.44013840830449813, 0.35086505190311407, 1.0) -(0.87151095732410611, 0.45074971164936561, 0.35901576316801226, 1.0) -(0.87612456747404843, 0.46136101499423293, 0.36716647443291039, 1.0) -(0.88073817762399076, 0.47197231833910031, 0.37531718569780848, 1.0) -(0.88535178777393309, 0.48258362168396757, 0.38346789696270656, 1.0) -(0.88996539792387541, 0.493194925028835, 0.39161860822760469, 1.0) -(0.89457900807381774, 0.50380622837370237, 0.39976931949250283, 1.0) -(0.89919261822376007, 0.51441753171856974, 0.40792003075740091, 1.0) -(0.90380622837370239, 0.52502883506343712, 0.41607074202229904, 1.0) -(0.90841983852364472, 0.53564013840830427, 0.42422145328719701, 1.0) -(0.91303344867358704, 0.54625144175317175, 0.43237216455209526, 1.0) -(0.91764705882352937, 0.55686274509803912, 0.44052287581699334, 1.0) -(0.9222606689734717, 0.5674740484429065, 0.44867358708189148, 1.0) -(0.92687427912341402, 0.57808535178777387, 0.45682429834678961, 1.0) -(0.93148788927335635, 0.58869665513264113, 0.4649750096116877, 1.0) -(0.93610149942329868, 0.59930795847750851, 0.47312572087658578, 1.0) -(0.940715109573241, 0.60991926182237588, 0.48127643214148391, 1.0) -(0.94532871972318333, 0.62053056516724314, 0.48942714340638194, 1.0) -(0.94994232987312566, 0.63114186851211063, 0.49757785467128013, 1.0) -(0.95455594002306798, 0.641753171856978, 0.50572856593617821, 1.0) -(0.95755478662053062, 0.65121107266435974, 0.51510957324106099, 1.0) -(0.95893886966551334, 0.65951557093425595, 0.52572087658592837, 1.0) -(0.96032295271049595, 0.66782006920415216, 0.53633217993079563, 1.0) -(0.96170703575547867, 0.67612456747404837, 0.546943483275663, 1.0) -(0.96309111880046139, 0.68442906574394458, 0.55755478662053037, 1.0) -(0.96447520184544411, 0.69273356401384067, 0.56816608996539764, 1.0) -(0.96585928489042683, 0.701038062283737, 0.57877739331026512, 1.0) -(0.96724336793540944, 0.70934256055363309, 0.58938869665513249, 1.0) -(0.96862745098039216, 0.7176470588235293, 0.59999999999999987, 1.0) -(0.97001153402537488, 0.72595155709342551, 0.61061130334486724, 1.0) -(0.9713956170703576, 0.73425605536332172, 0.62122260668973461, 1.0) -(0.97277970011534032, 0.74256055363321793, 0.63183391003460199, 1.0) -(0.97416378316032293, 0.75086505190311414, 0.64244521337946936, 1.0) -(0.97554786620530565, 0.75916955017301024, 0.65305651672433651, 1.0) -(0.97693194925028837, 0.76747404844290656, 0.66366782006920411, 1.0) -(0.97831603229527109, 0.77577854671280266, 0.67427912341407148, 1.0) -(0.97970011534025381, 0.78408304498269887, 0.68489042675893885, 1.0) -(0.98108419838523653, 0.79238754325259508, 0.69550173010380623, 1.0) -(0.98246828143021914, 0.80069204152249129, 0.7061130334486736, 1.0) -(0.98385236447520186, 0.8089965397923875, 0.71672433679354086, 1.0) -(0.98523644752018458, 0.81730103806228371, 0.72733564013840835, 1.0) -(0.9866205305651673, 0.8256055363321797, 0.7379469434832755, 1.0) -(0.98800461361015002, 0.83391003460207602, 0.74855824682814298, 1.0) -(0.98938869665513263, 0.84221453287197223, 0.75916955017301035, 1.0) -(0.99077277970011535, 0.85051903114186844, 0.76978085351787773, 1.0) -(0.99215686274509807, 0.85882352941176465, 0.7803921568627451, 1.0) -(0.99246443675509421, 0.86435986159169542, 0.78900422914263746, 1.0) -(0.99277201076509036, 0.8698961937716263, 0.79761630142252982, 1.0) -(0.99307958477508651, 0.87543252595155707, 0.80622837370242217, 1.0) -(0.99338715878508266, 0.88096885813148773, 0.81484044598231442, 1.0) -(0.99369473279507881, 0.88650519031141861, 0.82345251826220689, 1.0) -(0.99400230680507495, 0.89204152249134938, 0.83206459054209914, 1.0) -(0.9943098808150711, 0.89757785467128026, 0.84067666282199149, 1.0) -(0.99461745482506725, 0.90311418685121103, 0.84928873510188385, 1.0) -(0.99492502883506351, 0.9086505190311418, 0.85790080738177621, 1.0) -(0.99523260284505966, 0.91418685121107268, 0.86651287966166857, 1.0) -(0.9955401768550558, 0.91972318339100345, 0.87512495194156092, 1.0) -(0.99584775086505195, 0.92525951557093411, 0.88373702422145317, 1.0) -(0.9961553248750481, 0.93079584775086499, 0.89234909650134564, 1.0) -(0.99646289888504425, 0.93633217993079587, 0.900961168781238, 1.0) -(0.99677047289504039, 0.94186851211072664, 0.90957324106113036, 1.0) -(0.99707804690503654, 0.94740484429065741, 0.91818531334102271, 1.0) -(0.99738562091503269, 0.95294117647058818, 0.92679738562091507, 1.0) -(0.99769319492502884, 0.95847750865051906, 0.93540945790080743, 1.0) -(0.99800076893502498, 0.96401384083044983, 0.94402153018069979, 1.0) -(0.99830834294502113, 0.96955017301038049, 0.95263360246059192, 1.0) -(0.99861591695501728, 0.97508650519031137, 0.96124567474048439, 1.0) -(0.99892349096501343, 0.98062283737024225, 0.96985774702037675, 1.0) -(0.99923106497500958, 0.98615916955017302, 0.97846981930026911, 1.0) -(0.99953863898500572, 0.99169550173010379, 0.98708189158016146, 1.0) -(0.99984621299500187, 0.99723183391003456, 0.99569396386005382, 1.0) -(0.99761630142252977, 0.99761630142252977, 0.99761630142252977, 1.0) -(0.99284890426758943, 0.99284890426758943, 0.99284890426758943, 1.0) -(0.98808150711264897, 0.98808150711264897, 0.98808150711264897, 1.0) -(0.98331410995770863, 0.98331410995770863, 0.98331410995770863, 1.0) -(0.97854671280276828, 0.97854671280276828, 0.97854671280276828, 1.0) -(0.97377931564782783, 0.97377931564782783, 0.97377931564782783, 1.0) -(0.96901191849288737, 0.96901191849288737, 0.96901191849288737, 1.0) -(0.96424452133794702, 0.96424452133794702, 0.96424452133794702, 1.0) -(0.95947712418300657, 0.95947712418300657, 0.95947712418300657, 1.0) -(0.95470972702806622, 0.95470972702806622, 0.95470972702806622, 1.0) -(0.94994232987312577, 0.94994232987312577, 0.94994232987312577, 1.0) -(0.94517493271818531, 0.94517493271818531, 0.94517493271818531, 1.0) -(0.94040753556324497, 0.94040753556324497, 0.94040753556324497, 1.0) -(0.93564013840830451, 0.93564013840830451, 0.93564013840830451, 1.0) -(0.93087274125336417, 0.93087274125336417, 0.93087274125336417, 1.0) -(0.92610534409842371, 0.92610534409842371, 0.92610534409842371, 1.0) -(0.92133794694348337, 0.92133794694348337, 0.92133794694348337, 1.0) -(0.91657054978854291, 0.91657054978854291, 0.91657054978854291, 1.0) -(0.91180315263360256, 0.91180315263360256, 0.91180315263360256, 1.0) -(0.90703575547866211, 0.90703575547866211, 0.90703575547866211, 1.0) -(0.90226835832372188, 0.90226835832372188, 0.90226835832372188, 1.0) -(0.89750096116878131, 0.89750096116878131, 0.89750096116878131, 1.0) -(0.89273356401384096, 0.89273356401384096, 0.89273356401384096, 1.0) -(0.88796616685890051, 0.88796616685890051, 0.88796616685890051, 1.0) -(0.88319876970396016, 0.88319876970396016, 0.88319876970396016, 1.0) -(0.87843137254901971, 0.87843137254901971, 0.87843137254901971, 1.0) -(0.87258746635909279, 0.87258746635909279, 0.87258746635909279, 1.0) -(0.86674356016916587, 0.86674356016916587, 0.86674356016916587, 1.0) -(0.86089965397923895, 0.86089965397923895, 0.86089965397923895, 1.0) -(0.85505574778931193, 0.85505574778931193, 0.85505574778931193, 1.0) -(0.84921184159938501, 0.84921184159938501, 0.84921184159938501, 1.0) -(0.84336793540945809, 0.84336793540945809, 0.84336793540945809, 1.0) -(0.83752402921953106, 0.83752402921953106, 0.83752402921953106, 1.0) -(0.83168012302960415, 0.83168012302960415, 0.83168012302960415, 1.0) -(0.82583621683967723, 0.82583621683967723, 0.82583621683967723, 1.0) -(0.8199923106497502, 0.8199923106497502, 0.8199923106497502, 1.0) -(0.8141484044598235, 0.8141484044598235, 0.8141484044598235, 1.0) -(0.80830449826989637, 0.80830449826989637, 0.80830449826989637, 1.0) -(0.80246059207996945, 0.80246059207996945, 0.80246059207996945, 1.0) -(0.79661668589004242, 0.79661668589004242, 0.79661668589004242, 1.0) -(0.7907727797001155, 0.7907727797001155, 0.7907727797001155, 1.0) -(0.78492887351018847, 0.78492887351018847, 0.78492887351018847, 1.0) -(0.77908496732026156, 0.77908496732026156, 0.77908496732026156, 1.0) -(0.77324106113033464, 0.77324106113033464, 0.77324106113033464, 1.0) -(0.76739715494040772, 0.76739715494040772, 0.76739715494040772, 1.0) -(0.76155324875048069, 0.76155324875048069, 0.76155324875048069, 1.0) -(0.75570934256055378, 0.75570934256055378, 0.75570934256055378, 1.0) -(0.74986543637062675, 0.74986543637062675, 0.74986543637062675, 1.0) -(0.74402153018069983, 0.74402153018069983, 0.74402153018069983, 1.0) -(0.73817762399077291, 0.73817762399077291, 0.73817762399077291, 1.0) -(0.732333717800846, 0.732333717800846, 0.732333717800846, 1.0) -(0.72549019607843157, 0.72549019607843157, 0.72549019607843157, 1.0) -(0.71764705882352986, 0.71764705882352986, 0.71764705882352986, 1.0) -(0.70980392156862759, 0.70980392156862759, 0.70980392156862759, 1.0) -(0.70196078431372566, 0.70196078431372566, 0.70196078431372566, 1.0) -(0.69411764705882373, 0.69411764705882373, 0.69411764705882373, 1.0) -(0.68627450980392168, 0.68627450980392168, 0.68627450980392168, 1.0) -(0.67843137254901975, 0.67843137254901975, 0.67843137254901975, 1.0) -(0.67058823529411782, 0.67058823529411782, 0.67058823529411782, 1.0) -(0.66274509803921577, 0.66274509803921577, 0.66274509803921577, 1.0) -(0.65490196078431384, 0.65490196078431384, 0.65490196078431384, 1.0) -(0.64705882352941191, 0.64705882352941191, 0.64705882352941191, 1.0) -(0.63921568627450986, 0.63921568627450986, 0.63921568627450986, 1.0) -(0.63137254901960793, 0.63137254901960793, 0.63137254901960793, 1.0) -(0.623529411764706, 0.623529411764706, 0.623529411764706, 1.0) -(0.61568627450980395, 0.61568627450980395, 0.61568627450980395, 1.0) -(0.60784313725490202, 0.60784313725490202, 0.60784313725490202, 1.0) -(0.60000000000000009, 0.60000000000000009, 0.60000000000000009, 1.0) -(0.59215686274509838, 0.59215686274509838, 0.59215686274509838, 1.0) -(0.58431372549019611, 0.58431372549019611, 0.58431372549019611, 1.0) -(0.57647058823529418, 0.57647058823529418, 0.57647058823529418, 1.0) -(0.56862745098039214, 0.56862745098039214, 0.56862745098039214, 1.0) -(0.5607843137254902, 0.5607843137254902, 0.5607843137254902, 1.0) -(0.55294117647058827, 0.55294117647058827, 0.55294117647058827, 1.0) -(0.54509803921568634, 0.54509803921568634, 0.54509803921568634, 1.0) -(0.5372549019607844, 0.5372549019607844, 0.5372549019607844, 1.0) -(0.52941176470588236, 0.52941176470588236, 0.52941176470588236, 1.0) -(0.52049211841599385, 0.52049211841599385, 0.52049211841599385, 1.0) -(0.51157247212610535, 0.51157247212610535, 0.51157247212610535, 1.0) -(0.50265282583621684, 0.50265282583621684, 0.50265282583621684, 1.0) -(0.49373317954632834, 0.49373317954632834, 0.49373317954632834, 1.0) -(0.48481353325643983, 0.48481353325643983, 0.48481353325643983, 1.0) -(0.47589388696655133, 0.47589388696655133, 0.47589388696655133, 1.0) -(0.46697424067666282, 0.46697424067666282, 0.46697424067666282, 1.0) -(0.45805459438677454, 0.45805459438677454, 0.45805459438677454, 1.0) -(0.44913494809688581, 0.44913494809688581, 0.44913494809688581, 1.0) -(0.44021530180699731, 0.44021530180699731, 0.44021530180699731, 1.0) -(0.4312956555171088, 0.4312956555171088, 0.4312956555171088, 1.0) -(0.42237600922722029, 0.42237600922722029, 0.42237600922722029, 1.0) -(0.41345636293733179, 0.41345636293733179, 0.41345636293733179, 1.0) -(0.40453671664744328, 0.40453671664744328, 0.40453671664744328, 1.0) -(0.39561707035755478, 0.39561707035755478, 0.39561707035755478, 1.0) -(0.38669742406766627, 0.38669742406766627, 0.38669742406766627, 1.0) -(0.37777777777777777, 0.37777777777777777, 0.37777777777777777, 1.0) -(0.36885813148788926, 0.36885813148788926, 0.36885813148788926, 1.0) -(0.35993848519800076, 0.35993848519800076, 0.35993848519800076, 1.0) -(0.35101883890811225, 0.35101883890811225, 0.35101883890811225, 1.0) -(0.34209919261822375, 0.34209919261822375, 0.34209919261822375, 1.0) -(0.33317954632833524, 0.33317954632833524, 0.33317954632833524, 1.0) -(0.32425990003844674, 0.32425990003844674, 0.32425990003844674, 1.0) -(0.31534025374855845, 0.31534025374855845, 0.31534025374855845, 1.0) -(0.30642060745866972, 0.30642060745866972, 0.30642060745866972, 1.0) -(0.29803921568627451, 0.29803921568627451, 0.29803921568627451, 1.0) -(0.29019607843137252, 0.29019607843137252, 0.29019607843137252, 1.0) -(0.28235294117647058, 0.28235294117647058, 0.28235294117647058, 1.0) -(0.2745098039215686, 0.2745098039215686, 0.2745098039215686, 1.0) -(0.26666666666666666, 0.26666666666666666, 0.26666666666666666, 1.0) -(0.25882352941176467, 0.25882352941176467, 0.25882352941176467, 1.0) -(0.25098039215686274, 0.25098039215686274, 0.25098039215686274, 1.0) -(0.24313725490196075, 0.24313725490196075, 0.24313725490196075, 1.0) -(0.23529411764705882, 0.23529411764705882, 0.23529411764705882, 1.0) -(0.22745098039215683, 0.22745098039215683, 0.22745098039215683, 1.0) -(0.2196078431372549, 0.2196078431372549, 0.2196078431372549, 1.0) -(0.21176470588235291, 0.21176470588235291, 0.21176470588235291, 1.0) -(0.20392156862745098, 0.20392156862745098, 0.20392156862745098, 1.0) -(0.19607843137254899, 0.19607843137254899, 0.19607843137254899, 1.0) -(0.18823529411764728, 0.18823529411764728, 0.18823529411764728, 1.0) -(0.1803921568627451, 0.1803921568627451, 0.1803921568627451, 1.0) -(0.17254901960784313, 0.17254901960784313, 0.17254901960784313, 1.0) -(0.16470588235294117, 0.16470588235294117, 0.16470588235294117, 1.0) -(0.15686274509803921, 0.15686274509803921, 0.15686274509803921, 1.0) -(0.14901960784313725, 0.14901960784313725, 0.14901960784313725, 1.0) -(0.14117647058823529, 0.14117647058823529, 0.14117647058823529, 1.0) -(0.13333333333333333, 0.13333333333333333, 0.13333333333333333, 1.0) -(0.12549019607843137, 0.12549019607843137, 0.12549019607843137, 1.0) -(0.11764705882352941, 0.11764705882352941, 0.11764705882352941, 1.0) -(0.10980392156862745, 0.10980392156862745, 0.10980392156862745, 1.0) -(0.10196078431372549, 0.10196078431372549, 0.10196078431372549, 1.0) diff --git a/extern/tfn/colormaps/diverging/RdYlBu.cpp b/extern/tfn/colormaps/diverging/RdYlBu.cpp deleted file mode 100644 index 9d2e0af..0000000 --- a/extern/tfn/colormaps/diverging/RdYlBu.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_diverging_RdYlBu; -} -const std::vector colormap::data_diverging_RdYlBu = /* NOLINT(cert-err58-cpp) */ -{ -{0.6470588235294118f, 0.0f, 0.14901960784313725f, 1.0f}, -{0.65474817377931571f, 0.0073817762399077278f, 0.14917339484813533f, 1.0f}, -{0.66243752402921952f, 0.014763552479815456f, 0.1493271818531334f, 1.0f}, -{0.67012687427912343f, 0.022145328719723183f, 0.14948096885813147f, 1.0f}, -{0.67781622452902734f, 0.029527104959630911f, 0.14963475586312958f, 1.0f}, -{0.68550557477893115f, 0.03690888119953864f, 0.14978854286812765f, 1.0f}, -{0.69319492502883506f, 0.044290657439446365f, 0.14994232987312572f, 1.0f}, -{0.70088427527873898f, 0.051672433679354098f, 0.1500961168781238f, 1.0f}, -{0.70857362552864289f, 0.059054209919261823f, 0.15024990388312187f, 1.0f}, -{0.7162629757785467f, 0.066435986159169555f, 0.15040369088811995f, 1.0f}, -{0.72395232602845061f, 0.07381776239907728f, 0.15055747789311805f, 1.0f}, -{0.73164167627835452f, 0.081199538638985005f, 0.15071126489811612f, 1.0f}, -{0.73933102652825844f, 0.088581314878892731f, 0.15086505190311419f, 1.0f}, -{0.74702037677816224f, 0.095963091118800456f, 0.15101883890811227f, 1.0f}, -{0.75470972702806616f, 0.1033448673587082f, 0.15117262591311034f, 1.0f}, -{0.76239907727797007f, 0.11072664359861592f, 0.15132641291810842f, 1.0f}, -{0.77008842752787388f, 0.11810841983852365f, 0.15148019992310652f, 1.0f}, -{0.77777777777777779f, 0.12549019607843137f, 0.15163398692810459f, 1.0f}, -{0.7854671280276817f, 0.13287197231833911f, 0.15178777393310267f, 1.0f}, -{0.79315647827758551f, 0.14025374855824682f, 0.15194156093810074f, 1.0f}, -{0.80084582852748942f, 0.14763552479815456f, 0.15209534794309881f, 1.0f}, -{0.80853517877739334f, 0.15501730103806227f, 0.15224913494809689f, 1.0f}, -{0.81622452902729714f, 0.16239907727797001f, 0.15240292195309496f, 1.0f}, -{0.82391387927720106f, 0.16978085351787775f, 0.15255670895809306f, 1.0f}, -{0.83160322952710497f, 0.17716262975778546f, 0.15271049596309114f, 1.0f}, -{0.83929257977700877f, 0.18454440599769317f, 0.15286428296808921f, 1.0f}, -{0.84536716647443289f, 0.19292579777008842f, 0.15509419454056134f, 1.0f}, -{0.84982698961937719f, 0.20230680507497117f, 0.15940023068050752f, 1.0f}, -{0.85428681276432139f, 0.2116878123798539f, 0.16370626682045369f, 1.0f}, -{0.8587466359092657f, 0.22106881968473663f, 0.16801230296039987f, 1.0f}, -{0.8632064590542099f, 0.23044982698961938f, 0.17231833910034602f, 1.0f}, -{0.8676662821991542f, 0.23983083429450211f, 0.1766243752402922f, 1.0f}, -{0.8721261053440984f, 0.24921184159938484f, 0.18093041138023838f, 1.0f}, -{0.87658592848904271f, 0.25859284890426754f, 0.18523644752018453f, 1.0f}, -{0.88104575163398691f, 0.26797385620915032f, 0.18954248366013071f, 1.0f}, -{0.88550557477893121f, 0.27735486351403305f, 0.19384851980007689f, 1.0f}, -{0.88996539792387541f, 0.28673587081891577f, 0.19815455594002307f, 1.0f}, -{0.89442522106881972f, 0.29611687812379844f, 0.20246059207996922f, 1.0f}, -{0.89888504421376392f, 0.30549788542868128f, 0.20676662821991543f, 1.0f}, -{0.90334486735870823f, 0.31487889273356401f, 0.21107266435986161f, 1.0f}, -{0.90780469050365242f, 0.32425990003844674f, 0.21537870049980778f, 1.0f}, -{0.91226451364859673f, 0.33364090734332941f, 0.21968473663975391f, 1.0f}, -{0.91672433679354093f, 0.34302191464821219f, 0.22399077277970014f, 1.0f}, -{0.92118415993848524f, 0.35240292195309497f, 0.22829680891964632f, 1.0f}, -{0.92564398308342943f, 0.36178392925797764f, 0.23260284505959247f, 1.0f}, -{0.93010380622837374f, 0.37116493656286037f, 0.23690888119953862f, 1.0f}, -{0.93456362937331794f, 0.38054594386774315f, 0.24121491733948483f, 1.0f}, -{0.93902345251826225f, 0.38992695117262588f, 0.24552095347943098f, 1.0f}, -{0.94348327566320656f, 0.39930795847750866f, 0.24982698961937716f, 1.0f}, -{0.94794309880815075f, 0.40868896578239133f, 0.25413302575932328f, 1.0f}, -{0.95240292195309495f, 0.41806997308727412f, 0.25843906189926952f, 1.0f}, -{0.95686274509803926f, 0.42745098039215684f, 0.2627450980392157f, 1.0f}, -{0.95824682814302198f, 0.43744713571703187f, 0.26735870818915802f, 1.0f}, -{0.9596309111880047f, 0.44744329104190683f, 0.27197231833910029f, 1.0f}, -{0.96101499423298731f, 0.45743944636678197f, 0.27658592848904268f, 1.0f}, -{0.96239907727797003f, 0.46743560169165704f, 0.281199538638985f, 1.0f}, -{0.96378316032295275f, 0.47743175701653207f, 0.28581314878892733f, 1.0f}, -{0.96516724336793547f, 0.48742791234140703f, 0.2904267589388696f, 1.0f}, -{0.96655132641291819f, 0.49742406766628217f, 0.29504036908881198f, 1.0f}, -{0.9679354094579008f, 0.50742022299115719f, 0.29965397923875431f, 1.0f}, -{0.96931949250288352f, 0.51741637831603227f, 0.30426758938869664f, 1.0f}, -{0.97070357554786624f, 0.52741253364090723f, 0.30888119953863891f, 1.0f}, -{0.97208765859284896f, 0.53740868896578231f, 0.31349480968858129f, 1.0f}, -{0.97347174163783168f, 0.54740484429065739f, 0.31810841983852362f, 1.0f}, -{0.97485582468281429f, 0.55740099961553247f, 0.32272202998846594f, 1.0f}, -{0.97623990772779701f, 0.56739715494040743f, 0.32733564013840827f, 1.0f}, -{0.97762399077277973f, 0.5773933102652824f, 0.33194925028835054f, 1.0f}, -{0.97900807381776245f, 0.58738946559015759f, 0.33656286043829292f, 1.0f}, -{0.98039215686274517f, 0.59738562091503256f, 0.34117647058823525f, 1.0f}, -{0.98177623990772778f, 0.60738177623990763f, 0.34579008073817757f, 1.0f}, -{0.9831603229527105f, 0.61737793156478271f, 0.3504036908881199f, 1.0f}, -{0.98454440599769322f, 0.62737408688965768f, 0.35501730103806223f, 1.0f}, -{0.98592848904267594f, 0.63737024221453276f, 0.35963091118800455f, 1.0f}, -{0.98731257208765866f, 0.64736639753940783f, 0.36424452133794688f, 1.0f}, -{0.98869665513264127f, 0.65736255286428269f, 0.36885813148788915f, 1.0f}, -{0.99008073817762399f, 0.66735870818915788f, 0.37347174163783153f, 1.0f}, -{0.99146482122260671f, 0.67735486351403296f, 0.37808535178777386f, 1.0f}, -{0.99223375624759713f, 0.6861976163014224f, 0.38400615148019979f, 1.0f}, -{0.99238754325259515f, 0.69388696655132631f, 0.39123414071510948f, 1.0f}, -{0.99254133025759328f, 0.70157631680123023f, 0.39846212995001912f, 1.0f}, -{0.9926951172625913f, 0.70926566705113414f, 0.40569011918492875f, 1.0f}, -{0.99284890426758943f, 0.71695501730103794f, 0.41291810841983845f, 1.0f}, -{0.99300269127258745f, 0.72464436755094175f, 0.42014609765474797f, 1.0f}, -{0.99315647827758557f, 0.73233371780084577f, 0.42737408688965772f, 1.0f}, -{0.99331026528258359f, 0.74002306805074969f, 0.43460207612456736f, 1.0f}, -{0.99346405228758172f, 0.74771241830065349f, 0.44183006535947705f, 1.0f}, -{0.99361783929257985f, 0.75540176855055741f, 0.44905805459438669f, 1.0f}, -{0.99377162629757787f, 0.76309111880046132f, 0.45628604382929633f, 1.0f}, -{0.993925413302576f, 0.77078046905036524f, 0.46351403306420602f, 1.0f}, -{0.99407920030757402f, 0.77846981930026904f, 0.47074202229911566f, 1.0f}, -{0.99423298731257215f, 0.78615916955017284f, 0.47797001153402519f, 1.0f}, -{0.99438677431757017f, 0.79384851980007687f, 0.48519800076893493f, 1.0f}, -{0.9945405613225683f, 0.80153787004998067f, 0.49242599000384463f, 1.0f}, -{0.99469434832756631f, 0.80922722029988459f, 0.49965397923875426f, 1.0f}, -{0.99484813533256444f, 0.8169165705497885f, 0.50688196847366396f, 1.0f}, -{0.99500192233756246f, 0.82460592079969242f, 0.51410995770857359f, 1.0f}, -{0.99515570934256059f, 0.83229527104959633f, 0.52133794694348323f, 1.0f}, -{0.99530949634755861f, 0.83998462129950013f, 0.52856593617839287f, 1.0f}, -{0.99546328335255674f, 0.84767397154940394f, 0.5357939254133024f, 1.0f}, -{0.99561707035755476f, 0.85536332179930796f, 0.54302191464821226f, 1.0f}, -{0.99577085736255289f, 0.86305267204921177f, 0.55024990388312189f, 1.0f}, -{0.9959246443675509f, 0.87074202229911568f, 0.55747789311803153f, 1.0f}, -{0.99607843137254903f, 0.8784313725490196f, 0.56470588235294117f, 1.0f}, -{0.99623221837754716f, 0.88319876970396005f, 0.57193387158785081f, 1.0f}, -{0.99638600538254518f, 0.8879661668589004f, 0.57916186082276044f, 1.0f}, -{0.99653979238754331f, 0.89273356401384085f, 0.58638985005767008f, 1.0f}, -{0.99669357939254133f, 0.8975009611687812f, 0.59361783929257972f, 1.0f}, -{0.99684736639753946f, 0.90226835832372165f, 0.60084582852748947f, 1.0f}, -{0.99700115340253748f, 0.907035755478662f, 0.6080738177623991f, 1.0f}, -{0.99715494040753561f, 0.91180315263360245f, 0.61530180699730874f, 1.0f}, -{0.99730872741253362f, 0.91657054978854291f, 0.62252979623221838f, 1.0f}, -{0.99746251441753175f, 0.92133794694348325f, 0.62975778546712802f, 1.0f}, -{0.99761630142252977f, 0.92610534409842371f, 0.63698577470203765f, 1.0f}, -{0.9977700884275279f, 0.93087274125336406f, 0.64421376393694729f, 1.0f}, -{0.99792387543252592f, 0.9356401384083044f, 0.65144175317185682f, 1.0f}, -{0.99807766243752405f, 0.94040753556324486f, 0.65866974240676668f, 1.0f}, -{0.99823144944252207f, 0.94517493271818531f, 0.66589773164167632f, 1.0f}, -{0.9983852364475202f, 0.94994232987312577f, 0.67312572087658595f, 1.0f}, -{0.99853902345251822f, 0.95470972702806611f, 0.68035371011149559f, 1.0f}, -{0.99869281045751634f, 0.95947712418300657f, 0.68758169934640523f, 1.0f}, -{0.99884659746251447f, 0.96424452133794691f, 0.69480968858131487f, 1.0f}, -{0.99900038446751249f, 0.96901191849288737f, 0.7020376778162245f, 1.0f}, -{0.99915417147251062f, 0.97377931564782771f, 0.70926566705113414f, 1.0f}, -{0.99930795847750864f, 0.97854671280276817f, 0.71649365628604378f, 1.0f}, -{0.99946174548250677f, 0.98331410995770852f, 0.72372164552095353f, 1.0f}, -{0.99961553248750479f, 0.98808150711264897f, 0.73094963475586316f, 1.0f}, -{0.99976931949250292f, 0.99284890426758943f, 0.7381776239907728f, 1.0f}, -{0.99992310649750094f, 0.99761630142252977f, 0.74540561322568244f, 1.0f}, -{0.99761630142252977f, 0.99907727797001156f, 0.7534025374855825f, 1.0f}, -{0.99284890426758943f, 0.99723183391003456f, 0.76216839677047288f, 1.0f}, -{0.98808150711264897f, 0.99538638985005767f, 0.77093425605536325f, 1.0f}, -{0.98331410995770863f, 0.99354094579008079f, 0.77970011534025374f, 1.0f}, -{0.97854671280276828f, 0.9916955017301039f, 0.78846597462514389f, 1.0f}, -{0.97377931564782783f, 0.9898500576701269f, 0.7972318339100346f, 1.0f}, -{0.96901191849288737f, 0.98800461361014991f, 0.80599769319492498f, 1.0f}, -{0.96424452133794702f, 0.98615916955017302f, 0.81476355247981536f, 1.0f}, -{0.95947712418300657f, 0.98431372549019602f, 0.82352941176470584f, 1.0f}, -{0.95470972702806622f, 0.98246828143021914f, 0.83229527104959622f, 1.0f}, -{0.94994232987312577f, 0.98062283737024225f, 0.8410611303344866f, 1.0f}, -{0.94517493271818531f, 0.97877739331026525f, 0.84982698961937708f, 1.0f}, -{0.94040753556324497f, 0.97693194925028837f, 0.85859284890426746f, 1.0f}, -{0.93564013840830451f, 0.97508650519031137f, 0.86735870818915783f, 1.0f}, -{0.93087274125336417f, 0.97324106113033448f, 0.87612456747404832f, 1.0f}, -{0.92610534409842371f, 0.9713956170703576f, 0.8848904267589387f, 1.0f}, -{0.92133794694348337f, 0.9695501730103806f, 0.89365628604382907f, 1.0f}, -{0.91657054978854291f, 0.96770472895040371f, 0.90242214532871956f, 1.0f}, -{0.91180315263360256f, 0.96585928489042672f, 0.91118800461360994f, 1.0f}, -{0.90703575547866211f, 0.96401384083044983f, 0.91995386389850031f, 1.0f}, -{0.90226835832372188f, 0.96216839677047294f, 0.92871972318339058f, 1.0f}, -{0.89750096116878131f, 0.96032295271049595f, 0.93748558246828129f, 1.0f}, -{0.89273356401384096f, 0.95847750865051906f, 0.94625144175317155f, 1.0f}, -{0.88796616685890051f, 0.95663206459054206f, 0.95501730103806204f, 1.0f}, -{0.88319876970396016f, 0.95478662053056518f, 0.96378316032295241f, 1.0f}, -{0.87843137254901971f, 0.95294117647058818f, 0.9725490196078429f, 1.0f}, -{0.87028066128412174f, 0.94894271434063826f, 0.97024221453287207f, 1.0f}, -{0.86212995001922355f, 0.94494425221068823f, 0.96793540945790091f, 1.0f}, -{0.85397923875432546f, 0.9409457900807382f, 0.96562860438292974f, 1.0f}, -{0.84582852748942738f, 0.93694732795078828f, 0.96332179930795858f, 1.0f}, -{0.83767781622452919f, 0.93294886582083825f, 0.96101499423298731f, 1.0f}, -{0.82952710495963111f, 0.92895040369088822f, 0.95870818915801614f, 1.0f}, -{0.82137639369473303f, 0.92495194156093818f, 0.95640138408304498f, 1.0f}, -{0.81322568242983484f, 0.92095347943098815f, 0.95409457900807382f, 1.0f}, -{0.80507497116493676f, 0.91695501730103812f, 0.95178777393310265f, 1.0f}, -{0.79692425990003868f, 0.91295655517108809f, 0.94948096885813149f, 1.0f}, -{0.78877354863514082f, 0.90895809304113817f, 0.94717416378316044f, 1.0f}, -{0.78062283737024241f, 0.90495963091118803f, 0.94486735870818916f, 1.0f}, -{0.77247212610534433f, 0.90096116878123811f, 0.942560553633218f, 1.0f}, -{0.76432141484044613f, 0.89696270665128808f, 0.94025374855824684f, 1.0f}, -{0.75617070357554805f, 0.89296424452133805f, 0.93794694348327567f, 1.0f}, -{0.74801999231064997f, 0.88896578239138802f, 0.93564013840830451f, 1.0f}, -{0.73986928104575189f, 0.88496732026143798f, 0.93333333333333335f, 1.0f}, -{0.7317185697808537f, 0.88096885813148795f, 0.93102652825836218f, 1.0f}, -{0.72356785851595562f, 0.87697039600153792f, 0.92871972318339102f, 1.0f}, -{0.71541714725105754f, 0.87297193387158789f, 0.92641291810841986f, 1.0f}, -{0.70726643598615935f, 0.86897347174163797f, 0.9241061130334487f, 1.0f}, -{0.69911572472126127f, 0.86497500961168794f, 0.92179930795847753f, 1.0f}, -{0.69096501345636319f, 0.86097654748173791f, 0.91949250288350637f, 1.0f}, -{0.68281430219146499f, 0.85697808535178788f, 0.91718569780853521f, 1.0f}, -{0.67466359092656691f, 0.85297962322183785f, 0.91487889273356404f, 1.0f}, -{0.6663590926566707f, 0.84759707804690521f, 0.91188004613610163f, 1.0f}, -{0.6579008073817767f, 0.84083044982698996f, 0.90818915801614786f, 1.0f}, -{0.64944252210688214f, 0.83406382160707437f, 0.90449826989619386f, 1.0f}, -{0.64098423683198791f, 0.8272971933871589f, 0.90080738177623998f, 1.0f}, -{0.63252595155709357f, 0.82053056516724354f, 0.8971164936562861f, 1.0f}, -{0.62406766628219934f, 0.81376393694732807f, 0.89342560553633221f, 1.0f}, -{0.615609381007305f, 0.80699730872741271f, 0.88973471741637833f, 1.0f}, -{0.60715109573241077f, 0.80023068050749724f, 0.88604382929642445f, 1.0f}, -{0.59869281045751643f, 0.79346405228758177f, 0.88235294117647067f, 1.0f}, -{0.59023452518262221f, 0.78669742406766641f, 0.87866205305651679f, 1.0f}, -{0.58177623990772787f, 0.77993079584775094f, 0.87497116493656291f, 1.0f}, -{0.57331795463283364f, 0.77316416762783557f, 0.87128027681660902f, 1.0f}, -{0.5648596693579393f, 0.7663975394079201f, 0.86758938869665514f, 1.0f}, -{0.55640138408304507f, 0.75963091118800474f, 0.86389850057670126f, 1.0f}, -{0.54794309880815084f, 0.75286428296808927f, 0.86020761245674737f, 1.0f}, -{0.5394848135332565f, 0.74609765474817391f, 0.8565167243367936f, 1.0f}, -{0.53102652825836227f, 0.73933102652825844f, 0.85282583621683972f, 1.0f}, -{0.52256824298346816f, 0.73256439830834319f, 0.84913494809688594f, 1.0f}, -{0.51410995770857371f, 0.72579777008842761f, 0.84544405997693195f, 1.0f}, -{0.50565167243367937f, 0.71903114186851214f, 0.84175317185697807f, 1.0f}, -{0.49719338715878514f, 0.71226451364859678f, 0.83806228373702418f, 1.0f}, -{0.48873510188389085f, 0.7054978854286813f, 0.83437139561707041f, 1.0f}, -{0.48027681660899657f, 0.69873125720876594f, 0.83068050749711653f, 1.0f}, -{0.47181853133410223f, 0.69196462898885047f, 0.82698961937716264f, 1.0f}, -{0.463360246059208f, 0.68519800076893511f, 0.82329873125720876f, 1.0f}, -{0.45490196078431372f, 0.67843137254901964f, 0.81960784313725488f, 1.0f}, -{0.44767397154940408f, 0.66981930026912728f, 0.81514801999231068f, 1.0f}, -{0.44044598231449444f, 0.66120722798923492f, 0.81068819684736637f, 1.0f}, -{0.43321799307958475f, 0.65259515570934257f, 0.80622837370242217f, 1.0f}, -{0.42599000384467511f, 0.64398308342945021f, 0.80176855055747787f, 1.0f}, -{0.41876201460976548f, 0.63537101114955785f, 0.79730872741253367f, 1.0f}, -{0.41153402537485584f, 0.62675893886966549f, 0.79284890426758936f, 1.0f}, -{0.40430603613994615f, 0.61814686658977314f, 0.78838908112264516f, 1.0f}, -{0.39707804690503673f, 0.60953479430988111f, 0.78392925797770097f, 1.0f}, -{0.38985005767012687f, 0.60092272202998842f, 0.77946943483275666f, 1.0f}, -{0.38262206843521723f, 0.59231064975009617f, 0.77500961168781235f, 1.0f}, -{0.37539407920030754f, 0.58369857747020382f, 0.77054978854286815f, 1.0f}, -{0.3681660899653979f, 0.57508650519031146f, 0.76608996539792384f, 1.0f}, -{0.36093810073048826f, 0.5664744329104191f, 0.76163014225297965f, 1.0f}, -{0.35371011149557863f, 0.55786236063052674f, 0.75717031910803534f, 1.0f}, -{0.34648212226066899f, 0.54925028835063439f, 0.75271049596309114f, 1.0f}, -{0.3392541330257593f, 0.54063821607074203f, 0.74825067281814683f, 1.0f}, -{0.33202614379084966f, 0.53202614379084967f, 0.74379084967320264f, 1.0f}, -{0.32479815455593997f, 0.52341407151095731f, 0.73933102652825844f, 1.0f}, -{0.31757016532103033f, 0.51480199923106496f, 0.73487120338331413f, 1.0f}, -{0.31034217608612069f, 0.5061899269511726f, 0.73041138023836993f, 1.0f}, -{0.30311418685121105f, 0.49757785467128024f, 0.72595155709342563f, 1.0f}, -{0.29588619761630142f, 0.48896578239138788f, 0.72149173394848143f, 1.0f}, -{0.28865820838139178f, 0.48035371011149552f, 0.71703191080353712f, 1.0f}, -{0.28143021914648231f, 0.4717416378316035f, 0.71257208765859303f, 1.0f}, -{0.2742022299115725f, 0.46312956555171086f, 0.70811226451364861f, 1.0f}, -{0.26905036524413684f, 0.45397923875432522f, 0.70349865436370629f, 1.0f}, -{0.2659746251441753f, 0.44429065743944635f, 0.69873125720876594f, 1.0f}, -{0.26289888504421377f, 0.43460207612456747f, 0.69396386005382549f, 1.0f}, -{0.25982314494425218f, 0.42491349480968854f, 0.68919646289888514f, 1.0f}, -{0.25674740484429065f, 0.41522491349480967f, 0.68442906574394469f, 1.0f}, -{0.25367166474432912f, 0.40553633217993079f, 0.67966166858900423f, 1.0f}, -{0.25059592464436753f, 0.39584775086505186f, 0.67489427143406389f, 1.0f}, -{0.247520184544406f, 0.38615916955017299f, 0.67012687427912343f, 1.0f}, -{0.24444444444444444f, 0.37647058823529411f, 0.66535947712418309f, 1.0f}, -{0.24136870434448288f, 0.36678200692041518f, 0.66059207996924263f, 1.0f}, -{0.23829296424452134f, 0.35709342560553631f, 0.65582468281430228f, 1.0f}, -{0.23521722414455978f, 0.34740484429065743f, 0.65105728565936183f, 1.0f}, -{0.23214148404459822f, 0.33771626297577856f, 0.64628988850442137f, 1.0f}, -{0.22906574394463669f, 0.32802768166089963f, 0.64152249134948103f, 1.0f}, -{0.22599000384467521f, 0.31833910034602103f, 0.63675509419454079f, 1.0f}, -{0.22291426374471357f, 0.30865051903114188f, 0.63198769703960023f, 1.0f}, -{0.21983852364475201f, 0.29896193771626295f, 0.62722029988465977f, 1.0f}, -{0.21676278354479048f, 0.28927335640138407f, 0.62245290272971943f, 1.0f}, -{0.21368704344482892f, 0.2795847750865052f, 0.61768550557477897f, 1.0f}, -{0.21061130334486738f, 0.26989619377162632f, 0.61291810841983851f, 1.0f}, -{0.2075355632449058f, 0.26020761245674739f, 0.60815071126489817f, 1.0f}, -{0.20445982314494426f, 0.25051903114186846f, 0.60338331410995771f, 1.0f}, -{0.2013840830449827f, 0.24083044982698962f, 0.59861591695501737f, 1.0f}, -{0.19830834294502114f, 0.23114186851211074f, 0.59384851980007691f, 1.0f}, -{0.19523260284505961f, 0.22145328719723181f, 0.58908112264513646f, 1.0f}, -{0.19215686274509805f, 0.21176470588235294f, 0.58431372549019611f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/diverging/RdYlBu.txt b/extern/tfn/colormaps/diverging/RdYlBu.txt deleted file mode 100644 index f1e5308..0000000 --- a/extern/tfn/colormaps/diverging/RdYlBu.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.6470588235294118, 0.0, 0.14901960784313725, 1.0) -(0.65474817377931571, 0.0073817762399077278, 0.14917339484813533, 1.0) -(0.66243752402921952, 0.014763552479815456, 0.1493271818531334, 1.0) -(0.67012687427912343, 0.022145328719723183, 0.14948096885813147, 1.0) -(0.67781622452902734, 0.029527104959630911, 0.14963475586312958, 1.0) -(0.68550557477893115, 0.03690888119953864, 0.14978854286812765, 1.0) -(0.69319492502883506, 0.044290657439446365, 0.14994232987312572, 1.0) -(0.70088427527873898, 0.051672433679354098, 0.1500961168781238, 1.0) -(0.70857362552864289, 0.059054209919261823, 0.15024990388312187, 1.0) -(0.7162629757785467, 0.066435986159169555, 0.15040369088811995, 1.0) -(0.72395232602845061, 0.07381776239907728, 0.15055747789311805, 1.0) -(0.73164167627835452, 0.081199538638985005, 0.15071126489811612, 1.0) -(0.73933102652825844, 0.088581314878892731, 0.15086505190311419, 1.0) -(0.74702037677816224, 0.095963091118800456, 0.15101883890811227, 1.0) -(0.75470972702806616, 0.1033448673587082, 0.15117262591311034, 1.0) -(0.76239907727797007, 0.11072664359861592, 0.15132641291810842, 1.0) -(0.77008842752787388, 0.11810841983852365, 0.15148019992310652, 1.0) -(0.77777777777777779, 0.12549019607843137, 0.15163398692810459, 1.0) -(0.7854671280276817, 0.13287197231833911, 0.15178777393310267, 1.0) -(0.79315647827758551, 0.14025374855824682, 0.15194156093810074, 1.0) -(0.80084582852748942, 0.14763552479815456, 0.15209534794309881, 1.0) -(0.80853517877739334, 0.15501730103806227, 0.15224913494809689, 1.0) -(0.81622452902729714, 0.16239907727797001, 0.15240292195309496, 1.0) -(0.82391387927720106, 0.16978085351787775, 0.15255670895809306, 1.0) -(0.83160322952710497, 0.17716262975778546, 0.15271049596309114, 1.0) -(0.83929257977700877, 0.18454440599769317, 0.15286428296808921, 1.0) -(0.84536716647443289, 0.19292579777008842, 0.15509419454056134, 1.0) -(0.84982698961937719, 0.20230680507497117, 0.15940023068050752, 1.0) -(0.85428681276432139, 0.2116878123798539, 0.16370626682045369, 1.0) -(0.8587466359092657, 0.22106881968473663, 0.16801230296039987, 1.0) -(0.8632064590542099, 0.23044982698961938, 0.17231833910034602, 1.0) -(0.8676662821991542, 0.23983083429450211, 0.1766243752402922, 1.0) -(0.8721261053440984, 0.24921184159938484, 0.18093041138023838, 1.0) -(0.87658592848904271, 0.25859284890426754, 0.18523644752018453, 1.0) -(0.88104575163398691, 0.26797385620915032, 0.18954248366013071, 1.0) -(0.88550557477893121, 0.27735486351403305, 0.19384851980007689, 1.0) -(0.88996539792387541, 0.28673587081891577, 0.19815455594002307, 1.0) -(0.89442522106881972, 0.29611687812379844, 0.20246059207996922, 1.0) -(0.89888504421376392, 0.30549788542868128, 0.20676662821991543, 1.0) -(0.90334486735870823, 0.31487889273356401, 0.21107266435986161, 1.0) -(0.90780469050365242, 0.32425990003844674, 0.21537870049980778, 1.0) -(0.91226451364859673, 0.33364090734332941, 0.21968473663975391, 1.0) -(0.91672433679354093, 0.34302191464821219, 0.22399077277970014, 1.0) -(0.92118415993848524, 0.35240292195309497, 0.22829680891964632, 1.0) -(0.92564398308342943, 0.36178392925797764, 0.23260284505959247, 1.0) -(0.93010380622837374, 0.37116493656286037, 0.23690888119953862, 1.0) -(0.93456362937331794, 0.38054594386774315, 0.24121491733948483, 1.0) -(0.93902345251826225, 0.38992695117262588, 0.24552095347943098, 1.0) -(0.94348327566320656, 0.39930795847750866, 0.24982698961937716, 1.0) -(0.94794309880815075, 0.40868896578239133, 0.25413302575932328, 1.0) -(0.95240292195309495, 0.41806997308727412, 0.25843906189926952, 1.0) -(0.95686274509803926, 0.42745098039215684, 0.2627450980392157, 1.0) -(0.95824682814302198, 0.43744713571703187, 0.26735870818915802, 1.0) -(0.9596309111880047, 0.44744329104190683, 0.27197231833910029, 1.0) -(0.96101499423298731, 0.45743944636678197, 0.27658592848904268, 1.0) -(0.96239907727797003, 0.46743560169165704, 0.281199538638985, 1.0) -(0.96378316032295275, 0.47743175701653207, 0.28581314878892733, 1.0) -(0.96516724336793547, 0.48742791234140703, 0.2904267589388696, 1.0) -(0.96655132641291819, 0.49742406766628217, 0.29504036908881198, 1.0) -(0.9679354094579008, 0.50742022299115719, 0.29965397923875431, 1.0) -(0.96931949250288352, 0.51741637831603227, 0.30426758938869664, 1.0) -(0.97070357554786624, 0.52741253364090723, 0.30888119953863891, 1.0) -(0.97208765859284896, 0.53740868896578231, 0.31349480968858129, 1.0) -(0.97347174163783168, 0.54740484429065739, 0.31810841983852362, 1.0) -(0.97485582468281429, 0.55740099961553247, 0.32272202998846594, 1.0) -(0.97623990772779701, 0.56739715494040743, 0.32733564013840827, 1.0) -(0.97762399077277973, 0.5773933102652824, 0.33194925028835054, 1.0) -(0.97900807381776245, 0.58738946559015759, 0.33656286043829292, 1.0) -(0.98039215686274517, 0.59738562091503256, 0.34117647058823525, 1.0) -(0.98177623990772778, 0.60738177623990763, 0.34579008073817757, 1.0) -(0.9831603229527105, 0.61737793156478271, 0.3504036908881199, 1.0) -(0.98454440599769322, 0.62737408688965768, 0.35501730103806223, 1.0) -(0.98592848904267594, 0.63737024221453276, 0.35963091118800455, 1.0) -(0.98731257208765866, 0.64736639753940783, 0.36424452133794688, 1.0) -(0.98869665513264127, 0.65736255286428269, 0.36885813148788915, 1.0) -(0.99008073817762399, 0.66735870818915788, 0.37347174163783153, 1.0) -(0.99146482122260671, 0.67735486351403296, 0.37808535178777386, 1.0) -(0.99223375624759713, 0.6861976163014224, 0.38400615148019979, 1.0) -(0.99238754325259515, 0.69388696655132631, 0.39123414071510948, 1.0) -(0.99254133025759328, 0.70157631680123023, 0.39846212995001912, 1.0) -(0.9926951172625913, 0.70926566705113414, 0.40569011918492875, 1.0) -(0.99284890426758943, 0.71695501730103794, 0.41291810841983845, 1.0) -(0.99300269127258745, 0.72464436755094175, 0.42014609765474797, 1.0) -(0.99315647827758557, 0.73233371780084577, 0.42737408688965772, 1.0) -(0.99331026528258359, 0.74002306805074969, 0.43460207612456736, 1.0) -(0.99346405228758172, 0.74771241830065349, 0.44183006535947705, 1.0) -(0.99361783929257985, 0.75540176855055741, 0.44905805459438669, 1.0) -(0.99377162629757787, 0.76309111880046132, 0.45628604382929633, 1.0) -(0.993925413302576, 0.77078046905036524, 0.46351403306420602, 1.0) -(0.99407920030757402, 0.77846981930026904, 0.47074202229911566, 1.0) -(0.99423298731257215, 0.78615916955017284, 0.47797001153402519, 1.0) -(0.99438677431757017, 0.79384851980007687, 0.48519800076893493, 1.0) -(0.9945405613225683, 0.80153787004998067, 0.49242599000384463, 1.0) -(0.99469434832756631, 0.80922722029988459, 0.49965397923875426, 1.0) -(0.99484813533256444, 0.8169165705497885, 0.50688196847366396, 1.0) -(0.99500192233756246, 0.82460592079969242, 0.51410995770857359, 1.0) -(0.99515570934256059, 0.83229527104959633, 0.52133794694348323, 1.0) -(0.99530949634755861, 0.83998462129950013, 0.52856593617839287, 1.0) -(0.99546328335255674, 0.84767397154940394, 0.5357939254133024, 1.0) -(0.99561707035755476, 0.85536332179930796, 0.54302191464821226, 1.0) -(0.99577085736255289, 0.86305267204921177, 0.55024990388312189, 1.0) -(0.9959246443675509, 0.87074202229911568, 0.55747789311803153, 1.0) -(0.99607843137254903, 0.8784313725490196, 0.56470588235294117, 1.0) -(0.99623221837754716, 0.88319876970396005, 0.57193387158785081, 1.0) -(0.99638600538254518, 0.8879661668589004, 0.57916186082276044, 1.0) -(0.99653979238754331, 0.89273356401384085, 0.58638985005767008, 1.0) -(0.99669357939254133, 0.8975009611687812, 0.59361783929257972, 1.0) -(0.99684736639753946, 0.90226835832372165, 0.60084582852748947, 1.0) -(0.99700115340253748, 0.907035755478662, 0.6080738177623991, 1.0) -(0.99715494040753561, 0.91180315263360245, 0.61530180699730874, 1.0) -(0.99730872741253362, 0.91657054978854291, 0.62252979623221838, 1.0) -(0.99746251441753175, 0.92133794694348325, 0.62975778546712802, 1.0) -(0.99761630142252977, 0.92610534409842371, 0.63698577470203765, 1.0) -(0.9977700884275279, 0.93087274125336406, 0.64421376393694729, 1.0) -(0.99792387543252592, 0.9356401384083044, 0.65144175317185682, 1.0) -(0.99807766243752405, 0.94040753556324486, 0.65866974240676668, 1.0) -(0.99823144944252207, 0.94517493271818531, 0.66589773164167632, 1.0) -(0.9983852364475202, 0.94994232987312577, 0.67312572087658595, 1.0) -(0.99853902345251822, 0.95470972702806611, 0.68035371011149559, 1.0) -(0.99869281045751634, 0.95947712418300657, 0.68758169934640523, 1.0) -(0.99884659746251447, 0.96424452133794691, 0.69480968858131487, 1.0) -(0.99900038446751249, 0.96901191849288737, 0.7020376778162245, 1.0) -(0.99915417147251062, 0.97377931564782771, 0.70926566705113414, 1.0) -(0.99930795847750864, 0.97854671280276817, 0.71649365628604378, 1.0) -(0.99946174548250677, 0.98331410995770852, 0.72372164552095353, 1.0) -(0.99961553248750479, 0.98808150711264897, 0.73094963475586316, 1.0) -(0.99976931949250292, 0.99284890426758943, 0.7381776239907728, 1.0) -(0.99992310649750094, 0.99761630142252977, 0.74540561322568244, 1.0) -(0.99761630142252977, 0.99907727797001156, 0.7534025374855825, 1.0) -(0.99284890426758943, 0.99723183391003456, 0.76216839677047288, 1.0) -(0.98808150711264897, 0.99538638985005767, 0.77093425605536325, 1.0) -(0.98331410995770863, 0.99354094579008079, 0.77970011534025374, 1.0) -(0.97854671280276828, 0.9916955017301039, 0.78846597462514389, 1.0) -(0.97377931564782783, 0.9898500576701269, 0.7972318339100346, 1.0) -(0.96901191849288737, 0.98800461361014991, 0.80599769319492498, 1.0) -(0.96424452133794702, 0.98615916955017302, 0.81476355247981536, 1.0) -(0.95947712418300657, 0.98431372549019602, 0.82352941176470584, 1.0) -(0.95470972702806622, 0.98246828143021914, 0.83229527104959622, 1.0) -(0.94994232987312577, 0.98062283737024225, 0.8410611303344866, 1.0) -(0.94517493271818531, 0.97877739331026525, 0.84982698961937708, 1.0) -(0.94040753556324497, 0.97693194925028837, 0.85859284890426746, 1.0) -(0.93564013840830451, 0.97508650519031137, 0.86735870818915783, 1.0) -(0.93087274125336417, 0.97324106113033448, 0.87612456747404832, 1.0) -(0.92610534409842371, 0.9713956170703576, 0.8848904267589387, 1.0) -(0.92133794694348337, 0.9695501730103806, 0.89365628604382907, 1.0) -(0.91657054978854291, 0.96770472895040371, 0.90242214532871956, 1.0) -(0.91180315263360256, 0.96585928489042672, 0.91118800461360994, 1.0) -(0.90703575547866211, 0.96401384083044983, 0.91995386389850031, 1.0) -(0.90226835832372188, 0.96216839677047294, 0.92871972318339058, 1.0) -(0.89750096116878131, 0.96032295271049595, 0.93748558246828129, 1.0) -(0.89273356401384096, 0.95847750865051906, 0.94625144175317155, 1.0) -(0.88796616685890051, 0.95663206459054206, 0.95501730103806204, 1.0) -(0.88319876970396016, 0.95478662053056518, 0.96378316032295241, 1.0) -(0.87843137254901971, 0.95294117647058818, 0.9725490196078429, 1.0) -(0.87028066128412174, 0.94894271434063826, 0.97024221453287207, 1.0) -(0.86212995001922355, 0.94494425221068823, 0.96793540945790091, 1.0) -(0.85397923875432546, 0.9409457900807382, 0.96562860438292974, 1.0) -(0.84582852748942738, 0.93694732795078828, 0.96332179930795858, 1.0) -(0.83767781622452919, 0.93294886582083825, 0.96101499423298731, 1.0) -(0.82952710495963111, 0.92895040369088822, 0.95870818915801614, 1.0) -(0.82137639369473303, 0.92495194156093818, 0.95640138408304498, 1.0) -(0.81322568242983484, 0.92095347943098815, 0.95409457900807382, 1.0) -(0.80507497116493676, 0.91695501730103812, 0.95178777393310265, 1.0) -(0.79692425990003868, 0.91295655517108809, 0.94948096885813149, 1.0) -(0.78877354863514082, 0.90895809304113817, 0.94717416378316044, 1.0) -(0.78062283737024241, 0.90495963091118803, 0.94486735870818916, 1.0) -(0.77247212610534433, 0.90096116878123811, 0.942560553633218, 1.0) -(0.76432141484044613, 0.89696270665128808, 0.94025374855824684, 1.0) -(0.75617070357554805, 0.89296424452133805, 0.93794694348327567, 1.0) -(0.74801999231064997, 0.88896578239138802, 0.93564013840830451, 1.0) -(0.73986928104575189, 0.88496732026143798, 0.93333333333333335, 1.0) -(0.7317185697808537, 0.88096885813148795, 0.93102652825836218, 1.0) -(0.72356785851595562, 0.87697039600153792, 0.92871972318339102, 1.0) -(0.71541714725105754, 0.87297193387158789, 0.92641291810841986, 1.0) -(0.70726643598615935, 0.86897347174163797, 0.9241061130334487, 1.0) -(0.69911572472126127, 0.86497500961168794, 0.92179930795847753, 1.0) -(0.69096501345636319, 0.86097654748173791, 0.91949250288350637, 1.0) -(0.68281430219146499, 0.85697808535178788, 0.91718569780853521, 1.0) -(0.67466359092656691, 0.85297962322183785, 0.91487889273356404, 1.0) -(0.6663590926566707, 0.84759707804690521, 0.91188004613610163, 1.0) -(0.6579008073817767, 0.84083044982698996, 0.90818915801614786, 1.0) -(0.64944252210688214, 0.83406382160707437, 0.90449826989619386, 1.0) -(0.64098423683198791, 0.8272971933871589, 0.90080738177623998, 1.0) -(0.63252595155709357, 0.82053056516724354, 0.8971164936562861, 1.0) -(0.62406766628219934, 0.81376393694732807, 0.89342560553633221, 1.0) -(0.615609381007305, 0.80699730872741271, 0.88973471741637833, 1.0) -(0.60715109573241077, 0.80023068050749724, 0.88604382929642445, 1.0) -(0.59869281045751643, 0.79346405228758177, 0.88235294117647067, 1.0) -(0.59023452518262221, 0.78669742406766641, 0.87866205305651679, 1.0) -(0.58177623990772787, 0.77993079584775094, 0.87497116493656291, 1.0) -(0.57331795463283364, 0.77316416762783557, 0.87128027681660902, 1.0) -(0.5648596693579393, 0.7663975394079201, 0.86758938869665514, 1.0) -(0.55640138408304507, 0.75963091118800474, 0.86389850057670126, 1.0) -(0.54794309880815084, 0.75286428296808927, 0.86020761245674737, 1.0) -(0.5394848135332565, 0.74609765474817391, 0.8565167243367936, 1.0) -(0.53102652825836227, 0.73933102652825844, 0.85282583621683972, 1.0) -(0.52256824298346816, 0.73256439830834319, 0.84913494809688594, 1.0) -(0.51410995770857371, 0.72579777008842761, 0.84544405997693195, 1.0) -(0.50565167243367937, 0.71903114186851214, 0.84175317185697807, 1.0) -(0.49719338715878514, 0.71226451364859678, 0.83806228373702418, 1.0) -(0.48873510188389085, 0.7054978854286813, 0.83437139561707041, 1.0) -(0.48027681660899657, 0.69873125720876594, 0.83068050749711653, 1.0) -(0.47181853133410223, 0.69196462898885047, 0.82698961937716264, 1.0) -(0.463360246059208, 0.68519800076893511, 0.82329873125720876, 1.0) -(0.45490196078431372, 0.67843137254901964, 0.81960784313725488, 1.0) -(0.44767397154940408, 0.66981930026912728, 0.81514801999231068, 1.0) -(0.44044598231449444, 0.66120722798923492, 0.81068819684736637, 1.0) -(0.43321799307958475, 0.65259515570934257, 0.80622837370242217, 1.0) -(0.42599000384467511, 0.64398308342945021, 0.80176855055747787, 1.0) -(0.41876201460976548, 0.63537101114955785, 0.79730872741253367, 1.0) -(0.41153402537485584, 0.62675893886966549, 0.79284890426758936, 1.0) -(0.40430603613994615, 0.61814686658977314, 0.78838908112264516, 1.0) -(0.39707804690503673, 0.60953479430988111, 0.78392925797770097, 1.0) -(0.38985005767012687, 0.60092272202998842, 0.77946943483275666, 1.0) -(0.38262206843521723, 0.59231064975009617, 0.77500961168781235, 1.0) -(0.37539407920030754, 0.58369857747020382, 0.77054978854286815, 1.0) -(0.3681660899653979, 0.57508650519031146, 0.76608996539792384, 1.0) -(0.36093810073048826, 0.5664744329104191, 0.76163014225297965, 1.0) -(0.35371011149557863, 0.55786236063052674, 0.75717031910803534, 1.0) -(0.34648212226066899, 0.54925028835063439, 0.75271049596309114, 1.0) -(0.3392541330257593, 0.54063821607074203, 0.74825067281814683, 1.0) -(0.33202614379084966, 0.53202614379084967, 0.74379084967320264, 1.0) -(0.32479815455593997, 0.52341407151095731, 0.73933102652825844, 1.0) -(0.31757016532103033, 0.51480199923106496, 0.73487120338331413, 1.0) -(0.31034217608612069, 0.5061899269511726, 0.73041138023836993, 1.0) -(0.30311418685121105, 0.49757785467128024, 0.72595155709342563, 1.0) -(0.29588619761630142, 0.48896578239138788, 0.72149173394848143, 1.0) -(0.28865820838139178, 0.48035371011149552, 0.71703191080353712, 1.0) -(0.28143021914648231, 0.4717416378316035, 0.71257208765859303, 1.0) -(0.2742022299115725, 0.46312956555171086, 0.70811226451364861, 1.0) -(0.26905036524413684, 0.45397923875432522, 0.70349865436370629, 1.0) -(0.2659746251441753, 0.44429065743944635, 0.69873125720876594, 1.0) -(0.26289888504421377, 0.43460207612456747, 0.69396386005382549, 1.0) -(0.25982314494425218, 0.42491349480968854, 0.68919646289888514, 1.0) -(0.25674740484429065, 0.41522491349480967, 0.68442906574394469, 1.0) -(0.25367166474432912, 0.40553633217993079, 0.67966166858900423, 1.0) -(0.25059592464436753, 0.39584775086505186, 0.67489427143406389, 1.0) -(0.247520184544406, 0.38615916955017299, 0.67012687427912343, 1.0) -(0.24444444444444444, 0.37647058823529411, 0.66535947712418309, 1.0) -(0.24136870434448288, 0.36678200692041518, 0.66059207996924263, 1.0) -(0.23829296424452134, 0.35709342560553631, 0.65582468281430228, 1.0) -(0.23521722414455978, 0.34740484429065743, 0.65105728565936183, 1.0) -(0.23214148404459822, 0.33771626297577856, 0.64628988850442137, 1.0) -(0.22906574394463669, 0.32802768166089963, 0.64152249134948103, 1.0) -(0.22599000384467521, 0.31833910034602103, 0.63675509419454079, 1.0) -(0.22291426374471357, 0.30865051903114188, 0.63198769703960023, 1.0) -(0.21983852364475201, 0.29896193771626295, 0.62722029988465977, 1.0) -(0.21676278354479048, 0.28927335640138407, 0.62245290272971943, 1.0) -(0.21368704344482892, 0.2795847750865052, 0.61768550557477897, 1.0) -(0.21061130334486738, 0.26989619377162632, 0.61291810841983851, 1.0) -(0.2075355632449058, 0.26020761245674739, 0.60815071126489817, 1.0) -(0.20445982314494426, 0.25051903114186846, 0.60338331410995771, 1.0) -(0.2013840830449827, 0.24083044982698962, 0.59861591695501737, 1.0) -(0.19830834294502114, 0.23114186851211074, 0.59384851980007691, 1.0) -(0.19523260284505961, 0.22145328719723181, 0.58908112264513646, 1.0) -(0.19215686274509805, 0.21176470588235294, 0.58431372549019611, 1.0) diff --git a/extern/tfn/colormaps/diverging/RdYlGn.cpp b/extern/tfn/colormaps/diverging/RdYlGn.cpp deleted file mode 100644 index 48ca9eb..0000000 --- a/extern/tfn/colormaps/diverging/RdYlGn.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_diverging_RdYlGn; -} -const std::vector colormap::data_diverging_RdYlGn = /* NOLINT(cert-err58-cpp) */ -{ -{0.6470588235294118f, 0.0f, 0.14901960784313725f, 1.0f}, -{0.65474817377931571f, 0.0073817762399077278f, 0.14917339484813533f, 1.0f}, -{0.66243752402921952f, 0.014763552479815456f, 0.1493271818531334f, 1.0f}, -{0.67012687427912343f, 0.022145328719723183f, 0.14948096885813147f, 1.0f}, -{0.67781622452902734f, 0.029527104959630911f, 0.14963475586312958f, 1.0f}, -{0.68550557477893115f, 0.03690888119953864f, 0.14978854286812765f, 1.0f}, -{0.69319492502883506f, 0.044290657439446365f, 0.14994232987312572f, 1.0f}, -{0.70088427527873898f, 0.051672433679354098f, 0.1500961168781238f, 1.0f}, -{0.70857362552864289f, 0.059054209919261823f, 0.15024990388312187f, 1.0f}, -{0.7162629757785467f, 0.066435986159169555f, 0.15040369088811995f, 1.0f}, -{0.72395232602845061f, 0.07381776239907728f, 0.15055747789311805f, 1.0f}, -{0.73164167627835452f, 0.081199538638985005f, 0.15071126489811612f, 1.0f}, -{0.73933102652825844f, 0.088581314878892731f, 0.15086505190311419f, 1.0f}, -{0.74702037677816224f, 0.095963091118800456f, 0.15101883890811227f, 1.0f}, -{0.75470972702806616f, 0.1033448673587082f, 0.15117262591311034f, 1.0f}, -{0.76239907727797007f, 0.11072664359861592f, 0.15132641291810842f, 1.0f}, -{0.77008842752787388f, 0.11810841983852365f, 0.15148019992310652f, 1.0f}, -{0.77777777777777779f, 0.12549019607843137f, 0.15163398692810459f, 1.0f}, -{0.7854671280276817f, 0.13287197231833911f, 0.15178777393310267f, 1.0f}, -{0.79315647827758551f, 0.14025374855824682f, 0.15194156093810074f, 1.0f}, -{0.80084582852748942f, 0.14763552479815456f, 0.15209534794309881f, 1.0f}, -{0.80853517877739334f, 0.15501730103806227f, 0.15224913494809689f, 1.0f}, -{0.81622452902729714f, 0.16239907727797001f, 0.15240292195309496f, 1.0f}, -{0.82391387927720106f, 0.16978085351787775f, 0.15255670895809306f, 1.0f}, -{0.83160322952710497f, 0.17716262975778546f, 0.15271049596309114f, 1.0f}, -{0.83929257977700877f, 0.18454440599769317f, 0.15286428296808921f, 1.0f}, -{0.84536716647443289f, 0.19292579777008842f, 0.15509419454056134f, 1.0f}, -{0.84982698961937719f, 0.20230680507497117f, 0.15940023068050752f, 1.0f}, -{0.85428681276432139f, 0.2116878123798539f, 0.16370626682045369f, 1.0f}, -{0.8587466359092657f, 0.22106881968473663f, 0.16801230296039987f, 1.0f}, -{0.8632064590542099f, 0.23044982698961938f, 0.17231833910034602f, 1.0f}, -{0.8676662821991542f, 0.23983083429450211f, 0.1766243752402922f, 1.0f}, -{0.8721261053440984f, 0.24921184159938484f, 0.18093041138023838f, 1.0f}, -{0.87658592848904271f, 0.25859284890426754f, 0.18523644752018453f, 1.0f}, -{0.88104575163398691f, 0.26797385620915032f, 0.18954248366013071f, 1.0f}, -{0.88550557477893121f, 0.27735486351403305f, 0.19384851980007689f, 1.0f}, -{0.88996539792387541f, 0.28673587081891577f, 0.19815455594002307f, 1.0f}, -{0.89442522106881972f, 0.29611687812379844f, 0.20246059207996922f, 1.0f}, -{0.89888504421376392f, 0.30549788542868128f, 0.20676662821991543f, 1.0f}, -{0.90334486735870823f, 0.31487889273356401f, 0.21107266435986161f, 1.0f}, -{0.90780469050365242f, 0.32425990003844674f, 0.21537870049980778f, 1.0f}, -{0.91226451364859673f, 0.33364090734332941f, 0.21968473663975391f, 1.0f}, -{0.91672433679354093f, 0.34302191464821219f, 0.22399077277970014f, 1.0f}, -{0.92118415993848524f, 0.35240292195309497f, 0.22829680891964632f, 1.0f}, -{0.92564398308342943f, 0.36178392925797764f, 0.23260284505959247f, 1.0f}, -{0.93010380622837374f, 0.37116493656286037f, 0.23690888119953862f, 1.0f}, -{0.93456362937331794f, 0.38054594386774315f, 0.24121491733948483f, 1.0f}, -{0.93902345251826225f, 0.38992695117262588f, 0.24552095347943098f, 1.0f}, -{0.94348327566320656f, 0.39930795847750866f, 0.24982698961937716f, 1.0f}, -{0.94794309880815075f, 0.40868896578239133f, 0.25413302575932328f, 1.0f}, -{0.95240292195309495f, 0.41806997308727412f, 0.25843906189926952f, 1.0f}, -{0.95686274509803926f, 0.42745098039215684f, 0.2627450980392157f, 1.0f}, -{0.95824682814302198f, 0.43744713571703187f, 0.26735870818915802f, 1.0f}, -{0.9596309111880047f, 0.44744329104190683f, 0.27197231833910029f, 1.0f}, -{0.96101499423298731f, 0.45743944636678197f, 0.27658592848904268f, 1.0f}, -{0.96239907727797003f, 0.46743560169165704f, 0.281199538638985f, 1.0f}, -{0.96378316032295275f, 0.47743175701653207f, 0.28581314878892733f, 1.0f}, -{0.96516724336793547f, 0.48742791234140703f, 0.2904267589388696f, 1.0f}, -{0.96655132641291819f, 0.49742406766628217f, 0.29504036908881198f, 1.0f}, -{0.9679354094579008f, 0.50742022299115719f, 0.29965397923875431f, 1.0f}, -{0.96931949250288352f, 0.51741637831603227f, 0.30426758938869664f, 1.0f}, -{0.97070357554786624f, 0.52741253364090723f, 0.30888119953863891f, 1.0f}, -{0.97208765859284896f, 0.53740868896578231f, 0.31349480968858129f, 1.0f}, -{0.97347174163783168f, 0.54740484429065739f, 0.31810841983852362f, 1.0f}, -{0.97485582468281429f, 0.55740099961553247f, 0.32272202998846594f, 1.0f}, -{0.97623990772779701f, 0.56739715494040743f, 0.32733564013840827f, 1.0f}, -{0.97762399077277973f, 0.5773933102652824f, 0.33194925028835054f, 1.0f}, -{0.97900807381776245f, 0.58738946559015759f, 0.33656286043829292f, 1.0f}, -{0.98039215686274517f, 0.59738562091503256f, 0.34117647058823525f, 1.0f}, -{0.98177623990772778f, 0.60738177623990763f, 0.34579008073817757f, 1.0f}, -{0.9831603229527105f, 0.61737793156478271f, 0.3504036908881199f, 1.0f}, -{0.98454440599769322f, 0.62737408688965768f, 0.35501730103806223f, 1.0f}, -{0.98592848904267594f, 0.63737024221453276f, 0.35963091118800455f, 1.0f}, -{0.98731257208765866f, 0.64736639753940783f, 0.36424452133794688f, 1.0f}, -{0.98869665513264127f, 0.65736255286428269f, 0.36885813148788915f, 1.0f}, -{0.99008073817762399f, 0.66735870818915788f, 0.37347174163783153f, 1.0f}, -{0.99146482122260671f, 0.67735486351403296f, 0.37808535178777386f, 1.0f}, -{0.99223375624759713f, 0.6861976163014224f, 0.38362168396770463f, 1.0f}, -{0.99238754325259515f, 0.69388696655132631f, 0.3900807381776239f, 1.0f}, -{0.99254133025759328f, 0.70157631680123023f, 0.39653979238754317f, 1.0f}, -{0.9926951172625913f, 0.70926566705113414f, 0.40299884659746243f, 1.0f}, -{0.99284890426758943f, 0.71695501730103794f, 0.40945790080738165f, 1.0f}, -{0.99300269127258745f, 0.72464436755094175f, 0.41591695501730086f, 1.0f}, -{0.99315647827758557f, 0.73233371780084577f, 0.42237600922722018f, 1.0f}, -{0.99331026528258359f, 0.74002306805074969f, 0.42883506343713945f, 1.0f}, -{0.99346405228758172f, 0.74771241830065349f, 0.43529411764705872f, 1.0f}, -{0.99361783929257985f, 0.75540176855055741f, 0.44175317185697799f, 1.0f}, -{0.99377162629757787f, 0.76309111880046132f, 0.44821222606689726f, 1.0f}, -{0.993925413302576f, 0.77078046905036524f, 0.45467128027681653f, 1.0f}, -{0.99407920030757402f, 0.77846981930026904f, 0.46113033448673579f, 1.0f}, -{0.99423298731257215f, 0.78615916955017284f, 0.46758938869665495f, 1.0f}, -{0.99438677431757017f, 0.79384851980007687f, 0.47404844290657433f, 1.0f}, -{0.9945405613225683f, 0.80153787004998067f, 0.48050749711649354f, 1.0f}, -{0.99469434832756631f, 0.80922722029988459f, 0.48696655132641287f, 1.0f}, -{0.99484813533256444f, 0.8169165705497885f, 0.49342560553633208f, 1.0f}, -{0.99500192233756246f, 0.82460592079969242f, 0.4998846597462514f, 1.0f}, -{0.99515570934256059f, 0.83229527104959633f, 0.50634371395617062f, 1.0f}, -{0.99530949634755861f, 0.83998462129950013f, 0.51280276816608994f, 1.0f}, -{0.99546328335255674f, 0.84767397154940394f, 0.51926182237600904f, 1.0f}, -{0.99561707035755476f, 0.85536332179930796f, 0.52572087658592848f, 1.0f}, -{0.99577085736255289f, 0.86305267204921177f, 0.53217993079584769f, 1.0f}, -{0.9959246443675509f, 0.87074202229911568f, 0.5386389850057669f, 1.0f}, -{0.99607843137254903f, 0.8784313725490196f, 0.54509803921568623f, 1.0f}, -{0.99623221837754716f, 0.88319876970396005f, 0.55309496347558629f, 1.0f}, -{0.99638600538254518f, 0.8879661668589004f, 0.56109188773548635f, 1.0f}, -{0.99653979238754331f, 0.89273356401384085f, 0.5690888119953863f, 1.0f}, -{0.99669357939254133f, 0.8975009611687812f, 0.57708573625528625f, 1.0f}, -{0.99684736639753946f, 0.90226835832372165f, 0.58508266051518643f, 1.0f}, -{0.99700115340253748f, 0.907035755478662f, 0.59307958477508649f, 1.0f}, -{0.99715494040753561f, 0.91180315263360245f, 0.60107650903498655f, 1.0f}, -{0.99730872741253362f, 0.91657054978854291f, 0.6090734332948865f, 1.0f}, -{0.99746251441753175f, 0.92133794694348325f, 0.61707035755478656f, 1.0f}, -{0.99761630142252977f, 0.92610534409842371f, 0.62506728181468663f, 1.0f}, -{0.9977700884275279f, 0.93087274125336406f, 0.63306420607458669f, 1.0f}, -{0.99792387543252592f, 0.9356401384083044f, 0.64106113033448664f, 1.0f}, -{0.99807766243752405f, 0.94040753556324486f, 0.6490580545943867f, 1.0f}, -{0.99823144944252207f, 0.94517493271818531f, 0.65705497885428676f, 1.0f}, -{0.9983852364475202f, 0.94994232987312577f, 0.66505190311418683f, 1.0f}, -{0.99853902345251822f, 0.95470972702806611f, 0.67304882737408689f, 1.0f}, -{0.99869281045751634f, 0.95947712418300657f, 0.68104575163398695f, 1.0f}, -{0.99884659746251447f, 0.96424452133794691f, 0.68904267589388701f, 1.0f}, -{0.99900038446751249f, 0.96901191849288737f, 0.69703960015378696f, 1.0f}, -{0.99915417147251062f, 0.97377931564782771f, 0.70503652441368692f, 1.0f}, -{0.99930795847750864f, 0.97854671280276817f, 0.71303344867358709f, 1.0f}, -{0.99946174548250677f, 0.98331410995770852f, 0.72103037293348715f, 1.0f}, -{0.99961553248750479f, 0.98808150711264897f, 0.7290272971933871f, 1.0f}, -{0.99976931949250292f, 0.99284890426758943f, 0.73702422145328716f, 1.0f}, -{0.99992310649750094f, 0.99761630142252977f, 0.74502114571318723f, 1.0f}, -{0.99707804690503654f, 0.99876970396001541f, 0.74502114571318723f, 1.0f}, -{0.99123414071510962f, 0.99630911188004612f, 0.73702422145328716f, 1.0f}, -{0.9853902345251826f, 0.99384851980007693f, 0.72902729719338721f, 1.0f}, -{0.97954632833525568f, 0.99138792772010764f, 0.72103037293348715f, 1.0f}, -{0.97370242214532887f, 0.98892733564013846f, 0.71303344867358731f, 1.0f}, -{0.96785851595540184f, 0.98646674356016917f, 0.70503652441368714f, 1.0f}, -{0.96201460976547482f, 0.98400615148019999f, 0.69703960015378708f, 1.0f}, -{0.9561707035755479f, 0.98154555940023069f, 0.68904267589388701f, 1.0f}, -{0.95032679738562098f, 0.97908496732026151f, 0.68104575163398695f, 1.0f}, -{0.94448289119569406f, 0.97662437524029222f, 0.673048827374087f, 1.0f}, -{0.93863898500576703f, 0.97416378316032293f, 0.66505190311418694f, 1.0f}, -{0.93279507881584012f, 0.97170319108035375f, 0.65705497885428688f, 1.0f}, -{0.9269511726259132f, 0.96924259900038445f, 0.64905805459438681f, 1.0f}, -{0.92110726643598628f, 0.96678200692041527f, 0.64106113033448686f, 1.0f}, -{0.91526336024605925f, 0.96432141484044598f, 0.6330642060745868f, 1.0f}, -{0.90941945405613234f, 0.9618608227604768f, 0.62506728181468674f, 1.0f}, -{0.90357554786620542f, 0.9594002306805075f, 0.61707035755478667f, 1.0f}, -{0.89773164167627839f, 0.95693963860053832f, 0.60907343329488672f, 1.0f}, -{0.89188773548635147f, 0.95447904652056903f, 0.60107650903498666f, 1.0f}, -{0.88604382929642456f, 0.95201845444059985f, 0.5930795847750866f, 1.0f}, -{0.88019992310649775f, 0.94955786236063067f, 0.58508266051518687f, 1.0f}, -{0.87435601691657072f, 0.94709727028066137f, 0.57708573625528659f, 1.0f}, -{0.86851211072664369f, 0.94463667820069208f, 0.56908881199538652f, 1.0f}, -{0.86266820453671678f, 0.9421760861207229f, 0.56109188773548646f, 1.0f}, -{0.85682429834678986f, 0.93971549404075361f, 0.55309496347558651f, 1.0f}, -{0.85098039215686283f, 0.93725490196078443f, 0.54509803921568645f, 1.0f}, -{0.84313725490196101f, 0.93387158785082669f, 0.54002306805074984f, 1.0f}, -{0.83529411764705908f, 0.93048827374086895f, 0.53494809688581324f, 1.0f}, -{0.82745098039215703f, 0.92710495963091133f, 0.52987312572087664f, 1.0f}, -{0.8196078431372551f, 0.92372164552095359f, 0.52479815455594014f, 1.0f}, -{0.81176470588235317f, 0.92033833141099586f, 0.51972318339100354f, 1.0f}, -{0.80392156862745123f, 0.91695501730103812f, 0.51464821222606705f, 1.0f}, -{0.79607843137254919f, 0.9135717031910805f, 0.50957324106113044f, 1.0f}, -{0.78823529411764726f, 0.91018838908112276f, 0.50449826989619384f, 1.0f}, -{0.78039215686274532f, 0.90680507497116503f, 0.49942329873125735f, 1.0f}, -{0.77254901960784339f, 0.90342176086120729f, 0.49434832756632074f, 1.0f}, -{0.76470588235294157f, 0.90003844675124967f, 0.48927335640138436f, 1.0f}, -{0.75686274509803941f, 0.89665513264129193f, 0.48419838523644765f, 1.0f}, -{0.74901960784313748f, 0.89327181853133419f, 0.4791234140715111f, 1.0f}, -{0.74117647058823555f, 0.88988850442137646f, 0.47404844290657455f, 1.0f}, -{0.7333333333333335f, 0.88650519031141872f, 0.46897347174163795f, 1.0f}, -{0.72549019607843157f, 0.8831218762014611f, 0.4638985005767014f, 1.0f}, -{0.71764705882352964f, 0.87973856209150336f, 0.45882352941176485f, 1.0f}, -{0.7098039215686277f, 0.87635524798154563f, 0.45374855824682825f, 1.0f}, -{0.70196078431372566f, 0.87297193387158789f, 0.44867358708189176f, 1.0f}, -{0.69411764705882373f, 0.86958861976163027f, 0.44359861591695515f, 1.0f}, -{0.6862745098039218f, 0.86620530565167253f, 0.4385236447520186f, 1.0f}, -{0.67843137254901986f, 0.86282199154171479f, 0.43344867358708206f, 1.0f}, -{0.67058823529411793f, 0.85943867743175706f, 0.42837370242214545f, 1.0f}, -{0.662745098039216f, 0.85605536332179932f, 0.42329873125720896f, 1.0f}, -{0.65490196078431395f, 0.8526720492118417f, 0.41822376009227236f, 1.0f}, -{0.64605920799692451f, 0.8488273740868898f, 0.41514801999231071f, 1.0f}, -{0.6362168396770479f, 0.84452133794694373f, 0.4140715109573242f, 1.0f}, -{0.62637447135717061f, 0.84021530180699744f, 0.41299500192233762f, 1.0f}, -{0.61653210303729367f, 0.83590926566705126f, 0.41191849288735105f, 1.0f}, -{0.60668973471741661f, 0.83160322952710508f, 0.41084198385236453f, 1.0f}, -{0.59684736639753966f, 0.8272971933871589f, 0.40976547481737796f, 1.0f}, -{0.58700499807766271f, 0.82299115724721272f, 0.40868896578239144f, 1.0f}, -{0.57716262975778565f, 0.81868512110726654f, 0.40761245674740487f, 1.0f}, -{0.5673202614379087f, 0.81437908496732037f, 0.40653594771241836f, 1.0f}, -{0.55747789311803175f, 0.81007304882737419f, 0.40545943867743178f, 1.0f}, -{0.54763552479815469f, 0.80576701268742801f, 0.40438292964244527f, 1.0f}, -{0.53779315647827775f, 0.80146097654748183f, 0.40330642060745869f, 1.0f}, -{0.5279507881584008f, 0.79715494040753565f, 0.40222991157247218f, 1.0f}, -{0.51810841983852374f, 0.79284890426758947f, 0.4011534025374856f, 1.0f}, -{0.50826605151864679f, 0.78854286812764329f, 0.40007689350249909f, 1.0f}, -{0.49842368319876984f, 0.78423683198769711f, 0.39900038446751251f, 1.0f}, -{0.48858131487889289f, 0.77993079584775094f, 0.397923875432526f, 1.0f}, -{0.47873894655901617f, 0.77562475970780487f, 0.39684736639753948f, 1.0f}, -{0.46889657823913888f, 0.77131872356785858f, 0.39577085736255291f, 1.0f}, -{0.45905420991926194f, 0.7670126874279124f, 0.39469434832756634f, 1.0f}, -{0.44921184159938493f, 0.76270665128796622f, 0.39361783929257982f, 1.0f}, -{0.43936947327950793f, 0.75840061514802004f, 0.39254133025759325f, 1.0f}, -{0.42952710495963098f, 0.75409457900807386f, 0.39146482122260673f, 1.0f}, -{0.41968473663975397f, 0.74978854286812768f, 0.39038831218762016f, 1.0f}, -{0.40984236831987703f, 0.7454825067281815f, 0.38931180315263358f, 1.0f}, -{0.40000000000000002f, 0.74117647058823533f, 0.38823529411764707f, 1.0f}, -{0.38831218762014613f, 0.73548635140330643f, 0.38531334102268361f, 1.0f}, -{0.37662437524029224f, 0.72979623221837753f, 0.38239138792772009f, 1.0f}, -{0.3649365628604383f, 0.72410611303344874f, 0.37946943483275664f, 1.0f}, -{0.35324875048058441f, 0.71841599384851984f, 0.37654748173779318f, 1.0f}, -{0.34156093810073052f, 0.71272587466359094f, 0.37362552864282966f, 1.0f}, -{0.32987312572087657f, 0.70703575547866204f, 0.3707035755478662f, 1.0f}, -{0.31818531334102268f, 0.70134563629373314f, 0.36778162245290275f, 1.0f}, -{0.30649750096116912f, 0.69565551710880447f, 0.36485966935793934f, 1.0f}, -{0.29480968858131484f, 0.68996539792387546f, 0.36193771626297577f, 1.0f}, -{0.28312187620146101f, 0.68427527873894656f, 0.35901576316801231f, 1.0f}, -{0.27143406382160706f, 0.67858515955401766f, 0.35609381007304886f, 1.0f}, -{0.25974625144175317f, 0.67289504036908887f, 0.35317185697808534f, 1.0f}, -{0.24805843906189928f, 0.66720492118415997f, 0.35024990388312188f, 1.0f}, -{0.23637062668204534f, 0.66151480199923107f, 0.34732795078815837f, 1.0f}, -{0.22468281430219145f, 0.65582468281430217f, 0.34440599769319491f, 1.0f}, -{0.21299500192233756f, 0.65013456362937339f, 0.34148404459823145f, 1.0f}, -{0.20130718954248367f, 0.64444444444444449f, 0.33856209150326799f, 1.0f}, -{0.18961937716262972f, 0.63875432525951559f, 0.33564013840830448f, 1.0f}, -{0.17793156478277583f, 0.63306420607458669f, 0.33271818531334102f, 1.0f}, -{0.16624375240292194f, 0.62737408688965779f, 0.32979623221837756f, 1.0f}, -{0.15455594002306805f, 0.621683967704729f, 0.32687427912341405f, 1.0f}, -{0.1428681276432141f, 0.6159938485198001f, 0.32395232602845059f, 1.0f}, -{0.13118031526336021f, 0.6103037293348712f, 0.32103037293348713f, 1.0f}, -{0.11949250288350666f, 0.60461361014994253f, 0.31810841983852373f, 1.0f}, -{0.10780469050365243f, 0.59892349096501341f, 0.31518646674356016f, 1.0f}, -{0.099961553248750473f, 0.59238754325259513f, 0.31180315263360248f, 1.0f}, -{0.095963091118800456f, 0.58500576701268747f, 0.30795847750865052f, 1.0f}, -{0.091964628988850439f, 0.57762399077277971f, 0.30411380238369856f, 1.0f}, -{0.087966166858900421f, 0.57024221453287194f, 0.30026912725874666f, 1.0f}, -{0.083967704728950404f, 0.56286043829296428f, 0.2964244521337947f, 1.0f}, -{0.079969242599000387f, 0.55547866205305652f, 0.29257977700884275f, 1.0f}, -{0.07597078046905037f, 0.54809688581314875f, 0.28873510188389079f, 1.0f}, -{0.071972318339100338f, 0.54071510957324109f, 0.28489042675893889f, 1.0f}, -{0.067973856209150335f, 0.53333333333333333f, 0.28104575163398693f, 1.0f}, -{0.063975394079200304f, 0.52595155709342556f, 0.27720107650903497f, 1.0f}, -{0.059976931949250287f, 0.5185697808535179f, 0.27335640138408307f, 1.0f}, -{0.055978469819300269f, 0.51118800461361014f, 0.26951172625913111f, 1.0f}, -{0.051980007689350252f, 0.50380622837370237f, 0.26566705113417916f, 1.0f}, -{0.047981545559400228f, 0.49642445213379471f, 0.2618223760092272f, 1.0f}, -{0.043983083429450329f, 0.48904267589388717f, 0.25797770088427541f, 1.0f}, -{0.039984621299500193f, 0.48166089965397924f, 0.25413302575932334f, 1.0f}, -{0.035986159169550169f, 0.47427912341407152f, 0.25028835063437138f, 1.0f}, -{0.031987697039600152f, 0.46689734717416376f, 0.24644367550941948f, 1.0f}, -{0.027989234909650135f, 0.45951557093425605f, 0.24259900038446752f, 1.0f}, -{0.023990772779700117f, 0.45213379469434833f, 0.23875432525951557f, 1.0f}, -{0.019992310649750086f, 0.44475201845444057f, 0.23490965013456364f, 1.0f}, -{0.015993848519800083f, 0.43737024221453286f, 0.23106497500961171f, 1.0f}, -{0.011995386389850066f, 0.42998846597462514f, 0.22722029988465975f, 1.0f}, -{0.0079969242599000484f, 0.42260668973471743f, 0.22337562475970782f, 1.0f}, -{0.0039984621299500173f, 0.41522491349480967f, 0.21953094963475589f, 1.0f}, -{0.0f, 0.40784313725490196f, 0.21568627450980393f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/diverging/RdYlGn.txt b/extern/tfn/colormaps/diverging/RdYlGn.txt deleted file mode 100644 index 079e8bc..0000000 --- a/extern/tfn/colormaps/diverging/RdYlGn.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.6470588235294118, 0.0, 0.14901960784313725, 1.0) -(0.65474817377931571, 0.0073817762399077278, 0.14917339484813533, 1.0) -(0.66243752402921952, 0.014763552479815456, 0.1493271818531334, 1.0) -(0.67012687427912343, 0.022145328719723183, 0.14948096885813147, 1.0) -(0.67781622452902734, 0.029527104959630911, 0.14963475586312958, 1.0) -(0.68550557477893115, 0.03690888119953864, 0.14978854286812765, 1.0) -(0.69319492502883506, 0.044290657439446365, 0.14994232987312572, 1.0) -(0.70088427527873898, 0.051672433679354098, 0.1500961168781238, 1.0) -(0.70857362552864289, 0.059054209919261823, 0.15024990388312187, 1.0) -(0.7162629757785467, 0.066435986159169555, 0.15040369088811995, 1.0) -(0.72395232602845061, 0.07381776239907728, 0.15055747789311805, 1.0) -(0.73164167627835452, 0.081199538638985005, 0.15071126489811612, 1.0) -(0.73933102652825844, 0.088581314878892731, 0.15086505190311419, 1.0) -(0.74702037677816224, 0.095963091118800456, 0.15101883890811227, 1.0) -(0.75470972702806616, 0.1033448673587082, 0.15117262591311034, 1.0) -(0.76239907727797007, 0.11072664359861592, 0.15132641291810842, 1.0) -(0.77008842752787388, 0.11810841983852365, 0.15148019992310652, 1.0) -(0.77777777777777779, 0.12549019607843137, 0.15163398692810459, 1.0) -(0.7854671280276817, 0.13287197231833911, 0.15178777393310267, 1.0) -(0.79315647827758551, 0.14025374855824682, 0.15194156093810074, 1.0) -(0.80084582852748942, 0.14763552479815456, 0.15209534794309881, 1.0) -(0.80853517877739334, 0.15501730103806227, 0.15224913494809689, 1.0) -(0.81622452902729714, 0.16239907727797001, 0.15240292195309496, 1.0) -(0.82391387927720106, 0.16978085351787775, 0.15255670895809306, 1.0) -(0.83160322952710497, 0.17716262975778546, 0.15271049596309114, 1.0) -(0.83929257977700877, 0.18454440599769317, 0.15286428296808921, 1.0) -(0.84536716647443289, 0.19292579777008842, 0.15509419454056134, 1.0) -(0.84982698961937719, 0.20230680507497117, 0.15940023068050752, 1.0) -(0.85428681276432139, 0.2116878123798539, 0.16370626682045369, 1.0) -(0.8587466359092657, 0.22106881968473663, 0.16801230296039987, 1.0) -(0.8632064590542099, 0.23044982698961938, 0.17231833910034602, 1.0) -(0.8676662821991542, 0.23983083429450211, 0.1766243752402922, 1.0) -(0.8721261053440984, 0.24921184159938484, 0.18093041138023838, 1.0) -(0.87658592848904271, 0.25859284890426754, 0.18523644752018453, 1.0) -(0.88104575163398691, 0.26797385620915032, 0.18954248366013071, 1.0) -(0.88550557477893121, 0.27735486351403305, 0.19384851980007689, 1.0) -(0.88996539792387541, 0.28673587081891577, 0.19815455594002307, 1.0) -(0.89442522106881972, 0.29611687812379844, 0.20246059207996922, 1.0) -(0.89888504421376392, 0.30549788542868128, 0.20676662821991543, 1.0) -(0.90334486735870823, 0.31487889273356401, 0.21107266435986161, 1.0) -(0.90780469050365242, 0.32425990003844674, 0.21537870049980778, 1.0) -(0.91226451364859673, 0.33364090734332941, 0.21968473663975391, 1.0) -(0.91672433679354093, 0.34302191464821219, 0.22399077277970014, 1.0) -(0.92118415993848524, 0.35240292195309497, 0.22829680891964632, 1.0) -(0.92564398308342943, 0.36178392925797764, 0.23260284505959247, 1.0) -(0.93010380622837374, 0.37116493656286037, 0.23690888119953862, 1.0) -(0.93456362937331794, 0.38054594386774315, 0.24121491733948483, 1.0) -(0.93902345251826225, 0.38992695117262588, 0.24552095347943098, 1.0) -(0.94348327566320656, 0.39930795847750866, 0.24982698961937716, 1.0) -(0.94794309880815075, 0.40868896578239133, 0.25413302575932328, 1.0) -(0.95240292195309495, 0.41806997308727412, 0.25843906189926952, 1.0) -(0.95686274509803926, 0.42745098039215684, 0.2627450980392157, 1.0) -(0.95824682814302198, 0.43744713571703187, 0.26735870818915802, 1.0) -(0.9596309111880047, 0.44744329104190683, 0.27197231833910029, 1.0) -(0.96101499423298731, 0.45743944636678197, 0.27658592848904268, 1.0) -(0.96239907727797003, 0.46743560169165704, 0.281199538638985, 1.0) -(0.96378316032295275, 0.47743175701653207, 0.28581314878892733, 1.0) -(0.96516724336793547, 0.48742791234140703, 0.2904267589388696, 1.0) -(0.96655132641291819, 0.49742406766628217, 0.29504036908881198, 1.0) -(0.9679354094579008, 0.50742022299115719, 0.29965397923875431, 1.0) -(0.96931949250288352, 0.51741637831603227, 0.30426758938869664, 1.0) -(0.97070357554786624, 0.52741253364090723, 0.30888119953863891, 1.0) -(0.97208765859284896, 0.53740868896578231, 0.31349480968858129, 1.0) -(0.97347174163783168, 0.54740484429065739, 0.31810841983852362, 1.0) -(0.97485582468281429, 0.55740099961553247, 0.32272202998846594, 1.0) -(0.97623990772779701, 0.56739715494040743, 0.32733564013840827, 1.0) -(0.97762399077277973, 0.5773933102652824, 0.33194925028835054, 1.0) -(0.97900807381776245, 0.58738946559015759, 0.33656286043829292, 1.0) -(0.98039215686274517, 0.59738562091503256, 0.34117647058823525, 1.0) -(0.98177623990772778, 0.60738177623990763, 0.34579008073817757, 1.0) -(0.9831603229527105, 0.61737793156478271, 0.3504036908881199, 1.0) -(0.98454440599769322, 0.62737408688965768, 0.35501730103806223, 1.0) -(0.98592848904267594, 0.63737024221453276, 0.35963091118800455, 1.0) -(0.98731257208765866, 0.64736639753940783, 0.36424452133794688, 1.0) -(0.98869665513264127, 0.65736255286428269, 0.36885813148788915, 1.0) -(0.99008073817762399, 0.66735870818915788, 0.37347174163783153, 1.0) -(0.99146482122260671, 0.67735486351403296, 0.37808535178777386, 1.0) -(0.99223375624759713, 0.6861976163014224, 0.38362168396770463, 1.0) -(0.99238754325259515, 0.69388696655132631, 0.3900807381776239, 1.0) -(0.99254133025759328, 0.70157631680123023, 0.39653979238754317, 1.0) -(0.9926951172625913, 0.70926566705113414, 0.40299884659746243, 1.0) -(0.99284890426758943, 0.71695501730103794, 0.40945790080738165, 1.0) -(0.99300269127258745, 0.72464436755094175, 0.41591695501730086, 1.0) -(0.99315647827758557, 0.73233371780084577, 0.42237600922722018, 1.0) -(0.99331026528258359, 0.74002306805074969, 0.42883506343713945, 1.0) -(0.99346405228758172, 0.74771241830065349, 0.43529411764705872, 1.0) -(0.99361783929257985, 0.75540176855055741, 0.44175317185697799, 1.0) -(0.99377162629757787, 0.76309111880046132, 0.44821222606689726, 1.0) -(0.993925413302576, 0.77078046905036524, 0.45467128027681653, 1.0) -(0.99407920030757402, 0.77846981930026904, 0.46113033448673579, 1.0) -(0.99423298731257215, 0.78615916955017284, 0.46758938869665495, 1.0) -(0.99438677431757017, 0.79384851980007687, 0.47404844290657433, 1.0) -(0.9945405613225683, 0.80153787004998067, 0.48050749711649354, 1.0) -(0.99469434832756631, 0.80922722029988459, 0.48696655132641287, 1.0) -(0.99484813533256444, 0.8169165705497885, 0.49342560553633208, 1.0) -(0.99500192233756246, 0.82460592079969242, 0.4998846597462514, 1.0) -(0.99515570934256059, 0.83229527104959633, 0.50634371395617062, 1.0) -(0.99530949634755861, 0.83998462129950013, 0.51280276816608994, 1.0) -(0.99546328335255674, 0.84767397154940394, 0.51926182237600904, 1.0) -(0.99561707035755476, 0.85536332179930796, 0.52572087658592848, 1.0) -(0.99577085736255289, 0.86305267204921177, 0.53217993079584769, 1.0) -(0.9959246443675509, 0.87074202229911568, 0.5386389850057669, 1.0) -(0.99607843137254903, 0.8784313725490196, 0.54509803921568623, 1.0) -(0.99623221837754716, 0.88319876970396005, 0.55309496347558629, 1.0) -(0.99638600538254518, 0.8879661668589004, 0.56109188773548635, 1.0) -(0.99653979238754331, 0.89273356401384085, 0.5690888119953863, 1.0) -(0.99669357939254133, 0.8975009611687812, 0.57708573625528625, 1.0) -(0.99684736639753946, 0.90226835832372165, 0.58508266051518643, 1.0) -(0.99700115340253748, 0.907035755478662, 0.59307958477508649, 1.0) -(0.99715494040753561, 0.91180315263360245, 0.60107650903498655, 1.0) -(0.99730872741253362, 0.91657054978854291, 0.6090734332948865, 1.0) -(0.99746251441753175, 0.92133794694348325, 0.61707035755478656, 1.0) -(0.99761630142252977, 0.92610534409842371, 0.62506728181468663, 1.0) -(0.9977700884275279, 0.93087274125336406, 0.63306420607458669, 1.0) -(0.99792387543252592, 0.9356401384083044, 0.64106113033448664, 1.0) -(0.99807766243752405, 0.94040753556324486, 0.6490580545943867, 1.0) -(0.99823144944252207, 0.94517493271818531, 0.65705497885428676, 1.0) -(0.9983852364475202, 0.94994232987312577, 0.66505190311418683, 1.0) -(0.99853902345251822, 0.95470972702806611, 0.67304882737408689, 1.0) -(0.99869281045751634, 0.95947712418300657, 0.68104575163398695, 1.0) -(0.99884659746251447, 0.96424452133794691, 0.68904267589388701, 1.0) -(0.99900038446751249, 0.96901191849288737, 0.69703960015378696, 1.0) -(0.99915417147251062, 0.97377931564782771, 0.70503652441368692, 1.0) -(0.99930795847750864, 0.97854671280276817, 0.71303344867358709, 1.0) -(0.99946174548250677, 0.98331410995770852, 0.72103037293348715, 1.0) -(0.99961553248750479, 0.98808150711264897, 0.7290272971933871, 1.0) -(0.99976931949250292, 0.99284890426758943, 0.73702422145328716, 1.0) -(0.99992310649750094, 0.99761630142252977, 0.74502114571318723, 1.0) -(0.99707804690503654, 0.99876970396001541, 0.74502114571318723, 1.0) -(0.99123414071510962, 0.99630911188004612, 0.73702422145328716, 1.0) -(0.9853902345251826, 0.99384851980007693, 0.72902729719338721, 1.0) -(0.97954632833525568, 0.99138792772010764, 0.72103037293348715, 1.0) -(0.97370242214532887, 0.98892733564013846, 0.71303344867358731, 1.0) -(0.96785851595540184, 0.98646674356016917, 0.70503652441368714, 1.0) -(0.96201460976547482, 0.98400615148019999, 0.69703960015378708, 1.0) -(0.9561707035755479, 0.98154555940023069, 0.68904267589388701, 1.0) -(0.95032679738562098, 0.97908496732026151, 0.68104575163398695, 1.0) -(0.94448289119569406, 0.97662437524029222, 0.673048827374087, 1.0) -(0.93863898500576703, 0.97416378316032293, 0.66505190311418694, 1.0) -(0.93279507881584012, 0.97170319108035375, 0.65705497885428688, 1.0) -(0.9269511726259132, 0.96924259900038445, 0.64905805459438681, 1.0) -(0.92110726643598628, 0.96678200692041527, 0.64106113033448686, 1.0) -(0.91526336024605925, 0.96432141484044598, 0.6330642060745868, 1.0) -(0.90941945405613234, 0.9618608227604768, 0.62506728181468674, 1.0) -(0.90357554786620542, 0.9594002306805075, 0.61707035755478667, 1.0) -(0.89773164167627839, 0.95693963860053832, 0.60907343329488672, 1.0) -(0.89188773548635147, 0.95447904652056903, 0.60107650903498666, 1.0) -(0.88604382929642456, 0.95201845444059985, 0.5930795847750866, 1.0) -(0.88019992310649775, 0.94955786236063067, 0.58508266051518687, 1.0) -(0.87435601691657072, 0.94709727028066137, 0.57708573625528659, 1.0) -(0.86851211072664369, 0.94463667820069208, 0.56908881199538652, 1.0) -(0.86266820453671678, 0.9421760861207229, 0.56109188773548646, 1.0) -(0.85682429834678986, 0.93971549404075361, 0.55309496347558651, 1.0) -(0.85098039215686283, 0.93725490196078443, 0.54509803921568645, 1.0) -(0.84313725490196101, 0.93387158785082669, 0.54002306805074984, 1.0) -(0.83529411764705908, 0.93048827374086895, 0.53494809688581324, 1.0) -(0.82745098039215703, 0.92710495963091133, 0.52987312572087664, 1.0) -(0.8196078431372551, 0.92372164552095359, 0.52479815455594014, 1.0) -(0.81176470588235317, 0.92033833141099586, 0.51972318339100354, 1.0) -(0.80392156862745123, 0.91695501730103812, 0.51464821222606705, 1.0) -(0.79607843137254919, 0.9135717031910805, 0.50957324106113044, 1.0) -(0.78823529411764726, 0.91018838908112276, 0.50449826989619384, 1.0) -(0.78039215686274532, 0.90680507497116503, 0.49942329873125735, 1.0) -(0.77254901960784339, 0.90342176086120729, 0.49434832756632074, 1.0) -(0.76470588235294157, 0.90003844675124967, 0.48927335640138436, 1.0) -(0.75686274509803941, 0.89665513264129193, 0.48419838523644765, 1.0) -(0.74901960784313748, 0.89327181853133419, 0.4791234140715111, 1.0) -(0.74117647058823555, 0.88988850442137646, 0.47404844290657455, 1.0) -(0.7333333333333335, 0.88650519031141872, 0.46897347174163795, 1.0) -(0.72549019607843157, 0.8831218762014611, 0.4638985005767014, 1.0) -(0.71764705882352964, 0.87973856209150336, 0.45882352941176485, 1.0) -(0.7098039215686277, 0.87635524798154563, 0.45374855824682825, 1.0) -(0.70196078431372566, 0.87297193387158789, 0.44867358708189176, 1.0) -(0.69411764705882373, 0.86958861976163027, 0.44359861591695515, 1.0) -(0.6862745098039218, 0.86620530565167253, 0.4385236447520186, 1.0) -(0.67843137254901986, 0.86282199154171479, 0.43344867358708206, 1.0) -(0.67058823529411793, 0.85943867743175706, 0.42837370242214545, 1.0) -(0.662745098039216, 0.85605536332179932, 0.42329873125720896, 1.0) -(0.65490196078431395, 0.8526720492118417, 0.41822376009227236, 1.0) -(0.64605920799692451, 0.8488273740868898, 0.41514801999231071, 1.0) -(0.6362168396770479, 0.84452133794694373, 0.4140715109573242, 1.0) -(0.62637447135717061, 0.84021530180699744, 0.41299500192233762, 1.0) -(0.61653210303729367, 0.83590926566705126, 0.41191849288735105, 1.0) -(0.60668973471741661, 0.83160322952710508, 0.41084198385236453, 1.0) -(0.59684736639753966, 0.8272971933871589, 0.40976547481737796, 1.0) -(0.58700499807766271, 0.82299115724721272, 0.40868896578239144, 1.0) -(0.57716262975778565, 0.81868512110726654, 0.40761245674740487, 1.0) -(0.5673202614379087, 0.81437908496732037, 0.40653594771241836, 1.0) -(0.55747789311803175, 0.81007304882737419, 0.40545943867743178, 1.0) -(0.54763552479815469, 0.80576701268742801, 0.40438292964244527, 1.0) -(0.53779315647827775, 0.80146097654748183, 0.40330642060745869, 1.0) -(0.5279507881584008, 0.79715494040753565, 0.40222991157247218, 1.0) -(0.51810841983852374, 0.79284890426758947, 0.4011534025374856, 1.0) -(0.50826605151864679, 0.78854286812764329, 0.40007689350249909, 1.0) -(0.49842368319876984, 0.78423683198769711, 0.39900038446751251, 1.0) -(0.48858131487889289, 0.77993079584775094, 0.397923875432526, 1.0) -(0.47873894655901617, 0.77562475970780487, 0.39684736639753948, 1.0) -(0.46889657823913888, 0.77131872356785858, 0.39577085736255291, 1.0) -(0.45905420991926194, 0.7670126874279124, 0.39469434832756634, 1.0) -(0.44921184159938493, 0.76270665128796622, 0.39361783929257982, 1.0) -(0.43936947327950793, 0.75840061514802004, 0.39254133025759325, 1.0) -(0.42952710495963098, 0.75409457900807386, 0.39146482122260673, 1.0) -(0.41968473663975397, 0.74978854286812768, 0.39038831218762016, 1.0) -(0.40984236831987703, 0.7454825067281815, 0.38931180315263358, 1.0) -(0.40000000000000002, 0.74117647058823533, 0.38823529411764707, 1.0) -(0.38831218762014613, 0.73548635140330643, 0.38531334102268361, 1.0) -(0.37662437524029224, 0.72979623221837753, 0.38239138792772009, 1.0) -(0.3649365628604383, 0.72410611303344874, 0.37946943483275664, 1.0) -(0.35324875048058441, 0.71841599384851984, 0.37654748173779318, 1.0) -(0.34156093810073052, 0.71272587466359094, 0.37362552864282966, 1.0) -(0.32987312572087657, 0.70703575547866204, 0.3707035755478662, 1.0) -(0.31818531334102268, 0.70134563629373314, 0.36778162245290275, 1.0) -(0.30649750096116912, 0.69565551710880447, 0.36485966935793934, 1.0) -(0.29480968858131484, 0.68996539792387546, 0.36193771626297577, 1.0) -(0.28312187620146101, 0.68427527873894656, 0.35901576316801231, 1.0) -(0.27143406382160706, 0.67858515955401766, 0.35609381007304886, 1.0) -(0.25974625144175317, 0.67289504036908887, 0.35317185697808534, 1.0) -(0.24805843906189928, 0.66720492118415997, 0.35024990388312188, 1.0) -(0.23637062668204534, 0.66151480199923107, 0.34732795078815837, 1.0) -(0.22468281430219145, 0.65582468281430217, 0.34440599769319491, 1.0) -(0.21299500192233756, 0.65013456362937339, 0.34148404459823145, 1.0) -(0.20130718954248367, 0.64444444444444449, 0.33856209150326799, 1.0) -(0.18961937716262972, 0.63875432525951559, 0.33564013840830448, 1.0) -(0.17793156478277583, 0.63306420607458669, 0.33271818531334102, 1.0) -(0.16624375240292194, 0.62737408688965779, 0.32979623221837756, 1.0) -(0.15455594002306805, 0.621683967704729, 0.32687427912341405, 1.0) -(0.1428681276432141, 0.6159938485198001, 0.32395232602845059, 1.0) -(0.13118031526336021, 0.6103037293348712, 0.32103037293348713, 1.0) -(0.11949250288350666, 0.60461361014994253, 0.31810841983852373, 1.0) -(0.10780469050365243, 0.59892349096501341, 0.31518646674356016, 1.0) -(0.099961553248750473, 0.59238754325259513, 0.31180315263360248, 1.0) -(0.095963091118800456, 0.58500576701268747, 0.30795847750865052, 1.0) -(0.091964628988850439, 0.57762399077277971, 0.30411380238369856, 1.0) -(0.087966166858900421, 0.57024221453287194, 0.30026912725874666, 1.0) -(0.083967704728950404, 0.56286043829296428, 0.2964244521337947, 1.0) -(0.079969242599000387, 0.55547866205305652, 0.29257977700884275, 1.0) -(0.07597078046905037, 0.54809688581314875, 0.28873510188389079, 1.0) -(0.071972318339100338, 0.54071510957324109, 0.28489042675893889, 1.0) -(0.067973856209150335, 0.53333333333333333, 0.28104575163398693, 1.0) -(0.063975394079200304, 0.52595155709342556, 0.27720107650903497, 1.0) -(0.059976931949250287, 0.5185697808535179, 0.27335640138408307, 1.0) -(0.055978469819300269, 0.51118800461361014, 0.26951172625913111, 1.0) -(0.051980007689350252, 0.50380622837370237, 0.26566705113417916, 1.0) -(0.047981545559400228, 0.49642445213379471, 0.2618223760092272, 1.0) -(0.043983083429450329, 0.48904267589388717, 0.25797770088427541, 1.0) -(0.039984621299500193, 0.48166089965397924, 0.25413302575932334, 1.0) -(0.035986159169550169, 0.47427912341407152, 0.25028835063437138, 1.0) -(0.031987697039600152, 0.46689734717416376, 0.24644367550941948, 1.0) -(0.027989234909650135, 0.45951557093425605, 0.24259900038446752, 1.0) -(0.023990772779700117, 0.45213379469434833, 0.23875432525951557, 1.0) -(0.019992310649750086, 0.44475201845444057, 0.23490965013456364, 1.0) -(0.015993848519800083, 0.43737024221453286, 0.23106497500961171, 1.0) -(0.011995386389850066, 0.42998846597462514, 0.22722029988465975, 1.0) -(0.0079969242599000484, 0.42260668973471743, 0.22337562475970782, 1.0) -(0.0039984621299500173, 0.41522491349480967, 0.21953094963475589, 1.0) -(0.0, 0.40784313725490196, 0.21568627450980393, 1.0) diff --git a/extern/tfn/colormaps/diverging/Spectral.cpp b/extern/tfn/colormaps/diverging/Spectral.cpp deleted file mode 100644 index a77a168..0000000 --- a/extern/tfn/colormaps/diverging/Spectral.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_diverging_Spectral; -} -const std::vector colormap::data_diverging_Spectral = /* NOLINT(cert-err58-cpp) */ -{ -{0.61960784313725492f, 0.0039215686274509803f, 0.25882352941176473f, 1.0f}, -{0.62806612841214915f, 0.013302575932333718f, 0.26082276047673975f, 1.0f}, -{0.63652441368704349f, 0.022683583237216455f, 0.26282199154171476f, 1.0f}, -{0.64498269896193772f, 0.032064590542099189f, 0.26482122260668978f, 1.0f}, -{0.65344098423683206f, 0.04144559784698193f, 0.26682045367166479f, 1.0f}, -{0.66189926951172628f, 0.050826605151864664f, 0.26881968473663975f, 1.0f}, -{0.67035755478662051f, 0.060207612456747397f, 0.27081891580161477f, 1.0f}, -{0.67881584006151485f, 0.069588619761630138f, 0.27281814686658978f, 1.0f}, -{0.68727412533640908f, 0.078969627066512879f, 0.2748173779315648f, 1.0f}, -{0.69573241061130342f, 0.08835063437139562f, 0.27681660899653981f, 1.0f}, -{0.70419069588619765f, 0.097731641676278347f, 0.27881584006151483f, 1.0f}, -{0.71264898116109188f, 0.10711264898116109f, 0.28081507112648985f, 1.0f}, -{0.72110726643598622f, 0.11649365628604381f, 0.28281430219146486f, 1.0f}, -{0.72956555171088044f, 0.12587466359092656f, 0.28481353325643982f, 1.0f}, -{0.73802383698577478f, 0.13525567089580931f, 0.28681276432141484f, 1.0f}, -{0.74648212226066901f, 0.14463667820069204f, 0.28881199538638985f, 1.0f}, -{0.75494040753556324f, 0.15401768550557476f, 0.29081122645136487f, 1.0f}, -{0.76339869281045747f, 0.16339869281045749f, 0.29281045751633988f, 1.0f}, -{0.77185697808535181f, 0.17277970011534027f, 0.2948096885813149f, 1.0f}, -{0.78031526336024615f, 0.182160707420223f, 0.29680891964628991f, 1.0f}, -{0.78877354863514038f, 0.19154171472510573f, 0.29880815071126493f, 1.0f}, -{0.7972318339100346f, 0.20092272202998845f, 0.30080738177623989f, 1.0f}, -{0.80569011918492894f, 0.21030372933487118f, 0.30280661284121491f, 1.0f}, -{0.81414840445982317f, 0.21968473663975391f, 0.30480584390618992f, 1.0f}, -{0.82260668973471751f, 0.22906574394463664f, 0.30680507497116494f, 1.0f}, -{0.83106497500961174f, 0.23844675124951936f, 0.30880430603613995f, 1.0f}, -{0.83767781622452908f, 0.2467512495194156f, 0.30888119953863902f, 1.0f}, -{0.84244521337946943f, 0.25397923875432526f, 0.30703575547866208f, 1.0f}, -{0.84721261053440988f, 0.2612072279892349f, 0.30519031141868513f, 1.0f}, -{0.85198000768935023f, 0.26843521722414454f, 0.30334486735870819f, 1.0f}, -{0.85674740484429068f, 0.27566320645905418f, 0.30149942329873125f, 1.0f}, -{0.86151480199923114f, 0.28289119569396387f, 0.29965397923875431f, 1.0f}, -{0.86628219915417148f, 0.29011918492887351f, 0.29780853517877742f, 1.0f}, -{0.87104959630911183f, 0.29734717416378309f, 0.29596309111880048f, 1.0f}, -{0.87581699346405228f, 0.30457516339869278f, 0.29411764705882354f, 1.0f}, -{0.88058439061899274f, 0.31180315263360248f, 0.2922722029988466f, 1.0f}, -{0.88535178777393309f, 0.31903114186851211f, 0.29042675893886966f, 1.0f}, -{0.89011918492887354f, 0.3262591311034217f, 0.28858131487889277f, 1.0f}, -{0.894886582083814f, 0.33348712033833139f, 0.28673587081891583f, 1.0f}, -{0.89965397923875434f, 0.34071510957324103f, 0.28489042675893889f, 1.0f}, -{0.9044213763936948f, 0.34794309880815066f, 0.28304498269896194f, 1.0f}, -{0.90918877354863514f, 0.3551710880430603f, 0.281199538638985f, 1.0f}, -{0.9139561707035756f, 0.36239907727796999f, 0.27935409457900806f, 1.0f}, -{0.91872356785851594f, 0.36962706651287969f, 0.27750865051903117f, 1.0f}, -{0.9234909650134564f, 0.37685505574778932f, 0.27566320645905423f, 1.0f}, -{0.92825836216839674f, 0.38408304498269891f, 0.27381776239907729f, 1.0f}, -{0.9330257593233372f, 0.3913110342176086f, 0.27197231833910035f, 1.0f}, -{0.93779315647827766f, 0.39853902345251824f, 0.27012687427912341f, 1.0f}, -{0.942560553633218f, 0.40576701268742787f, 0.26828143021914652f, 1.0f}, -{0.94732795078815846f, 0.41299500192233751f, 0.26643598615916958f, 1.0f}, -{0.95209534794309891f, 0.42022299115724721f, 0.26459054209919264f, 1.0f}, -{0.95686274509803926f, 0.42745098039215684f, 0.2627450980392157f, 1.0f}, -{0.95824682814302198f, 0.43744713571703187f, 0.26735870818915802f, 1.0f}, -{0.9596309111880047f, 0.44744329104190683f, 0.27197231833910029f, 1.0f}, -{0.96101499423298731f, 0.45743944636678197f, 0.27658592848904268f, 1.0f}, -{0.96239907727797003f, 0.46743560169165704f, 0.281199538638985f, 1.0f}, -{0.96378316032295275f, 0.47743175701653207f, 0.28581314878892733f, 1.0f}, -{0.96516724336793547f, 0.48742791234140703f, 0.2904267589388696f, 1.0f}, -{0.96655132641291819f, 0.49742406766628217f, 0.29504036908881198f, 1.0f}, -{0.9679354094579008f, 0.50742022299115719f, 0.29965397923875431f, 1.0f}, -{0.96931949250288352f, 0.51741637831603227f, 0.30426758938869664f, 1.0f}, -{0.97070357554786624f, 0.52741253364090723f, 0.30888119953863891f, 1.0f}, -{0.97208765859284896f, 0.53740868896578231f, 0.31349480968858129f, 1.0f}, -{0.97347174163783168f, 0.54740484429065739f, 0.31810841983852362f, 1.0f}, -{0.97485582468281429f, 0.55740099961553247f, 0.32272202998846594f, 1.0f}, -{0.97623990772779701f, 0.56739715494040743f, 0.32733564013840827f, 1.0f}, -{0.97762399077277973f, 0.5773933102652824f, 0.33194925028835054f, 1.0f}, -{0.97900807381776245f, 0.58738946559015759f, 0.33656286043829292f, 1.0f}, -{0.98039215686274517f, 0.59738562091503256f, 0.34117647058823525f, 1.0f}, -{0.98177623990772778f, 0.60738177623990763f, 0.34579008073817757f, 1.0f}, -{0.9831603229527105f, 0.61737793156478271f, 0.3504036908881199f, 1.0f}, -{0.98454440599769322f, 0.62737408688965768f, 0.35501730103806223f, 1.0f}, -{0.98592848904267594f, 0.63737024221453276f, 0.35963091118800455f, 1.0f}, -{0.98731257208765866f, 0.64736639753940783f, 0.36424452133794688f, 1.0f}, -{0.98869665513264127f, 0.65736255286428269f, 0.36885813148788915f, 1.0f}, -{0.99008073817762399f, 0.66735870818915788f, 0.37347174163783153f, 1.0f}, -{0.99146482122260671f, 0.67735486351403296f, 0.37808535178777386f, 1.0f}, -{0.99223375624759713f, 0.6861976163014224f, 0.38362168396770463f, 1.0f}, -{0.99238754325259515f, 0.69388696655132631f, 0.3900807381776239f, 1.0f}, -{0.99254133025759328f, 0.70157631680123023f, 0.39653979238754317f, 1.0f}, -{0.9926951172625913f, 0.70926566705113414f, 0.40299884659746243f, 1.0f}, -{0.99284890426758943f, 0.71695501730103794f, 0.40945790080738165f, 1.0f}, -{0.99300269127258745f, 0.72464436755094175f, 0.41591695501730086f, 1.0f}, -{0.99315647827758557f, 0.73233371780084577f, 0.42237600922722018f, 1.0f}, -{0.99331026528258359f, 0.74002306805074969f, 0.42883506343713945f, 1.0f}, -{0.99346405228758172f, 0.74771241830065349f, 0.43529411764705872f, 1.0f}, -{0.99361783929257985f, 0.75540176855055741f, 0.44175317185697799f, 1.0f}, -{0.99377162629757787f, 0.76309111880046132f, 0.44821222606689726f, 1.0f}, -{0.993925413302576f, 0.77078046905036524f, 0.45467128027681653f, 1.0f}, -{0.99407920030757402f, 0.77846981930026904f, 0.46113033448673579f, 1.0f}, -{0.99423298731257215f, 0.78615916955017284f, 0.46758938869665495f, 1.0f}, -{0.99438677431757017f, 0.79384851980007687f, 0.47404844290657433f, 1.0f}, -{0.9945405613225683f, 0.80153787004998067f, 0.48050749711649354f, 1.0f}, -{0.99469434832756631f, 0.80922722029988459f, 0.48696655132641287f, 1.0f}, -{0.99484813533256444f, 0.8169165705497885f, 0.49342560553633208f, 1.0f}, -{0.99500192233756246f, 0.82460592079969242f, 0.4998846597462514f, 1.0f}, -{0.99515570934256059f, 0.83229527104959633f, 0.50634371395617062f, 1.0f}, -{0.99530949634755861f, 0.83998462129950013f, 0.51280276816608994f, 1.0f}, -{0.99546328335255674f, 0.84767397154940394f, 0.51926182237600904f, 1.0f}, -{0.99561707035755476f, 0.85536332179930796f, 0.52572087658592848f, 1.0f}, -{0.99577085736255289f, 0.86305267204921177f, 0.53217993079584769f, 1.0f}, -{0.9959246443675509f, 0.87074202229911568f, 0.5386389850057669f, 1.0f}, -{0.99607843137254903f, 0.8784313725490196f, 0.54509803921568623f, 1.0f}, -{0.99623221837754716f, 0.88319876970396005f, 0.55309496347558629f, 1.0f}, -{0.99638600538254518f, 0.8879661668589004f, 0.56109188773548635f, 1.0f}, -{0.99653979238754331f, 0.89273356401384085f, 0.5690888119953863f, 1.0f}, -{0.99669357939254133f, 0.8975009611687812f, 0.57708573625528625f, 1.0f}, -{0.99684736639753946f, 0.90226835832372165f, 0.58508266051518643f, 1.0f}, -{0.99700115340253748f, 0.907035755478662f, 0.59307958477508649f, 1.0f}, -{0.99715494040753561f, 0.91180315263360245f, 0.60107650903498655f, 1.0f}, -{0.99730872741253362f, 0.91657054978854291f, 0.6090734332948865f, 1.0f}, -{0.99746251441753175f, 0.92133794694348325f, 0.61707035755478656f, 1.0f}, -{0.99761630142252977f, 0.92610534409842371f, 0.62506728181468663f, 1.0f}, -{0.9977700884275279f, 0.93087274125336406f, 0.63306420607458669f, 1.0f}, -{0.99792387543252592f, 0.9356401384083044f, 0.64106113033448664f, 1.0f}, -{0.99807766243752405f, 0.94040753556324486f, 0.6490580545943867f, 1.0f}, -{0.99823144944252207f, 0.94517493271818531f, 0.65705497885428676f, 1.0f}, -{0.9983852364475202f, 0.94994232987312577f, 0.66505190311418683f, 1.0f}, -{0.99853902345251822f, 0.95470972702806611f, 0.67304882737408689f, 1.0f}, -{0.99869281045751634f, 0.95947712418300657f, 0.68104575163398695f, 1.0f}, -{0.99884659746251447f, 0.96424452133794691f, 0.68904267589388701f, 1.0f}, -{0.99900038446751249f, 0.96901191849288737f, 0.69703960015378696f, 1.0f}, -{0.99915417147251062f, 0.97377931564782771f, 0.70503652441368692f, 1.0f}, -{0.99930795847750864f, 0.97854671280276817f, 0.71303344867358709f, 1.0f}, -{0.99946174548250677f, 0.98331410995770852f, 0.72103037293348715f, 1.0f}, -{0.99961553248750479f, 0.98808150711264897f, 0.7290272971933871f, 1.0f}, -{0.99976931949250292f, 0.99284890426758943f, 0.73702422145328716f, 1.0f}, -{0.99992310649750094f, 0.99761630142252977f, 0.74502114571318723f, 1.0f}, -{0.99807766243752405f, 0.99923106497500958f, 0.74602076124567474f, 1.0f}, -{0.99423298731257215f, 0.99769319492502884f, 0.74002306805074969f, 1.0f}, -{0.99038831218762013f, 0.9961553248750481f, 0.73402537485582475f, 1.0f}, -{0.98654363706266823f, 0.99461745482506725f, 0.72802768166089971f, 1.0f}, -{0.98269896193771644f, 0.99307958477508651f, 0.72202998846597488f, 1.0f}, -{0.97885428681276432f, 0.99154171472510577f, 0.71603229527104961f, 1.0f}, -{0.97500961168781242f, 0.99000384467512492f, 0.71003460207612457f, 1.0f}, -{0.97116493656286051f, 0.98846597462514418f, 0.70403690888119963f, 1.0f}, -{0.9673202614379085f, 0.98692810457516345f, 0.69803921568627458f, 1.0f}, -{0.9634755863129566f, 0.9853902345251826f, 0.69204152249134954f, 1.0f}, -{0.9596309111880047f, 0.98385236447520186f, 0.68604382929642449f, 1.0f}, -{0.95578623606305269f, 0.98231449442522112f, 0.68004613610149955f, 1.0f}, -{0.95194156093810078f, 0.98077662437524038f, 0.67404844290657451f, 1.0f}, -{0.94809688581314888f, 0.97923875432525953f, 0.66805074971164946f, 1.0f}, -{0.94425221068819698f, 0.97770088427527879f, 0.66205305651672441f, 1.0f}, -{0.94040753556324497f, 0.97616301422529805f, 0.65605536332179937f, 1.0f}, -{0.93656286043829307f, 0.9746251441753172f, 0.65005767012687443f, 1.0f}, -{0.93271818531334105f, 0.97308727412533647f, 0.64405997693194939f, 1.0f}, -{0.92887351018838915f, 0.97154940407535573f, 0.63806228373702434f, 1.0f}, -{0.92502883506343725f, 0.97001153402537488f, 0.63206459054209929f, 1.0f}, -{0.92118415993848535f, 0.96847366397539414f, 0.62606689734717447f, 1.0f}, -{0.91733948481353333f, 0.9669357939254134f, 0.62006920415224931f, 1.0f}, -{0.91349480968858143f, 0.96539792387543255f, 0.61407151095732426f, 1.0f}, -{0.90965013456362953f, 0.96386005382545181f, 0.60807381776239922f, 1.0f}, -{0.90580545943867752f, 0.96232218377547107f, 0.60207612456747417f, 1.0f}, -{0.90196078431372562f, 0.96078431372549022f, 0.59607843137254912f, 1.0f}, -{0.8928873510188392f, 0.95709342560553645f, 0.5979238754325259f, 1.0f}, -{0.88381391772395257f, 0.95340253748558257f, 0.59976931949250278f, 1.0f}, -{0.87474048442906605f, 0.94971164936562869f, 0.60161476355247978f, 1.0f}, -{0.86566705113417941f, 0.94602076124567491f, 0.60346020761245667f, 1.0f}, -{0.85659361783929289f, 0.94232987312572103f, 0.60530565167243366f, 1.0f}, -{0.84752018454440625f, 0.93863898500576715f, 0.60715109573241055f, 1.0f}, -{0.83844675124951973f, 0.93494809688581326f, 0.60899653979238755f, 1.0f}, -{0.82937331795463309f, 0.93125720876585938f, 0.61084198385236443f, 1.0f}, -{0.82029988465974646f, 0.9275663206459055f, 0.61268742791234132f, 1.0f}, -{0.81122645136485994f, 0.92387543252595172f, 0.61453287197231832f, 1.0f}, -{0.80215301806997363f, 0.92018454440599795f, 0.6163783160322952f, 1.0f}, -{0.79307958477508678f, 0.91649365628604396f, 0.6182237600922722f, 1.0f}, -{0.78400615148020014f, 0.91280276816609007f, 0.62006920415224909f, 1.0f}, -{0.77493271818531362f, 0.90911188004613619f, 0.62191464821222608f, 1.0f}, -{0.76585928489042698f, 0.90542099192618242f, 0.62376009227220297f, 1.0f}, -{0.75678585159554035f, 0.90173010380622853f, 0.62560553633217986f, 1.0f}, -{0.74771241830065382f, 0.89803921568627465f, 0.62745098039215685f, 1.0f}, -{0.73863898500576719f, 0.89434832756632077f, 0.62929642445213374f, 1.0f}, -{0.72956555171088067f, 0.89065743944636688f, 0.63114186851211074f, 1.0f}, -{0.72049211841599403f, 0.88696655132641311f, 0.63298731257208762f, 1.0f}, -{0.71141868512110751f, 0.88327566320645923f, 0.63483275663206462f, 1.0f}, -{0.70234525182622087f, 0.87958477508650534f, 0.63667820069204151f, 1.0f}, -{0.69327181853133435f, 0.87589388696655146f, 0.63852364475201839f, 1.0f}, -{0.68419838523644771f, 0.87220299884659758f, 0.64036908881199539f, 1.0f}, -{0.67512495194156119f, 0.86851211072664369f, 0.64221453287197228f, 1.0f}, -{0.66528258362168424f, 0.86459054209919273f, 0.6432141484044599f, 1.0f}, -{0.65467128027681709f, 0.86043829296424479f, 0.64336793540945791f, 1.0f}, -{0.6440599769319495f, 0.85628604382929652f, 0.64352172241445604f, 1.0f}, -{0.63344867358708212f, 0.85213379469434847f, 0.64367550941945406f, 1.0f}, -{0.62283737024221475f, 0.84798154555940031f, 0.64382929642445219f, 1.0f}, -{0.61222606689734738f, 0.84382929642445226f, 0.64398308342945021f, 1.0f}, -{0.60161476355248f, 0.8396770472895041f, 0.64413687043444834f, 1.0f}, -{0.59100346020761263f, 0.83552479815455605f, 0.64429065743944636f, 1.0f}, -{0.58039215686274526f, 0.83137254901960789f, 0.64444444444444449f, 1.0f}, -{0.56978085351787788f, 0.82722029988465984f, 0.64459823144944262f, 1.0f}, -{0.55916955017301051f, 0.82306805074971168f, 0.64475201845444063f, 1.0f}, -{0.54855824682814314f, 0.81891580161476363f, 0.64490580545943876f, 1.0f}, -{0.53794694348327576f, 0.81476355247981547f, 0.64505959246443678f, 1.0f}, -{0.52733564013840839f, 0.81061130334486742f, 0.64521337946943491f, 1.0f}, -{0.51672433679354102f, 0.80645905420991926f, 0.64536716647443293f, 1.0f}, -{0.50611303344867364f, 0.80230680507497121f, 0.64552095347943106f, 1.0f}, -{0.49550173010380633f, 0.79815455594002316f, 0.64567474048442908f, 1.0f}, -{0.48489042675893923f, 0.79400230680507511f, 0.64582852748942721f, 1.0f}, -{0.47427912341407163f, 0.78985005767012684f, 0.64598231449442522f, 1.0f}, -{0.46366782006920426f, 0.78569780853517879f, 0.64613610149942335f, 1.0f}, -{0.45305651672433689f, 0.78154555940023074f, 0.64628988850442137f, 1.0f}, -{0.44244521337946952f, 0.77739331026528258f, 0.6464436755094195f, 1.0f}, -{0.43183391003460214f, 0.77324106113033442f, 0.64659746251441752f, 1.0f}, -{0.42122260668973477f, 0.76908881199538637f, 0.64675124951941565f, 1.0f}, -{0.4106113033448674f, 0.76493656286043832f, 0.64690503652441367f, 1.0f}, -{0.40000000000000002f, 0.76078431372549016f, 0.6470588235294118f, 1.0f}, -{0.39200307574009996f, 0.75186466743560165f, 0.65074971164936568f, 1.0f}, -{0.38400615148019995f, 0.74294502114571315f, 0.65444059976931956f, 1.0f}, -{0.37600922722029989f, 0.73402537485582464f, 0.65813148788927334f, 1.0f}, -{0.36801230296039988f, 0.72510572856593614f, 0.66182237600922722f, 1.0f}, -{0.36001537870049982f, 0.71618608227604763f, 0.6655132641291811f, 1.0f}, -{0.35201845444059976f, 0.70726643598615913f, 0.66920415224913499f, 1.0f}, -{0.34402153018069975f, 0.69834678969627062f, 0.67289504036908887f, 1.0f}, -{0.33602460592079997f, 0.68942714340638234f, 0.67658592848904264f, 1.0f}, -{0.32802768166089968f, 0.68050749711649361f, 0.68027681660899653f, 1.0f}, -{0.32003075740099962f, 0.6715878508266051f, 0.68396770472895041f, 1.0f}, -{0.31203383314109956f, 0.6626682045367166f, 0.68765859284890429f, 1.0f}, -{0.30403690888119955f, 0.65374855824682809f, 0.69134948096885818f, 1.0f}, -{0.29603998462129955f, 0.64482891195693959f, 0.69504036908881206f, 1.0f}, -{0.28804306036139948f, 0.63590926566705108f, 0.69873125720876594f, 1.0f}, -{0.28004613610149942f, 0.62698961937716258f, 0.70242214532871972f, 1.0f}, -{0.27204921184159936f, 0.61806997308727407f, 0.7061130334486736f, 1.0f}, -{0.26405228758169935f, 0.60915032679738568f, 0.70980392156862748f, 1.0f}, -{0.25605536332179929f, 0.60023068050749706f, 0.71349480968858137f, 1.0f}, -{0.24805843906189928f, 0.59131103421760856f, 0.71718569780853525f, 1.0f}, -{0.24006151480199925f, 0.58239138792772005f, 0.72087658592848913f, 1.0f}, -{0.23206459054209921f, 0.57347174163783166f, 0.72456747404844291f, 1.0f}, -{0.22406766628219915f, 0.56455209534794304f, 0.72825836216839679f, 1.0f}, -{0.21607074202229912f, 0.55563244905805464f, 0.73194925028835067f, 1.0f}, -{0.2080738177623993f, 0.54671280276816636f, 0.73564013840830444f, 1.0f}, -{0.20007689350249905f, 0.53779315647827763f, 0.73933102652825844f, 1.0f}, -{0.19946174548250672f, 0.52895040369088808f, 0.73910034602076125f, 1.0f}, -{0.20622837370242214f, 0.52018454440599771f, 0.7349480968858132f, 1.0f}, -{0.21299500192233756f, 0.51141868512110722f, 0.73079584775086504f, 1.0f}, -{0.21976163014225297f, 0.50265282583621684f, 0.72664359861591699f, 1.0f}, -{0.22652825836216839f, 0.49388696655132641f, 0.72249134948096883f, 1.0f}, -{0.2332948865820838f, 0.48512110726643598f, 0.71833910034602078f, 1.0f}, -{0.24006151480199922f, 0.47635524798154555f, 0.71418685121107273f, 1.0f}, -{0.24682814302191466f, 0.46758938869665512f, 0.71003460207612457f, 1.0f}, -{0.25359477124183005f, 0.45882352941176474f, 0.70588235294117652f, 1.0f}, -{0.26036139946174552f, 0.45005767012687425f, 0.70173010380622836f, 1.0f}, -{0.26712802768166088f, 0.44129181084198388f, 0.69757785467128031f, 1.0f}, -{0.27389465590157636f, 0.43252595155709339f, 0.69342560553633215f, 1.0f}, -{0.28066128412149172f, 0.42376009227220302f, 0.6892733564013841f, 1.0f}, -{0.28742791234140719f, 0.41499423298731258f, 0.68512110726643594f, 1.0f}, -{0.29419454056132238f, 0.40622837370242237f, 0.680968858131488f, 1.0f}, -{0.30096116878123802f, 0.39746251441753172f, 0.67681660899653973f, 1.0f}, -{0.30772779700115344f, 0.38869665513264129f, 0.67266435986159168f, 1.0f}, -{0.31449442522106885f, 0.37993079584775086f, 0.66851211072664363f, 1.0f}, -{0.32126105344098421f, 0.37116493656286043f, 0.66435986159169547f, 1.0f}, -{0.32802768166089968f, 0.36239907727797005f, 0.66020761245674742f, 1.0f}, -{0.3347943098808151f, 0.35363321799307956f, 0.65605536332179926f, 1.0f}, -{0.34156093810073052f, 0.34486735870818919f, 0.65190311418685121f, 1.0f}, -{0.34832756632064593f, 0.33610149942329876f, 0.64775086505190305f, 1.0f}, -{0.35509419454056135f, 0.32733564013840832f, 0.643598615916955f, 1.0f}, -{0.36186082276047676f, 0.31856978085351789f, 0.63944636678200684f, 1.0f}, -{0.36862745098039218f, 0.30980392156862746f, 0.63529411764705879f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/diverging/Spectral.txt b/extern/tfn/colormaps/diverging/Spectral.txt deleted file mode 100644 index e399ad2..0000000 --- a/extern/tfn/colormaps/diverging/Spectral.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.61960784313725492, 0.0039215686274509803, 0.25882352941176473, 1.0) -(0.62806612841214915, 0.013302575932333718, 0.26082276047673975, 1.0) -(0.63652441368704349, 0.022683583237216455, 0.26282199154171476, 1.0) -(0.64498269896193772, 0.032064590542099189, 0.26482122260668978, 1.0) -(0.65344098423683206, 0.04144559784698193, 0.26682045367166479, 1.0) -(0.66189926951172628, 0.050826605151864664, 0.26881968473663975, 1.0) -(0.67035755478662051, 0.060207612456747397, 0.27081891580161477, 1.0) -(0.67881584006151485, 0.069588619761630138, 0.27281814686658978, 1.0) -(0.68727412533640908, 0.078969627066512879, 0.2748173779315648, 1.0) -(0.69573241061130342, 0.08835063437139562, 0.27681660899653981, 1.0) -(0.70419069588619765, 0.097731641676278347, 0.27881584006151483, 1.0) -(0.71264898116109188, 0.10711264898116109, 0.28081507112648985, 1.0) -(0.72110726643598622, 0.11649365628604381, 0.28281430219146486, 1.0) -(0.72956555171088044, 0.12587466359092656, 0.28481353325643982, 1.0) -(0.73802383698577478, 0.13525567089580931, 0.28681276432141484, 1.0) -(0.74648212226066901, 0.14463667820069204, 0.28881199538638985, 1.0) -(0.75494040753556324, 0.15401768550557476, 0.29081122645136487, 1.0) -(0.76339869281045747, 0.16339869281045749, 0.29281045751633988, 1.0) -(0.77185697808535181, 0.17277970011534027, 0.2948096885813149, 1.0) -(0.78031526336024615, 0.182160707420223, 0.29680891964628991, 1.0) -(0.78877354863514038, 0.19154171472510573, 0.29880815071126493, 1.0) -(0.7972318339100346, 0.20092272202998845, 0.30080738177623989, 1.0) -(0.80569011918492894, 0.21030372933487118, 0.30280661284121491, 1.0) -(0.81414840445982317, 0.21968473663975391, 0.30480584390618992, 1.0) -(0.82260668973471751, 0.22906574394463664, 0.30680507497116494, 1.0) -(0.83106497500961174, 0.23844675124951936, 0.30880430603613995, 1.0) -(0.83767781622452908, 0.2467512495194156, 0.30888119953863902, 1.0) -(0.84244521337946943, 0.25397923875432526, 0.30703575547866208, 1.0) -(0.84721261053440988, 0.2612072279892349, 0.30519031141868513, 1.0) -(0.85198000768935023, 0.26843521722414454, 0.30334486735870819, 1.0) -(0.85674740484429068, 0.27566320645905418, 0.30149942329873125, 1.0) -(0.86151480199923114, 0.28289119569396387, 0.29965397923875431, 1.0) -(0.86628219915417148, 0.29011918492887351, 0.29780853517877742, 1.0) -(0.87104959630911183, 0.29734717416378309, 0.29596309111880048, 1.0) -(0.87581699346405228, 0.30457516339869278, 0.29411764705882354, 1.0) -(0.88058439061899274, 0.31180315263360248, 0.2922722029988466, 1.0) -(0.88535178777393309, 0.31903114186851211, 0.29042675893886966, 1.0) -(0.89011918492887354, 0.3262591311034217, 0.28858131487889277, 1.0) -(0.894886582083814, 0.33348712033833139, 0.28673587081891583, 1.0) -(0.89965397923875434, 0.34071510957324103, 0.28489042675893889, 1.0) -(0.9044213763936948, 0.34794309880815066, 0.28304498269896194, 1.0) -(0.90918877354863514, 0.3551710880430603, 0.281199538638985, 1.0) -(0.9139561707035756, 0.36239907727796999, 0.27935409457900806, 1.0) -(0.91872356785851594, 0.36962706651287969, 0.27750865051903117, 1.0) -(0.9234909650134564, 0.37685505574778932, 0.27566320645905423, 1.0) -(0.92825836216839674, 0.38408304498269891, 0.27381776239907729, 1.0) -(0.9330257593233372, 0.3913110342176086, 0.27197231833910035, 1.0) -(0.93779315647827766, 0.39853902345251824, 0.27012687427912341, 1.0) -(0.942560553633218, 0.40576701268742787, 0.26828143021914652, 1.0) -(0.94732795078815846, 0.41299500192233751, 0.26643598615916958, 1.0) -(0.95209534794309891, 0.42022299115724721, 0.26459054209919264, 1.0) -(0.95686274509803926, 0.42745098039215684, 0.2627450980392157, 1.0) -(0.95824682814302198, 0.43744713571703187, 0.26735870818915802, 1.0) -(0.9596309111880047, 0.44744329104190683, 0.27197231833910029, 1.0) -(0.96101499423298731, 0.45743944636678197, 0.27658592848904268, 1.0) -(0.96239907727797003, 0.46743560169165704, 0.281199538638985, 1.0) -(0.96378316032295275, 0.47743175701653207, 0.28581314878892733, 1.0) -(0.96516724336793547, 0.48742791234140703, 0.2904267589388696, 1.0) -(0.96655132641291819, 0.49742406766628217, 0.29504036908881198, 1.0) -(0.9679354094579008, 0.50742022299115719, 0.29965397923875431, 1.0) -(0.96931949250288352, 0.51741637831603227, 0.30426758938869664, 1.0) -(0.97070357554786624, 0.52741253364090723, 0.30888119953863891, 1.0) -(0.97208765859284896, 0.53740868896578231, 0.31349480968858129, 1.0) -(0.97347174163783168, 0.54740484429065739, 0.31810841983852362, 1.0) -(0.97485582468281429, 0.55740099961553247, 0.32272202998846594, 1.0) -(0.97623990772779701, 0.56739715494040743, 0.32733564013840827, 1.0) -(0.97762399077277973, 0.5773933102652824, 0.33194925028835054, 1.0) -(0.97900807381776245, 0.58738946559015759, 0.33656286043829292, 1.0) -(0.98039215686274517, 0.59738562091503256, 0.34117647058823525, 1.0) -(0.98177623990772778, 0.60738177623990763, 0.34579008073817757, 1.0) -(0.9831603229527105, 0.61737793156478271, 0.3504036908881199, 1.0) -(0.98454440599769322, 0.62737408688965768, 0.35501730103806223, 1.0) -(0.98592848904267594, 0.63737024221453276, 0.35963091118800455, 1.0) -(0.98731257208765866, 0.64736639753940783, 0.36424452133794688, 1.0) -(0.98869665513264127, 0.65736255286428269, 0.36885813148788915, 1.0) -(0.99008073817762399, 0.66735870818915788, 0.37347174163783153, 1.0) -(0.99146482122260671, 0.67735486351403296, 0.37808535178777386, 1.0) -(0.99223375624759713, 0.6861976163014224, 0.38362168396770463, 1.0) -(0.99238754325259515, 0.69388696655132631, 0.3900807381776239, 1.0) -(0.99254133025759328, 0.70157631680123023, 0.39653979238754317, 1.0) -(0.9926951172625913, 0.70926566705113414, 0.40299884659746243, 1.0) -(0.99284890426758943, 0.71695501730103794, 0.40945790080738165, 1.0) -(0.99300269127258745, 0.72464436755094175, 0.41591695501730086, 1.0) -(0.99315647827758557, 0.73233371780084577, 0.42237600922722018, 1.0) -(0.99331026528258359, 0.74002306805074969, 0.42883506343713945, 1.0) -(0.99346405228758172, 0.74771241830065349, 0.43529411764705872, 1.0) -(0.99361783929257985, 0.75540176855055741, 0.44175317185697799, 1.0) -(0.99377162629757787, 0.76309111880046132, 0.44821222606689726, 1.0) -(0.993925413302576, 0.77078046905036524, 0.45467128027681653, 1.0) -(0.99407920030757402, 0.77846981930026904, 0.46113033448673579, 1.0) -(0.99423298731257215, 0.78615916955017284, 0.46758938869665495, 1.0) -(0.99438677431757017, 0.79384851980007687, 0.47404844290657433, 1.0) -(0.9945405613225683, 0.80153787004998067, 0.48050749711649354, 1.0) -(0.99469434832756631, 0.80922722029988459, 0.48696655132641287, 1.0) -(0.99484813533256444, 0.8169165705497885, 0.49342560553633208, 1.0) -(0.99500192233756246, 0.82460592079969242, 0.4998846597462514, 1.0) -(0.99515570934256059, 0.83229527104959633, 0.50634371395617062, 1.0) -(0.99530949634755861, 0.83998462129950013, 0.51280276816608994, 1.0) -(0.99546328335255674, 0.84767397154940394, 0.51926182237600904, 1.0) -(0.99561707035755476, 0.85536332179930796, 0.52572087658592848, 1.0) -(0.99577085736255289, 0.86305267204921177, 0.53217993079584769, 1.0) -(0.9959246443675509, 0.87074202229911568, 0.5386389850057669, 1.0) -(0.99607843137254903, 0.8784313725490196, 0.54509803921568623, 1.0) -(0.99623221837754716, 0.88319876970396005, 0.55309496347558629, 1.0) -(0.99638600538254518, 0.8879661668589004, 0.56109188773548635, 1.0) -(0.99653979238754331, 0.89273356401384085, 0.5690888119953863, 1.0) -(0.99669357939254133, 0.8975009611687812, 0.57708573625528625, 1.0) -(0.99684736639753946, 0.90226835832372165, 0.58508266051518643, 1.0) -(0.99700115340253748, 0.907035755478662, 0.59307958477508649, 1.0) -(0.99715494040753561, 0.91180315263360245, 0.60107650903498655, 1.0) -(0.99730872741253362, 0.91657054978854291, 0.6090734332948865, 1.0) -(0.99746251441753175, 0.92133794694348325, 0.61707035755478656, 1.0) -(0.99761630142252977, 0.92610534409842371, 0.62506728181468663, 1.0) -(0.9977700884275279, 0.93087274125336406, 0.63306420607458669, 1.0) -(0.99792387543252592, 0.9356401384083044, 0.64106113033448664, 1.0) -(0.99807766243752405, 0.94040753556324486, 0.6490580545943867, 1.0) -(0.99823144944252207, 0.94517493271818531, 0.65705497885428676, 1.0) -(0.9983852364475202, 0.94994232987312577, 0.66505190311418683, 1.0) -(0.99853902345251822, 0.95470972702806611, 0.67304882737408689, 1.0) -(0.99869281045751634, 0.95947712418300657, 0.68104575163398695, 1.0) -(0.99884659746251447, 0.96424452133794691, 0.68904267589388701, 1.0) -(0.99900038446751249, 0.96901191849288737, 0.69703960015378696, 1.0) -(0.99915417147251062, 0.97377931564782771, 0.70503652441368692, 1.0) -(0.99930795847750864, 0.97854671280276817, 0.71303344867358709, 1.0) -(0.99946174548250677, 0.98331410995770852, 0.72103037293348715, 1.0) -(0.99961553248750479, 0.98808150711264897, 0.7290272971933871, 1.0) -(0.99976931949250292, 0.99284890426758943, 0.73702422145328716, 1.0) -(0.99992310649750094, 0.99761630142252977, 0.74502114571318723, 1.0) -(0.99807766243752405, 0.99923106497500958, 0.74602076124567474, 1.0) -(0.99423298731257215, 0.99769319492502884, 0.74002306805074969, 1.0) -(0.99038831218762013, 0.9961553248750481, 0.73402537485582475, 1.0) -(0.98654363706266823, 0.99461745482506725, 0.72802768166089971, 1.0) -(0.98269896193771644, 0.99307958477508651, 0.72202998846597488, 1.0) -(0.97885428681276432, 0.99154171472510577, 0.71603229527104961, 1.0) -(0.97500961168781242, 0.99000384467512492, 0.71003460207612457, 1.0) -(0.97116493656286051, 0.98846597462514418, 0.70403690888119963, 1.0) -(0.9673202614379085, 0.98692810457516345, 0.69803921568627458, 1.0) -(0.9634755863129566, 0.9853902345251826, 0.69204152249134954, 1.0) -(0.9596309111880047, 0.98385236447520186, 0.68604382929642449, 1.0) -(0.95578623606305269, 0.98231449442522112, 0.68004613610149955, 1.0) -(0.95194156093810078, 0.98077662437524038, 0.67404844290657451, 1.0) -(0.94809688581314888, 0.97923875432525953, 0.66805074971164946, 1.0) -(0.94425221068819698, 0.97770088427527879, 0.66205305651672441, 1.0) -(0.94040753556324497, 0.97616301422529805, 0.65605536332179937, 1.0) -(0.93656286043829307, 0.9746251441753172, 0.65005767012687443, 1.0) -(0.93271818531334105, 0.97308727412533647, 0.64405997693194939, 1.0) -(0.92887351018838915, 0.97154940407535573, 0.63806228373702434, 1.0) -(0.92502883506343725, 0.97001153402537488, 0.63206459054209929, 1.0) -(0.92118415993848535, 0.96847366397539414, 0.62606689734717447, 1.0) -(0.91733948481353333, 0.9669357939254134, 0.62006920415224931, 1.0) -(0.91349480968858143, 0.96539792387543255, 0.61407151095732426, 1.0) -(0.90965013456362953, 0.96386005382545181, 0.60807381776239922, 1.0) -(0.90580545943867752, 0.96232218377547107, 0.60207612456747417, 1.0) -(0.90196078431372562, 0.96078431372549022, 0.59607843137254912, 1.0) -(0.8928873510188392, 0.95709342560553645, 0.5979238754325259, 1.0) -(0.88381391772395257, 0.95340253748558257, 0.59976931949250278, 1.0) -(0.87474048442906605, 0.94971164936562869, 0.60161476355247978, 1.0) -(0.86566705113417941, 0.94602076124567491, 0.60346020761245667, 1.0) -(0.85659361783929289, 0.94232987312572103, 0.60530565167243366, 1.0) -(0.84752018454440625, 0.93863898500576715, 0.60715109573241055, 1.0) -(0.83844675124951973, 0.93494809688581326, 0.60899653979238755, 1.0) -(0.82937331795463309, 0.93125720876585938, 0.61084198385236443, 1.0) -(0.82029988465974646, 0.9275663206459055, 0.61268742791234132, 1.0) -(0.81122645136485994, 0.92387543252595172, 0.61453287197231832, 1.0) -(0.80215301806997363, 0.92018454440599795, 0.6163783160322952, 1.0) -(0.79307958477508678, 0.91649365628604396, 0.6182237600922722, 1.0) -(0.78400615148020014, 0.91280276816609007, 0.62006920415224909, 1.0) -(0.77493271818531362, 0.90911188004613619, 0.62191464821222608, 1.0) -(0.76585928489042698, 0.90542099192618242, 0.62376009227220297, 1.0) -(0.75678585159554035, 0.90173010380622853, 0.62560553633217986, 1.0) -(0.74771241830065382, 0.89803921568627465, 0.62745098039215685, 1.0) -(0.73863898500576719, 0.89434832756632077, 0.62929642445213374, 1.0) -(0.72956555171088067, 0.89065743944636688, 0.63114186851211074, 1.0) -(0.72049211841599403, 0.88696655132641311, 0.63298731257208762, 1.0) -(0.71141868512110751, 0.88327566320645923, 0.63483275663206462, 1.0) -(0.70234525182622087, 0.87958477508650534, 0.63667820069204151, 1.0) -(0.69327181853133435, 0.87589388696655146, 0.63852364475201839, 1.0) -(0.68419838523644771, 0.87220299884659758, 0.64036908881199539, 1.0) -(0.67512495194156119, 0.86851211072664369, 0.64221453287197228, 1.0) -(0.66528258362168424, 0.86459054209919273, 0.6432141484044599, 1.0) -(0.65467128027681709, 0.86043829296424479, 0.64336793540945791, 1.0) -(0.6440599769319495, 0.85628604382929652, 0.64352172241445604, 1.0) -(0.63344867358708212, 0.85213379469434847, 0.64367550941945406, 1.0) -(0.62283737024221475, 0.84798154555940031, 0.64382929642445219, 1.0) -(0.61222606689734738, 0.84382929642445226, 0.64398308342945021, 1.0) -(0.60161476355248, 0.8396770472895041, 0.64413687043444834, 1.0) -(0.59100346020761263, 0.83552479815455605, 0.64429065743944636, 1.0) -(0.58039215686274526, 0.83137254901960789, 0.64444444444444449, 1.0) -(0.56978085351787788, 0.82722029988465984, 0.64459823144944262, 1.0) -(0.55916955017301051, 0.82306805074971168, 0.64475201845444063, 1.0) -(0.54855824682814314, 0.81891580161476363, 0.64490580545943876, 1.0) -(0.53794694348327576, 0.81476355247981547, 0.64505959246443678, 1.0) -(0.52733564013840839, 0.81061130334486742, 0.64521337946943491, 1.0) -(0.51672433679354102, 0.80645905420991926, 0.64536716647443293, 1.0) -(0.50611303344867364, 0.80230680507497121, 0.64552095347943106, 1.0) -(0.49550173010380633, 0.79815455594002316, 0.64567474048442908, 1.0) -(0.48489042675893923, 0.79400230680507511, 0.64582852748942721, 1.0) -(0.47427912341407163, 0.78985005767012684, 0.64598231449442522, 1.0) -(0.46366782006920426, 0.78569780853517879, 0.64613610149942335, 1.0) -(0.45305651672433689, 0.78154555940023074, 0.64628988850442137, 1.0) -(0.44244521337946952, 0.77739331026528258, 0.6464436755094195, 1.0) -(0.43183391003460214, 0.77324106113033442, 0.64659746251441752, 1.0) -(0.42122260668973477, 0.76908881199538637, 0.64675124951941565, 1.0) -(0.4106113033448674, 0.76493656286043832, 0.64690503652441367, 1.0) -(0.40000000000000002, 0.76078431372549016, 0.6470588235294118, 1.0) -(0.39200307574009996, 0.75186466743560165, 0.65074971164936568, 1.0) -(0.38400615148019995, 0.74294502114571315, 0.65444059976931956, 1.0) -(0.37600922722029989, 0.73402537485582464, 0.65813148788927334, 1.0) -(0.36801230296039988, 0.72510572856593614, 0.66182237600922722, 1.0) -(0.36001537870049982, 0.71618608227604763, 0.6655132641291811, 1.0) -(0.35201845444059976, 0.70726643598615913, 0.66920415224913499, 1.0) -(0.34402153018069975, 0.69834678969627062, 0.67289504036908887, 1.0) -(0.33602460592079997, 0.68942714340638234, 0.67658592848904264, 1.0) -(0.32802768166089968, 0.68050749711649361, 0.68027681660899653, 1.0) -(0.32003075740099962, 0.6715878508266051, 0.68396770472895041, 1.0) -(0.31203383314109956, 0.6626682045367166, 0.68765859284890429, 1.0) -(0.30403690888119955, 0.65374855824682809, 0.69134948096885818, 1.0) -(0.29603998462129955, 0.64482891195693959, 0.69504036908881206, 1.0) -(0.28804306036139948, 0.63590926566705108, 0.69873125720876594, 1.0) -(0.28004613610149942, 0.62698961937716258, 0.70242214532871972, 1.0) -(0.27204921184159936, 0.61806997308727407, 0.7061130334486736, 1.0) -(0.26405228758169935, 0.60915032679738568, 0.70980392156862748, 1.0) -(0.25605536332179929, 0.60023068050749706, 0.71349480968858137, 1.0) -(0.24805843906189928, 0.59131103421760856, 0.71718569780853525, 1.0) -(0.24006151480199925, 0.58239138792772005, 0.72087658592848913, 1.0) -(0.23206459054209921, 0.57347174163783166, 0.72456747404844291, 1.0) -(0.22406766628219915, 0.56455209534794304, 0.72825836216839679, 1.0) -(0.21607074202229912, 0.55563244905805464, 0.73194925028835067, 1.0) -(0.2080738177623993, 0.54671280276816636, 0.73564013840830444, 1.0) -(0.20007689350249905, 0.53779315647827763, 0.73933102652825844, 1.0) -(0.19946174548250672, 0.52895040369088808, 0.73910034602076125, 1.0) -(0.20622837370242214, 0.52018454440599771, 0.7349480968858132, 1.0) -(0.21299500192233756, 0.51141868512110722, 0.73079584775086504, 1.0) -(0.21976163014225297, 0.50265282583621684, 0.72664359861591699, 1.0) -(0.22652825836216839, 0.49388696655132641, 0.72249134948096883, 1.0) -(0.2332948865820838, 0.48512110726643598, 0.71833910034602078, 1.0) -(0.24006151480199922, 0.47635524798154555, 0.71418685121107273, 1.0) -(0.24682814302191466, 0.46758938869665512, 0.71003460207612457, 1.0) -(0.25359477124183005, 0.45882352941176474, 0.70588235294117652, 1.0) -(0.26036139946174552, 0.45005767012687425, 0.70173010380622836, 1.0) -(0.26712802768166088, 0.44129181084198388, 0.69757785467128031, 1.0) -(0.27389465590157636, 0.43252595155709339, 0.69342560553633215, 1.0) -(0.28066128412149172, 0.42376009227220302, 0.6892733564013841, 1.0) -(0.28742791234140719, 0.41499423298731258, 0.68512110726643594, 1.0) -(0.29419454056132238, 0.40622837370242237, 0.680968858131488, 1.0) -(0.30096116878123802, 0.39746251441753172, 0.67681660899653973, 1.0) -(0.30772779700115344, 0.38869665513264129, 0.67266435986159168, 1.0) -(0.31449442522106885, 0.37993079584775086, 0.66851211072664363, 1.0) -(0.32126105344098421, 0.37116493656286043, 0.66435986159169547, 1.0) -(0.32802768166089968, 0.36239907727797005, 0.66020761245674742, 1.0) -(0.3347943098808151, 0.35363321799307956, 0.65605536332179926, 1.0) -(0.34156093810073052, 0.34486735870818919, 0.65190311418685121, 1.0) -(0.34832756632064593, 0.33610149942329876, 0.64775086505190305, 1.0) -(0.35509419454056135, 0.32733564013840832, 0.643598615916955, 1.0) -(0.36186082276047676, 0.31856978085351789, 0.63944636678200684, 1.0) -(0.36862745098039218, 0.30980392156862746, 0.63529411764705879, 1.0) diff --git a/extern/tfn/colormaps/diverging/bwr.cpp b/extern/tfn/colormaps/diverging/bwr.cpp deleted file mode 100644 index dbe0f7d..0000000 --- a/extern/tfn/colormaps/diverging/bwr.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_diverging_bwr; -} -const std::vector colormap::data_diverging_bwr = /* NOLINT(cert-err58-cpp) */ -{ -{0.0f, 0.0f, 1.0f, 1.0f}, -{0.0078431372549019607f, 0.0078431372549019607f, 1.0f, 1.0f}, -{0.015686274509803921f, 0.015686274509803921f, 1.0f, 1.0f}, -{0.023529411764705882f, 0.023529411764705882f, 1.0f, 1.0f}, -{0.031372549019607843f, 0.031372549019607843f, 1.0f, 1.0f}, -{0.039215686274509803f, 0.039215686274509803f, 1.0f, 1.0f}, -{0.047058823529411764f, 0.047058823529411764f, 1.0f, 1.0f}, -{0.054901960784313725f, 0.054901960784313725f, 1.0f, 1.0f}, -{0.062745098039215685f, 0.062745098039215685f, 1.0f, 1.0f}, -{0.070588235294117646f, 0.070588235294117646f, 1.0f, 1.0f}, -{0.078431372549019607f, 0.078431372549019607f, 1.0f, 1.0f}, -{0.086274509803921567f, 0.086274509803921567f, 1.0f, 1.0f}, -{0.094117647058823528f, 0.094117647058823528f, 1.0f, 1.0f}, -{0.10196078431372549f, 0.10196078431372549f, 1.0f, 1.0f}, -{0.10980392156862745f, 0.10980392156862745f, 1.0f, 1.0f}, -{0.11764705882352941f, 0.11764705882352941f, 1.0f, 1.0f}, -{0.12549019607843137f, 0.12549019607843137f, 1.0f, 1.0f}, -{0.13333333333333333f, 0.13333333333333333f, 1.0f, 1.0f}, -{0.14117647058823529f, 0.14117647058823529f, 1.0f, 1.0f}, -{0.14901960784313725f, 0.14901960784313725f, 1.0f, 1.0f}, -{0.15686274509803921f, 0.15686274509803921f, 1.0f, 1.0f}, -{0.16470588235294117f, 0.16470588235294117f, 1.0f, 1.0f}, -{0.17254901960784313f, 0.17254901960784313f, 1.0f, 1.0f}, -{0.1803921568627451f, 0.1803921568627451f, 1.0f, 1.0f}, -{0.18823529411764706f, 0.18823529411764706f, 1.0f, 1.0f}, -{0.19607843137254902f, 0.19607843137254902f, 1.0f, 1.0f}, -{0.20392156862745098f, 0.20392156862745098f, 1.0f, 1.0f}, -{0.21176470588235294f, 0.21176470588235294f, 1.0f, 1.0f}, -{0.2196078431372549f, 0.2196078431372549f, 1.0f, 1.0f}, -{0.22745098039215686f, 0.22745098039215686f, 1.0f, 1.0f}, -{0.23529411764705882f, 0.23529411764705882f, 1.0f, 1.0f}, -{0.24313725490196078f, 0.24313725490196078f, 1.0f, 1.0f}, -{0.25098039215686274f, 0.25098039215686274f, 1.0f, 1.0f}, -{0.25882352941176467f, 0.25882352941176467f, 1.0f, 1.0f}, -{0.26666666666666666f, 0.26666666666666666f, 1.0f, 1.0f}, -{0.27450980392156865f, 0.27450980392156865f, 1.0f, 1.0f}, -{0.28235294117647058f, 0.28235294117647058f, 1.0f, 1.0f}, -{0.29019607843137252f, 0.29019607843137252f, 1.0f, 1.0f}, -{0.29803921568627451f, 0.29803921568627451f, 1.0f, 1.0f}, -{0.30588235294117649f, 0.30588235294117649f, 1.0f, 1.0f}, -{0.31372549019607843f, 0.31372549019607843f, 1.0f, 1.0f}, -{0.32156862745098036f, 0.32156862745098036f, 1.0f, 1.0f}, -{0.32941176470588235f, 0.32941176470588235f, 1.0f, 1.0f}, -{0.33725490196078434f, 0.33725490196078434f, 1.0f, 1.0f}, -{0.34509803921568627f, 0.34509803921568627f, 1.0f, 1.0f}, -{0.3529411764705882f, 0.3529411764705882f, 1.0f, 1.0f}, -{0.36078431372549019f, 0.36078431372549019f, 1.0f, 1.0f}, -{0.36862745098039218f, 0.36862745098039218f, 1.0f, 1.0f}, -{0.37647058823529411f, 0.37647058823529411f, 1.0f, 1.0f}, -{0.38431372549019605f, 0.38431372549019605f, 1.0f, 1.0f}, -{0.39215686274509803f, 0.39215686274509803f, 1.0f, 1.0f}, -{0.40000000000000002f, 0.40000000000000002f, 1.0f, 1.0f}, -{0.40784313725490196f, 0.40784313725490196f, 1.0f, 1.0f}, -{0.41568627450980389f, 0.41568627450980389f, 1.0f, 1.0f}, -{0.42352941176470588f, 0.42352941176470588f, 1.0f, 1.0f}, -{0.43137254901960786f, 0.43137254901960786f, 1.0f, 1.0f}, -{0.4392156862745098f, 0.4392156862745098f, 1.0f, 1.0f}, -{0.44705882352941173f, 0.44705882352941173f, 1.0f, 1.0f}, -{0.45490196078431372f, 0.45490196078431372f, 1.0f, 1.0f}, -{0.46274509803921571f, 0.46274509803921571f, 1.0f, 1.0f}, -{0.47058823529411764f, 0.47058823529411764f, 1.0f, 1.0f}, -{0.47843137254901957f, 0.47843137254901957f, 1.0f, 1.0f}, -{0.48627450980392156f, 0.48627450980392156f, 1.0f, 1.0f}, -{0.49411764705882355f, 0.49411764705882355f, 1.0f, 1.0f}, -{0.50196078431372548f, 0.50196078431372548f, 1.0f, 1.0f}, -{0.50980392156862742f, 0.50980392156862742f, 1.0f, 1.0f}, -{0.51764705882352935f, 0.51764705882352935f, 1.0f, 1.0f}, -{0.52549019607843139f, 0.52549019607843139f, 1.0f, 1.0f}, -{0.53333333333333333f, 0.53333333333333333f, 1.0f, 1.0f}, -{0.54117647058823526f, 0.54117647058823526f, 1.0f, 1.0f}, -{0.5490196078431373f, 0.5490196078431373f, 1.0f, 1.0f}, -{0.55686274509803924f, 0.55686274509803924f, 1.0f, 1.0f}, -{0.56470588235294117f, 0.56470588235294117f, 1.0f, 1.0f}, -{0.5725490196078431f, 0.5725490196078431f, 1.0f, 1.0f}, -{0.58039215686274503f, 0.58039215686274503f, 1.0f, 1.0f}, -{0.58823529411764708f, 0.58823529411764708f, 1.0f, 1.0f}, -{0.59607843137254901f, 0.59607843137254901f, 1.0f, 1.0f}, -{0.60392156862745094f, 0.60392156862745094f, 1.0f, 1.0f}, -{0.61176470588235299f, 0.61176470588235299f, 1.0f, 1.0f}, -{0.61960784313725492f, 0.61960784313725492f, 1.0f, 1.0f}, -{0.62745098039215685f, 0.62745098039215685f, 1.0f, 1.0f}, -{0.63529411764705879f, 0.63529411764705879f, 1.0f, 1.0f}, -{0.64313725490196072f, 0.64313725490196072f, 1.0f, 1.0f}, -{0.65098039215686276f, 0.65098039215686276f, 1.0f, 1.0f}, -{0.6588235294117647f, 0.6588235294117647f, 1.0f, 1.0f}, -{0.66666666666666663f, 0.66666666666666663f, 1.0f, 1.0f}, -{0.67450980392156867f, 0.67450980392156867f, 1.0f, 1.0f}, -{0.68235294117647061f, 0.68235294117647061f, 1.0f, 1.0f}, -{0.69019607843137254f, 0.69019607843137254f, 1.0f, 1.0f}, -{0.69803921568627447f, 0.69803921568627447f, 1.0f, 1.0f}, -{0.70588235294117641f, 0.70588235294117641f, 1.0f, 1.0f}, -{0.71372549019607845f, 0.71372549019607845f, 1.0f, 1.0f}, -{0.72156862745098038f, 0.72156862745098038f, 1.0f, 1.0f}, -{0.72941176470588232f, 0.72941176470588232f, 1.0f, 1.0f}, -{0.73725490196078436f, 0.73725490196078436f, 1.0f, 1.0f}, -{0.74509803921568629f, 0.74509803921568629f, 1.0f, 1.0f}, -{0.75294117647058822f, 0.75294117647058822f, 1.0f, 1.0f}, -{0.76078431372549016f, 0.76078431372549016f, 1.0f, 1.0f}, -{0.76862745098039209f, 0.76862745098039209f, 1.0f, 1.0f}, -{0.77647058823529413f, 0.77647058823529413f, 1.0f, 1.0f}, -{0.78431372549019607f, 0.78431372549019607f, 1.0f, 1.0f}, -{0.792156862745098f, 0.792156862745098f, 1.0f, 1.0f}, -{0.80000000000000004f, 0.80000000000000004f, 1.0f, 1.0f}, -{0.80784313725490198f, 0.80784313725490198f, 1.0f, 1.0f}, -{0.81568627450980391f, 0.81568627450980391f, 1.0f, 1.0f}, -{0.82352941176470584f, 0.82352941176470584f, 1.0f, 1.0f}, -{0.83137254901960778f, 0.83137254901960778f, 1.0f, 1.0f}, -{0.83921568627450982f, 0.83921568627450982f, 1.0f, 1.0f}, -{0.84705882352941175f, 0.84705882352941175f, 1.0f, 1.0f}, -{0.85490196078431369f, 0.85490196078431369f, 1.0f, 1.0f}, -{0.86274509803921573f, 0.86274509803921573f, 1.0f, 1.0f}, -{0.87058823529411766f, 0.87058823529411766f, 1.0f, 1.0f}, -{0.8784313725490196f, 0.8784313725490196f, 1.0f, 1.0f}, -{0.88627450980392153f, 0.88627450980392153f, 1.0f, 1.0f}, -{0.89411764705882346f, 0.89411764705882346f, 1.0f, 1.0f}, -{0.90196078431372551f, 0.90196078431372551f, 1.0f, 1.0f}, -{0.90980392156862744f, 0.90980392156862744f, 1.0f, 1.0f}, -{0.91764705882352937f, 0.91764705882352937f, 1.0f, 1.0f}, -{0.92549019607843142f, 0.92549019607843142f, 1.0f, 1.0f}, -{0.93333333333333335f, 0.93333333333333335f, 1.0f, 1.0f}, -{0.94117647058823528f, 0.94117647058823528f, 1.0f, 1.0f}, -{0.94901960784313721f, 0.94901960784313721f, 1.0f, 1.0f}, -{0.95686274509803915f, 0.95686274509803915f, 1.0f, 1.0f}, -{0.96470588235294119f, 0.96470588235294119f, 1.0f, 1.0f}, -{0.97254901960784312f, 0.97254901960784312f, 1.0f, 1.0f}, -{0.98039215686274506f, 0.98039215686274506f, 1.0f, 1.0f}, -{0.9882352941176471f, 0.9882352941176471f, 1.0f, 1.0f}, -{0.99607843137254903f, 0.99607843137254903f, 1.0f, 1.0f}, -{1.0f, 0.99607843137254903f, 0.99607843137254903f, 1.0f}, -{1.0f, 0.9882352941176471f, 0.9882352941176471f, 1.0f}, -{1.0f, 0.98039215686274506f, 0.98039215686274506f, 1.0f}, -{1.0f, 0.97254901960784312f, 0.97254901960784312f, 1.0f}, -{1.0f, 0.96470588235294141f, 0.96470588235294141f, 1.0f}, -{1.0f, 0.95686274509803926f, 0.95686274509803926f, 1.0f}, -{1.0f, 0.94901960784313721f, 0.94901960784313721f, 1.0f}, -{1.0f, 0.94117647058823528f, 0.94117647058823528f, 1.0f}, -{1.0f, 0.93333333333333335f, 0.93333333333333335f, 1.0f}, -{1.0f, 0.92549019607843142f, 0.92549019607843142f, 1.0f}, -{1.0f, 0.91764705882352937f, 0.91764705882352937f, 1.0f}, -{1.0f, 0.90980392156862744f, 0.90980392156862744f, 1.0f}, -{1.0f, 0.90196078431372551f, 0.90196078431372551f, 1.0f}, -{1.0f, 0.89411764705882357f, 0.89411764705882357f, 1.0f}, -{1.0f, 0.88627450980392153f, 0.88627450980392153f, 1.0f}, -{1.0f, 0.8784313725490196f, 0.8784313725490196f, 1.0f}, -{1.0f, 0.87058823529411766f, 0.87058823529411766f, 1.0f}, -{1.0f, 0.86274509803921573f, 0.86274509803921573f, 1.0f}, -{1.0f, 0.85490196078431369f, 0.85490196078431369f, 1.0f}, -{1.0f, 0.84705882352941175f, 0.84705882352941175f, 1.0f}, -{1.0f, 0.83921568627451004f, 0.83921568627451004f, 1.0f}, -{1.0f, 0.83137254901960778f, 0.83137254901960778f, 1.0f}, -{1.0f, 0.82352941176470584f, 0.82352941176470584f, 1.0f}, -{1.0f, 0.81568627450980391f, 0.81568627450980391f, 1.0f}, -{1.0f, 0.80784313725490198f, 0.80784313725490198f, 1.0f}, -{1.0f, 0.80000000000000004f, 0.80000000000000004f, 1.0f}, -{1.0f, 0.792156862745098f, 0.792156862745098f, 1.0f}, -{1.0f, 0.78431372549019607f, 0.78431372549019607f, 1.0f}, -{1.0f, 0.77647058823529413f, 0.77647058823529413f, 1.0f}, -{1.0f, 0.76862745098039209f, 0.76862745098039209f, 1.0f}, -{1.0f, 0.76078431372549016f, 0.76078431372549016f, 1.0f}, -{1.0f, 0.75294117647058822f, 0.75294117647058822f, 1.0f}, -{1.0f, 0.74509803921568629f, 0.74509803921568629f, 1.0f}, -{1.0f, 0.73725490196078436f, 0.73725490196078436f, 1.0f}, -{1.0f, 0.72941176470588243f, 0.72941176470588243f, 1.0f}, -{1.0f, 0.72156862745098038f, 0.72156862745098038f, 1.0f}, -{1.0f, 0.71372549019607867f, 0.71372549019607867f, 1.0f}, -{1.0f, 0.70588235294117641f, 0.70588235294117641f, 1.0f}, -{1.0f, 0.69803921568627447f, 0.69803921568627447f, 1.0f}, -{1.0f, 0.69019607843137254f, 0.69019607843137254f, 1.0f}, -{1.0f, 0.68235294117647061f, 0.68235294117647061f, 1.0f}, -{1.0f, 0.67450980392156867f, 0.67450980392156867f, 1.0f}, -{1.0f, 0.66666666666666674f, 0.66666666666666674f, 1.0f}, -{1.0f, 0.6588235294117647f, 0.6588235294117647f, 1.0f}, -{1.0f, 0.65098039215686276f, 0.65098039215686276f, 1.0f}, -{1.0f, 0.64313725490196072f, 0.64313725490196072f, 1.0f}, -{1.0f, 0.63529411764705879f, 0.63529411764705879f, 1.0f}, -{1.0f, 0.62745098039215685f, 0.62745098039215685f, 1.0f}, -{1.0f, 0.61960784313725492f, 0.61960784313725492f, 1.0f}, -{1.0f, 0.61176470588235299f, 0.61176470588235299f, 1.0f}, -{1.0f, 0.60392156862745106f, 0.60392156862745106f, 1.0f}, -{1.0f, 0.59607843137254901f, 0.59607843137254901f, 1.0f}, -{1.0f, 0.5882352941176473f, 0.5882352941176473f, 1.0f}, -{1.0f, 0.58039215686274503f, 0.58039215686274503f, 1.0f}, -{1.0f, 0.5725490196078431f, 0.5725490196078431f, 1.0f}, -{1.0f, 0.56470588235294117f, 0.56470588235294117f, 1.0f}, -{1.0f, 0.55686274509803924f, 0.55686274509803924f, 1.0f}, -{1.0f, 0.5490196078431373f, 0.5490196078431373f, 1.0f}, -{1.0f, 0.54117647058823537f, 0.54117647058823537f, 1.0f}, -{1.0f, 0.53333333333333333f, 0.53333333333333333f, 1.0f}, -{1.0f, 0.52549019607843139f, 0.52549019607843139f, 1.0f}, -{1.0f, 0.51764705882352935f, 0.51764705882352935f, 1.0f}, -{1.0f, 0.50980392156862742f, 0.50980392156862742f, 1.0f}, -{1.0f, 0.50196078431372548f, 0.50196078431372548f, 1.0f}, -{1.0f, 0.49411764705882355f, 0.49411764705882355f, 1.0f}, -{1.0f, 0.48627450980392162f, 0.48627450980392162f, 1.0f}, -{1.0f, 0.47843137254901957f, 0.47843137254901957f, 1.0f}, -{1.0f, 0.47058823529411764f, 0.47058823529411764f, 1.0f}, -{1.0f, 0.46274509803921593f, 0.46274509803921593f, 1.0f}, -{1.0f, 0.45490196078431377f, 0.45490196078431377f, 1.0f}, -{1.0f, 0.44705882352941173f, 0.44705882352941173f, 1.0f}, -{1.0f, 0.4392156862745098f, 0.4392156862745098f, 1.0f}, -{1.0f, 0.43137254901960786f, 0.43137254901960786f, 1.0f}, -{1.0f, 0.42352941176470593f, 0.42352941176470593f, 1.0f}, -{1.0f, 0.41568627450980389f, 0.41568627450980389f, 1.0f}, -{1.0f, 0.40784313725490196f, 0.40784313725490196f, 1.0f}, -{1.0f, 0.40000000000000002f, 0.40000000000000002f, 1.0f}, -{1.0f, 0.39215686274509809f, 0.39215686274509809f, 1.0f}, -{1.0f, 0.38431372549019605f, 0.38431372549019605f, 1.0f}, -{1.0f, 0.37647058823529411f, 0.37647058823529411f, 1.0f}, -{1.0f, 0.36862745098039218f, 0.36862745098039218f, 1.0f}, -{1.0f, 0.36078431372549025f, 0.36078431372549025f, 1.0f}, -{1.0f, 0.3529411764705882f, 0.3529411764705882f, 1.0f}, -{1.0f, 0.34509803921568627f, 0.34509803921568627f, 1.0f}, -{1.0f, 0.33725490196078456f, 0.33725490196078456f, 1.0f}, -{1.0f, 0.3294117647058824f, 0.3294117647058824f, 1.0f}, -{1.0f, 0.32156862745098036f, 0.32156862745098036f, 1.0f}, -{1.0f, 0.31372549019607843f, 0.31372549019607843f, 1.0f}, -{1.0f, 0.30588235294117649f, 0.30588235294117649f, 1.0f}, -{1.0f, 0.29803921568627456f, 0.29803921568627456f, 1.0f}, -{1.0f, 0.29019607843137252f, 0.29019607843137252f, 1.0f}, -{1.0f, 0.28235294117647058f, 0.28235294117647058f, 1.0f}, -{1.0f, 0.27450980392156865f, 0.27450980392156865f, 1.0f}, -{1.0f, 0.26666666666666672f, 0.26666666666666672f, 1.0f}, -{1.0f, 0.25882352941176467f, 0.25882352941176467f, 1.0f}, -{1.0f, 0.25098039215686274f, 0.25098039215686274f, 1.0f}, -{1.0f, 0.24313725490196081f, 0.24313725490196081f, 1.0f}, -{1.0f, 0.23529411764705888f, 0.23529411764705888f, 1.0f}, -{1.0f, 0.22745098039215683f, 0.22745098039215683f, 1.0f}, -{1.0f, 0.2196078431372549f, 0.2196078431372549f, 1.0f}, -{1.0f, 0.21176470588235319f, 0.21176470588235319f, 1.0f}, -{1.0f, 0.20392156862745103f, 0.20392156862745103f, 1.0f}, -{1.0f, 0.19607843137254899f, 0.19607843137254899f, 1.0f}, -{1.0f, 0.18823529411764706f, 0.18823529411764706f, 1.0f}, -{1.0f, 0.18039215686274512f, 0.18039215686274512f, 1.0f}, -{1.0f, 0.17254901960784319f, 0.17254901960784319f, 1.0f}, -{1.0f, 0.16470588235294115f, 0.16470588235294115f, 1.0f}, -{1.0f, 0.15686274509803921f, 0.15686274509803921f, 1.0f}, -{1.0f, 0.14901960784313728f, 0.14901960784313728f, 1.0f}, -{1.0f, 0.14117647058823535f, 0.14117647058823535f, 1.0f}, -{1.0f, 0.1333333333333333f, 0.1333333333333333f, 1.0f}, -{1.0f, 0.12549019607843137f, 0.12549019607843137f, 1.0f}, -{1.0f, 0.11764705882352944f, 0.11764705882352944f, 1.0f}, -{1.0f, 0.1098039215686275f, 0.1098039215686275f, 1.0f}, -{1.0f, 0.10196078431372546f, 0.10196078431372546f, 1.0f}, -{1.0f, 0.094117647058823528f, 0.094117647058823528f, 1.0f}, -{1.0f, 0.086274509803921817f, 0.086274509803921817f, 1.0f}, -{1.0f, 0.078431372549019662f, 0.078431372549019662f, 1.0f}, -{1.0f, 0.070588235294117618f, 0.070588235294117618f, 1.0f}, -{1.0f, 0.062745098039215685f, 0.062745098039215685f, 1.0f}, -{1.0f, 0.054901960784313752f, 0.054901960784313752f, 1.0f}, -{1.0f, 0.04705882352941182f, 0.04705882352941182f, 1.0f}, -{1.0f, 0.039215686274509776f, 0.039215686274509776f, 1.0f}, -{1.0f, 0.031372549019607843f, 0.031372549019607843f, 1.0f}, -{1.0f, 0.02352941176470591f, 0.02352941176470591f, 1.0f}, -{1.0f, 0.015686274509803977f, 0.015686274509803977f, 1.0f}, -{1.0f, 0.0078431372549019329f, 0.0078431372549019329f, 1.0f}, -{1.0f, 0.0f, 0.0f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/diverging/bwr.txt b/extern/tfn/colormaps/diverging/bwr.txt deleted file mode 100644 index 77d09e1..0000000 --- a/extern/tfn/colormaps/diverging/bwr.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.0, 0.0, 1.0, 1.0) -(0.0078431372549019607, 0.0078431372549019607, 1.0, 1.0) -(0.015686274509803921, 0.015686274509803921, 1.0, 1.0) -(0.023529411764705882, 0.023529411764705882, 1.0, 1.0) -(0.031372549019607843, 0.031372549019607843, 1.0, 1.0) -(0.039215686274509803, 0.039215686274509803, 1.0, 1.0) -(0.047058823529411764, 0.047058823529411764, 1.0, 1.0) -(0.054901960784313725, 0.054901960784313725, 1.0, 1.0) -(0.062745098039215685, 0.062745098039215685, 1.0, 1.0) -(0.070588235294117646, 0.070588235294117646, 1.0, 1.0) -(0.078431372549019607, 0.078431372549019607, 1.0, 1.0) -(0.086274509803921567, 0.086274509803921567, 1.0, 1.0) -(0.094117647058823528, 0.094117647058823528, 1.0, 1.0) -(0.10196078431372549, 0.10196078431372549, 1.0, 1.0) -(0.10980392156862745, 0.10980392156862745, 1.0, 1.0) -(0.11764705882352941, 0.11764705882352941, 1.0, 1.0) -(0.12549019607843137, 0.12549019607843137, 1.0, 1.0) -(0.13333333333333333, 0.13333333333333333, 1.0, 1.0) -(0.14117647058823529, 0.14117647058823529, 1.0, 1.0) -(0.14901960784313725, 0.14901960784313725, 1.0, 1.0) -(0.15686274509803921, 0.15686274509803921, 1.0, 1.0) -(0.16470588235294117, 0.16470588235294117, 1.0, 1.0) -(0.17254901960784313, 0.17254901960784313, 1.0, 1.0) -(0.1803921568627451, 0.1803921568627451, 1.0, 1.0) -(0.18823529411764706, 0.18823529411764706, 1.0, 1.0) -(0.19607843137254902, 0.19607843137254902, 1.0, 1.0) -(0.20392156862745098, 0.20392156862745098, 1.0, 1.0) -(0.21176470588235294, 0.21176470588235294, 1.0, 1.0) -(0.2196078431372549, 0.2196078431372549, 1.0, 1.0) -(0.22745098039215686, 0.22745098039215686, 1.0, 1.0) -(0.23529411764705882, 0.23529411764705882, 1.0, 1.0) -(0.24313725490196078, 0.24313725490196078, 1.0, 1.0) -(0.25098039215686274, 0.25098039215686274, 1.0, 1.0) -(0.25882352941176467, 0.25882352941176467, 1.0, 1.0) -(0.26666666666666666, 0.26666666666666666, 1.0, 1.0) -(0.27450980392156865, 0.27450980392156865, 1.0, 1.0) -(0.28235294117647058, 0.28235294117647058, 1.0, 1.0) -(0.29019607843137252, 0.29019607843137252, 1.0, 1.0) -(0.29803921568627451, 0.29803921568627451, 1.0, 1.0) -(0.30588235294117649, 0.30588235294117649, 1.0, 1.0) -(0.31372549019607843, 0.31372549019607843, 1.0, 1.0) -(0.32156862745098036, 0.32156862745098036, 1.0, 1.0) -(0.32941176470588235, 0.32941176470588235, 1.0, 1.0) -(0.33725490196078434, 0.33725490196078434, 1.0, 1.0) -(0.34509803921568627, 0.34509803921568627, 1.0, 1.0) -(0.3529411764705882, 0.3529411764705882, 1.0, 1.0) -(0.36078431372549019, 0.36078431372549019, 1.0, 1.0) -(0.36862745098039218, 0.36862745098039218, 1.0, 1.0) -(0.37647058823529411, 0.37647058823529411, 1.0, 1.0) -(0.38431372549019605, 0.38431372549019605, 1.0, 1.0) -(0.39215686274509803, 0.39215686274509803, 1.0, 1.0) -(0.40000000000000002, 0.40000000000000002, 1.0, 1.0) -(0.40784313725490196, 0.40784313725490196, 1.0, 1.0) -(0.41568627450980389, 0.41568627450980389, 1.0, 1.0) -(0.42352941176470588, 0.42352941176470588, 1.0, 1.0) -(0.43137254901960786, 0.43137254901960786, 1.0, 1.0) -(0.4392156862745098, 0.4392156862745098, 1.0, 1.0) -(0.44705882352941173, 0.44705882352941173, 1.0, 1.0) -(0.45490196078431372, 0.45490196078431372, 1.0, 1.0) -(0.46274509803921571, 0.46274509803921571, 1.0, 1.0) -(0.47058823529411764, 0.47058823529411764, 1.0, 1.0) -(0.47843137254901957, 0.47843137254901957, 1.0, 1.0) -(0.48627450980392156, 0.48627450980392156, 1.0, 1.0) -(0.49411764705882355, 0.49411764705882355, 1.0, 1.0) -(0.50196078431372548, 0.50196078431372548, 1.0, 1.0) -(0.50980392156862742, 0.50980392156862742, 1.0, 1.0) -(0.51764705882352935, 0.51764705882352935, 1.0, 1.0) -(0.52549019607843139, 0.52549019607843139, 1.0, 1.0) -(0.53333333333333333, 0.53333333333333333, 1.0, 1.0) -(0.54117647058823526, 0.54117647058823526, 1.0, 1.0) -(0.5490196078431373, 0.5490196078431373, 1.0, 1.0) -(0.55686274509803924, 0.55686274509803924, 1.0, 1.0) -(0.56470588235294117, 0.56470588235294117, 1.0, 1.0) -(0.5725490196078431, 0.5725490196078431, 1.0, 1.0) -(0.58039215686274503, 0.58039215686274503, 1.0, 1.0) -(0.58823529411764708, 0.58823529411764708, 1.0, 1.0) -(0.59607843137254901, 0.59607843137254901, 1.0, 1.0) -(0.60392156862745094, 0.60392156862745094, 1.0, 1.0) -(0.61176470588235299, 0.61176470588235299, 1.0, 1.0) -(0.61960784313725492, 0.61960784313725492, 1.0, 1.0) -(0.62745098039215685, 0.62745098039215685, 1.0, 1.0) -(0.63529411764705879, 0.63529411764705879, 1.0, 1.0) -(0.64313725490196072, 0.64313725490196072, 1.0, 1.0) -(0.65098039215686276, 0.65098039215686276, 1.0, 1.0) -(0.6588235294117647, 0.6588235294117647, 1.0, 1.0) -(0.66666666666666663, 0.66666666666666663, 1.0, 1.0) -(0.67450980392156867, 0.67450980392156867, 1.0, 1.0) -(0.68235294117647061, 0.68235294117647061, 1.0, 1.0) -(0.69019607843137254, 0.69019607843137254, 1.0, 1.0) -(0.69803921568627447, 0.69803921568627447, 1.0, 1.0) -(0.70588235294117641, 0.70588235294117641, 1.0, 1.0) -(0.71372549019607845, 0.71372549019607845, 1.0, 1.0) -(0.72156862745098038, 0.72156862745098038, 1.0, 1.0) -(0.72941176470588232, 0.72941176470588232, 1.0, 1.0) -(0.73725490196078436, 0.73725490196078436, 1.0, 1.0) -(0.74509803921568629, 0.74509803921568629, 1.0, 1.0) -(0.75294117647058822, 0.75294117647058822, 1.0, 1.0) -(0.76078431372549016, 0.76078431372549016, 1.0, 1.0) -(0.76862745098039209, 0.76862745098039209, 1.0, 1.0) -(0.77647058823529413, 0.77647058823529413, 1.0, 1.0) -(0.78431372549019607, 0.78431372549019607, 1.0, 1.0) -(0.792156862745098, 0.792156862745098, 1.0, 1.0) -(0.80000000000000004, 0.80000000000000004, 1.0, 1.0) -(0.80784313725490198, 0.80784313725490198, 1.0, 1.0) -(0.81568627450980391, 0.81568627450980391, 1.0, 1.0) -(0.82352941176470584, 0.82352941176470584, 1.0, 1.0) -(0.83137254901960778, 0.83137254901960778, 1.0, 1.0) -(0.83921568627450982, 0.83921568627450982, 1.0, 1.0) -(0.84705882352941175, 0.84705882352941175, 1.0, 1.0) -(0.85490196078431369, 0.85490196078431369, 1.0, 1.0) -(0.86274509803921573, 0.86274509803921573, 1.0, 1.0) -(0.87058823529411766, 0.87058823529411766, 1.0, 1.0) -(0.8784313725490196, 0.8784313725490196, 1.0, 1.0) -(0.88627450980392153, 0.88627450980392153, 1.0, 1.0) -(0.89411764705882346, 0.89411764705882346, 1.0, 1.0) -(0.90196078431372551, 0.90196078431372551, 1.0, 1.0) -(0.90980392156862744, 0.90980392156862744, 1.0, 1.0) -(0.91764705882352937, 0.91764705882352937, 1.0, 1.0) -(0.92549019607843142, 0.92549019607843142, 1.0, 1.0) -(0.93333333333333335, 0.93333333333333335, 1.0, 1.0) -(0.94117647058823528, 0.94117647058823528, 1.0, 1.0) -(0.94901960784313721, 0.94901960784313721, 1.0, 1.0) -(0.95686274509803915, 0.95686274509803915, 1.0, 1.0) -(0.96470588235294119, 0.96470588235294119, 1.0, 1.0) -(0.97254901960784312, 0.97254901960784312, 1.0, 1.0) -(0.98039215686274506, 0.98039215686274506, 1.0, 1.0) -(0.9882352941176471, 0.9882352941176471, 1.0, 1.0) -(0.99607843137254903, 0.99607843137254903, 1.0, 1.0) -(1.0, 0.99607843137254903, 0.99607843137254903, 1.0) -(1.0, 0.9882352941176471, 0.9882352941176471, 1.0) -(1.0, 0.98039215686274506, 0.98039215686274506, 1.0) -(1.0, 0.97254901960784312, 0.97254901960784312, 1.0) -(1.0, 0.96470588235294141, 0.96470588235294141, 1.0) -(1.0, 0.95686274509803926, 0.95686274509803926, 1.0) -(1.0, 0.94901960784313721, 0.94901960784313721, 1.0) -(1.0, 0.94117647058823528, 0.94117647058823528, 1.0) -(1.0, 0.93333333333333335, 0.93333333333333335, 1.0) -(1.0, 0.92549019607843142, 0.92549019607843142, 1.0) -(1.0, 0.91764705882352937, 0.91764705882352937, 1.0) -(1.0, 0.90980392156862744, 0.90980392156862744, 1.0) -(1.0, 0.90196078431372551, 0.90196078431372551, 1.0) -(1.0, 0.89411764705882357, 0.89411764705882357, 1.0) -(1.0, 0.88627450980392153, 0.88627450980392153, 1.0) -(1.0, 0.8784313725490196, 0.8784313725490196, 1.0) -(1.0, 0.87058823529411766, 0.87058823529411766, 1.0) -(1.0, 0.86274509803921573, 0.86274509803921573, 1.0) -(1.0, 0.85490196078431369, 0.85490196078431369, 1.0) -(1.0, 0.84705882352941175, 0.84705882352941175, 1.0) -(1.0, 0.83921568627451004, 0.83921568627451004, 1.0) -(1.0, 0.83137254901960778, 0.83137254901960778, 1.0) -(1.0, 0.82352941176470584, 0.82352941176470584, 1.0) -(1.0, 0.81568627450980391, 0.81568627450980391, 1.0) -(1.0, 0.80784313725490198, 0.80784313725490198, 1.0) -(1.0, 0.80000000000000004, 0.80000000000000004, 1.0) -(1.0, 0.792156862745098, 0.792156862745098, 1.0) -(1.0, 0.78431372549019607, 0.78431372549019607, 1.0) -(1.0, 0.77647058823529413, 0.77647058823529413, 1.0) -(1.0, 0.76862745098039209, 0.76862745098039209, 1.0) -(1.0, 0.76078431372549016, 0.76078431372549016, 1.0) -(1.0, 0.75294117647058822, 0.75294117647058822, 1.0) -(1.0, 0.74509803921568629, 0.74509803921568629, 1.0) -(1.0, 0.73725490196078436, 0.73725490196078436, 1.0) -(1.0, 0.72941176470588243, 0.72941176470588243, 1.0) -(1.0, 0.72156862745098038, 0.72156862745098038, 1.0) -(1.0, 0.71372549019607867, 0.71372549019607867, 1.0) -(1.0, 0.70588235294117641, 0.70588235294117641, 1.0) -(1.0, 0.69803921568627447, 0.69803921568627447, 1.0) -(1.0, 0.69019607843137254, 0.69019607843137254, 1.0) -(1.0, 0.68235294117647061, 0.68235294117647061, 1.0) -(1.0, 0.67450980392156867, 0.67450980392156867, 1.0) -(1.0, 0.66666666666666674, 0.66666666666666674, 1.0) -(1.0, 0.6588235294117647, 0.6588235294117647, 1.0) -(1.0, 0.65098039215686276, 0.65098039215686276, 1.0) -(1.0, 0.64313725490196072, 0.64313725490196072, 1.0) -(1.0, 0.63529411764705879, 0.63529411764705879, 1.0) -(1.0, 0.62745098039215685, 0.62745098039215685, 1.0) -(1.0, 0.61960784313725492, 0.61960784313725492, 1.0) -(1.0, 0.61176470588235299, 0.61176470588235299, 1.0) -(1.0, 0.60392156862745106, 0.60392156862745106, 1.0) -(1.0, 0.59607843137254901, 0.59607843137254901, 1.0) -(1.0, 0.5882352941176473, 0.5882352941176473, 1.0) -(1.0, 0.58039215686274503, 0.58039215686274503, 1.0) -(1.0, 0.5725490196078431, 0.5725490196078431, 1.0) -(1.0, 0.56470588235294117, 0.56470588235294117, 1.0) -(1.0, 0.55686274509803924, 0.55686274509803924, 1.0) -(1.0, 0.5490196078431373, 0.5490196078431373, 1.0) -(1.0, 0.54117647058823537, 0.54117647058823537, 1.0) -(1.0, 0.53333333333333333, 0.53333333333333333, 1.0) -(1.0, 0.52549019607843139, 0.52549019607843139, 1.0) -(1.0, 0.51764705882352935, 0.51764705882352935, 1.0) -(1.0, 0.50980392156862742, 0.50980392156862742, 1.0) -(1.0, 0.50196078431372548, 0.50196078431372548, 1.0) -(1.0, 0.49411764705882355, 0.49411764705882355, 1.0) -(1.0, 0.48627450980392162, 0.48627450980392162, 1.0) -(1.0, 0.47843137254901957, 0.47843137254901957, 1.0) -(1.0, 0.47058823529411764, 0.47058823529411764, 1.0) -(1.0, 0.46274509803921593, 0.46274509803921593, 1.0) -(1.0, 0.45490196078431377, 0.45490196078431377, 1.0) -(1.0, 0.44705882352941173, 0.44705882352941173, 1.0) -(1.0, 0.4392156862745098, 0.4392156862745098, 1.0) -(1.0, 0.43137254901960786, 0.43137254901960786, 1.0) -(1.0, 0.42352941176470593, 0.42352941176470593, 1.0) -(1.0, 0.41568627450980389, 0.41568627450980389, 1.0) -(1.0, 0.40784313725490196, 0.40784313725490196, 1.0) -(1.0, 0.40000000000000002, 0.40000000000000002, 1.0) -(1.0, 0.39215686274509809, 0.39215686274509809, 1.0) -(1.0, 0.38431372549019605, 0.38431372549019605, 1.0) -(1.0, 0.37647058823529411, 0.37647058823529411, 1.0) -(1.0, 0.36862745098039218, 0.36862745098039218, 1.0) -(1.0, 0.36078431372549025, 0.36078431372549025, 1.0) -(1.0, 0.3529411764705882, 0.3529411764705882, 1.0) -(1.0, 0.34509803921568627, 0.34509803921568627, 1.0) -(1.0, 0.33725490196078456, 0.33725490196078456, 1.0) -(1.0, 0.3294117647058824, 0.3294117647058824, 1.0) -(1.0, 0.32156862745098036, 0.32156862745098036, 1.0) -(1.0, 0.31372549019607843, 0.31372549019607843, 1.0) -(1.0, 0.30588235294117649, 0.30588235294117649, 1.0) -(1.0, 0.29803921568627456, 0.29803921568627456, 1.0) -(1.0, 0.29019607843137252, 0.29019607843137252, 1.0) -(1.0, 0.28235294117647058, 0.28235294117647058, 1.0) -(1.0, 0.27450980392156865, 0.27450980392156865, 1.0) -(1.0, 0.26666666666666672, 0.26666666666666672, 1.0) -(1.0, 0.25882352941176467, 0.25882352941176467, 1.0) -(1.0, 0.25098039215686274, 0.25098039215686274, 1.0) -(1.0, 0.24313725490196081, 0.24313725490196081, 1.0) -(1.0, 0.23529411764705888, 0.23529411764705888, 1.0) -(1.0, 0.22745098039215683, 0.22745098039215683, 1.0) -(1.0, 0.2196078431372549, 0.2196078431372549, 1.0) -(1.0, 0.21176470588235319, 0.21176470588235319, 1.0) -(1.0, 0.20392156862745103, 0.20392156862745103, 1.0) -(1.0, 0.19607843137254899, 0.19607843137254899, 1.0) -(1.0, 0.18823529411764706, 0.18823529411764706, 1.0) -(1.0, 0.18039215686274512, 0.18039215686274512, 1.0) -(1.0, 0.17254901960784319, 0.17254901960784319, 1.0) -(1.0, 0.16470588235294115, 0.16470588235294115, 1.0) -(1.0, 0.15686274509803921, 0.15686274509803921, 1.0) -(1.0, 0.14901960784313728, 0.14901960784313728, 1.0) -(1.0, 0.14117647058823535, 0.14117647058823535, 1.0) -(1.0, 0.1333333333333333, 0.1333333333333333, 1.0) -(1.0, 0.12549019607843137, 0.12549019607843137, 1.0) -(1.0, 0.11764705882352944, 0.11764705882352944, 1.0) -(1.0, 0.1098039215686275, 0.1098039215686275, 1.0) -(1.0, 0.10196078431372546, 0.10196078431372546, 1.0) -(1.0, 0.094117647058823528, 0.094117647058823528, 1.0) -(1.0, 0.086274509803921817, 0.086274509803921817, 1.0) -(1.0, 0.078431372549019662, 0.078431372549019662, 1.0) -(1.0, 0.070588235294117618, 0.070588235294117618, 1.0) -(1.0, 0.062745098039215685, 0.062745098039215685, 1.0) -(1.0, 0.054901960784313752, 0.054901960784313752, 1.0) -(1.0, 0.04705882352941182, 0.04705882352941182, 1.0) -(1.0, 0.039215686274509776, 0.039215686274509776, 1.0) -(1.0, 0.031372549019607843, 0.031372549019607843, 1.0) -(1.0, 0.02352941176470591, 0.02352941176470591, 1.0) -(1.0, 0.015686274509803977, 0.015686274509803977, 1.0) -(1.0, 0.0078431372549019329, 0.0078431372549019329, 1.0) -(1.0, 0.0, 0.0, 1.0) diff --git a/extern/tfn/colormaps/diverging/coolwarm.cpp b/extern/tfn/colormaps/diverging/coolwarm.cpp deleted file mode 100644 index e3e0e1b..0000000 --- a/extern/tfn/colormaps/diverging/coolwarm.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_diverging_coolwarm; -} -const std::vector colormap::data_diverging_coolwarm = /* NOLINT(cert-err58-cpp) */ -{ -{0.2298057f, 0.298717966f, 0.75368315299999999f, 1.0f}, -{0.23437707945098038f, 0.30554173032941179f, 0.75967952758823531f, 1.0f}, -{0.23894845890196079f, 0.31236549465882352f, 0.76567590217647052f, 1.0f}, -{0.24351983835294116f, 0.3191892589882353f, 0.77167227676470584f, 1.0f}, -{0.24809121780392157f, 0.32601302331764709f, 0.77766865135294116f, 1.0f}, -{0.25266259725490192f, 0.33283678764705882f, 0.78366502594117649f, 1.0f}, -{0.25723397670588233f, 0.3396605519764706f, 0.78966140052941169f, 1.0f}, -{0.26180535615686273f, 0.34648431630588239f, 0.79565777511764701f, 1.0f}, -{0.26638146835294113f, 0.35330440842352945f, 0.80163731949803918f, 1.0f}, -{0.27110429564705879f, 0.36001066197647058f, 0.8070951274352941f, 1.0f}, -{0.27582712294117645f, 0.36671691552941177f, 0.81255293537254902f, 1.0f}, -{0.28054995023529411f, 0.37342316908235296f, 0.81801074330980394f, 1.0f}, -{0.28527277752941177f, 0.38012942263529415f, 0.82346855124705887f, 1.0f}, -{0.28999560482352937f, 0.38683567618823528f, 0.82892635918431368f, 1.0f}, -{0.29471843211764703f, 0.39354192974117647f, 0.8343841671215686f, 1.0f}, -{0.29944125941176469f, 0.40024818329411765f, 0.83984197505882352f, 1.0f}, -{0.30417428700392157f, 0.40694488283921565f, 0.84526272669803926f, 1.0f}, -{0.30906031906666664f, 0.41349827226666663f, 0.85012763386666668f, 1.0f}, -{0.31394635112941177f, 0.42005166169411762f, 0.8549925410352941f, 1.0f}, -{0.31883238319215684f, 0.4266050511215686f, 0.85985744820392163f, 1.0f}, -{0.32371841525490197f, 0.43315844054901959f, 0.86472235537254905f, 1.0f}, -{0.32860444731764704f, 0.43971182997647057f, 0.86958726254117646f, 1.0f}, -{0.33349047938039217f, 0.44626521940392155f, 0.87445216970980388f, 1.0f}, -{0.3383765114431373f, 0.45281860883137254f, 0.8793170768784313f, 1.0f}, -{0.34327752343529416f, 0.45935363472941176f, 0.88412192162352943f, 1.0f}, -{0.34832334141176474f, 0.46571114650980389f, 0.88834616294117641f, 1.0f}, -{0.35336915938823532f, 0.47206865829019606f, 0.8925704042588235f, 1.0f}, -{0.3584149773647059f, 0.47842617007058824f, 0.89679464557647059f, 1.0f}, -{0.36346079534117648f, 0.48478368185098042f, 0.90101888689411769f, 1.0f}, -{0.36850661331764706f, 0.49114119363137254f, 0.90524312821176467f, 1.0f}, -{0.37355243129411764f, 0.49749870541176472f, 0.90946736952941176f, 1.0f}, -{0.37859824927058822f, 0.5038562171921569f, 0.91369161084705885f, 1.0f}, -{0.38366206577254902f, 0.51018341728627459f, 0.91783067323137257f, 1.0f}, -{0.38885187195294113f, 0.51629843557647059f, 0.9213734830823529f, 1.0f}, -{0.3940416781333333f, 0.52241345386666671f, 0.92491629293333333f, 1.0f}, -{0.39923148431372546f, 0.52852847215686283f, 0.92845910278431376f, 1.0f}, -{0.40442129049411762f, 0.53464349044705883f, 0.93200191263529408f, 1.0f}, -{0.40961109667450979f, 0.54075850873725495f, 0.93554472248627452f, 1.0f}, -{0.41480090285490195f, 0.54687352702745107f, 0.93908753233725495f, 1.0f}, -{0.41999070903529412f, 0.55298854531764707f, 0.94263034218823527f, 1.0f}, -{0.42519897019607844f, 0.55905817976470595f, 0.94606145707843137f, 1.0f}, -{0.43050688825098038f, 0.56488274145882356f, 0.94888941918039216f, 1.0f}, -{0.43581480630588237f, 0.57070730315294116f, 0.95171738128235295f, 1.0f}, -{0.44112272436078431f, 0.57653186484705887f, 0.95454534338431374f, 1.0f}, -{0.44643064241568631f, 0.58235642654117648f, 0.95737330548627453f, 1.0f}, -{0.45173856047058819f, 0.58818098823529408f, 0.96020126758823521f, 1.0f}, -{0.45704647852549019f, 0.59400554992941179f, 0.963029229690196f, 1.0f}, -{0.46235439658039218f, 0.59983011162352939f, 0.96585719179215679f, 1.0f}, -{0.46767809468235294f, 0.60559123162352935f, 0.96854628109411756f, 1.0f}, -{0.47307017298823528f, 0.61107743761568623f, 0.97063358826274504f, 1.0f}, -{0.47846225129411762f, 0.6165636436078431f, 0.97272089543137252f, 1.0f}, -{0.48385432959999997f, 0.62204984959999998f, 0.97480820260000001f, 1.0f}, -{0.48924640790588236f, 0.62753605559215686f, 0.97689550976862749f, 1.0f}, -{0.49463848621176465f, 0.63302226158431363f, 0.97898281693725486f, 1.0f}, -{0.50003056451764705f, 0.63850846757647062f, 0.98107012410588235f, 1.0f}, -{0.50542264282352933f, 0.6439946735686275f, 0.98315743127450983f, 1.0f}, -{0.51082432425098034f, 0.64939661482352939f, 0.98507877637647068f, 1.0f}, -{0.51626030254117639f, 0.6544976105882353f, 0.98640739981176473f, 1.0f}, -{0.52169628083137254f, 0.65959860635294121f, 0.98773602324705889f, 1.0f}, -{0.52713225912156858f, 0.664699602117647f, 0.98906464668235294f, 1.0f}, -{0.53256823741176462f, 0.66980059788235291f, 0.99039327011764711f, 1.0f}, -{0.53800421570196066f, 0.67490159364705871f, 0.99172189355294116f, 1.0f}, -{0.54344019399215682f, 0.68000258941176472f, 0.99305051698823532f, 1.0f}, -{0.54887617228235286f, 0.68510358517647052f, 0.99437914042352948f, 1.0f}, -{0.55431186991372539f, 0.69009701121568623f, 0.99551554823529409f, 1.0f}, -{0.55974672556862737f, 0.69476772807843135f, 0.99607530917647058f, 1.0f}, -{0.56518158122352935f, 0.69943844494117635f, 0.99663507011764707f, 1.0f}, -{0.57061643687843133f, 0.70410916180392158f, 0.99719483105882356f, 1.0f}, -{0.57605129253333331f, 0.7087798786666667f, 0.99775459200000005f, 1.0f}, -{0.5814861481882353f, 0.7134505955294117f, 0.99831435294117643f, 1.0f}, -{0.58692100384313728f, 0.71812131239215682f, 0.99887411388235292f, 1.0f}, -{0.59235585949803926f, 0.72279202925490194f, 0.99943387482352941f, 1.0f}, -{0.59777677549411767f, 0.72732972488235292f, 0.99977673177647053f, 1.0f}, -{0.60316206791764704f, 0.73152747735294121f, 0.99956527853725485f, 1.0f}, -{0.6085473603411764f, 0.73572522982352939f, 0.99935382529803918f, 1.0f}, -{0.61393265276470588f, 0.73992298229411768f, 0.9991423720588235f, 1.0f}, -{0.61931794518823535f, 0.74412073476470586f, 0.99893091881960783f, 1.0f}, -{0.62470323761176472f, 0.74831848723529415f, 0.99871946558039215f, 1.0f}, -{0.63008853003529408f, 0.75251623970588233f, 0.99850801234117648f, 1.0f}, -{0.63547382245882356f, 0.75671399217647062f, 0.9982965591019608f, 1.0f}, -{0.640827782372549f, 0.7607515064117647f, 0.99784577488235293f, 1.0f}, -{0.64611281076470584f, 0.7644364965294117f, 0.99686846250588235f, 1.0f}, -{0.65139783915686267f, 0.7681214866470587f, 0.99589115012941176f, 1.0f}, -{0.65668286754901961f, 0.77180647676470582f, 0.99491383775294118f, 1.0f}, -{0.66196789594117644f, 0.77549146688235293f, 0.99393652537647059f, 1.0f}, -{0.66725292433333339f, 0.77917645699999993f, 0.99295921300000001f, 1.0f}, -{0.67253795272549022f, 0.78286144711764705f, 0.99198190062352942f, 1.0f}, -{0.67782298111764705f, 0.78654643723529405f, 0.99100458824705884f, 1.0f}, -{0.68305568156078433f, 0.790042626890196f, 0.98976842818431376f, 1.0f}, -{0.68818848319215686f, 0.79317837929803914f, 0.98803810435686279f, 1.0f}, -{0.69332128482352939f, 0.79631413170588228f, 0.98630778052941181f, 1.0f}, -{0.69845408645490192f, 0.79944988411372542f, 0.98457745670196084f, 1.0f}, -{0.70358688808627456f, 0.80258563652156856f, 0.98284713287450975f, 1.0f}, -{0.70871968971764709f, 0.8057213889294117f, 0.98111680904705878f, 1.0f}, -{0.71385249134901962f, 0.80885714133725484f, 0.97938648521960781f, 1.0f}, -{0.71898529298039215f, 0.81199289374509798f, 0.97765616139215683f, 1.0f}, -{0.72404137188235296f, 0.81491039264705878f, 0.97565097064705886f, 1.0f}, -{0.7289695795686274f, 0.81746413570588239f, 0.973187668372549f, 1.0f}, -{0.73389778725490185f, 0.82001787876470589f, 0.97072436609803925f, 1.0f}, -{0.7388259949411764f, 0.82257162182352939f, 0.96826106382352939f, 1.0f}, -{0.74375420262745096f, 0.82512536488235289f, 0.96579776154901964f, 1.0f}, -{0.7486824103137254f, 0.8276791079411765f, 0.96333445927450978f, 1.0f}, -{0.75361061799999995f, 0.83023285099999999f, 0.96087115700000003f, 1.0f}, -{0.75853882568627451f, 0.83278659405882349f, 0.95840785472549017f, 1.0f}, -{0.76336278010196068f, 0.83509222181960785f, 0.95565767655686273f, 1.0f}, -{0.76803436435294115f, 0.83703521952941173f, 0.95248821823529406f, 1.0f}, -{0.7727059486039215f, 0.83897821723921562f, 0.9493187599137255f, 1.0f}, -{0.77737753285490196f, 0.84092121494901961f, 0.94614930159215682f, 1.0f}, -{0.78204911710588232f, 0.8428642126588235f, 0.94297984327058826f, 1.0f}, -{0.78672070135686278f, 0.84480721036862749f, 0.93981038494901958f, 1.0f}, -{0.79139228560784314f, 0.84675020807843138f, 0.93664092662745091f, 1.0f}, -{0.7960638698588236f, 0.84869320578823526f, 0.93347146830588235f, 1.0f}, -{0.80060084729411773f, 0.85035832156078428f, 0.93000756039215682f, 1.0f}, -{0.80496475882352947f, 0.85166616055686273f, 0.92616507443137253f, 1.0f}, -{0.80932867035294109f, 0.85297399955294118f, 0.92232258847058823f, 1.0f}, -{0.81369258188235294f, 0.85428183854901962f, 0.91848010250980394f, 1.0f}, -{0.81805649341176467f, 0.85558967754509807f, 0.91463761654901965f, 1.0f}, -{0.82242040494117652f, 0.85689751654117652f, 0.91079513058823536f, 1.0f}, -{0.82678431647058825f, 0.85820535553725485f, 0.90695264462745095f, 1.0f}, -{0.83114822799999999f, 0.8595131945333333f, 0.90311015866666666f, 1.0f}, -{0.83534471135294119f, 0.86051399729411759f, 0.8989704099411765f, 1.0f}, -{0.83935144277254903f, 0.86116682565490199f, 0.89449376341568632f, 1.0f}, -{0.84335817419215675f, 0.86181965401568628f, 0.89001711689019614f, 1.0f}, -{0.8473649056117647f, 0.86247248237647056f, 0.88554047036470596f, 1.0f}, -{0.85137163703137253f, 0.86312531073725485f, 0.88106382383921578f, 1.0f}, -{0.85537836845098036f, 0.86377813909803913f, 0.87658717731372549f, 1.0f}, -{0.8593850998705882f, 0.86443096745882353f, 0.87211053078823531f, 1.0f}, -{0.86339183129019603f, 0.86508379581960781f, 0.86763388426274513f, 1.0f}, -{0.86742763508627452f, 0.86437659977254899f, 0.86260246201960789f, 1.0f}, -{0.87149251125882354f, 0.86230937931764706f, 0.85701626405882358f, 1.0f}, -{0.87555738743137257f, 0.86024215886274502f, 0.85143006609803928f, 1.0f}, -{0.87962226360392159f, 0.85817493840784309f, 0.84584386813725498f, 1.0f}, -{0.88368713977647051f, 0.85610771795294116f, 0.84025767017647079f, 1.0f}, -{0.88775201594901965f, 0.85404049749803912f, 0.83467147221568627f, 1.0f}, -{0.89181689212156867f, 0.85197327704313719f, 0.82908527425490197f, 1.0f}, -{0.8958817682941177f, 0.84990605658823526f, 0.82349907629411767f, 1.0f}, -{0.89954320660000009f, 0.84750023599999991f, 0.81778907440000004f, 1.0f}, -{0.90284867031764715f, 0.84479565058823525f, 0.81196983374117648f, 1.0f}, -{0.9061541340352941f, 0.84209106517647059f, 0.80615059308235293f, 1.0f}, -{0.90945959775294116f, 0.83938647976470582f, 0.80033135242352937f, 1.0f}, -{0.91276506147058822f, 0.83668189435294116f, 0.79451211176470582f, 1.0f}, -{0.91607052518823529f, 0.8339773089411765f, 0.78869287110588238f, 1.0f}, -{0.91937598890588235f, 0.83127272352941184f, 0.78287363044705882f, 1.0f}, -{0.92268145262352941f, 0.82856813811764707f, 0.77705438978823527f, 1.0f}, -{0.92556342300000005f, 0.82551729807058827f, 0.77113630781176468f, 1.0f}, -{0.92811600966666663f, 0.82219714886274509f, 0.76514134925490196f, 1.0f}, -{0.93066859633333332f, 0.81887699965490202f, 0.75914639069803924f, 1.0f}, -{0.93322118300000001f, 0.81555685044705883f, 0.75315143214117641f, 1.0f}, -{0.93577376966666659f, 0.81223670123921576f, 0.74715647358431392f, 1.0f}, -{0.93832635633333328f, 0.80891655203137258f, 0.74116151502745098f, 1.0f}, -{0.94087894299999997f, 0.8055964028235294f, 0.73516655647058826f, 1.0f}, -{0.94343152966666666f, 0.80227625361568622f, 0.72917159791372554f, 1.0f}, -{0.94554029890980396f, 0.79860574053333333f, 0.72310541729803923f, 1.0f}, -{0.94734540359999997f, 0.79469550479999995f, 0.71699050580000001f, 1.0f}, -{0.94915050829019609f, 0.79078526906666669f, 0.71087559430196079f, 1.0f}, -{0.95095561298039222f, 0.78687503333333331f, 0.70476068280392157f, 1.0f}, -{0.95276071767058823f, 0.78296479760000004f, 0.69864577130588235f, 1.0f}, -{0.95456582236078436f, 0.77905456186666666f, 0.69253085980784312f, 1.0f}, -{0.95637092705098037f, 0.77514432613333339f, 0.6864159483098039f, 1.0f}, -{0.95817603174117649f, 0.77123409040000002f, 0.68030103681176468f, 1.0f}, -{0.95951765847058823f, 0.7669728545098039f, 0.67414471503921569f, 1.0f}, -{0.9605811984235294f, 0.76250101852549024f, 0.66796354710196071f, 1.0f}, -{0.96164473837647058f, 0.75802918254117646f, 0.66178237916470584f, 1.0f}, -{0.96270827832941175f, 0.75355734655686279f, 0.65560121122745096f, 1.0f}, -{0.96377181828235292f, 0.74908551057254913f, 0.6494200432901962f, 1.0f}, -{0.96483535823529409f, 0.74461367458823524f, 0.64323887535294122f, 1.0f}, -{0.96589889818823527f, 0.74014183860392158f, 0.63705770741568624f, 1.0f}, -{0.96696243814117644f, 0.7356700026196078f, 0.63087653947843136f, 1.0f}, -{0.96754429763529415f, 0.73084971618823524f, 0.62468547823529408f, 1.0f}, -{0.96787384831764711f, 0.72584690809411767f, 0.61848923478431372f, 1.0f}, -{0.96820339899999996f, 0.72084409999999999f, 0.61229299133333337f, 1.0f}, -{0.96853294968235293f, 0.7158412919058823f, 0.6060967478823529f, 1.0f}, -{0.96886250036470589f, 0.71083848381176473f, 0.59990050443137255f, 1.0f}, -{0.96919205104705886f, 0.70583567571764705f, 0.59370426098039208f, 1.0f}, -{0.96952160172941171f, 0.70083286762352937f, 0.58750801752941173f, 1.0f}, -{0.96985115241176467f, 0.69583005952941168f, 0.58131177407843138f, 1.0f}, -{0.96968297966666661f, 0.69048393073725489f, 0.57513836136470586f, 1.0f}, -{0.96928856899999993f, 0.68498174708235293f, 0.56897532625882352f, 1.0f}, -{0.96889415833333337f, 0.67947956342745097f, 0.56281229115294118f, 1.0f}, -{0.96849974766666669f, 0.67397737977254901f, 0.55664925604705884f, 1.0f}, -{0.96810533700000001f, 0.66847519611764716f, 0.55048622094117661f, 1.0f}, -{0.96771092633333333f, 0.66297301246274509f, 0.54432318583529415f, 1.0f}, -{0.96731651566666665f, 0.65747082880784313f, 0.53816015072941181f, 1.0f}, -{0.96692210499999998f, 0.65196864515294117f, 0.53199711562352947f, 1.0f}, -{0.96601671983921567f, 0.64612974158823522f, 0.52589034825882353f, 1.0f}, -{0.96491138813725486f, 0.64015907805882344f, 0.51980559870588239f, 1.0f}, -{0.96380605643529405f, 0.63418841452941177f, 0.51372084915294125f, 1.0f}, -{0.96270072473333335f, 0.62821775099999999f, 0.5076360996f, 1.0f}, -{0.96159539303137254f, 0.62224708747058821f, 0.50155135004705886f, 1.0f}, -{0.96049006132941173f, 0.61627642394117643f, 0.49546660049411767f, 1.0f}, -{0.95938472962745092f, 0.61030576041176476f, 0.48938185094117648f, 1.0f}, -{0.95827939792549022f, 0.60433509688235298f, 0.48329710138823534f, 1.0f}, -{0.9566532109764706f, 0.59803382271764705f, 0.47730229235294119f, 1.0f}, -{0.95485340561176468f, 0.59162234500784316f, 0.47133746349019612f, 1.0f}, -{0.95305360024705876f, 0.58521086729803917f, 0.46537263462745099f, 1.0f}, -{0.95125379488235295f, 0.57879938958823529f, 0.45940780576470591f, 1.0f}, -{0.94945398951764715f, 0.57238791187843152f, 0.453442976901961f, 1.0f}, -{0.94765418415294111f, 0.56597643416862742f, 0.44747814803921571f, 1.0f}, -{0.94585437878823531f, 0.55956495645882354f, 0.44151331917647063f, 1.0f}, -{0.94405457342352939f, 0.55315347874901966f, 0.4355484903137255f, 1.0f}, -{0.94172792982352937f, 0.54641347701960785f, 0.42970707037254902f, 1.0f}, -{0.93925377151764711f, 0.53958148856470589f, 0.42390020492941177f, 1.0f}, -{0.93677961321176473f, 0.53274950010980393f, 0.41809333948627453f, 1.0f}, -{0.93430545490588235f, 0.52591751165490197f, 0.41228647404313729f, 1.0f}, -{0.93183129659999997f, 0.51908552320000001f, 0.40647960859999999f, 1.0f}, -{0.9293571382941177f, 0.51225353474509805f, 0.40067274315686274f, 1.0f}, -{0.92688297998823532f, 0.50542154629019609f, 0.3948658777137255f, 1.0f}, -{0.92440882168235294f, 0.49858955783529413f, 0.38905901227058826f, 1.0f}, -{0.92140622122745097f, 0.49142041718431373f, 0.38340843537647057f, 1.0f}, -{0.9182816725843137f, 0.48417347218039214f, 0.37779392507058823f, 1.0f}, -{0.91515712394117643f, 0.4769265271764706f, 0.3721794147647059f, 1.0f}, -{0.91203257529803927f, 0.46967958217254901f, 0.36656490445882356f, 1.0f}, -{0.908908026654902f, 0.46243263716862765f, 0.36095039415294133f, 1.0f}, -{0.90578347801176473f, 0.45518569216470589f, 0.35533588384705883f, 1.0f}, -{0.90265892936862746f, 0.4479387471607843f, 0.34972137354117649f, 1.0f}, -{0.89953438072549019f, 0.44069180215686271f, 0.34410686323529416f, 1.0f}, -{0.89588459483529415f, 0.43307455670588235f, 0.33868063451764707f, 1.0f}, -{0.89213754278823532f, 0.4253887370980392f, 0.33328927276078435f, 1.0f}, -{0.88839049074117649f, 0.41770291749019606f, 0.32789791100392157f, 1.0f}, -{0.88464343869411766f, 0.41001709788235297f, 0.32250654924705885f, 1.0f}, -{0.88089638664705883f, 0.40233127827450982f, 0.31711518749019613f, 1.0f}, -{0.8771493346f, 0.39464545866666667f, 0.31172382573333335f, 1.0f}, -{0.87340228255294117f, 0.38695963905882352f, 0.30633246397647063f, 1.0f}, -{0.86965523050588234f, 0.37927381945098043f, 0.30094110221960785f, 1.0f}, -{0.8653913329372549f, 0.37112767204705882f, 0.29576895641568629f, 1.0f}, -{0.86105360029411759f, 0.36291576352941179f, 0.29062812717647057f, 1.0f}, -{0.8567158676509804f, 0.35470385501176471f, 0.28548729793725491f, 1.0f}, -{0.8523781350078431f, 0.34649194649411763f, 0.2803464686980392f, 1.0f}, -{0.84804040236470601f, 0.33828003797647083f, 0.2752056394588237f, 1.0f}, -{0.8437026697215686f, 0.33006812945882352f, 0.27006481021960782f, 1.0f}, -{0.83936493707843141f, 0.32185622094117644f, 0.26492398098039216f, 1.0f}, -{0.8350272044352941f, 0.31364431242352941f, 0.25978315174117644f, 1.0f}, -{0.83018652194901965f, 0.30473276355294115f, 0.25489142806666665f, 1.0f}, -{0.82529381016862746f, 0.29574883809411762f, 0.2500254739333333f, 1.0f}, -{0.82040109838823527f, 0.28676491263529408f, 0.2451595198f, 1.0f}, -{0.81550838660784319f, 0.2777809871764706f, 0.24029356566666665f, 1.0f}, -{0.810615674827451f, 0.26879706171764706f, 0.23542761153333333f, 1.0f}, -{0.80572296304705882f, 0.25981313625882352f, 0.23056165740000001f, 1.0f}, -{0.80083025126666663f, 0.25082921079999998f, 0.22569570326666666f, 1.0f}, -{0.79593753948627455f, 0.24184528534117647f, 0.22082974913333334f, 1.0f}, -{0.79056153194117651f, 0.23139699905882352f, 0.21624203829411764f, 1.0f}, -{0.78515330467843136f, 0.22085108872156861f, 0.21167287700784312f, 1.0f}, -{0.77974507741568633f, 0.21030517838431373f, 0.20710371572156863f, 1.0f}, -{0.77433685015294118f, 0.19975926804705882f, 0.20253455443529411f, 1.0f}, -{0.76892862289019626f, 0.18921335770980421f, 0.19796539314901973f, 1.0f}, -{0.763520395627451f, 0.17866744737254903f, 0.1933962318627451f, 1.0f}, -{0.75811216836470596f, 0.16812153703529409f, 0.18882707057647058f, 1.0f}, -{0.75270394110196082f, 0.15757562669803921f, 0.18425790929019609f, 1.0f}, -{0.74683801221176471f, 0.14002101948235293f, 0.17999609695686275f, 1.0f}, -{0.74095731875294124f, 0.12224032527058823f, 0.17574419910588235f, 1.0f}, -{0.73507662529411766f, 0.10445963105882351f, 0.17149230125490195f, 1.0f}, -{0.72919593183529408f, 0.08667893684705881f, 0.16724040340392157f, 1.0f}, -{0.7233152383764706f, 0.068898242635294107f, 0.16298850555294117f, 1.0f}, -{0.71743454491764702f, 0.051117548423529391f, 0.15873660770196077f, 1.0f}, -{0.71155385145882355f, 0.033336854211764688f, 0.1544847098509804f, 1.0f}, -{0.70567315799999997f, 0.015556159999999999f, 0.15023281199999999f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/diverging/coolwarm.txt b/extern/tfn/colormaps/diverging/coolwarm.txt deleted file mode 100644 index 22ea469..0000000 --- a/extern/tfn/colormaps/diverging/coolwarm.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.2298057, 0.298717966, 0.75368315299999999, 1.0) -(0.23437707945098038, 0.30554173032941179, 0.75967952758823531, 1.0) -(0.23894845890196079, 0.31236549465882352, 0.76567590217647052, 1.0) -(0.24351983835294116, 0.3191892589882353, 0.77167227676470584, 1.0) -(0.24809121780392157, 0.32601302331764709, 0.77766865135294116, 1.0) -(0.25266259725490192, 0.33283678764705882, 0.78366502594117649, 1.0) -(0.25723397670588233, 0.3396605519764706, 0.78966140052941169, 1.0) -(0.26180535615686273, 0.34648431630588239, 0.79565777511764701, 1.0) -(0.26638146835294113, 0.35330440842352945, 0.80163731949803918, 1.0) -(0.27110429564705879, 0.36001066197647058, 0.8070951274352941, 1.0) -(0.27582712294117645, 0.36671691552941177, 0.81255293537254902, 1.0) -(0.28054995023529411, 0.37342316908235296, 0.81801074330980394, 1.0) -(0.28527277752941177, 0.38012942263529415, 0.82346855124705887, 1.0) -(0.28999560482352937, 0.38683567618823528, 0.82892635918431368, 1.0) -(0.29471843211764703, 0.39354192974117647, 0.8343841671215686, 1.0) -(0.29944125941176469, 0.40024818329411765, 0.83984197505882352, 1.0) -(0.30417428700392157, 0.40694488283921565, 0.84526272669803926, 1.0) -(0.30906031906666664, 0.41349827226666663, 0.85012763386666668, 1.0) -(0.31394635112941177, 0.42005166169411762, 0.8549925410352941, 1.0) -(0.31883238319215684, 0.4266050511215686, 0.85985744820392163, 1.0) -(0.32371841525490197, 0.43315844054901959, 0.86472235537254905, 1.0) -(0.32860444731764704, 0.43971182997647057, 0.86958726254117646, 1.0) -(0.33349047938039217, 0.44626521940392155, 0.87445216970980388, 1.0) -(0.3383765114431373, 0.45281860883137254, 0.8793170768784313, 1.0) -(0.34327752343529416, 0.45935363472941176, 0.88412192162352943, 1.0) -(0.34832334141176474, 0.46571114650980389, 0.88834616294117641, 1.0) -(0.35336915938823532, 0.47206865829019606, 0.8925704042588235, 1.0) -(0.3584149773647059, 0.47842617007058824, 0.89679464557647059, 1.0) -(0.36346079534117648, 0.48478368185098042, 0.90101888689411769, 1.0) -(0.36850661331764706, 0.49114119363137254, 0.90524312821176467, 1.0) -(0.37355243129411764, 0.49749870541176472, 0.90946736952941176, 1.0) -(0.37859824927058822, 0.5038562171921569, 0.91369161084705885, 1.0) -(0.38366206577254902, 0.51018341728627459, 0.91783067323137257, 1.0) -(0.38885187195294113, 0.51629843557647059, 0.9213734830823529, 1.0) -(0.3940416781333333, 0.52241345386666671, 0.92491629293333333, 1.0) -(0.39923148431372546, 0.52852847215686283, 0.92845910278431376, 1.0) -(0.40442129049411762, 0.53464349044705883, 0.93200191263529408, 1.0) -(0.40961109667450979, 0.54075850873725495, 0.93554472248627452, 1.0) -(0.41480090285490195, 0.54687352702745107, 0.93908753233725495, 1.0) -(0.41999070903529412, 0.55298854531764707, 0.94263034218823527, 1.0) -(0.42519897019607844, 0.55905817976470595, 0.94606145707843137, 1.0) -(0.43050688825098038, 0.56488274145882356, 0.94888941918039216, 1.0) -(0.43581480630588237, 0.57070730315294116, 0.95171738128235295, 1.0) -(0.44112272436078431, 0.57653186484705887, 0.95454534338431374, 1.0) -(0.44643064241568631, 0.58235642654117648, 0.95737330548627453, 1.0) -(0.45173856047058819, 0.58818098823529408, 0.96020126758823521, 1.0) -(0.45704647852549019, 0.59400554992941179, 0.963029229690196, 1.0) -(0.46235439658039218, 0.59983011162352939, 0.96585719179215679, 1.0) -(0.46767809468235294, 0.60559123162352935, 0.96854628109411756, 1.0) -(0.47307017298823528, 0.61107743761568623, 0.97063358826274504, 1.0) -(0.47846225129411762, 0.6165636436078431, 0.97272089543137252, 1.0) -(0.48385432959999997, 0.62204984959999998, 0.97480820260000001, 1.0) -(0.48924640790588236, 0.62753605559215686, 0.97689550976862749, 1.0) -(0.49463848621176465, 0.63302226158431363, 0.97898281693725486, 1.0) -(0.50003056451764705, 0.63850846757647062, 0.98107012410588235, 1.0) -(0.50542264282352933, 0.6439946735686275, 0.98315743127450983, 1.0) -(0.51082432425098034, 0.64939661482352939, 0.98507877637647068, 1.0) -(0.51626030254117639, 0.6544976105882353, 0.98640739981176473, 1.0) -(0.52169628083137254, 0.65959860635294121, 0.98773602324705889, 1.0) -(0.52713225912156858, 0.664699602117647, 0.98906464668235294, 1.0) -(0.53256823741176462, 0.66980059788235291, 0.99039327011764711, 1.0) -(0.53800421570196066, 0.67490159364705871, 0.99172189355294116, 1.0) -(0.54344019399215682, 0.68000258941176472, 0.99305051698823532, 1.0) -(0.54887617228235286, 0.68510358517647052, 0.99437914042352948, 1.0) -(0.55431186991372539, 0.69009701121568623, 0.99551554823529409, 1.0) -(0.55974672556862737, 0.69476772807843135, 0.99607530917647058, 1.0) -(0.56518158122352935, 0.69943844494117635, 0.99663507011764707, 1.0) -(0.57061643687843133, 0.70410916180392158, 0.99719483105882356, 1.0) -(0.57605129253333331, 0.7087798786666667, 0.99775459200000005, 1.0) -(0.5814861481882353, 0.7134505955294117, 0.99831435294117643, 1.0) -(0.58692100384313728, 0.71812131239215682, 0.99887411388235292, 1.0) -(0.59235585949803926, 0.72279202925490194, 0.99943387482352941, 1.0) -(0.59777677549411767, 0.72732972488235292, 0.99977673177647053, 1.0) -(0.60316206791764704, 0.73152747735294121, 0.99956527853725485, 1.0) -(0.6085473603411764, 0.73572522982352939, 0.99935382529803918, 1.0) -(0.61393265276470588, 0.73992298229411768, 0.9991423720588235, 1.0) -(0.61931794518823535, 0.74412073476470586, 0.99893091881960783, 1.0) -(0.62470323761176472, 0.74831848723529415, 0.99871946558039215, 1.0) -(0.63008853003529408, 0.75251623970588233, 0.99850801234117648, 1.0) -(0.63547382245882356, 0.75671399217647062, 0.9982965591019608, 1.0) -(0.640827782372549, 0.7607515064117647, 0.99784577488235293, 1.0) -(0.64611281076470584, 0.7644364965294117, 0.99686846250588235, 1.0) -(0.65139783915686267, 0.7681214866470587, 0.99589115012941176, 1.0) -(0.65668286754901961, 0.77180647676470582, 0.99491383775294118, 1.0) -(0.66196789594117644, 0.77549146688235293, 0.99393652537647059, 1.0) -(0.66725292433333339, 0.77917645699999993, 0.99295921300000001, 1.0) -(0.67253795272549022, 0.78286144711764705, 0.99198190062352942, 1.0) -(0.67782298111764705, 0.78654643723529405, 0.99100458824705884, 1.0) -(0.68305568156078433, 0.790042626890196, 0.98976842818431376, 1.0) -(0.68818848319215686, 0.79317837929803914, 0.98803810435686279, 1.0) -(0.69332128482352939, 0.79631413170588228, 0.98630778052941181, 1.0) -(0.69845408645490192, 0.79944988411372542, 0.98457745670196084, 1.0) -(0.70358688808627456, 0.80258563652156856, 0.98284713287450975, 1.0) -(0.70871968971764709, 0.8057213889294117, 0.98111680904705878, 1.0) -(0.71385249134901962, 0.80885714133725484, 0.97938648521960781, 1.0) -(0.71898529298039215, 0.81199289374509798, 0.97765616139215683, 1.0) -(0.72404137188235296, 0.81491039264705878, 0.97565097064705886, 1.0) -(0.7289695795686274, 0.81746413570588239, 0.973187668372549, 1.0) -(0.73389778725490185, 0.82001787876470589, 0.97072436609803925, 1.0) -(0.7388259949411764, 0.82257162182352939, 0.96826106382352939, 1.0) -(0.74375420262745096, 0.82512536488235289, 0.96579776154901964, 1.0) -(0.7486824103137254, 0.8276791079411765, 0.96333445927450978, 1.0) -(0.75361061799999995, 0.83023285099999999, 0.96087115700000003, 1.0) -(0.75853882568627451, 0.83278659405882349, 0.95840785472549017, 1.0) -(0.76336278010196068, 0.83509222181960785, 0.95565767655686273, 1.0) -(0.76803436435294115, 0.83703521952941173, 0.95248821823529406, 1.0) -(0.7727059486039215, 0.83897821723921562, 0.9493187599137255, 1.0) -(0.77737753285490196, 0.84092121494901961, 0.94614930159215682, 1.0) -(0.78204911710588232, 0.8428642126588235, 0.94297984327058826, 1.0) -(0.78672070135686278, 0.84480721036862749, 0.93981038494901958, 1.0) -(0.79139228560784314, 0.84675020807843138, 0.93664092662745091, 1.0) -(0.7960638698588236, 0.84869320578823526, 0.93347146830588235, 1.0) -(0.80060084729411773, 0.85035832156078428, 0.93000756039215682, 1.0) -(0.80496475882352947, 0.85166616055686273, 0.92616507443137253, 1.0) -(0.80932867035294109, 0.85297399955294118, 0.92232258847058823, 1.0) -(0.81369258188235294, 0.85428183854901962, 0.91848010250980394, 1.0) -(0.81805649341176467, 0.85558967754509807, 0.91463761654901965, 1.0) -(0.82242040494117652, 0.85689751654117652, 0.91079513058823536, 1.0) -(0.82678431647058825, 0.85820535553725485, 0.90695264462745095, 1.0) -(0.83114822799999999, 0.8595131945333333, 0.90311015866666666, 1.0) -(0.83534471135294119, 0.86051399729411759, 0.8989704099411765, 1.0) -(0.83935144277254903, 0.86116682565490199, 0.89449376341568632, 1.0) -(0.84335817419215675, 0.86181965401568628, 0.89001711689019614, 1.0) -(0.8473649056117647, 0.86247248237647056, 0.88554047036470596, 1.0) -(0.85137163703137253, 0.86312531073725485, 0.88106382383921578, 1.0) -(0.85537836845098036, 0.86377813909803913, 0.87658717731372549, 1.0) -(0.8593850998705882, 0.86443096745882353, 0.87211053078823531, 1.0) -(0.86339183129019603, 0.86508379581960781, 0.86763388426274513, 1.0) -(0.86742763508627452, 0.86437659977254899, 0.86260246201960789, 1.0) -(0.87149251125882354, 0.86230937931764706, 0.85701626405882358, 1.0) -(0.87555738743137257, 0.86024215886274502, 0.85143006609803928, 1.0) -(0.87962226360392159, 0.85817493840784309, 0.84584386813725498, 1.0) -(0.88368713977647051, 0.85610771795294116, 0.84025767017647079, 1.0) -(0.88775201594901965, 0.85404049749803912, 0.83467147221568627, 1.0) -(0.89181689212156867, 0.85197327704313719, 0.82908527425490197, 1.0) -(0.8958817682941177, 0.84990605658823526, 0.82349907629411767, 1.0) -(0.89954320660000009, 0.84750023599999991, 0.81778907440000004, 1.0) -(0.90284867031764715, 0.84479565058823525, 0.81196983374117648, 1.0) -(0.9061541340352941, 0.84209106517647059, 0.80615059308235293, 1.0) -(0.90945959775294116, 0.83938647976470582, 0.80033135242352937, 1.0) -(0.91276506147058822, 0.83668189435294116, 0.79451211176470582, 1.0) -(0.91607052518823529, 0.8339773089411765, 0.78869287110588238, 1.0) -(0.91937598890588235, 0.83127272352941184, 0.78287363044705882, 1.0) -(0.92268145262352941, 0.82856813811764707, 0.77705438978823527, 1.0) -(0.92556342300000005, 0.82551729807058827, 0.77113630781176468, 1.0) -(0.92811600966666663, 0.82219714886274509, 0.76514134925490196, 1.0) -(0.93066859633333332, 0.81887699965490202, 0.75914639069803924, 1.0) -(0.93322118300000001, 0.81555685044705883, 0.75315143214117641, 1.0) -(0.93577376966666659, 0.81223670123921576, 0.74715647358431392, 1.0) -(0.93832635633333328, 0.80891655203137258, 0.74116151502745098, 1.0) -(0.94087894299999997, 0.8055964028235294, 0.73516655647058826, 1.0) -(0.94343152966666666, 0.80227625361568622, 0.72917159791372554, 1.0) -(0.94554029890980396, 0.79860574053333333, 0.72310541729803923, 1.0) -(0.94734540359999997, 0.79469550479999995, 0.71699050580000001, 1.0) -(0.94915050829019609, 0.79078526906666669, 0.71087559430196079, 1.0) -(0.95095561298039222, 0.78687503333333331, 0.70476068280392157, 1.0) -(0.95276071767058823, 0.78296479760000004, 0.69864577130588235, 1.0) -(0.95456582236078436, 0.77905456186666666, 0.69253085980784312, 1.0) -(0.95637092705098037, 0.77514432613333339, 0.6864159483098039, 1.0) -(0.95817603174117649, 0.77123409040000002, 0.68030103681176468, 1.0) -(0.95951765847058823, 0.7669728545098039, 0.67414471503921569, 1.0) -(0.9605811984235294, 0.76250101852549024, 0.66796354710196071, 1.0) -(0.96164473837647058, 0.75802918254117646, 0.66178237916470584, 1.0) -(0.96270827832941175, 0.75355734655686279, 0.65560121122745096, 1.0) -(0.96377181828235292, 0.74908551057254913, 0.6494200432901962, 1.0) -(0.96483535823529409, 0.74461367458823524, 0.64323887535294122, 1.0) -(0.96589889818823527, 0.74014183860392158, 0.63705770741568624, 1.0) -(0.96696243814117644, 0.7356700026196078, 0.63087653947843136, 1.0) -(0.96754429763529415, 0.73084971618823524, 0.62468547823529408, 1.0) -(0.96787384831764711, 0.72584690809411767, 0.61848923478431372, 1.0) -(0.96820339899999996, 0.72084409999999999, 0.61229299133333337, 1.0) -(0.96853294968235293, 0.7158412919058823, 0.6060967478823529, 1.0) -(0.96886250036470589, 0.71083848381176473, 0.59990050443137255, 1.0) -(0.96919205104705886, 0.70583567571764705, 0.59370426098039208, 1.0) -(0.96952160172941171, 0.70083286762352937, 0.58750801752941173, 1.0) -(0.96985115241176467, 0.69583005952941168, 0.58131177407843138, 1.0) -(0.96968297966666661, 0.69048393073725489, 0.57513836136470586, 1.0) -(0.96928856899999993, 0.68498174708235293, 0.56897532625882352, 1.0) -(0.96889415833333337, 0.67947956342745097, 0.56281229115294118, 1.0) -(0.96849974766666669, 0.67397737977254901, 0.55664925604705884, 1.0) -(0.96810533700000001, 0.66847519611764716, 0.55048622094117661, 1.0) -(0.96771092633333333, 0.66297301246274509, 0.54432318583529415, 1.0) -(0.96731651566666665, 0.65747082880784313, 0.53816015072941181, 1.0) -(0.96692210499999998, 0.65196864515294117, 0.53199711562352947, 1.0) -(0.96601671983921567, 0.64612974158823522, 0.52589034825882353, 1.0) -(0.96491138813725486, 0.64015907805882344, 0.51980559870588239, 1.0) -(0.96380605643529405, 0.63418841452941177, 0.51372084915294125, 1.0) -(0.96270072473333335, 0.62821775099999999, 0.5076360996, 1.0) -(0.96159539303137254, 0.62224708747058821, 0.50155135004705886, 1.0) -(0.96049006132941173, 0.61627642394117643, 0.49546660049411767, 1.0) -(0.95938472962745092, 0.61030576041176476, 0.48938185094117648, 1.0) -(0.95827939792549022, 0.60433509688235298, 0.48329710138823534, 1.0) -(0.9566532109764706, 0.59803382271764705, 0.47730229235294119, 1.0) -(0.95485340561176468, 0.59162234500784316, 0.47133746349019612, 1.0) -(0.95305360024705876, 0.58521086729803917, 0.46537263462745099, 1.0) -(0.95125379488235295, 0.57879938958823529, 0.45940780576470591, 1.0) -(0.94945398951764715, 0.57238791187843152, 0.453442976901961, 1.0) -(0.94765418415294111, 0.56597643416862742, 0.44747814803921571, 1.0) -(0.94585437878823531, 0.55956495645882354, 0.44151331917647063, 1.0) -(0.94405457342352939, 0.55315347874901966, 0.4355484903137255, 1.0) -(0.94172792982352937, 0.54641347701960785, 0.42970707037254902, 1.0) -(0.93925377151764711, 0.53958148856470589, 0.42390020492941177, 1.0) -(0.93677961321176473, 0.53274950010980393, 0.41809333948627453, 1.0) -(0.93430545490588235, 0.52591751165490197, 0.41228647404313729, 1.0) -(0.93183129659999997, 0.51908552320000001, 0.40647960859999999, 1.0) -(0.9293571382941177, 0.51225353474509805, 0.40067274315686274, 1.0) -(0.92688297998823532, 0.50542154629019609, 0.3948658777137255, 1.0) -(0.92440882168235294, 0.49858955783529413, 0.38905901227058826, 1.0) -(0.92140622122745097, 0.49142041718431373, 0.38340843537647057, 1.0) -(0.9182816725843137, 0.48417347218039214, 0.37779392507058823, 1.0) -(0.91515712394117643, 0.4769265271764706, 0.3721794147647059, 1.0) -(0.91203257529803927, 0.46967958217254901, 0.36656490445882356, 1.0) -(0.908908026654902, 0.46243263716862765, 0.36095039415294133, 1.0) -(0.90578347801176473, 0.45518569216470589, 0.35533588384705883, 1.0) -(0.90265892936862746, 0.4479387471607843, 0.34972137354117649, 1.0) -(0.89953438072549019, 0.44069180215686271, 0.34410686323529416, 1.0) -(0.89588459483529415, 0.43307455670588235, 0.33868063451764707, 1.0) -(0.89213754278823532, 0.4253887370980392, 0.33328927276078435, 1.0) -(0.88839049074117649, 0.41770291749019606, 0.32789791100392157, 1.0) -(0.88464343869411766, 0.41001709788235297, 0.32250654924705885, 1.0) -(0.88089638664705883, 0.40233127827450982, 0.31711518749019613, 1.0) -(0.8771493346, 0.39464545866666667, 0.31172382573333335, 1.0) -(0.87340228255294117, 0.38695963905882352, 0.30633246397647063, 1.0) -(0.86965523050588234, 0.37927381945098043, 0.30094110221960785, 1.0) -(0.8653913329372549, 0.37112767204705882, 0.29576895641568629, 1.0) -(0.86105360029411759, 0.36291576352941179, 0.29062812717647057, 1.0) -(0.8567158676509804, 0.35470385501176471, 0.28548729793725491, 1.0) -(0.8523781350078431, 0.34649194649411763, 0.2803464686980392, 1.0) -(0.84804040236470601, 0.33828003797647083, 0.2752056394588237, 1.0) -(0.8437026697215686, 0.33006812945882352, 0.27006481021960782, 1.0) -(0.83936493707843141, 0.32185622094117644, 0.26492398098039216, 1.0) -(0.8350272044352941, 0.31364431242352941, 0.25978315174117644, 1.0) -(0.83018652194901965, 0.30473276355294115, 0.25489142806666665, 1.0) -(0.82529381016862746, 0.29574883809411762, 0.2500254739333333, 1.0) -(0.82040109838823527, 0.28676491263529408, 0.2451595198, 1.0) -(0.81550838660784319, 0.2777809871764706, 0.24029356566666665, 1.0) -(0.810615674827451, 0.26879706171764706, 0.23542761153333333, 1.0) -(0.80572296304705882, 0.25981313625882352, 0.23056165740000001, 1.0) -(0.80083025126666663, 0.25082921079999998, 0.22569570326666666, 1.0) -(0.79593753948627455, 0.24184528534117647, 0.22082974913333334, 1.0) -(0.79056153194117651, 0.23139699905882352, 0.21624203829411764, 1.0) -(0.78515330467843136, 0.22085108872156861, 0.21167287700784312, 1.0) -(0.77974507741568633, 0.21030517838431373, 0.20710371572156863, 1.0) -(0.77433685015294118, 0.19975926804705882, 0.20253455443529411, 1.0) -(0.76892862289019626, 0.18921335770980421, 0.19796539314901973, 1.0) -(0.763520395627451, 0.17866744737254903, 0.1933962318627451, 1.0) -(0.75811216836470596, 0.16812153703529409, 0.18882707057647058, 1.0) -(0.75270394110196082, 0.15757562669803921, 0.18425790929019609, 1.0) -(0.74683801221176471, 0.14002101948235293, 0.17999609695686275, 1.0) -(0.74095731875294124, 0.12224032527058823, 0.17574419910588235, 1.0) -(0.73507662529411766, 0.10445963105882351, 0.17149230125490195, 1.0) -(0.72919593183529408, 0.08667893684705881, 0.16724040340392157, 1.0) -(0.7233152383764706, 0.068898242635294107, 0.16298850555294117, 1.0) -(0.71743454491764702, 0.051117548423529391, 0.15873660770196077, 1.0) -(0.71155385145882355, 0.033336854211764688, 0.1544847098509804, 1.0) -(0.70567315799999997, 0.015556159999999999, 0.15023281199999999, 1.0) diff --git a/extern/tfn/colormaps/diverging/seismic.cpp b/extern/tfn/colormaps/diverging/seismic.cpp deleted file mode 100644 index 52e110d..0000000 --- a/extern/tfn/colormaps/diverging/seismic.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_diverging_seismic; -} -const std::vector colormap::data_diverging_seismic = /* NOLINT(cert-err58-cpp) */ -{ -{0.0f, 0.0f, 0.29999999999999999f, 1.0f}, -{0.0f, 0.0f, 0.31098039215686274f, 1.0f}, -{0.0f, 0.0f, 0.32196078431372549f, 1.0f}, -{0.0f, 0.0f, 0.33294117647058824f, 1.0f}, -{0.0f, 0.0f, 0.34392156862745094f, 1.0f}, -{0.0f, 0.0f, 0.35490196078431369f, 1.0f}, -{0.0f, 0.0f, 0.36588235294117644f, 1.0f}, -{0.0f, 0.0f, 0.37686274509803919f, 1.0f}, -{0.0f, 0.0f, 0.38784313725490194f, 1.0f}, -{0.0f, 0.0f, 0.39882352941176469f, 1.0f}, -{0.0f, 0.0f, 0.40980392156862744f, 1.0f}, -{0.0f, 0.0f, 0.42078431372549019f, 1.0f}, -{0.0f, 0.0f, 0.43176470588235294f, 1.0f}, -{0.0f, 0.0f, 0.44274509803921569f, 1.0f}, -{0.0f, 0.0f, 0.45372549019607844f, 1.0f}, -{0.0f, 0.0f, 0.46470588235294119f, 1.0f}, -{0.0f, 0.0f, 0.47568627450980389f, 1.0f}, -{0.0f, 0.0f, 0.48666666666666664f, 1.0f}, -{0.0f, 0.0f, 0.49764705882352939f, 1.0f}, -{0.0f, 0.0f, 0.50862745098039208f, 1.0f}, -{0.0f, 0.0f, 0.51960784313725483f, 1.0f}, -{0.0f, 0.0f, 0.53058823529411758f, 1.0f}, -{0.0f, 0.0f, 0.54156862745098033f, 1.0f}, -{0.0f, 0.0f, 0.55254901960784308f, 1.0f}, -{0.0f, 0.0f, 0.56352941176470583f, 1.0f}, -{0.0f, 0.0f, 0.57450980392156858f, 1.0f}, -{0.0f, 0.0f, 0.58549019607843134f, 1.0f}, -{0.0f, 0.0f, 0.59647058823529409f, 1.0f}, -{0.0f, 0.0f, 0.60745098039215684f, 1.0f}, -{0.0f, 0.0f, 0.61843137254901959f, 1.0f}, -{0.0f, 0.0f, 0.62941176470588234f, 1.0f}, -{0.0f, 0.0f, 0.64039215686274509f, 1.0f}, -{0.0f, 0.0f, 0.65137254901960784f, 1.0f}, -{0.0f, 0.0f, 0.66235294117647059f, 1.0f}, -{0.0f, 0.0f, 0.67333333333333334f, 1.0f}, -{0.0f, 0.0f, 0.68431372549019609f, 1.0f}, -{0.0f, 0.0f, 0.69529411764705884f, 1.0f}, -{0.0f, 0.0f, 0.70627450980392148f, 1.0f}, -{0.0f, 0.0f, 0.71725490196078434f, 1.0f}, -{0.0f, 0.0f, 0.72823529411764709f, 1.0f}, -{0.0f, 0.0f, 0.73921568627450973f, 1.0f}, -{0.0f, 0.0f, 0.75019607843137248f, 1.0f}, -{0.0f, 0.0f, 0.76117647058823523f, 1.0f}, -{0.0f, 0.0f, 0.77215686274509809f, 1.0f}, -{0.0f, 0.0f, 0.78313725490196073f, 1.0f}, -{0.0f, 0.0f, 0.79411764705882337f, 1.0f}, -{0.0f, 0.0f, 0.80509803921568612f, 1.0f}, -{0.0f, 0.0f, 0.8160784313725491f, 1.0f}, -{0.0f, 0.0f, 0.82705882352941162f, 1.0f}, -{0.0f, 0.0f, 0.83803921568627437f, 1.0f}, -{0.0f, 0.0f, 0.84901960784313713f, 1.0f}, -{0.0f, 0.0f, 0.85999999999999988f, 1.0f}, -{0.0f, 0.0f, 0.87098039215686263f, 1.0f}, -{0.0f, 0.0f, 0.88196078431372538f, 1.0f}, -{0.0f, 0.0f, 0.89294117647058813f, 1.0f}, -{0.0f, 0.0f, 0.90392156862745088f, 1.0f}, -{0.0f, 0.0f, 0.91490196078431363f, 1.0f}, -{0.0f, 0.0f, 0.92588235294117638f, 1.0f}, -{0.0f, 0.0f, 0.93686274509803913f, 1.0f}, -{0.0f, 0.0f, 0.94784313725490188f, 1.0f}, -{0.0f, 0.0f, 0.95882352941176463f, 1.0f}, -{0.0f, 0.0f, 0.96980392156862738f, 1.0f}, -{0.0f, 0.0f, 0.98078431372549013f, 1.0f}, -{0.0f, 0.0f, 0.99176470588235288f, 1.0f}, -{0.0039215686274509803f, 0.0039215686274509803f, 1.0f, 1.0f}, -{0.019607843137254902f, 0.019607843137254902f, 1.0f, 1.0f}, -{0.035294117647058601f, 0.035294117647058601f, 1.0f, 1.0f}, -{0.050980392156862744f, 0.050980392156862744f, 1.0f, 1.0f}, -{0.066666666666666666f, 0.066666666666666666f, 1.0f, 1.0f}, -{0.082352941176470587f, 0.082352941176470587f, 1.0f, 1.0f}, -{0.098039215686274508f, 0.098039215686274508f, 1.0f, 1.0f}, -{0.11372549019607843f, 0.11372549019607843f, 1.0f, 1.0f}, -{0.12941176470588237f, 0.12941176470588237f, 1.0f, 1.0f}, -{0.14509803921568629f, 0.14509803921568629f, 1.0f, 1.0f}, -{0.16078431372548999f, 0.16078431372548999f, 1.0f, 1.0f}, -{0.17647058823529413f, 0.17647058823529413f, 1.0f, 1.0f}, -{0.19215686274509805f, 0.19215686274509805f, 1.0f, 1.0f}, -{0.20784313725490197f, 0.20784313725490197f, 1.0f, 1.0f}, -{0.22352941176470589f, 0.22352941176470589f, 1.0f, 1.0f}, -{0.23921568627450981f, 0.23921568627450981f, 1.0f, 1.0f}, -{0.25490196078431371f, 0.25490196078431371f, 1.0f, 1.0f}, -{0.27058823529411763f, 0.27058823529411763f, 1.0f, 1.0f}, -{0.28627450980392133f, 0.28627450980392133f, 1.0f, 1.0f}, -{0.30196078431372547f, 0.30196078431372547f, 1.0f, 1.0f}, -{0.31764705882352939f, 0.31764705882352939f, 1.0f, 1.0f}, -{0.33333333333333331f, 0.33333333333333331f, 1.0f, 1.0f}, -{0.34901960784313724f, 0.34901960784313724f, 1.0f, 1.0f}, -{0.36470588235294116f, 0.36470588235294116f, 1.0f, 1.0f}, -{0.38039215686274508f, 0.38039215686274508f, 1.0f, 1.0f}, -{0.396078431372549f, 0.396078431372549f, 1.0f, 1.0f}, -{0.4117647058823527f, 0.4117647058823527f, 1.0f, 1.0f}, -{0.42745098039215684f, 0.42745098039215684f, 1.0f, 1.0f}, -{0.44313725490196076f, 0.44313725490196076f, 1.0f, 1.0f}, -{0.45882352941176469f, 0.45882352941176469f, 1.0f, 1.0f}, -{0.47450980392156861f, 0.47450980392156861f, 1.0f, 1.0f}, -{0.49019607843137253f, 0.49019607843137253f, 1.0f, 1.0f}, -{0.50588235294117645f, 0.50588235294117645f, 1.0f, 1.0f}, -{0.52156862745098043f, 0.52156862745098043f, 1.0f, 1.0f}, -{0.53725490196078407f, 0.53725490196078407f, 1.0f, 1.0f}, -{0.55294117647058827f, 0.55294117647058827f, 1.0f, 1.0f}, -{0.56862745098039214f, 0.56862745098039214f, 1.0f, 1.0f}, -{0.58431372549019611f, 0.58431372549019611f, 1.0f, 1.0f}, -{0.59999999999999998f, 0.59999999999999998f, 1.0f, 1.0f}, -{0.61568627450980395f, 0.61568627450980395f, 1.0f, 1.0f}, -{0.63137254901960782f, 0.63137254901960782f, 1.0f, 1.0f}, -{0.6470588235294118f, 0.6470588235294118f, 1.0f, 1.0f}, -{0.66274509803921544f, 0.66274509803921544f, 1.0f, 1.0f}, -{0.67843137254901964f, 0.67843137254901964f, 1.0f, 1.0f}, -{0.69411764705882351f, 0.69411764705882351f, 1.0f, 1.0f}, -{0.70980392156862748f, 0.70980392156862748f, 1.0f, 1.0f}, -{0.72549019607843135f, 0.72549019607843135f, 1.0f, 1.0f}, -{0.74117647058823533f, 0.74117647058823533f, 1.0f, 1.0f}, -{0.75686274509803919f, 0.75686274509803919f, 1.0f, 1.0f}, -{0.77254901960784317f, 0.77254901960784317f, 1.0f, 1.0f}, -{0.78823529411764681f, 0.78823529411764681f, 1.0f, 1.0f}, -{0.80392156862745101f, 0.80392156862745101f, 1.0f, 1.0f}, -{0.81960784313725488f, 0.81960784313725488f, 1.0f, 1.0f}, -{0.83529411764705885f, 0.83529411764705885f, 1.0f, 1.0f}, -{0.85098039215686272f, 0.85098039215686272f, 1.0f, 1.0f}, -{0.8666666666666667f, 0.8666666666666667f, 1.0f, 1.0f}, -{0.88235294117647056f, 0.88235294117647056f, 1.0f, 1.0f}, -{0.89803921568627454f, 0.89803921568627454f, 1.0f, 1.0f}, -{0.91372549019607818f, 0.91372549019607818f, 1.0f, 1.0f}, -{0.92941176470588238f, 0.92941176470588238f, 1.0f, 1.0f}, -{0.94509803921568625f, 0.94509803921568625f, 1.0f, 1.0f}, -{0.96078431372549022f, 0.96078431372549022f, 1.0f, 1.0f}, -{0.97647058823529409f, 0.97647058823529409f, 1.0f, 1.0f}, -{0.99215686274509807f, 0.99215686274509807f, 1.0f, 1.0f}, -{1.0f, 0.99215686274509807f, 0.99215686274509807f, 1.0f}, -{1.0f, 0.97647058823529409f, 0.97647058823529409f, 1.0f}, -{1.0f, 0.96078431372549022f, 0.96078431372549022f, 1.0f}, -{1.0f, 0.94509803921568625f, 0.94509803921568625f, 1.0f}, -{1.0f, 0.92941176470588283f, 0.92941176470588283f, 1.0f}, -{1.0f, 0.9137254901960784f, 0.9137254901960784f, 1.0f}, -{1.0f, 0.89803921568627454f, 0.89803921568627454f, 1.0f}, -{1.0f, 0.88235294117647056f, 0.88235294117647056f, 1.0f}, -{1.0f, 0.8666666666666667f, 0.8666666666666667f, 1.0f}, -{1.0f, 0.85098039215686272f, 0.85098039215686272f, 1.0f}, -{1.0f, 0.83529411764705885f, 0.83529411764705885f, 1.0f}, -{1.0f, 0.81960784313725488f, 0.81960784313725488f, 1.0f}, -{1.0f, 0.80392156862745101f, 0.80392156862745101f, 1.0f}, -{1.0f, 0.78823529411764703f, 0.78823529411764703f, 1.0f}, -{1.0f, 0.77254901960784317f, 0.77254901960784317f, 1.0f}, -{1.0f, 0.75686274509803919f, 0.75686274509803919f, 1.0f}, -{1.0f, 0.74117647058823533f, 0.74117647058823533f, 1.0f}, -{1.0f, 0.72549019607843135f, 0.72549019607843135f, 1.0f}, -{1.0f, 0.70980392156862737f, 0.70980392156862737f, 1.0f}, -{1.0f, 0.69411764705882351f, 0.69411764705882351f, 1.0f}, -{1.0f, 0.67843137254902008f, 0.67843137254902008f, 1.0f}, -{1.0f, 0.66274509803921566f, 0.66274509803921566f, 1.0f}, -{1.0f, 0.64705882352941169f, 0.64705882352941169f, 1.0f}, -{1.0f, 0.63137254901960782f, 0.63137254901960782f, 1.0f}, -{1.0f, 0.61568627450980395f, 0.61568627450980395f, 1.0f}, -{1.0f, 0.59999999999999998f, 0.59999999999999998f, 1.0f}, -{1.0f, 0.584313725490196f, 0.584313725490196f, 1.0f}, -{1.0f, 0.56862745098039214f, 0.56862745098039214f, 1.0f}, -{1.0f, 0.55294117647058827f, 0.55294117647058827f, 1.0f}, -{1.0f, 0.53725490196078429f, 0.53725490196078429f, 1.0f}, -{1.0f, 0.52156862745098032f, 0.52156862745098032f, 1.0f}, -{1.0f, 0.50588235294117645f, 0.50588235294117645f, 1.0f}, -{1.0f, 0.49019607843137258f, 0.49019607843137258f, 1.0f}, -{1.0f, 0.47450980392156861f, 0.47450980392156861f, 1.0f}, -{1.0f, 0.45882352941176474f, 0.45882352941176474f, 1.0f}, -{1.0f, 0.44313725490196076f, 0.44313725490196076f, 1.0f}, -{1.0f, 0.42745098039215734f, 0.42745098039215734f, 1.0f}, -{1.0f, 0.41176470588235292f, 0.41176470588235292f, 1.0f}, -{1.0f, 0.39607843137254906f, 0.39607843137254906f, 1.0f}, -{1.0f, 0.38039215686274508f, 0.38039215686274508f, 1.0f}, -{1.0f, 0.36470588235294121f, 0.36470588235294121f, 1.0f}, -{1.0f, 0.34901960784313724f, 0.34901960784313724f, 1.0f}, -{1.0f, 0.33333333333333337f, 0.33333333333333337f, 1.0f}, -{1.0f, 0.31764705882352939f, 0.31764705882352939f, 1.0f}, -{1.0f, 0.30196078431372553f, 0.30196078431372553f, 1.0f}, -{1.0f, 0.28627450980392155f, 0.28627450980392155f, 1.0f}, -{1.0f, 0.27058823529411768f, 0.27058823529411768f, 1.0f}, -{1.0f, 0.25490196078431371f, 0.25490196078431371f, 1.0f}, -{1.0f, 0.23921568627450984f, 0.23921568627450984f, 1.0f}, -{1.0f, 0.22352941176470587f, 0.22352941176470587f, 1.0f}, -{1.0f, 0.207843137254902f, 0.207843137254902f, 1.0f}, -{1.0f, 0.19215686274509802f, 0.19215686274509802f, 1.0f}, -{1.0f, 0.1764705882352946f, 0.1764705882352946f, 1.0f}, -{1.0f, 0.16078431372549018f, 0.16078431372549018f, 1.0f}, -{1.0f, 0.14509803921568631f, 0.14509803921568631f, 1.0f}, -{1.0f, 0.12941176470588234f, 0.12941176470588234f, 1.0f}, -{1.0f, 0.11372549019607847f, 0.11372549019607847f, 1.0f}, -{1.0f, 0.098039215686274495f, 0.098039215686274495f, 1.0f}, -{1.0f, 0.082352941176470629f, 0.082352941176470629f, 1.0f}, -{1.0f, 0.066666666666666652f, 0.066666666666666652f, 1.0f}, -{1.0f, 0.050980392156862786f, 0.050980392156862786f, 1.0f}, -{1.0f, 0.035294117647058809f, 0.035294117647058809f, 1.0f}, -{1.0f, 0.019607843137254943f, 0.019607843137254943f, 1.0f}, -{1.0f, 0.0039215686274509665f, 0.0039215686274509665f, 1.0f}, -{0.99411764705882355f, 0.0f, 0.0f, 1.0f}, -{0.98627450980392162f, 0.0f, 0.0f, 1.0f}, -{0.97843137254901957f, 0.0f, 0.0f, 1.0f}, -{0.97058823529411764f, 0.0f, 0.0f, 1.0f}, -{0.96274509803921593f, 0.0f, 0.0f, 1.0f}, -{0.95490196078431377f, 0.0f, 0.0f, 1.0f}, -{0.94705882352941173f, 0.0f, 0.0f, 1.0f}, -{0.9392156862745098f, 0.0f, 0.0f, 1.0f}, -{0.93137254901960786f, 0.0f, 0.0f, 1.0f}, -{0.92352941176470593f, 0.0f, 0.0f, 1.0f}, -{0.91568627450980389f, 0.0f, 0.0f, 1.0f}, -{0.90784313725490196f, 0.0f, 0.0f, 1.0f}, -{0.90000000000000002f, 0.0f, 0.0f, 1.0f}, -{0.89215686274509798f, 0.0f, 0.0f, 1.0f}, -{0.88431372549019605f, 0.0f, 0.0f, 1.0f}, -{0.87647058823529411f, 0.0f, 0.0f, 1.0f}, -{0.86862745098039218f, 0.0f, 0.0f, 1.0f}, -{0.86078431372549025f, 0.0f, 0.0f, 1.0f}, -{0.8529411764705882f, 0.0f, 0.0f, 1.0f}, -{0.84509803921568627f, 0.0f, 0.0f, 1.0f}, -{0.83725490196078456f, 0.0f, 0.0f, 1.0f}, -{0.82941176470588229f, 0.0f, 0.0f, 1.0f}, -{0.82156862745098036f, 0.0f, 0.0f, 1.0f}, -{0.81372549019607843f, 0.0f, 0.0f, 1.0f}, -{0.80588235294117649f, 0.0f, 0.0f, 1.0f}, -{0.79803921568627456f, 0.0f, 0.0f, 1.0f}, -{0.79019607843137252f, 0.0f, 0.0f, 1.0f}, -{0.78235294117647058f, 0.0f, 0.0f, 1.0f}, -{0.77450980392156865f, 0.0f, 0.0f, 1.0f}, -{0.76666666666666661f, 0.0f, 0.0f, 1.0f}, -{0.75882352941176467f, 0.0f, 0.0f, 1.0f}, -{0.75098039215686274f, 0.0f, 0.0f, 1.0f}, -{0.74313725490196081f, 0.0f, 0.0f, 1.0f}, -{0.73529411764705888f, 0.0f, 0.0f, 1.0f}, -{0.72745098039215694f, 0.0f, 0.0f, 1.0f}, -{0.7196078431372549f, 0.0f, 0.0f, 1.0f}, -{0.71176470588235319f, 0.0f, 0.0f, 1.0f}, -{0.70392156862745092f, 0.0f, 0.0f, 1.0f}, -{0.69607843137254899f, 0.0f, 0.0f, 1.0f}, -{0.68823529411764706f, 0.0f, 0.0f, 1.0f}, -{0.68039215686274512f, 0.0f, 0.0f, 1.0f}, -{0.67254901960784319f, 0.0f, 0.0f, 1.0f}, -{0.66470588235294126f, 0.0f, 0.0f, 1.0f}, -{0.65686274509803921f, 0.0f, 0.0f, 1.0f}, -{0.64901960784313728f, 0.0f, 0.0f, 1.0f}, -{0.64117647058823524f, 0.0f, 0.0f, 1.0f}, -{0.6333333333333333f, 0.0f, 0.0f, 1.0f}, -{0.62549019607843137f, 0.0f, 0.0f, 1.0f}, -{0.61764705882352944f, 0.0f, 0.0f, 1.0f}, -{0.6098039215686275f, 0.0f, 0.0f, 1.0f}, -{0.60196078431372557f, 0.0f, 0.0f, 1.0f}, -{0.59411764705882353f, 0.0f, 0.0f, 1.0f}, -{0.58627450980392182f, 0.0f, 0.0f, 1.0f}, -{0.57843137254901955f, 0.0f, 0.0f, 1.0f}, -{0.57058823529411762f, 0.0f, 0.0f, 1.0f}, -{0.56274509803921569f, 0.0f, 0.0f, 1.0f}, -{0.55490196078431375f, 0.0f, 0.0f, 1.0f}, -{0.54705882352941182f, 0.0f, 0.0f, 1.0f}, -{0.53921568627450989f, 0.0f, 0.0f, 1.0f}, -{0.53137254901960784f, 0.0f, 0.0f, 1.0f}, -{0.52352941176470591f, 0.0f, 0.0f, 1.0f}, -{0.51568627450980387f, 0.0f, 0.0f, 1.0f}, -{0.50784313725490193f, 0.0f, 0.0f, 1.0f}, -{0.5f, 0.0f, 0.0f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/diverging/seismic.txt b/extern/tfn/colormaps/diverging/seismic.txt deleted file mode 100644 index 08d8b38..0000000 --- a/extern/tfn/colormaps/diverging/seismic.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.0, 0.0, 0.29999999999999999, 1.0) -(0.0, 0.0, 0.31098039215686274, 1.0) -(0.0, 0.0, 0.32196078431372549, 1.0) -(0.0, 0.0, 0.33294117647058824, 1.0) -(0.0, 0.0, 0.34392156862745094, 1.0) -(0.0, 0.0, 0.35490196078431369, 1.0) -(0.0, 0.0, 0.36588235294117644, 1.0) -(0.0, 0.0, 0.37686274509803919, 1.0) -(0.0, 0.0, 0.38784313725490194, 1.0) -(0.0, 0.0, 0.39882352941176469, 1.0) -(0.0, 0.0, 0.40980392156862744, 1.0) -(0.0, 0.0, 0.42078431372549019, 1.0) -(0.0, 0.0, 0.43176470588235294, 1.0) -(0.0, 0.0, 0.44274509803921569, 1.0) -(0.0, 0.0, 0.45372549019607844, 1.0) -(0.0, 0.0, 0.46470588235294119, 1.0) -(0.0, 0.0, 0.47568627450980389, 1.0) -(0.0, 0.0, 0.48666666666666664, 1.0) -(0.0, 0.0, 0.49764705882352939, 1.0) -(0.0, 0.0, 0.50862745098039208, 1.0) -(0.0, 0.0, 0.51960784313725483, 1.0) -(0.0, 0.0, 0.53058823529411758, 1.0) -(0.0, 0.0, 0.54156862745098033, 1.0) -(0.0, 0.0, 0.55254901960784308, 1.0) -(0.0, 0.0, 0.56352941176470583, 1.0) -(0.0, 0.0, 0.57450980392156858, 1.0) -(0.0, 0.0, 0.58549019607843134, 1.0) -(0.0, 0.0, 0.59647058823529409, 1.0) -(0.0, 0.0, 0.60745098039215684, 1.0) -(0.0, 0.0, 0.61843137254901959, 1.0) -(0.0, 0.0, 0.62941176470588234, 1.0) -(0.0, 0.0, 0.64039215686274509, 1.0) -(0.0, 0.0, 0.65137254901960784, 1.0) -(0.0, 0.0, 0.66235294117647059, 1.0) -(0.0, 0.0, 0.67333333333333334, 1.0) -(0.0, 0.0, 0.68431372549019609, 1.0) -(0.0, 0.0, 0.69529411764705884, 1.0) -(0.0, 0.0, 0.70627450980392148, 1.0) -(0.0, 0.0, 0.71725490196078434, 1.0) -(0.0, 0.0, 0.72823529411764709, 1.0) -(0.0, 0.0, 0.73921568627450973, 1.0) -(0.0, 0.0, 0.75019607843137248, 1.0) -(0.0, 0.0, 0.76117647058823523, 1.0) -(0.0, 0.0, 0.77215686274509809, 1.0) -(0.0, 0.0, 0.78313725490196073, 1.0) -(0.0, 0.0, 0.79411764705882337, 1.0) -(0.0, 0.0, 0.80509803921568612, 1.0) -(0.0, 0.0, 0.8160784313725491, 1.0) -(0.0, 0.0, 0.82705882352941162, 1.0) -(0.0, 0.0, 0.83803921568627437, 1.0) -(0.0, 0.0, 0.84901960784313713, 1.0) -(0.0, 0.0, 0.85999999999999988, 1.0) -(0.0, 0.0, 0.87098039215686263, 1.0) -(0.0, 0.0, 0.88196078431372538, 1.0) -(0.0, 0.0, 0.89294117647058813, 1.0) -(0.0, 0.0, 0.90392156862745088, 1.0) -(0.0, 0.0, 0.91490196078431363, 1.0) -(0.0, 0.0, 0.92588235294117638, 1.0) -(0.0, 0.0, 0.93686274509803913, 1.0) -(0.0, 0.0, 0.94784313725490188, 1.0) -(0.0, 0.0, 0.95882352941176463, 1.0) -(0.0, 0.0, 0.96980392156862738, 1.0) -(0.0, 0.0, 0.98078431372549013, 1.0) -(0.0, 0.0, 0.99176470588235288, 1.0) -(0.0039215686274509803, 0.0039215686274509803, 1.0, 1.0) -(0.019607843137254902, 0.019607843137254902, 1.0, 1.0) -(0.035294117647058601, 0.035294117647058601, 1.0, 1.0) -(0.050980392156862744, 0.050980392156862744, 1.0, 1.0) -(0.066666666666666666, 0.066666666666666666, 1.0, 1.0) -(0.082352941176470587, 0.082352941176470587, 1.0, 1.0) -(0.098039215686274508, 0.098039215686274508, 1.0, 1.0) -(0.11372549019607843, 0.11372549019607843, 1.0, 1.0) -(0.12941176470588237, 0.12941176470588237, 1.0, 1.0) -(0.14509803921568629, 0.14509803921568629, 1.0, 1.0) -(0.16078431372548999, 0.16078431372548999, 1.0, 1.0) -(0.17647058823529413, 0.17647058823529413, 1.0, 1.0) -(0.19215686274509805, 0.19215686274509805, 1.0, 1.0) -(0.20784313725490197, 0.20784313725490197, 1.0, 1.0) -(0.22352941176470589, 0.22352941176470589, 1.0, 1.0) -(0.23921568627450981, 0.23921568627450981, 1.0, 1.0) -(0.25490196078431371, 0.25490196078431371, 1.0, 1.0) -(0.27058823529411763, 0.27058823529411763, 1.0, 1.0) -(0.28627450980392133, 0.28627450980392133, 1.0, 1.0) -(0.30196078431372547, 0.30196078431372547, 1.0, 1.0) -(0.31764705882352939, 0.31764705882352939, 1.0, 1.0) -(0.33333333333333331, 0.33333333333333331, 1.0, 1.0) -(0.34901960784313724, 0.34901960784313724, 1.0, 1.0) -(0.36470588235294116, 0.36470588235294116, 1.0, 1.0) -(0.38039215686274508, 0.38039215686274508, 1.0, 1.0) -(0.396078431372549, 0.396078431372549, 1.0, 1.0) -(0.4117647058823527, 0.4117647058823527, 1.0, 1.0) -(0.42745098039215684, 0.42745098039215684, 1.0, 1.0) -(0.44313725490196076, 0.44313725490196076, 1.0, 1.0) -(0.45882352941176469, 0.45882352941176469, 1.0, 1.0) -(0.47450980392156861, 0.47450980392156861, 1.0, 1.0) -(0.49019607843137253, 0.49019607843137253, 1.0, 1.0) -(0.50588235294117645, 0.50588235294117645, 1.0, 1.0) -(0.52156862745098043, 0.52156862745098043, 1.0, 1.0) -(0.53725490196078407, 0.53725490196078407, 1.0, 1.0) -(0.55294117647058827, 0.55294117647058827, 1.0, 1.0) -(0.56862745098039214, 0.56862745098039214, 1.0, 1.0) -(0.58431372549019611, 0.58431372549019611, 1.0, 1.0) -(0.59999999999999998, 0.59999999999999998, 1.0, 1.0) -(0.61568627450980395, 0.61568627450980395, 1.0, 1.0) -(0.63137254901960782, 0.63137254901960782, 1.0, 1.0) -(0.6470588235294118, 0.6470588235294118, 1.0, 1.0) -(0.66274509803921544, 0.66274509803921544, 1.0, 1.0) -(0.67843137254901964, 0.67843137254901964, 1.0, 1.0) -(0.69411764705882351, 0.69411764705882351, 1.0, 1.0) -(0.70980392156862748, 0.70980392156862748, 1.0, 1.0) -(0.72549019607843135, 0.72549019607843135, 1.0, 1.0) -(0.74117647058823533, 0.74117647058823533, 1.0, 1.0) -(0.75686274509803919, 0.75686274509803919, 1.0, 1.0) -(0.77254901960784317, 0.77254901960784317, 1.0, 1.0) -(0.78823529411764681, 0.78823529411764681, 1.0, 1.0) -(0.80392156862745101, 0.80392156862745101, 1.0, 1.0) -(0.81960784313725488, 0.81960784313725488, 1.0, 1.0) -(0.83529411764705885, 0.83529411764705885, 1.0, 1.0) -(0.85098039215686272, 0.85098039215686272, 1.0, 1.0) -(0.8666666666666667, 0.8666666666666667, 1.0, 1.0) -(0.88235294117647056, 0.88235294117647056, 1.0, 1.0) -(0.89803921568627454, 0.89803921568627454, 1.0, 1.0) -(0.91372549019607818, 0.91372549019607818, 1.0, 1.0) -(0.92941176470588238, 0.92941176470588238, 1.0, 1.0) -(0.94509803921568625, 0.94509803921568625, 1.0, 1.0) -(0.96078431372549022, 0.96078431372549022, 1.0, 1.0) -(0.97647058823529409, 0.97647058823529409, 1.0, 1.0) -(0.99215686274509807, 0.99215686274509807, 1.0, 1.0) -(1.0, 0.99215686274509807, 0.99215686274509807, 1.0) -(1.0, 0.97647058823529409, 0.97647058823529409, 1.0) -(1.0, 0.96078431372549022, 0.96078431372549022, 1.0) -(1.0, 0.94509803921568625, 0.94509803921568625, 1.0) -(1.0, 0.92941176470588283, 0.92941176470588283, 1.0) -(1.0, 0.9137254901960784, 0.9137254901960784, 1.0) -(1.0, 0.89803921568627454, 0.89803921568627454, 1.0) -(1.0, 0.88235294117647056, 0.88235294117647056, 1.0) -(1.0, 0.8666666666666667, 0.8666666666666667, 1.0) -(1.0, 0.85098039215686272, 0.85098039215686272, 1.0) -(1.0, 0.83529411764705885, 0.83529411764705885, 1.0) -(1.0, 0.81960784313725488, 0.81960784313725488, 1.0) -(1.0, 0.80392156862745101, 0.80392156862745101, 1.0) -(1.0, 0.78823529411764703, 0.78823529411764703, 1.0) -(1.0, 0.77254901960784317, 0.77254901960784317, 1.0) -(1.0, 0.75686274509803919, 0.75686274509803919, 1.0) -(1.0, 0.74117647058823533, 0.74117647058823533, 1.0) -(1.0, 0.72549019607843135, 0.72549019607843135, 1.0) -(1.0, 0.70980392156862737, 0.70980392156862737, 1.0) -(1.0, 0.69411764705882351, 0.69411764705882351, 1.0) -(1.0, 0.67843137254902008, 0.67843137254902008, 1.0) -(1.0, 0.66274509803921566, 0.66274509803921566, 1.0) -(1.0, 0.64705882352941169, 0.64705882352941169, 1.0) -(1.0, 0.63137254901960782, 0.63137254901960782, 1.0) -(1.0, 0.61568627450980395, 0.61568627450980395, 1.0) -(1.0, 0.59999999999999998, 0.59999999999999998, 1.0) -(1.0, 0.584313725490196, 0.584313725490196, 1.0) -(1.0, 0.56862745098039214, 0.56862745098039214, 1.0) -(1.0, 0.55294117647058827, 0.55294117647058827, 1.0) -(1.0, 0.53725490196078429, 0.53725490196078429, 1.0) -(1.0, 0.52156862745098032, 0.52156862745098032, 1.0) -(1.0, 0.50588235294117645, 0.50588235294117645, 1.0) -(1.0, 0.49019607843137258, 0.49019607843137258, 1.0) -(1.0, 0.47450980392156861, 0.47450980392156861, 1.0) -(1.0, 0.45882352941176474, 0.45882352941176474, 1.0) -(1.0, 0.44313725490196076, 0.44313725490196076, 1.0) -(1.0, 0.42745098039215734, 0.42745098039215734, 1.0) -(1.0, 0.41176470588235292, 0.41176470588235292, 1.0) -(1.0, 0.39607843137254906, 0.39607843137254906, 1.0) -(1.0, 0.38039215686274508, 0.38039215686274508, 1.0) -(1.0, 0.36470588235294121, 0.36470588235294121, 1.0) -(1.0, 0.34901960784313724, 0.34901960784313724, 1.0) -(1.0, 0.33333333333333337, 0.33333333333333337, 1.0) -(1.0, 0.31764705882352939, 0.31764705882352939, 1.0) -(1.0, 0.30196078431372553, 0.30196078431372553, 1.0) -(1.0, 0.28627450980392155, 0.28627450980392155, 1.0) -(1.0, 0.27058823529411768, 0.27058823529411768, 1.0) -(1.0, 0.25490196078431371, 0.25490196078431371, 1.0) -(1.0, 0.23921568627450984, 0.23921568627450984, 1.0) -(1.0, 0.22352941176470587, 0.22352941176470587, 1.0) -(1.0, 0.207843137254902, 0.207843137254902, 1.0) -(1.0, 0.19215686274509802, 0.19215686274509802, 1.0) -(1.0, 0.1764705882352946, 0.1764705882352946, 1.0) -(1.0, 0.16078431372549018, 0.16078431372549018, 1.0) -(1.0, 0.14509803921568631, 0.14509803921568631, 1.0) -(1.0, 0.12941176470588234, 0.12941176470588234, 1.0) -(1.0, 0.11372549019607847, 0.11372549019607847, 1.0) -(1.0, 0.098039215686274495, 0.098039215686274495, 1.0) -(1.0, 0.082352941176470629, 0.082352941176470629, 1.0) -(1.0, 0.066666666666666652, 0.066666666666666652, 1.0) -(1.0, 0.050980392156862786, 0.050980392156862786, 1.0) -(1.0, 0.035294117647058809, 0.035294117647058809, 1.0) -(1.0, 0.019607843137254943, 0.019607843137254943, 1.0) -(1.0, 0.0039215686274509665, 0.0039215686274509665, 1.0) -(0.99411764705882355, 0.0, 0.0, 1.0) -(0.98627450980392162, 0.0, 0.0, 1.0) -(0.97843137254901957, 0.0, 0.0, 1.0) -(0.97058823529411764, 0.0, 0.0, 1.0) -(0.96274509803921593, 0.0, 0.0, 1.0) -(0.95490196078431377, 0.0, 0.0, 1.0) -(0.94705882352941173, 0.0, 0.0, 1.0) -(0.9392156862745098, 0.0, 0.0, 1.0) -(0.93137254901960786, 0.0, 0.0, 1.0) -(0.92352941176470593, 0.0, 0.0, 1.0) -(0.91568627450980389, 0.0, 0.0, 1.0) -(0.90784313725490196, 0.0, 0.0, 1.0) -(0.90000000000000002, 0.0, 0.0, 1.0) -(0.89215686274509798, 0.0, 0.0, 1.0) -(0.88431372549019605, 0.0, 0.0, 1.0) -(0.87647058823529411, 0.0, 0.0, 1.0) -(0.86862745098039218, 0.0, 0.0, 1.0) -(0.86078431372549025, 0.0, 0.0, 1.0) -(0.8529411764705882, 0.0, 0.0, 1.0) -(0.84509803921568627, 0.0, 0.0, 1.0) -(0.83725490196078456, 0.0, 0.0, 1.0) -(0.82941176470588229, 0.0, 0.0, 1.0) -(0.82156862745098036, 0.0, 0.0, 1.0) -(0.81372549019607843, 0.0, 0.0, 1.0) -(0.80588235294117649, 0.0, 0.0, 1.0) -(0.79803921568627456, 0.0, 0.0, 1.0) -(0.79019607843137252, 0.0, 0.0, 1.0) -(0.78235294117647058, 0.0, 0.0, 1.0) -(0.77450980392156865, 0.0, 0.0, 1.0) -(0.76666666666666661, 0.0, 0.0, 1.0) -(0.75882352941176467, 0.0, 0.0, 1.0) -(0.75098039215686274, 0.0, 0.0, 1.0) -(0.74313725490196081, 0.0, 0.0, 1.0) -(0.73529411764705888, 0.0, 0.0, 1.0) -(0.72745098039215694, 0.0, 0.0, 1.0) -(0.7196078431372549, 0.0, 0.0, 1.0) -(0.71176470588235319, 0.0, 0.0, 1.0) -(0.70392156862745092, 0.0, 0.0, 1.0) -(0.69607843137254899, 0.0, 0.0, 1.0) -(0.68823529411764706, 0.0, 0.0, 1.0) -(0.68039215686274512, 0.0, 0.0, 1.0) -(0.67254901960784319, 0.0, 0.0, 1.0) -(0.66470588235294126, 0.0, 0.0, 1.0) -(0.65686274509803921, 0.0, 0.0, 1.0) -(0.64901960784313728, 0.0, 0.0, 1.0) -(0.64117647058823524, 0.0, 0.0, 1.0) -(0.6333333333333333, 0.0, 0.0, 1.0) -(0.62549019607843137, 0.0, 0.0, 1.0) -(0.61764705882352944, 0.0, 0.0, 1.0) -(0.6098039215686275, 0.0, 0.0, 1.0) -(0.60196078431372557, 0.0, 0.0, 1.0) -(0.59411764705882353, 0.0, 0.0, 1.0) -(0.58627450980392182, 0.0, 0.0, 1.0) -(0.57843137254901955, 0.0, 0.0, 1.0) -(0.57058823529411762, 0.0, 0.0, 1.0) -(0.56274509803921569, 0.0, 0.0, 1.0) -(0.55490196078431375, 0.0, 0.0, 1.0) -(0.54705882352941182, 0.0, 0.0, 1.0) -(0.53921568627450989, 0.0, 0.0, 1.0) -(0.53137254901960784, 0.0, 0.0, 1.0) -(0.52352941176470591, 0.0, 0.0, 1.0) -(0.51568627450980387, 0.0, 0.0, 1.0) -(0.50784313725490193, 0.0, 0.0, 1.0) -(0.5, 0.0, 0.0, 1.0) diff --git a/extern/tfn/colormaps/perceptual/inferno.cpp b/extern/tfn/colormaps/perceptual/inferno.cpp deleted file mode 100644 index fd62a29..0000000 --- a/extern/tfn/colormaps/perceptual/inferno.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_perceptual_inferno; -} -const std::vector colormap::data_perceptual_inferno = /* NOLINT(cert-err58-cpp) */ -{ -{0.001462f, 0.000466f, 0.013866f, 1.0f}, -{0.0022669999999999999f, 0.0012700000000000001f, 0.01857f, 1.0f}, -{0.0032989999999999998f, 0.0022490000000000001f, 0.024239f, 1.0f}, -{0.0045469999999999998f, 0.003392f, 0.030908999999999999f, 1.0f}, -{0.0060060000000000001f, 0.004692f, 0.038558000000000002f, 1.0f}, -{0.0076759999999999997f, 0.006136f, 0.046836000000000003f, 1.0f}, -{0.0095610000000000001f, 0.0077130000000000002f, 0.055142999999999998f, 1.0f}, -{0.011663f, 0.009417f, 0.063460000000000003f, 1.0f}, -{0.013995f, 0.011225000000000001f, 0.071861999999999995f, 1.0f}, -{0.016560999999999999f, 0.013136f, 0.080282000000000006f, 1.0f}, -{0.019373000000000001f, 0.015133000000000001f, 0.088766999999999999f, 1.0f}, -{0.022447000000000002f, 0.017198999999999999f, 0.097326999999999997f, 1.0f}, -{0.025793f, 0.019331000000000001f, 0.10593f, 1.0f}, -{0.029432f, 0.021503000000000001f, 0.114621f, 1.0f}, -{0.033384999999999998f, 0.023702000000000001f, 0.12339700000000001f, 1.0f}, -{0.037668f, 0.025921f, 0.13223199999999999f, 1.0f}, -{0.042252999999999999f, 0.028139000000000001f, 0.14114099999999999f, 1.0f}, -{0.046914999999999998f, 0.030324f, 0.15016399999999999f, 1.0f}, -{0.051644000000000002f, 0.032474000000000003f, 0.15925400000000001f, 1.0f}, -{0.056448999999999999f, 0.034569000000000003f, 0.16841400000000001f, 1.0f}, -{0.061339999999999999f, 0.036589999999999998f, 0.17764199999999999f, 1.0f}, -{0.066331000000000001f, 0.038503999999999997f, 0.18696199999999999f, 1.0f}, -{0.071429000000000006f, 0.040294000000000003f, 0.196354f, 1.0f}, -{0.076636999999999997f, 0.041904999999999998f, 0.20579900000000001f, 1.0f}, -{0.081961999999999993f, 0.043327999999999998f, 0.21528900000000001f, 1.0f}, -{0.087411000000000003f, 0.044555999999999998f, 0.22481300000000001f, 1.0f}, -{0.092990000000000003f, 0.045582999999999999f, 0.23435800000000001f, 1.0f}, -{0.098701999999999998f, 0.046401999999999999f, 0.24390400000000001f, 1.0f}, -{0.10455100000000001f, 0.047008000000000001f, 0.25342999999999999f, 1.0f}, -{0.110536f, 0.047398999999999997f, 0.26291199999999998f, 1.0f}, -{0.116656f, 0.047573999999999998f, 0.27232099999999998f, 1.0f}, -{0.122908f, 0.047536000000000002f, 0.28162399999999999f, 1.0f}, -{0.12928500000000001f, 0.047293000000000002f, 0.29078799999999999f, 1.0f}, -{0.13577800000000001f, 0.046856000000000002f, 0.29977599999999999f, 1.0f}, -{0.142378f, 0.046241999999999998f, 0.30855300000000002f, 1.0f}, -{0.14907300000000001f, 0.045468000000000001f, 0.31708500000000001f, 1.0f}, -{0.15584999999999999f, 0.044559000000000001f, 0.32533800000000002f, 1.0f}, -{0.162689f, 0.043554000000000002f, 0.33327699999999999f, 1.0f}, -{0.169575f, 0.042488999999999999f, 0.34087400000000001f, 1.0f}, -{0.17649300000000001f, 0.041402000000000001f, 0.348111f, 1.0f}, -{0.18342900000000001f, 0.040328999999999997f, 0.35497099999999998f, 1.0f}, -{0.19036700000000001f, 0.039308999999999997f, 0.36144700000000002f, 1.0f}, -{0.197297f, 0.038399999999999997f, 0.367535f, 1.0f}, -{0.204209f, 0.037631999999999999f, 0.37323800000000001f, 1.0f}, -{0.211095f, 0.03703f, 0.37856299999999998f, 1.0f}, -{0.217949f, 0.036615000000000002f, 0.38352199999999997f, 1.0f}, -{0.22476299999999999f, 0.036405f, 0.388129f, 1.0f}, -{0.23153799999999999f, 0.036405f, 0.39240000000000003f, 1.0f}, -{0.23827300000000001f, 0.036621000000000001f, 0.39635300000000001f, 1.0f}, -{0.24496699999999999f, 0.037054999999999998f, 0.400007f, 1.0f}, -{0.25162000000000001f, 0.037705000000000002f, 0.40337800000000001f, 1.0f}, -{0.25823400000000002f, 0.038571000000000001f, 0.40648499999999999f, 1.0f}, -{0.26480999999999999f, 0.039647000000000002f, 0.40934500000000001f, 1.0f}, -{0.271347f, 0.040922f, 0.41197600000000001f, 1.0f}, -{0.27784999999999999f, 0.042353000000000002f, 0.41439199999999998f, 1.0f}, -{0.28432099999999999f, 0.043933f, 0.41660799999999998f, 1.0f}, -{0.29076299999999999f, 0.045643999999999997f, 0.41863699999999998f, 1.0f}, -{0.297178f, 0.047469999999999998f, 0.420491f, 1.0f}, -{0.303568f, 0.049396000000000002f, 0.422182f, 1.0f}, -{0.30993500000000002f, 0.051407000000000001f, 0.42372100000000001f, 1.0f}, -{0.31628200000000001f, 0.053490000000000003f, 0.42511599999999999f, 1.0f}, -{0.32261000000000001f, 0.055634000000000003f, 0.42637700000000001f, 1.0f}, -{0.32892100000000002f, 0.057827000000000003f, 0.42751099999999997f, 1.0f}, -{0.33521699999999999f, 0.060060000000000002f, 0.42852400000000002f, 1.0f}, -{0.34150000000000003f, 0.062324999999999998f, 0.429425f, 1.0f}, -{0.347771f, 0.064616000000000007f, 0.43021700000000002f, 1.0f}, -{0.35403200000000001f, 0.066924999999999998f, 0.43090600000000001f, 1.0f}, -{0.36028399999999999f, 0.069247000000000003f, 0.43149700000000002f, 1.0f}, -{0.36652899999999999f, 0.071579000000000004f, 0.43199399999999999f, 1.0f}, -{0.37276799999999999f, 0.073914999999999995f, 0.43240000000000001f, 1.0f}, -{0.37900099999999998f, 0.076253000000000001f, 0.43271900000000002f, 1.0f}, -{0.38522800000000001f, 0.078590999999999994f, 0.43295499999999998f, 1.0f}, -{0.391453f, 0.080926999999999999f, 0.43310900000000002f, 1.0f}, -{0.39767400000000003f, 0.083256999999999998f, 0.43318299999999998f, 1.0f}, -{0.40389399999999998f, 0.085580000000000003f, 0.43317899999999998f, 1.0f}, -{0.41011300000000001f, 0.087896000000000002f, 0.43309799999999998f, 1.0f}, -{0.41633100000000001f, 0.090203000000000005f, 0.43294300000000002f, 1.0f}, -{0.42254900000000001f, 0.092501f, 0.43271399999999999f, 1.0f}, -{0.42876799999999998f, 0.094789999999999999f, 0.43241200000000002f, 1.0f}, -{0.43498700000000001f, 0.097069000000000003f, 0.43203900000000001f, 1.0f}, -{0.44120700000000002f, 0.099337999999999996f, 0.43159399999999998f, 1.0f}, -{0.44742799999999999f, 0.10159700000000001f, 0.43108000000000002f, 1.0f}, -{0.45365100000000003f, 0.103848f, 0.43049799999999999f, 1.0f}, -{0.45987499999999998f, 0.106089f, 0.42984600000000001f, 1.0f}, -{0.46610000000000001f, 0.108322f, 0.42912499999999998f, 1.0f}, -{0.47232800000000003f, 0.11054700000000001f, 0.42833399999999999f, 1.0f}, -{0.47855799999999998f, 0.112764f, 0.42747499999999999f, 1.0f}, -{0.48478900000000003f, 0.11497400000000001f, 0.42654799999999998f, 1.0f}, -{0.49102200000000001f, 0.11717900000000001f, 0.42555199999999999f, 1.0f}, -{0.497257f, 0.119379f, 0.42448799999999998f, 1.0f}, -{0.50349299999999997f, 0.121575f, 0.42335600000000001f, 1.0f}, -{0.50973000000000002f, 0.123769f, 0.42215599999999998f, 1.0f}, -{0.51596699999999995f, 0.12595999999999999f, 0.42088700000000001f, 1.0f}, -{0.52220599999999995f, 0.12814999999999999f, 0.41954900000000001f, 1.0f}, -{0.52844400000000002f, 0.13034100000000001f, 0.41814200000000001f, 1.0f}, -{0.53468300000000002f, 0.13253400000000001f, 0.41666700000000001f, 1.0f}, -{0.54091999999999996f, 0.13472899999999999f, 0.41512300000000002f, 1.0f}, -{0.547157f, 0.136929f, 0.41351100000000002f, 1.0f}, -{0.553392f, 0.13913400000000001f, 0.411829f, 1.0f}, -{0.55962400000000001f, 0.141346f, 0.410078f, 1.0f}, -{0.56585399999999997f, 0.143567f, 0.40825800000000001f, 1.0f}, -{0.57208099999999995f, 0.14579700000000001f, 0.40636899999999998f, 1.0f}, -{0.57830400000000004f, 0.148039f, 0.40441100000000002f, 1.0f}, -{0.58452099999999996f, 0.15029400000000001f, 0.40238499999999999f, 1.0f}, -{0.59073399999999998f, 0.152563f, 0.40028999999999998f, 1.0f}, -{0.59694000000000003f, 0.15484800000000001f, 0.39812500000000001f, 1.0f}, -{0.60313899999999998f, 0.15715100000000001f, 0.39589099999999999f, 1.0f}, -{0.60933000000000004f, 0.159474f, 0.39358900000000002f, 1.0f}, -{0.61551299999999998f, 0.16181699999999999f, 0.39121899999999998f, 1.0f}, -{0.62168500000000004f, 0.164184f, 0.38878099999999999f, 1.0f}, -{0.62784700000000004f, 0.166575f, 0.38627600000000001f, 1.0f}, -{0.63399799999999995f, 0.168992f, 0.38370399999999999f, 1.0f}, -{0.64013500000000001f, 0.17143800000000001f, 0.38106499999999999f, 1.0f}, -{0.64625999999999995f, 0.17391400000000001f, 0.378359f, 1.0f}, -{0.65236899999999998f, 0.17642099999999999f, 0.37558599999999998f, 1.0f}, -{0.65846300000000002f, 0.17896200000000001f, 0.37274800000000002f, 1.0f}, -{0.66454000000000002f, 0.18153900000000001f, 0.36984600000000001f, 1.0f}, -{0.67059899999999995f, 0.18415300000000001f, 0.36687900000000001f, 1.0f}, -{0.67663799999999996f, 0.186807f, 0.36384899999999998f, 1.0f}, -{0.68265600000000004f, 0.189501f, 0.36075699999999999f, 1.0f}, -{0.68865299999999996f, 0.19223899999999999f, 0.357603f, 1.0f}, -{0.69462699999999999f, 0.195021f, 0.35438799999999998f, 1.0f}, -{0.70057599999999998f, 0.197851f, 0.35111300000000001f, 1.0f}, -{0.70650000000000002f, 0.20072799999999999f, 0.347777f, 1.0f}, -{0.71239600000000003f, 0.203656f, 0.34438299999999999f, 1.0f}, -{0.71826400000000001f, 0.20663599999999999f, 0.34093099999999998f, 1.0f}, -{0.72410300000000005f, 0.20967f, 0.337424f, 1.0f}, -{0.72990900000000003f, 0.212759f, 0.33386100000000002f, 1.0f}, -{0.73568299999999998f, 0.21590599999999999f, 0.33024500000000001f, 1.0f}, -{0.74142300000000005f, 0.219112f, 0.32657599999999998f, 1.0f}, -{0.74712699999999999f, 0.22237799999999999f, 0.32285599999999998f, 1.0f}, -{0.75279399999999996f, 0.22570599999999999f, 0.31908500000000001f, 1.0f}, -{0.75842200000000004f, 0.229097f, 0.31526599999999999f, 1.0f}, -{0.76400999999999997f, 0.23255400000000001f, 0.31139899999999998f, 1.0f}, -{0.76955600000000002f, 0.23607700000000001f, 0.30748500000000001f, 1.0f}, -{0.77505900000000005f, 0.23966699999999999f, 0.30352600000000002f, 1.0f}, -{0.78051700000000002f, 0.24332699999999999f, 0.29952299999999998f, 1.0f}, -{0.78592899999999999f, 0.247056f, 0.29547699999999999f, 1.0f}, -{0.79129300000000002f, 0.25085600000000002f, 0.29138999999999998f, 1.0f}, -{0.79660699999999995f, 0.25472800000000001f, 0.28726400000000002f, 1.0f}, -{0.801871f, 0.25867400000000002f, 0.28309899999999999f, 1.0f}, -{0.80708199999999997f, 0.26269199999999998f, 0.27889799999999998f, 1.0f}, -{0.81223900000000004f, 0.26678600000000002f, 0.27466099999999999f, 1.0f}, -{0.81734099999999998f, 0.27095399999999997f, 0.27039000000000002f, 1.0f}, -{0.82238599999999995f, 0.27519700000000002f, 0.26608500000000002f, 1.0f}, -{0.827372f, 0.27951700000000002f, 0.26174999999999998f, 1.0f}, -{0.83229900000000001f, 0.28391300000000003f, 0.25738299999999997f, 1.0f}, -{0.83716500000000005f, 0.288385f, 0.25298799999999999f, 1.0f}, -{0.84196899999999997f, 0.292933f, 0.24856400000000001f, 1.0f}, -{0.84670900000000004f, 0.29755900000000002f, 0.244113f, 1.0f}, -{0.85138400000000003f, 0.30225999999999997f, 0.23963599999999999f, 1.0f}, -{0.85599199999999998f, 0.30703799999999998f, 0.23513300000000001f, 1.0f}, -{0.86053299999999999f, 0.311892f, 0.23060600000000001f, 1.0f}, -{0.86500600000000005f, 0.31682199999999999f, 0.22605500000000001f, 1.0f}, -{0.86940899999999999f, 0.32182699999999997f, 0.22148200000000001f, 1.0f}, -{0.87374099999999999f, 0.32690599999999997f, 0.216886f, 1.0f}, -{0.87800100000000003f, 0.33206000000000002f, 0.21226800000000001f, 1.0f}, -{0.88218799999999997f, 0.337287f, 0.20762800000000001f, 1.0f}, -{0.88630200000000003f, 0.342586f, 0.20296800000000001f, 1.0f}, -{0.89034100000000005f, 0.34795700000000002f, 0.19828599999999999f, 1.0f}, -{0.89430500000000002f, 0.35339900000000002f, 0.19358400000000001f, 1.0f}, -{0.89819199999999999f, 0.35891099999999998f, 0.18886f, 1.0f}, -{0.902003f, 0.36449199999999998f, 0.184116f, 1.0f}, -{0.90573499999999996f, 0.37014000000000002f, 0.17935000000000001f, 1.0f}, -{0.90939000000000003f, 0.37585600000000002f, 0.174563f, 1.0f}, -{0.91296600000000006f, 0.38163599999999998f, 0.16975499999999999f, 1.0f}, -{0.916462f, 0.38748100000000002f, 0.16492399999999999f, 1.0f}, -{0.919879f, 0.39338899999999999f, 0.16006999999999999f, 1.0f}, -{0.92321500000000001f, 0.39935900000000002f, 0.155193f, 1.0f}, -{0.92647000000000002f, 0.405389f, 0.15029200000000001f, 1.0f}, -{0.92964400000000003f, 0.41147899999999998f, 0.145367f, 1.0f}, -{0.93273700000000004f, 0.41762700000000003f, 0.14041699999999999f, 1.0f}, -{0.935747f, 0.42383100000000001f, 0.13544f, 1.0f}, -{0.93867500000000004f, 0.430091f, 0.130438f, 1.0f}, -{0.94152100000000005f, 0.43640499999999999f, 0.12540899999999999f, 1.0f}, -{0.94428500000000004f, 0.442772f, 0.120354f, 1.0f}, -{0.94696499999999995f, 0.44919100000000001f, 0.115272f, 1.0f}, -{0.94956200000000002f, 0.45566000000000001f, 0.110164f, 1.0f}, -{0.952075f, 0.46217799999999998f, 0.105031f, 1.0f}, -{0.95450599999999997f, 0.46874399999999999f, 0.099874000000000004f, 1.0f}, -{0.95685200000000004f, 0.475356f, 0.094695000000000001f, 1.0f}, -{0.95911400000000002f, 0.482014f, 0.089498999999999995f, 1.0f}, -{0.96129299999999995f, 0.48871599999999998f, 0.084289000000000003f, 1.0f}, -{0.96338699999999999f, 0.49546200000000001f, 0.079073000000000004f, 1.0f}, -{0.96539699999999995f, 0.50224899999999995f, 0.073858999999999994f, 1.0f}, -{0.96732200000000002f, 0.50907800000000003f, 0.068658999999999998f, 1.0f}, -{0.969163f, 0.51594600000000002f, 0.063488000000000003f, 1.0f}, -{0.97091899999999998f, 0.52285300000000001f, 0.058367000000000002f, 1.0f}, -{0.97258999999999995f, 0.52979799999999999f, 0.053324000000000003f, 1.0f}, -{0.97417600000000004f, 0.53678000000000003f, 0.048391999999999998f, 1.0f}, -{0.97567700000000002f, 0.543798f, 0.043617999999999997f, 1.0f}, -{0.97709199999999996f, 0.55084999999999995f, 0.039050000000000001f, 1.0f}, -{0.97842200000000001f, 0.55793700000000002f, 0.034930999999999997f, 1.0f}, -{0.97966600000000004f, 0.56505700000000003f, 0.031408999999999999f, 1.0f}, -{0.98082400000000003f, 0.57220899999999997f, 0.028507999999999999f, 1.0f}, -{0.98189499999999996f, 0.57939200000000002f, 0.026249999999999999f, 1.0f}, -{0.982881f, 0.58660599999999996f, 0.024660999999999999f, 1.0f}, -{0.98377899999999996f, 0.59384899999999996f, 0.023769999999999999f, 1.0f}, -{0.98459099999999999f, 0.60112200000000005f, 0.023605999999999999f, 1.0f}, -{0.98531500000000005f, 0.60842200000000002f, 0.024202000000000001f, 1.0f}, -{0.98595200000000005f, 0.61575000000000002f, 0.025592f, 1.0f}, -{0.98650199999999999f, 0.62310500000000002f, 0.027813999999999998f, 1.0f}, -{0.98696399999999995f, 0.63048499999999996f, 0.030908000000000001f, 1.0f}, -{0.98733700000000002f, 0.63788999999999996f, 0.034916000000000003f, 1.0f}, -{0.987622f, 0.64532f, 0.039885999999999998f, 1.0f}, -{0.987819f, 0.65277300000000005f, 0.045581000000000003f, 1.0f}, -{0.98792599999999997f, 0.66025f, 0.051749999999999997f, 1.0f}, -{0.98794499999999996f, 0.66774800000000001f, 0.058328999999999999f, 1.0f}, -{0.98787400000000003f, 0.67526699999999995f, 0.065256999999999996f, 1.0f}, -{0.98771399999999998f, 0.68280700000000005f, 0.072488999999999998f, 1.0f}, -{0.98746400000000001f, 0.69036600000000004f, 0.079990000000000006f, 1.0f}, -{0.987124f, 0.69794400000000001f, 0.087731000000000003f, 1.0f}, -{0.98669399999999996f, 0.70553999999999994f, 0.095694000000000001f, 1.0f}, -{0.98617500000000002f, 0.71315300000000004f, 0.103863f, 1.0f}, -{0.98556600000000005f, 0.72078200000000003f, 0.112229f, 1.0f}, -{0.98486499999999999f, 0.72842700000000005f, 0.120785f, 1.0f}, -{0.98407500000000003f, 0.73608700000000005f, 0.129527f, 1.0f}, -{0.98319599999999996f, 0.74375800000000003f, 0.13845299999999999f, 1.0f}, -{0.98222799999999999f, 0.75144200000000005f, 0.147565f, 1.0f}, -{0.98117299999999996f, 0.759135f, 0.156863f, 1.0f}, -{0.98003200000000001f, 0.76683699999999999f, 0.166353f, 1.0f}, -{0.97880599999999995f, 0.77454500000000004f, 0.176037f, 1.0f}, -{0.97749699999999995f, 0.78225800000000001f, 0.185923f, 1.0f}, -{0.97610799999999998f, 0.78997399999999995f, 0.196018f, 1.0f}, -{0.974638f, 0.79769199999999996f, 0.20633199999999999f, 1.0f}, -{0.97308799999999995f, 0.80540900000000004f, 0.21687699999999999f, 1.0f}, -{0.971468f, 0.81312200000000001f, 0.227658f, 1.0f}, -{0.96978299999999995f, 0.82082500000000003f, 0.23868600000000001f, 1.0f}, -{0.96804100000000004f, 0.828515f, 0.249972f, 1.0f}, -{0.96624299999999996f, 0.83619100000000002f, 0.26153399999999999f, 1.0f}, -{0.96439399999999997f, 0.84384800000000004f, 0.273391f, 1.0f}, -{0.96251699999999996f, 0.85147600000000001f, 0.28554600000000002f, 1.0f}, -{0.96062599999999998f, 0.85906899999999997f, 0.29801f, 1.0f}, -{0.95872000000000002f, 0.86662399999999995f, 0.31081999999999999f, 1.0f}, -{0.95683399999999996f, 0.87412900000000004f, 0.32397399999999998f, 1.0f}, -{0.95499699999999998f, 0.88156900000000005f, 0.33747500000000002f, 1.0f}, -{0.95321500000000003f, 0.88894200000000001f, 0.35136899999999999f, 1.0f}, -{0.951546f, 0.89622599999999997f, 0.36562699999999998f, 1.0f}, -{0.95001800000000003f, 0.90340900000000002f, 0.38027100000000003f, 1.0f}, -{0.94868300000000005f, 0.91047299999999998f, 0.395289f, 1.0f}, -{0.94759400000000005f, 0.91739899999999996f, 0.410665f, 1.0f}, -{0.94680900000000001f, 0.92416799999999999f, 0.426373f, 1.0f}, -{0.94639200000000001f, 0.93076099999999995f, 0.44236700000000001f, 1.0f}, -{0.94640299999999999f, 0.93715899999999996f, 0.458592f, 1.0f}, -{0.94690300000000005f, 0.94334799999999996f, 0.47497f, 1.0f}, -{0.94793700000000003f, 0.949318f, 0.49142599999999997f, 1.0f}, -{0.94954499999999997f, 0.955063f, 0.50785999999999998f, 1.0f}, -{0.95174000000000003f, 0.96058699999999997f, 0.52420299999999997f, 1.0f}, -{0.95452899999999996f, 0.96589599999999998f, 0.54036099999999998f, 1.0f}, -{0.95789599999999997f, 0.97100299999999995f, 0.55627499999999996f, 1.0f}, -{0.961812f, 0.97592400000000001f, 0.57192500000000002f, 1.0f}, -{0.96624900000000002f, 0.98067800000000005f, 0.58720600000000001f, 1.0f}, -{0.97116199999999997f, 0.98528199999999999f, 0.60215399999999997f, 1.0f}, -{0.97651100000000002f, 0.98975299999999999f, 0.61675999999999997f, 1.0f}, -{0.98225700000000005f, 0.99410900000000002f, 0.63101700000000005f, 1.0f}, -{0.98836199999999996f, 0.99836400000000003f, 0.64492400000000005f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/perceptual/inferno.txt b/extern/tfn/colormaps/perceptual/inferno.txt deleted file mode 100644 index 0b3487c..0000000 --- a/extern/tfn/colormaps/perceptual/inferno.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.001462, 0.000466, 0.013866, 1.0) -(0.0022669999999999999, 0.0012700000000000001, 0.01857, 1.0) -(0.0032989999999999998, 0.0022490000000000001, 0.024239, 1.0) -(0.0045469999999999998, 0.003392, 0.030908999999999999, 1.0) -(0.0060060000000000001, 0.004692, 0.038558000000000002, 1.0) -(0.0076759999999999997, 0.006136, 0.046836000000000003, 1.0) -(0.0095610000000000001, 0.0077130000000000002, 0.055142999999999998, 1.0) -(0.011663, 0.009417, 0.063460000000000003, 1.0) -(0.013995, 0.011225000000000001, 0.071861999999999995, 1.0) -(0.016560999999999999, 0.013136, 0.080282000000000006, 1.0) -(0.019373000000000001, 0.015133000000000001, 0.088766999999999999, 1.0) -(0.022447000000000002, 0.017198999999999999, 0.097326999999999997, 1.0) -(0.025793, 0.019331000000000001, 0.10593, 1.0) -(0.029432, 0.021503000000000001, 0.114621, 1.0) -(0.033384999999999998, 0.023702000000000001, 0.12339700000000001, 1.0) -(0.037668, 0.025921, 0.13223199999999999, 1.0) -(0.042252999999999999, 0.028139000000000001, 0.14114099999999999, 1.0) -(0.046914999999999998, 0.030324, 0.15016399999999999, 1.0) -(0.051644000000000002, 0.032474000000000003, 0.15925400000000001, 1.0) -(0.056448999999999999, 0.034569000000000003, 0.16841400000000001, 1.0) -(0.061339999999999999, 0.036589999999999998, 0.17764199999999999, 1.0) -(0.066331000000000001, 0.038503999999999997, 0.18696199999999999, 1.0) -(0.071429000000000006, 0.040294000000000003, 0.196354, 1.0) -(0.076636999999999997, 0.041904999999999998, 0.20579900000000001, 1.0) -(0.081961999999999993, 0.043327999999999998, 0.21528900000000001, 1.0) -(0.087411000000000003, 0.044555999999999998, 0.22481300000000001, 1.0) -(0.092990000000000003, 0.045582999999999999, 0.23435800000000001, 1.0) -(0.098701999999999998, 0.046401999999999999, 0.24390400000000001, 1.0) -(0.10455100000000001, 0.047008000000000001, 0.25342999999999999, 1.0) -(0.110536, 0.047398999999999997, 0.26291199999999998, 1.0) -(0.116656, 0.047573999999999998, 0.27232099999999998, 1.0) -(0.122908, 0.047536000000000002, 0.28162399999999999, 1.0) -(0.12928500000000001, 0.047293000000000002, 0.29078799999999999, 1.0) -(0.13577800000000001, 0.046856000000000002, 0.29977599999999999, 1.0) -(0.142378, 0.046241999999999998, 0.30855300000000002, 1.0) -(0.14907300000000001, 0.045468000000000001, 0.31708500000000001, 1.0) -(0.15584999999999999, 0.044559000000000001, 0.32533800000000002, 1.0) -(0.162689, 0.043554000000000002, 0.33327699999999999, 1.0) -(0.169575, 0.042488999999999999, 0.34087400000000001, 1.0) -(0.17649300000000001, 0.041402000000000001, 0.348111, 1.0) -(0.18342900000000001, 0.040328999999999997, 0.35497099999999998, 1.0) -(0.19036700000000001, 0.039308999999999997, 0.36144700000000002, 1.0) -(0.197297, 0.038399999999999997, 0.367535, 1.0) -(0.204209, 0.037631999999999999, 0.37323800000000001, 1.0) -(0.211095, 0.03703, 0.37856299999999998, 1.0) -(0.217949, 0.036615000000000002, 0.38352199999999997, 1.0) -(0.22476299999999999, 0.036405, 0.388129, 1.0) -(0.23153799999999999, 0.036405, 0.39240000000000003, 1.0) -(0.23827300000000001, 0.036621000000000001, 0.39635300000000001, 1.0) -(0.24496699999999999, 0.037054999999999998, 0.400007, 1.0) -(0.25162000000000001, 0.037705000000000002, 0.40337800000000001, 1.0) -(0.25823400000000002, 0.038571000000000001, 0.40648499999999999, 1.0) -(0.26480999999999999, 0.039647000000000002, 0.40934500000000001, 1.0) -(0.271347, 0.040922, 0.41197600000000001, 1.0) -(0.27784999999999999, 0.042353000000000002, 0.41439199999999998, 1.0) -(0.28432099999999999, 0.043933, 0.41660799999999998, 1.0) -(0.29076299999999999, 0.045643999999999997, 0.41863699999999998, 1.0) -(0.297178, 0.047469999999999998, 0.420491, 1.0) -(0.303568, 0.049396000000000002, 0.422182, 1.0) -(0.30993500000000002, 0.051407000000000001, 0.42372100000000001, 1.0) -(0.31628200000000001, 0.053490000000000003, 0.42511599999999999, 1.0) -(0.32261000000000001, 0.055634000000000003, 0.42637700000000001, 1.0) -(0.32892100000000002, 0.057827000000000003, 0.42751099999999997, 1.0) -(0.33521699999999999, 0.060060000000000002, 0.42852400000000002, 1.0) -(0.34150000000000003, 0.062324999999999998, 0.429425, 1.0) -(0.347771, 0.064616000000000007, 0.43021700000000002, 1.0) -(0.35403200000000001, 0.066924999999999998, 0.43090600000000001, 1.0) -(0.36028399999999999, 0.069247000000000003, 0.43149700000000002, 1.0) -(0.36652899999999999, 0.071579000000000004, 0.43199399999999999, 1.0) -(0.37276799999999999, 0.073914999999999995, 0.43240000000000001, 1.0) -(0.37900099999999998, 0.076253000000000001, 0.43271900000000002, 1.0) -(0.38522800000000001, 0.078590999999999994, 0.43295499999999998, 1.0) -(0.391453, 0.080926999999999999, 0.43310900000000002, 1.0) -(0.39767400000000003, 0.083256999999999998, 0.43318299999999998, 1.0) -(0.40389399999999998, 0.085580000000000003, 0.43317899999999998, 1.0) -(0.41011300000000001, 0.087896000000000002, 0.43309799999999998, 1.0) -(0.41633100000000001, 0.090203000000000005, 0.43294300000000002, 1.0) -(0.42254900000000001, 0.092501, 0.43271399999999999, 1.0) -(0.42876799999999998, 0.094789999999999999, 0.43241200000000002, 1.0) -(0.43498700000000001, 0.097069000000000003, 0.43203900000000001, 1.0) -(0.44120700000000002, 0.099337999999999996, 0.43159399999999998, 1.0) -(0.44742799999999999, 0.10159700000000001, 0.43108000000000002, 1.0) -(0.45365100000000003, 0.103848, 0.43049799999999999, 1.0) -(0.45987499999999998, 0.106089, 0.42984600000000001, 1.0) -(0.46610000000000001, 0.108322, 0.42912499999999998, 1.0) -(0.47232800000000003, 0.11054700000000001, 0.42833399999999999, 1.0) -(0.47855799999999998, 0.112764, 0.42747499999999999, 1.0) -(0.48478900000000003, 0.11497400000000001, 0.42654799999999998, 1.0) -(0.49102200000000001, 0.11717900000000001, 0.42555199999999999, 1.0) -(0.497257, 0.119379, 0.42448799999999998, 1.0) -(0.50349299999999997, 0.121575, 0.42335600000000001, 1.0) -(0.50973000000000002, 0.123769, 0.42215599999999998, 1.0) -(0.51596699999999995, 0.12595999999999999, 0.42088700000000001, 1.0) -(0.52220599999999995, 0.12814999999999999, 0.41954900000000001, 1.0) -(0.52844400000000002, 0.13034100000000001, 0.41814200000000001, 1.0) -(0.53468300000000002, 0.13253400000000001, 0.41666700000000001, 1.0) -(0.54091999999999996, 0.13472899999999999, 0.41512300000000002, 1.0) -(0.547157, 0.136929, 0.41351100000000002, 1.0) -(0.553392, 0.13913400000000001, 0.411829, 1.0) -(0.55962400000000001, 0.141346, 0.410078, 1.0) -(0.56585399999999997, 0.143567, 0.40825800000000001, 1.0) -(0.57208099999999995, 0.14579700000000001, 0.40636899999999998, 1.0) -(0.57830400000000004, 0.148039, 0.40441100000000002, 1.0) -(0.58452099999999996, 0.15029400000000001, 0.40238499999999999, 1.0) -(0.59073399999999998, 0.152563, 0.40028999999999998, 1.0) -(0.59694000000000003, 0.15484800000000001, 0.39812500000000001, 1.0) -(0.60313899999999998, 0.15715100000000001, 0.39589099999999999, 1.0) -(0.60933000000000004, 0.159474, 0.39358900000000002, 1.0) -(0.61551299999999998, 0.16181699999999999, 0.39121899999999998, 1.0) -(0.62168500000000004, 0.164184, 0.38878099999999999, 1.0) -(0.62784700000000004, 0.166575, 0.38627600000000001, 1.0) -(0.63399799999999995, 0.168992, 0.38370399999999999, 1.0) -(0.64013500000000001, 0.17143800000000001, 0.38106499999999999, 1.0) -(0.64625999999999995, 0.17391400000000001, 0.378359, 1.0) -(0.65236899999999998, 0.17642099999999999, 0.37558599999999998, 1.0) -(0.65846300000000002, 0.17896200000000001, 0.37274800000000002, 1.0) -(0.66454000000000002, 0.18153900000000001, 0.36984600000000001, 1.0) -(0.67059899999999995, 0.18415300000000001, 0.36687900000000001, 1.0) -(0.67663799999999996, 0.186807, 0.36384899999999998, 1.0) -(0.68265600000000004, 0.189501, 0.36075699999999999, 1.0) -(0.68865299999999996, 0.19223899999999999, 0.357603, 1.0) -(0.69462699999999999, 0.195021, 0.35438799999999998, 1.0) -(0.70057599999999998, 0.197851, 0.35111300000000001, 1.0) -(0.70650000000000002, 0.20072799999999999, 0.347777, 1.0) -(0.71239600000000003, 0.203656, 0.34438299999999999, 1.0) -(0.71826400000000001, 0.20663599999999999, 0.34093099999999998, 1.0) -(0.72410300000000005, 0.20967, 0.337424, 1.0) -(0.72990900000000003, 0.212759, 0.33386100000000002, 1.0) -(0.73568299999999998, 0.21590599999999999, 0.33024500000000001, 1.0) -(0.74142300000000005, 0.219112, 0.32657599999999998, 1.0) -(0.74712699999999999, 0.22237799999999999, 0.32285599999999998, 1.0) -(0.75279399999999996, 0.22570599999999999, 0.31908500000000001, 1.0) -(0.75842200000000004, 0.229097, 0.31526599999999999, 1.0) -(0.76400999999999997, 0.23255400000000001, 0.31139899999999998, 1.0) -(0.76955600000000002, 0.23607700000000001, 0.30748500000000001, 1.0) -(0.77505900000000005, 0.23966699999999999, 0.30352600000000002, 1.0) -(0.78051700000000002, 0.24332699999999999, 0.29952299999999998, 1.0) -(0.78592899999999999, 0.247056, 0.29547699999999999, 1.0) -(0.79129300000000002, 0.25085600000000002, 0.29138999999999998, 1.0) -(0.79660699999999995, 0.25472800000000001, 0.28726400000000002, 1.0) -(0.801871, 0.25867400000000002, 0.28309899999999999, 1.0) -(0.80708199999999997, 0.26269199999999998, 0.27889799999999998, 1.0) -(0.81223900000000004, 0.26678600000000002, 0.27466099999999999, 1.0) -(0.81734099999999998, 0.27095399999999997, 0.27039000000000002, 1.0) -(0.82238599999999995, 0.27519700000000002, 0.26608500000000002, 1.0) -(0.827372, 0.27951700000000002, 0.26174999999999998, 1.0) -(0.83229900000000001, 0.28391300000000003, 0.25738299999999997, 1.0) -(0.83716500000000005, 0.288385, 0.25298799999999999, 1.0) -(0.84196899999999997, 0.292933, 0.24856400000000001, 1.0) -(0.84670900000000004, 0.29755900000000002, 0.244113, 1.0) -(0.85138400000000003, 0.30225999999999997, 0.23963599999999999, 1.0) -(0.85599199999999998, 0.30703799999999998, 0.23513300000000001, 1.0) -(0.86053299999999999, 0.311892, 0.23060600000000001, 1.0) -(0.86500600000000005, 0.31682199999999999, 0.22605500000000001, 1.0) -(0.86940899999999999, 0.32182699999999997, 0.22148200000000001, 1.0) -(0.87374099999999999, 0.32690599999999997, 0.216886, 1.0) -(0.87800100000000003, 0.33206000000000002, 0.21226800000000001, 1.0) -(0.88218799999999997, 0.337287, 0.20762800000000001, 1.0) -(0.88630200000000003, 0.342586, 0.20296800000000001, 1.0) -(0.89034100000000005, 0.34795700000000002, 0.19828599999999999, 1.0) -(0.89430500000000002, 0.35339900000000002, 0.19358400000000001, 1.0) -(0.89819199999999999, 0.35891099999999998, 0.18886, 1.0) -(0.902003, 0.36449199999999998, 0.184116, 1.0) -(0.90573499999999996, 0.37014000000000002, 0.17935000000000001, 1.0) -(0.90939000000000003, 0.37585600000000002, 0.174563, 1.0) -(0.91296600000000006, 0.38163599999999998, 0.16975499999999999, 1.0) -(0.916462, 0.38748100000000002, 0.16492399999999999, 1.0) -(0.919879, 0.39338899999999999, 0.16006999999999999, 1.0) -(0.92321500000000001, 0.39935900000000002, 0.155193, 1.0) -(0.92647000000000002, 0.405389, 0.15029200000000001, 1.0) -(0.92964400000000003, 0.41147899999999998, 0.145367, 1.0) -(0.93273700000000004, 0.41762700000000003, 0.14041699999999999, 1.0) -(0.935747, 0.42383100000000001, 0.13544, 1.0) -(0.93867500000000004, 0.430091, 0.130438, 1.0) -(0.94152100000000005, 0.43640499999999999, 0.12540899999999999, 1.0) -(0.94428500000000004, 0.442772, 0.120354, 1.0) -(0.94696499999999995, 0.44919100000000001, 0.115272, 1.0) -(0.94956200000000002, 0.45566000000000001, 0.110164, 1.0) -(0.952075, 0.46217799999999998, 0.105031, 1.0) -(0.95450599999999997, 0.46874399999999999, 0.099874000000000004, 1.0) -(0.95685200000000004, 0.475356, 0.094695000000000001, 1.0) -(0.95911400000000002, 0.482014, 0.089498999999999995, 1.0) -(0.96129299999999995, 0.48871599999999998, 0.084289000000000003, 1.0) -(0.96338699999999999, 0.49546200000000001, 0.079073000000000004, 1.0) -(0.96539699999999995, 0.50224899999999995, 0.073858999999999994, 1.0) -(0.96732200000000002, 0.50907800000000003, 0.068658999999999998, 1.0) -(0.969163, 0.51594600000000002, 0.063488000000000003, 1.0) -(0.97091899999999998, 0.52285300000000001, 0.058367000000000002, 1.0) -(0.97258999999999995, 0.52979799999999999, 0.053324000000000003, 1.0) -(0.97417600000000004, 0.53678000000000003, 0.048391999999999998, 1.0) -(0.97567700000000002, 0.543798, 0.043617999999999997, 1.0) -(0.97709199999999996, 0.55084999999999995, 0.039050000000000001, 1.0) -(0.97842200000000001, 0.55793700000000002, 0.034930999999999997, 1.0) -(0.97966600000000004, 0.56505700000000003, 0.031408999999999999, 1.0) -(0.98082400000000003, 0.57220899999999997, 0.028507999999999999, 1.0) -(0.98189499999999996, 0.57939200000000002, 0.026249999999999999, 1.0) -(0.982881, 0.58660599999999996, 0.024660999999999999, 1.0) -(0.98377899999999996, 0.59384899999999996, 0.023769999999999999, 1.0) -(0.98459099999999999, 0.60112200000000005, 0.023605999999999999, 1.0) -(0.98531500000000005, 0.60842200000000002, 0.024202000000000001, 1.0) -(0.98595200000000005, 0.61575000000000002, 0.025592, 1.0) -(0.98650199999999999, 0.62310500000000002, 0.027813999999999998, 1.0) -(0.98696399999999995, 0.63048499999999996, 0.030908000000000001, 1.0) -(0.98733700000000002, 0.63788999999999996, 0.034916000000000003, 1.0) -(0.987622, 0.64532, 0.039885999999999998, 1.0) -(0.987819, 0.65277300000000005, 0.045581000000000003, 1.0) -(0.98792599999999997, 0.66025, 0.051749999999999997, 1.0) -(0.98794499999999996, 0.66774800000000001, 0.058328999999999999, 1.0) -(0.98787400000000003, 0.67526699999999995, 0.065256999999999996, 1.0) -(0.98771399999999998, 0.68280700000000005, 0.072488999999999998, 1.0) -(0.98746400000000001, 0.69036600000000004, 0.079990000000000006, 1.0) -(0.987124, 0.69794400000000001, 0.087731000000000003, 1.0) -(0.98669399999999996, 0.70553999999999994, 0.095694000000000001, 1.0) -(0.98617500000000002, 0.71315300000000004, 0.103863, 1.0) -(0.98556600000000005, 0.72078200000000003, 0.112229, 1.0) -(0.98486499999999999, 0.72842700000000005, 0.120785, 1.0) -(0.98407500000000003, 0.73608700000000005, 0.129527, 1.0) -(0.98319599999999996, 0.74375800000000003, 0.13845299999999999, 1.0) -(0.98222799999999999, 0.75144200000000005, 0.147565, 1.0) -(0.98117299999999996, 0.759135, 0.156863, 1.0) -(0.98003200000000001, 0.76683699999999999, 0.166353, 1.0) -(0.97880599999999995, 0.77454500000000004, 0.176037, 1.0) -(0.97749699999999995, 0.78225800000000001, 0.185923, 1.0) -(0.97610799999999998, 0.78997399999999995, 0.196018, 1.0) -(0.974638, 0.79769199999999996, 0.20633199999999999, 1.0) -(0.97308799999999995, 0.80540900000000004, 0.21687699999999999, 1.0) -(0.971468, 0.81312200000000001, 0.227658, 1.0) -(0.96978299999999995, 0.82082500000000003, 0.23868600000000001, 1.0) -(0.96804100000000004, 0.828515, 0.249972, 1.0) -(0.96624299999999996, 0.83619100000000002, 0.26153399999999999, 1.0) -(0.96439399999999997, 0.84384800000000004, 0.273391, 1.0) -(0.96251699999999996, 0.85147600000000001, 0.28554600000000002, 1.0) -(0.96062599999999998, 0.85906899999999997, 0.29801, 1.0) -(0.95872000000000002, 0.86662399999999995, 0.31081999999999999, 1.0) -(0.95683399999999996, 0.87412900000000004, 0.32397399999999998, 1.0) -(0.95499699999999998, 0.88156900000000005, 0.33747500000000002, 1.0) -(0.95321500000000003, 0.88894200000000001, 0.35136899999999999, 1.0) -(0.951546, 0.89622599999999997, 0.36562699999999998, 1.0) -(0.95001800000000003, 0.90340900000000002, 0.38027100000000003, 1.0) -(0.94868300000000005, 0.91047299999999998, 0.395289, 1.0) -(0.94759400000000005, 0.91739899999999996, 0.410665, 1.0) -(0.94680900000000001, 0.92416799999999999, 0.426373, 1.0) -(0.94639200000000001, 0.93076099999999995, 0.44236700000000001, 1.0) -(0.94640299999999999, 0.93715899999999996, 0.458592, 1.0) -(0.94690300000000005, 0.94334799999999996, 0.47497, 1.0) -(0.94793700000000003, 0.949318, 0.49142599999999997, 1.0) -(0.94954499999999997, 0.955063, 0.50785999999999998, 1.0) -(0.95174000000000003, 0.96058699999999997, 0.52420299999999997, 1.0) -(0.95452899999999996, 0.96589599999999998, 0.54036099999999998, 1.0) -(0.95789599999999997, 0.97100299999999995, 0.55627499999999996, 1.0) -(0.961812, 0.97592400000000001, 0.57192500000000002, 1.0) -(0.96624900000000002, 0.98067800000000005, 0.58720600000000001, 1.0) -(0.97116199999999997, 0.98528199999999999, 0.60215399999999997, 1.0) -(0.97651100000000002, 0.98975299999999999, 0.61675999999999997, 1.0) -(0.98225700000000005, 0.99410900000000002, 0.63101700000000005, 1.0) -(0.98836199999999996, 0.99836400000000003, 0.64492400000000005, 1.0) diff --git a/extern/tfn/colormaps/perceptual/magma.cpp b/extern/tfn/colormaps/perceptual/magma.cpp deleted file mode 100644 index 7cef7d1..0000000 --- a/extern/tfn/colormaps/perceptual/magma.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_perceptual_magma; -} -const std::vector colormap::data_perceptual_magma = /* NOLINT(cert-err58-cpp) */ -{ -{0.001462f, 0.000466f, 0.013866f, 1.0f}, -{0.002258f, 0.0012949999999999999f, 0.018331f, 1.0f}, -{0.0032789999999999998f, 0.0023050000000000002f, 0.023708f, 1.0f}, -{0.0045120000000000004f, 0.00349f, 0.029964999999999999f, 1.0f}, -{0.0059500000000000004f, 0.0048430000000000001f, 0.037130000000000003f, 1.0f}, -{0.0075880000000000001f, 0.0063559999999999997f, 0.044972999999999999f, 1.0f}, -{0.0094260000000000004f, 0.0080219999999999996f, 0.052844000000000002f, 1.0f}, -{0.011464999999999999f, 0.0098279999999999999f, 0.060749999999999998f, 1.0f}, -{0.013708f, 0.011771f, 0.068667000000000006f, 1.0f}, -{0.016156f, 0.01384f, 0.076603000000000004f, 1.0f}, -{0.018814999999999998f, 0.016025999999999999f, 0.084584000000000006f, 1.0f}, -{0.021691999999999999f, 0.018319999999999999f, 0.092609999999999998f, 1.0f}, -{0.024792000000000002f, 0.020715000000000001f, 0.100676f, 1.0f}, -{0.028122999999999999f, 0.023200999999999999f, 0.10878699999999999f, 1.0f}, -{0.031696000000000002f, 0.025765f, 0.116965f, 1.0f}, -{0.035520000000000003f, 0.028396999999999999f, 0.12520899999999999f, 1.0f}, -{0.039607999999999997f, 0.03109f, 0.13351499999999999f, 1.0f}, -{0.043830000000000001f, 0.033829999999999999f, 0.14188600000000001f, 1.0f}, -{0.048062000000000001f, 0.036607000000000001f, 0.15032699999999999f, 1.0f}, -{0.052319999999999998f, 0.039406999999999998f, 0.15884100000000001f, 1.0f}, -{0.056614999999999999f, 0.042160000000000003f, 0.16744600000000001f, 1.0f}, -{0.060949000000000003f, 0.044794f, 0.17612900000000001f, 1.0f}, -{0.065329999999999999f, 0.047317999999999999f, 0.184892f, 1.0f}, -{0.069764000000000007f, 0.049725999999999999f, 0.19373499999999999f, 1.0f}, -{0.074257000000000004f, 0.052017000000000001f, 0.20266000000000001f, 1.0f}, -{0.078814999999999996f, 0.054184000000000003f, 0.21166699999999999f, 1.0f}, -{0.083446000000000006f, 0.056224999999999997f, 0.22075500000000001f, 1.0f}, -{0.088154999999999997f, 0.058132999999999997f, 0.22992199999999999f, 1.0f}, -{0.092949000000000004f, 0.059903999999999999f, 0.23916399999999999f, 1.0f}, -{0.097833000000000003f, 0.061531000000000002f, 0.248477f, 1.0f}, -{0.102815f, 0.063009999999999997f, 0.25785400000000003f, 1.0f}, -{0.10789899999999999f, 0.064335000000000003f, 0.267289f, 1.0f}, -{0.113094f, 0.065491999999999995f, 0.27678399999999997f, 1.0f}, -{0.118405f, 0.066478999999999996f, 0.28632099999999999f, 1.0f}, -{0.123833f, 0.067294999999999994f, 0.295879f, 1.0f}, -{0.12938f, 0.067934999999999995f, 0.30544300000000002f, 1.0f}, -{0.13505300000000001f, 0.068390999999999993f, 0.315f, 1.0f}, -{0.14085800000000001f, 0.068654000000000007f, 0.32453799999999999f, 1.0f}, -{0.146785f, 0.068737999999999994f, 0.334011f, 1.0f}, -{0.152839f, 0.068637000000000004f, 0.34340399999999999f, 1.0f}, -{0.15901799999999999f, 0.068353999999999998f, 0.352688f, 1.0f}, -{0.16530800000000001f, 0.067910999999999999f, 0.36181600000000003f, 1.0f}, -{0.171713f, 0.067305000000000004f, 0.37077100000000002f, 1.0f}, -{0.17821200000000001f, 0.066575999999999996f, 0.37949699999999997f, 1.0f}, -{0.18480099999999999f, 0.065731999999999999f, 0.38797300000000001f, 1.0f}, -{0.19145999999999999f, 0.064818000000000001f, 0.396152f, 1.0f}, -{0.19817699999999999f, 0.063862000000000002f, 0.40400900000000001f, 1.0f}, -{0.20493500000000001f, 0.062907000000000005f, 0.41151399999999999f, 1.0f}, -{0.21171799999999999f, 0.061991999999999998f, 0.41864699999999999f, 1.0f}, -{0.21851200000000001f, 0.061157999999999997f, 0.42539199999999999f, 1.0f}, -{0.225302f, 0.060444999999999999f, 0.43174200000000001f, 1.0f}, -{0.23207700000000001f, 0.059888999999999998f, 0.437695f, 1.0f}, -{0.23882600000000001f, 0.059517f, 0.44325599999999998f, 1.0f}, -{0.24554300000000001f, 0.059352000000000002f, 0.448436f, 1.0f}, -{0.25222f, 0.059415000000000003f, 0.45324799999999998f, 1.0f}, -{0.258857f, 0.059706000000000002f, 0.45771000000000001f, 1.0f}, -{0.26544699999999999f, 0.060236999999999999f, 0.46183999999999997f, 1.0f}, -{0.27199400000000001f, 0.060994f, 0.46566000000000002f, 1.0f}, -{0.27849299999999999f, 0.061977999999999998f, 0.46919f, 1.0f}, -{0.28495100000000001f, 0.063168000000000002f, 0.47245100000000001f, 1.0f}, -{0.29136600000000001f, 0.064552999999999999f, 0.475462f, 1.0f}, -{0.29774f, 0.066116999999999995f, 0.47824299999999997f, 1.0f}, -{0.30408099999999999f, 0.067835000000000006f, 0.48081200000000002f, 1.0f}, -{0.31038199999999999f, 0.069702f, 0.483186f, 1.0f}, -{0.31665399999999999f, 0.071690000000000004f, 0.48537999999999998f, 1.0f}, -{0.32289899999999999f, 0.073782f, 0.48740800000000001f, 1.0f}, -{0.32911400000000002f, 0.075971999999999998f, 0.48928700000000003f, 1.0f}, -{0.33530799999999999f, 0.078236f, 0.49102400000000002f, 1.0f}, -{0.34148200000000001f, 0.080563999999999997f, 0.49263099999999999f, 1.0f}, -{0.347636f, 0.082946000000000006f, 0.49412099999999998f, 1.0f}, -{0.353773f, 0.085373000000000004f, 0.49550100000000002f, 1.0f}, -{0.359898f, 0.087831000000000006f, 0.496778f, 1.0f}, -{0.366012f, 0.090314000000000005f, 0.49796000000000001f, 1.0f}, -{0.372116f, 0.092815999999999996f, 0.49905300000000002f, 1.0f}, -{0.37821100000000002f, 0.095332f, 0.50006700000000004f, 1.0f}, -{0.384299f, 0.097854999999999998f, 0.50100199999999995f, 1.0f}, -{0.39038400000000001f, 0.100379f, 0.50186399999999998f, 1.0f}, -{0.39646700000000001f, 0.10290199999999999f, 0.50265800000000005f, 1.0f}, -{0.40254800000000002f, 0.10542f, 0.503386f, 1.0f}, -{0.40862900000000002f, 0.10793f, 0.50405199999999994f, 1.0f}, -{0.41470899999999999f, 0.110431f, 0.50466200000000005f, 1.0f}, -{0.42079100000000003f, 0.11292000000000001f, 0.50521499999999997f, 1.0f}, -{0.42687700000000001f, 0.115395f, 0.505714f, 1.0f}, -{0.43296699999999999f, 0.117855f, 0.50616000000000005f, 1.0f}, -{0.43906200000000001f, 0.120298f, 0.50655499999999998f, 1.0f}, -{0.44516299999999998f, 0.122724f, 0.50690100000000005f, 1.0f}, -{0.45127099999999998f, 0.12513199999999999f, 0.50719800000000004f, 1.0f}, -{0.45738600000000001f, 0.127522f, 0.50744800000000001f, 1.0f}, -{0.46350799999999998f, 0.12989300000000001f, 0.50765199999999999f, 1.0f}, -{0.46964f, 0.132245f, 0.50780899999999995f, 1.0f}, -{0.47577999999999998f, 0.134577f, 0.50792099999999996f, 1.0f}, -{0.481929f, 0.13689100000000001f, 0.50798900000000002f, 1.0f}, -{0.48808800000000002f, 0.139186f, 0.50801099999999999f, 1.0f}, -{0.49425799999999998f, 0.141462f, 0.507988f, 1.0f}, -{0.50043800000000005f, 0.14371900000000001f, 0.50792000000000004f, 1.0f}, -{0.506629f, 0.145958f, 0.50780599999999998f, 1.0f}, -{0.51283100000000004f, 0.14817900000000001f, 0.50764799999999999f, 1.0f}, -{0.51904499999999998f, 0.15038299999999999f, 0.50744299999999998f, 1.0f}, -{0.52527000000000001f, 0.15256900000000001f, 0.50719199999999998f, 1.0f}, -{0.53150699999999995f, 0.15473899999999999f, 0.50689499999999998f, 1.0f}, -{0.53775499999999998f, 0.15689400000000001f, 0.50655099999999997f, 1.0f}, -{0.54401500000000003f, 0.15903300000000001f, 0.50615900000000003f, 1.0f}, -{0.55028699999999997f, 0.161158f, 0.50571900000000003f, 1.0f}, -{0.55657100000000004f, 0.163269f, 0.50522999999999996f, 1.0f}, -{0.56286599999999998f, 0.16536799999999999f, 0.50469200000000003f, 1.0f}, -{0.56917200000000001f, 0.16745399999999999f, 0.50410500000000003f, 1.0f}, -{0.57548999999999995f, 0.16952999999999999f, 0.50346599999999997f, 1.0f}, -{0.58181899999999998f, 0.171596f, 0.50277700000000003f, 1.0f}, -{0.58815799999999996f, 0.173652f, 0.50203500000000001f, 1.0f}, -{0.59450800000000004f, 0.175701f, 0.50124100000000005f, 1.0f}, -{0.60086799999999996f, 0.17774300000000001f, 0.50039400000000001f, 1.0f}, -{0.60723800000000006f, 0.17977899999999999f, 0.49949199999999999f, 1.0f}, -{0.61361699999999997f, 0.181811f, 0.49853599999999998f, 1.0f}, -{0.62000500000000003f, 0.18384f, 0.49752400000000002f, 1.0f}, -{0.62640099999999999f, 0.185867f, 0.49645600000000001f, 1.0f}, -{0.63280499999999995f, 0.187893f, 0.49533199999999999f, 1.0f}, -{0.63921600000000001f, 0.18992100000000001f, 0.49414999999999998f, 1.0f}, -{0.64563300000000001f, 0.19195200000000001f, 0.49291000000000001f, 1.0f}, -{0.65205599999999997f, 0.19398599999999999f, 0.49161100000000002f, 1.0f}, -{0.65848300000000004f, 0.19602700000000001f, 0.49025299999999999f, 1.0f}, -{0.66491500000000003f, 0.198075f, 0.48883599999999999f, 1.0f}, -{0.67134899999999997f, 0.20013300000000001f, 0.48735800000000001f, 1.0f}, -{0.677786f, 0.20220299999999999f, 0.485819f, 1.0f}, -{0.68422400000000005f, 0.204286f, 0.48421900000000001f, 1.0f}, -{0.69066099999999997f, 0.20638400000000001f, 0.48255799999999999f, 1.0f}, -{0.697098f, 0.20850099999999999f, 0.48083500000000001f, 1.0f}, -{0.70353200000000005f, 0.21063799999999999f, 0.479049f, 1.0f}, -{0.70996199999999998f, 0.21279699999999999f, 0.47720099999999999f, 1.0f}, -{0.716387f, 0.21498200000000001f, 0.47528999999999999f, 1.0f}, -{0.72280500000000003f, 0.217194f, 0.47331600000000001f, 1.0f}, -{0.72921599999999998f, 0.21943699999999999f, 0.471279f, 1.0f}, -{0.73561600000000005f, 0.22171299999999999f, 0.46917999999999999f, 1.0f}, -{0.742004f, 0.224025f, 0.46701799999999999f, 1.0f}, -{0.74837799999999999f, 0.22637699999999999f, 0.46479399999999998f, 1.0f}, -{0.75473699999999999f, 0.228772f, 0.462509f, 1.0f}, -{0.761077f, 0.231214f, 0.46016200000000002f, 1.0f}, -{0.76739800000000002f, 0.233705f, 0.45775500000000002f, 1.0f}, -{0.77369500000000002f, 0.23624899999999999f, 0.455289f, 1.0f}, -{0.77996799999999999f, 0.23885100000000001f, 0.45276499999999997f, 1.0f}, -{0.78621200000000002f, 0.24151400000000001f, 0.45018399999999997f, 1.0f}, -{0.79242699999999999f, 0.24424199999999999f, 0.44754300000000002f, 1.0f}, -{0.79860799999999998f, 0.24704000000000001f, 0.44484800000000002f, 1.0f}, -{0.80475200000000002f, 0.24991099999999999f, 0.44210199999999999f, 1.0f}, -{0.81085499999999999f, 0.252861f, 0.439305f, 1.0f}, -{0.81691400000000003f, 0.25589499999999998f, 0.43646099999999999f, 1.0f}, -{0.82292600000000005f, 0.25901600000000002f, 0.43357299999999999f, 1.0f}, -{0.82888600000000001f, 0.26222899999999999f, 0.43064400000000003f, 1.0f}, -{0.83479099999999995f, 0.26554f, 0.42767100000000002f, 1.0f}, -{0.84063600000000005f, 0.268953f, 0.42466599999999999f, 1.0f}, -{0.84641599999999995f, 0.27247300000000002f, 0.42163099999999998f, 1.0f}, -{0.85212600000000005f, 0.27610600000000002f, 0.41857299999999997f, 1.0f}, -{0.85776300000000005f, 0.27985700000000002f, 0.41549599999999998f, 1.0f}, -{0.86331999999999998f, 0.28372900000000001f, 0.41240300000000002f, 1.0f}, -{0.86879300000000004f, 0.28772799999999998f, 0.40930299999999997f, 1.0f}, -{0.87417599999999995f, 0.29185899999999998f, 0.40620499999999998f, 1.0f}, -{0.87946400000000002f, 0.29612500000000003f, 0.40311799999999998f, 1.0f}, -{0.88465099999999997f, 0.30053000000000002f, 0.40004699999999999f, 1.0f}, -{0.88973100000000005f, 0.30507899999999999f, 0.39700200000000002f, 1.0f}, -{0.89470000000000005f, 0.30977300000000002f, 0.39399499999999998f, 1.0f}, -{0.89955200000000002f, 0.31461600000000001f, 0.39103700000000002f, 1.0f}, -{0.904281f, 0.31961000000000001f, 0.38813700000000001f, 1.0f}, -{0.90888400000000003f, 0.32475500000000002f, 0.38530799999999998f, 1.0f}, -{0.913354f, 0.33005200000000001f, 0.38256299999999999f, 1.0f}, -{0.91768899999999998f, 0.33550000000000002f, 0.379915f, 1.0f}, -{0.92188400000000004f, 0.34109800000000001f, 0.37737599999999999f, 1.0f}, -{0.92593700000000001f, 0.34684399999999999f, 0.37495899999999999f, 1.0f}, -{0.92984500000000003f, 0.35273399999999999f, 0.37267699999999998f, 1.0f}, -{0.93360600000000005f, 0.35876400000000003f, 0.37054100000000001f, 1.0f}, -{0.93722099999999997f, 0.364929f, 0.36856699999999998f, 1.0f}, -{0.94068700000000005f, 0.371224f, 0.36676199999999998f, 1.0f}, -{0.94400600000000001f, 0.37764300000000001f, 0.36513600000000002f, 1.0f}, -{0.94718000000000002f, 0.38417800000000002f, 0.363701f, 1.0f}, -{0.95021f, 0.39082f, 0.36246800000000001f, 1.0f}, -{0.95309900000000003f, 0.397563f, 0.36143799999999998f, 1.0f}, -{0.95584899999999995f, 0.40439999999999998f, 0.36061900000000002f, 1.0f}, -{0.95846399999999998f, 0.41132400000000002f, 0.360014f, 1.0f}, -{0.96094900000000005f, 0.418323f, 0.35963000000000001f, 1.0f}, -{0.96331f, 0.42538999999999999f, 0.35946899999999998f, 1.0f}, -{0.96554899999999999f, 0.43251899999999999f, 0.35952899999999999f, 1.0f}, -{0.96767099999999995f, 0.43970300000000001f, 0.35981000000000002f, 1.0f}, -{0.96967999999999999f, 0.446936f, 0.36031099999999999f, 1.0f}, -{0.97158199999999995f, 0.45421f, 0.36103000000000002f, 1.0f}, -{0.97338100000000005f, 0.46151999999999999f, 0.36196499999999998f, 1.0f}, -{0.975082f, 0.46886100000000003f, 0.36311100000000002f, 1.0f}, -{0.97668999999999995f, 0.47622599999999998f, 0.36446600000000001f, 1.0f}, -{0.97821000000000002f, 0.48361199999999999f, 0.36602499999999999f, 1.0f}, -{0.97964499999999999f, 0.49101400000000001f, 0.36778300000000003f, 1.0f}, -{0.98099999999999998f, 0.49842799999999998f, 0.36973400000000001f, 1.0f}, -{0.98227900000000001f, 0.50585100000000005f, 0.37187399999999998f, 1.0f}, -{0.98348500000000005f, 0.51327999999999996f, 0.37419799999999998f, 1.0f}, -{0.984622f, 0.52071299999999998f, 0.37669799999999998f, 1.0f}, -{0.98569300000000004f, 0.52814799999999995f, 0.37937100000000001f, 1.0f}, -{0.98670000000000002f, 0.535582f, 0.38220999999999999f, 1.0f}, -{0.98764600000000002f, 0.54301500000000003f, 0.38521f, 1.0f}, -{0.988533f, 0.55044599999999999f, 0.38836500000000002f, 1.0f}, -{0.98936299999999999f, 0.55787299999999995f, 0.39167099999999999f, 1.0f}, -{0.99013799999999996f, 0.56529600000000002f, 0.39512199999999997f, 1.0f}, -{0.99087099999999995f, 0.57270600000000005f, 0.39871400000000001f, 1.0f}, -{0.99155800000000005f, 0.58010700000000004f, 0.40244099999999999f, 1.0f}, -{0.99219599999999997f, 0.58750199999999997f, 0.40629900000000002f, 1.0f}, -{0.99278500000000003f, 0.59489099999999995f, 0.41028300000000001f, 1.0f}, -{0.99332600000000004f, 0.602275f, 0.41438999999999998f, 1.0f}, -{0.993834f, 0.60964399999999996f, 0.41861300000000001f, 1.0f}, -{0.994309f, 0.61699899999999996f, 0.42294999999999999f, 1.0f}, -{0.99473800000000001f, 0.62434999999999996f, 0.42739700000000003f, 1.0f}, -{0.99512199999999995f, 0.63169600000000004f, 0.43195099999999997f, 1.0f}, -{0.99548000000000003f, 0.63902700000000001f, 0.43660700000000002f, 1.0f}, -{0.99580999999999997f, 0.64634400000000003f, 0.441361f, 1.0f}, -{0.99609599999999998f, 0.65365899999999999f, 0.44621300000000003f, 1.0f}, -{0.99634100000000003f, 0.66096900000000003f, 0.45116000000000001f, 1.0f}, -{0.99658000000000002f, 0.66825599999999996f, 0.45619199999999999f, 1.0f}, -{0.99677499999999997f, 0.67554099999999995f, 0.461314f, 1.0f}, -{0.99692499999999995f, 0.68282799999999999f, 0.466526f, 1.0f}, -{0.99707699999999999f, 0.69008800000000003f, 0.47181099999999998f, 1.0f}, -{0.99718600000000002f, 0.697349f, 0.477182f, 1.0f}, -{0.99725399999999997f, 0.70461099999999999f, 0.48263499999999998f, 1.0f}, -{0.99732500000000002f, 0.71184800000000004f, 0.48815399999999998f, 1.0f}, -{0.99735099999999999f, 0.71908899999999998f, 0.493755f, 1.0f}, -{0.99735099999999999f, 0.72632399999999997f, 0.49942799999999998f, 1.0f}, -{0.99734100000000003f, 0.733545f, 0.50516700000000003f, 1.0f}, -{0.99728499999999998f, 0.74077199999999999f, 0.51098299999999997f, 1.0f}, -{0.997228f, 0.74798100000000001f, 0.51685899999999996f, 1.0f}, -{0.99713799999999997f, 0.75519000000000003f, 0.52280599999999999f, 1.0f}, -{0.99701899999999999f, 0.76239800000000002f, 0.52882099999999999f, 1.0f}, -{0.99689799999999995f, 0.76959100000000003f, 0.53489200000000003f, 1.0f}, -{0.99672700000000003f, 0.77679500000000001f, 0.54103900000000005f, 1.0f}, -{0.99657099999999998f, 0.78397700000000003f, 0.54723299999999997f, 1.0f}, -{0.99636899999999995f, 0.79116699999999995f, 0.55349899999999996f, 1.0f}, -{0.99616199999999999f, 0.79834799999999995f, 0.55981999999999998f, 1.0f}, -{0.99593200000000004f, 0.80552699999999999f, 0.56620199999999998f, 1.0f}, -{0.99568000000000001f, 0.81270600000000004f, 0.57264499999999996f, 1.0f}, -{0.99542399999999998f, 0.81987500000000002f, 0.57913999999999999f, 1.0f}, -{0.99513099999999999f, 0.82705200000000001f, 0.58570100000000003f, 1.0f}, -{0.99485100000000004f, 0.83421299999999998f, 0.59230700000000003f, 1.0f}, -{0.99452399999999996f, 0.841387f, 0.59898300000000004f, 1.0f}, -{0.99422200000000005f, 0.84853999999999996f, 0.60569600000000001f, 1.0f}, -{0.99386600000000003f, 0.855711f, 0.61248199999999997f, 1.0f}, -{0.99354500000000001f, 0.86285900000000004f, 0.61929900000000004f, 1.0f}, -{0.99317f, 0.87002400000000002f, 0.626189f, 1.0f}, -{0.99283100000000002f, 0.87716799999999995f, 0.63310900000000003f, 1.0f}, -{0.99243999999999999f, 0.88432999999999995f, 0.64009899999999997f, 1.0f}, -{0.992089f, 0.89146999999999998f, 0.64711600000000002f, 1.0f}, -{0.99168800000000001f, 0.89862699999999995f, 0.65420199999999995f, 1.0f}, -{0.99133199999999999f, 0.90576299999999998f, 0.66130900000000004f, 1.0f}, -{0.99092999999999998f, 0.91291500000000003f, 0.66848099999999999f, 1.0f}, -{0.99056999999999995f, 0.92004900000000001f, 0.67567500000000003f, 1.0f}, -{0.99017500000000003f, 0.92719600000000002f, 0.68292600000000003f, 1.0f}, -{0.989815f, 0.93432899999999997f, 0.69019799999999998f, 1.0f}, -{0.98943400000000004f, 0.94147000000000003f, 0.697519f, 1.0f}, -{0.98907699999999998f, 0.948604f, 0.70486300000000002f, 1.0f}, -{0.98871699999999996f, 0.95574199999999998f, 0.71224200000000004f, 1.0f}, -{0.988367f, 0.96287800000000001f, 0.71964899999999998f, 1.0f}, -{0.98803300000000005f, 0.97001199999999999f, 0.72707699999999997f, 1.0f}, -{0.98769099999999999f, 0.97715399999999997f, 0.73453599999999997f, 1.0f}, -{0.98738700000000001f, 0.98428800000000005f, 0.74200200000000005f, 1.0f}, -{0.98705299999999996f, 0.99143800000000004f, 0.74950399999999995f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/perceptual/magma.txt b/extern/tfn/colormaps/perceptual/magma.txt deleted file mode 100644 index 2cb8d6e..0000000 --- a/extern/tfn/colormaps/perceptual/magma.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.001462, 0.000466, 0.013866, 1.0) -(0.002258, 0.0012949999999999999, 0.018331, 1.0) -(0.0032789999999999998, 0.0023050000000000002, 0.023708, 1.0) -(0.0045120000000000004, 0.00349, 0.029964999999999999, 1.0) -(0.0059500000000000004, 0.0048430000000000001, 0.037130000000000003, 1.0) -(0.0075880000000000001, 0.0063559999999999997, 0.044972999999999999, 1.0) -(0.0094260000000000004, 0.0080219999999999996, 0.052844000000000002, 1.0) -(0.011464999999999999, 0.0098279999999999999, 0.060749999999999998, 1.0) -(0.013708, 0.011771, 0.068667000000000006, 1.0) -(0.016156, 0.01384, 0.076603000000000004, 1.0) -(0.018814999999999998, 0.016025999999999999, 0.084584000000000006, 1.0) -(0.021691999999999999, 0.018319999999999999, 0.092609999999999998, 1.0) -(0.024792000000000002, 0.020715000000000001, 0.100676, 1.0) -(0.028122999999999999, 0.023200999999999999, 0.10878699999999999, 1.0) -(0.031696000000000002, 0.025765, 0.116965, 1.0) -(0.035520000000000003, 0.028396999999999999, 0.12520899999999999, 1.0) -(0.039607999999999997, 0.03109, 0.13351499999999999, 1.0) -(0.043830000000000001, 0.033829999999999999, 0.14188600000000001, 1.0) -(0.048062000000000001, 0.036607000000000001, 0.15032699999999999, 1.0) -(0.052319999999999998, 0.039406999999999998, 0.15884100000000001, 1.0) -(0.056614999999999999, 0.042160000000000003, 0.16744600000000001, 1.0) -(0.060949000000000003, 0.044794, 0.17612900000000001, 1.0) -(0.065329999999999999, 0.047317999999999999, 0.184892, 1.0) -(0.069764000000000007, 0.049725999999999999, 0.19373499999999999, 1.0) -(0.074257000000000004, 0.052017000000000001, 0.20266000000000001, 1.0) -(0.078814999999999996, 0.054184000000000003, 0.21166699999999999, 1.0) -(0.083446000000000006, 0.056224999999999997, 0.22075500000000001, 1.0) -(0.088154999999999997, 0.058132999999999997, 0.22992199999999999, 1.0) -(0.092949000000000004, 0.059903999999999999, 0.23916399999999999, 1.0) -(0.097833000000000003, 0.061531000000000002, 0.248477, 1.0) -(0.102815, 0.063009999999999997, 0.25785400000000003, 1.0) -(0.10789899999999999, 0.064335000000000003, 0.267289, 1.0) -(0.113094, 0.065491999999999995, 0.27678399999999997, 1.0) -(0.118405, 0.066478999999999996, 0.28632099999999999, 1.0) -(0.123833, 0.067294999999999994, 0.295879, 1.0) -(0.12938, 0.067934999999999995, 0.30544300000000002, 1.0) -(0.13505300000000001, 0.068390999999999993, 0.315, 1.0) -(0.14085800000000001, 0.068654000000000007, 0.32453799999999999, 1.0) -(0.146785, 0.068737999999999994, 0.334011, 1.0) -(0.152839, 0.068637000000000004, 0.34340399999999999, 1.0) -(0.15901799999999999, 0.068353999999999998, 0.352688, 1.0) -(0.16530800000000001, 0.067910999999999999, 0.36181600000000003, 1.0) -(0.171713, 0.067305000000000004, 0.37077100000000002, 1.0) -(0.17821200000000001, 0.066575999999999996, 0.37949699999999997, 1.0) -(0.18480099999999999, 0.065731999999999999, 0.38797300000000001, 1.0) -(0.19145999999999999, 0.064818000000000001, 0.396152, 1.0) -(0.19817699999999999, 0.063862000000000002, 0.40400900000000001, 1.0) -(0.20493500000000001, 0.062907000000000005, 0.41151399999999999, 1.0) -(0.21171799999999999, 0.061991999999999998, 0.41864699999999999, 1.0) -(0.21851200000000001, 0.061157999999999997, 0.42539199999999999, 1.0) -(0.225302, 0.060444999999999999, 0.43174200000000001, 1.0) -(0.23207700000000001, 0.059888999999999998, 0.437695, 1.0) -(0.23882600000000001, 0.059517, 0.44325599999999998, 1.0) -(0.24554300000000001, 0.059352000000000002, 0.448436, 1.0) -(0.25222, 0.059415000000000003, 0.45324799999999998, 1.0) -(0.258857, 0.059706000000000002, 0.45771000000000001, 1.0) -(0.26544699999999999, 0.060236999999999999, 0.46183999999999997, 1.0) -(0.27199400000000001, 0.060994, 0.46566000000000002, 1.0) -(0.27849299999999999, 0.061977999999999998, 0.46919, 1.0) -(0.28495100000000001, 0.063168000000000002, 0.47245100000000001, 1.0) -(0.29136600000000001, 0.064552999999999999, 0.475462, 1.0) -(0.29774, 0.066116999999999995, 0.47824299999999997, 1.0) -(0.30408099999999999, 0.067835000000000006, 0.48081200000000002, 1.0) -(0.31038199999999999, 0.069702, 0.483186, 1.0) -(0.31665399999999999, 0.071690000000000004, 0.48537999999999998, 1.0) -(0.32289899999999999, 0.073782, 0.48740800000000001, 1.0) -(0.32911400000000002, 0.075971999999999998, 0.48928700000000003, 1.0) -(0.33530799999999999, 0.078236, 0.49102400000000002, 1.0) -(0.34148200000000001, 0.080563999999999997, 0.49263099999999999, 1.0) -(0.347636, 0.082946000000000006, 0.49412099999999998, 1.0) -(0.353773, 0.085373000000000004, 0.49550100000000002, 1.0) -(0.359898, 0.087831000000000006, 0.496778, 1.0) -(0.366012, 0.090314000000000005, 0.49796000000000001, 1.0) -(0.372116, 0.092815999999999996, 0.49905300000000002, 1.0) -(0.37821100000000002, 0.095332, 0.50006700000000004, 1.0) -(0.384299, 0.097854999999999998, 0.50100199999999995, 1.0) -(0.39038400000000001, 0.100379, 0.50186399999999998, 1.0) -(0.39646700000000001, 0.10290199999999999, 0.50265800000000005, 1.0) -(0.40254800000000002, 0.10542, 0.503386, 1.0) -(0.40862900000000002, 0.10793, 0.50405199999999994, 1.0) -(0.41470899999999999, 0.110431, 0.50466200000000005, 1.0) -(0.42079100000000003, 0.11292000000000001, 0.50521499999999997, 1.0) -(0.42687700000000001, 0.115395, 0.505714, 1.0) -(0.43296699999999999, 0.117855, 0.50616000000000005, 1.0) -(0.43906200000000001, 0.120298, 0.50655499999999998, 1.0) -(0.44516299999999998, 0.122724, 0.50690100000000005, 1.0) -(0.45127099999999998, 0.12513199999999999, 0.50719800000000004, 1.0) -(0.45738600000000001, 0.127522, 0.50744800000000001, 1.0) -(0.46350799999999998, 0.12989300000000001, 0.50765199999999999, 1.0) -(0.46964, 0.132245, 0.50780899999999995, 1.0) -(0.47577999999999998, 0.134577, 0.50792099999999996, 1.0) -(0.481929, 0.13689100000000001, 0.50798900000000002, 1.0) -(0.48808800000000002, 0.139186, 0.50801099999999999, 1.0) -(0.49425799999999998, 0.141462, 0.507988, 1.0) -(0.50043800000000005, 0.14371900000000001, 0.50792000000000004, 1.0) -(0.506629, 0.145958, 0.50780599999999998, 1.0) -(0.51283100000000004, 0.14817900000000001, 0.50764799999999999, 1.0) -(0.51904499999999998, 0.15038299999999999, 0.50744299999999998, 1.0) -(0.52527000000000001, 0.15256900000000001, 0.50719199999999998, 1.0) -(0.53150699999999995, 0.15473899999999999, 0.50689499999999998, 1.0) -(0.53775499999999998, 0.15689400000000001, 0.50655099999999997, 1.0) -(0.54401500000000003, 0.15903300000000001, 0.50615900000000003, 1.0) -(0.55028699999999997, 0.161158, 0.50571900000000003, 1.0) -(0.55657100000000004, 0.163269, 0.50522999999999996, 1.0) -(0.56286599999999998, 0.16536799999999999, 0.50469200000000003, 1.0) -(0.56917200000000001, 0.16745399999999999, 0.50410500000000003, 1.0) -(0.57548999999999995, 0.16952999999999999, 0.50346599999999997, 1.0) -(0.58181899999999998, 0.171596, 0.50277700000000003, 1.0) -(0.58815799999999996, 0.173652, 0.50203500000000001, 1.0) -(0.59450800000000004, 0.175701, 0.50124100000000005, 1.0) -(0.60086799999999996, 0.17774300000000001, 0.50039400000000001, 1.0) -(0.60723800000000006, 0.17977899999999999, 0.49949199999999999, 1.0) -(0.61361699999999997, 0.181811, 0.49853599999999998, 1.0) -(0.62000500000000003, 0.18384, 0.49752400000000002, 1.0) -(0.62640099999999999, 0.185867, 0.49645600000000001, 1.0) -(0.63280499999999995, 0.187893, 0.49533199999999999, 1.0) -(0.63921600000000001, 0.18992100000000001, 0.49414999999999998, 1.0) -(0.64563300000000001, 0.19195200000000001, 0.49291000000000001, 1.0) -(0.65205599999999997, 0.19398599999999999, 0.49161100000000002, 1.0) -(0.65848300000000004, 0.19602700000000001, 0.49025299999999999, 1.0) -(0.66491500000000003, 0.198075, 0.48883599999999999, 1.0) -(0.67134899999999997, 0.20013300000000001, 0.48735800000000001, 1.0) -(0.677786, 0.20220299999999999, 0.485819, 1.0) -(0.68422400000000005, 0.204286, 0.48421900000000001, 1.0) -(0.69066099999999997, 0.20638400000000001, 0.48255799999999999, 1.0) -(0.697098, 0.20850099999999999, 0.48083500000000001, 1.0) -(0.70353200000000005, 0.21063799999999999, 0.479049, 1.0) -(0.70996199999999998, 0.21279699999999999, 0.47720099999999999, 1.0) -(0.716387, 0.21498200000000001, 0.47528999999999999, 1.0) -(0.72280500000000003, 0.217194, 0.47331600000000001, 1.0) -(0.72921599999999998, 0.21943699999999999, 0.471279, 1.0) -(0.73561600000000005, 0.22171299999999999, 0.46917999999999999, 1.0) -(0.742004, 0.224025, 0.46701799999999999, 1.0) -(0.74837799999999999, 0.22637699999999999, 0.46479399999999998, 1.0) -(0.75473699999999999, 0.228772, 0.462509, 1.0) -(0.761077, 0.231214, 0.46016200000000002, 1.0) -(0.76739800000000002, 0.233705, 0.45775500000000002, 1.0) -(0.77369500000000002, 0.23624899999999999, 0.455289, 1.0) -(0.77996799999999999, 0.23885100000000001, 0.45276499999999997, 1.0) -(0.78621200000000002, 0.24151400000000001, 0.45018399999999997, 1.0) -(0.79242699999999999, 0.24424199999999999, 0.44754300000000002, 1.0) -(0.79860799999999998, 0.24704000000000001, 0.44484800000000002, 1.0) -(0.80475200000000002, 0.24991099999999999, 0.44210199999999999, 1.0) -(0.81085499999999999, 0.252861, 0.439305, 1.0) -(0.81691400000000003, 0.25589499999999998, 0.43646099999999999, 1.0) -(0.82292600000000005, 0.25901600000000002, 0.43357299999999999, 1.0) -(0.82888600000000001, 0.26222899999999999, 0.43064400000000003, 1.0) -(0.83479099999999995, 0.26554, 0.42767100000000002, 1.0) -(0.84063600000000005, 0.268953, 0.42466599999999999, 1.0) -(0.84641599999999995, 0.27247300000000002, 0.42163099999999998, 1.0) -(0.85212600000000005, 0.27610600000000002, 0.41857299999999997, 1.0) -(0.85776300000000005, 0.27985700000000002, 0.41549599999999998, 1.0) -(0.86331999999999998, 0.28372900000000001, 0.41240300000000002, 1.0) -(0.86879300000000004, 0.28772799999999998, 0.40930299999999997, 1.0) -(0.87417599999999995, 0.29185899999999998, 0.40620499999999998, 1.0) -(0.87946400000000002, 0.29612500000000003, 0.40311799999999998, 1.0) -(0.88465099999999997, 0.30053000000000002, 0.40004699999999999, 1.0) -(0.88973100000000005, 0.30507899999999999, 0.39700200000000002, 1.0) -(0.89470000000000005, 0.30977300000000002, 0.39399499999999998, 1.0) -(0.89955200000000002, 0.31461600000000001, 0.39103700000000002, 1.0) -(0.904281, 0.31961000000000001, 0.38813700000000001, 1.0) -(0.90888400000000003, 0.32475500000000002, 0.38530799999999998, 1.0) -(0.913354, 0.33005200000000001, 0.38256299999999999, 1.0) -(0.91768899999999998, 0.33550000000000002, 0.379915, 1.0) -(0.92188400000000004, 0.34109800000000001, 0.37737599999999999, 1.0) -(0.92593700000000001, 0.34684399999999999, 0.37495899999999999, 1.0) -(0.92984500000000003, 0.35273399999999999, 0.37267699999999998, 1.0) -(0.93360600000000005, 0.35876400000000003, 0.37054100000000001, 1.0) -(0.93722099999999997, 0.364929, 0.36856699999999998, 1.0) -(0.94068700000000005, 0.371224, 0.36676199999999998, 1.0) -(0.94400600000000001, 0.37764300000000001, 0.36513600000000002, 1.0) -(0.94718000000000002, 0.38417800000000002, 0.363701, 1.0) -(0.95021, 0.39082, 0.36246800000000001, 1.0) -(0.95309900000000003, 0.397563, 0.36143799999999998, 1.0) -(0.95584899999999995, 0.40439999999999998, 0.36061900000000002, 1.0) -(0.95846399999999998, 0.41132400000000002, 0.360014, 1.0) -(0.96094900000000005, 0.418323, 0.35963000000000001, 1.0) -(0.96331, 0.42538999999999999, 0.35946899999999998, 1.0) -(0.96554899999999999, 0.43251899999999999, 0.35952899999999999, 1.0) -(0.96767099999999995, 0.43970300000000001, 0.35981000000000002, 1.0) -(0.96967999999999999, 0.446936, 0.36031099999999999, 1.0) -(0.97158199999999995, 0.45421, 0.36103000000000002, 1.0) -(0.97338100000000005, 0.46151999999999999, 0.36196499999999998, 1.0) -(0.975082, 0.46886100000000003, 0.36311100000000002, 1.0) -(0.97668999999999995, 0.47622599999999998, 0.36446600000000001, 1.0) -(0.97821000000000002, 0.48361199999999999, 0.36602499999999999, 1.0) -(0.97964499999999999, 0.49101400000000001, 0.36778300000000003, 1.0) -(0.98099999999999998, 0.49842799999999998, 0.36973400000000001, 1.0) -(0.98227900000000001, 0.50585100000000005, 0.37187399999999998, 1.0) -(0.98348500000000005, 0.51327999999999996, 0.37419799999999998, 1.0) -(0.984622, 0.52071299999999998, 0.37669799999999998, 1.0) -(0.98569300000000004, 0.52814799999999995, 0.37937100000000001, 1.0) -(0.98670000000000002, 0.535582, 0.38220999999999999, 1.0) -(0.98764600000000002, 0.54301500000000003, 0.38521, 1.0) -(0.988533, 0.55044599999999999, 0.38836500000000002, 1.0) -(0.98936299999999999, 0.55787299999999995, 0.39167099999999999, 1.0) -(0.99013799999999996, 0.56529600000000002, 0.39512199999999997, 1.0) -(0.99087099999999995, 0.57270600000000005, 0.39871400000000001, 1.0) -(0.99155800000000005, 0.58010700000000004, 0.40244099999999999, 1.0) -(0.99219599999999997, 0.58750199999999997, 0.40629900000000002, 1.0) -(0.99278500000000003, 0.59489099999999995, 0.41028300000000001, 1.0) -(0.99332600000000004, 0.602275, 0.41438999999999998, 1.0) -(0.993834, 0.60964399999999996, 0.41861300000000001, 1.0) -(0.994309, 0.61699899999999996, 0.42294999999999999, 1.0) -(0.99473800000000001, 0.62434999999999996, 0.42739700000000003, 1.0) -(0.99512199999999995, 0.63169600000000004, 0.43195099999999997, 1.0) -(0.99548000000000003, 0.63902700000000001, 0.43660700000000002, 1.0) -(0.99580999999999997, 0.64634400000000003, 0.441361, 1.0) -(0.99609599999999998, 0.65365899999999999, 0.44621300000000003, 1.0) -(0.99634100000000003, 0.66096900000000003, 0.45116000000000001, 1.0) -(0.99658000000000002, 0.66825599999999996, 0.45619199999999999, 1.0) -(0.99677499999999997, 0.67554099999999995, 0.461314, 1.0) -(0.99692499999999995, 0.68282799999999999, 0.466526, 1.0) -(0.99707699999999999, 0.69008800000000003, 0.47181099999999998, 1.0) -(0.99718600000000002, 0.697349, 0.477182, 1.0) -(0.99725399999999997, 0.70461099999999999, 0.48263499999999998, 1.0) -(0.99732500000000002, 0.71184800000000004, 0.48815399999999998, 1.0) -(0.99735099999999999, 0.71908899999999998, 0.493755, 1.0) -(0.99735099999999999, 0.72632399999999997, 0.49942799999999998, 1.0) -(0.99734100000000003, 0.733545, 0.50516700000000003, 1.0) -(0.99728499999999998, 0.74077199999999999, 0.51098299999999997, 1.0) -(0.997228, 0.74798100000000001, 0.51685899999999996, 1.0) -(0.99713799999999997, 0.75519000000000003, 0.52280599999999999, 1.0) -(0.99701899999999999, 0.76239800000000002, 0.52882099999999999, 1.0) -(0.99689799999999995, 0.76959100000000003, 0.53489200000000003, 1.0) -(0.99672700000000003, 0.77679500000000001, 0.54103900000000005, 1.0) -(0.99657099999999998, 0.78397700000000003, 0.54723299999999997, 1.0) -(0.99636899999999995, 0.79116699999999995, 0.55349899999999996, 1.0) -(0.99616199999999999, 0.79834799999999995, 0.55981999999999998, 1.0) -(0.99593200000000004, 0.80552699999999999, 0.56620199999999998, 1.0) -(0.99568000000000001, 0.81270600000000004, 0.57264499999999996, 1.0) -(0.99542399999999998, 0.81987500000000002, 0.57913999999999999, 1.0) -(0.99513099999999999, 0.82705200000000001, 0.58570100000000003, 1.0) -(0.99485100000000004, 0.83421299999999998, 0.59230700000000003, 1.0) -(0.99452399999999996, 0.841387, 0.59898300000000004, 1.0) -(0.99422200000000005, 0.84853999999999996, 0.60569600000000001, 1.0) -(0.99386600000000003, 0.855711, 0.61248199999999997, 1.0) -(0.99354500000000001, 0.86285900000000004, 0.61929900000000004, 1.0) -(0.99317, 0.87002400000000002, 0.626189, 1.0) -(0.99283100000000002, 0.87716799999999995, 0.63310900000000003, 1.0) -(0.99243999999999999, 0.88432999999999995, 0.64009899999999997, 1.0) -(0.992089, 0.89146999999999998, 0.64711600000000002, 1.0) -(0.99168800000000001, 0.89862699999999995, 0.65420199999999995, 1.0) -(0.99133199999999999, 0.90576299999999998, 0.66130900000000004, 1.0) -(0.99092999999999998, 0.91291500000000003, 0.66848099999999999, 1.0) -(0.99056999999999995, 0.92004900000000001, 0.67567500000000003, 1.0) -(0.99017500000000003, 0.92719600000000002, 0.68292600000000003, 1.0) -(0.989815, 0.93432899999999997, 0.69019799999999998, 1.0) -(0.98943400000000004, 0.94147000000000003, 0.697519, 1.0) -(0.98907699999999998, 0.948604, 0.70486300000000002, 1.0) -(0.98871699999999996, 0.95574199999999998, 0.71224200000000004, 1.0) -(0.988367, 0.96287800000000001, 0.71964899999999998, 1.0) -(0.98803300000000005, 0.97001199999999999, 0.72707699999999997, 1.0) -(0.98769099999999999, 0.97715399999999997, 0.73453599999999997, 1.0) -(0.98738700000000001, 0.98428800000000005, 0.74200200000000005, 1.0) -(0.98705299999999996, 0.99143800000000004, 0.74950399999999995, 1.0) diff --git a/extern/tfn/colormaps/perceptual/plasma.cpp b/extern/tfn/colormaps/perceptual/plasma.cpp deleted file mode 100644 index 349a904..0000000 --- a/extern/tfn/colormaps/perceptual/plasma.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_perceptual_plasma; -} -const std::vector colormap::data_perceptual_plasma = /* NOLINT(cert-err58-cpp) */ -{ -{0.050382999999999997f, 0.029803f, 0.52797499999999997f, 1.0f}, -{0.063535999999999995f, 0.028426f, 0.53312400000000004f, 1.0f}, -{0.075353000000000003f, 0.027206000000000001f, 0.53800700000000001f, 1.0f}, -{0.086221999999999993f, 0.026124999999999999f, 0.54265799999999997f, 1.0f}, -{0.096379000000000006f, 0.025165f, 0.54710300000000001f, 1.0f}, -{0.10598f, 0.024309000000000001f, 0.55136799999999997f, 1.0f}, -{0.115124f, 0.023556000000000001f, 0.55546799999999996f, 1.0f}, -{0.123903f, 0.022877999999999999f, 0.559423f, 1.0f}, -{0.132381f, 0.022258f, 0.56325000000000003f, 1.0f}, -{0.14060300000000001f, 0.021687000000000001f, 0.56695899999999999f, 1.0f}, -{0.14860699999999999f, 0.021153999999999999f, 0.57056200000000001f, 1.0f}, -{0.156421f, 0.020650999999999999f, 0.57406500000000005f, 1.0f}, -{0.16406999999999999f, 0.020171000000000001f, 0.57747800000000005f, 1.0f}, -{0.171574f, 0.019706000000000001f, 0.58080600000000004f, 1.0f}, -{0.17895f, 0.019251999999999998f, 0.58405399999999996f, 1.0f}, -{0.18621299999999999f, 0.018803f, 0.58722799999999997f, 1.0f}, -{0.19337399999999999f, 0.018353999999999999f, 0.59033000000000002f, 1.0f}, -{0.20044500000000001f, 0.017902000000000001f, 0.593364f, 1.0f}, -{0.20743500000000001f, 0.017441999999999999f, 0.596333f, 1.0f}, -{0.21435000000000001f, 0.016972999999999999f, 0.59923899999999997f, 1.0f}, -{0.221197f, 0.016497000000000001f, 0.60208300000000003f, 1.0f}, -{0.22798299999999999f, 0.016007f, 0.60486700000000004f, 1.0f}, -{0.23471500000000001f, 0.015502f, 0.60759200000000002f, 1.0f}, -{0.241396f, 0.014978999999999999f, 0.610259f, 1.0f}, -{0.248032f, 0.014439f, 0.61286799999999997f, 1.0f}, -{0.25462699999999999f, 0.013882f, 0.61541900000000005f, 1.0f}, -{0.261183f, 0.013308f, 0.61791099999999999f, 1.0f}, -{0.26770300000000002f, 0.012716f, 0.62034599999999995f, 1.0f}, -{0.27419100000000002f, 0.012109f, 0.622722f, 1.0f}, -{0.28064800000000001f, 0.011488f, 0.62503799999999998f, 1.0f}, -{0.287076f, 0.010855f, 0.62729500000000005f, 1.0f}, -{0.29347800000000002f, 0.010213f, 0.62948999999999999f, 1.0f}, -{0.29985499999999998f, 0.0095610000000000001f, 0.63162399999999996f, 1.0f}, -{0.30620999999999998f, 0.0089020000000000002f, 0.63369399999999998f, 1.0f}, -{0.31254300000000002f, 0.0082389999999999998f, 0.63570000000000004f, 1.0f}, -{0.31885599999999997f, 0.0075760000000000003f, 0.63763999999999998f, 1.0f}, -{0.32514999999999999f, 0.0069150000000000001f, 0.63951199999999997f, 1.0f}, -{0.331426f, 0.0062610000000000001f, 0.641316f, 1.0f}, -{0.33768300000000001f, 0.0056179999999999997f, 0.64304899999999998f, 1.0f}, -{0.34392499999999998f, 0.0049909999999999998f, 0.64471000000000001f, 1.0f}, -{0.35015000000000002f, 0.0043819999999999996f, 0.64629800000000004f, 1.0f}, -{0.35635899999999998f, 0.0037980000000000002f, 0.64781f, 1.0f}, -{0.36255300000000001f, 0.0032429999999999998f, 0.64924499999999996f, 1.0f}, -{0.36873299999999998f, 0.0027239999999999999f, 0.65060099999999998f, 1.0f}, -{0.37489699999999998f, 0.002245f, 0.65187600000000001f, 1.0f}, -{0.38104700000000002f, 0.0018140000000000001f, 0.65306799999999998f, 1.0f}, -{0.387183f, 0.0014339999999999999f, 0.65417700000000001f, 1.0f}, -{0.39330399999999999f, 0.001114f, 0.65519899999999998f, 1.0f}, -{0.39941100000000002f, 0.00085899999999999995f, 0.65613299999999997f, 1.0f}, -{0.405503f, 0.000678f, 0.65697700000000003f, 1.0f}, -{0.41158f, 0.00057700000000000004f, 0.65773000000000004f, 1.0f}, -{0.41764200000000001f, 0.00056400000000000005f, 0.65839000000000003f, 1.0f}, -{0.42368899999999998f, 0.00064599999999999998f, 0.65895599999999999f, 1.0f}, -{0.42971900000000002f, 0.00083100000000000003f, 0.65942500000000004f, 1.0f}, -{0.43573400000000001f, 0.001127f, 0.65979699999999997f, 1.0f}, -{0.44173200000000001f, 0.0015399999999999999f, 0.66006900000000002f, 1.0f}, -{0.447714f, 0.0020799999999999998f, 0.66024000000000005f, 1.0f}, -{0.453677f, 0.0027550000000000001f, 0.66030999999999995f, 1.0f}, -{0.459623f, 0.0035739999999999999f, 0.660277f, 1.0f}, -{0.46555000000000002f, 0.0045450000000000004f, 0.66013900000000003f, 1.0f}, -{0.47145700000000001f, 0.0056779999999999999f, 0.65989699999999996f, 1.0f}, -{0.47734399999999999f, 0.0069800000000000001f, 0.65954900000000005f, 1.0f}, -{0.48320999999999997f, 0.0084600000000000005f, 0.65909499999999999f, 1.0f}, -{0.48905500000000002f, 0.010127000000000001f, 0.65853399999999995f, 1.0f}, -{0.49487700000000001f, 0.011990000000000001f, 0.65786500000000003f, 1.0f}, -{0.50067799999999996f, 0.014055f, 0.65708800000000001f, 1.0f}, -{0.50645399999999996f, 0.016333f, 0.65620199999999995f, 1.0f}, -{0.51220600000000005f, 0.018832999999999999f, 0.65520900000000004f, 1.0f}, -{0.51793299999999998f, 0.021562999999999999f, 0.65410900000000005f, 1.0f}, -{0.52363300000000002f, 0.024532000000000002f, 0.65290099999999995f, 1.0f}, -{0.52930600000000005f, 0.027747000000000001f, 0.651586f, 1.0f}, -{0.53495199999999998f, 0.031217000000000002f, 0.65016499999999999f, 1.0f}, -{0.54056999999999999f, 0.034950000000000002f, 0.64863999999999999f, 1.0f}, -{0.546157f, 0.038954000000000003f, 0.64700999999999997f, 1.0f}, -{0.55171499999999996f, 0.043136000000000001f, 0.64527699999999999f, 1.0f}, -{0.55724300000000004f, 0.047330999999999998f, 0.64344299999999999f, 1.0f}, -{0.56273799999999996f, 0.051545000000000001f, 0.641509f, 1.0f}, -{0.56820099999999996f, 0.055778000000000001f, 0.63947699999999996f, 1.0f}, -{0.57363200000000003f, 0.060027999999999998f, 0.63734900000000005f, 1.0f}, -{0.57902900000000002f, 0.064296000000000006f, 0.63512599999999997f, 1.0f}, -{0.58439099999999999f, 0.068579000000000001f, 0.63281200000000004f, 1.0f}, -{0.58971899999999999f, 0.072877999999999998f, 0.63040799999999997f, 1.0f}, -{0.59501099999999996f, 0.077189999999999995f, 0.62791699999999995f, 1.0f}, -{0.60026599999999997f, 0.081516000000000005f, 0.62534199999999995f, 1.0f}, -{0.60548500000000005f, 0.085854f, 0.62268599999999996f, 1.0f}, -{0.61066699999999996f, 0.090204000000000006f, 0.61995100000000003f, 1.0f}, -{0.61581200000000003f, 0.094563999999999995f, 0.61714000000000002f, 1.0f}, -{0.620919f, 0.098933999999999994f, 0.61425700000000005f, 1.0f}, -{0.62598699999999996f, 0.103312f, 0.61130499999999999f, 1.0f}, -{0.63101700000000005f, 0.107699f, 0.60828700000000002f, 1.0f}, -{0.63600800000000002f, 0.112092f, 0.60520499999999999f, 1.0f}, -{0.64095899999999995f, 0.116492f, 0.60206499999999996f, 1.0f}, -{0.645872f, 0.12089800000000001f, 0.59886700000000004f, 1.0f}, -{0.65074600000000005f, 0.125309f, 0.59561699999999995f, 1.0f}, -{0.65558000000000005f, 0.12972500000000001f, 0.59231699999999998f, 1.0f}, -{0.66037400000000002f, 0.13414400000000001f, 0.58897100000000002f, 1.0f}, -{0.66512899999999997f, 0.13856599999999999f, 0.58558200000000005f, 1.0f}, -{0.66984500000000002f, 0.14299200000000001f, 0.58215399999999995f, 1.0f}, -{0.67452199999999995f, 0.14741899999999999f, 0.57868799999999998f, 1.0f}, -{0.67915999999999999f, 0.15184800000000001f, 0.57518899999999995f, 1.0f}, -{0.68375799999999998f, 0.156278f, 0.57165999999999995f, 1.0f}, -{0.68831799999999999f, 0.16070899999999999f, 0.56810300000000002f, 1.0f}, -{0.69284000000000001f, 0.16514100000000001f, 0.56452199999999997f, 1.0f}, -{0.69732400000000005f, 0.169573f, 0.56091899999999995f, 1.0f}, -{0.70176899999999998f, 0.17400499999999999f, 0.55729600000000001f, 1.0f}, -{0.70617799999999997f, 0.17843700000000001f, 0.55365699999999995f, 1.0f}, -{0.71054899999999999f, 0.182868f, 0.55000400000000005f, 1.0f}, -{0.71488300000000005f, 0.18729899999999999f, 0.54633799999999999f, 1.0f}, -{0.71918099999999996f, 0.19172900000000001f, 0.54266300000000001f, 1.0f}, -{0.72344399999999998f, 0.196158f, 0.53898100000000004f, 1.0f}, -{0.72767000000000004f, 0.20058599999999999f, 0.53529300000000002f, 1.0f}, -{0.73186200000000001f, 0.205013f, 0.53160099999999999f, 1.0f}, -{0.73601899999999998f, 0.20943899999999999f, 0.52790800000000004f, 1.0f}, -{0.740143f, 0.213864f, 0.52421600000000002f, 1.0f}, -{0.744232f, 0.21828800000000001f, 0.52052399999999999f, 1.0f}, -{0.74828899999999998f, 0.22271099999999999f, 0.51683400000000002f, 1.0f}, -{0.75231199999999998f, 0.227133f, 0.51314899999999997f, 1.0f}, -{0.75630399999999998f, 0.23155500000000001f, 0.50946800000000003f, 1.0f}, -{0.76026400000000005f, 0.23597599999999999f, 0.50579399999999997f, 1.0f}, -{0.76419300000000001f, 0.240396f, 0.50212599999999996f, 1.0f}, -{0.76809000000000005f, 0.24481700000000001f, 0.49846499999999999f, 1.0f}, -{0.77195800000000003f, 0.24923699999999999f, 0.494813f, 1.0f}, -{0.77579600000000004f, 0.25365799999999999f, 0.49117100000000002f, 1.0f}, -{0.77960399999999996f, 0.25807799999999997f, 0.487539f, 1.0f}, -{0.78338300000000005f, 0.26250000000000001f, 0.48391800000000001f, 1.0f}, -{0.78713299999999997f, 0.26692199999999999f, 0.48030699999999998f, 1.0f}, -{0.79085499999999997f, 0.271345f, 0.47670600000000002f, 1.0f}, -{0.79454899999999995f, 0.27577000000000002f, 0.47311700000000001f, 1.0f}, -{0.79821600000000004f, 0.28019699999999997f, 0.46953800000000001f, 1.0f}, -{0.80185499999999998f, 0.28462599999999999f, 0.46597100000000002f, 1.0f}, -{0.80546700000000004f, 0.28905700000000001f, 0.46241500000000002f, 1.0f}, -{0.80905199999999999f, 0.293491f, 0.45887f, 1.0f}, -{0.812612f, 0.29792800000000003f, 0.45533800000000002f, 1.0f}, -{0.81614399999999998f, 0.30236800000000003f, 0.451816f, 1.0f}, -{0.81965100000000002f, 0.30681199999999997f, 0.44830599999999998f, 1.0f}, -{0.82313199999999997f, 0.31126100000000001f, 0.44480599999999998f, 1.0f}, -{0.82658799999999999f, 0.31571399999999999f, 0.44131599999999999f, 1.0f}, -{0.83001800000000003f, 0.32017200000000001f, 0.437836f, 1.0f}, -{0.833422f, 0.32463500000000001f, 0.43436599999999997f, 1.0f}, -{0.83680100000000002f, 0.32910499999999998f, 0.43090499999999998f, 1.0f}, -{0.84015499999999999f, 0.33357999999999999f, 0.42745499999999997f, 1.0f}, -{0.84348400000000001f, 0.33806199999999997f, 0.42401299999999997f, 1.0f}, -{0.84678799999999999f, 0.34255099999999999f, 0.42057899999999998f, 1.0f}, -{0.85006599999999999f, 0.34704800000000002f, 0.417153f, 1.0f}, -{0.85331900000000005f, 0.351553f, 0.41373399999999999f, 1.0f}, -{0.85654699999999995f, 0.35606599999999999f, 0.41032200000000002f, 1.0f}, -{0.85975000000000001f, 0.36058800000000002f, 0.40691699999999997f, 1.0f}, -{0.862927f, 0.36511900000000003f, 0.40351900000000002f, 1.0f}, -{0.86607800000000001f, 0.36965999999999999f, 0.40012599999999998f, 1.0f}, -{0.86920299999999995f, 0.37421199999999999f, 0.39673799999999998f, 1.0f}, -{0.87230300000000005f, 0.378774f, 0.39335500000000001f, 1.0f}, -{0.87537600000000004f, 0.38334699999999999f, 0.38997599999999999f, 1.0f}, -{0.87842299999999995f, 0.387932f, 0.3866f, 1.0f}, -{0.88144299999999998f, 0.39252900000000002f, 0.38322899999999999f, 1.0f}, -{0.884436f, 0.39713900000000002f, 0.37985999999999998f, 1.0f}, -{0.88740200000000002f, 0.40176200000000001f, 0.376494f, 1.0f}, -{0.89034000000000002f, 0.40639799999999998f, 0.37313000000000002f, 1.0f}, -{0.89324999999999999f, 0.41104800000000002f, 0.36976799999999999f, 1.0f}, -{0.89613100000000001f, 0.41571200000000003f, 0.36640699999999998f, 1.0f}, -{0.89898400000000001f, 0.42039199999999999f, 0.36304700000000001f, 1.0f}, -{0.90180700000000003f, 0.42508699999999999f, 0.35968800000000001f, 1.0f}, -{0.90460099999999999f, 0.42979699999999998f, 0.35632900000000001f, 1.0f}, -{0.90736499999999998f, 0.43452400000000002f, 0.35297000000000001f, 1.0f}, -{0.91009799999999996f, 0.43926799999999999f, 0.34960999999999998f, 1.0f}, -{0.91279999999999994f, 0.44402900000000001f, 0.34625099999999998f, 1.0f}, -{0.91547100000000003f, 0.44880700000000001f, 0.34288999999999997f, 1.0f}, -{0.91810899999999995f, 0.45360299999999998f, 0.33952900000000003f, 1.0f}, -{0.92071400000000003f, 0.45841700000000002f, 0.33616600000000002f, 1.0f}, -{0.92328699999999997f, 0.46325100000000002f, 0.33280100000000001f, 1.0f}, -{0.92582500000000001f, 0.46810299999999999f, 0.32943499999999998f, 1.0f}, -{0.92832899999999996f, 0.47297499999999998f, 0.326067f, 1.0f}, -{0.93079800000000001f, 0.47786699999999999f, 0.32269700000000001f, 1.0f}, -{0.93323199999999995f, 0.48277999999999999f, 0.31932500000000003f, 1.0f}, -{0.93562999999999996f, 0.48771199999999998f, 0.31595200000000001f, 1.0f}, -{0.93798999999999999f, 0.49266700000000002f, 0.31257499999999999f, 1.0f}, -{0.94031299999999995f, 0.49764199999999997f, 0.309197f, 1.0f}, -{0.94259800000000005f, 0.50263899999999995f, 0.30581599999999998f, 1.0f}, -{0.94484400000000002f, 0.50765800000000005f, 0.30243300000000001f, 1.0f}, -{0.94705099999999998f, 0.51269900000000002f, 0.29904900000000001f, 1.0f}, -{0.94921699999999998f, 0.51776299999999997f, 0.29566199999999998f, 1.0f}, -{0.95134399999999997f, 0.52285000000000004f, 0.29227500000000001f, 1.0f}, -{0.95342800000000005f, 0.52795999999999998f, 0.288883f, 1.0f}, -{0.95547000000000004f, 0.53309300000000004f, 0.28549000000000002f, 1.0f}, -{0.95746900000000001f, 0.53825000000000001f, 0.28209600000000001f, 1.0f}, -{0.95942400000000005f, 0.543431f, 0.27870099999999998f, 1.0f}, -{0.96133599999999997f, 0.54863600000000001f, 0.27530500000000002f, 1.0f}, -{0.96320300000000003f, 0.55386500000000005f, 0.27190900000000001f, 1.0f}, -{0.96502399999999999f, 0.559118f, 0.268513f, 1.0f}, -{0.96679800000000005f, 0.56439600000000001f, 0.26511800000000002f, 1.0f}, -{0.968526f, 0.56969999999999998f, 0.26172099999999998f, 1.0f}, -{0.97020499999999998f, 0.57502799999999998f, 0.25832500000000003f, 1.0f}, -{0.971835f, 0.58038199999999995f, 0.25493100000000002f, 1.0f}, -{0.97341599999999995f, 0.58576099999999998f, 0.25153999999999999f, 1.0f}, -{0.97494700000000001f, 0.59116500000000005f, 0.24815100000000001f, 1.0f}, -{0.97642799999999996f, 0.59659499999999999f, 0.24476700000000001f, 1.0f}, -{0.97785599999999995f, 0.602051f, 0.24138699999999999f, 1.0f}, -{0.97923300000000002f, 0.60753199999999996f, 0.238013f, 1.0f}, -{0.98055599999999998f, 0.613039f, 0.23464599999999999f, 1.0f}, -{0.98182599999999998f, 0.61857200000000001f, 0.23128699999999999f, 1.0f}, -{0.98304100000000005f, 0.62413099999999999f, 0.227937f, 1.0f}, -{0.98419900000000005f, 0.629718f, 0.22459499999999999f, 1.0f}, -{0.98530099999999998f, 0.63532999999999995f, 0.22126499999999999f, 1.0f}, -{0.98634500000000003f, 0.64096900000000001f, 0.217948f, 1.0f}, -{0.98733199999999999f, 0.64663300000000001f, 0.21464800000000001f, 1.0f}, -{0.98826000000000003f, 0.65232500000000004f, 0.211364f, 1.0f}, -{0.98912800000000001f, 0.65804300000000004f, 0.20810000000000001f, 1.0f}, -{0.98993500000000001f, 0.66378700000000002f, 0.20485900000000001f, 1.0f}, -{0.99068100000000003f, 0.66955799999999999f, 0.20164199999999999f, 1.0f}, -{0.99136500000000005f, 0.67535500000000004f, 0.19845299999999999f, 1.0f}, -{0.99198500000000001f, 0.68117899999999998f, 0.195295f, 1.0f}, -{0.99254100000000001f, 0.68703000000000003f, 0.19217000000000001f, 1.0f}, -{0.99303200000000003f, 0.69290700000000005f, 0.189084f, 1.0f}, -{0.99345600000000001f, 0.69881000000000004f, 0.18604100000000001f, 1.0f}, -{0.99381399999999998f, 0.70474099999999995f, 0.18304300000000001f, 1.0f}, -{0.99410299999999996f, 0.71069800000000005f, 0.18009700000000001f, 1.0f}, -{0.99432399999999999f, 0.71668100000000001f, 0.177208f, 1.0f}, -{0.99447399999999997f, 0.72269099999999997f, 0.17438100000000001f, 1.0f}, -{0.99455300000000002f, 0.72872800000000004f, 0.171622f, 1.0f}, -{0.99456100000000003f, 0.73479099999999997f, 0.168938f, 1.0f}, -{0.99449500000000002f, 0.74087999999999998f, 0.16633500000000001f, 1.0f}, -{0.99435499999999999f, 0.74699499999999996f, 0.16382099999999999f, 1.0f}, -{0.99414100000000005f, 0.75313699999999995f, 0.16140399999999999f, 1.0f}, -{0.99385100000000004f, 0.75930399999999998f, 0.15909200000000001f, 1.0f}, -{0.99348199999999998f, 0.76549900000000004f, 0.156891f, 1.0f}, -{0.99303300000000005f, 0.77171999999999996f, 0.154808f, 1.0f}, -{0.99250499999999997f, 0.77796699999999996f, 0.15285499999999999f, 1.0f}, -{0.99189700000000003f, 0.78423900000000002f, 0.15104200000000001f, 1.0f}, -{0.99120900000000001f, 0.79053700000000005f, 0.14937700000000001f, 1.0f}, -{0.99043899999999996f, 0.79685899999999998f, 0.14787f, 1.0f}, -{0.98958699999999999f, 0.80320499999999995f, 0.14652899999999999f, 1.0f}, -{0.98864799999999997f, 0.80957900000000005f, 0.14535699999999999f, 1.0f}, -{0.98762099999999997f, 0.81597799999999998f, 0.14436299999999999f, 1.0f}, -{0.98650899999999997f, 0.82240100000000005f, 0.14355699999999999f, 1.0f}, -{0.98531400000000002f, 0.82884599999999997f, 0.14294499999999999f, 1.0f}, -{0.98403099999999999f, 0.83531500000000003f, 0.14252799999999999f, 1.0f}, -{0.982653f, 0.841812f, 0.14230300000000001f, 1.0f}, -{0.98119000000000001f, 0.848329f, 0.14227899999999999f, 1.0f}, -{0.97964399999999996f, 0.85486600000000001f, 0.142453f, 1.0f}, -{0.97799499999999995f, 0.86143199999999998f, 0.14280799999999999f, 1.0f}, -{0.97626500000000005f, 0.86801600000000001f, 0.14335100000000001f, 1.0f}, -{0.97444299999999995f, 0.87462200000000001f, 0.14406099999999999f, 1.0f}, -{0.97253000000000001f, 0.88124999999999998f, 0.144923f, 1.0f}, -{0.97053299999999998f, 0.88789600000000002f, 0.14591899999999999f, 1.0f}, -{0.96844300000000005f, 0.89456400000000003f, 0.14701400000000001f, 1.0f}, -{0.96627099999999999f, 0.90124899999999997f, 0.14818000000000001f, 1.0f}, -{0.96402100000000002f, 0.90795000000000003f, 0.14937f, 1.0f}, -{0.96168100000000001f, 0.91467200000000004f, 0.15051999999999999f, 1.0f}, -{0.95927600000000002f, 0.92140699999999998f, 0.15156600000000001f, 1.0f}, -{0.95680799999999999f, 0.92815199999999998f, 0.15240899999999999f, 1.0f}, -{0.954287f, 0.93490799999999996f, 0.152921f, 1.0f}, -{0.95172599999999996f, 0.94167100000000004f, 0.15292500000000001f, 1.0f}, -{0.94915099999999997f, 0.94843500000000003f, 0.15217800000000001f, 1.0f}, -{0.94660200000000005f, 0.95518999999999998f, 0.15032799999999999f, 1.0f}, -{0.94415199999999999f, 0.96191599999999999f, 0.14686099999999999f, 1.0f}, -{0.94189599999999996f, 0.96858999999999995f, 0.140956f, 1.0f}, -{0.94001500000000004f, 0.97515799999999997f, 0.131326f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/perceptual/plasma.txt b/extern/tfn/colormaps/perceptual/plasma.txt deleted file mode 100644 index b2fe60f..0000000 --- a/extern/tfn/colormaps/perceptual/plasma.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.050382999999999997, 0.029803, 0.52797499999999997, 1.0) -(0.063535999999999995, 0.028426, 0.53312400000000004, 1.0) -(0.075353000000000003, 0.027206000000000001, 0.53800700000000001, 1.0) -(0.086221999999999993, 0.026124999999999999, 0.54265799999999997, 1.0) -(0.096379000000000006, 0.025165, 0.54710300000000001, 1.0) -(0.10598, 0.024309000000000001, 0.55136799999999997, 1.0) -(0.115124, 0.023556000000000001, 0.55546799999999996, 1.0) -(0.123903, 0.022877999999999999, 0.559423, 1.0) -(0.132381, 0.022258, 0.56325000000000003, 1.0) -(0.14060300000000001, 0.021687000000000001, 0.56695899999999999, 1.0) -(0.14860699999999999, 0.021153999999999999, 0.57056200000000001, 1.0) -(0.156421, 0.020650999999999999, 0.57406500000000005, 1.0) -(0.16406999999999999, 0.020171000000000001, 0.57747800000000005, 1.0) -(0.171574, 0.019706000000000001, 0.58080600000000004, 1.0) -(0.17895, 0.019251999999999998, 0.58405399999999996, 1.0) -(0.18621299999999999, 0.018803, 0.58722799999999997, 1.0) -(0.19337399999999999, 0.018353999999999999, 0.59033000000000002, 1.0) -(0.20044500000000001, 0.017902000000000001, 0.593364, 1.0) -(0.20743500000000001, 0.017441999999999999, 0.596333, 1.0) -(0.21435000000000001, 0.016972999999999999, 0.59923899999999997, 1.0) -(0.221197, 0.016497000000000001, 0.60208300000000003, 1.0) -(0.22798299999999999, 0.016007, 0.60486700000000004, 1.0) -(0.23471500000000001, 0.015502, 0.60759200000000002, 1.0) -(0.241396, 0.014978999999999999, 0.610259, 1.0) -(0.248032, 0.014439, 0.61286799999999997, 1.0) -(0.25462699999999999, 0.013882, 0.61541900000000005, 1.0) -(0.261183, 0.013308, 0.61791099999999999, 1.0) -(0.26770300000000002, 0.012716, 0.62034599999999995, 1.0) -(0.27419100000000002, 0.012109, 0.622722, 1.0) -(0.28064800000000001, 0.011488, 0.62503799999999998, 1.0) -(0.287076, 0.010855, 0.62729500000000005, 1.0) -(0.29347800000000002, 0.010213, 0.62948999999999999, 1.0) -(0.29985499999999998, 0.0095610000000000001, 0.63162399999999996, 1.0) -(0.30620999999999998, 0.0089020000000000002, 0.63369399999999998, 1.0) -(0.31254300000000002, 0.0082389999999999998, 0.63570000000000004, 1.0) -(0.31885599999999997, 0.0075760000000000003, 0.63763999999999998, 1.0) -(0.32514999999999999, 0.0069150000000000001, 0.63951199999999997, 1.0) -(0.331426, 0.0062610000000000001, 0.641316, 1.0) -(0.33768300000000001, 0.0056179999999999997, 0.64304899999999998, 1.0) -(0.34392499999999998, 0.0049909999999999998, 0.64471000000000001, 1.0) -(0.35015000000000002, 0.0043819999999999996, 0.64629800000000004, 1.0) -(0.35635899999999998, 0.0037980000000000002, 0.64781, 1.0) -(0.36255300000000001, 0.0032429999999999998, 0.64924499999999996, 1.0) -(0.36873299999999998, 0.0027239999999999999, 0.65060099999999998, 1.0) -(0.37489699999999998, 0.002245, 0.65187600000000001, 1.0) -(0.38104700000000002, 0.0018140000000000001, 0.65306799999999998, 1.0) -(0.387183, 0.0014339999999999999, 0.65417700000000001, 1.0) -(0.39330399999999999, 0.001114, 0.65519899999999998, 1.0) -(0.39941100000000002, 0.00085899999999999995, 0.65613299999999997, 1.0) -(0.405503, 0.000678, 0.65697700000000003, 1.0) -(0.41158, 0.00057700000000000004, 0.65773000000000004, 1.0) -(0.41764200000000001, 0.00056400000000000005, 0.65839000000000003, 1.0) -(0.42368899999999998, 0.00064599999999999998, 0.65895599999999999, 1.0) -(0.42971900000000002, 0.00083100000000000003, 0.65942500000000004, 1.0) -(0.43573400000000001, 0.001127, 0.65979699999999997, 1.0) -(0.44173200000000001, 0.0015399999999999999, 0.66006900000000002, 1.0) -(0.447714, 0.0020799999999999998, 0.66024000000000005, 1.0) -(0.453677, 0.0027550000000000001, 0.66030999999999995, 1.0) -(0.459623, 0.0035739999999999999, 0.660277, 1.0) -(0.46555000000000002, 0.0045450000000000004, 0.66013900000000003, 1.0) -(0.47145700000000001, 0.0056779999999999999, 0.65989699999999996, 1.0) -(0.47734399999999999, 0.0069800000000000001, 0.65954900000000005, 1.0) -(0.48320999999999997, 0.0084600000000000005, 0.65909499999999999, 1.0) -(0.48905500000000002, 0.010127000000000001, 0.65853399999999995, 1.0) -(0.49487700000000001, 0.011990000000000001, 0.65786500000000003, 1.0) -(0.50067799999999996, 0.014055, 0.65708800000000001, 1.0) -(0.50645399999999996, 0.016333, 0.65620199999999995, 1.0) -(0.51220600000000005, 0.018832999999999999, 0.65520900000000004, 1.0) -(0.51793299999999998, 0.021562999999999999, 0.65410900000000005, 1.0) -(0.52363300000000002, 0.024532000000000002, 0.65290099999999995, 1.0) -(0.52930600000000005, 0.027747000000000001, 0.651586, 1.0) -(0.53495199999999998, 0.031217000000000002, 0.65016499999999999, 1.0) -(0.54056999999999999, 0.034950000000000002, 0.64863999999999999, 1.0) -(0.546157, 0.038954000000000003, 0.64700999999999997, 1.0) -(0.55171499999999996, 0.043136000000000001, 0.64527699999999999, 1.0) -(0.55724300000000004, 0.047330999999999998, 0.64344299999999999, 1.0) -(0.56273799999999996, 0.051545000000000001, 0.641509, 1.0) -(0.56820099999999996, 0.055778000000000001, 0.63947699999999996, 1.0) -(0.57363200000000003, 0.060027999999999998, 0.63734900000000005, 1.0) -(0.57902900000000002, 0.064296000000000006, 0.63512599999999997, 1.0) -(0.58439099999999999, 0.068579000000000001, 0.63281200000000004, 1.0) -(0.58971899999999999, 0.072877999999999998, 0.63040799999999997, 1.0) -(0.59501099999999996, 0.077189999999999995, 0.62791699999999995, 1.0) -(0.60026599999999997, 0.081516000000000005, 0.62534199999999995, 1.0) -(0.60548500000000005, 0.085854, 0.62268599999999996, 1.0) -(0.61066699999999996, 0.090204000000000006, 0.61995100000000003, 1.0) -(0.61581200000000003, 0.094563999999999995, 0.61714000000000002, 1.0) -(0.620919, 0.098933999999999994, 0.61425700000000005, 1.0) -(0.62598699999999996, 0.103312, 0.61130499999999999, 1.0) -(0.63101700000000005, 0.107699, 0.60828700000000002, 1.0) -(0.63600800000000002, 0.112092, 0.60520499999999999, 1.0) -(0.64095899999999995, 0.116492, 0.60206499999999996, 1.0) -(0.645872, 0.12089800000000001, 0.59886700000000004, 1.0) -(0.65074600000000005, 0.125309, 0.59561699999999995, 1.0) -(0.65558000000000005, 0.12972500000000001, 0.59231699999999998, 1.0) -(0.66037400000000002, 0.13414400000000001, 0.58897100000000002, 1.0) -(0.66512899999999997, 0.13856599999999999, 0.58558200000000005, 1.0) -(0.66984500000000002, 0.14299200000000001, 0.58215399999999995, 1.0) -(0.67452199999999995, 0.14741899999999999, 0.57868799999999998, 1.0) -(0.67915999999999999, 0.15184800000000001, 0.57518899999999995, 1.0) -(0.68375799999999998, 0.156278, 0.57165999999999995, 1.0) -(0.68831799999999999, 0.16070899999999999, 0.56810300000000002, 1.0) -(0.69284000000000001, 0.16514100000000001, 0.56452199999999997, 1.0) -(0.69732400000000005, 0.169573, 0.56091899999999995, 1.0) -(0.70176899999999998, 0.17400499999999999, 0.55729600000000001, 1.0) -(0.70617799999999997, 0.17843700000000001, 0.55365699999999995, 1.0) -(0.71054899999999999, 0.182868, 0.55000400000000005, 1.0) -(0.71488300000000005, 0.18729899999999999, 0.54633799999999999, 1.0) -(0.71918099999999996, 0.19172900000000001, 0.54266300000000001, 1.0) -(0.72344399999999998, 0.196158, 0.53898100000000004, 1.0) -(0.72767000000000004, 0.20058599999999999, 0.53529300000000002, 1.0) -(0.73186200000000001, 0.205013, 0.53160099999999999, 1.0) -(0.73601899999999998, 0.20943899999999999, 0.52790800000000004, 1.0) -(0.740143, 0.213864, 0.52421600000000002, 1.0) -(0.744232, 0.21828800000000001, 0.52052399999999999, 1.0) -(0.74828899999999998, 0.22271099999999999, 0.51683400000000002, 1.0) -(0.75231199999999998, 0.227133, 0.51314899999999997, 1.0) -(0.75630399999999998, 0.23155500000000001, 0.50946800000000003, 1.0) -(0.76026400000000005, 0.23597599999999999, 0.50579399999999997, 1.0) -(0.76419300000000001, 0.240396, 0.50212599999999996, 1.0) -(0.76809000000000005, 0.24481700000000001, 0.49846499999999999, 1.0) -(0.77195800000000003, 0.24923699999999999, 0.494813, 1.0) -(0.77579600000000004, 0.25365799999999999, 0.49117100000000002, 1.0) -(0.77960399999999996, 0.25807799999999997, 0.487539, 1.0) -(0.78338300000000005, 0.26250000000000001, 0.48391800000000001, 1.0) -(0.78713299999999997, 0.26692199999999999, 0.48030699999999998, 1.0) -(0.79085499999999997, 0.271345, 0.47670600000000002, 1.0) -(0.79454899999999995, 0.27577000000000002, 0.47311700000000001, 1.0) -(0.79821600000000004, 0.28019699999999997, 0.46953800000000001, 1.0) -(0.80185499999999998, 0.28462599999999999, 0.46597100000000002, 1.0) -(0.80546700000000004, 0.28905700000000001, 0.46241500000000002, 1.0) -(0.80905199999999999, 0.293491, 0.45887, 1.0) -(0.812612, 0.29792800000000003, 0.45533800000000002, 1.0) -(0.81614399999999998, 0.30236800000000003, 0.451816, 1.0) -(0.81965100000000002, 0.30681199999999997, 0.44830599999999998, 1.0) -(0.82313199999999997, 0.31126100000000001, 0.44480599999999998, 1.0) -(0.82658799999999999, 0.31571399999999999, 0.44131599999999999, 1.0) -(0.83001800000000003, 0.32017200000000001, 0.437836, 1.0) -(0.833422, 0.32463500000000001, 0.43436599999999997, 1.0) -(0.83680100000000002, 0.32910499999999998, 0.43090499999999998, 1.0) -(0.84015499999999999, 0.33357999999999999, 0.42745499999999997, 1.0) -(0.84348400000000001, 0.33806199999999997, 0.42401299999999997, 1.0) -(0.84678799999999999, 0.34255099999999999, 0.42057899999999998, 1.0) -(0.85006599999999999, 0.34704800000000002, 0.417153, 1.0) -(0.85331900000000005, 0.351553, 0.41373399999999999, 1.0) -(0.85654699999999995, 0.35606599999999999, 0.41032200000000002, 1.0) -(0.85975000000000001, 0.36058800000000002, 0.40691699999999997, 1.0) -(0.862927, 0.36511900000000003, 0.40351900000000002, 1.0) -(0.86607800000000001, 0.36965999999999999, 0.40012599999999998, 1.0) -(0.86920299999999995, 0.37421199999999999, 0.39673799999999998, 1.0) -(0.87230300000000005, 0.378774, 0.39335500000000001, 1.0) -(0.87537600000000004, 0.38334699999999999, 0.38997599999999999, 1.0) -(0.87842299999999995, 0.387932, 0.3866, 1.0) -(0.88144299999999998, 0.39252900000000002, 0.38322899999999999, 1.0) -(0.884436, 0.39713900000000002, 0.37985999999999998, 1.0) -(0.88740200000000002, 0.40176200000000001, 0.376494, 1.0) -(0.89034000000000002, 0.40639799999999998, 0.37313000000000002, 1.0) -(0.89324999999999999, 0.41104800000000002, 0.36976799999999999, 1.0) -(0.89613100000000001, 0.41571200000000003, 0.36640699999999998, 1.0) -(0.89898400000000001, 0.42039199999999999, 0.36304700000000001, 1.0) -(0.90180700000000003, 0.42508699999999999, 0.35968800000000001, 1.0) -(0.90460099999999999, 0.42979699999999998, 0.35632900000000001, 1.0) -(0.90736499999999998, 0.43452400000000002, 0.35297000000000001, 1.0) -(0.91009799999999996, 0.43926799999999999, 0.34960999999999998, 1.0) -(0.91279999999999994, 0.44402900000000001, 0.34625099999999998, 1.0) -(0.91547100000000003, 0.44880700000000001, 0.34288999999999997, 1.0) -(0.91810899999999995, 0.45360299999999998, 0.33952900000000003, 1.0) -(0.92071400000000003, 0.45841700000000002, 0.33616600000000002, 1.0) -(0.92328699999999997, 0.46325100000000002, 0.33280100000000001, 1.0) -(0.92582500000000001, 0.46810299999999999, 0.32943499999999998, 1.0) -(0.92832899999999996, 0.47297499999999998, 0.326067, 1.0) -(0.93079800000000001, 0.47786699999999999, 0.32269700000000001, 1.0) -(0.93323199999999995, 0.48277999999999999, 0.31932500000000003, 1.0) -(0.93562999999999996, 0.48771199999999998, 0.31595200000000001, 1.0) -(0.93798999999999999, 0.49266700000000002, 0.31257499999999999, 1.0) -(0.94031299999999995, 0.49764199999999997, 0.309197, 1.0) -(0.94259800000000005, 0.50263899999999995, 0.30581599999999998, 1.0) -(0.94484400000000002, 0.50765800000000005, 0.30243300000000001, 1.0) -(0.94705099999999998, 0.51269900000000002, 0.29904900000000001, 1.0) -(0.94921699999999998, 0.51776299999999997, 0.29566199999999998, 1.0) -(0.95134399999999997, 0.52285000000000004, 0.29227500000000001, 1.0) -(0.95342800000000005, 0.52795999999999998, 0.288883, 1.0) -(0.95547000000000004, 0.53309300000000004, 0.28549000000000002, 1.0) -(0.95746900000000001, 0.53825000000000001, 0.28209600000000001, 1.0) -(0.95942400000000005, 0.543431, 0.27870099999999998, 1.0) -(0.96133599999999997, 0.54863600000000001, 0.27530500000000002, 1.0) -(0.96320300000000003, 0.55386500000000005, 0.27190900000000001, 1.0) -(0.96502399999999999, 0.559118, 0.268513, 1.0) -(0.96679800000000005, 0.56439600000000001, 0.26511800000000002, 1.0) -(0.968526, 0.56969999999999998, 0.26172099999999998, 1.0) -(0.97020499999999998, 0.57502799999999998, 0.25832500000000003, 1.0) -(0.971835, 0.58038199999999995, 0.25493100000000002, 1.0) -(0.97341599999999995, 0.58576099999999998, 0.25153999999999999, 1.0) -(0.97494700000000001, 0.59116500000000005, 0.24815100000000001, 1.0) -(0.97642799999999996, 0.59659499999999999, 0.24476700000000001, 1.0) -(0.97785599999999995, 0.602051, 0.24138699999999999, 1.0) -(0.97923300000000002, 0.60753199999999996, 0.238013, 1.0) -(0.98055599999999998, 0.613039, 0.23464599999999999, 1.0) -(0.98182599999999998, 0.61857200000000001, 0.23128699999999999, 1.0) -(0.98304100000000005, 0.62413099999999999, 0.227937, 1.0) -(0.98419900000000005, 0.629718, 0.22459499999999999, 1.0) -(0.98530099999999998, 0.63532999999999995, 0.22126499999999999, 1.0) -(0.98634500000000003, 0.64096900000000001, 0.217948, 1.0) -(0.98733199999999999, 0.64663300000000001, 0.21464800000000001, 1.0) -(0.98826000000000003, 0.65232500000000004, 0.211364, 1.0) -(0.98912800000000001, 0.65804300000000004, 0.20810000000000001, 1.0) -(0.98993500000000001, 0.66378700000000002, 0.20485900000000001, 1.0) -(0.99068100000000003, 0.66955799999999999, 0.20164199999999999, 1.0) -(0.99136500000000005, 0.67535500000000004, 0.19845299999999999, 1.0) -(0.99198500000000001, 0.68117899999999998, 0.195295, 1.0) -(0.99254100000000001, 0.68703000000000003, 0.19217000000000001, 1.0) -(0.99303200000000003, 0.69290700000000005, 0.189084, 1.0) -(0.99345600000000001, 0.69881000000000004, 0.18604100000000001, 1.0) -(0.99381399999999998, 0.70474099999999995, 0.18304300000000001, 1.0) -(0.99410299999999996, 0.71069800000000005, 0.18009700000000001, 1.0) -(0.99432399999999999, 0.71668100000000001, 0.177208, 1.0) -(0.99447399999999997, 0.72269099999999997, 0.17438100000000001, 1.0) -(0.99455300000000002, 0.72872800000000004, 0.171622, 1.0) -(0.99456100000000003, 0.73479099999999997, 0.168938, 1.0) -(0.99449500000000002, 0.74087999999999998, 0.16633500000000001, 1.0) -(0.99435499999999999, 0.74699499999999996, 0.16382099999999999, 1.0) -(0.99414100000000005, 0.75313699999999995, 0.16140399999999999, 1.0) -(0.99385100000000004, 0.75930399999999998, 0.15909200000000001, 1.0) -(0.99348199999999998, 0.76549900000000004, 0.156891, 1.0) -(0.99303300000000005, 0.77171999999999996, 0.154808, 1.0) -(0.99250499999999997, 0.77796699999999996, 0.15285499999999999, 1.0) -(0.99189700000000003, 0.78423900000000002, 0.15104200000000001, 1.0) -(0.99120900000000001, 0.79053700000000005, 0.14937700000000001, 1.0) -(0.99043899999999996, 0.79685899999999998, 0.14787, 1.0) -(0.98958699999999999, 0.80320499999999995, 0.14652899999999999, 1.0) -(0.98864799999999997, 0.80957900000000005, 0.14535699999999999, 1.0) -(0.98762099999999997, 0.81597799999999998, 0.14436299999999999, 1.0) -(0.98650899999999997, 0.82240100000000005, 0.14355699999999999, 1.0) -(0.98531400000000002, 0.82884599999999997, 0.14294499999999999, 1.0) -(0.98403099999999999, 0.83531500000000003, 0.14252799999999999, 1.0) -(0.982653, 0.841812, 0.14230300000000001, 1.0) -(0.98119000000000001, 0.848329, 0.14227899999999999, 1.0) -(0.97964399999999996, 0.85486600000000001, 0.142453, 1.0) -(0.97799499999999995, 0.86143199999999998, 0.14280799999999999, 1.0) -(0.97626500000000005, 0.86801600000000001, 0.14335100000000001, 1.0) -(0.97444299999999995, 0.87462200000000001, 0.14406099999999999, 1.0) -(0.97253000000000001, 0.88124999999999998, 0.144923, 1.0) -(0.97053299999999998, 0.88789600000000002, 0.14591899999999999, 1.0) -(0.96844300000000005, 0.89456400000000003, 0.14701400000000001, 1.0) -(0.96627099999999999, 0.90124899999999997, 0.14818000000000001, 1.0) -(0.96402100000000002, 0.90795000000000003, 0.14937, 1.0) -(0.96168100000000001, 0.91467200000000004, 0.15051999999999999, 1.0) -(0.95927600000000002, 0.92140699999999998, 0.15156600000000001, 1.0) -(0.95680799999999999, 0.92815199999999998, 0.15240899999999999, 1.0) -(0.954287, 0.93490799999999996, 0.152921, 1.0) -(0.95172599999999996, 0.94167100000000004, 0.15292500000000001, 1.0) -(0.94915099999999997, 0.94843500000000003, 0.15217800000000001, 1.0) -(0.94660200000000005, 0.95518999999999998, 0.15032799999999999, 1.0) -(0.94415199999999999, 0.96191599999999999, 0.14686099999999999, 1.0) -(0.94189599999999996, 0.96858999999999995, 0.140956, 1.0) -(0.94001500000000004, 0.97515799999999997, 0.131326, 1.0) diff --git a/extern/tfn/colormaps/perceptual/viridis.cpp b/extern/tfn/colormaps/perceptual/viridis.cpp deleted file mode 100644 index 6f1fde0..0000000 --- a/extern/tfn/colormaps/perceptual/viridis.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_perceptual_viridis; -} -const std::vector colormap::data_perceptual_viridis = /* NOLINT(cert-err58-cpp) */ -{ -{0.26700400000000002f, 0.0048739999999999999f, 0.32941500000000001f, 1.0f}, -{0.26851000000000003f, 0.0096050000000000007f, 0.33542699999999998f, 1.0f}, -{0.26994400000000002f, 0.014625000000000001f, 0.34137899999999999f, 1.0f}, -{0.27130500000000002f, 0.019942000000000001f, 0.34726899999999999f, 1.0f}, -{0.272594f, 0.025562999999999999f, 0.35309299999999999f, 1.0f}, -{0.27380900000000002f, 0.031496999999999997f, 0.35885299999999998f, 1.0f}, -{0.27495199999999997f, 0.037752000000000001f, 0.36454300000000001f, 1.0f}, -{0.27602199999999999f, 0.044166999999999998f, 0.37016399999999999f, 1.0f}, -{0.27701799999999999f, 0.050344f, 0.37571500000000002f, 1.0f}, -{0.27794099999999999f, 0.056323999999999999f, 0.381191f, 1.0f}, -{0.27879100000000001f, 0.062144999999999999f, 0.38659199999999999f, 1.0f}, -{0.27956599999999998f, 0.067835999999999994f, 0.39191700000000002f, 1.0f}, -{0.28026699999999999f, 0.073416999999999996f, 0.39716299999999999f, 1.0f}, -{0.28089399999999998f, 0.078907000000000005f, 0.40232899999999999f, 1.0f}, -{0.28144599999999997f, 0.084320000000000006f, 0.407414f, 1.0f}, -{0.28192400000000001f, 0.089665999999999996f, 0.41241499999999998f, 1.0f}, -{0.28232699999999999f, 0.094954999999999998f, 0.41733100000000001f, 1.0f}, -{0.28265600000000002f, 0.10019599999999999f, 0.42215999999999998f, 1.0f}, -{0.28290999999999999f, 0.105393f, 0.426902f, 1.0f}, -{0.28309099999999998f, 0.110553f, 0.43155399999999999f, 1.0f}, -{0.28319699999999998f, 0.11568000000000001f, 0.43611499999999997f, 1.0f}, -{0.28322900000000001f, 0.120777f, 0.44058399999999998f, 1.0f}, -{0.28318700000000002f, 0.12584799999999999f, 0.44496000000000002f, 1.0f}, -{0.28307199999999999f, 0.13089500000000001f, 0.449241f, 1.0f}, -{0.28288400000000002f, 0.13592000000000001f, 0.45342700000000002f, 1.0f}, -{0.28262300000000001f, 0.140926f, 0.45751700000000001f, 1.0f}, -{0.28228999999999999f, 0.14591199999999999f, 0.46150999999999998f, 1.0f}, -{0.281887f, 0.15088099999999999f, 0.46540500000000001f, 1.0f}, -{0.281412f, 0.155834f, 0.46920099999999998f, 1.0f}, -{0.28086800000000001f, 0.160771f, 0.47289900000000001f, 1.0f}, -{0.28025499999999998f, 0.16569300000000001f, 0.47649799999999998f, 1.0f}, -{0.27957399999999999f, 0.170599f, 0.47999700000000001f, 1.0f}, -{0.27882600000000002f, 0.17549000000000001f, 0.48339700000000002f, 1.0f}, -{0.27801199999999998f, 0.180367f, 0.48669699999999999f, 1.0f}, -{0.27713399999999999f, 0.185228f, 0.489898f, 1.0f}, -{0.276194f, 0.19007399999999999f, 0.49300100000000002f, 1.0f}, -{0.27519100000000002f, 0.19490499999999999f, 0.49600499999999997f, 1.0f}, -{0.27412799999999998f, 0.19972100000000001f, 0.49891099999999999f, 1.0f}, -{0.27300600000000003f, 0.20452000000000001f, 0.50172099999999997f, 1.0f}, -{0.27182800000000001f, 0.20930299999999999f, 0.50443400000000005f, 1.0f}, -{0.27059499999999997f, 0.21406900000000001f, 0.50705199999999995f, 1.0f}, -{0.26930799999999999f, 0.21881800000000001f, 0.50957699999999995f, 1.0f}, -{0.26796799999999998f, 0.223549f, 0.51200800000000002f, 1.0f}, -{0.26657999999999998f, 0.22826199999999999f, 0.51434899999999995f, 1.0f}, -{0.26514500000000002f, 0.232956f, 0.51659900000000003f, 1.0f}, -{0.26366299999999998f, 0.23763100000000001f, 0.51876199999999995f, 1.0f}, -{0.26213799999999998f, 0.242286f, 0.52083699999999999f, 1.0f}, -{0.260571f, 0.246922f, 0.52282799999999996f, 1.0f}, -{0.258965f, 0.25153700000000001f, 0.52473599999999998f, 1.0f}, -{0.257322f, 0.25613000000000002f, 0.526563f, 1.0f}, -{0.25564500000000001f, 0.26070300000000002f, 0.528312f, 1.0f}, -{0.25393500000000002f, 0.26525399999999999f, 0.52998299999999998f, 1.0f}, -{0.25219399999999997f, 0.269783f, 0.53157900000000002f, 1.0f}, -{0.25042500000000001f, 0.27428999999999998f, 0.53310299999999999f, 1.0f}, -{0.24862899999999999f, 0.278775f, 0.53455600000000003f, 1.0f}, -{0.246811f, 0.28323700000000002f, 0.535941f, 1.0f}, -{0.244972f, 0.28767500000000001f, 0.53725999999999996f, 1.0f}, -{0.243113f, 0.29209200000000002f, 0.53851599999999999f, 1.0f}, -{0.24123700000000001f, 0.296485f, 0.53970899999999999f, 1.0f}, -{0.239346f, 0.30085499999999998f, 0.54084399999999999f, 1.0f}, -{0.23744100000000001f, 0.30520199999999997f, 0.54192099999999999f, 1.0f}, -{0.23552600000000001f, 0.309527f, 0.54294399999999998f, 1.0f}, -{0.23360300000000001f, 0.313828f, 0.54391400000000001f, 1.0f}, -{0.23167399999999999f, 0.318106f, 0.54483400000000004f, 1.0f}, -{0.229739f, 0.32236100000000001f, 0.54570600000000002f, 1.0f}, -{0.227802f, 0.326594f, 0.54653200000000002f, 1.0f}, -{0.22586300000000001f, 0.33080500000000002f, 0.54731399999999997f, 1.0f}, -{0.22392500000000001f, 0.33499400000000001f, 0.54805300000000001f, 1.0f}, -{0.22198899999999999f, 0.33916099999999999f, 0.54875200000000002f, 1.0f}, -{0.220057f, 0.34330699999999997f, 0.54941300000000004f, 1.0f}, -{0.21812999999999999f, 0.34743200000000002f, 0.55003800000000003f, 1.0f}, -{0.21621000000000001f, 0.35153499999999999f, 0.55062699999999998f, 1.0f}, -{0.21429799999999999f, 0.35561900000000002f, 0.55118400000000001f, 1.0f}, -{0.212395f, 0.35968299999999997f, 0.55171000000000003f, 1.0f}, -{0.210503f, 0.36372700000000002f, 0.55220599999999997f, 1.0f}, -{0.208623f, 0.36775200000000002f, 0.55267500000000003f, 1.0f}, -{0.206756f, 0.37175799999999998f, 0.55311699999999997f, 1.0f}, -{0.204903f, 0.37574600000000002f, 0.55353300000000005f, 1.0f}, -{0.20306299999999999f, 0.379716f, 0.553925f, 1.0f}, -{0.201239f, 0.38367000000000001f, 0.55429399999999995f, 1.0f}, -{0.19943f, 0.38760699999999998f, 0.55464199999999997f, 1.0f}, -{0.19763600000000001f, 0.39152799999999999f, 0.55496900000000005f, 1.0f}, -{0.19586000000000001f, 0.39543299999999998f, 0.55527599999999999f, 1.0f}, -{0.19409999999999999f, 0.39932299999999998f, 0.55556499999999998f, 1.0f}, -{0.192357f, 0.40319899999999997f, 0.555836f, 1.0f}, -{0.19063099999999999f, 0.40706100000000001f, 0.55608900000000006f, 1.0f}, -{0.18892300000000001f, 0.41091f, 0.55632599999999999f, 1.0f}, -{0.18723100000000001f, 0.414746f, 0.55654700000000001f, 1.0f}, -{0.185556f, 0.41857f, 0.55675300000000005f, 1.0f}, -{0.18389800000000001f, 0.42238300000000001f, 0.55694399999999999f, 1.0f}, -{0.182256f, 0.42618400000000001f, 0.55711999999999995f, 1.0f}, -{0.18062900000000001f, 0.429975f, 0.55728200000000006f, 1.0f}, -{0.17901900000000001f, 0.43375599999999997f, 0.55742999999999998f, 1.0f}, -{0.177423f, 0.437527f, 0.55756499999999998f, 1.0f}, -{0.175841f, 0.44129000000000002f, 0.55768499999999999f, 1.0f}, -{0.17427400000000001f, 0.445044f, 0.55779199999999995f, 1.0f}, -{0.17271900000000001f, 0.448791f, 0.55788499999999996f, 1.0f}, -{0.17117599999999999f, 0.45252999999999999f, 0.55796500000000004f, 1.0f}, -{0.16964599999999999f, 0.456262f, 0.55803000000000003f, 1.0f}, -{0.168126f, 0.45998800000000001f, 0.55808199999999997f, 1.0f}, -{0.16661699999999999f, 0.46370800000000001f, 0.55811900000000003f, 1.0f}, -{0.16511700000000001f, 0.46742299999999998f, 0.558141f, 1.0f}, -{0.16362499999999999f, 0.47113300000000002f, 0.55814799999999998f, 1.0f}, -{0.16214200000000001f, 0.47483799999999998f, 0.55813999999999997f, 1.0f}, -{0.160665f, 0.47854000000000002f, 0.55811500000000003f, 1.0f}, -{0.159194f, 0.48223700000000003f, 0.55807300000000004f, 1.0f}, -{0.15772900000000001f, 0.48593199999999998f, 0.55801299999999998f, 1.0f}, -{0.15626999999999999f, 0.489624f, 0.55793599999999999f, 1.0f}, -{0.15481500000000001f, 0.493313f, 0.55784f, 1.0f}, -{0.153364f, 0.497f, 0.557724f, 1.0f}, -{0.151918f, 0.50068500000000005f, 0.55758700000000005f, 1.0f}, -{0.150476f, 0.50436899999999996f, 0.55742999999999998f, 1.0f}, -{0.149039f, 0.50805100000000003f, 0.55725000000000002f, 1.0f}, -{0.14760699999999999f, 0.51173299999999999f, 0.55704900000000002f, 1.0f}, -{0.14618f, 0.51541300000000001f, 0.55682299999999996f, 1.0f}, -{0.144759f, 0.51909300000000003f, 0.55657199999999996f, 1.0f}, -{0.143343f, 0.52277300000000004f, 0.55629499999999998f, 1.0f}, -{0.14193500000000001f, 0.52645299999999995f, 0.55599100000000001f, 1.0f}, -{0.14053599999999999f, 0.53013200000000005f, 0.55565900000000001f, 1.0f}, -{0.13914699999999999f, 0.53381199999999995f, 0.55529799999999996f, 1.0f}, -{0.13777f, 0.53749199999999997f, 0.55490600000000001f, 1.0f}, -{0.136408f, 0.54117300000000002f, 0.55448299999999995f, 1.0f}, -{0.13506599999999999f, 0.54485300000000003f, 0.55402899999999999f, 1.0f}, -{0.133743f, 0.54853499999999999f, 0.55354099999999995f, 1.0f}, -{0.13244400000000001f, 0.55221600000000004f, 0.55301800000000001f, 1.0f}, -{0.13117200000000001f, 0.55589900000000003f, 0.55245900000000003f, 1.0f}, -{0.12993299999999999f, 0.55958200000000002f, 0.55186400000000002f, 1.0f}, -{0.12872900000000001f, 0.56326500000000002f, 0.55122899999999997f, 1.0f}, -{0.12756799999999999f, 0.56694900000000004f, 0.55055600000000005f, 1.0f}, -{0.12645300000000001f, 0.57063299999999995f, 0.54984100000000002f, 1.0f}, -{0.12539400000000001f, 0.574318f, 0.54908599999999996f, 1.0f}, -{0.12439500000000001f, 0.57800200000000002f, 0.54828699999999997f, 1.0f}, -{0.123463f, 0.58168699999999995f, 0.54744499999999996f, 1.0f}, -{0.12260600000000001f, 0.58537099999999997f, 0.54655699999999996f, 1.0f}, -{0.12183099999999999f, 0.589055f, 0.54562299999999997f, 1.0f}, -{0.12114800000000001f, 0.59273900000000002f, 0.54464100000000004f, 1.0f}, -{0.12056500000000001f, 0.59642200000000001f, 0.54361099999999996f, 1.0f}, -{0.120092f, 0.60010399999999997f, 0.54252999999999996f, 1.0f}, -{0.119738f, 0.60378500000000002f, 0.54139999999999999f, 1.0f}, -{0.11951199999999999f, 0.607464f, 0.54021799999999998f, 1.0f}, -{0.119423f, 0.61114100000000005f, 0.53898199999999996f, 1.0f}, -{0.11948300000000001f, 0.61481699999999995f, 0.53769199999999995f, 1.0f}, -{0.119699f, 0.61848999999999998f, 0.53634700000000002f, 1.0f}, -{0.12008099999999999f, 0.62216099999999996f, 0.53494600000000003f, 1.0f}, -{0.120638f, 0.62582800000000005f, 0.53348799999999996f, 1.0f}, -{0.12138f, 0.62949200000000005f, 0.53197300000000003f, 1.0f}, -{0.122312f, 0.63315299999999997f, 0.53039800000000004f, 1.0f}, -{0.123444f, 0.63680899999999996f, 0.52876299999999998f, 1.0f}, -{0.12478f, 0.64046099999999995f, 0.52706799999999998f, 1.0f}, -{0.12632599999999999f, 0.64410699999999999f, 0.52531099999999997f, 1.0f}, -{0.12808700000000001f, 0.64774900000000002f, 0.52349100000000004f, 1.0f}, -{0.13006699999999999f, 0.65138399999999996f, 0.52160799999999996f, 1.0f}, -{0.132268f, 0.65501399999999999f, 0.51966100000000004f, 1.0f}, -{0.13469200000000001f, 0.658636f, 0.51764900000000003f, 1.0f}, -{0.13733899999999999f, 0.66225199999999995f, 0.515571f, 1.0f}, -{0.14021f, 0.66585899999999998f, 0.51342699999999997f, 1.0f}, -{0.14330300000000001f, 0.66945900000000003f, 0.51121499999999997f, 1.0f}, -{0.146616f, 0.67305000000000004f, 0.50893600000000006f, 1.0f}, -{0.150148f, 0.67663099999999998f, 0.50658899999999996f, 1.0f}, -{0.153894f, 0.680203f, 0.50417199999999995f, 1.0f}, -{0.15785099999999999f, 0.68376499999999996f, 0.50168599999999997f, 1.0f}, -{0.16201599999999999f, 0.68731600000000004f, 0.49912899999999999f, 1.0f}, -{0.166383f, 0.69085600000000003f, 0.496502f, 1.0f}, -{0.17094799999999999f, 0.694384f, 0.49380299999999999f, 1.0f}, -{0.175707f, 0.69789999999999996f, 0.491033f, 1.0f}, -{0.18065300000000001f, 0.70140199999999997f, 0.48818899999999998f, 1.0f}, -{0.185783f, 0.70489100000000005f, 0.48527300000000001f, 1.0f}, -{0.19109000000000001f, 0.70836600000000005f, 0.48228399999999999f, 1.0f}, -{0.196571f, 0.71182699999999999f, 0.47922100000000001f, 1.0f}, -{0.20221900000000001f, 0.71527200000000002f, 0.47608400000000001f, 1.0f}, -{0.20802999999999999f, 0.71870100000000003f, 0.47287299999999999f, 1.0f}, -{0.214f, 0.72211400000000003f, 0.46958800000000001f, 1.0f}, -{0.22012399999999999f, 0.72550899999999996f, 0.46622599999999997f, 1.0f}, -{0.22639699999999999f, 0.72888799999999998f, 0.46278900000000001f, 1.0f}, -{0.23281499999999999f, 0.73224699999999998f, 0.45927699999999999f, 1.0f}, -{0.239374f, 0.73558800000000002f, 0.45568799999999998f, 1.0f}, -{0.24607000000000001f, 0.73890999999999996f, 0.45202399999999998f, 1.0f}, -{0.25289899999999998f, 0.74221099999999995f, 0.44828400000000002f, 1.0f}, -{0.259857f, 0.74549200000000004f, 0.444467f, 1.0f}, -{0.26694099999999998f, 0.74875100000000006f, 0.44057299999999999f, 1.0f}, -{0.27414899999999998f, 0.75198799999999999f, 0.43660100000000002f, 1.0f}, -{0.28147699999999998f, 0.75520299999999996f, 0.43255199999999999f, 1.0f}, -{0.28892099999999998f, 0.75839400000000001f, 0.42842599999999997f, 1.0f}, -{0.29647899999999999f, 0.76156100000000004f, 0.42422300000000002f, 1.0f}, -{0.30414799999999997f, 0.76470400000000005f, 0.41994300000000001f, 1.0f}, -{0.31192500000000001f, 0.767822f, 0.41558600000000001f, 1.0f}, -{0.31980900000000001f, 0.77091399999999999f, 0.41115200000000002f, 1.0f}, -{0.32779599999999998f, 0.77398f, 0.40664f, 1.0f}, -{0.33588499999999999f, 0.77701799999999999f, 0.40204899999999999f, 1.0f}, -{0.34407399999999999f, 0.78002899999999997f, 0.39738099999999998f, 1.0f}, -{0.35236000000000001f, 0.78301100000000001f, 0.39263599999999999f, 1.0f}, -{0.36074099999999998f, 0.785964f, 0.38781399999999999f, 1.0f}, -{0.36921399999999999f, 0.78888800000000003f, 0.38291399999999998f, 1.0f}, -{0.37777899999999998f, 0.79178099999999996f, 0.37793900000000002f, 1.0f}, -{0.38643300000000003f, 0.79464400000000002f, 0.372886f, 1.0f}, -{0.39517400000000003f, 0.79747500000000004f, 0.367757f, 1.0f}, -{0.404001f, 0.80027499999999996f, 0.36255199999999999f, 1.0f}, -{0.41291299999999997f, 0.803041f, 0.357269f, 1.0f}, -{0.42190800000000001f, 0.80577399999999999f, 0.35191f, 1.0f}, -{0.430983f, 0.808473f, 0.34647600000000001f, 1.0f}, -{0.440137f, 0.81113800000000003f, 0.34096700000000002f, 1.0f}, -{0.44936799999999999f, 0.81376800000000005f, 0.33538400000000002f, 1.0f}, -{0.45867400000000003f, 0.81636299999999995f, 0.32972699999999999f, 1.0f}, -{0.468053f, 0.81892100000000001f, 0.32399800000000001f, 1.0f}, -{0.47750399999999998f, 0.82144399999999995f, 0.31819500000000001f, 1.0f}, -{0.48702600000000001f, 0.82392900000000002f, 0.31232100000000002f, 1.0f}, -{0.49661499999999997f, 0.826376f, 0.30637700000000001f, 1.0f}, -{0.50627100000000003f, 0.82878600000000002f, 0.30036200000000002f, 1.0f}, -{0.51599200000000001f, 0.83115799999999995f, 0.29427900000000001f, 1.0f}, -{0.52577600000000002f, 0.83349099999999998f, 0.28812700000000002f, 1.0f}, -{0.53562100000000001f, 0.835785f, 0.28190799999999999f, 1.0f}, -{0.54552400000000001f, 0.83803899999999998f, 0.27562599999999998f, 1.0f}, -{0.55548399999999998f, 0.84025399999999995f, 0.26928099999999999f, 1.0f}, -{0.56549799999999995f, 0.84243000000000001f, 0.26287700000000003f, 1.0f}, -{0.57556300000000005f, 0.84456600000000004f, 0.256415f, 1.0f}, -{0.58567800000000003f, 0.846661f, 0.24989700000000001f, 1.0f}, -{0.59583900000000001f, 0.84871700000000005f, 0.24332899999999999f, 1.0f}, -{0.60604499999999994f, 0.85073299999999996f, 0.23671200000000001f, 1.0f}, -{0.61629299999999998f, 0.85270900000000005f, 0.23005200000000001f, 1.0f}, -{0.626579f, 0.85464499999999999f, 0.223353f, 1.0f}, -{0.63690199999999997f, 0.85654200000000003f, 0.21662000000000001f, 1.0f}, -{0.64725699999999997f, 0.85840000000000005f, 0.20986099999999999f, 1.0f}, -{0.65764199999999995f, 0.86021899999999996f, 0.20308200000000001f, 1.0f}, -{0.66805400000000004f, 0.86199899999999996f, 0.196293f, 1.0f}, -{0.67848900000000001f, 0.86374200000000001f, 0.189503f, 1.0f}, -{0.688944f, 0.865448f, 0.182725f, 1.0f}, -{0.69941500000000001f, 0.86711700000000003f, 0.17597099999999999f, 1.0f}, -{0.70989800000000003f, 0.86875100000000005f, 0.16925699999999999f, 1.0f}, -{0.720391f, 0.87034999999999996f, 0.162603f, 1.0f}, -{0.73088900000000001f, 0.87191600000000002f, 0.156029f, 1.0f}, -{0.74138800000000005f, 0.87344900000000003f, 0.149561f, 1.0f}, -{0.751884f, 0.87495100000000003f, 0.14322799999999999f, 1.0f}, -{0.76237299999999997f, 0.87642399999999998f, 0.13706399999999999f, 1.0f}, -{0.77285199999999998f, 0.87786799999999998f, 0.131109f, 1.0f}, -{0.78331499999999998f, 0.87928499999999998f, 0.12540499999999999f, 1.0f}, -{0.79376000000000002f, 0.88067799999999996f, 0.120005f, 1.0f}, -{0.80418199999999995f, 0.882046f, 0.114965f, 1.0f}, -{0.81457599999999997f, 0.88339299999999998f, 0.110347f, 1.0f}, -{0.82494000000000001f, 0.88471999999999995f, 0.10621700000000001f, 1.0f}, -{0.83526999999999996f, 0.88602899999999996f, 0.102646f, 1.0f}, -{0.84556100000000001f, 0.88732200000000006f, 0.099701999999999999f, 1.0f}, -{0.85580999999999996f, 0.88860099999999997f, 0.097451999999999997f, 1.0f}, -{0.86601300000000003f, 0.88986799999999999f, 0.095952999999999997f, 1.0f}, -{0.87616799999999995f, 0.89112499999999994f, 0.095250000000000001f, 1.0f}, -{0.88627100000000003f, 0.892374f, 0.095374f, 1.0f}, -{0.89632000000000001f, 0.89361599999999997f, 0.096335000000000004f, 1.0f}, -{0.90631099999999998f, 0.89485499999999996f, 0.098125000000000004f, 1.0f}, -{0.916242f, 0.89609099999999997f, 0.100717f, 1.0f}, -{0.92610599999999998f, 0.89732999999999996f, 0.104071f, 1.0f}, -{0.93590399999999996f, 0.89856999999999998f, 0.108131f, 1.0f}, -{0.94563600000000003f, 0.89981500000000003f, 0.11283799999999999f, 1.0f}, -{0.95530000000000004f, 0.901065f, 0.118128f, 1.0f}, -{0.96489400000000003f, 0.90232299999999999f, 0.123941f, 1.0f}, -{0.97441699999999998f, 0.90359f, 0.130215f, 1.0f}, -{0.98386799999999996f, 0.90486699999999998f, 0.13689699999999999f, 1.0f}, -{0.99324800000000002f, 0.90615699999999999f, 0.14393600000000001f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/perceptual/viridis.txt b/extern/tfn/colormaps/perceptual/viridis.txt deleted file mode 100644 index fb12ad8..0000000 --- a/extern/tfn/colormaps/perceptual/viridis.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.26700400000000002, 0.0048739999999999999, 0.32941500000000001, 1.0) -(0.26851000000000003, 0.0096050000000000007, 0.33542699999999998, 1.0) -(0.26994400000000002, 0.014625000000000001, 0.34137899999999999, 1.0) -(0.27130500000000002, 0.019942000000000001, 0.34726899999999999, 1.0) -(0.272594, 0.025562999999999999, 0.35309299999999999, 1.0) -(0.27380900000000002, 0.031496999999999997, 0.35885299999999998, 1.0) -(0.27495199999999997, 0.037752000000000001, 0.36454300000000001, 1.0) -(0.27602199999999999, 0.044166999999999998, 0.37016399999999999, 1.0) -(0.27701799999999999, 0.050344, 0.37571500000000002, 1.0) -(0.27794099999999999, 0.056323999999999999, 0.381191, 1.0) -(0.27879100000000001, 0.062144999999999999, 0.38659199999999999, 1.0) -(0.27956599999999998, 0.067835999999999994, 0.39191700000000002, 1.0) -(0.28026699999999999, 0.073416999999999996, 0.39716299999999999, 1.0) -(0.28089399999999998, 0.078907000000000005, 0.40232899999999999, 1.0) -(0.28144599999999997, 0.084320000000000006, 0.407414, 1.0) -(0.28192400000000001, 0.089665999999999996, 0.41241499999999998, 1.0) -(0.28232699999999999, 0.094954999999999998, 0.41733100000000001, 1.0) -(0.28265600000000002, 0.10019599999999999, 0.42215999999999998, 1.0) -(0.28290999999999999, 0.105393, 0.426902, 1.0) -(0.28309099999999998, 0.110553, 0.43155399999999999, 1.0) -(0.28319699999999998, 0.11568000000000001, 0.43611499999999997, 1.0) -(0.28322900000000001, 0.120777, 0.44058399999999998, 1.0) -(0.28318700000000002, 0.12584799999999999, 0.44496000000000002, 1.0) -(0.28307199999999999, 0.13089500000000001, 0.449241, 1.0) -(0.28288400000000002, 0.13592000000000001, 0.45342700000000002, 1.0) -(0.28262300000000001, 0.140926, 0.45751700000000001, 1.0) -(0.28228999999999999, 0.14591199999999999, 0.46150999999999998, 1.0) -(0.281887, 0.15088099999999999, 0.46540500000000001, 1.0) -(0.281412, 0.155834, 0.46920099999999998, 1.0) -(0.28086800000000001, 0.160771, 0.47289900000000001, 1.0) -(0.28025499999999998, 0.16569300000000001, 0.47649799999999998, 1.0) -(0.27957399999999999, 0.170599, 0.47999700000000001, 1.0) -(0.27882600000000002, 0.17549000000000001, 0.48339700000000002, 1.0) -(0.27801199999999998, 0.180367, 0.48669699999999999, 1.0) -(0.27713399999999999, 0.185228, 0.489898, 1.0) -(0.276194, 0.19007399999999999, 0.49300100000000002, 1.0) -(0.27519100000000002, 0.19490499999999999, 0.49600499999999997, 1.0) -(0.27412799999999998, 0.19972100000000001, 0.49891099999999999, 1.0) -(0.27300600000000003, 0.20452000000000001, 0.50172099999999997, 1.0) -(0.27182800000000001, 0.20930299999999999, 0.50443400000000005, 1.0) -(0.27059499999999997, 0.21406900000000001, 0.50705199999999995, 1.0) -(0.26930799999999999, 0.21881800000000001, 0.50957699999999995, 1.0) -(0.26796799999999998, 0.223549, 0.51200800000000002, 1.0) -(0.26657999999999998, 0.22826199999999999, 0.51434899999999995, 1.0) -(0.26514500000000002, 0.232956, 0.51659900000000003, 1.0) -(0.26366299999999998, 0.23763100000000001, 0.51876199999999995, 1.0) -(0.26213799999999998, 0.242286, 0.52083699999999999, 1.0) -(0.260571, 0.246922, 0.52282799999999996, 1.0) -(0.258965, 0.25153700000000001, 0.52473599999999998, 1.0) -(0.257322, 0.25613000000000002, 0.526563, 1.0) -(0.25564500000000001, 0.26070300000000002, 0.528312, 1.0) -(0.25393500000000002, 0.26525399999999999, 0.52998299999999998, 1.0) -(0.25219399999999997, 0.269783, 0.53157900000000002, 1.0) -(0.25042500000000001, 0.27428999999999998, 0.53310299999999999, 1.0) -(0.24862899999999999, 0.278775, 0.53455600000000003, 1.0) -(0.246811, 0.28323700000000002, 0.535941, 1.0) -(0.244972, 0.28767500000000001, 0.53725999999999996, 1.0) -(0.243113, 0.29209200000000002, 0.53851599999999999, 1.0) -(0.24123700000000001, 0.296485, 0.53970899999999999, 1.0) -(0.239346, 0.30085499999999998, 0.54084399999999999, 1.0) -(0.23744100000000001, 0.30520199999999997, 0.54192099999999999, 1.0) -(0.23552600000000001, 0.309527, 0.54294399999999998, 1.0) -(0.23360300000000001, 0.313828, 0.54391400000000001, 1.0) -(0.23167399999999999, 0.318106, 0.54483400000000004, 1.0) -(0.229739, 0.32236100000000001, 0.54570600000000002, 1.0) -(0.227802, 0.326594, 0.54653200000000002, 1.0) -(0.22586300000000001, 0.33080500000000002, 0.54731399999999997, 1.0) -(0.22392500000000001, 0.33499400000000001, 0.54805300000000001, 1.0) -(0.22198899999999999, 0.33916099999999999, 0.54875200000000002, 1.0) -(0.220057, 0.34330699999999997, 0.54941300000000004, 1.0) -(0.21812999999999999, 0.34743200000000002, 0.55003800000000003, 1.0) -(0.21621000000000001, 0.35153499999999999, 0.55062699999999998, 1.0) -(0.21429799999999999, 0.35561900000000002, 0.55118400000000001, 1.0) -(0.212395, 0.35968299999999997, 0.55171000000000003, 1.0) -(0.210503, 0.36372700000000002, 0.55220599999999997, 1.0) -(0.208623, 0.36775200000000002, 0.55267500000000003, 1.0) -(0.206756, 0.37175799999999998, 0.55311699999999997, 1.0) -(0.204903, 0.37574600000000002, 0.55353300000000005, 1.0) -(0.20306299999999999, 0.379716, 0.553925, 1.0) -(0.201239, 0.38367000000000001, 0.55429399999999995, 1.0) -(0.19943, 0.38760699999999998, 0.55464199999999997, 1.0) -(0.19763600000000001, 0.39152799999999999, 0.55496900000000005, 1.0) -(0.19586000000000001, 0.39543299999999998, 0.55527599999999999, 1.0) -(0.19409999999999999, 0.39932299999999998, 0.55556499999999998, 1.0) -(0.192357, 0.40319899999999997, 0.555836, 1.0) -(0.19063099999999999, 0.40706100000000001, 0.55608900000000006, 1.0) -(0.18892300000000001, 0.41091, 0.55632599999999999, 1.0) -(0.18723100000000001, 0.414746, 0.55654700000000001, 1.0) -(0.185556, 0.41857, 0.55675300000000005, 1.0) -(0.18389800000000001, 0.42238300000000001, 0.55694399999999999, 1.0) -(0.182256, 0.42618400000000001, 0.55711999999999995, 1.0) -(0.18062900000000001, 0.429975, 0.55728200000000006, 1.0) -(0.17901900000000001, 0.43375599999999997, 0.55742999999999998, 1.0) -(0.177423, 0.437527, 0.55756499999999998, 1.0) -(0.175841, 0.44129000000000002, 0.55768499999999999, 1.0) -(0.17427400000000001, 0.445044, 0.55779199999999995, 1.0) -(0.17271900000000001, 0.448791, 0.55788499999999996, 1.0) -(0.17117599999999999, 0.45252999999999999, 0.55796500000000004, 1.0) -(0.16964599999999999, 0.456262, 0.55803000000000003, 1.0) -(0.168126, 0.45998800000000001, 0.55808199999999997, 1.0) -(0.16661699999999999, 0.46370800000000001, 0.55811900000000003, 1.0) -(0.16511700000000001, 0.46742299999999998, 0.558141, 1.0) -(0.16362499999999999, 0.47113300000000002, 0.55814799999999998, 1.0) -(0.16214200000000001, 0.47483799999999998, 0.55813999999999997, 1.0) -(0.160665, 0.47854000000000002, 0.55811500000000003, 1.0) -(0.159194, 0.48223700000000003, 0.55807300000000004, 1.0) -(0.15772900000000001, 0.48593199999999998, 0.55801299999999998, 1.0) -(0.15626999999999999, 0.489624, 0.55793599999999999, 1.0) -(0.15481500000000001, 0.493313, 0.55784, 1.0) -(0.153364, 0.497, 0.557724, 1.0) -(0.151918, 0.50068500000000005, 0.55758700000000005, 1.0) -(0.150476, 0.50436899999999996, 0.55742999999999998, 1.0) -(0.149039, 0.50805100000000003, 0.55725000000000002, 1.0) -(0.14760699999999999, 0.51173299999999999, 0.55704900000000002, 1.0) -(0.14618, 0.51541300000000001, 0.55682299999999996, 1.0) -(0.144759, 0.51909300000000003, 0.55657199999999996, 1.0) -(0.143343, 0.52277300000000004, 0.55629499999999998, 1.0) -(0.14193500000000001, 0.52645299999999995, 0.55599100000000001, 1.0) -(0.14053599999999999, 0.53013200000000005, 0.55565900000000001, 1.0) -(0.13914699999999999, 0.53381199999999995, 0.55529799999999996, 1.0) -(0.13777, 0.53749199999999997, 0.55490600000000001, 1.0) -(0.136408, 0.54117300000000002, 0.55448299999999995, 1.0) -(0.13506599999999999, 0.54485300000000003, 0.55402899999999999, 1.0) -(0.133743, 0.54853499999999999, 0.55354099999999995, 1.0) -(0.13244400000000001, 0.55221600000000004, 0.55301800000000001, 1.0) -(0.13117200000000001, 0.55589900000000003, 0.55245900000000003, 1.0) -(0.12993299999999999, 0.55958200000000002, 0.55186400000000002, 1.0) -(0.12872900000000001, 0.56326500000000002, 0.55122899999999997, 1.0) -(0.12756799999999999, 0.56694900000000004, 0.55055600000000005, 1.0) -(0.12645300000000001, 0.57063299999999995, 0.54984100000000002, 1.0) -(0.12539400000000001, 0.574318, 0.54908599999999996, 1.0) -(0.12439500000000001, 0.57800200000000002, 0.54828699999999997, 1.0) -(0.123463, 0.58168699999999995, 0.54744499999999996, 1.0) -(0.12260600000000001, 0.58537099999999997, 0.54655699999999996, 1.0) -(0.12183099999999999, 0.589055, 0.54562299999999997, 1.0) -(0.12114800000000001, 0.59273900000000002, 0.54464100000000004, 1.0) -(0.12056500000000001, 0.59642200000000001, 0.54361099999999996, 1.0) -(0.120092, 0.60010399999999997, 0.54252999999999996, 1.0) -(0.119738, 0.60378500000000002, 0.54139999999999999, 1.0) -(0.11951199999999999, 0.607464, 0.54021799999999998, 1.0) -(0.119423, 0.61114100000000005, 0.53898199999999996, 1.0) -(0.11948300000000001, 0.61481699999999995, 0.53769199999999995, 1.0) -(0.119699, 0.61848999999999998, 0.53634700000000002, 1.0) -(0.12008099999999999, 0.62216099999999996, 0.53494600000000003, 1.0) -(0.120638, 0.62582800000000005, 0.53348799999999996, 1.0) -(0.12138, 0.62949200000000005, 0.53197300000000003, 1.0) -(0.122312, 0.63315299999999997, 0.53039800000000004, 1.0) -(0.123444, 0.63680899999999996, 0.52876299999999998, 1.0) -(0.12478, 0.64046099999999995, 0.52706799999999998, 1.0) -(0.12632599999999999, 0.64410699999999999, 0.52531099999999997, 1.0) -(0.12808700000000001, 0.64774900000000002, 0.52349100000000004, 1.0) -(0.13006699999999999, 0.65138399999999996, 0.52160799999999996, 1.0) -(0.132268, 0.65501399999999999, 0.51966100000000004, 1.0) -(0.13469200000000001, 0.658636, 0.51764900000000003, 1.0) -(0.13733899999999999, 0.66225199999999995, 0.515571, 1.0) -(0.14021, 0.66585899999999998, 0.51342699999999997, 1.0) -(0.14330300000000001, 0.66945900000000003, 0.51121499999999997, 1.0) -(0.146616, 0.67305000000000004, 0.50893600000000006, 1.0) -(0.150148, 0.67663099999999998, 0.50658899999999996, 1.0) -(0.153894, 0.680203, 0.50417199999999995, 1.0) -(0.15785099999999999, 0.68376499999999996, 0.50168599999999997, 1.0) -(0.16201599999999999, 0.68731600000000004, 0.49912899999999999, 1.0) -(0.166383, 0.69085600000000003, 0.496502, 1.0) -(0.17094799999999999, 0.694384, 0.49380299999999999, 1.0) -(0.175707, 0.69789999999999996, 0.491033, 1.0) -(0.18065300000000001, 0.70140199999999997, 0.48818899999999998, 1.0) -(0.185783, 0.70489100000000005, 0.48527300000000001, 1.0) -(0.19109000000000001, 0.70836600000000005, 0.48228399999999999, 1.0) -(0.196571, 0.71182699999999999, 0.47922100000000001, 1.0) -(0.20221900000000001, 0.71527200000000002, 0.47608400000000001, 1.0) -(0.20802999999999999, 0.71870100000000003, 0.47287299999999999, 1.0) -(0.214, 0.72211400000000003, 0.46958800000000001, 1.0) -(0.22012399999999999, 0.72550899999999996, 0.46622599999999997, 1.0) -(0.22639699999999999, 0.72888799999999998, 0.46278900000000001, 1.0) -(0.23281499999999999, 0.73224699999999998, 0.45927699999999999, 1.0) -(0.239374, 0.73558800000000002, 0.45568799999999998, 1.0) -(0.24607000000000001, 0.73890999999999996, 0.45202399999999998, 1.0) -(0.25289899999999998, 0.74221099999999995, 0.44828400000000002, 1.0) -(0.259857, 0.74549200000000004, 0.444467, 1.0) -(0.26694099999999998, 0.74875100000000006, 0.44057299999999999, 1.0) -(0.27414899999999998, 0.75198799999999999, 0.43660100000000002, 1.0) -(0.28147699999999998, 0.75520299999999996, 0.43255199999999999, 1.0) -(0.28892099999999998, 0.75839400000000001, 0.42842599999999997, 1.0) -(0.29647899999999999, 0.76156100000000004, 0.42422300000000002, 1.0) -(0.30414799999999997, 0.76470400000000005, 0.41994300000000001, 1.0) -(0.31192500000000001, 0.767822, 0.41558600000000001, 1.0) -(0.31980900000000001, 0.77091399999999999, 0.41115200000000002, 1.0) -(0.32779599999999998, 0.77398, 0.40664, 1.0) -(0.33588499999999999, 0.77701799999999999, 0.40204899999999999, 1.0) -(0.34407399999999999, 0.78002899999999997, 0.39738099999999998, 1.0) -(0.35236000000000001, 0.78301100000000001, 0.39263599999999999, 1.0) -(0.36074099999999998, 0.785964, 0.38781399999999999, 1.0) -(0.36921399999999999, 0.78888800000000003, 0.38291399999999998, 1.0) -(0.37777899999999998, 0.79178099999999996, 0.37793900000000002, 1.0) -(0.38643300000000003, 0.79464400000000002, 0.372886, 1.0) -(0.39517400000000003, 0.79747500000000004, 0.367757, 1.0) -(0.404001, 0.80027499999999996, 0.36255199999999999, 1.0) -(0.41291299999999997, 0.803041, 0.357269, 1.0) -(0.42190800000000001, 0.80577399999999999, 0.35191, 1.0) -(0.430983, 0.808473, 0.34647600000000001, 1.0) -(0.440137, 0.81113800000000003, 0.34096700000000002, 1.0) -(0.44936799999999999, 0.81376800000000005, 0.33538400000000002, 1.0) -(0.45867400000000003, 0.81636299999999995, 0.32972699999999999, 1.0) -(0.468053, 0.81892100000000001, 0.32399800000000001, 1.0) -(0.47750399999999998, 0.82144399999999995, 0.31819500000000001, 1.0) -(0.48702600000000001, 0.82392900000000002, 0.31232100000000002, 1.0) -(0.49661499999999997, 0.826376, 0.30637700000000001, 1.0) -(0.50627100000000003, 0.82878600000000002, 0.30036200000000002, 1.0) -(0.51599200000000001, 0.83115799999999995, 0.29427900000000001, 1.0) -(0.52577600000000002, 0.83349099999999998, 0.28812700000000002, 1.0) -(0.53562100000000001, 0.835785, 0.28190799999999999, 1.0) -(0.54552400000000001, 0.83803899999999998, 0.27562599999999998, 1.0) -(0.55548399999999998, 0.84025399999999995, 0.26928099999999999, 1.0) -(0.56549799999999995, 0.84243000000000001, 0.26287700000000003, 1.0) -(0.57556300000000005, 0.84456600000000004, 0.256415, 1.0) -(0.58567800000000003, 0.846661, 0.24989700000000001, 1.0) -(0.59583900000000001, 0.84871700000000005, 0.24332899999999999, 1.0) -(0.60604499999999994, 0.85073299999999996, 0.23671200000000001, 1.0) -(0.61629299999999998, 0.85270900000000005, 0.23005200000000001, 1.0) -(0.626579, 0.85464499999999999, 0.223353, 1.0) -(0.63690199999999997, 0.85654200000000003, 0.21662000000000001, 1.0) -(0.64725699999999997, 0.85840000000000005, 0.20986099999999999, 1.0) -(0.65764199999999995, 0.86021899999999996, 0.20308200000000001, 1.0) -(0.66805400000000004, 0.86199899999999996, 0.196293, 1.0) -(0.67848900000000001, 0.86374200000000001, 0.189503, 1.0) -(0.688944, 0.865448, 0.182725, 1.0) -(0.69941500000000001, 0.86711700000000003, 0.17597099999999999, 1.0) -(0.70989800000000003, 0.86875100000000005, 0.16925699999999999, 1.0) -(0.720391, 0.87034999999999996, 0.162603, 1.0) -(0.73088900000000001, 0.87191600000000002, 0.156029, 1.0) -(0.74138800000000005, 0.87344900000000003, 0.149561, 1.0) -(0.751884, 0.87495100000000003, 0.14322799999999999, 1.0) -(0.76237299999999997, 0.87642399999999998, 0.13706399999999999, 1.0) -(0.77285199999999998, 0.87786799999999998, 0.131109, 1.0) -(0.78331499999999998, 0.87928499999999998, 0.12540499999999999, 1.0) -(0.79376000000000002, 0.88067799999999996, 0.120005, 1.0) -(0.80418199999999995, 0.882046, 0.114965, 1.0) -(0.81457599999999997, 0.88339299999999998, 0.110347, 1.0) -(0.82494000000000001, 0.88471999999999995, 0.10621700000000001, 1.0) -(0.83526999999999996, 0.88602899999999996, 0.102646, 1.0) -(0.84556100000000001, 0.88732200000000006, 0.099701999999999999, 1.0) -(0.85580999999999996, 0.88860099999999997, 0.097451999999999997, 1.0) -(0.86601300000000003, 0.88986799999999999, 0.095952999999999997, 1.0) -(0.87616799999999995, 0.89112499999999994, 0.095250000000000001, 1.0) -(0.88627100000000003, 0.892374, 0.095374, 1.0) -(0.89632000000000001, 0.89361599999999997, 0.096335000000000004, 1.0) -(0.90631099999999998, 0.89485499999999996, 0.098125000000000004, 1.0) -(0.916242, 0.89609099999999997, 0.100717, 1.0) -(0.92610599999999998, 0.89732999999999996, 0.104071, 1.0) -(0.93590399999999996, 0.89856999999999998, 0.108131, 1.0) -(0.94563600000000003, 0.89981500000000003, 0.11283799999999999, 1.0) -(0.95530000000000004, 0.901065, 0.118128, 1.0) -(0.96489400000000003, 0.90232299999999999, 0.123941, 1.0) -(0.97441699999999998, 0.90359, 0.130215, 1.0) -(0.98386799999999996, 0.90486699999999998, 0.13689699999999999, 1.0) -(0.99324800000000002, 0.90615699999999999, 0.14393600000000001, 1.0) diff --git a/extern/tfn/colormaps/sequential/Blues.cpp b/extern/tfn/colormaps/sequential/Blues.cpp deleted file mode 100644 index edbac29..0000000 --- a/extern/tfn/colormaps/sequential/Blues.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential_Blues; -} -const std::vector colormap::data_sequential_Blues = /* NOLINT(cert-err58-cpp) */ -{ -{0.96862745098039216f, 0.98431372549019602f, 1.0f, 1.0f}, -{0.96555171088043057f, 0.98234525182622068f, 0.99901576316801233f, 1.0f}, -{0.96247597078046909f, 0.98037677816224522f, 0.99803152633602465f, 1.0f}, -{0.9594002306805075f, 0.97840830449826988f, 0.99704728950403687f, 1.0f}, -{0.95632449058054592f, 0.97643983083429442f, 0.9960630526720492f, 1.0f}, -{0.95324875048058444f, 0.97447135717031907f, 0.99507881584006153f, 1.0f}, -{0.95017301038062285f, 0.97250288350634362f, 0.99409457900807385f, 1.0f}, -{0.94709727028066126f, 0.97053440984236827f, 0.99311034217608607f, 1.0f}, -{0.94402153018069979f, 0.96856593617839293f, 0.9921261053440984f, 1.0f}, -{0.9409457900807382f, 0.96659746251441747f, 0.99114186851211072f, 1.0f}, -{0.93787004998077661f, 0.96462898885044213f, 0.99015763168012305f, 1.0f}, -{0.93479430988081513f, 0.96266051518646667f, 0.98917339484813538f, 1.0f}, -{0.93171856978085354f, 0.96069204152249132f, 0.9881891580161476f, 1.0f}, -{0.92864282968089196f, 0.95872356785851587f, 0.98720492118415992f, 1.0f}, -{0.92556708958093037f, 0.95675509419454052f, 0.98622068435217225f, 1.0f}, -{0.92249134948096889f, 0.95478662053056507f, 0.98523644752018458f, 1.0f}, -{0.9194156093810073f, 0.95281814686658972f, 0.98425221068819679f, 1.0f}, -{0.91633986928104572f, 0.95084967320261438f, 0.98326797385620912f, 1.0f}, -{0.91326412918108424f, 0.94888119953863892f, 0.98228373702422145f, 1.0f}, -{0.91018838908112265f, 0.94691272587466357f, 0.98129950019223378f, 1.0f}, -{0.90711264898116106f, 0.94494425221068812f, 0.9803152633602461f, 1.0f}, -{0.90403690888119959f, 0.94297577854671277f, 0.97933102652825832f, 1.0f}, -{0.900961168781238f, 0.94100730488273732f, 0.97834678969627065f, 1.0f}, -{0.89788542868127641f, 0.93903883121876197f, 0.97736255286428297f, 1.0f}, -{0.89480968858131493f, 0.93707035755478651f, 0.9763783160322953f, 1.0f}, -{0.89173394848135334f, 0.93510188389081117f, 0.97539407920030752f, 1.0f}, -{0.88865820838139176f, 0.93313341022683582f, 0.97440984236831985f, 1.0f}, -{0.88558246828143028f, 0.93116493656286037f, 0.97342560553633217f, 1.0f}, -{0.88250672818146869f, 0.92919646289888502f, 0.9724413687043445f, 1.0f}, -{0.8794309880815071f, 0.92722798923490957f, 0.97145713187235683f, 1.0f}, -{0.87635524798154552f, 0.92525951557093422f, 0.97047289504036904f, 1.0f}, -{0.87327950788158404f, 0.92329104190695876f, 0.96948865820838137f, 1.0f}, -{0.87021914648212229f, 0.92132256824298342f, 0.9685044213763937f, 1.0f}, -{0.86726643598615916f, 0.91935409457900807f, 0.96752018454440603f, 1.0f}, -{0.86431372549019614f, 0.91738562091503262f, 0.96653594771241835f, 1.0f}, -{0.86136101499423301f, 0.91541714725105727f, 0.96555171088043057f, 1.0f}, -{0.85840830449826988f, 0.91344867358708182f, 0.9645674740484429f, 1.0f}, -{0.85545559400230686f, 0.91148019992310647f, 0.96358323721645522f, 1.0f}, -{0.85250288350634373f, 0.90951172625913101f, 0.96259900038446755f, 1.0f}, -{0.8495501730103806f, 0.90754325259515567f, 0.96161476355247977f, 1.0f}, -{0.84659746251441759f, 0.90557477893118021f, 0.9606305267204921f, 1.0f}, -{0.84364475201845446f, 0.90360630526720487f, 0.95964628988850442f, 1.0f}, -{0.84069204152249133f, 0.90163783160322952f, 0.95866205305651675f, 1.0f}, -{0.83773933102652831f, 0.89966935793925407f, 0.95767781622452908f, 1.0f}, -{0.83478662053056518f, 0.89770088427527872f, 0.95669357939254129f, 1.0f}, -{0.83183391003460216f, 0.89573241061130326f, 0.95570934256055362f, 1.0f}, -{0.82888119953863904f, 0.89376393694732792f, 0.95472510572856595f, 1.0f}, -{0.82592848904267591f, 0.89179546328335246f, 0.95374086889657828f, 1.0f}, -{0.82297577854671278f, 0.88982698961937712f, 0.95275663206459049f, 1.0f}, -{0.82002306805074976f, 0.88785851595540177f, 0.95177239523260282f, 1.0f}, -{0.81707035755478663f, 0.88589004229142632f, 0.95078815840061515f, 1.0f}, -{0.8141176470588235f, 0.88392156862745097f, 0.94980392156862747f, 1.0f}, -{0.81116493656286048f, 0.88195309496347551f, 0.9488196847366398f, 1.0f}, -{0.80821222606689735f, 0.87998462129950017f, 0.94783544790465202f, 1.0f}, -{0.80525951557093434f, 0.87801614763552471f, 0.94685121107266434f, 1.0f}, -{0.80230680507497121f, 0.87604767397154937f, 0.94586697424067667f, 1.0f}, -{0.79935409457900808f, 0.87407920030757391f, 0.944882737408689f, 1.0f}, -{0.79640138408304506f, 0.87211072664359857f, 0.94389850057670133f, 1.0f}, -{0.79344867358708193f, 0.87014225297962322f, 0.94291426374471354f, 1.0f}, -{0.7904959630911188f, 0.86817377931564776f, 0.94193002691272587f, 1.0f}, -{0.78754325259515578f, 0.86620530565167242f, 0.9409457900807382f, 1.0f}, -{0.78459054209919266f, 0.86423683198769696f, 0.93996155324875053f, 1.0f}, -{0.78163783160322953f, 0.86226835832372162f, 0.93897731641676274f, 1.0f}, -{0.77868512110726651f, 0.86029988465974616f, 0.93799307958477507f, 1.0f}, -{0.77524029219530954f, 0.85830065359477115f, 0.93682429834678971f, 1.0f}, -{0.77031910803537107f, 0.85620915032679734f, 0.93510188389081128f, 1.0f}, -{0.7653979238754326f, 0.85411764705882354f, 0.93337946943483274f, 1.0f}, -{0.76047673971549401f, 0.85202614379084962f, 0.93165705497885432f, 1.0f}, -{0.75555555555555554f, 0.84993464052287582f, 0.92993464052287578f, 1.0f}, -{0.75063437139561706f, 0.8478431372549019f, 0.92821222606689735f, 1.0f}, -{0.74571318723567859f, 0.8457516339869281f, 0.92648981161091892f, 1.0f}, -{0.74079200307574011f, 0.84366013071895418f, 0.92476739715494038f, 1.0f}, -{0.73587081891580164f, 0.84156862745098038f, 0.92304498269896196f, 1.0f}, -{0.73094963475586316f, 0.83947712418300646f, 0.92132256824298342f, 1.0f}, -{0.72602845059592469f, 0.83738562091503266f, 0.91960015378700499f, 1.0f}, -{0.72110726643598622f, 0.83529411764705874f, 0.91787773933102657f, 1.0f}, -{0.71618608227604774f, 0.83320261437908494f, 0.91615532487504803f, 1.0f}, -{0.71126489811610916f, 0.83111111111111102f, 0.9144329104190696f, 1.0f}, -{0.70634371395617068f, 0.82901960784313722f, 0.91271049596309106f, 1.0f}, -{0.70142252979623221f, 0.8269281045751633f, 0.91098808150711263f, 1.0f}, -{0.69650134563629373f, 0.8248366013071895f, 0.90926566705113421f, 1.0f}, -{0.69158016147635526f, 0.82274509803921569f, 0.90754325259515567f, 1.0f}, -{0.6866589773164169f, 0.82065359477124178f, 0.90582083813917724f, 1.0f}, -{0.68173779315647831f, 0.81856209150326797f, 0.90409842368319882f, 1.0f}, -{0.67681660899653984f, 0.81647058823529406f, 0.90237600922722028f, 1.0f}, -{0.67189542483660136f, 0.81437908496732025f, 0.90065359477124185f, 1.0f}, -{0.66697424067666289f, 0.81228758169934634f, 0.89893118031526331f, 1.0f}, -{0.66205305651672441f, 0.81019607843137254f, 0.89720876585928488f, 1.0f}, -{0.65713187235678583f, 0.80810457516339862f, 0.89548635140330646f, 1.0f}, -{0.65221068819684735f, 0.80601307189542482f, 0.89376393694732792f, 1.0f}, -{0.64728950403690899f, 0.80392156862745101f, 0.89204152249134949f, 1.0f}, -{0.64236831987697041f, 0.8018300653594771f, 0.89031910803537095f, 1.0f}, -{0.63744713571703193f, 0.79973856209150318f, 0.88859669357939253f, 1.0f}, -{0.63252595155709346f, 0.79764705882352938f, 0.8868742791234141f, 1.0f}, -{0.62760476739715498f, 0.79555555555555557f, 0.88515186466743556f, 1.0f}, -{0.62268358323721651f, 0.79346405228758166f, 0.88342945021145713f, 1.0f}, -{0.61725490196078436f, 0.79086505190311418f, 0.88184544405997689f, 1.0f}, -{0.61098039215686273f, 0.78742022299115721f, 0.88049211841599384f, 1.0f}, -{0.60470588235294132f, 0.78397539407920036f, 0.87913879277201079f, 1.0f}, -{0.59843137254901957f, 0.78053056516724328f, 0.87778546712802763f, 1.0f}, -{0.59215686274509804f, 0.77708573625528643f, 0.87643214148404458f, 1.0f}, -{0.58588235294117652f, 0.77364090734332946f, 0.87507881584006153f, 1.0f}, -{0.57960784313725489f, 0.7701960784313725f, 0.87372549019607837f, 1.0f}, -{0.57333333333333336f, 0.76675124951941553f, 0.87237216455209532f, 1.0f}, -{0.56705882352941184f, 0.76330642060745868f, 0.87101883890811227f, 1.0f}, -{0.5607843137254902f, 0.75986159169550171f, 0.86966551326412922f, 1.0f}, -{0.55450980392156879f, 0.75641676278354486f, 0.86831218762014606f, 1.0f}, -{0.54823529411764704f, 0.75297193387158778f, 0.86695886197616301f, 1.0f}, -{0.54196078431372552f, 0.74952710495963093f, 0.86560553633217996f, 1.0f}, -{0.53568627450980388f, 0.74608227604767396f, 0.8642522106881968f, 1.0f}, -{0.52941176470588236f, 0.742637447135717f, 0.86289888504421375f, 1.0f}, -{0.52313725490196084f, 0.73919261822376003f, 0.8615455594002307f, 1.0f}, -{0.5168627450980392f, 0.73574778931180318f, 0.86019223375624765f, 1.0f}, -{0.51058823529411768f, 0.73230296039984621f, 0.85883890811226449f, 1.0f}, -{0.50431372549019615f, 0.72885813148788936f, 0.85748558246828144f, 1.0f}, -{0.49803921568627452f, 0.72541330257593239f, 0.85613225682429839f, 1.0f}, -{0.49176470588235299f, 0.72196847366397543f, 0.85477893118031523f, 1.0f}, -{0.48549019607843136f, 0.71852364475201846f, 0.85342560553633218f, 1.0f}, -{0.47921568627450983f, 0.7150788158400615f, 0.85207227989234913f, 1.0f}, -{0.47294117647058825f, 0.71163398692810453f, 0.85071895424836597f, 1.0f}, -{0.46666666666666667f, 0.70818915801614768f, 0.84936562860438292f, 1.0f}, -{0.46039215686274515f, 0.70474432910419071f, 0.84801230296039987f, 1.0f}, -{0.45411764705882363f, 0.70129950019223386f, 0.84665897731641682f, 1.0f}, -{0.44784313725490199f, 0.69785467128027689f, 0.84530565167243366f, 1.0f}, -{0.44156862745098041f, 0.69440984236831993f, 0.84395232602845061f, 1.0f}, -{0.43529411764705883f, 0.69096501345636296f, 0.84259900038446756f, 1.0f}, -{0.42901960784313731f, 0.687520184544406f, 0.84124567474048439f, 1.0f}, -{0.42274509803921567f, 0.68407535563244903f, 0.83989234909650134f, 1.0f}, -{0.41708573625528644f, 0.68063052672049218f, 0.83823144944252215f, 1.0f}, -{0.41204152249134951f, 0.67718569780853521f, 0.83626297577854669f, 1.0f}, -{0.40699730872741252f, 0.67374086889657825f, 0.83429450211457135f, 1.0f}, -{0.40195309496347559f, 0.67029603998462128f, 0.83232602845059589f, 1.0f}, -{0.39690888119953882f, 0.66685121107266443f, 0.83035755478662066f, 1.0f}, -{0.39186466743560172f, 0.66340638216070746f, 0.8283890811226452f, 1.0f}, -{0.38682045367166473f, 0.6599615532487505f, 0.82642060745866974f, 1.0f}, -{0.3817762399077278f, 0.65651672433679353f, 0.8244521337946944f, 1.0f}, -{0.37673202614379087f, 0.65307189542483657f, 0.82248366013071894f, 1.0f}, -{0.37168781237985393f, 0.64962706651287971f, 0.8205151864667436f, 1.0f}, -{0.366643598615917f, 0.64618223760092275f, 0.81854671280276814f, 1.0f}, -{0.36159938485198001f, 0.64273740868896578f, 0.81657823913879279f, 1.0f}, -{0.35655517108804308f, 0.63929257977700882f, 0.81460976547481745f, 1.0f}, -{0.35151095732410614f, 0.63584775086505185f, 0.81264129181084199f, 1.0f}, -{0.34646674356016915f, 0.632402921953095f, 0.81067281814686665f, 1.0f}, -{0.34142252979623222f, 0.62895809304113803f, 0.80870434448289119f, 1.0f}, -{0.33637831603229529f, 0.62551326412918107f, 0.80673587081891585f, 1.0f}, -{0.33133410226835835f, 0.6220684352172241f, 0.80476739715494039f, 1.0f}, -{0.32628988850442137f, 0.61862360630526725f, 0.80279892349096504f, 1.0f}, -{0.32124567474048443f, 0.61517877739331028f, 0.80083044982698959f, 1.0f}, -{0.31620146097654767f, 0.61173394848135343f, 0.79886197616301424f, 1.0f}, -{0.31115724721261057f, 0.60828911956939635f, 0.7968935024990389f, 1.0f}, -{0.30611303344867358f, 0.60484429065743939f, 0.79492502883506344f, 1.0f}, -{0.30106881968473664f, 0.60139946174548253f, 0.7929565551710881f, 1.0f}, -{0.29602460592079971f, 0.59795463283352557f, 0.79098808150711264f, 1.0f}, -{0.29098039215686278f, 0.5945098039215686f, 0.78901960784313729f, 1.0f}, -{0.28593617839292584f, 0.59106497500961164f, 0.78705113417916184f, 1.0f}, -{0.28089196462898885f, 0.58762014609765467f, 0.78508266051518649f, 1.0f}, -{0.27584775086505192f, 0.58417531718569782f, 0.78311418685121104f, 1.0f}, -{0.27080353710111493f, 0.58073048827374085f, 0.78114571318723569f, 1.0f}, -{0.265759323337178f, 0.57728565936178389f, 0.77917723952326035f, 1.0f}, -{0.26071510957324107f, 0.57384083044982692f, 0.77720876585928489f, 1.0f}, -{0.25628604382929643f, 0.57001153402537486f, 0.77516339869281048f, 1.0f}, -{0.25222606689734722f, 0.56595155709342559f, 0.77307189542483656f, 1.0f}, -{0.24816608996539793f, 0.56189158016147633f, 0.77098039215686276f, 1.0f}, -{0.2441061130334487f, 0.55783160322952707f, 0.76888888888888896f, 1.0f}, -{0.24004613610149955f, 0.55377162629757792f, 0.76679738562091515f, 1.0f}, -{0.23598615916955018f, 0.54971164936562855f, 0.76470588235294124f, 1.0f}, -{0.23192618223760095f, 0.54565167243367929f, 0.76261437908496732f, 1.0f}, -{0.22786620530565169f, 0.54159169550173003f, 0.76052287581699352f, 1.0f}, -{0.22380622837370245f, 0.53753171856978077f, 0.7584313725490196f, 1.0f}, -{0.21974625144175319f, 0.53347174163783162f, 0.7563398692810458f, 1.0f}, -{0.21568627450980393f, 0.52941176470588236f, 0.75424836601307188f, 1.0f}, -{0.2116262975778547f, 0.5253517877739331f, 0.75215686274509808f, 1.0f}, -{0.20756632064590544f, 0.52129181084198384f, 0.75006535947712416f, 1.0f}, -{0.20350634371395621f, 0.51723183391003458f, 0.74797385620915036f, 1.0f}, -{0.19944636678200695f, 0.51317185697808532f, 0.74588235294117644f, 1.0f}, -{0.19538638985005768f, 0.50911188004613606f, 0.74379084967320264f, 1.0f}, -{0.19132641291810842f, 0.5050519031141868f, 0.74169934640522883f, 1.0f}, -{0.18726643598615916f, 0.50099192618223753f, 0.73960784313725492f, 1.0f}, -{0.18320645905420993f, 0.49693194925028833f, 0.73751633986928111f, 1.0f}, -{0.1791464821222607f, 0.49287197231833907f, 0.7354248366013072f, 1.0f}, -{0.17508650519031155f, 0.48881199538638992f, 0.73333333333333339f, 1.0f}, -{0.17102652825836218f, 0.4847520184544406f, 0.73124183006535948f, 1.0f}, -{0.16696655132641292f, 0.48069204152249134f, 0.72915032679738567f, 1.0f}, -{0.16290657439446368f, 0.47663206459054208f, 0.72705882352941176f, 1.0f}, -{0.15884659746251442f, 0.47257208765859282f, 0.72496732026143795f, 1.0f}, -{0.15478662053056519f, 0.46851211072664356f, 0.72287581699346404f, 1.0f}, -{0.15072664359861593f, 0.4644521337946943f, 0.72078431372549023f, 1.0f}, -{0.14666666666666667f, 0.46039215686274504f, 0.71869281045751632f, 1.0f}, -{0.14260668973471741f, 0.45633217993079583f, 0.71660130718954251f, 1.0f}, -{0.13854671280276817f, 0.45227220299884657f, 0.71450980392156871f, 1.0f}, -{0.13448673587081894f, 0.44821222606689731f, 0.71241830065359479f, 1.0f}, -{0.13042675893886968f, 0.44415224913494811f, 0.71032679738562099f, 1.0f}, -{0.1271049596309112f, 0.44018454440599769f, 0.70749711649365632f, 1.0f}, -{0.12402921953094964f, 0.43624759707804689f, 0.70442137639369473f, 1.0f}, -{0.1209534794309881f, 0.43231064975009609f, 0.70134563629373325f, 1.0f}, -{0.11787773933102653f, 0.42837370242214529f, 0.69826989619377167f, 1.0f}, -{0.11480199923106507f, 0.42443675509419465f, 0.69519415609381019f, 1.0f}, -{0.11172625913110343f, 0.42049980776624374f, 0.6921184159938486f, 1.0f}, -{0.10865051903114188f, 0.41656286043829294f, 0.68904267589388701f, 1.0f}, -{0.10557477893118032f, 0.41262591311034214f, 0.68596693579392543f, 1.0f}, -{0.10249903883121878f, 0.40868896578239139f, 0.68289119569396384f, 1.0f}, -{0.099423298731257215f, 0.40475201845444059f, 0.67981545559400236f, 1.0f}, -{0.096347558631295654f, 0.40081507112648979f, 0.67673971549404077f, 1.0f}, -{0.093271818531334108f, 0.39687812379853898f, 0.67366397539407918f, 1.0f}, -{0.090196078431372562f, 0.39294117647058824f, 0.67058823529411771f, 1.0f}, -{0.087120338331411001f, 0.38900422914263744f, 0.66751249519415612f, 1.0f}, -{0.084044598231449441f, 0.38506728181468663f, 0.66443675509419453f, 1.0f}, -{0.080968858131487895f, 0.38113033448673583f, 0.66136101499423305f, 1.0f}, -{0.077893118031526348f, 0.37719338715878503f, 0.65828527489427147f, 1.0f}, -{0.074817377931564788f, 0.37325643983083429f, 0.65520953479430988f, 1.0f}, -{0.071741637831603228f, 0.36931949250288348f, 0.6521337946943484f, 1.0f}, -{0.068665897731641681f, 0.36538254517493268f, 0.64905805459438681f, 1.0f}, -{0.065590157631680218f, 0.36144559784698205f, 0.64598231449442534f, 1.0f}, -{0.062514417531718575f, 0.35750865051903113f, 0.64290657439446375f, 1.0f}, -{0.059438677431757014f, 0.35357170319108033f, 0.63983083429450216f, 1.0f}, -{0.056362937331795468f, 0.34963475586312953f, 0.63675509419454057f, 1.0f}, -{0.053287197231833908f, 0.34569780853517873f, 0.63367935409457909f, 1.0f}, -{0.050211457131872361f, 0.34176086120722798f, 0.63060361399461751f, 1.0f}, -{0.047135717031910801f, 0.33782391387927718f, 0.62752787389465592f, 1.0f}, -{0.044059976931949255f, 0.33388696655132638f, 0.62445213379469444f, 1.0f}, -{0.040984236831987694f, 0.32995001922337563f, 0.62137639369473285f, 1.0f}, -{0.037908496732026148f, 0.32601307189542483f, 0.61830065359477127f, 1.0f}, -{0.034832756632064588f, 0.32207612456747403f, 0.61522491349480979f, 1.0f}, -{0.031757016532103041f, 0.31813917723952323f, 0.6121491733948482f, 1.0f}, -{0.031372549019607843f, 0.3140945790080738f, 0.60648981161091897f, 1.0f}, -{0.031372549019607843f, 0.31003460207612454f, 0.60046136101499425f, 1.0f}, -{0.031372549019607843f, 0.30597462514417528f, 0.59443291041906965f, 1.0f}, -{0.031372549019607843f, 0.30191464821222602f, 0.58840445982314504f, 1.0f}, -{0.031372549019607843f, 0.29785467128027693f, 0.58237600922722055f, 1.0f}, -{0.031372549019607843f, 0.29379469434832756f, 0.57634755863129572f, 1.0f}, -{0.031372549019607843f, 0.2897347174163783f, 0.570319108035371f, 1.0f}, -{0.031372549019607843f, 0.28567474048442904f, 0.5642906574394464f, 1.0f}, -{0.031372549019607843f, 0.28161476355247983f, 0.55826220684352179f, 1.0f}, -{0.031372549019607843f, 0.27755478662053057f, 0.55223375624759707f, 1.0f}, -{0.031372549019607843f, 0.27349480968858131f, 0.54620530565167247f, 1.0f}, -{0.031372549019607843f, 0.26943483275663205f, 0.54017685505574786f, 1.0f}, -{0.031372549019607843f, 0.26537485582468279f, 0.53414840445982315f, 1.0f}, -{0.031372549019607843f, 0.26131487889273353f, 0.52811995386389854f, 1.0f}, -{0.031372549019607843f, 0.25725490196078432f, 0.52209150326797382f, 1.0f}, -{0.031372549019607843f, 0.25319492502883506f, 0.51606305267204922f, 1.0f}, -{0.031372549019607843f, 0.2491349480968858f, 0.51003460207612461f, 1.0f}, -{0.031372549019607843f, 0.24507497116493654f, 0.50400615148019989f, 1.0f}, -{0.031372549019607843f, 0.24101499423298731f, 0.49797770088427529f, 1.0f}, -{0.031372549019607843f, 0.23695501730103807f, 0.49194925028835068f, 1.0f}, -{0.031372549019607843f, 0.23289504036908892f, 0.48592079969242619f, 1.0f}, -{0.031372549019607843f, 0.22883506343713955f, 0.47989234909650136f, 1.0f}, -{0.031372549019607843f, 0.22477508650519029f, 0.47386389850057675f, 1.0f}, -{0.031372549019607843f, 0.22071510957324106f, 0.46783544790465204f, 1.0f}, -{0.031372549019607843f, 0.2166551326412918f, 0.46180699730872743f, 1.0f}, -{0.031372549019607843f, 0.21259515570934256f, 0.45577854671280282f, 1.0f}, -{0.031372549019607843f, 0.2085351787773933f, 0.44975009611687811f, 1.0f}, -{0.031372549019607843f, 0.20447520184544404f, 0.4437216455209535f, 1.0f}, -{0.031372549019607843f, 0.20041522491349481f, 0.43769319492502884f, 1.0f}, -{0.031372549019607843f, 0.19635524798154555f, 0.43166474432910418f, 1.0f}, -{0.031372549019607843f, 0.19229527104959632f, 0.42563629373317957f, 1.0f}, -{0.031372549019607843f, 0.18823529411764706f, 0.41960784313725491f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential/Blues.txt b/extern/tfn/colormaps/sequential/Blues.txt deleted file mode 100644 index efa47cc..0000000 --- a/extern/tfn/colormaps/sequential/Blues.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.96862745098039216, 0.98431372549019602, 1.0, 1.0) -(0.96555171088043057, 0.98234525182622068, 0.99901576316801233, 1.0) -(0.96247597078046909, 0.98037677816224522, 0.99803152633602465, 1.0) -(0.9594002306805075, 0.97840830449826988, 0.99704728950403687, 1.0) -(0.95632449058054592, 0.97643983083429442, 0.9960630526720492, 1.0) -(0.95324875048058444, 0.97447135717031907, 0.99507881584006153, 1.0) -(0.95017301038062285, 0.97250288350634362, 0.99409457900807385, 1.0) -(0.94709727028066126, 0.97053440984236827, 0.99311034217608607, 1.0) -(0.94402153018069979, 0.96856593617839293, 0.9921261053440984, 1.0) -(0.9409457900807382, 0.96659746251441747, 0.99114186851211072, 1.0) -(0.93787004998077661, 0.96462898885044213, 0.99015763168012305, 1.0) -(0.93479430988081513, 0.96266051518646667, 0.98917339484813538, 1.0) -(0.93171856978085354, 0.96069204152249132, 0.9881891580161476, 1.0) -(0.92864282968089196, 0.95872356785851587, 0.98720492118415992, 1.0) -(0.92556708958093037, 0.95675509419454052, 0.98622068435217225, 1.0) -(0.92249134948096889, 0.95478662053056507, 0.98523644752018458, 1.0) -(0.9194156093810073, 0.95281814686658972, 0.98425221068819679, 1.0) -(0.91633986928104572, 0.95084967320261438, 0.98326797385620912, 1.0) -(0.91326412918108424, 0.94888119953863892, 0.98228373702422145, 1.0) -(0.91018838908112265, 0.94691272587466357, 0.98129950019223378, 1.0) -(0.90711264898116106, 0.94494425221068812, 0.9803152633602461, 1.0) -(0.90403690888119959, 0.94297577854671277, 0.97933102652825832, 1.0) -(0.900961168781238, 0.94100730488273732, 0.97834678969627065, 1.0) -(0.89788542868127641, 0.93903883121876197, 0.97736255286428297, 1.0) -(0.89480968858131493, 0.93707035755478651, 0.9763783160322953, 1.0) -(0.89173394848135334, 0.93510188389081117, 0.97539407920030752, 1.0) -(0.88865820838139176, 0.93313341022683582, 0.97440984236831985, 1.0) -(0.88558246828143028, 0.93116493656286037, 0.97342560553633217, 1.0) -(0.88250672818146869, 0.92919646289888502, 0.9724413687043445, 1.0) -(0.8794309880815071, 0.92722798923490957, 0.97145713187235683, 1.0) -(0.87635524798154552, 0.92525951557093422, 0.97047289504036904, 1.0) -(0.87327950788158404, 0.92329104190695876, 0.96948865820838137, 1.0) -(0.87021914648212229, 0.92132256824298342, 0.9685044213763937, 1.0) -(0.86726643598615916, 0.91935409457900807, 0.96752018454440603, 1.0) -(0.86431372549019614, 0.91738562091503262, 0.96653594771241835, 1.0) -(0.86136101499423301, 0.91541714725105727, 0.96555171088043057, 1.0) -(0.85840830449826988, 0.91344867358708182, 0.9645674740484429, 1.0) -(0.85545559400230686, 0.91148019992310647, 0.96358323721645522, 1.0) -(0.85250288350634373, 0.90951172625913101, 0.96259900038446755, 1.0) -(0.8495501730103806, 0.90754325259515567, 0.96161476355247977, 1.0) -(0.84659746251441759, 0.90557477893118021, 0.9606305267204921, 1.0) -(0.84364475201845446, 0.90360630526720487, 0.95964628988850442, 1.0) -(0.84069204152249133, 0.90163783160322952, 0.95866205305651675, 1.0) -(0.83773933102652831, 0.89966935793925407, 0.95767781622452908, 1.0) -(0.83478662053056518, 0.89770088427527872, 0.95669357939254129, 1.0) -(0.83183391003460216, 0.89573241061130326, 0.95570934256055362, 1.0) -(0.82888119953863904, 0.89376393694732792, 0.95472510572856595, 1.0) -(0.82592848904267591, 0.89179546328335246, 0.95374086889657828, 1.0) -(0.82297577854671278, 0.88982698961937712, 0.95275663206459049, 1.0) -(0.82002306805074976, 0.88785851595540177, 0.95177239523260282, 1.0) -(0.81707035755478663, 0.88589004229142632, 0.95078815840061515, 1.0) -(0.8141176470588235, 0.88392156862745097, 0.94980392156862747, 1.0) -(0.81116493656286048, 0.88195309496347551, 0.9488196847366398, 1.0) -(0.80821222606689735, 0.87998462129950017, 0.94783544790465202, 1.0) -(0.80525951557093434, 0.87801614763552471, 0.94685121107266434, 1.0) -(0.80230680507497121, 0.87604767397154937, 0.94586697424067667, 1.0) -(0.79935409457900808, 0.87407920030757391, 0.944882737408689, 1.0) -(0.79640138408304506, 0.87211072664359857, 0.94389850057670133, 1.0) -(0.79344867358708193, 0.87014225297962322, 0.94291426374471354, 1.0) -(0.7904959630911188, 0.86817377931564776, 0.94193002691272587, 1.0) -(0.78754325259515578, 0.86620530565167242, 0.9409457900807382, 1.0) -(0.78459054209919266, 0.86423683198769696, 0.93996155324875053, 1.0) -(0.78163783160322953, 0.86226835832372162, 0.93897731641676274, 1.0) -(0.77868512110726651, 0.86029988465974616, 0.93799307958477507, 1.0) -(0.77524029219530954, 0.85830065359477115, 0.93682429834678971, 1.0) -(0.77031910803537107, 0.85620915032679734, 0.93510188389081128, 1.0) -(0.7653979238754326, 0.85411764705882354, 0.93337946943483274, 1.0) -(0.76047673971549401, 0.85202614379084962, 0.93165705497885432, 1.0) -(0.75555555555555554, 0.84993464052287582, 0.92993464052287578, 1.0) -(0.75063437139561706, 0.8478431372549019, 0.92821222606689735, 1.0) -(0.74571318723567859, 0.8457516339869281, 0.92648981161091892, 1.0) -(0.74079200307574011, 0.84366013071895418, 0.92476739715494038, 1.0) -(0.73587081891580164, 0.84156862745098038, 0.92304498269896196, 1.0) -(0.73094963475586316, 0.83947712418300646, 0.92132256824298342, 1.0) -(0.72602845059592469, 0.83738562091503266, 0.91960015378700499, 1.0) -(0.72110726643598622, 0.83529411764705874, 0.91787773933102657, 1.0) -(0.71618608227604774, 0.83320261437908494, 0.91615532487504803, 1.0) -(0.71126489811610916, 0.83111111111111102, 0.9144329104190696, 1.0) -(0.70634371395617068, 0.82901960784313722, 0.91271049596309106, 1.0) -(0.70142252979623221, 0.8269281045751633, 0.91098808150711263, 1.0) -(0.69650134563629373, 0.8248366013071895, 0.90926566705113421, 1.0) -(0.69158016147635526, 0.82274509803921569, 0.90754325259515567, 1.0) -(0.6866589773164169, 0.82065359477124178, 0.90582083813917724, 1.0) -(0.68173779315647831, 0.81856209150326797, 0.90409842368319882, 1.0) -(0.67681660899653984, 0.81647058823529406, 0.90237600922722028, 1.0) -(0.67189542483660136, 0.81437908496732025, 0.90065359477124185, 1.0) -(0.66697424067666289, 0.81228758169934634, 0.89893118031526331, 1.0) -(0.66205305651672441, 0.81019607843137254, 0.89720876585928488, 1.0) -(0.65713187235678583, 0.80810457516339862, 0.89548635140330646, 1.0) -(0.65221068819684735, 0.80601307189542482, 0.89376393694732792, 1.0) -(0.64728950403690899, 0.80392156862745101, 0.89204152249134949, 1.0) -(0.64236831987697041, 0.8018300653594771, 0.89031910803537095, 1.0) -(0.63744713571703193, 0.79973856209150318, 0.88859669357939253, 1.0) -(0.63252595155709346, 0.79764705882352938, 0.8868742791234141, 1.0) -(0.62760476739715498, 0.79555555555555557, 0.88515186466743556, 1.0) -(0.62268358323721651, 0.79346405228758166, 0.88342945021145713, 1.0) -(0.61725490196078436, 0.79086505190311418, 0.88184544405997689, 1.0) -(0.61098039215686273, 0.78742022299115721, 0.88049211841599384, 1.0) -(0.60470588235294132, 0.78397539407920036, 0.87913879277201079, 1.0) -(0.59843137254901957, 0.78053056516724328, 0.87778546712802763, 1.0) -(0.59215686274509804, 0.77708573625528643, 0.87643214148404458, 1.0) -(0.58588235294117652, 0.77364090734332946, 0.87507881584006153, 1.0) -(0.57960784313725489, 0.7701960784313725, 0.87372549019607837, 1.0) -(0.57333333333333336, 0.76675124951941553, 0.87237216455209532, 1.0) -(0.56705882352941184, 0.76330642060745868, 0.87101883890811227, 1.0) -(0.5607843137254902, 0.75986159169550171, 0.86966551326412922, 1.0) -(0.55450980392156879, 0.75641676278354486, 0.86831218762014606, 1.0) -(0.54823529411764704, 0.75297193387158778, 0.86695886197616301, 1.0) -(0.54196078431372552, 0.74952710495963093, 0.86560553633217996, 1.0) -(0.53568627450980388, 0.74608227604767396, 0.8642522106881968, 1.0) -(0.52941176470588236, 0.742637447135717, 0.86289888504421375, 1.0) -(0.52313725490196084, 0.73919261822376003, 0.8615455594002307, 1.0) -(0.5168627450980392, 0.73574778931180318, 0.86019223375624765, 1.0) -(0.51058823529411768, 0.73230296039984621, 0.85883890811226449, 1.0) -(0.50431372549019615, 0.72885813148788936, 0.85748558246828144, 1.0) -(0.49803921568627452, 0.72541330257593239, 0.85613225682429839, 1.0) -(0.49176470588235299, 0.72196847366397543, 0.85477893118031523, 1.0) -(0.48549019607843136, 0.71852364475201846, 0.85342560553633218, 1.0) -(0.47921568627450983, 0.7150788158400615, 0.85207227989234913, 1.0) -(0.47294117647058825, 0.71163398692810453, 0.85071895424836597, 1.0) -(0.46666666666666667, 0.70818915801614768, 0.84936562860438292, 1.0) -(0.46039215686274515, 0.70474432910419071, 0.84801230296039987, 1.0) -(0.45411764705882363, 0.70129950019223386, 0.84665897731641682, 1.0) -(0.44784313725490199, 0.69785467128027689, 0.84530565167243366, 1.0) -(0.44156862745098041, 0.69440984236831993, 0.84395232602845061, 1.0) -(0.43529411764705883, 0.69096501345636296, 0.84259900038446756, 1.0) -(0.42901960784313731, 0.687520184544406, 0.84124567474048439, 1.0) -(0.42274509803921567, 0.68407535563244903, 0.83989234909650134, 1.0) -(0.41708573625528644, 0.68063052672049218, 0.83823144944252215, 1.0) -(0.41204152249134951, 0.67718569780853521, 0.83626297577854669, 1.0) -(0.40699730872741252, 0.67374086889657825, 0.83429450211457135, 1.0) -(0.40195309496347559, 0.67029603998462128, 0.83232602845059589, 1.0) -(0.39690888119953882, 0.66685121107266443, 0.83035755478662066, 1.0) -(0.39186466743560172, 0.66340638216070746, 0.8283890811226452, 1.0) -(0.38682045367166473, 0.6599615532487505, 0.82642060745866974, 1.0) -(0.3817762399077278, 0.65651672433679353, 0.8244521337946944, 1.0) -(0.37673202614379087, 0.65307189542483657, 0.82248366013071894, 1.0) -(0.37168781237985393, 0.64962706651287971, 0.8205151864667436, 1.0) -(0.366643598615917, 0.64618223760092275, 0.81854671280276814, 1.0) -(0.36159938485198001, 0.64273740868896578, 0.81657823913879279, 1.0) -(0.35655517108804308, 0.63929257977700882, 0.81460976547481745, 1.0) -(0.35151095732410614, 0.63584775086505185, 0.81264129181084199, 1.0) -(0.34646674356016915, 0.632402921953095, 0.81067281814686665, 1.0) -(0.34142252979623222, 0.62895809304113803, 0.80870434448289119, 1.0) -(0.33637831603229529, 0.62551326412918107, 0.80673587081891585, 1.0) -(0.33133410226835835, 0.6220684352172241, 0.80476739715494039, 1.0) -(0.32628988850442137, 0.61862360630526725, 0.80279892349096504, 1.0) -(0.32124567474048443, 0.61517877739331028, 0.80083044982698959, 1.0) -(0.31620146097654767, 0.61173394848135343, 0.79886197616301424, 1.0) -(0.31115724721261057, 0.60828911956939635, 0.7968935024990389, 1.0) -(0.30611303344867358, 0.60484429065743939, 0.79492502883506344, 1.0) -(0.30106881968473664, 0.60139946174548253, 0.7929565551710881, 1.0) -(0.29602460592079971, 0.59795463283352557, 0.79098808150711264, 1.0) -(0.29098039215686278, 0.5945098039215686, 0.78901960784313729, 1.0) -(0.28593617839292584, 0.59106497500961164, 0.78705113417916184, 1.0) -(0.28089196462898885, 0.58762014609765467, 0.78508266051518649, 1.0) -(0.27584775086505192, 0.58417531718569782, 0.78311418685121104, 1.0) -(0.27080353710111493, 0.58073048827374085, 0.78114571318723569, 1.0) -(0.265759323337178, 0.57728565936178389, 0.77917723952326035, 1.0) -(0.26071510957324107, 0.57384083044982692, 0.77720876585928489, 1.0) -(0.25628604382929643, 0.57001153402537486, 0.77516339869281048, 1.0) -(0.25222606689734722, 0.56595155709342559, 0.77307189542483656, 1.0) -(0.24816608996539793, 0.56189158016147633, 0.77098039215686276, 1.0) -(0.2441061130334487, 0.55783160322952707, 0.76888888888888896, 1.0) -(0.24004613610149955, 0.55377162629757792, 0.76679738562091515, 1.0) -(0.23598615916955018, 0.54971164936562855, 0.76470588235294124, 1.0) -(0.23192618223760095, 0.54565167243367929, 0.76261437908496732, 1.0) -(0.22786620530565169, 0.54159169550173003, 0.76052287581699352, 1.0) -(0.22380622837370245, 0.53753171856978077, 0.7584313725490196, 1.0) -(0.21974625144175319, 0.53347174163783162, 0.7563398692810458, 1.0) -(0.21568627450980393, 0.52941176470588236, 0.75424836601307188, 1.0) -(0.2116262975778547, 0.5253517877739331, 0.75215686274509808, 1.0) -(0.20756632064590544, 0.52129181084198384, 0.75006535947712416, 1.0) -(0.20350634371395621, 0.51723183391003458, 0.74797385620915036, 1.0) -(0.19944636678200695, 0.51317185697808532, 0.74588235294117644, 1.0) -(0.19538638985005768, 0.50911188004613606, 0.74379084967320264, 1.0) -(0.19132641291810842, 0.5050519031141868, 0.74169934640522883, 1.0) -(0.18726643598615916, 0.50099192618223753, 0.73960784313725492, 1.0) -(0.18320645905420993, 0.49693194925028833, 0.73751633986928111, 1.0) -(0.1791464821222607, 0.49287197231833907, 0.7354248366013072, 1.0) -(0.17508650519031155, 0.48881199538638992, 0.73333333333333339, 1.0) -(0.17102652825836218, 0.4847520184544406, 0.73124183006535948, 1.0) -(0.16696655132641292, 0.48069204152249134, 0.72915032679738567, 1.0) -(0.16290657439446368, 0.47663206459054208, 0.72705882352941176, 1.0) -(0.15884659746251442, 0.47257208765859282, 0.72496732026143795, 1.0) -(0.15478662053056519, 0.46851211072664356, 0.72287581699346404, 1.0) -(0.15072664359861593, 0.4644521337946943, 0.72078431372549023, 1.0) -(0.14666666666666667, 0.46039215686274504, 0.71869281045751632, 1.0) -(0.14260668973471741, 0.45633217993079583, 0.71660130718954251, 1.0) -(0.13854671280276817, 0.45227220299884657, 0.71450980392156871, 1.0) -(0.13448673587081894, 0.44821222606689731, 0.71241830065359479, 1.0) -(0.13042675893886968, 0.44415224913494811, 0.71032679738562099, 1.0) -(0.1271049596309112, 0.44018454440599769, 0.70749711649365632, 1.0) -(0.12402921953094964, 0.43624759707804689, 0.70442137639369473, 1.0) -(0.1209534794309881, 0.43231064975009609, 0.70134563629373325, 1.0) -(0.11787773933102653, 0.42837370242214529, 0.69826989619377167, 1.0) -(0.11480199923106507, 0.42443675509419465, 0.69519415609381019, 1.0) -(0.11172625913110343, 0.42049980776624374, 0.6921184159938486, 1.0) -(0.10865051903114188, 0.41656286043829294, 0.68904267589388701, 1.0) -(0.10557477893118032, 0.41262591311034214, 0.68596693579392543, 1.0) -(0.10249903883121878, 0.40868896578239139, 0.68289119569396384, 1.0) -(0.099423298731257215, 0.40475201845444059, 0.67981545559400236, 1.0) -(0.096347558631295654, 0.40081507112648979, 0.67673971549404077, 1.0) -(0.093271818531334108, 0.39687812379853898, 0.67366397539407918, 1.0) -(0.090196078431372562, 0.39294117647058824, 0.67058823529411771, 1.0) -(0.087120338331411001, 0.38900422914263744, 0.66751249519415612, 1.0) -(0.084044598231449441, 0.38506728181468663, 0.66443675509419453, 1.0) -(0.080968858131487895, 0.38113033448673583, 0.66136101499423305, 1.0) -(0.077893118031526348, 0.37719338715878503, 0.65828527489427147, 1.0) -(0.074817377931564788, 0.37325643983083429, 0.65520953479430988, 1.0) -(0.071741637831603228, 0.36931949250288348, 0.6521337946943484, 1.0) -(0.068665897731641681, 0.36538254517493268, 0.64905805459438681, 1.0) -(0.065590157631680218, 0.36144559784698205, 0.64598231449442534, 1.0) -(0.062514417531718575, 0.35750865051903113, 0.64290657439446375, 1.0) -(0.059438677431757014, 0.35357170319108033, 0.63983083429450216, 1.0) -(0.056362937331795468, 0.34963475586312953, 0.63675509419454057, 1.0) -(0.053287197231833908, 0.34569780853517873, 0.63367935409457909, 1.0) -(0.050211457131872361, 0.34176086120722798, 0.63060361399461751, 1.0) -(0.047135717031910801, 0.33782391387927718, 0.62752787389465592, 1.0) -(0.044059976931949255, 0.33388696655132638, 0.62445213379469444, 1.0) -(0.040984236831987694, 0.32995001922337563, 0.62137639369473285, 1.0) -(0.037908496732026148, 0.32601307189542483, 0.61830065359477127, 1.0) -(0.034832756632064588, 0.32207612456747403, 0.61522491349480979, 1.0) -(0.031757016532103041, 0.31813917723952323, 0.6121491733948482, 1.0) -(0.031372549019607843, 0.3140945790080738, 0.60648981161091897, 1.0) -(0.031372549019607843, 0.31003460207612454, 0.60046136101499425, 1.0) -(0.031372549019607843, 0.30597462514417528, 0.59443291041906965, 1.0) -(0.031372549019607843, 0.30191464821222602, 0.58840445982314504, 1.0) -(0.031372549019607843, 0.29785467128027693, 0.58237600922722055, 1.0) -(0.031372549019607843, 0.29379469434832756, 0.57634755863129572, 1.0) -(0.031372549019607843, 0.2897347174163783, 0.570319108035371, 1.0) -(0.031372549019607843, 0.28567474048442904, 0.5642906574394464, 1.0) -(0.031372549019607843, 0.28161476355247983, 0.55826220684352179, 1.0) -(0.031372549019607843, 0.27755478662053057, 0.55223375624759707, 1.0) -(0.031372549019607843, 0.27349480968858131, 0.54620530565167247, 1.0) -(0.031372549019607843, 0.26943483275663205, 0.54017685505574786, 1.0) -(0.031372549019607843, 0.26537485582468279, 0.53414840445982315, 1.0) -(0.031372549019607843, 0.26131487889273353, 0.52811995386389854, 1.0) -(0.031372549019607843, 0.25725490196078432, 0.52209150326797382, 1.0) -(0.031372549019607843, 0.25319492502883506, 0.51606305267204922, 1.0) -(0.031372549019607843, 0.2491349480968858, 0.51003460207612461, 1.0) -(0.031372549019607843, 0.24507497116493654, 0.50400615148019989, 1.0) -(0.031372549019607843, 0.24101499423298731, 0.49797770088427529, 1.0) -(0.031372549019607843, 0.23695501730103807, 0.49194925028835068, 1.0) -(0.031372549019607843, 0.23289504036908892, 0.48592079969242619, 1.0) -(0.031372549019607843, 0.22883506343713955, 0.47989234909650136, 1.0) -(0.031372549019607843, 0.22477508650519029, 0.47386389850057675, 1.0) -(0.031372549019607843, 0.22071510957324106, 0.46783544790465204, 1.0) -(0.031372549019607843, 0.2166551326412918, 0.46180699730872743, 1.0) -(0.031372549019607843, 0.21259515570934256, 0.45577854671280282, 1.0) -(0.031372549019607843, 0.2085351787773933, 0.44975009611687811, 1.0) -(0.031372549019607843, 0.20447520184544404, 0.4437216455209535, 1.0) -(0.031372549019607843, 0.20041522491349481, 0.43769319492502884, 1.0) -(0.031372549019607843, 0.19635524798154555, 0.43166474432910418, 1.0) -(0.031372549019607843, 0.19229527104959632, 0.42563629373317957, 1.0) -(0.031372549019607843, 0.18823529411764706, 0.41960784313725491, 1.0) diff --git a/extern/tfn/colormaps/sequential/BuGn.cpp b/extern/tfn/colormaps/sequential/BuGn.cpp deleted file mode 100644 index f1647e7..0000000 --- a/extern/tfn/colormaps/sequential/BuGn.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential_BuGn; -} -const std::vector colormap::data_sequential_BuGn = /* NOLINT(cert-err58-cpp) */ -{ -{0.96862745098039216f, 0.9882352941176471f, 0.99215686274509807f, 1.0f}, -{0.96641291810841989f, 0.98737408688965789f, 0.99166474432910423f, 1.0f}, -{0.96419838523644752f, 0.98651287966166867f, 0.99117262591311039f, 1.0f}, -{0.96198385236447526f, 0.98565167243367935f, 0.99068050749711656f, 1.0f}, -{0.95976931949250288f, 0.98479046520569014f, 0.99018838908112272f, 1.0f}, -{0.95755478662053062f, 0.98392925797770092f, 0.98969627066512877f, 1.0f}, -{0.95534025374855824f, 0.98306805074971171f, 0.98920415224913494f, 1.0f}, -{0.95312572087658598f, 0.98220684352172249f, 0.9887120338331411f, 1.0f}, -{0.95091118800461361f, 0.98134563629373317f, 0.98821991541714727f, 1.0f}, -{0.94869665513264134f, 0.98048442906574396f, 0.98772779700115343f, 1.0f}, -{0.94648212226066897f, 0.97962322183775474f, 0.98723567858515959f, 1.0f}, -{0.9442675893886967f, 0.97876201460976553f, 0.98674356016916576f, 1.0f}, -{0.94205305651672433f, 0.97790080738177632f, 0.98625144175317181f, 1.0f}, -{0.93983852364475207f, 0.97703960015378699f, 0.98575932333717797f, 1.0f}, -{0.93762399077277969f, 0.97617839292579778f, 0.98526720492118414f, 1.0f}, -{0.93540945790080743f, 0.97531718569780856f, 0.9847750865051903f, 1.0f}, -{0.93319492502883505f, 0.97445597846981935f, 0.98428296808919646f, 1.0f}, -{0.93098039215686279f, 0.97359477124183014f, 0.98379084967320263f, 1.0f}, -{0.92876585928489042f, 0.97273356401384081f, 0.98329873125720879f, 1.0f}, -{0.92655132641291815f, 0.9718723567858516f, 0.98280661284121495f, 1.0f}, -{0.92433679354094578f, 0.97101114955786239f, 0.98231449442522101f, 1.0f}, -{0.92212226066897351f, 0.97014994232987317f, 0.98182237600922717f, 1.0f}, -{0.91990772779700114f, 0.96928873510188396f, 0.98133025759323333f, 1.0f}, -{0.91769319492502888f, 0.96842752787389474f, 0.9808381391772395f, 1.0f}, -{0.9154786620530565f, 0.96756632064590542f, 0.98034602076124566f, 1.0f}, -{0.91326412918108424f, 0.96670511341791621f, 0.97985390234525183f, 1.0f}, -{0.91104959630911186f, 0.96584390618992699f, 0.97936178392925799f, 1.0f}, -{0.9088350634371396f, 0.96498269896193778f, 0.97886966551326415f, 1.0f}, -{0.90662053056516723f, 0.96412149173394845f, 0.97837754709727021f, 1.0f}, -{0.90440599769319496f, 0.96326028450595924f, 0.97788542868127637f, 1.0f}, -{0.90219146482122259f, 0.96239907727797003f, 0.97739331026528253f, 1.0f}, -{0.89997693194925033f, 0.96153787004998081f, 0.9769011918492887f, 1.0f}, -{0.89765474817377933f, 0.96064590542099193f, 0.97617839292579778f, 1.0f}, -{0.89457900807381785f, 0.9595386389850058f, 0.97384083044982694f, 1.0f}, -{0.89150326797385626f, 0.95843137254901967f, 0.97150326797385622f, 1.0f}, -{0.88842752787389467f, 0.95732410611303342f, 0.96916570549788539f, 1.0f}, -{0.88535178777393309f, 0.95621683967704729f, 0.96682814302191467f, 1.0f}, -{0.88227604767397161f, 0.95510957324106116f, 0.96449058054594383f, 1.0f}, -{0.87920030757401002f, 0.95400230680507503f, 0.96215301806997311f, 1.0f}, -{0.87612456747404843f, 0.9528950403690889f, 0.95981545559400228f, 1.0f}, -{0.87304882737408696f, 0.95178777393310265f, 0.95747789311803155f, 1.0f}, -{0.86997308727412537f, 0.95068050749711652f, 0.95514033064206072f, 1.0f}, -{0.86689734717416378f, 0.94957324106113039f, 0.95280276816609f, 1.0f}, -{0.8638216070742023f, 0.94846597462514426f, 0.95046520569011916f, 1.0f}, -{0.86074586697424071f, 0.94735870818915802f, 0.94812764321414844f, 1.0f}, -{0.85767012687427924f, 0.94625144175317188f, 0.94579008073817761f, 1.0f}, -{0.85459438677431765f, 0.94514417531718575f, 0.94345251826220689f, 1.0f}, -{0.85151864667435606f, 0.94403690888119962f, 0.94111495578623605f, 1.0f}, -{0.84844290657439447f, 0.94292964244521338f, 0.93877739331026533f, 1.0f}, -{0.845367166474433f, 0.94182237600922725f, 0.9364398308342945f, 1.0f}, -{0.84229142637447141f, 0.94071510957324112f, 0.93410226835832377f, 1.0f}, -{0.83921568627450982f, 0.93960784313725498f, 0.93176470588235294f, 1.0f}, -{0.83613994617454834f, 0.93850057670126874f, 0.92942714340638211f, 1.0f}, -{0.83306420607458675f, 0.93739331026528261f, 0.92708958093041138f, 1.0f}, -{0.82998846597462517f, 0.93628604382929648f, 0.92475201845444066f, 1.0f}, -{0.82691272587466358f, 0.93517877739331035f, 0.92241445597846983f, 1.0f}, -{0.8238369857747021f, 0.9340715109573241f, 0.92007689350249899f, 1.0f}, -{0.82076124567474051f, 0.93296424452133797f, 0.91773933102652827f, 1.0f}, -{0.81768550557477893f, 0.93185697808535184f, 0.91540176855055744f, 1.0f}, -{0.81460976547481745f, 0.93074971164936571f, 0.91306420607458672f, 1.0f}, -{0.81153402537485586f, 0.92964244521337946f, 0.91072664359861588f, 1.0f}, -{0.80845828527489438f, 0.92853517877739333f, 0.90838908112264516f, 1.0f}, -{0.8053825451749328f, 0.9274279123414072f, 0.90605151864667433f, 1.0f}, -{0.80230680507497121f, 0.92632064590542107f, 0.9037139561707036f, 1.0f}, -{0.79843137254901964f, 0.92487504805843912f, 0.90106881968473662f, 1.0f}, -{0.79215686274509811f, 0.92241445597846983f, 0.8975009611687812f, 1.0f}, -{0.78588235294117659f, 0.91995386389850065f, 0.89393310265282588f, 1.0f}, -{0.77960784313725495f, 0.91749327181853135f, 0.89036524413687046f, 1.0f}, -{0.77333333333333332f, 0.91503267973856217f, 0.88679738562091504f, 1.0f}, -{0.76705882352941179f, 0.91257208765859288f, 0.88322952710495961f, 1.0f}, -{0.76078431372549027f, 0.91011149557862359f, 0.87966166858900419f, 1.0f}, -{0.75450980392156863f, 0.9076509034986544f, 0.87609381007304887f, 1.0f}, -{0.74823529411764711f, 0.90519031141868511f, 0.87252595155709345f, 1.0f}, -{0.74196078431372547f, 0.90272971933871593f, 0.86895809304113802f, 1.0f}, -{0.73568627450980406f, 0.90026912725874664f, 0.86539023452518271f, 1.0f}, -{0.72941176470588243f, 0.89780853517877746f, 0.86182237600922718f, 1.0f}, -{0.72313725490196079f, 0.89534794309880816f, 0.85825451749327186f, 1.0f}, -{0.71686274509803927f, 0.89288735101883887f, 0.85468665897731644f, 1.0f}, -{0.71058823529411763f, 0.89042675893886969f, 0.85111880046136101f, 1.0f}, -{0.70431372549019611f, 0.8879661668589004f, 0.84755094194540559f, 1.0f}, -{0.69803921568627447f, 0.88550557477893121f, 0.84398308342945016f, 1.0f}, -{0.69176470588235295f, 0.88304498269896192f, 0.84041522491349485f, 1.0f}, -{0.68549019607843142f, 0.88058439061899274f, 0.83684736639753943f, 1.0f}, -{0.67921568627450979f, 0.87812379853902345f, 0.833279507881584f, 1.0f}, -{0.67294117647058826f, 0.87566320645905427f, 0.82971164936562858f, 1.0f}, -{0.66666666666666674f, 0.87320261437908497f, 0.82614379084967315f, 1.0f}, -{0.66039215686274511f, 0.87074202229911568f, 0.82257593233371784f, 1.0f}, -{0.65411764705882347f, 0.8682814302191465f, 0.81900807381776242f, 1.0f}, -{0.64784313725490195f, 0.86582083813917721f, 0.81544021530180699f, 1.0f}, -{0.64156862745098042f, 0.86336024605920803f, 0.81187235678585157f, 1.0f}, -{0.6352941176470589f, 0.86089965397923884f, 0.80830449826989625f, 1.0f}, -{0.62901960784313726f, 0.85843906189926955f, 0.80473663975394083f, 1.0f}, -{0.62274509803921574f, 0.85597846981930026f, 0.80116878123798541f, 1.0f}, -{0.6164705882352941f, 0.85351787773933108f, 0.79760092272202998f, 1.0f}, -{0.61019607843137258f, 0.85105728565936178f, 0.79403306420607456f, 1.0f}, -{0.60392156862745094f, 0.84859669357939249f, 0.79046520569011913f, 1.0f}, -{0.59764705882352942f, 0.84604382929642441f, 0.78652825836216833f, 1.0f}, -{0.59137254901960778f, 0.84333717800845831f, 0.78197616301422523f, 1.0f}, -{0.58509803921568637f, 0.8406305267204921f, 0.77742406766628225f, 1.0f}, -{0.57882352941176474f, 0.83792387543252589f, 0.77287197231833904f, 1.0f}, -{0.5725490196078431f, 0.83521722414455979f, 0.76831987697039594f, 1.0f}, -{0.56627450980392158f, 0.83251057285659358f, 0.76376778162245285f, 1.0f}, -{0.55999999999999994f, 0.82980392156862748f, 0.75921568627450975f, 1.0f}, -{0.55372549019607842f, 0.82709727028066127f, 0.75466359092656665f, 1.0f}, -{0.54745098039215689f, 0.82439061899269506f, 0.75011149557862355f, 1.0f}, -{0.54117647058823526f, 0.82168396770472896f, 0.74555940023068046f, 1.0f}, -{0.53490196078431385f, 0.81897731641676286f, 0.74100730488273747f, 1.0f}, -{0.5286274509803921f, 0.81627066512879665f, 0.73645520953479426f, 1.0f}, -{0.52235294117647058f, 0.81356401384083044f, 0.73190311418685117f, 1.0f}, -{0.51607843137254905f, 0.81085736255286422f, 0.72735101883890807f, 1.0f}, -{0.50980392156862742f, 0.80815071126489813f, 0.72279892349096497f, 1.0f}, -{0.50352941176470589f, 0.80544405997693191f, 0.71824682814302188f, 1.0f}, -{0.49725490196078431f, 0.80273740868896581f, 0.71369473279507889f, 1.0f}, -{0.49098039215686273f, 0.8000307574009996f, 0.70914263744713568f, 1.0f}, -{0.48470588235294126f, 0.7973241061130335f, 0.7045905420991927f, 1.0f}, -{0.47843137254901963f, 0.79461745482506729f, 0.70003844675124949f, 1.0f}, -{0.47215686274509805f, 0.79191080353710108f, 0.6954863514033065f, 1.0f}, -{0.46588235294117653f, 0.78920415224913487f, 0.69093425605536329f, 1.0f}, -{0.45960784313725489f, 0.78649750096116877f, 0.68638216070742031f, 1.0f}, -{0.45333333333333337f, 0.78379084967320256f, 0.6818300653594771f, 1.0f}, -{0.44705882352941179f, 0.78108419838523646f, 0.67727797001153411f, 1.0f}, -{0.44078431372549021f, 0.77837754709727025f, 0.67272587466359091f, 1.0f}, -{0.43450980392156874f, 0.77567089580930415f, 0.66817377931564792f, 1.0f}, -{0.42823529411764705f, 0.77296424452133794f, 0.66362168396770471f, 1.0f}, -{0.42196078431372552f, 0.77025759323337173f, 0.65906958861976173f, 1.0f}, -{0.41568627450980394f, 0.76755094194540563f, 0.65451749327181852f, 1.0f}, -{0.40941176470588236f, 0.76484429065743942f, 0.64996539792387553f, 1.0f}, -{0.40313725490196084f, 0.76213763936947321f, 0.64541330257593232f, 1.0f}, -{0.39772395232602847f, 0.75955401768550557f, 0.64030757400999616f, 1.0f}, -{0.39317185697808538f, 0.75709342560553627f, 0.63464821222606693f, 1.0f}, -{0.38861976163014228f, 0.75463283352556709f, 0.6289888504421377f, 1.0f}, -{0.38406766628219918f, 0.7521722414455978f, 0.62332948865820847f, 1.0f}, -{0.3795155709342562f, 0.74971164936562862f, 0.61767012687427936f, 1.0f}, -{0.37496347558631299f, 0.74725105728565933f, 0.61201076509034991f, 1.0f}, -{0.37041138023836989f, 0.74479046520569014f, 0.60635140330642068f, 1.0f}, -{0.36585928489042679f, 0.74232987312572085f, 0.60069204152249145f, 1.0f}, -{0.36130718954248364f, 0.73986928104575156f, 0.59503267973856211f, 1.0f}, -{0.35675509419454055f, 0.73740868896578238f, 0.58937331795463288f, 1.0f}, -{0.35220299884659745f, 0.73494809688581308f, 0.58371395617070365f, 1.0f}, -{0.34765090349865435f, 0.7324875048058439f, 0.57805459438677431f, 1.0f}, -{0.34309880815071125f, 0.73002691272587461f, 0.57239523260284508f, 1.0f}, -{0.33854671280276816f, 0.72756632064590543f, 0.56673587081891585f, 1.0f}, -{0.33399461745482506f, 0.72510572856593614f, 0.56107650903498663f, 1.0f}, -{0.32944252210688196f, 0.72264513648596695f, 0.55541714725105729f, 1.0f}, -{0.32489042675893887f, 0.72018454440599766f, 0.54975778546712806f, 1.0f}, -{0.32033833141099577f, 0.71772395232602848f, 0.54409842368319883f, 1.0f}, -{0.31578623606305267f, 0.71526336024605919f, 0.53843906189926949f, 1.0f}, -{0.31123414071510958f, 0.71280276816609001f, 0.53277970011534026f, 1.0f}, -{0.30668204536716659f, 0.71034217608612082f, 0.52712033833141114f, 1.0f}, -{0.30212995001922338f, 0.70788158400615142f, 0.5214609765474818f, 1.0f}, -{0.29757785467128028f, 0.70542099192618224f, 0.51580161476355246f, 1.0f}, -{0.29302575932333719f, 0.70296039984621295f, 0.51014225297962323f, 1.0f}, -{0.28847366397539409f, 0.70049980776624376f, 0.50448289119569401f, 1.0f}, -{0.28392156862745099f, 0.69803921568627447f, 0.49882352941176472f, 1.0f}, -{0.2793694732795079f, 0.69557862360630529f, 0.49316416762783544f, 1.0f}, -{0.2748173779315648f, 0.693118031526336f, 0.48750480584390621f, 1.0f}, -{0.2702652825836217f, 0.69065743944636682f, 0.48184544405997698f, 1.0f}, -{0.26571318723567861f, 0.68819684736639752f, 0.4761860822760477f, 1.0f}, -{0.26116109188773545f, 0.68573625528642834f, 0.47052672049211841f, 1.0f}, -{0.25660899653979236f, 0.68327566320645905f, 0.46486735870818918f, 1.0f}, -{0.25259515570934254f, 0.67966166858900423f, 0.45897731641676281f, 1.0f}, -{0.24890426758938869f, 0.67535563244905805f, 0.45294886582083815f, 1.0f}, -{0.24521337946943481f, 0.67104959630911187f, 0.44692041522491349f, 1.0f}, -{0.24152249134948095f, 0.66674356016916569f, 0.44089196462898889f, 1.0f}, -{0.23783160322952721f, 0.66243752402921963f, 0.43486351403306439f, 1.0f}, -{0.23414071510957324f, 0.65813148788927334f, 0.42883506343713956f, 1.0f}, -{0.23044982698961936f, 0.65382545174932716f, 0.4228066128412149f, 1.0f}, -{0.2267589388696655f, 0.64951941560938098f, 0.4167781622452903f, 1.0f}, -{0.22306805074971164f, 0.6452133794694348f, 0.41074971164936563f, 1.0f}, -{0.21937716262975779f, 0.64090734332948862f, 0.40472126105344097f, 1.0f}, -{0.21568627450980393f, 0.63660130718954244f, 0.39869281045751637f, 1.0f}, -{0.21199538638985005f, 0.63229527104959626f, 0.39266435986159171f, 1.0f}, -{0.20830449826989619f, 0.62798923490965008f, 0.38663590926566704f, 1.0f}, -{0.20461361014994234f, 0.62368319876970391f, 0.38060745866974244f, 1.0f}, -{0.20092272202998845f, 0.61937716262975773f, 0.37457900807381778f, 1.0f}, -{0.1972318339100346f, 0.61507112648981166f, 0.36855055747789311f, 1.0f}, -{0.19354094579008074f, 0.61076509034986537f, 0.36252210688196845f, 1.0f}, -{0.18985005767012686f, 0.60645905420991919f, 0.35649365628604379f, 1.0f}, -{0.186159169550173f, 0.60215301806997301f, 0.35046520569011919f, 1.0f}, -{0.18246828143021915f, 0.59784698193002694f, 0.34443675509419452f, 1.0f}, -{0.17877739331026538f, 0.59354094579008088f, 0.33840830449827008f, 1.0f}, -{0.17508650519031144f, 0.58923490965013459f, 0.33237985390234526f, 1.0f}, -{0.17139561707035755f, 0.5849288735101883f, 0.3263514033064206f, 1.0f}, -{0.1677047289504037f, 0.58062283737024223f, 0.32032295271049593f, 1.0f}, -{0.16401384083044984f, 0.57631680123029605f, 0.31429450211457133f, 1.0f}, -{0.16032295271049596f, 0.57201076509034987f, 0.30826605151864667f, 1.0f}, -{0.1566320645905421f, 0.56770472895040369f, 0.30223760092272201f, 1.0f}, -{0.15294117647058825f, 0.56339869281045751f, 0.2962091503267974f, 1.0f}, -{0.14925028835063436f, 0.55909265667051133f, 0.29018069973087268f, 1.0f}, -{0.14555940023068051f, 0.55478662053056516f, 0.28415224913494808f, 1.0f}, -{0.14186851211072665f, 0.55048058439061898f, 0.27812379853902347f, 1.0f}, -{0.13817762399077277f, 0.5461745482506728f, 0.27209534794309875f, 1.0f}, -{0.13402537485582469f, 0.54232987312572078f, 0.26828143021914647f, 1.0f}, -{0.12971933871587851f, 0.53863898500576701f, 0.26520569011918493f, 1.0f}, -{0.12541330257593233f, 0.53494809688581313f, 0.26212995001922335f, 1.0f}, -{0.12110726643598617f, 0.53125720876585925f, 0.25905420991926181f, 1.0f}, -{0.11680123029604011f, 0.52756632064590547f, 0.25597846981930034f, 1.0f}, -{0.11249519415609383f, 0.52387543252595148f, 0.25290272971933869f, 1.0f}, -{0.10818915801614765f, 0.5201845444059976f, 0.24982698961937716f, 1.0f}, -{0.10388312187620147f, 0.51649365628604382f, 0.2467512495194156f, 1.0f}, -{0.099577085736255289f, 0.51280276816608994f, 0.24367550941945404f, 1.0f}, -{0.09527104959630911f, 0.50911188004613606f, 0.24059976931949248f, 1.0f}, -{0.090965013456362945f, 0.50542099192618217f, 0.23752402921953092f, 1.0f}, -{0.086658977316416766f, 0.50173010380622829f, 0.23444828911956939f, 1.0f}, -{0.082352941176470601f, 0.49803921568627446f, 0.23137254901960783f, 1.0f}, -{0.078046905036524422f, 0.49434832756632063f, 0.22829680891964627f, 1.0f}, -{0.073740868896578243f, 0.49065743944636675f, 0.22522106881968473f, 1.0f}, -{0.069434832756632064f, 0.48696655132641287f, 0.22214532871972317f, 1.0f}, -{0.065128796616685899f, 0.48327566320645904f, 0.21906958861976161f, 1.0f}, -{0.060822760476739721f, 0.47958477508650516f, 0.21599384851980008f, 1.0f}, -{0.056516724336793542f, 0.47589388696655127f, 0.21291810841983852f, 1.0f}, -{0.052210688196847363f, 0.47220299884659744f, 0.20984236831987696f, 1.0f}, -{0.047904652056901309f, 0.46851211072664367f, 0.20676662821991548f, 1.0f}, -{0.043598615916955019f, 0.46482122260668968f, 0.20369088811995384f, 1.0f}, -{0.03929257977700884f, 0.46113033448673585f, 0.20061514801999231f, 1.0f}, -{0.034986543637062675f, 0.45743944636678197f, 0.19753940792003075f, 1.0f}, -{0.030680507497116496f, 0.45374855824682814f, 0.19446366782006919f, 1.0f}, -{0.026374471357170318f, 0.45005767012687425f, 0.19138792772010765f, 1.0f}, -{0.022068435217224139f, 0.44636678200692037f, 0.18831218762014609f, 1.0f}, -{0.017762399077277974f, 0.44267589388696654f, 0.18523644752018453f, 1.0f}, -{0.013456362937331795f, 0.43898500576701266f, 0.182160707420223f, 1.0f}, -{0.0091503267973856162f, 0.43529411764705883f, 0.17908496732026141f, 1.0f}, -{0.0048442906574394373f, 0.43160322952710495f, 0.17600922722029988f, 1.0f}, -{0.00053825451749325848f, 0.42791234140715106f, 0.17293348712033835f, 1.0f}, -{0.0f, 0.42303729334871204f, 0.170718954248366f, 1.0f}, -{0.0f, 0.41799307958477505f, 0.16862745098039217f, 1.0f}, -{0.0f, 0.41294886582083812f, 0.16653594771241831f, 1.0f}, -{0.0f, 0.40790465205690118f, 0.16444444444444445f, 1.0f}, -{0.0f, 0.40286043829296436f, 0.16235294117647064f, 1.0f}, -{0.0f, 0.39781622452902726f, 0.16026143790849673f, 1.0f}, -{0.0f, 0.39277201076509033f, 0.15816993464052287f, 1.0f}, -{0.0f, 0.3877277970011534f, 0.15607843137254901f, 1.0f}, -{0.0f, 0.38268358323721646f, 0.15398692810457515f, 1.0f}, -{0.0f, 0.37763936947327947f, 0.15189542483660129f, 1.0f}, -{0.0f, 0.37259515570934254f, 0.14980392156862746f, 1.0f}, -{0.0f, 0.36755094194540561f, 0.1477124183006536f, 1.0f}, -{0.0f, 0.36250672818146867f, 0.14562091503267974f, 1.0f}, -{0.0f, 0.35746251441753168f, 0.14352941176470588f, 1.0f}, -{0.0f, 0.35241830065359475f, 0.14143790849673202f, 1.0f}, -{0.0f, 0.34737408688965782f, 0.13934640522875816f, 1.0f}, -{0.0f, 0.34232987312572088f, 0.13725490196078433f, 1.0f}, -{0.0f, 0.3372856593617839f, 0.13516339869281047f, 1.0f}, -{0.0f, 0.33224144559784696f, 0.13307189542483661f, 1.0f}, -{0.0f, 0.32719723183391003f, 0.13098039215686275f, 1.0f}, -{0.0f, 0.32215301806997321f, 0.12888888888888894f, 1.0f}, -{0.0f, 0.31710880430603616f, 0.12679738562091503f, 1.0f}, -{0.0f, 0.31206459054209917f, 0.12470588235294117f, 1.0f}, -{0.0f, 0.30702037677816224f, 0.12261437908496732f, 1.0f}, -{0.0f, 0.30197616301422525f, 0.12052287581699346f, 1.0f}, -{0.0f, 0.29693194925028832f, 0.11843137254901961f, 1.0f}, -{0.0f, 0.29188773548635139f, 0.11633986928104575f, 1.0f}, -{0.0f, 0.28684352172241445f, 0.11424836601307189f, 1.0f}, -{0.0f, 0.28179930795847752f, 0.11215686274509803f, 1.0f}, -{0.0f, 0.27675509419454059f, 0.11006535947712418f, 1.0f}, -{0.0f, 0.2717108804306036f, 0.10797385620915033f, 1.0f}, -{0.0f, 0.26666666666666666f, 0.10588235294117647f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential/BuGn.txt b/extern/tfn/colormaps/sequential/BuGn.txt deleted file mode 100644 index a074742..0000000 --- a/extern/tfn/colormaps/sequential/BuGn.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.96862745098039216, 0.9882352941176471, 0.99215686274509807, 1.0) -(0.96641291810841989, 0.98737408688965789, 0.99166474432910423, 1.0) -(0.96419838523644752, 0.98651287966166867, 0.99117262591311039, 1.0) -(0.96198385236447526, 0.98565167243367935, 0.99068050749711656, 1.0) -(0.95976931949250288, 0.98479046520569014, 0.99018838908112272, 1.0) -(0.95755478662053062, 0.98392925797770092, 0.98969627066512877, 1.0) -(0.95534025374855824, 0.98306805074971171, 0.98920415224913494, 1.0) -(0.95312572087658598, 0.98220684352172249, 0.9887120338331411, 1.0) -(0.95091118800461361, 0.98134563629373317, 0.98821991541714727, 1.0) -(0.94869665513264134, 0.98048442906574396, 0.98772779700115343, 1.0) -(0.94648212226066897, 0.97962322183775474, 0.98723567858515959, 1.0) -(0.9442675893886967, 0.97876201460976553, 0.98674356016916576, 1.0) -(0.94205305651672433, 0.97790080738177632, 0.98625144175317181, 1.0) -(0.93983852364475207, 0.97703960015378699, 0.98575932333717797, 1.0) -(0.93762399077277969, 0.97617839292579778, 0.98526720492118414, 1.0) -(0.93540945790080743, 0.97531718569780856, 0.9847750865051903, 1.0) -(0.93319492502883505, 0.97445597846981935, 0.98428296808919646, 1.0) -(0.93098039215686279, 0.97359477124183014, 0.98379084967320263, 1.0) -(0.92876585928489042, 0.97273356401384081, 0.98329873125720879, 1.0) -(0.92655132641291815, 0.9718723567858516, 0.98280661284121495, 1.0) -(0.92433679354094578, 0.97101114955786239, 0.98231449442522101, 1.0) -(0.92212226066897351, 0.97014994232987317, 0.98182237600922717, 1.0) -(0.91990772779700114, 0.96928873510188396, 0.98133025759323333, 1.0) -(0.91769319492502888, 0.96842752787389474, 0.9808381391772395, 1.0) -(0.9154786620530565, 0.96756632064590542, 0.98034602076124566, 1.0) -(0.91326412918108424, 0.96670511341791621, 0.97985390234525183, 1.0) -(0.91104959630911186, 0.96584390618992699, 0.97936178392925799, 1.0) -(0.9088350634371396, 0.96498269896193778, 0.97886966551326415, 1.0) -(0.90662053056516723, 0.96412149173394845, 0.97837754709727021, 1.0) -(0.90440599769319496, 0.96326028450595924, 0.97788542868127637, 1.0) -(0.90219146482122259, 0.96239907727797003, 0.97739331026528253, 1.0) -(0.89997693194925033, 0.96153787004998081, 0.9769011918492887, 1.0) -(0.89765474817377933, 0.96064590542099193, 0.97617839292579778, 1.0) -(0.89457900807381785, 0.9595386389850058, 0.97384083044982694, 1.0) -(0.89150326797385626, 0.95843137254901967, 0.97150326797385622, 1.0) -(0.88842752787389467, 0.95732410611303342, 0.96916570549788539, 1.0) -(0.88535178777393309, 0.95621683967704729, 0.96682814302191467, 1.0) -(0.88227604767397161, 0.95510957324106116, 0.96449058054594383, 1.0) -(0.87920030757401002, 0.95400230680507503, 0.96215301806997311, 1.0) -(0.87612456747404843, 0.9528950403690889, 0.95981545559400228, 1.0) -(0.87304882737408696, 0.95178777393310265, 0.95747789311803155, 1.0) -(0.86997308727412537, 0.95068050749711652, 0.95514033064206072, 1.0) -(0.86689734717416378, 0.94957324106113039, 0.95280276816609, 1.0) -(0.8638216070742023, 0.94846597462514426, 0.95046520569011916, 1.0) -(0.86074586697424071, 0.94735870818915802, 0.94812764321414844, 1.0) -(0.85767012687427924, 0.94625144175317188, 0.94579008073817761, 1.0) -(0.85459438677431765, 0.94514417531718575, 0.94345251826220689, 1.0) -(0.85151864667435606, 0.94403690888119962, 0.94111495578623605, 1.0) -(0.84844290657439447, 0.94292964244521338, 0.93877739331026533, 1.0) -(0.845367166474433, 0.94182237600922725, 0.9364398308342945, 1.0) -(0.84229142637447141, 0.94071510957324112, 0.93410226835832377, 1.0) -(0.83921568627450982, 0.93960784313725498, 0.93176470588235294, 1.0) -(0.83613994617454834, 0.93850057670126874, 0.92942714340638211, 1.0) -(0.83306420607458675, 0.93739331026528261, 0.92708958093041138, 1.0) -(0.82998846597462517, 0.93628604382929648, 0.92475201845444066, 1.0) -(0.82691272587466358, 0.93517877739331035, 0.92241445597846983, 1.0) -(0.8238369857747021, 0.9340715109573241, 0.92007689350249899, 1.0) -(0.82076124567474051, 0.93296424452133797, 0.91773933102652827, 1.0) -(0.81768550557477893, 0.93185697808535184, 0.91540176855055744, 1.0) -(0.81460976547481745, 0.93074971164936571, 0.91306420607458672, 1.0) -(0.81153402537485586, 0.92964244521337946, 0.91072664359861588, 1.0) -(0.80845828527489438, 0.92853517877739333, 0.90838908112264516, 1.0) -(0.8053825451749328, 0.9274279123414072, 0.90605151864667433, 1.0) -(0.80230680507497121, 0.92632064590542107, 0.9037139561707036, 1.0) -(0.79843137254901964, 0.92487504805843912, 0.90106881968473662, 1.0) -(0.79215686274509811, 0.92241445597846983, 0.8975009611687812, 1.0) -(0.78588235294117659, 0.91995386389850065, 0.89393310265282588, 1.0) -(0.77960784313725495, 0.91749327181853135, 0.89036524413687046, 1.0) -(0.77333333333333332, 0.91503267973856217, 0.88679738562091504, 1.0) -(0.76705882352941179, 0.91257208765859288, 0.88322952710495961, 1.0) -(0.76078431372549027, 0.91011149557862359, 0.87966166858900419, 1.0) -(0.75450980392156863, 0.9076509034986544, 0.87609381007304887, 1.0) -(0.74823529411764711, 0.90519031141868511, 0.87252595155709345, 1.0) -(0.74196078431372547, 0.90272971933871593, 0.86895809304113802, 1.0) -(0.73568627450980406, 0.90026912725874664, 0.86539023452518271, 1.0) -(0.72941176470588243, 0.89780853517877746, 0.86182237600922718, 1.0) -(0.72313725490196079, 0.89534794309880816, 0.85825451749327186, 1.0) -(0.71686274509803927, 0.89288735101883887, 0.85468665897731644, 1.0) -(0.71058823529411763, 0.89042675893886969, 0.85111880046136101, 1.0) -(0.70431372549019611, 0.8879661668589004, 0.84755094194540559, 1.0) -(0.69803921568627447, 0.88550557477893121, 0.84398308342945016, 1.0) -(0.69176470588235295, 0.88304498269896192, 0.84041522491349485, 1.0) -(0.68549019607843142, 0.88058439061899274, 0.83684736639753943, 1.0) -(0.67921568627450979, 0.87812379853902345, 0.833279507881584, 1.0) -(0.67294117647058826, 0.87566320645905427, 0.82971164936562858, 1.0) -(0.66666666666666674, 0.87320261437908497, 0.82614379084967315, 1.0) -(0.66039215686274511, 0.87074202229911568, 0.82257593233371784, 1.0) -(0.65411764705882347, 0.8682814302191465, 0.81900807381776242, 1.0) -(0.64784313725490195, 0.86582083813917721, 0.81544021530180699, 1.0) -(0.64156862745098042, 0.86336024605920803, 0.81187235678585157, 1.0) -(0.6352941176470589, 0.86089965397923884, 0.80830449826989625, 1.0) -(0.62901960784313726, 0.85843906189926955, 0.80473663975394083, 1.0) -(0.62274509803921574, 0.85597846981930026, 0.80116878123798541, 1.0) -(0.6164705882352941, 0.85351787773933108, 0.79760092272202998, 1.0) -(0.61019607843137258, 0.85105728565936178, 0.79403306420607456, 1.0) -(0.60392156862745094, 0.84859669357939249, 0.79046520569011913, 1.0) -(0.59764705882352942, 0.84604382929642441, 0.78652825836216833, 1.0) -(0.59137254901960778, 0.84333717800845831, 0.78197616301422523, 1.0) -(0.58509803921568637, 0.8406305267204921, 0.77742406766628225, 1.0) -(0.57882352941176474, 0.83792387543252589, 0.77287197231833904, 1.0) -(0.5725490196078431, 0.83521722414455979, 0.76831987697039594, 1.0) -(0.56627450980392158, 0.83251057285659358, 0.76376778162245285, 1.0) -(0.55999999999999994, 0.82980392156862748, 0.75921568627450975, 1.0) -(0.55372549019607842, 0.82709727028066127, 0.75466359092656665, 1.0) -(0.54745098039215689, 0.82439061899269506, 0.75011149557862355, 1.0) -(0.54117647058823526, 0.82168396770472896, 0.74555940023068046, 1.0) -(0.53490196078431385, 0.81897731641676286, 0.74100730488273747, 1.0) -(0.5286274509803921, 0.81627066512879665, 0.73645520953479426, 1.0) -(0.52235294117647058, 0.81356401384083044, 0.73190311418685117, 1.0) -(0.51607843137254905, 0.81085736255286422, 0.72735101883890807, 1.0) -(0.50980392156862742, 0.80815071126489813, 0.72279892349096497, 1.0) -(0.50352941176470589, 0.80544405997693191, 0.71824682814302188, 1.0) -(0.49725490196078431, 0.80273740868896581, 0.71369473279507889, 1.0) -(0.49098039215686273, 0.8000307574009996, 0.70914263744713568, 1.0) -(0.48470588235294126, 0.7973241061130335, 0.7045905420991927, 1.0) -(0.47843137254901963, 0.79461745482506729, 0.70003844675124949, 1.0) -(0.47215686274509805, 0.79191080353710108, 0.6954863514033065, 1.0) -(0.46588235294117653, 0.78920415224913487, 0.69093425605536329, 1.0) -(0.45960784313725489, 0.78649750096116877, 0.68638216070742031, 1.0) -(0.45333333333333337, 0.78379084967320256, 0.6818300653594771, 1.0) -(0.44705882352941179, 0.78108419838523646, 0.67727797001153411, 1.0) -(0.44078431372549021, 0.77837754709727025, 0.67272587466359091, 1.0) -(0.43450980392156874, 0.77567089580930415, 0.66817377931564792, 1.0) -(0.42823529411764705, 0.77296424452133794, 0.66362168396770471, 1.0) -(0.42196078431372552, 0.77025759323337173, 0.65906958861976173, 1.0) -(0.41568627450980394, 0.76755094194540563, 0.65451749327181852, 1.0) -(0.40941176470588236, 0.76484429065743942, 0.64996539792387553, 1.0) -(0.40313725490196084, 0.76213763936947321, 0.64541330257593232, 1.0) -(0.39772395232602847, 0.75955401768550557, 0.64030757400999616, 1.0) -(0.39317185697808538, 0.75709342560553627, 0.63464821222606693, 1.0) -(0.38861976163014228, 0.75463283352556709, 0.6289888504421377, 1.0) -(0.38406766628219918, 0.7521722414455978, 0.62332948865820847, 1.0) -(0.3795155709342562, 0.74971164936562862, 0.61767012687427936, 1.0) -(0.37496347558631299, 0.74725105728565933, 0.61201076509034991, 1.0) -(0.37041138023836989, 0.74479046520569014, 0.60635140330642068, 1.0) -(0.36585928489042679, 0.74232987312572085, 0.60069204152249145, 1.0) -(0.36130718954248364, 0.73986928104575156, 0.59503267973856211, 1.0) -(0.35675509419454055, 0.73740868896578238, 0.58937331795463288, 1.0) -(0.35220299884659745, 0.73494809688581308, 0.58371395617070365, 1.0) -(0.34765090349865435, 0.7324875048058439, 0.57805459438677431, 1.0) -(0.34309880815071125, 0.73002691272587461, 0.57239523260284508, 1.0) -(0.33854671280276816, 0.72756632064590543, 0.56673587081891585, 1.0) -(0.33399461745482506, 0.72510572856593614, 0.56107650903498663, 1.0) -(0.32944252210688196, 0.72264513648596695, 0.55541714725105729, 1.0) -(0.32489042675893887, 0.72018454440599766, 0.54975778546712806, 1.0) -(0.32033833141099577, 0.71772395232602848, 0.54409842368319883, 1.0) -(0.31578623606305267, 0.71526336024605919, 0.53843906189926949, 1.0) -(0.31123414071510958, 0.71280276816609001, 0.53277970011534026, 1.0) -(0.30668204536716659, 0.71034217608612082, 0.52712033833141114, 1.0) -(0.30212995001922338, 0.70788158400615142, 0.5214609765474818, 1.0) -(0.29757785467128028, 0.70542099192618224, 0.51580161476355246, 1.0) -(0.29302575932333719, 0.70296039984621295, 0.51014225297962323, 1.0) -(0.28847366397539409, 0.70049980776624376, 0.50448289119569401, 1.0) -(0.28392156862745099, 0.69803921568627447, 0.49882352941176472, 1.0) -(0.2793694732795079, 0.69557862360630529, 0.49316416762783544, 1.0) -(0.2748173779315648, 0.693118031526336, 0.48750480584390621, 1.0) -(0.2702652825836217, 0.69065743944636682, 0.48184544405997698, 1.0) -(0.26571318723567861, 0.68819684736639752, 0.4761860822760477, 1.0) -(0.26116109188773545, 0.68573625528642834, 0.47052672049211841, 1.0) -(0.25660899653979236, 0.68327566320645905, 0.46486735870818918, 1.0) -(0.25259515570934254, 0.67966166858900423, 0.45897731641676281, 1.0) -(0.24890426758938869, 0.67535563244905805, 0.45294886582083815, 1.0) -(0.24521337946943481, 0.67104959630911187, 0.44692041522491349, 1.0) -(0.24152249134948095, 0.66674356016916569, 0.44089196462898889, 1.0) -(0.23783160322952721, 0.66243752402921963, 0.43486351403306439, 1.0) -(0.23414071510957324, 0.65813148788927334, 0.42883506343713956, 1.0) -(0.23044982698961936, 0.65382545174932716, 0.4228066128412149, 1.0) -(0.2267589388696655, 0.64951941560938098, 0.4167781622452903, 1.0) -(0.22306805074971164, 0.6452133794694348, 0.41074971164936563, 1.0) -(0.21937716262975779, 0.64090734332948862, 0.40472126105344097, 1.0) -(0.21568627450980393, 0.63660130718954244, 0.39869281045751637, 1.0) -(0.21199538638985005, 0.63229527104959626, 0.39266435986159171, 1.0) -(0.20830449826989619, 0.62798923490965008, 0.38663590926566704, 1.0) -(0.20461361014994234, 0.62368319876970391, 0.38060745866974244, 1.0) -(0.20092272202998845, 0.61937716262975773, 0.37457900807381778, 1.0) -(0.1972318339100346, 0.61507112648981166, 0.36855055747789311, 1.0) -(0.19354094579008074, 0.61076509034986537, 0.36252210688196845, 1.0) -(0.18985005767012686, 0.60645905420991919, 0.35649365628604379, 1.0) -(0.186159169550173, 0.60215301806997301, 0.35046520569011919, 1.0) -(0.18246828143021915, 0.59784698193002694, 0.34443675509419452, 1.0) -(0.17877739331026538, 0.59354094579008088, 0.33840830449827008, 1.0) -(0.17508650519031144, 0.58923490965013459, 0.33237985390234526, 1.0) -(0.17139561707035755, 0.5849288735101883, 0.3263514033064206, 1.0) -(0.1677047289504037, 0.58062283737024223, 0.32032295271049593, 1.0) -(0.16401384083044984, 0.57631680123029605, 0.31429450211457133, 1.0) -(0.16032295271049596, 0.57201076509034987, 0.30826605151864667, 1.0) -(0.1566320645905421, 0.56770472895040369, 0.30223760092272201, 1.0) -(0.15294117647058825, 0.56339869281045751, 0.2962091503267974, 1.0) -(0.14925028835063436, 0.55909265667051133, 0.29018069973087268, 1.0) -(0.14555940023068051, 0.55478662053056516, 0.28415224913494808, 1.0) -(0.14186851211072665, 0.55048058439061898, 0.27812379853902347, 1.0) -(0.13817762399077277, 0.5461745482506728, 0.27209534794309875, 1.0) -(0.13402537485582469, 0.54232987312572078, 0.26828143021914647, 1.0) -(0.12971933871587851, 0.53863898500576701, 0.26520569011918493, 1.0) -(0.12541330257593233, 0.53494809688581313, 0.26212995001922335, 1.0) -(0.12110726643598617, 0.53125720876585925, 0.25905420991926181, 1.0) -(0.11680123029604011, 0.52756632064590547, 0.25597846981930034, 1.0) -(0.11249519415609383, 0.52387543252595148, 0.25290272971933869, 1.0) -(0.10818915801614765, 0.5201845444059976, 0.24982698961937716, 1.0) -(0.10388312187620147, 0.51649365628604382, 0.2467512495194156, 1.0) -(0.099577085736255289, 0.51280276816608994, 0.24367550941945404, 1.0) -(0.09527104959630911, 0.50911188004613606, 0.24059976931949248, 1.0) -(0.090965013456362945, 0.50542099192618217, 0.23752402921953092, 1.0) -(0.086658977316416766, 0.50173010380622829, 0.23444828911956939, 1.0) -(0.082352941176470601, 0.49803921568627446, 0.23137254901960783, 1.0) -(0.078046905036524422, 0.49434832756632063, 0.22829680891964627, 1.0) -(0.073740868896578243, 0.49065743944636675, 0.22522106881968473, 1.0) -(0.069434832756632064, 0.48696655132641287, 0.22214532871972317, 1.0) -(0.065128796616685899, 0.48327566320645904, 0.21906958861976161, 1.0) -(0.060822760476739721, 0.47958477508650516, 0.21599384851980008, 1.0) -(0.056516724336793542, 0.47589388696655127, 0.21291810841983852, 1.0) -(0.052210688196847363, 0.47220299884659744, 0.20984236831987696, 1.0) -(0.047904652056901309, 0.46851211072664367, 0.20676662821991548, 1.0) -(0.043598615916955019, 0.46482122260668968, 0.20369088811995384, 1.0) -(0.03929257977700884, 0.46113033448673585, 0.20061514801999231, 1.0) -(0.034986543637062675, 0.45743944636678197, 0.19753940792003075, 1.0) -(0.030680507497116496, 0.45374855824682814, 0.19446366782006919, 1.0) -(0.026374471357170318, 0.45005767012687425, 0.19138792772010765, 1.0) -(0.022068435217224139, 0.44636678200692037, 0.18831218762014609, 1.0) -(0.017762399077277974, 0.44267589388696654, 0.18523644752018453, 1.0) -(0.013456362937331795, 0.43898500576701266, 0.182160707420223, 1.0) -(0.0091503267973856162, 0.43529411764705883, 0.17908496732026141, 1.0) -(0.0048442906574394373, 0.43160322952710495, 0.17600922722029988, 1.0) -(0.00053825451749325848, 0.42791234140715106, 0.17293348712033835, 1.0) -(0.0, 0.42303729334871204, 0.170718954248366, 1.0) -(0.0, 0.41799307958477505, 0.16862745098039217, 1.0) -(0.0, 0.41294886582083812, 0.16653594771241831, 1.0) -(0.0, 0.40790465205690118, 0.16444444444444445, 1.0) -(0.0, 0.40286043829296436, 0.16235294117647064, 1.0) -(0.0, 0.39781622452902726, 0.16026143790849673, 1.0) -(0.0, 0.39277201076509033, 0.15816993464052287, 1.0) -(0.0, 0.3877277970011534, 0.15607843137254901, 1.0) -(0.0, 0.38268358323721646, 0.15398692810457515, 1.0) -(0.0, 0.37763936947327947, 0.15189542483660129, 1.0) -(0.0, 0.37259515570934254, 0.14980392156862746, 1.0) -(0.0, 0.36755094194540561, 0.1477124183006536, 1.0) -(0.0, 0.36250672818146867, 0.14562091503267974, 1.0) -(0.0, 0.35746251441753168, 0.14352941176470588, 1.0) -(0.0, 0.35241830065359475, 0.14143790849673202, 1.0) -(0.0, 0.34737408688965782, 0.13934640522875816, 1.0) -(0.0, 0.34232987312572088, 0.13725490196078433, 1.0) -(0.0, 0.3372856593617839, 0.13516339869281047, 1.0) -(0.0, 0.33224144559784696, 0.13307189542483661, 1.0) -(0.0, 0.32719723183391003, 0.13098039215686275, 1.0) -(0.0, 0.32215301806997321, 0.12888888888888894, 1.0) -(0.0, 0.31710880430603616, 0.12679738562091503, 1.0) -(0.0, 0.31206459054209917, 0.12470588235294117, 1.0) -(0.0, 0.30702037677816224, 0.12261437908496732, 1.0) -(0.0, 0.30197616301422525, 0.12052287581699346, 1.0) -(0.0, 0.29693194925028832, 0.11843137254901961, 1.0) -(0.0, 0.29188773548635139, 0.11633986928104575, 1.0) -(0.0, 0.28684352172241445, 0.11424836601307189, 1.0) -(0.0, 0.28179930795847752, 0.11215686274509803, 1.0) -(0.0, 0.27675509419454059, 0.11006535947712418, 1.0) -(0.0, 0.2717108804306036, 0.10797385620915033, 1.0) -(0.0, 0.26666666666666666, 0.10588235294117647, 1.0) diff --git a/extern/tfn/colormaps/sequential/BuPu.cpp b/extern/tfn/colormaps/sequential/BuPu.cpp deleted file mode 100644 index 166a002..0000000 --- a/extern/tfn/colormaps/sequential/BuPu.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential_BuPu; -} -const std::vector colormap::data_sequential_BuPu = /* NOLINT(cert-err58-cpp) */ -{ -{0.96862745098039216f, 0.9882352941176471f, 0.99215686274509807f, 1.0f}, -{0.96579777008842749f, 0.98626682045367176f, 0.99104959630911194f, 1.0f}, -{0.96296808919646293f, 0.9842983467896963f, 0.9899423298731258f, 1.0f}, -{0.96013840830449826f, 0.98232987312572095f, 0.98883506343713956f, 1.0f}, -{0.95730872741253359f, 0.9803613994617455f, 0.98772779700115343f, 1.0f}, -{0.95447904652056903f, 0.97839292579777015f, 0.9866205305651673f, 1.0f}, -{0.95164936562860436f, 0.9764244521337947f, 0.98551326412918117f, 1.0f}, -{0.9488196847366398f, 0.97445597846981935f, 0.98440599769319492f, 1.0f}, -{0.94599000384467513f, 0.97248750480584389f, 0.98329873125720879f, 1.0f}, -{0.94316032295271046f, 0.97051903114186855f, 0.98219146482122266f, 1.0f}, -{0.9403306420607459f, 0.9685505574778932f, 0.98108419838523653f, 1.0f}, -{0.93750096116878123f, 0.96658208381391775f, 0.97997693194925029f, 1.0f}, -{0.93467128027681656f, 0.9646136101499424f, 0.97886966551326415f, 1.0f}, -{0.931841599384852f, 0.96264513648596695f, 0.97776239907727802f, 1.0f}, -{0.92901191849288733f, 0.9606766628219916f, 0.97665513264129189f, 1.0f}, -{0.92618223760092278f, 0.95870818915801614f, 0.97554786620530565f, 1.0f}, -{0.92335255670895811f, 0.9567397154940408f, 0.97444059976931952f, 1.0f}, -{0.92052287581699344f, 0.95477124183006545f, 0.97333333333333338f, 1.0f}, -{0.91769319492502888f, 0.95280276816609f, 0.97222606689734725f, 1.0f}, -{0.91486351403306421f, 0.95083429450211465f, 0.97111880046136101f, 1.0f}, -{0.91203383314109954f, 0.9488658208381392f, 0.97001153402537488f, 1.0f}, -{0.90920415224913498f, 0.94689734717416385f, 0.96890426758938875f, 1.0f}, -{0.90637447135717031f, 0.94492887351018839f, 0.96779700115340261f, 1.0f}, -{0.90354479046520564f, 0.94296039984621305f, 0.96668973471741637f, 1.0f}, -{0.90071510957324108f, 0.94099192618223759f, 0.96558246828143024f, 1.0f}, -{0.89788542868127641f, 0.93902345251826225f, 0.96447520184544411f, 1.0f}, -{0.89505574778931174f, 0.9370549788542869f, 0.96336793540945798f, 1.0f}, -{0.89222606689734718f, 0.93508650519031145f, 0.96226066897347173f, 1.0f}, -{0.88939638600538251f, 0.9331180315263361f, 0.9611534025374856f, 1.0f}, -{0.88656670511341795f, 0.93114955786236064f, 0.96004613610149947f, 1.0f}, -{0.88373702422145328f, 0.9291810841983853f, 0.95893886966551334f, 1.0f}, -{0.88090734332948861f, 0.92721261053440984f, 0.9578316032295271f, 1.0f}, -{0.87792387543252592f, 0.9251057285659362f, 0.9566474432910419f, 1.0f}, -{0.87386389850057666f, 0.92202998846597473f, 0.95492502883506347f, 1.0f}, -{0.8698039215686274f, 0.91895424836601314f, 0.95320261437908504f, 1.0f}, -{0.86574394463667814f, 0.91587850826605155f, 0.95148019992310651f, 1.0f}, -{0.86168396770472899f, 0.91280276816608996f, 0.94975778546712808f, 1.0f}, -{0.85762399077277973f, 0.90972702806612848f, 0.94803537101114965f, 1.0f}, -{0.85356401384083047f, 0.9066512879661669f, 0.94631295655517111f, 1.0f}, -{0.84950403690888121f, 0.90357554786620531f, 0.94459054209919269f, 1.0f}, -{0.84544405997693195f, 0.90049980776624372f, 0.94286812764321415f, 1.0f}, -{0.84138408304498269f, 0.89742406766628224f, 0.94114571318723572f, 1.0f}, -{0.83732410611303343f, 0.89434832756632066f, 0.93942329873125729f, 1.0f}, -{0.83326412918108417f, 0.89127258746635907f, 0.93770088427527876f, 1.0f}, -{0.82920415224913491f, 0.88819684736639759f, 0.93597846981930033f, 1.0f}, -{0.82514417531718576f, 0.885121107266436f, 0.93425605536332179f, 1.0f}, -{0.8210841983852365f, 0.88204536716647441f, 0.93253364090734336f, 1.0f}, -{0.81702422145328724f, 0.87896962706651283f, 0.93081122645136494f, 1.0f}, -{0.81296424452133798f, 0.87589388696655135f, 0.9290888119953864f, 1.0f}, -{0.80890426758938871f, 0.87281814686658976f, 0.92736639753940797f, 1.0f}, -{0.80484429065743945f, 0.86974240676662817f, 0.92564398308342943f, 1.0f}, -{0.80078431372549019f, 0.8666666666666667f, 0.92392156862745101f, 1.0f}, -{0.79672433679354093f, 0.86359092656670511f, 0.92219915417147258f, 1.0f}, -{0.79266435986159167f, 0.86051518646674352f, 0.92047673971549404f, 1.0f}, -{0.78860438292964241f, 0.85743944636678204f, 0.91875432525951561f, 1.0f}, -{0.78454440599769315f, 0.85436370626682046f, 0.91703191080353708f, 1.0f}, -{0.780484429065744f, 0.85128796616685887f, 0.91530949634755865f, 1.0f}, -{0.77642445213379474f, 0.84821222606689739f, 0.91358708189158022f, 1.0f}, -{0.77236447520184548f, 0.8451364859669358f, 0.91186466743560168f, 1.0f}, -{0.76830449826989622f, 0.84206074586697421f, 0.91014225297962326f, 1.0f}, -{0.76424452133794696f, 0.83898500576701263f, 0.90841983852364483f, 1.0f}, -{0.7601845444059977f, 0.83590926566705115f, 0.90669742406766629f, 1.0f}, -{0.75612456747404844f, 0.83283352556708956f, 0.90497500961168786f, 1.0f}, -{0.75206459054209918f, 0.82975778546712797f, 0.90325259515570933f, 1.0f}, -{0.74800461361014992f, 0.82674356016916561f, 0.90159169550173013f, 1.0f}, -{0.74394463667820065f, 0.82391387927720106f, 0.90011534025374862f, 1.0f}, -{0.73988465974625151f, 0.82108419838523639f, 0.898638985005767f, 1.0f}, -{0.73582468281430224f, 0.81825451749327183f, 0.89716262975778549f, 1.0f}, -{0.73176470588235298f, 0.81542483660130716f, 0.89568627450980398f, 1.0f}, -{0.72770472895040372f, 0.81259515570934249f, 0.89420991926182236f, 1.0f}, -{0.72364475201845446f, 0.80976547481737793f, 0.89273356401384085f, 1.0f}, -{0.7195847750865052f, 0.80693579392541326f, 0.89125720876585923f, 1.0f}, -{0.71552479815455594f, 0.80410611303344859f, 0.88978085351787772f, 1.0f}, -{0.71146482122260668f, 0.80127643214148403f, 0.88830449826989621f, 1.0f}, -{0.70740484429065753f, 0.79844675124951947f, 0.88682814302191471f, 1.0f}, -{0.70334486735870816f, 0.7956170703575548f, 0.88535178777393309f, 1.0f}, -{0.6992848904267589f, 0.79278738946559013f, 0.88387543252595158f, 1.0f}, -{0.69522491349480964f, 0.78995770857362557f, 0.88239907727796996f, 1.0f}, -{0.69116493656286049f, 0.7871280276816609f, 0.88092272202998845f, 1.0f}, -{0.68710495963091123f, 0.78429834678969623f, 0.87944636678200694f, 1.0f}, -{0.68304498269896197f, 0.78146866589773167f, 0.87797001153402532f, 1.0f}, -{0.67898500576701271f, 0.778638985005767f, 0.87649365628604381f, 1.0f}, -{0.67492502883506356f, 0.77580930411380244f, 0.8750173010380623f, 1.0f}, -{0.67086505190311418f, 0.77297962322183777f, 0.87354094579008068f, 1.0f}, -{0.66680507497116492f, 0.77014994232987311f, 0.87206459054209917f, 1.0f}, -{0.66274509803921566f, 0.76732026143790855f, 0.87058823529411766f, 1.0f}, -{0.6586851211072664f, 0.76449058054594388f, 0.86911188004613604f, 1.0f}, -{0.65462514417531725f, 0.76166089965397932f, 0.86763552479815453f, 1.0f}, -{0.65056516724336799f, 0.75883121876201465f, 0.86615916955017302f, 1.0f}, -{0.64650519031141873f, 0.75600153787004998f, 0.8646828143021914f, 1.0f}, -{0.64244521337946947f, 0.75317185697808542f, 0.8632064590542099f, 1.0f}, -{0.63838523644752021f, 0.75034217608612075f, 0.86173010380622839f, 1.0f}, -{0.63432525951557095f, 0.74751249519415608f, 0.86025374855824677f, 1.0f}, -{0.63026528258362169f, 0.74468281430219152f, 0.85877739331026526f, 1.0f}, -{0.62620530565167243f, 0.74185313341022685f, 0.85730103806228375f, 1.0f}, -{0.62214532871972317f, 0.73902345251826229f, 0.85582468281430213f, 1.0f}, -{0.61877739331026527f, 0.73550173010380626f, 0.85397923875432524f, 1.0f}, -{0.616562860438293f, 0.73082660515186471f, 0.85151864667435595f, 1.0f}, -{0.61434832756632074f, 0.72615148019992326f, 0.84905805459438677f, 1.0f}, -{0.61213379469434837f, 0.72147635524798159f, 0.84659746251441748f, 1.0f}, -{0.60991926182237599f, 0.71680123029604004f, 0.84413687043444829f, 1.0f}, -{0.60770472895040373f, 0.71212610534409848f, 0.841676278354479f, 1.0f}, -{0.60549019607843135f, 0.70745098039215693f, 0.83921568627450982f, 1.0f}, -{0.60327566320645909f, 0.70277585544021537f, 0.83675509419454053f, 1.0f}, -{0.60106113033448672f, 0.69810073048827381f, 0.83429450211457135f, 1.0f}, -{0.59884659746251445f, 0.69342560553633226f, 0.83183391003460205f, 1.0f}, -{0.59663206459054219f, 0.6887504805843907f, 0.82937331795463287f, 1.0f}, -{0.59441753171856981f, 0.68407535563244914f, 0.82691272587466358f, 1.0f}, -{0.59220299884659744f, 0.67940023068050759f, 0.82445213379469429f, 1.0f}, -{0.58998846597462518f, 0.67472510572856592f, 0.8219915417147251f, 1.0f}, -{0.5877739331026528f, 0.67004998077662437f, 0.81953094963475581f, 1.0f}, -{0.58555940023068054f, 0.66537485582468281f, 0.81707035755478663f, 1.0f}, -{0.58334486735870827f, 0.66069973087274125f, 0.81460976547481734f, 1.0f}, -{0.5811303344867359f, 0.6560246059207997f, 0.81214917339484816f, 1.0f}, -{0.57891580161476364f, 0.65134948096885825f, 0.80968858131487897f, 1.0f}, -{0.57670126874279126f, 0.64667435601691658f, 0.80722798923490968f, 1.0f}, -{0.574486735870819f, 0.64199923106497503f, 0.80476739715494039f, 1.0f}, -{0.57227220299884662f, 0.63732410611303347f, 0.80230680507497121f, 1.0f}, -{0.57005767012687436f, 0.63264898116109192f, 0.79984621299500192f, 1.0f}, -{0.56784313725490199f, 0.62797385620915036f, 0.79738562091503273f, 1.0f}, -{0.56562860438292972f, 0.6232987312572088f, 0.79492502883506344f, 1.0f}, -{0.56341407151095735f, 0.61862360630526725f, 0.79246443675509415f, 1.0f}, -{0.56119953863898508f, 0.6139484813533258f, 0.79000384467512497f, 1.0f}, -{0.55898500576701271f, 0.60927335640138414f, 0.78754325259515578f, 1.0f}, -{0.55677047289504045f, 0.60459823144944258f, 0.78508266051518649f, 1.0f}, -{0.55455594002306807f, 0.59992310649750102f, 0.7826220684352172f, 1.0f}, -{0.55234140715109581f, 0.59524798154555947f, 0.78016147635524802f, 1.0f}, -{0.55012687427912343f, 0.59057285659361791f, 0.77770088427527873f, 1.0f}, -{0.5490196078431373f, 0.5855901576316801f, 0.77517877739331031f, 1.0f}, -{0.5490196078431373f, 0.58029988465974625f, 0.77259515570934256f, 1.0f}, -{0.5490196078431373f, 0.57500961168781239f, 0.77001153402537492f, 1.0f}, -{0.5490196078431373f, 0.56971933871587854f, 0.76742791234140717f, 1.0f}, -{0.5490196078431373f, 0.5644290657439448f, 0.76484429065743953f, 1.0f}, -{0.5490196078431373f, 0.55913879277201084f, 0.76226066897347178f, 1.0f}, -{0.5490196078431373f, 0.55384851980007688f, 0.75967704728950403f, 1.0f}, -{0.5490196078431373f, 0.54855824682814303f, 0.75709342560553639f, 1.0f}, -{0.5490196078431373f, 0.54326797385620917f, 0.75450980392156863f, 1.0f}, -{0.5490196078431373f, 0.53797770088427532f, 0.75192618223760088f, 1.0f}, -{0.5490196078431373f, 0.53268742791234147f, 0.74934256055363324f, 1.0f}, -{0.5490196078431373f, 0.52739715494040751f, 0.74675893886966549f, 1.0f}, -{0.5490196078431373f, 0.52210688196847366f, 0.74417531718569785f, 1.0f}, -{0.5490196078431373f, 0.51681660899653981f, 0.7415916955017301f, 1.0f}, -{0.5490196078431373f, 0.51152633602460595f, 0.73900807381776246f, 1.0f}, -{0.5490196078431373f, 0.5062360630526721f, 0.7364244521337947f, 1.0f}, -{0.5490196078431373f, 0.50094579008073814f, 0.73384083044982695f, 1.0f}, -{0.5490196078431373f, 0.49565551710880429f, 0.73125720876585931f, 1.0f}, -{0.5490196078431373f, 0.49036524413687044f, 0.72867358708189156f, 1.0f}, -{0.5490196078431373f, 0.48507497116493659f, 0.72608996539792381f, 1.0f}, -{0.5490196078431373f, 0.47978469819300285f, 0.72350634371395628f, 1.0f}, -{0.5490196078431373f, 0.47449442522106883f, 0.72092272202998842f, 1.0f}, -{0.5490196078431373f, 0.46920415224913492f, 0.71833910034602078f, 1.0f}, -{0.5490196078431373f, 0.46391387927720107f, 0.71575547866205302f, 1.0f}, -{0.5490196078431373f, 0.45862360630526722f, 0.71317185697808538f, 1.0f}, -{0.5490196078431373f, 0.45333333333333337f, 0.71058823529411763f, 1.0f}, -{0.5490196078431373f, 0.44804306036139946f, 0.70800461361014988f, 1.0f}, -{0.5490196078431373f, 0.44275278738946555f, 0.70542099192618224f, 1.0f}, -{0.5490196078431373f, 0.4374625144175317f, 0.70283737024221449f, 1.0f}, -{0.5490196078431373f, 0.43217224144559785f, 0.70025374855824685f, 1.0f}, -{0.5490196078431373f, 0.426881968473664f, 0.6976701268742791f, 1.0f}, -{0.5490196078431373f, 0.42159169550173015f, 0.69508650519031145f, 1.0f}, -{0.54871203383314116f, 0.4163783160322953f, 0.69257977700884277f, 1.0f}, -{0.54821991541714732f, 0.41121107266435986f, 0.69011918492887347f, 1.0f}, -{0.54772779700115348f, 0.40604382929642446f, 0.68765859284890429f, 1.0f}, -{0.54723567858515965f, 0.40087658592848907f, 0.685198000768935f, 1.0f}, -{0.54674356016916581f, 0.39570934256055379f, 0.68273740868896582f, 1.0f}, -{0.54625144175317186f, 0.39054209919261823f, 0.68027681660899653f, 1.0f}, -{0.54575932333717803f, 0.38537485582468284f, 0.67781622452902723f, 1.0f}, -{0.54526720492118419f, 0.38020761245674739f, 0.67535563244905805f, 1.0f}, -{0.54477508650519035f, 0.375040369088812f, 0.67289504036908876f, 1.0f}, -{0.54428296808919652f, 0.36987312572087661f, 0.67043444828911958f, 1.0f}, -{0.54379084967320268f, 0.36470588235294116f, 0.66797385620915029f, 1.0f}, -{0.54329873125720884f, 0.35953863898500577f, 0.6655132641291811f, 1.0f}, -{0.5428066128412149f, 0.35437139561707037f, 0.66305267204921181f, 1.0f}, -{0.54231449442522106f, 0.34920415224913492f, 0.66059207996924263f, 1.0f}, -{0.54182237600922722f, 0.34403690888119953f, 0.65813148788927334f, 1.0f}, -{0.54133025759323339f, 0.33886966551326414f, 0.65567089580930416f, 1.0f}, -{0.54083813917723955f, 0.33370242214532869f, 0.65321030372933486f, 1.0f}, -{0.54034602076124572f, 0.3285351787773933f, 0.65074971164936568f, 1.0f}, -{0.53985390234525188f, 0.32336793540945791f, 0.64828911956939639f, 1.0f}, -{0.53936178392925804f, 0.31820069204152246f, 0.6458285274894271f, 1.0f}, -{0.53886966551326421f, 0.31303344867358723f, 0.64336793540945802f, 1.0f}, -{0.53837754709727026f, 0.30786620530565167f, 0.64090734332948862f, 1.0f}, -{0.53788542868127642f, 0.30269896193771628f, 0.63844675124951944f, 1.0f}, -{0.53739331026528259f, 0.29753171856978083f, 0.63598615916955015f, 1.0f}, -{0.53690119184928875f, 0.29236447520184539f, 0.63352556708958097f, 1.0f}, -{0.53640907343329491f, 0.28719723183390999f, 0.63106497500961167f, 1.0f}, -{0.53591695501730108f, 0.2820299884659746f, 0.62860438292964249f, 1.0f}, -{0.53542483660130724f, 0.27686274509803921f, 0.6261437908496732f, 1.0f}, -{0.53493271818531329f, 0.27169550173010382f, 0.62368319876970402f, 1.0f}, -{0.53444059976931946f, 0.26652825836216837f, 0.62122260668973472f, 1.0f}, -{0.53394848135332562f, 0.26136101499423298f, 0.61876201460976554f, 1.0f}, -{0.53345636293733179f, 0.25619377162629753f, 0.61630142252979625f, 1.0f}, -{0.53268742791234136f, 0.25028835063437138f, 0.61264129181084204f, 1.0f}, -{0.53182622068435215f, 0.24413687043444826f, 0.60858131487889278f, 1.0f}, -{0.53096501345636293f, 0.23798539023452517f, 0.60452133794694352f, 1.0f}, -{0.53010380622837372f, 0.23183391003460208f, 0.60046136101499425f, 1.0f}, -{0.52924259900038451f, 0.22568242983467912f, 0.59640138408304511f, 1.0f}, -{0.52838139177239518f, 0.21953094963475586f, 0.59234140715109573f, 1.0f}, -{0.52752018454440597f, 0.21337946943483274f, 0.58828143021914647f, 1.0f}, -{0.52665897731641675f, 0.20722798923490965f, 0.58422145328719721f, 1.0f}, -{0.52579777008842754f, 0.20107650903498653f, 0.58016147635524795f, 1.0f}, -{0.52493656286043833f, 0.19492502883506341f, 0.57610149942329869f, 1.0f}, -{0.524075355632449f, 0.18877354863514031f, 0.57204152249134954f, 1.0f}, -{0.52321414840445979f, 0.18262206843521722f, 0.56798154555940028f, 1.0f}, -{0.52235294117647058f, 0.1764705882352941f, 0.56392156862745102f, 1.0f}, -{0.52149173394848136f, 0.17031910803537101f, 0.55986159169550176f, 1.0f}, -{0.52063052672049215f, 0.16416762783544792f, 0.5558016147635525f, 1.0f}, -{0.51976931949250282f, 0.1580161476355248f, 0.55174163783160324f, 1.0f}, -{0.51890811226451361f, 0.15186466743560167f, 0.54768166089965398f, 1.0f}, -{0.5180469050365244f, 0.14571318723567858f, 0.54362168396770472f, 1.0f}, -{0.51718569780853518f, 0.13956170703575549f, 0.53956170703575546f, 1.0f}, -{0.51632449058054597f, 0.13341022683583237f, 0.53550173010380619f, 1.0f}, -{0.51546328335255676f, 0.12725874663590944f, 0.53144175317185716f, 1.0f}, -{0.51460207612456743f, 0.12110726643598616f, 0.52738177623990778f, 1.0f}, -{0.51374086889657822f, 0.11495578623606306f, 0.52332179930795852f, 1.0f}, -{0.512879661668589f, 0.10880430603613994f, 0.51926182237600926f, 1.0f}, -{0.51201845444059979f, 0.10265282583621685f, 0.51520184544406f, 1.0f}, -{0.51115724721261047f, 0.096501345636293728f, 0.51114186851211074f, 1.0f}, -{0.51029603998462125f, 0.090349865436370635f, 0.50708189158016148f, 1.0f}, -{0.50943483275663204f, 0.084198385236447515f, 0.50302191464821222f, 1.0f}, -{0.50857362552864283f, 0.078046905036524422f, 0.49896193771626296f, 1.0f}, -{0.50771241830065361f, 0.071895424836601302f, 0.4949019607843137f, 1.0f}, -{0.50685121107266429f, 0.065743944636678209f, 0.49084198385236444f, 1.0f}, -{0.50599000384467507f, 0.059592464436755116f, 0.48678200692041518f, 1.0f}, -{0.50028450595924645f, 0.057208765859284895f, 0.48099961553248749f, 1.0f}, -{0.49388696655132641f, 0.055363321799307967f, 0.47497116493656283f, 1.0f}, -{0.48748942714340637f, 0.053517877739331032f, 0.46894271434063822f, 1.0f}, -{0.48109188773548633f, 0.051672433679354098f, 0.46291426374471356f, 1.0f}, -{0.47469434832756646f, 0.049826989619377218f, 0.45688581314878912f, 1.0f}, -{0.46829680891964626f, 0.047981545559400235f, 0.45085736255286429f, 1.0f}, -{0.46189926951172622f, 0.046136101499423307f, 0.44482891195693963f, 1.0f}, -{0.45550173010380623f, 0.044290657439446372f, 0.43880046136101497f, 1.0f}, -{0.4491041906958862f, 0.042445213379469438f, 0.43277201076509036f, 1.0f}, -{0.44270665128796616f, 0.04059976931949251f, 0.4267435601691657f, 1.0f}, -{0.43630911188004612f, 0.038754325259515575f, 0.42071510957324104f, 1.0f}, -{0.42991157247212608f, 0.03690888119953864f, 0.41468665897731638f, 1.0f}, -{0.42351403306420604f, 0.035063437139561712f, 0.40865820838139177f, 1.0f}, -{0.417116493656286f, 0.033217993079584777f, 0.40262975778546711f, 1.0f}, -{0.41071895424836602f, 0.031372549019607843f, 0.39660130718954245f, 1.0f}, -{0.40432141484044598f, 0.029527104959630915f, 0.39057285659361785f, 1.0f}, -{0.39792387543252594f, 0.02768166089965398f, 0.38454440599769318f, 1.0f}, -{0.3915263360246059f, 0.025836216839677052f, 0.37851595540176852f, 1.0f}, -{0.38512879661668586f, 0.023990772779700117f, 0.37248750480584392f, 1.0f}, -{0.37873125720876583f, 0.022145328719723183f, 0.36645905420991925f, 1.0f}, -{0.37233371780084601f, 0.020299884659746303f, 0.36043060361399482f, 1.0f}, -{0.3659361783929258f, 0.01845444059976932f, 0.35440215301806999f, 1.0f}, -{0.35953863898500571f, 0.016608996539792392f, 0.34837370242214533f, 1.0f}, -{0.35314109957708573f, 0.014763552479815457f, 0.34234525182622066f, 1.0f}, -{0.34674356016916569f, 0.012918108419838523f, 0.33631680123029606f, 1.0f}, -{0.34034602076124565f, 0.011072664359861595f, 0.3302883506343714f, 1.0f}, -{0.33394848135332567f, 0.00922722029988466f, 0.32425990003844674f, 1.0f}, -{0.32755094194540557f, 0.0073817762399077252f, 0.31823144944252213f, 1.0f}, -{0.32115340253748559f, 0.0055363321799307974f, 0.31220299884659747f, 1.0f}, -{0.31475586312956549f, 0.0036908881199538626f, 0.30617454825067281f, 1.0f}, -{0.30835832372164551f, 0.0018454440599769348f, 0.3001460976547482f, 1.0f}, -{0.30196078431372547f, 0.0f, 0.29411764705882354f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential/BuPu.txt b/extern/tfn/colormaps/sequential/BuPu.txt deleted file mode 100644 index 0cb3b8f..0000000 --- a/extern/tfn/colormaps/sequential/BuPu.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.96862745098039216, 0.9882352941176471, 0.99215686274509807, 1.0) -(0.96579777008842749, 0.98626682045367176, 0.99104959630911194, 1.0) -(0.96296808919646293, 0.9842983467896963, 0.9899423298731258, 1.0) -(0.96013840830449826, 0.98232987312572095, 0.98883506343713956, 1.0) -(0.95730872741253359, 0.9803613994617455, 0.98772779700115343, 1.0) -(0.95447904652056903, 0.97839292579777015, 0.9866205305651673, 1.0) -(0.95164936562860436, 0.9764244521337947, 0.98551326412918117, 1.0) -(0.9488196847366398, 0.97445597846981935, 0.98440599769319492, 1.0) -(0.94599000384467513, 0.97248750480584389, 0.98329873125720879, 1.0) -(0.94316032295271046, 0.97051903114186855, 0.98219146482122266, 1.0) -(0.9403306420607459, 0.9685505574778932, 0.98108419838523653, 1.0) -(0.93750096116878123, 0.96658208381391775, 0.97997693194925029, 1.0) -(0.93467128027681656, 0.9646136101499424, 0.97886966551326415, 1.0) -(0.931841599384852, 0.96264513648596695, 0.97776239907727802, 1.0) -(0.92901191849288733, 0.9606766628219916, 0.97665513264129189, 1.0) -(0.92618223760092278, 0.95870818915801614, 0.97554786620530565, 1.0) -(0.92335255670895811, 0.9567397154940408, 0.97444059976931952, 1.0) -(0.92052287581699344, 0.95477124183006545, 0.97333333333333338, 1.0) -(0.91769319492502888, 0.95280276816609, 0.97222606689734725, 1.0) -(0.91486351403306421, 0.95083429450211465, 0.97111880046136101, 1.0) -(0.91203383314109954, 0.9488658208381392, 0.97001153402537488, 1.0) -(0.90920415224913498, 0.94689734717416385, 0.96890426758938875, 1.0) -(0.90637447135717031, 0.94492887351018839, 0.96779700115340261, 1.0) -(0.90354479046520564, 0.94296039984621305, 0.96668973471741637, 1.0) -(0.90071510957324108, 0.94099192618223759, 0.96558246828143024, 1.0) -(0.89788542868127641, 0.93902345251826225, 0.96447520184544411, 1.0) -(0.89505574778931174, 0.9370549788542869, 0.96336793540945798, 1.0) -(0.89222606689734718, 0.93508650519031145, 0.96226066897347173, 1.0) -(0.88939638600538251, 0.9331180315263361, 0.9611534025374856, 1.0) -(0.88656670511341795, 0.93114955786236064, 0.96004613610149947, 1.0) -(0.88373702422145328, 0.9291810841983853, 0.95893886966551334, 1.0) -(0.88090734332948861, 0.92721261053440984, 0.9578316032295271, 1.0) -(0.87792387543252592, 0.9251057285659362, 0.9566474432910419, 1.0) -(0.87386389850057666, 0.92202998846597473, 0.95492502883506347, 1.0) -(0.8698039215686274, 0.91895424836601314, 0.95320261437908504, 1.0) -(0.86574394463667814, 0.91587850826605155, 0.95148019992310651, 1.0) -(0.86168396770472899, 0.91280276816608996, 0.94975778546712808, 1.0) -(0.85762399077277973, 0.90972702806612848, 0.94803537101114965, 1.0) -(0.85356401384083047, 0.9066512879661669, 0.94631295655517111, 1.0) -(0.84950403690888121, 0.90357554786620531, 0.94459054209919269, 1.0) -(0.84544405997693195, 0.90049980776624372, 0.94286812764321415, 1.0) -(0.84138408304498269, 0.89742406766628224, 0.94114571318723572, 1.0) -(0.83732410611303343, 0.89434832756632066, 0.93942329873125729, 1.0) -(0.83326412918108417, 0.89127258746635907, 0.93770088427527876, 1.0) -(0.82920415224913491, 0.88819684736639759, 0.93597846981930033, 1.0) -(0.82514417531718576, 0.885121107266436, 0.93425605536332179, 1.0) -(0.8210841983852365, 0.88204536716647441, 0.93253364090734336, 1.0) -(0.81702422145328724, 0.87896962706651283, 0.93081122645136494, 1.0) -(0.81296424452133798, 0.87589388696655135, 0.9290888119953864, 1.0) -(0.80890426758938871, 0.87281814686658976, 0.92736639753940797, 1.0) -(0.80484429065743945, 0.86974240676662817, 0.92564398308342943, 1.0) -(0.80078431372549019, 0.8666666666666667, 0.92392156862745101, 1.0) -(0.79672433679354093, 0.86359092656670511, 0.92219915417147258, 1.0) -(0.79266435986159167, 0.86051518646674352, 0.92047673971549404, 1.0) -(0.78860438292964241, 0.85743944636678204, 0.91875432525951561, 1.0) -(0.78454440599769315, 0.85436370626682046, 0.91703191080353708, 1.0) -(0.780484429065744, 0.85128796616685887, 0.91530949634755865, 1.0) -(0.77642445213379474, 0.84821222606689739, 0.91358708189158022, 1.0) -(0.77236447520184548, 0.8451364859669358, 0.91186466743560168, 1.0) -(0.76830449826989622, 0.84206074586697421, 0.91014225297962326, 1.0) -(0.76424452133794696, 0.83898500576701263, 0.90841983852364483, 1.0) -(0.7601845444059977, 0.83590926566705115, 0.90669742406766629, 1.0) -(0.75612456747404844, 0.83283352556708956, 0.90497500961168786, 1.0) -(0.75206459054209918, 0.82975778546712797, 0.90325259515570933, 1.0) -(0.74800461361014992, 0.82674356016916561, 0.90159169550173013, 1.0) -(0.74394463667820065, 0.82391387927720106, 0.90011534025374862, 1.0) -(0.73988465974625151, 0.82108419838523639, 0.898638985005767, 1.0) -(0.73582468281430224, 0.81825451749327183, 0.89716262975778549, 1.0) -(0.73176470588235298, 0.81542483660130716, 0.89568627450980398, 1.0) -(0.72770472895040372, 0.81259515570934249, 0.89420991926182236, 1.0) -(0.72364475201845446, 0.80976547481737793, 0.89273356401384085, 1.0) -(0.7195847750865052, 0.80693579392541326, 0.89125720876585923, 1.0) -(0.71552479815455594, 0.80410611303344859, 0.88978085351787772, 1.0) -(0.71146482122260668, 0.80127643214148403, 0.88830449826989621, 1.0) -(0.70740484429065753, 0.79844675124951947, 0.88682814302191471, 1.0) -(0.70334486735870816, 0.7956170703575548, 0.88535178777393309, 1.0) -(0.6992848904267589, 0.79278738946559013, 0.88387543252595158, 1.0) -(0.69522491349480964, 0.78995770857362557, 0.88239907727796996, 1.0) -(0.69116493656286049, 0.7871280276816609, 0.88092272202998845, 1.0) -(0.68710495963091123, 0.78429834678969623, 0.87944636678200694, 1.0) -(0.68304498269896197, 0.78146866589773167, 0.87797001153402532, 1.0) -(0.67898500576701271, 0.778638985005767, 0.87649365628604381, 1.0) -(0.67492502883506356, 0.77580930411380244, 0.8750173010380623, 1.0) -(0.67086505190311418, 0.77297962322183777, 0.87354094579008068, 1.0) -(0.66680507497116492, 0.77014994232987311, 0.87206459054209917, 1.0) -(0.66274509803921566, 0.76732026143790855, 0.87058823529411766, 1.0) -(0.6586851211072664, 0.76449058054594388, 0.86911188004613604, 1.0) -(0.65462514417531725, 0.76166089965397932, 0.86763552479815453, 1.0) -(0.65056516724336799, 0.75883121876201465, 0.86615916955017302, 1.0) -(0.64650519031141873, 0.75600153787004998, 0.8646828143021914, 1.0) -(0.64244521337946947, 0.75317185697808542, 0.8632064590542099, 1.0) -(0.63838523644752021, 0.75034217608612075, 0.86173010380622839, 1.0) -(0.63432525951557095, 0.74751249519415608, 0.86025374855824677, 1.0) -(0.63026528258362169, 0.74468281430219152, 0.85877739331026526, 1.0) -(0.62620530565167243, 0.74185313341022685, 0.85730103806228375, 1.0) -(0.62214532871972317, 0.73902345251826229, 0.85582468281430213, 1.0) -(0.61877739331026527, 0.73550173010380626, 0.85397923875432524, 1.0) -(0.616562860438293, 0.73082660515186471, 0.85151864667435595, 1.0) -(0.61434832756632074, 0.72615148019992326, 0.84905805459438677, 1.0) -(0.61213379469434837, 0.72147635524798159, 0.84659746251441748, 1.0) -(0.60991926182237599, 0.71680123029604004, 0.84413687043444829, 1.0) -(0.60770472895040373, 0.71212610534409848, 0.841676278354479, 1.0) -(0.60549019607843135, 0.70745098039215693, 0.83921568627450982, 1.0) -(0.60327566320645909, 0.70277585544021537, 0.83675509419454053, 1.0) -(0.60106113033448672, 0.69810073048827381, 0.83429450211457135, 1.0) -(0.59884659746251445, 0.69342560553633226, 0.83183391003460205, 1.0) -(0.59663206459054219, 0.6887504805843907, 0.82937331795463287, 1.0) -(0.59441753171856981, 0.68407535563244914, 0.82691272587466358, 1.0) -(0.59220299884659744, 0.67940023068050759, 0.82445213379469429, 1.0) -(0.58998846597462518, 0.67472510572856592, 0.8219915417147251, 1.0) -(0.5877739331026528, 0.67004998077662437, 0.81953094963475581, 1.0) -(0.58555940023068054, 0.66537485582468281, 0.81707035755478663, 1.0) -(0.58334486735870827, 0.66069973087274125, 0.81460976547481734, 1.0) -(0.5811303344867359, 0.6560246059207997, 0.81214917339484816, 1.0) -(0.57891580161476364, 0.65134948096885825, 0.80968858131487897, 1.0) -(0.57670126874279126, 0.64667435601691658, 0.80722798923490968, 1.0) -(0.574486735870819, 0.64199923106497503, 0.80476739715494039, 1.0) -(0.57227220299884662, 0.63732410611303347, 0.80230680507497121, 1.0) -(0.57005767012687436, 0.63264898116109192, 0.79984621299500192, 1.0) -(0.56784313725490199, 0.62797385620915036, 0.79738562091503273, 1.0) -(0.56562860438292972, 0.6232987312572088, 0.79492502883506344, 1.0) -(0.56341407151095735, 0.61862360630526725, 0.79246443675509415, 1.0) -(0.56119953863898508, 0.6139484813533258, 0.79000384467512497, 1.0) -(0.55898500576701271, 0.60927335640138414, 0.78754325259515578, 1.0) -(0.55677047289504045, 0.60459823144944258, 0.78508266051518649, 1.0) -(0.55455594002306807, 0.59992310649750102, 0.7826220684352172, 1.0) -(0.55234140715109581, 0.59524798154555947, 0.78016147635524802, 1.0) -(0.55012687427912343, 0.59057285659361791, 0.77770088427527873, 1.0) -(0.5490196078431373, 0.5855901576316801, 0.77517877739331031, 1.0) -(0.5490196078431373, 0.58029988465974625, 0.77259515570934256, 1.0) -(0.5490196078431373, 0.57500961168781239, 0.77001153402537492, 1.0) -(0.5490196078431373, 0.56971933871587854, 0.76742791234140717, 1.0) -(0.5490196078431373, 0.5644290657439448, 0.76484429065743953, 1.0) -(0.5490196078431373, 0.55913879277201084, 0.76226066897347178, 1.0) -(0.5490196078431373, 0.55384851980007688, 0.75967704728950403, 1.0) -(0.5490196078431373, 0.54855824682814303, 0.75709342560553639, 1.0) -(0.5490196078431373, 0.54326797385620917, 0.75450980392156863, 1.0) -(0.5490196078431373, 0.53797770088427532, 0.75192618223760088, 1.0) -(0.5490196078431373, 0.53268742791234147, 0.74934256055363324, 1.0) -(0.5490196078431373, 0.52739715494040751, 0.74675893886966549, 1.0) -(0.5490196078431373, 0.52210688196847366, 0.74417531718569785, 1.0) -(0.5490196078431373, 0.51681660899653981, 0.7415916955017301, 1.0) -(0.5490196078431373, 0.51152633602460595, 0.73900807381776246, 1.0) -(0.5490196078431373, 0.5062360630526721, 0.7364244521337947, 1.0) -(0.5490196078431373, 0.50094579008073814, 0.73384083044982695, 1.0) -(0.5490196078431373, 0.49565551710880429, 0.73125720876585931, 1.0) -(0.5490196078431373, 0.49036524413687044, 0.72867358708189156, 1.0) -(0.5490196078431373, 0.48507497116493659, 0.72608996539792381, 1.0) -(0.5490196078431373, 0.47978469819300285, 0.72350634371395628, 1.0) -(0.5490196078431373, 0.47449442522106883, 0.72092272202998842, 1.0) -(0.5490196078431373, 0.46920415224913492, 0.71833910034602078, 1.0) -(0.5490196078431373, 0.46391387927720107, 0.71575547866205302, 1.0) -(0.5490196078431373, 0.45862360630526722, 0.71317185697808538, 1.0) -(0.5490196078431373, 0.45333333333333337, 0.71058823529411763, 1.0) -(0.5490196078431373, 0.44804306036139946, 0.70800461361014988, 1.0) -(0.5490196078431373, 0.44275278738946555, 0.70542099192618224, 1.0) -(0.5490196078431373, 0.4374625144175317, 0.70283737024221449, 1.0) -(0.5490196078431373, 0.43217224144559785, 0.70025374855824685, 1.0) -(0.5490196078431373, 0.426881968473664, 0.6976701268742791, 1.0) -(0.5490196078431373, 0.42159169550173015, 0.69508650519031145, 1.0) -(0.54871203383314116, 0.4163783160322953, 0.69257977700884277, 1.0) -(0.54821991541714732, 0.41121107266435986, 0.69011918492887347, 1.0) -(0.54772779700115348, 0.40604382929642446, 0.68765859284890429, 1.0) -(0.54723567858515965, 0.40087658592848907, 0.685198000768935, 1.0) -(0.54674356016916581, 0.39570934256055379, 0.68273740868896582, 1.0) -(0.54625144175317186, 0.39054209919261823, 0.68027681660899653, 1.0) -(0.54575932333717803, 0.38537485582468284, 0.67781622452902723, 1.0) -(0.54526720492118419, 0.38020761245674739, 0.67535563244905805, 1.0) -(0.54477508650519035, 0.375040369088812, 0.67289504036908876, 1.0) -(0.54428296808919652, 0.36987312572087661, 0.67043444828911958, 1.0) -(0.54379084967320268, 0.36470588235294116, 0.66797385620915029, 1.0) -(0.54329873125720884, 0.35953863898500577, 0.6655132641291811, 1.0) -(0.5428066128412149, 0.35437139561707037, 0.66305267204921181, 1.0) -(0.54231449442522106, 0.34920415224913492, 0.66059207996924263, 1.0) -(0.54182237600922722, 0.34403690888119953, 0.65813148788927334, 1.0) -(0.54133025759323339, 0.33886966551326414, 0.65567089580930416, 1.0) -(0.54083813917723955, 0.33370242214532869, 0.65321030372933486, 1.0) -(0.54034602076124572, 0.3285351787773933, 0.65074971164936568, 1.0) -(0.53985390234525188, 0.32336793540945791, 0.64828911956939639, 1.0) -(0.53936178392925804, 0.31820069204152246, 0.6458285274894271, 1.0) -(0.53886966551326421, 0.31303344867358723, 0.64336793540945802, 1.0) -(0.53837754709727026, 0.30786620530565167, 0.64090734332948862, 1.0) -(0.53788542868127642, 0.30269896193771628, 0.63844675124951944, 1.0) -(0.53739331026528259, 0.29753171856978083, 0.63598615916955015, 1.0) -(0.53690119184928875, 0.29236447520184539, 0.63352556708958097, 1.0) -(0.53640907343329491, 0.28719723183390999, 0.63106497500961167, 1.0) -(0.53591695501730108, 0.2820299884659746, 0.62860438292964249, 1.0) -(0.53542483660130724, 0.27686274509803921, 0.6261437908496732, 1.0) -(0.53493271818531329, 0.27169550173010382, 0.62368319876970402, 1.0) -(0.53444059976931946, 0.26652825836216837, 0.62122260668973472, 1.0) -(0.53394848135332562, 0.26136101499423298, 0.61876201460976554, 1.0) -(0.53345636293733179, 0.25619377162629753, 0.61630142252979625, 1.0) -(0.53268742791234136, 0.25028835063437138, 0.61264129181084204, 1.0) -(0.53182622068435215, 0.24413687043444826, 0.60858131487889278, 1.0) -(0.53096501345636293, 0.23798539023452517, 0.60452133794694352, 1.0) -(0.53010380622837372, 0.23183391003460208, 0.60046136101499425, 1.0) -(0.52924259900038451, 0.22568242983467912, 0.59640138408304511, 1.0) -(0.52838139177239518, 0.21953094963475586, 0.59234140715109573, 1.0) -(0.52752018454440597, 0.21337946943483274, 0.58828143021914647, 1.0) -(0.52665897731641675, 0.20722798923490965, 0.58422145328719721, 1.0) -(0.52579777008842754, 0.20107650903498653, 0.58016147635524795, 1.0) -(0.52493656286043833, 0.19492502883506341, 0.57610149942329869, 1.0) -(0.524075355632449, 0.18877354863514031, 0.57204152249134954, 1.0) -(0.52321414840445979, 0.18262206843521722, 0.56798154555940028, 1.0) -(0.52235294117647058, 0.1764705882352941, 0.56392156862745102, 1.0) -(0.52149173394848136, 0.17031910803537101, 0.55986159169550176, 1.0) -(0.52063052672049215, 0.16416762783544792, 0.5558016147635525, 1.0) -(0.51976931949250282, 0.1580161476355248, 0.55174163783160324, 1.0) -(0.51890811226451361, 0.15186466743560167, 0.54768166089965398, 1.0) -(0.5180469050365244, 0.14571318723567858, 0.54362168396770472, 1.0) -(0.51718569780853518, 0.13956170703575549, 0.53956170703575546, 1.0) -(0.51632449058054597, 0.13341022683583237, 0.53550173010380619, 1.0) -(0.51546328335255676, 0.12725874663590944, 0.53144175317185716, 1.0) -(0.51460207612456743, 0.12110726643598616, 0.52738177623990778, 1.0) -(0.51374086889657822, 0.11495578623606306, 0.52332179930795852, 1.0) -(0.512879661668589, 0.10880430603613994, 0.51926182237600926, 1.0) -(0.51201845444059979, 0.10265282583621685, 0.51520184544406, 1.0) -(0.51115724721261047, 0.096501345636293728, 0.51114186851211074, 1.0) -(0.51029603998462125, 0.090349865436370635, 0.50708189158016148, 1.0) -(0.50943483275663204, 0.084198385236447515, 0.50302191464821222, 1.0) -(0.50857362552864283, 0.078046905036524422, 0.49896193771626296, 1.0) -(0.50771241830065361, 0.071895424836601302, 0.4949019607843137, 1.0) -(0.50685121107266429, 0.065743944636678209, 0.49084198385236444, 1.0) -(0.50599000384467507, 0.059592464436755116, 0.48678200692041518, 1.0) -(0.50028450595924645, 0.057208765859284895, 0.48099961553248749, 1.0) -(0.49388696655132641, 0.055363321799307967, 0.47497116493656283, 1.0) -(0.48748942714340637, 0.053517877739331032, 0.46894271434063822, 1.0) -(0.48109188773548633, 0.051672433679354098, 0.46291426374471356, 1.0) -(0.47469434832756646, 0.049826989619377218, 0.45688581314878912, 1.0) -(0.46829680891964626, 0.047981545559400235, 0.45085736255286429, 1.0) -(0.46189926951172622, 0.046136101499423307, 0.44482891195693963, 1.0) -(0.45550173010380623, 0.044290657439446372, 0.43880046136101497, 1.0) -(0.4491041906958862, 0.042445213379469438, 0.43277201076509036, 1.0) -(0.44270665128796616, 0.04059976931949251, 0.4267435601691657, 1.0) -(0.43630911188004612, 0.038754325259515575, 0.42071510957324104, 1.0) -(0.42991157247212608, 0.03690888119953864, 0.41468665897731638, 1.0) -(0.42351403306420604, 0.035063437139561712, 0.40865820838139177, 1.0) -(0.417116493656286, 0.033217993079584777, 0.40262975778546711, 1.0) -(0.41071895424836602, 0.031372549019607843, 0.39660130718954245, 1.0) -(0.40432141484044598, 0.029527104959630915, 0.39057285659361785, 1.0) -(0.39792387543252594, 0.02768166089965398, 0.38454440599769318, 1.0) -(0.3915263360246059, 0.025836216839677052, 0.37851595540176852, 1.0) -(0.38512879661668586, 0.023990772779700117, 0.37248750480584392, 1.0) -(0.37873125720876583, 0.022145328719723183, 0.36645905420991925, 1.0) -(0.37233371780084601, 0.020299884659746303, 0.36043060361399482, 1.0) -(0.3659361783929258, 0.01845444059976932, 0.35440215301806999, 1.0) -(0.35953863898500571, 0.016608996539792392, 0.34837370242214533, 1.0) -(0.35314109957708573, 0.014763552479815457, 0.34234525182622066, 1.0) -(0.34674356016916569, 0.012918108419838523, 0.33631680123029606, 1.0) -(0.34034602076124565, 0.011072664359861595, 0.3302883506343714, 1.0) -(0.33394848135332567, 0.00922722029988466, 0.32425990003844674, 1.0) -(0.32755094194540557, 0.0073817762399077252, 0.31823144944252213, 1.0) -(0.32115340253748559, 0.0055363321799307974, 0.31220299884659747, 1.0) -(0.31475586312956549, 0.0036908881199538626, 0.30617454825067281, 1.0) -(0.30835832372164551, 0.0018454440599769348, 0.3001460976547482, 1.0) -(0.30196078431372547, 0.0, 0.29411764705882354, 1.0) diff --git a/extern/tfn/colormaps/sequential/GnBu.cpp b/extern/tfn/colormaps/sequential/GnBu.cpp deleted file mode 100644 index b861045..0000000 --- a/extern/tfn/colormaps/sequential/GnBu.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential_GnBu; -} -const std::vector colormap::data_sequential_GnBu = /* NOLINT(cert-err58-cpp) */ -{ -{0.96862745098039216f, 0.9882352941176471f, 0.94117647058823528f, 1.0f}, -{0.96579777008842749f, 0.98712802768166097f, 0.93859284890426753f, 1.0f}, -{0.96296808919646293f, 0.98602076124567473f, 0.93600922722029989f, 1.0f}, -{0.96013840830449826f, 0.98491349480968859f, 0.93342560553633214f, 1.0f}, -{0.95730872741253359f, 0.98380622837370246f, 0.9308419838523645f, 1.0f}, -{0.95447904652056903f, 0.98269896193771633f, 0.92825836216839674f, 1.0f}, -{0.95164936562860436f, 0.98159169550173009f, 0.92567474048442899f, 1.0f}, -{0.9488196847366398f, 0.98048442906574396f, 0.92309111880046135f, 1.0f}, -{0.94599000384467513f, 0.97937716262975782f, 0.9205074971164936f, 1.0f}, -{0.94316032295271046f, 0.97826989619377169f, 0.91792387543252596f, 1.0f}, -{0.9403306420607459f, 0.97716262975778545f, 0.91534025374855821f, 1.0f}, -{0.93750096116878123f, 0.97605536332179932f, 0.91275663206459057f, 1.0f}, -{0.93467128027681656f, 0.97494809688581319f, 0.91017301038062282f, 1.0f}, -{0.931841599384852f, 0.97384083044982694f, 0.90758938869665506f, 1.0f}, -{0.92901191849288733f, 0.97273356401384081f, 0.90500576701268742f, 1.0f}, -{0.92618223760092278f, 0.97162629757785468f, 0.90242214532871967f, 1.0f}, -{0.92335255670895811f, 0.97051903114186855f, 0.89983852364475203f, 1.0f}, -{0.92052287581699344f, 0.96941176470588231f, 0.89725490196078428f, 1.0f}, -{0.91769319492502888f, 0.96830449826989617f, 0.89467128027681653f, 1.0f}, -{0.91486351403306421f, 0.96719723183391004f, 0.89208765859284889f, 1.0f}, -{0.91203383314109954f, 0.9660899653979238f, 0.88950403690888113f, 1.0f}, -{0.90920415224913498f, 0.96498269896193767f, 0.88692041522491349f, 1.0f}, -{0.90637447135717031f, 0.96387543252595154f, 0.88433679354094574f, 1.0f}, -{0.90354479046520564f, 0.9627681660899654f, 0.88175317185697799f, 1.0f}, -{0.90071510957324108f, 0.96166089965397916f, 0.87916955017301035f, 1.0f}, -{0.89788542868127641f, 0.96055363321799303f, 0.8765859284890426f, 1.0f}, -{0.89505574778931174f, 0.9594463667820069f, 0.87400230680507496f, 1.0f}, -{0.89222606689734718f, 0.95833910034602077f, 0.87141868512110721f, 1.0f}, -{0.88939638600538251f, 0.95723183391003452f, 0.86883506343713957f, 1.0f}, -{0.88656670511341795f, 0.95612456747404839f, 0.86625144175317181f, 1.0f}, -{0.88373702422145328f, 0.95501730103806226f, 0.86366782006920406f, 1.0f}, -{0.88090734332948861f, 0.95391003460207613f, 0.86108419838523642f, 1.0f}, -{0.87812379853902345f, 0.95281814686658972f, 0.85848519800076883f, 1.0f}, -{0.87566320645905427f, 0.95183391003460205f, 0.85577854671280273f, 1.0f}, -{0.87320261437908497f, 0.95084967320261438f, 0.85307189542483652f, 1.0f}, -{0.87074202229911568f, 0.94986543637062659f, 0.85036524413687042f, 1.0f}, -{0.8682814302191465f, 0.94888119953863892f, 0.84765859284890421f, 1.0f}, -{0.86582083813917721f, 0.94789696270665125f, 0.84495194156093811f, 1.0f}, -{0.86336024605920803f, 0.94691272587466357f, 0.8422452902729719f, 1.0f}, -{0.86089965397923873f, 0.94592848904267579f, 0.83953863898500569f, 1.0f}, -{0.85843906189926955f, 0.94494425221068812f, 0.83683198769703959f, 1.0f}, -{0.85597846981930026f, 0.94396001537870045f, 0.83412533640907338f, 1.0f}, -{0.85351787773933108f, 0.94297577854671277f, 0.83141868512110728f, 1.0f}, -{0.85105728565936178f, 0.9419915417147251f, 0.82871203383314107f, 1.0f}, -{0.8485966935793926f, 0.94100730488273732f, 0.82600538254517497f, 1.0f}, -{0.84613610149942331f, 0.94002306805074964f, 0.82329873125720876f, 1.0f}, -{0.84367550941945413f, 0.93903883121876197f, 0.82059207996924255f, 1.0f}, -{0.84121491733948484f, 0.9380545943867743f, 0.81788542868127645f, 1.0f}, -{0.83875432525951554f, 0.93707035755478651f, 0.81517877739331024f, 1.0f}, -{0.83629373317954636f, 0.93608612072279884f, 0.81247212610534414f, 1.0f}, -{0.83383314109957707f, 0.93510188389081117f, 0.80976547481737793f, 1.0f}, -{0.83137254901960789f, 0.9341176470588235f, 0.80705882352941172f, 1.0f}, -{0.82891195693963859f, 0.93313341022683582f, 0.80435217224144562f, 1.0f}, -{0.82645136485966941f, 0.93214917339484804f, 0.80164552095347941f, 1.0f}, -{0.82399077277970012f, 0.93116493656286037f, 0.79893886966551331f, 1.0f}, -{0.82153018069973094f, 0.9301806997308727f, 0.7962322183775471f, 1.0f}, -{0.81906958861976165f, 0.92919646289888502f, 0.79352556708958089f, 1.0f}, -{0.81660899653979246f, 0.92821222606689735f, 0.79081891580161479f, 1.0f}, -{0.81414840445982317f, 0.92722798923490957f, 0.78811226451364857f, 1.0f}, -{0.81168781237985388f, 0.92624375240292189f, 0.78540561322568248f, 1.0f}, -{0.8092272202998847f, 0.92525951557093422f, 0.78269896193771626f, 1.0f}, -{0.80676662821991552f, 0.92427527873894655f, 0.77999231064975016f, 1.0f}, -{0.80430603613994622f, 0.92329104190695876f, 0.77728565936178395f, 1.0f}, -{0.80184544405997693f, 0.92230680507497109f, 0.77457900807381774f, 1.0f}, -{0.79889273356401391f, 0.92113802383698573f, 0.77205690119184933f, 1.0f}, -{0.79446366782006927f, 0.9194156093810073f, 0.77008842752787388f, 1.0f}, -{0.79003460207612464f, 0.91769319492502877f, 0.76811995386389853f, 1.0f}, -{0.78560553633218f, 0.91597078046905034f, 0.76615148019992318f, 1.0f}, -{0.78117647058823536f, 0.9142483660130718f, 0.76418300653594773f, 1.0f}, -{0.77674740484429072f, 0.91252595155709337f, 0.76221453287197238f, 1.0f}, -{0.77231833910034609f, 0.91080353710111495f, 0.76024605920799693f, 1.0f}, -{0.76788927335640145f, 0.90908112264513641f, 0.75827758554402158f, 1.0f}, -{0.76346020761245681f, 0.90735870818915798f, 0.75630911188004613f, 1.0f}, -{0.75903114186851217f, 0.90563629373317955f, 0.75434063821607078f, 1.0f}, -{0.75460207612456753f, 0.90391387927720102f, 0.75237216455209543f, 1.0f}, -{0.7501730103806229f, 0.90219146482122259f, 0.75040369088811998f, 1.0f}, -{0.74574394463667826f, 0.90046905036524416f, 0.74843521722414463f, 1.0f}, -{0.74131487889273362f, 0.89874663590926562f, 0.74646674356016918f, 1.0f}, -{0.73688581314878898f, 0.8970242214532872f, 0.74449826989619383f, 1.0f}, -{0.73245674740484434f, 0.89530180699730866f, 0.74252979623221838f, 1.0f}, -{0.72802768166089971f, 0.89357939254133023f, 0.74056132256824303f, 1.0f}, -{0.72359861591695507f, 0.8918569780853518f, 0.73859284890426757f, 1.0f}, -{0.71916955017301043f, 0.89013456362937338f, 0.73662437524029223f, 1.0f}, -{0.71474048442906579f, 0.88841214917339484f, 0.73465590157631688f, 1.0f}, -{0.71031141868512115f, 0.88668973471741641f, 0.73268742791234143f, 1.0f}, -{0.70588235294117652f, 0.88496732026143787f, 0.73071895424836608f, 1.0f}, -{0.70145328719723188f, 0.88324490580545945f, 0.72875048058439063f, 1.0f}, -{0.69702422145328724f, 0.88152249134948102f, 0.72678200692041528f, 1.0f}, -{0.6925951557093426f, 0.87980007689350248f, 0.72481353325643982f, 1.0f}, -{0.68816608996539796f, 0.87807766243752405f, 0.72284505959246448f, 1.0f}, -{0.68373702422145333f, 0.87635524798154563f, 0.72087658592848913f, 1.0f}, -{0.67930795847750869f, 0.87463283352556709f, 0.71890811226451368f, 1.0f}, -{0.67487889273356405f, 0.87291041906958866f, 0.71693963860053833f, 1.0f}, -{0.67044982698961941f, 0.87118800461361012f, 0.71497116493656288f, 1.0f}, -{0.66602076124567477f, 0.8694655901576317f, 0.71300269127258753f, 1.0f}, -{0.66159169550173014f, 0.86774317570165327f, 0.71103421760861207f, 1.0f}, -{0.65674740484429062f, 0.86588235294117655f, 0.71049596309111884f, 1.0f}, -{0.65121107266435985f, 0.86379084967320263f, 0.71234140715109573f, 1.0f}, -{0.64567474048442919f, 0.86169934640522883f, 0.71418685121107273f, 1.0f}, -{0.64013840830449831f, 0.85960784313725491f, 0.71603229527104961f, 1.0f}, -{0.63460207612456743f, 0.85751633986928111f, 0.71787773933102661f, 1.0f}, -{0.62906574394463666f, 0.85542483660130719f, 0.7197231833910035f, 1.0f}, -{0.62352941176470589f, 0.85333333333333339f, 0.72156862745098038f, 1.0f}, -{0.61799307958477512f, 0.85124183006535947f, 0.72341407151095738f, 1.0f}, -{0.61245674740484424f, 0.84915032679738567f, 0.72525951557093427f, 1.0f}, -{0.60692041522491347f, 0.84705882352941175f, 0.72710495963091126f, 1.0f}, -{0.60138408304498281f, 0.84496732026143795f, 0.72895040369088815f, 1.0f}, -{0.59584775086505193f, 0.84287581699346403f, 0.73079584775086504f, 1.0f}, -{0.59031141868512105f, 0.84078431372549023f, 0.73264129181084203f, 1.0f}, -{0.58477508650519028f, 0.83869281045751642f, 0.73448673587081892f, 1.0f}, -{0.57923875432525951f, 0.83660130718954251f, 0.73633217993079592f, 1.0f}, -{0.57370242214532874f, 0.8345098039215687f, 0.7381776239907728f, 1.0f}, -{0.56816608996539797f, 0.83241830065359479f, 0.7400230680507498f, 1.0f}, -{0.56262975778546709f, 0.83032679738562098f, 0.74186851211072669f, 1.0f}, -{0.55709342560553643f, 0.82823529411764718f, 0.74371395617070357f, 1.0f}, -{0.55155709342560555f, 0.82614379084967327f, 0.74555940023068057f, 1.0f}, -{0.54602076124567478f, 0.82405228758169935f, 0.74740484429065746f, 1.0f}, -{0.54048442906574401f, 0.82196078431372555f, 0.74925028835063445f, 1.0f}, -{0.53494809688581313f, 0.81986928104575163f, 0.75109573241061134f, 1.0f}, -{0.52941176470588236f, 0.81777777777777783f, 0.75294117647058822f, 1.0f}, -{0.52387543252595159f, 0.81568627450980391f, 0.75478662053056522f, 1.0f}, -{0.51833910034602071f, 0.81359477124183011f, 0.75663206459054211f, 1.0f}, -{0.51280276816609005f, 0.8115032679738563f, 0.75847750865051899f, 1.0f}, -{0.50726643598615917f, 0.80941176470588239f, 0.76032295271049599f, 1.0f}, -{0.5017301038062284f, 0.80732026143790858f, 0.76216839677047288f, 1.0f}, -{0.49619377162629763f, 0.80522875816993467f, 0.76401384083044988f, 1.0f}, -{0.49065743944636681f, 0.80313725490196086f, 0.76585928489042676f, 1.0f}, -{0.48512110726643598f, 0.80104575163398695f, 0.76770472895040376f, 1.0f}, -{0.47958477508650521f, 0.79846212995001931f, 0.76955017301038064f, 1.0f}, -{0.47404844290657439f, 0.79538638985005772f, 0.77139561707035764f, 1.0f}, -{0.46851211072664362f, 0.79231064975009613f, 0.77324106113033453f, 1.0f}, -{0.46297577854671279f, 0.78923490965013454f, 0.77508650519031141f, 1.0f}, -{0.45743944636678219f, 0.78615916955017318f, 0.7769319492502883f, 1.0f}, -{0.4519031141868512f, 0.78308342945021148f, 0.7787773933102653f, 1.0f}, -{0.44636678200692043f, 0.78000768935024989f, 0.78062283737024218f, 1.0f}, -{0.4408304498269896f, 0.77693194925028841f, 0.78246828143021918f, 1.0f}, -{0.43529411764705883f, 0.77385620915032682f, 0.78431372549019607f, 1.0f}, -{0.42975778546712806f, 0.77078046905036524f, 0.78615916955017306f, 1.0f}, -{0.42422145328719724f, 0.76770472895040376f, 0.78800461361014995f, 1.0f}, -{0.41868512110726647f, 0.76462898885044217f, 0.78985005767012684f, 1.0f}, -{0.41314878892733564f, 0.76155324875048058f, 0.79169550173010383f, 1.0f}, -{0.40761245674740487f, 0.75847750865051899f, 0.79354094579008072f, 1.0f}, -{0.40207612456747405f, 0.75540176855055752f, 0.79538638985005772f, 1.0f}, -{0.39653979238754328f, 0.75232602845059593f, 0.7972318339100346f, 1.0f}, -{0.39100346020761245f, 0.74925028835063434f, 0.79907727797001149f, 1.0f}, -{0.38546712802768168f, 0.74617454825067275f, 0.80092272202998849f, 1.0f}, -{0.37993079584775086f, 0.74309880815071128f, 0.80276816608996537f, 1.0f}, -{0.37439446366782009f, 0.74002306805074969f, 0.80461361014994237f, 1.0f}, -{0.36885813148788943f, 0.73694732795078821f, 0.80645905420991915f, 1.0f}, -{0.36332179930795849f, 0.73387158785082662f, 0.80830449826989614f, 1.0f}, -{0.35778546712802772f, 0.73079584775086504f, 0.81014994232987314f, 1.0f}, -{0.3522491349480969f, 0.72772010765090345f, 0.81199538638985003f, 1.0f}, -{0.34671280276816607f, 0.72464436755094197f, 0.81384083044982691f, 1.0f}, -{0.3411764705882353f, 0.72156862745098038f, 0.81568627450980391f, 1.0f}, -{0.33564013840830453f, 0.71849288735101879f, 0.8175317185697808f, 1.0f}, -{0.33010380622837371f, 0.71541714725105721f, 0.81937716262975779f, 1.0f}, -{0.32456747404844288f, 0.71234140715109573f, 0.82122260668973468f, 1.0f}, -{0.31903114186851211f, 0.70926566705113414f, 0.82306805074971157f, 1.0f}, -{0.31349480968858134f, 0.70618992695117255f, 0.82491349480968856f, 1.0f}, -{0.30795847750865057f, 0.70311418685121096f, 0.82675893886966545f, 1.0f}, -{0.30319108035371012f, 0.69896193771626292f, 0.82583621683967701f, 1.0f}, -{0.29888504421376394f, 0.6941637831603229f, 0.82325259515570925f, 1.0f}, -{0.29457900807381776f, 0.68936562860438289f, 0.82066897347174161f, 1.0f}, -{0.29027297193387158f, 0.68456747404844287f, 0.81808535178777386f, 1.0f}, -{0.28596693579392557f, 0.67976931949250297f, 0.81550173010380622f, 1.0f}, -{0.28166089965397928f, 0.67497116493656284f, 0.81291810841983847f, 1.0f}, -{0.2773548635140331f, 0.67017301038062282f, 0.81033448673587083f, 1.0f}, -{0.27304882737408692f, 0.66537485582468281f, 0.80775086505190308f, 1.0f}, -{0.26874279123414074f, 0.66057670126874279f, 0.80516724336793533f, 1.0f}, -{0.26443675509419456f, 0.65577854671280278f, 0.80258362168396769f, 1.0f}, -{0.26013071895424839f, 0.65098039215686276f, 0.79999999999999993f, 1.0f}, -{0.25582468281430221f, 0.64618223760092275f, 0.79741637831603229f, 1.0f}, -{0.25151864667435603f, 0.64138408304498273f, 0.79483275663206454f, 1.0f}, -{0.24721261053440985f, 0.63658592848904272f, 0.7922491349480969f, 1.0f}, -{0.24290657439446367f, 0.63178777393310259f, 0.78966551326412915f, 1.0f}, -{0.23860053825451752f, 0.62698961937716269f, 0.78708189158016151f, 1.0f}, -{0.23429450211457131f, 0.62219146482122256f, 0.78449826989619376f, 1.0f}, -{0.22998846597462516f, 0.61739331026528255f, 0.781914648212226f, 1.0f}, -{0.22568242983467898f, 0.61259515570934253f, 0.77933102652825836f, 1.0f}, -{0.2213763936947328f, 0.60779700115340252f, 0.77674740484429061f, 1.0f}, -{0.21707035755478676f, 0.60299884659746261f, 0.77416378316032297f, 1.0f}, -{0.21276432141484047f, 0.59820069204152249f, 0.77158016147635522f, 1.0f}, -{0.20845828527489429f, 0.59340253748558247f, 0.76899653979238758f, 1.0f}, -{0.20415224913494812f, 0.58860438292964246f, 0.76641291810841983f, 1.0f}, -{0.19984621299500194f, 0.58380622837370244f, 0.76382929642445219f, 1.0f}, -{0.19554017685505576f, 0.57900807381776243f, 0.76124567474048443f, 1.0f}, -{0.19123414071510958f, 0.57420991926182241f, 0.75866205305651668f, 1.0f}, -{0.1869281045751634f, 0.56941176470588239f, 0.75607843137254904f, 1.0f}, -{0.18262206843521722f, 0.56461361014994238f, 0.75349480968858129f, 1.0f}, -{0.17831603229527107f, 0.55981545559400236f, 0.75091118800461365f, 1.0f}, -{0.17400999615532489f, 0.55501730103806235f, 0.7483275663206459f, 1.0f}, -{0.16970396001537871f, 0.55021914648212233f, 0.74574394463667826f, 1.0f}, -{0.16539792387543253f, 0.5456978085351788f, 0.74343713956170709f, 1.0f}, -{0.16109188773548636f, 0.54126874279123416f, 0.74122260668973472f, 1.0f}, -{0.15678585159554018f, 0.53683967704728952f, 0.73900807381776246f, 1.0f}, -{0.15247981545559403f, 0.53241061130334488f, 0.73679354094579008f, 1.0f}, -{0.14817377931564796f, 0.52798154555940036f, 0.73457900807381782f, 1.0f}, -{0.14386774317570167f, 0.52355247981545561f, 0.73236447520184544f, 1.0f}, -{0.13956170703575549f, 0.51912341407151097f, 0.73014994232987318f, 1.0f}, -{0.13525567089580931f, 0.51469434832756633f, 0.72793540945790081f, 1.0f}, -{0.13094963475586313f, 0.51026528258362169f, 0.72572087658592854f, 1.0f}, -{0.12664359861591695f, 0.50583621683967706f, 0.72350634371395617f, 1.0f}, -{0.12233756247597079f, 0.50140715109573242f, 0.7212918108419839f, 1.0f}, -{0.11803152633602461f, 0.49697808535178778f, 0.71907727797001153f, 1.0f}, -{0.11372549019607844f, 0.49254901960784314f, 0.71686274509803927f, 1.0f}, -{0.10941945405613226f, 0.4881199538638985f, 0.71464821222606689f, 1.0f}, -{0.10511341791618609f, 0.48369088811995387f, 0.71243367935409463f, 1.0f}, -{0.10080738177623991f, 0.47926182237600923f, 0.71021914648212225f, 1.0f}, -{0.096501345636293742f, 0.47483275663206459f, 0.70800461361014999f, 1.0f}, -{0.092195309496347563f, 0.47040369088811995f, 0.70579008073817762f, 1.0f}, -{0.087889273356401384f, 0.46597462514417531f, 0.70357554786620535f, 1.0f}, -{0.083583237216455206f, 0.46154555940023068f, 0.70136101499423298f, 1.0f}, -{0.079277201076509152f, 0.45711649365628615f, 0.69914648212226072f, 1.0f}, -{0.074971164936562862f, 0.4526874279123414f, 0.69693194925028834f, 1.0f}, -{0.070665128796616683f, 0.44825836216839676f, 0.69471741637831608f, 1.0f}, -{0.066359092656670518f, 0.44382929642445212f, 0.6925028835063437f, 1.0f}, -{0.062053056516724339f, 0.43940023068050749f, 0.69028835063437144f, 1.0f}, -{0.05774702037677816f, 0.43497116493656285f, 0.68807381776239906f, 1.0f}, -{0.053440984236831982f, 0.43054209919261821f, 0.6858592848904268f, 1.0f}, -{0.049134948096885817f, 0.42611303344867357f, 0.68364475201845454f, 1.0f}, -{0.044828911956939638f, 0.42168396770472893f, 0.68143021914648216f, 1.0f}, -{0.040522875816993459f, 0.4172549019607843f, 0.67921568627450979f, 1.0f}, -{0.03621683967704728f, 0.41282583621683966f, 0.67700115340253753f, 1.0f}, -{0.031910803537101101f, 0.40839677047289502f, 0.67478662053056526f, 1.0f}, -{0.031372549019607843f, 0.40353710111495578f, 0.66988081507112651f, 1.0f}, -{0.031372549019607843f, 0.3986159169550173f, 0.66459054209919266f, 1.0f}, -{0.031372549019607843f, 0.39369473279507883f, 0.65930026912725881f, 1.0f}, -{0.031372549019607843f, 0.38877354863514035f, 0.65400999615532496f, 1.0f}, -{0.031372549019607843f, 0.38385236447520199f, 0.64871972318339122f, 1.0f}, -{0.031372549019607843f, 0.37893118031526335f, 0.64342945021145714f, 1.0f}, -{0.031372549019607843f, 0.37400999615532488f, 0.63813917723952329f, 1.0f}, -{0.031372549019607843f, 0.3690888119953864f, 0.63284890426758944f, 1.0f}, -{0.031372549019607843f, 0.36416762783544787f, 0.62755863129565559f, 1.0f}, -{0.031372549019607843f, 0.3592464436755094f, 0.62226835832372163f, 1.0f}, -{0.031372549019607843f, 0.35432525951557092f, 0.61697808535178778f, 1.0f}, -{0.031372549019607843f, 0.34940407535563245f, 0.61168781237985392f, 1.0f}, -{0.031372549019607843f, 0.34448289119569397f, 0.60639753940792007f, 1.0f}, -{0.031372549019607843f, 0.3395617070357555f, 0.60110726643598622f, 1.0f}, -{0.031372549019607843f, 0.33464052287581697f, 0.59581699346405226f, 1.0f}, -{0.031372549019607843f, 0.3297193387158785f, 0.59052672049211841f, 1.0f}, -{0.031372549019607843f, 0.32479815455594002f, 0.58523644752018456f, 1.0f}, -{0.031372549019607843f, 0.31987697039600155f, 0.5799461745482507f, 1.0f}, -{0.031372549019607843f, 0.31495578623606302f, 0.57465590157631685f, 1.0f}, -{0.031372549019607843f, 0.31003460207612454f, 0.56936562860438289f, 1.0f}, -{0.031372549019607843f, 0.30511341791618624f, 0.56407535563244915f, 1.0f}, -{0.031372549019607843f, 0.3001922337562476f, 0.55878508266051519f, 1.0f}, -{0.031372549019607843f, 0.29527104959630912f, 0.55349480968858134f, 1.0f}, -{0.031372549019607843f, 0.29034986543637065f, 0.54820453671664748f, 1.0f}, -{0.031372549019607843f, 0.28542868127643212f, 0.54291426374471352f, 1.0f}, -{0.031372549019607843f, 0.28050749711649364f, 0.53762399077277967f, 1.0f}, -{0.031372549019607843f, 0.27558631295655517f, 0.53233371780084582f, 1.0f}, -{0.031372549019607843f, 0.27066512879661669f, 0.52704344482891197f, 1.0f}, -{0.031372549019607843f, 0.26574394463667816f, 0.52175317185697812f, 1.0f}, -{0.031372549019607843f, 0.26082276047673969f, 0.51646289888504415f, 1.0f}, -{0.031372549019607843f, 0.25590157631680122f, 0.5111726259131103f, 1.0f}, -{0.031372549019607843f, 0.25098039215686274f, 0.50588235294117645f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential/GnBu.txt b/extern/tfn/colormaps/sequential/GnBu.txt deleted file mode 100644 index 3462f88..0000000 --- a/extern/tfn/colormaps/sequential/GnBu.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.96862745098039216, 0.9882352941176471, 0.94117647058823528, 1.0) -(0.96579777008842749, 0.98712802768166097, 0.93859284890426753, 1.0) -(0.96296808919646293, 0.98602076124567473, 0.93600922722029989, 1.0) -(0.96013840830449826, 0.98491349480968859, 0.93342560553633214, 1.0) -(0.95730872741253359, 0.98380622837370246, 0.9308419838523645, 1.0) -(0.95447904652056903, 0.98269896193771633, 0.92825836216839674, 1.0) -(0.95164936562860436, 0.98159169550173009, 0.92567474048442899, 1.0) -(0.9488196847366398, 0.98048442906574396, 0.92309111880046135, 1.0) -(0.94599000384467513, 0.97937716262975782, 0.9205074971164936, 1.0) -(0.94316032295271046, 0.97826989619377169, 0.91792387543252596, 1.0) -(0.9403306420607459, 0.97716262975778545, 0.91534025374855821, 1.0) -(0.93750096116878123, 0.97605536332179932, 0.91275663206459057, 1.0) -(0.93467128027681656, 0.97494809688581319, 0.91017301038062282, 1.0) -(0.931841599384852, 0.97384083044982694, 0.90758938869665506, 1.0) -(0.92901191849288733, 0.97273356401384081, 0.90500576701268742, 1.0) -(0.92618223760092278, 0.97162629757785468, 0.90242214532871967, 1.0) -(0.92335255670895811, 0.97051903114186855, 0.89983852364475203, 1.0) -(0.92052287581699344, 0.96941176470588231, 0.89725490196078428, 1.0) -(0.91769319492502888, 0.96830449826989617, 0.89467128027681653, 1.0) -(0.91486351403306421, 0.96719723183391004, 0.89208765859284889, 1.0) -(0.91203383314109954, 0.9660899653979238, 0.88950403690888113, 1.0) -(0.90920415224913498, 0.96498269896193767, 0.88692041522491349, 1.0) -(0.90637447135717031, 0.96387543252595154, 0.88433679354094574, 1.0) -(0.90354479046520564, 0.9627681660899654, 0.88175317185697799, 1.0) -(0.90071510957324108, 0.96166089965397916, 0.87916955017301035, 1.0) -(0.89788542868127641, 0.96055363321799303, 0.8765859284890426, 1.0) -(0.89505574778931174, 0.9594463667820069, 0.87400230680507496, 1.0) -(0.89222606689734718, 0.95833910034602077, 0.87141868512110721, 1.0) -(0.88939638600538251, 0.95723183391003452, 0.86883506343713957, 1.0) -(0.88656670511341795, 0.95612456747404839, 0.86625144175317181, 1.0) -(0.88373702422145328, 0.95501730103806226, 0.86366782006920406, 1.0) -(0.88090734332948861, 0.95391003460207613, 0.86108419838523642, 1.0) -(0.87812379853902345, 0.95281814686658972, 0.85848519800076883, 1.0) -(0.87566320645905427, 0.95183391003460205, 0.85577854671280273, 1.0) -(0.87320261437908497, 0.95084967320261438, 0.85307189542483652, 1.0) -(0.87074202229911568, 0.94986543637062659, 0.85036524413687042, 1.0) -(0.8682814302191465, 0.94888119953863892, 0.84765859284890421, 1.0) -(0.86582083813917721, 0.94789696270665125, 0.84495194156093811, 1.0) -(0.86336024605920803, 0.94691272587466357, 0.8422452902729719, 1.0) -(0.86089965397923873, 0.94592848904267579, 0.83953863898500569, 1.0) -(0.85843906189926955, 0.94494425221068812, 0.83683198769703959, 1.0) -(0.85597846981930026, 0.94396001537870045, 0.83412533640907338, 1.0) -(0.85351787773933108, 0.94297577854671277, 0.83141868512110728, 1.0) -(0.85105728565936178, 0.9419915417147251, 0.82871203383314107, 1.0) -(0.8485966935793926, 0.94100730488273732, 0.82600538254517497, 1.0) -(0.84613610149942331, 0.94002306805074964, 0.82329873125720876, 1.0) -(0.84367550941945413, 0.93903883121876197, 0.82059207996924255, 1.0) -(0.84121491733948484, 0.9380545943867743, 0.81788542868127645, 1.0) -(0.83875432525951554, 0.93707035755478651, 0.81517877739331024, 1.0) -(0.83629373317954636, 0.93608612072279884, 0.81247212610534414, 1.0) -(0.83383314109957707, 0.93510188389081117, 0.80976547481737793, 1.0) -(0.83137254901960789, 0.9341176470588235, 0.80705882352941172, 1.0) -(0.82891195693963859, 0.93313341022683582, 0.80435217224144562, 1.0) -(0.82645136485966941, 0.93214917339484804, 0.80164552095347941, 1.0) -(0.82399077277970012, 0.93116493656286037, 0.79893886966551331, 1.0) -(0.82153018069973094, 0.9301806997308727, 0.7962322183775471, 1.0) -(0.81906958861976165, 0.92919646289888502, 0.79352556708958089, 1.0) -(0.81660899653979246, 0.92821222606689735, 0.79081891580161479, 1.0) -(0.81414840445982317, 0.92722798923490957, 0.78811226451364857, 1.0) -(0.81168781237985388, 0.92624375240292189, 0.78540561322568248, 1.0) -(0.8092272202998847, 0.92525951557093422, 0.78269896193771626, 1.0) -(0.80676662821991552, 0.92427527873894655, 0.77999231064975016, 1.0) -(0.80430603613994622, 0.92329104190695876, 0.77728565936178395, 1.0) -(0.80184544405997693, 0.92230680507497109, 0.77457900807381774, 1.0) -(0.79889273356401391, 0.92113802383698573, 0.77205690119184933, 1.0) -(0.79446366782006927, 0.9194156093810073, 0.77008842752787388, 1.0) -(0.79003460207612464, 0.91769319492502877, 0.76811995386389853, 1.0) -(0.78560553633218, 0.91597078046905034, 0.76615148019992318, 1.0) -(0.78117647058823536, 0.9142483660130718, 0.76418300653594773, 1.0) -(0.77674740484429072, 0.91252595155709337, 0.76221453287197238, 1.0) -(0.77231833910034609, 0.91080353710111495, 0.76024605920799693, 1.0) -(0.76788927335640145, 0.90908112264513641, 0.75827758554402158, 1.0) -(0.76346020761245681, 0.90735870818915798, 0.75630911188004613, 1.0) -(0.75903114186851217, 0.90563629373317955, 0.75434063821607078, 1.0) -(0.75460207612456753, 0.90391387927720102, 0.75237216455209543, 1.0) -(0.7501730103806229, 0.90219146482122259, 0.75040369088811998, 1.0) -(0.74574394463667826, 0.90046905036524416, 0.74843521722414463, 1.0) -(0.74131487889273362, 0.89874663590926562, 0.74646674356016918, 1.0) -(0.73688581314878898, 0.8970242214532872, 0.74449826989619383, 1.0) -(0.73245674740484434, 0.89530180699730866, 0.74252979623221838, 1.0) -(0.72802768166089971, 0.89357939254133023, 0.74056132256824303, 1.0) -(0.72359861591695507, 0.8918569780853518, 0.73859284890426757, 1.0) -(0.71916955017301043, 0.89013456362937338, 0.73662437524029223, 1.0) -(0.71474048442906579, 0.88841214917339484, 0.73465590157631688, 1.0) -(0.71031141868512115, 0.88668973471741641, 0.73268742791234143, 1.0) -(0.70588235294117652, 0.88496732026143787, 0.73071895424836608, 1.0) -(0.70145328719723188, 0.88324490580545945, 0.72875048058439063, 1.0) -(0.69702422145328724, 0.88152249134948102, 0.72678200692041528, 1.0) -(0.6925951557093426, 0.87980007689350248, 0.72481353325643982, 1.0) -(0.68816608996539796, 0.87807766243752405, 0.72284505959246448, 1.0) -(0.68373702422145333, 0.87635524798154563, 0.72087658592848913, 1.0) -(0.67930795847750869, 0.87463283352556709, 0.71890811226451368, 1.0) -(0.67487889273356405, 0.87291041906958866, 0.71693963860053833, 1.0) -(0.67044982698961941, 0.87118800461361012, 0.71497116493656288, 1.0) -(0.66602076124567477, 0.8694655901576317, 0.71300269127258753, 1.0) -(0.66159169550173014, 0.86774317570165327, 0.71103421760861207, 1.0) -(0.65674740484429062, 0.86588235294117655, 0.71049596309111884, 1.0) -(0.65121107266435985, 0.86379084967320263, 0.71234140715109573, 1.0) -(0.64567474048442919, 0.86169934640522883, 0.71418685121107273, 1.0) -(0.64013840830449831, 0.85960784313725491, 0.71603229527104961, 1.0) -(0.63460207612456743, 0.85751633986928111, 0.71787773933102661, 1.0) -(0.62906574394463666, 0.85542483660130719, 0.7197231833910035, 1.0) -(0.62352941176470589, 0.85333333333333339, 0.72156862745098038, 1.0) -(0.61799307958477512, 0.85124183006535947, 0.72341407151095738, 1.0) -(0.61245674740484424, 0.84915032679738567, 0.72525951557093427, 1.0) -(0.60692041522491347, 0.84705882352941175, 0.72710495963091126, 1.0) -(0.60138408304498281, 0.84496732026143795, 0.72895040369088815, 1.0) -(0.59584775086505193, 0.84287581699346403, 0.73079584775086504, 1.0) -(0.59031141868512105, 0.84078431372549023, 0.73264129181084203, 1.0) -(0.58477508650519028, 0.83869281045751642, 0.73448673587081892, 1.0) -(0.57923875432525951, 0.83660130718954251, 0.73633217993079592, 1.0) -(0.57370242214532874, 0.8345098039215687, 0.7381776239907728, 1.0) -(0.56816608996539797, 0.83241830065359479, 0.7400230680507498, 1.0) -(0.56262975778546709, 0.83032679738562098, 0.74186851211072669, 1.0) -(0.55709342560553643, 0.82823529411764718, 0.74371395617070357, 1.0) -(0.55155709342560555, 0.82614379084967327, 0.74555940023068057, 1.0) -(0.54602076124567478, 0.82405228758169935, 0.74740484429065746, 1.0) -(0.54048442906574401, 0.82196078431372555, 0.74925028835063445, 1.0) -(0.53494809688581313, 0.81986928104575163, 0.75109573241061134, 1.0) -(0.52941176470588236, 0.81777777777777783, 0.75294117647058822, 1.0) -(0.52387543252595159, 0.81568627450980391, 0.75478662053056522, 1.0) -(0.51833910034602071, 0.81359477124183011, 0.75663206459054211, 1.0) -(0.51280276816609005, 0.8115032679738563, 0.75847750865051899, 1.0) -(0.50726643598615917, 0.80941176470588239, 0.76032295271049599, 1.0) -(0.5017301038062284, 0.80732026143790858, 0.76216839677047288, 1.0) -(0.49619377162629763, 0.80522875816993467, 0.76401384083044988, 1.0) -(0.49065743944636681, 0.80313725490196086, 0.76585928489042676, 1.0) -(0.48512110726643598, 0.80104575163398695, 0.76770472895040376, 1.0) -(0.47958477508650521, 0.79846212995001931, 0.76955017301038064, 1.0) -(0.47404844290657439, 0.79538638985005772, 0.77139561707035764, 1.0) -(0.46851211072664362, 0.79231064975009613, 0.77324106113033453, 1.0) -(0.46297577854671279, 0.78923490965013454, 0.77508650519031141, 1.0) -(0.45743944636678219, 0.78615916955017318, 0.7769319492502883, 1.0) -(0.4519031141868512, 0.78308342945021148, 0.7787773933102653, 1.0) -(0.44636678200692043, 0.78000768935024989, 0.78062283737024218, 1.0) -(0.4408304498269896, 0.77693194925028841, 0.78246828143021918, 1.0) -(0.43529411764705883, 0.77385620915032682, 0.78431372549019607, 1.0) -(0.42975778546712806, 0.77078046905036524, 0.78615916955017306, 1.0) -(0.42422145328719724, 0.76770472895040376, 0.78800461361014995, 1.0) -(0.41868512110726647, 0.76462898885044217, 0.78985005767012684, 1.0) -(0.41314878892733564, 0.76155324875048058, 0.79169550173010383, 1.0) -(0.40761245674740487, 0.75847750865051899, 0.79354094579008072, 1.0) -(0.40207612456747405, 0.75540176855055752, 0.79538638985005772, 1.0) -(0.39653979238754328, 0.75232602845059593, 0.7972318339100346, 1.0) -(0.39100346020761245, 0.74925028835063434, 0.79907727797001149, 1.0) -(0.38546712802768168, 0.74617454825067275, 0.80092272202998849, 1.0) -(0.37993079584775086, 0.74309880815071128, 0.80276816608996537, 1.0) -(0.37439446366782009, 0.74002306805074969, 0.80461361014994237, 1.0) -(0.36885813148788943, 0.73694732795078821, 0.80645905420991915, 1.0) -(0.36332179930795849, 0.73387158785082662, 0.80830449826989614, 1.0) -(0.35778546712802772, 0.73079584775086504, 0.81014994232987314, 1.0) -(0.3522491349480969, 0.72772010765090345, 0.81199538638985003, 1.0) -(0.34671280276816607, 0.72464436755094197, 0.81384083044982691, 1.0) -(0.3411764705882353, 0.72156862745098038, 0.81568627450980391, 1.0) -(0.33564013840830453, 0.71849288735101879, 0.8175317185697808, 1.0) -(0.33010380622837371, 0.71541714725105721, 0.81937716262975779, 1.0) -(0.32456747404844288, 0.71234140715109573, 0.82122260668973468, 1.0) -(0.31903114186851211, 0.70926566705113414, 0.82306805074971157, 1.0) -(0.31349480968858134, 0.70618992695117255, 0.82491349480968856, 1.0) -(0.30795847750865057, 0.70311418685121096, 0.82675893886966545, 1.0) -(0.30319108035371012, 0.69896193771626292, 0.82583621683967701, 1.0) -(0.29888504421376394, 0.6941637831603229, 0.82325259515570925, 1.0) -(0.29457900807381776, 0.68936562860438289, 0.82066897347174161, 1.0) -(0.29027297193387158, 0.68456747404844287, 0.81808535178777386, 1.0) -(0.28596693579392557, 0.67976931949250297, 0.81550173010380622, 1.0) -(0.28166089965397928, 0.67497116493656284, 0.81291810841983847, 1.0) -(0.2773548635140331, 0.67017301038062282, 0.81033448673587083, 1.0) -(0.27304882737408692, 0.66537485582468281, 0.80775086505190308, 1.0) -(0.26874279123414074, 0.66057670126874279, 0.80516724336793533, 1.0) -(0.26443675509419456, 0.65577854671280278, 0.80258362168396769, 1.0) -(0.26013071895424839, 0.65098039215686276, 0.79999999999999993, 1.0) -(0.25582468281430221, 0.64618223760092275, 0.79741637831603229, 1.0) -(0.25151864667435603, 0.64138408304498273, 0.79483275663206454, 1.0) -(0.24721261053440985, 0.63658592848904272, 0.7922491349480969, 1.0) -(0.24290657439446367, 0.63178777393310259, 0.78966551326412915, 1.0) -(0.23860053825451752, 0.62698961937716269, 0.78708189158016151, 1.0) -(0.23429450211457131, 0.62219146482122256, 0.78449826989619376, 1.0) -(0.22998846597462516, 0.61739331026528255, 0.781914648212226, 1.0) -(0.22568242983467898, 0.61259515570934253, 0.77933102652825836, 1.0) -(0.2213763936947328, 0.60779700115340252, 0.77674740484429061, 1.0) -(0.21707035755478676, 0.60299884659746261, 0.77416378316032297, 1.0) -(0.21276432141484047, 0.59820069204152249, 0.77158016147635522, 1.0) -(0.20845828527489429, 0.59340253748558247, 0.76899653979238758, 1.0) -(0.20415224913494812, 0.58860438292964246, 0.76641291810841983, 1.0) -(0.19984621299500194, 0.58380622837370244, 0.76382929642445219, 1.0) -(0.19554017685505576, 0.57900807381776243, 0.76124567474048443, 1.0) -(0.19123414071510958, 0.57420991926182241, 0.75866205305651668, 1.0) -(0.1869281045751634, 0.56941176470588239, 0.75607843137254904, 1.0) -(0.18262206843521722, 0.56461361014994238, 0.75349480968858129, 1.0) -(0.17831603229527107, 0.55981545559400236, 0.75091118800461365, 1.0) -(0.17400999615532489, 0.55501730103806235, 0.7483275663206459, 1.0) -(0.16970396001537871, 0.55021914648212233, 0.74574394463667826, 1.0) -(0.16539792387543253, 0.5456978085351788, 0.74343713956170709, 1.0) -(0.16109188773548636, 0.54126874279123416, 0.74122260668973472, 1.0) -(0.15678585159554018, 0.53683967704728952, 0.73900807381776246, 1.0) -(0.15247981545559403, 0.53241061130334488, 0.73679354094579008, 1.0) -(0.14817377931564796, 0.52798154555940036, 0.73457900807381782, 1.0) -(0.14386774317570167, 0.52355247981545561, 0.73236447520184544, 1.0) -(0.13956170703575549, 0.51912341407151097, 0.73014994232987318, 1.0) -(0.13525567089580931, 0.51469434832756633, 0.72793540945790081, 1.0) -(0.13094963475586313, 0.51026528258362169, 0.72572087658592854, 1.0) -(0.12664359861591695, 0.50583621683967706, 0.72350634371395617, 1.0) -(0.12233756247597079, 0.50140715109573242, 0.7212918108419839, 1.0) -(0.11803152633602461, 0.49697808535178778, 0.71907727797001153, 1.0) -(0.11372549019607844, 0.49254901960784314, 0.71686274509803927, 1.0) -(0.10941945405613226, 0.4881199538638985, 0.71464821222606689, 1.0) -(0.10511341791618609, 0.48369088811995387, 0.71243367935409463, 1.0) -(0.10080738177623991, 0.47926182237600923, 0.71021914648212225, 1.0) -(0.096501345636293742, 0.47483275663206459, 0.70800461361014999, 1.0) -(0.092195309496347563, 0.47040369088811995, 0.70579008073817762, 1.0) -(0.087889273356401384, 0.46597462514417531, 0.70357554786620535, 1.0) -(0.083583237216455206, 0.46154555940023068, 0.70136101499423298, 1.0) -(0.079277201076509152, 0.45711649365628615, 0.69914648212226072, 1.0) -(0.074971164936562862, 0.4526874279123414, 0.69693194925028834, 1.0) -(0.070665128796616683, 0.44825836216839676, 0.69471741637831608, 1.0) -(0.066359092656670518, 0.44382929642445212, 0.6925028835063437, 1.0) -(0.062053056516724339, 0.43940023068050749, 0.69028835063437144, 1.0) -(0.05774702037677816, 0.43497116493656285, 0.68807381776239906, 1.0) -(0.053440984236831982, 0.43054209919261821, 0.6858592848904268, 1.0) -(0.049134948096885817, 0.42611303344867357, 0.68364475201845454, 1.0) -(0.044828911956939638, 0.42168396770472893, 0.68143021914648216, 1.0) -(0.040522875816993459, 0.4172549019607843, 0.67921568627450979, 1.0) -(0.03621683967704728, 0.41282583621683966, 0.67700115340253753, 1.0) -(0.031910803537101101, 0.40839677047289502, 0.67478662053056526, 1.0) -(0.031372549019607843, 0.40353710111495578, 0.66988081507112651, 1.0) -(0.031372549019607843, 0.3986159169550173, 0.66459054209919266, 1.0) -(0.031372549019607843, 0.39369473279507883, 0.65930026912725881, 1.0) -(0.031372549019607843, 0.38877354863514035, 0.65400999615532496, 1.0) -(0.031372549019607843, 0.38385236447520199, 0.64871972318339122, 1.0) -(0.031372549019607843, 0.37893118031526335, 0.64342945021145714, 1.0) -(0.031372549019607843, 0.37400999615532488, 0.63813917723952329, 1.0) -(0.031372549019607843, 0.3690888119953864, 0.63284890426758944, 1.0) -(0.031372549019607843, 0.36416762783544787, 0.62755863129565559, 1.0) -(0.031372549019607843, 0.3592464436755094, 0.62226835832372163, 1.0) -(0.031372549019607843, 0.35432525951557092, 0.61697808535178778, 1.0) -(0.031372549019607843, 0.34940407535563245, 0.61168781237985392, 1.0) -(0.031372549019607843, 0.34448289119569397, 0.60639753940792007, 1.0) -(0.031372549019607843, 0.3395617070357555, 0.60110726643598622, 1.0) -(0.031372549019607843, 0.33464052287581697, 0.59581699346405226, 1.0) -(0.031372549019607843, 0.3297193387158785, 0.59052672049211841, 1.0) -(0.031372549019607843, 0.32479815455594002, 0.58523644752018456, 1.0) -(0.031372549019607843, 0.31987697039600155, 0.5799461745482507, 1.0) -(0.031372549019607843, 0.31495578623606302, 0.57465590157631685, 1.0) -(0.031372549019607843, 0.31003460207612454, 0.56936562860438289, 1.0) -(0.031372549019607843, 0.30511341791618624, 0.56407535563244915, 1.0) -(0.031372549019607843, 0.3001922337562476, 0.55878508266051519, 1.0) -(0.031372549019607843, 0.29527104959630912, 0.55349480968858134, 1.0) -(0.031372549019607843, 0.29034986543637065, 0.54820453671664748, 1.0) -(0.031372549019607843, 0.28542868127643212, 0.54291426374471352, 1.0) -(0.031372549019607843, 0.28050749711649364, 0.53762399077277967, 1.0) -(0.031372549019607843, 0.27558631295655517, 0.53233371780084582, 1.0) -(0.031372549019607843, 0.27066512879661669, 0.52704344482891197, 1.0) -(0.031372549019607843, 0.26574394463667816, 0.52175317185697812, 1.0) -(0.031372549019607843, 0.26082276047673969, 0.51646289888504415, 1.0) -(0.031372549019607843, 0.25590157631680122, 0.5111726259131103, 1.0) -(0.031372549019607843, 0.25098039215686274, 0.50588235294117645, 1.0) diff --git a/extern/tfn/colormaps/sequential/Greens.cpp b/extern/tfn/colormaps/sequential/Greens.cpp deleted file mode 100644 index dd25e97..0000000 --- a/extern/tfn/colormaps/sequential/Greens.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential_Greens; -} -const std::vector colormap::data_sequential_Greens = /* NOLINT(cert-err58-cpp) */ -{ -{0.96862745098039216f, 0.9882352941176471f, 0.96078431372549022f, 1.0f}, -{0.96641291810841989f, 0.98737408688965789f, 0.95820069204152247f, 1.0f}, -{0.96419838523644752f, 0.98651287966166867f, 0.95561707035755483f, 1.0f}, -{0.96198385236447526f, 0.98565167243367935f, 0.95303344867358708f, 1.0f}, -{0.95976931949250288f, 0.98479046520569014f, 0.95044982698961944f, 1.0f}, -{0.95755478662053062f, 0.98392925797770092f, 0.94786620530565169f, 1.0f}, -{0.95534025374855824f, 0.98306805074971171f, 0.94528258362168394f, 1.0f}, -{0.95312572087658598f, 0.98220684352172249f, 0.9426989619377163f, 1.0f}, -{0.95091118800461361f, 0.98134563629373317f, 0.94011534025374854f, 1.0f}, -{0.94869665513264134f, 0.98048442906574396f, 0.9375317185697809f, 1.0f}, -{0.94648212226066897f, 0.97962322183775474f, 0.93494809688581315f, 1.0f}, -{0.9442675893886967f, 0.97876201460976553f, 0.93236447520184551f, 1.0f}, -{0.94205305651672433f, 0.97790080738177632f, 0.92978085351787776f, 1.0f}, -{0.93983852364475207f, 0.97703960015378699f, 0.92719723183391001f, 1.0f}, -{0.93762399077277969f, 0.97617839292579778f, 0.92461361014994237f, 1.0f}, -{0.93540945790080743f, 0.97531718569780856f, 0.92202998846597461f, 1.0f}, -{0.93319492502883505f, 0.97445597846981935f, 0.91944636678200697f, 1.0f}, -{0.93098039215686279f, 0.97359477124183014f, 0.91686274509803922f, 1.0f}, -{0.92876585928489042f, 0.97273356401384081f, 0.91427912341407147f, 1.0f}, -{0.92655132641291815f, 0.9718723567858516f, 0.91169550173010383f, 1.0f}, -{0.92433679354094578f, 0.97101114955786239f, 0.90911188004613608f, 1.0f}, -{0.92212226066897351f, 0.97014994232987317f, 0.90652825836216844f, 1.0f}, -{0.91990772779700114f, 0.96928873510188396f, 0.90394463667820069f, 1.0f}, -{0.91769319492502888f, 0.96842752787389474f, 0.90136101499423305f, 1.0f}, -{0.9154786620530565f, 0.96756632064590542f, 0.89877739331026529f, 1.0f}, -{0.91326412918108424f, 0.96670511341791621f, 0.89619377162629754f, 1.0f}, -{0.91104959630911186f, 0.96584390618992699f, 0.8936101499423299f, 1.0f}, -{0.9088350634371396f, 0.96498269896193778f, 0.89102652825836215f, 1.0f}, -{0.90662053056516723f, 0.96412149173394845f, 0.8884429065743944f, 1.0f}, -{0.90440599769319496f, 0.96326028450595924f, 0.88585928489042676f, 1.0f}, -{0.90219146482122259f, 0.96239907727797003f, 0.88327566320645901f, 1.0f}, -{0.89997693194925033f, 0.96153787004998081f, 0.88069204152249136f, 1.0f}, -{0.89757785467128026f, 0.96059976931949254f, 0.87793925413302576f, 1.0f}, -{0.89388696655132649f, 0.95912341407151103f, 0.87400230680507496f, 1.0f}, -{0.89019607843137261f, 0.95764705882352941f, 0.87006535947712416f, 1.0f}, -{0.88650519031141872f, 0.9561707035755479f, 0.86612841214917335f, 1.0f}, -{0.88281430219146484f, 0.95469434832756639f, 0.86219146482122255f, 1.0f}, -{0.87912341407151096f, 0.95321799307958477f, 0.85825451749327186f, 1.0f}, -{0.87543252595155707f, 0.95174163783160326f, 0.85431757016532106f, 1.0f}, -{0.8717416378316033f, 0.95026528258362175f, 0.85038062283737026f, 1.0f}, -{0.86805074971164942f, 0.94878892733564013f, 0.84644367550941946f, 1.0f}, -{0.86435986159169553f, 0.94731257208765862f, 0.84250672818146866f, 1.0f}, -{0.86066897347174165f, 0.94583621683967711f, 0.83856978085351785f, 1.0f}, -{0.85697808535178777f, 0.94435986159169549f, 0.83463283352556705f, 1.0f}, -{0.85328719723183388f, 0.94288350634371398f, 0.83069588619761625f, 1.0f}, -{0.84959630911188011f, 0.94140715109573248f, 0.82675893886966556f, 1.0f}, -{0.84590542099192623f, 0.93993079584775086f, 0.82282199154171476f, 1.0f}, -{0.84221453287197234f, 0.93845444059976935f, 0.81888504421376396f, 1.0f}, -{0.83852364475201846f, 0.93697808535178773f, 0.81494809688581316f, 1.0f}, -{0.83483275663206458f, 0.93550173010380622f, 0.81101114955786235f, 1.0f}, -{0.8311418685121108f, 0.93402537485582471f, 0.80707420222991155f, 1.0f}, -{0.82745098039215692f, 0.93254901960784309f, 0.80313725490196075f, 1.0f}, -{0.82376009227220304f, 0.93107266435986158f, 0.79920030757400995f, 1.0f}, -{0.82006920415224915f, 0.92959630911188007f, 0.79526336024605926f, 1.0f}, -{0.81637831603229527f, 0.92811995386389845f, 0.79132641291810846f, 1.0f}, -{0.81268742791234139f, 0.92664359861591694f, 0.78738946559015766f, 1.0f}, -{0.8089965397923875f, 0.92516724336793543f, 0.78345251826220685f, 1.0f}, -{0.80530565167243373f, 0.92369088811995381f, 0.77951557093425605f, 1.0f}, -{0.80161476355247985f, 0.9222145328719723f, 0.77557862360630525f, 1.0f}, -{0.79792387543252596f, 0.92073817762399079f, 0.77164167627835445f, 1.0f}, -{0.79423298731257208f, 0.91926182237600917f, 0.76770472895040365f, 1.0f}, -{0.7905420991926182f, 0.91778546712802767f, 0.76376778162245296f, 1.0f}, -{0.78685121107266442f, 0.91630911188004616f, 0.75983083429450216f, 1.0f}, -{0.78316032295271054f, 0.91483275663206454f, 0.75589388696655135f, 1.0f}, -{0.77922337562475974f, 0.91323337178008457f, 0.75180315263360242f, 1.0f}, -{0.77454825067281818f, 0.91126489811610911f, 0.74725105728565933f, 1.0f}, -{0.76987312572087663f, 0.90929642445213377f, 0.74269896193771634f, 1.0f}, -{0.76519800076893507f, 0.90732795078815842f, 0.73814686658977313f, 1.0f}, -{0.76052287581699352f, 0.90535947712418297f, 0.73359477124183003f, 1.0f}, -{0.75584775086505185f, 0.90339100346020762f, 0.72904267589388694f, 1.0f}, -{0.75117262591311029f, 0.90142252979623216f, 0.72449058054594384f, 1.0f}, -{0.74649750096116874f, 0.89945405613225682f, 0.71993848519800074f, 1.0f}, -{0.74182237600922718f, 0.89748558246828136f, 0.71538638985005765f, 1.0f}, -{0.73714725105728562f, 0.89551710880430602f, 0.71083429450211455f, 1.0f}, -{0.73247212610534418f, 0.89354863514033067f, 0.70628219915417145f, 1.0f}, -{0.72779700115340251f, 0.89158016147635522f, 0.70173010380622836f, 1.0f}, -{0.72312187620146096f, 0.88961168781237987f, 0.69717800845828526f, 1.0f}, -{0.7184467512495194f, 0.88764321414840441f, 0.69262591311034216f, 1.0f}, -{0.71377162629757784f, 0.88567474048442907f, 0.68807381776239906f, 1.0f}, -{0.70909650134563629f, 0.88370626682045361f, 0.68352172241445597f, 1.0f}, -{0.70442137639369473f, 0.88173779315647827f, 0.67896962706651287f, 1.0f}, -{0.69974625144175318f, 0.87976931949250281f, 0.67441753171856977f, 1.0f}, -{0.69507112648981173f, 0.87780084582852747f, 0.66986543637062668f, 1.0f}, -{0.69039600153787006f, 0.87583237216455212f, 0.66531334102268358f, 1.0f}, -{0.68572087658592851f, 0.87386389850057666f, 0.66076124567474048f, 1.0f}, -{0.68104575163398695f, 0.87189542483660132f, 0.65620915032679739f, 1.0f}, -{0.67637062668204539f, 0.86992695117262586f, 0.65165705497885429f, 1.0f}, -{0.67169550173010384f, 0.86795847750865052f, 0.64710495963091119f, 1.0f}, -{0.66702037677816228f, 0.86599000384467506f, 0.64255286428296809f, 1.0f}, -{0.66234525182622073f, 0.86402153018069972f, 0.638000768935025f, 1.0f}, -{0.65767012687427917f, 0.86205305651672437f, 0.6334486735870819f, 1.0f}, -{0.65299500192233761f, 0.86008458285274891f, 0.62889657823913869f, 1.0f}, -{0.64831987697039595f, 0.85811610918877357f, 0.62434448289119571f, 1.0f}, -{0.64364475201845439f, 0.85614763552479811f, 0.6197923875432525f, 1.0f}, -{0.63896962706651284f, 0.85417916186082277f, 0.61524029219530951f, 1.0f}, -{0.63429450211457128f, 0.85221068819684731f, 0.6106881968473663f, 1.0f}, -{0.62929642445213374f, 0.85001153402537488f, 0.60613610149942321f, 1.0f}, -{0.62376009227220297f, 0.84742791234140713f, 0.60158400615148011f, 1.0f}, -{0.61822376009227231f, 0.84484429065743949f, 0.59703191080353712f, 1.0f}, -{0.61268742791234143f, 0.84226066897347174f, 0.59247981545559392f, 1.0f}, -{0.60715109573241055f, 0.83967704728950399f, 0.58792772010765082f, 1.0f}, -{0.60161476355247978f, 0.83709342560553635f, 0.58337562475970772f, 1.0f}, -{0.59607843137254901f, 0.83450980392156859f, 0.57882352941176463f, 1.0f}, -{0.59054209919261824f, 0.83192618223760095f, 0.57427143406382153f, 1.0f}, -{0.58500576701268736f, 0.8293425605536332f, 0.56971933871587843f, 1.0f}, -{0.57946943483275659f, 0.82675893886966556f, 0.56516724336793533f, 1.0f}, -{0.57393310265282593f, 0.82417531718569781f, 0.56061514801999235f, 1.0f}, -{0.56839677047289505f, 0.82159169550173006f, 0.55606305267204914f, 1.0f}, -{0.56286043829296428f, 0.81900807381776242f, 0.55151095732410604f, 1.0f}, -{0.5573241061130334f, 0.81642445213379466f, 0.54695886197616295f, 1.0f}, -{0.55178777393310263f, 0.81384083044982702f, 0.54240676662821985f, 1.0f}, -{0.54625144175317186f, 0.81125720876585927f, 0.53785467128027675f, 1.0f}, -{0.54071510957324109f, 0.80867358708189163f, 0.53330257593233377f, 1.0f}, -{0.53517877739331021f, 0.80608996539792388f, 0.52875048058439056f, 1.0f}, -{0.52964244521337955f, 0.80350634371395624f, 0.52419838523644757f, 1.0f}, -{0.52410611303344867f, 0.80092272202998849f, 0.51964628988850436f, 1.0f}, -{0.5185697808535179f, 0.79833910034602074f, 0.51509419454056138f, 1.0f}, -{0.51303344867358702f, 0.7957554786620531f, 0.51054209919261817f, 1.0f}, -{0.50749711649365625f, 0.79317185697808534f, 0.50599000384467518f, 1.0f}, -{0.50196078431372548f, 0.7905882352941177f, 0.50143790849673198f, 1.0f}, -{0.49642445213379471f, 0.78800461361014995f, 0.49688581314878894f, 1.0f}, -{0.49088811995386389f, 0.78542099192618231f, 0.49233371780084584f, 1.0f}, -{0.48535178777393317f, 0.78283737024221456f, 0.4877816224529028f, 1.0f}, -{0.47981545559400229f, 0.78025374855824681f, 0.48322952710495964f, 1.0f}, -{0.47427912341407152f, 0.77767012687427917f, 0.47867743175701655f, 1.0f}, -{0.46874279123414075f, 0.77508650519031141f, 0.47412533640907345f, 1.0f}, -{0.46320645905420993f, 0.77250288350634377f, 0.46957324106113035f, 1.0f}, -{0.4576701268742791f, 0.76991926182237602f, 0.46502114571318726f, 1.0f}, -{0.45176470588235296f, 0.76708958093041146f, 0.46120722798923491f, 1.0f}, -{0.44549019607843138f, 0.76401384083044988f, 0.45813148788927338f, 1.0f}, -{0.4392156862745098f, 0.76093810073048829f, 0.45505574778931185f, 1.0f}, -{0.43294117647058822f, 0.75786236063052681f, 0.45198000768935026f, 1.0f}, -{0.42666666666666686f, 0.75478662053056533f, 0.44890426758938878f, 1.0f}, -{0.42039215686274511f, 0.75171088043060363f, 0.44582852748942714f, 1.0f}, -{0.41411764705882353f, 0.74863514033064205f, 0.44275278738946561f, 1.0f}, -{0.40784313725490196f, 0.74555940023068057f, 0.43967704728950407f, 1.0f}, -{0.40156862745098038f, 0.74248366013071898f, 0.43660130718954249f, 1.0f}, -{0.3952941176470588f, 0.73940792003075739f, 0.43352556708958095f, 1.0f}, -{0.38901960784313727f, 0.7363321799307958f, 0.43044982698961937f, 1.0f}, -{0.38274509803921569f, 0.73325643983083433f, 0.42737408688965783f, 1.0f}, -{0.37647058823529411f, 0.73018069973087274f, 0.42429834678969625f, 1.0f}, -{0.37019607843137253f, 0.72710495963091115f, 0.42122260668973471f, 1.0f}, -{0.36392156862745095f, 0.72402921953094967f, 0.41814686658977318f, 1.0f}, -{0.35764705882352943f, 0.72095347943098809f, 0.41507112648981159f, 1.0f}, -{0.35137254901960779f, 0.7178777393310265f, 0.41199538638985006f, 1.0f}, -{0.34509803921568627f, 0.71480199923106491f, 0.40891964628988853f, 1.0f}, -{0.33882352941176469f, 0.71172625913110343f, 0.40584390618992694f, 1.0f}, -{0.33254901960784311f, 0.70865051903114185f, 0.40276816608996541f, 1.0f}, -{0.3262745098039217f, 0.70557477893118037f, 0.39969242599000393f, 1.0f}, -{0.31999999999999995f, 0.70249903883121878f, 0.39661668589004229f, 1.0f}, -{0.31372549019607843f, 0.69942329873125719f, 0.3935409457900807f, 1.0f}, -{0.30745098039215685f, 0.6963475586312956f, 0.39046520569011917f, 1.0f}, -{0.30117647058823527f, 0.69327181853133402f, 0.38738946559015763f, 1.0f}, -{0.29490196078431369f, 0.69019607843137254f, 0.38431372549019605f, 1.0f}, -{0.28862745098039211f, 0.68712033833141095f, 0.38123798539023451f, 1.0f}, -{0.28235294117647058f, 0.68404459823144936f, 0.37816224529027298f, 1.0f}, -{0.276078431372549f, 0.68096885813148789f, 0.37508650519031139f, 1.0f}, -{0.26980392156862743f, 0.6778931180315263f, 0.37201076509034986f, 1.0f}, -{0.26352941176470585f, 0.67481737793156471f, 0.36893502499038827f, 1.0f}, -{0.25725490196078427f, 0.67174163783160323f, 0.36585928489042674f, 1.0f}, -{0.25259515570934254f, 0.6681276432141483f, 0.36286043829296422f, 1.0f}, -{0.24890426758938869f, 0.66419069588619761f, 0.35990772779700114f, 1.0f}, -{0.24521337946943481f, 0.66025374855824681f, 0.35695501730103807f, 1.0f}, -{0.24152249134948095f, 0.65631680123029601f, 0.35400230680507494f, 1.0f}, -{0.23783160322952721f, 0.65237985390234532f, 0.35104959630911192f, 1.0f}, -{0.23414071510957324f, 0.64844290657439441f, 0.34809688581314879f, 1.0f}, -{0.23044982698961936f, 0.6445059592464436f, 0.34514417531718566f, 1.0f}, -{0.2267589388696655f, 0.6405690119184928f, 0.34219146482122259f, 1.0f}, -{0.22306805074971164f, 0.636632064590542f, 0.33923875432525952f, 1.0f}, -{0.21937716262975779f, 0.63269511726259131f, 0.33628604382929639f, 1.0f}, -{0.21568627450980393f, 0.62875816993464051f, 0.33333333333333331f, 1.0f}, -{0.21199538638985005f, 0.62482122260668971f, 0.33038062283737024f, 1.0f}, -{0.20830449826989619f, 0.62088427527873891f, 0.32742791234140711f, 1.0f}, -{0.20461361014994234f, 0.6169473279507881f, 0.32447520184544404f, 1.0f}, -{0.20092272202998845f, 0.6130103806228373f, 0.32152249134948097f, 1.0f}, -{0.1972318339100346f, 0.6090734332948865f, 0.31856978085351784f, 1.0f}, -{0.19354094579008074f, 0.6051364859669357f, 0.31561707035755476f, 1.0f}, -{0.18985005767012686f, 0.60119953863898501f, 0.31266435986159169f, 1.0f}, -{0.186159169550173f, 0.59726259131103421f, 0.30971164936562856f, 1.0f}, -{0.18246828143021915f, 0.59332564398308341f, 0.30675893886966549f, 1.0f}, -{0.17877739331026538f, 0.58938869665513272f, 0.30380622837370247f, 1.0f}, -{0.17508650519031144f, 0.5854517493271818f, 0.30085351787773928f, 1.0f}, -{0.17139561707035755f, 0.581514801999231f, 0.29790080738177621f, 1.0f}, -{0.1677047289504037f, 0.5775778546712802f, 0.29494809688581314f, 1.0f}, -{0.16401384083044984f, 0.5736409073433294f, 0.29199538638985001f, 1.0f}, -{0.16032295271049596f, 0.5697039600153786f, 0.28904267589388694f, 1.0f}, -{0.1566320645905421f, 0.56576701268742791f, 0.28608996539792386f, 1.0f}, -{0.15294117647058825f, 0.5618300653594771f, 0.28313725490196073f, 1.0f}, -{0.14925028835063436f, 0.5578931180315263f, 0.28018454440599766f, 1.0f}, -{0.14555940023068051f, 0.5539561707035755f, 0.27723183391003459f, 1.0f}, -{0.14186851211072665f, 0.5500192233756247f, 0.27427912341407146f, 1.0f}, -{0.13817762399077277f, 0.5460822760476739f, 0.27132641291810838f, 1.0f}, -{0.13402537485582469f, 0.54232987312572078f, 0.26828143021914647f, 1.0f}, -{0.12971933871587851f, 0.53863898500576701f, 0.26520569011918493f, 1.0f}, -{0.12541330257593233f, 0.53494809688581313f, 0.26212995001922335f, 1.0f}, -{0.12110726643598617f, 0.53125720876585925f, 0.25905420991926181f, 1.0f}, -{0.11680123029604011f, 0.52756632064590547f, 0.25597846981930034f, 1.0f}, -{0.11249519415609383f, 0.52387543252595148f, 0.25290272971933869f, 1.0f}, -{0.10818915801614765f, 0.5201845444059976f, 0.24982698961937716f, 1.0f}, -{0.10388312187620147f, 0.51649365628604382f, 0.2467512495194156f, 1.0f}, -{0.099577085736255289f, 0.51280276816608994f, 0.24367550941945404f, 1.0f}, -{0.09527104959630911f, 0.50911188004613606f, 0.24059976931949248f, 1.0f}, -{0.090965013456362945f, 0.50542099192618217f, 0.23752402921953092f, 1.0f}, -{0.086658977316416766f, 0.50173010380622829f, 0.23444828911956939f, 1.0f}, -{0.082352941176470601f, 0.49803921568627446f, 0.23137254901960783f, 1.0f}, -{0.078046905036524422f, 0.49434832756632063f, 0.22829680891964627f, 1.0f}, -{0.073740868896578243f, 0.49065743944636675f, 0.22522106881968473f, 1.0f}, -{0.069434832756632064f, 0.48696655132641287f, 0.22214532871972317f, 1.0f}, -{0.065128796616685899f, 0.48327566320645904f, 0.21906958861976161f, 1.0f}, -{0.060822760476739721f, 0.47958477508650516f, 0.21599384851980008f, 1.0f}, -{0.056516724336793542f, 0.47589388696655127f, 0.21291810841983852f, 1.0f}, -{0.052210688196847363f, 0.47220299884659744f, 0.20984236831987696f, 1.0f}, -{0.047904652056901309f, 0.46851211072664367f, 0.20676662821991548f, 1.0f}, -{0.043598615916955019f, 0.46482122260668968f, 0.20369088811995384f, 1.0f}, -{0.03929257977700884f, 0.46113033448673585f, 0.20061514801999231f, 1.0f}, -{0.034986543637062675f, 0.45743944636678197f, 0.19753940792003075f, 1.0f}, -{0.030680507497116496f, 0.45374855824682814f, 0.19446366782006919f, 1.0f}, -{0.026374471357170318f, 0.45005767012687425f, 0.19138792772010765f, 1.0f}, -{0.022068435217224139f, 0.44636678200692037f, 0.18831218762014609f, 1.0f}, -{0.017762399077277974f, 0.44267589388696654f, 0.18523644752018453f, 1.0f}, -{0.013456362937331795f, 0.43898500576701266f, 0.182160707420223f, 1.0f}, -{0.0091503267973856162f, 0.43529411764705883f, 0.17908496732026141f, 1.0f}, -{0.0048442906574394373f, 0.43160322952710495f, 0.17600922722029988f, 1.0f}, -{0.00053825451749325848f, 0.42791234140715106f, 0.17293348712033835f, 1.0f}, -{0.0f, 0.42303729334871204f, 0.170718954248366f, 1.0f}, -{0.0f, 0.41799307958477505f, 0.16862745098039217f, 1.0f}, -{0.0f, 0.41294886582083812f, 0.16653594771241831f, 1.0f}, -{0.0f, 0.40790465205690118f, 0.16444444444444445f, 1.0f}, -{0.0f, 0.40286043829296436f, 0.16235294117647064f, 1.0f}, -{0.0f, 0.39781622452902726f, 0.16026143790849673f, 1.0f}, -{0.0f, 0.39277201076509033f, 0.15816993464052287f, 1.0f}, -{0.0f, 0.3877277970011534f, 0.15607843137254901f, 1.0f}, -{0.0f, 0.38268358323721646f, 0.15398692810457515f, 1.0f}, -{0.0f, 0.37763936947327947f, 0.15189542483660129f, 1.0f}, -{0.0f, 0.37259515570934254f, 0.14980392156862746f, 1.0f}, -{0.0f, 0.36755094194540561f, 0.1477124183006536f, 1.0f}, -{0.0f, 0.36250672818146867f, 0.14562091503267974f, 1.0f}, -{0.0f, 0.35746251441753168f, 0.14352941176470588f, 1.0f}, -{0.0f, 0.35241830065359475f, 0.14143790849673202f, 1.0f}, -{0.0f, 0.34737408688965782f, 0.13934640522875816f, 1.0f}, -{0.0f, 0.34232987312572088f, 0.13725490196078433f, 1.0f}, -{0.0f, 0.3372856593617839f, 0.13516339869281047f, 1.0f}, -{0.0f, 0.33224144559784696f, 0.13307189542483661f, 1.0f}, -{0.0f, 0.32719723183391003f, 0.13098039215686275f, 1.0f}, -{0.0f, 0.32215301806997321f, 0.12888888888888894f, 1.0f}, -{0.0f, 0.31710880430603616f, 0.12679738562091503f, 1.0f}, -{0.0f, 0.31206459054209917f, 0.12470588235294117f, 1.0f}, -{0.0f, 0.30702037677816224f, 0.12261437908496732f, 1.0f}, -{0.0f, 0.30197616301422525f, 0.12052287581699346f, 1.0f}, -{0.0f, 0.29693194925028832f, 0.11843137254901961f, 1.0f}, -{0.0f, 0.29188773548635139f, 0.11633986928104575f, 1.0f}, -{0.0f, 0.28684352172241445f, 0.11424836601307189f, 1.0f}, -{0.0f, 0.28179930795847752f, 0.11215686274509803f, 1.0f}, -{0.0f, 0.27675509419454059f, 0.11006535947712418f, 1.0f}, -{0.0f, 0.2717108804306036f, 0.10797385620915033f, 1.0f}, -{0.0f, 0.26666666666666666f, 0.10588235294117647f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential/Greens.txt b/extern/tfn/colormaps/sequential/Greens.txt deleted file mode 100644 index e25b7ec..0000000 --- a/extern/tfn/colormaps/sequential/Greens.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.96862745098039216, 0.9882352941176471, 0.96078431372549022, 1.0) -(0.96641291810841989, 0.98737408688965789, 0.95820069204152247, 1.0) -(0.96419838523644752, 0.98651287966166867, 0.95561707035755483, 1.0) -(0.96198385236447526, 0.98565167243367935, 0.95303344867358708, 1.0) -(0.95976931949250288, 0.98479046520569014, 0.95044982698961944, 1.0) -(0.95755478662053062, 0.98392925797770092, 0.94786620530565169, 1.0) -(0.95534025374855824, 0.98306805074971171, 0.94528258362168394, 1.0) -(0.95312572087658598, 0.98220684352172249, 0.9426989619377163, 1.0) -(0.95091118800461361, 0.98134563629373317, 0.94011534025374854, 1.0) -(0.94869665513264134, 0.98048442906574396, 0.9375317185697809, 1.0) -(0.94648212226066897, 0.97962322183775474, 0.93494809688581315, 1.0) -(0.9442675893886967, 0.97876201460976553, 0.93236447520184551, 1.0) -(0.94205305651672433, 0.97790080738177632, 0.92978085351787776, 1.0) -(0.93983852364475207, 0.97703960015378699, 0.92719723183391001, 1.0) -(0.93762399077277969, 0.97617839292579778, 0.92461361014994237, 1.0) -(0.93540945790080743, 0.97531718569780856, 0.92202998846597461, 1.0) -(0.93319492502883505, 0.97445597846981935, 0.91944636678200697, 1.0) -(0.93098039215686279, 0.97359477124183014, 0.91686274509803922, 1.0) -(0.92876585928489042, 0.97273356401384081, 0.91427912341407147, 1.0) -(0.92655132641291815, 0.9718723567858516, 0.91169550173010383, 1.0) -(0.92433679354094578, 0.97101114955786239, 0.90911188004613608, 1.0) -(0.92212226066897351, 0.97014994232987317, 0.90652825836216844, 1.0) -(0.91990772779700114, 0.96928873510188396, 0.90394463667820069, 1.0) -(0.91769319492502888, 0.96842752787389474, 0.90136101499423305, 1.0) -(0.9154786620530565, 0.96756632064590542, 0.89877739331026529, 1.0) -(0.91326412918108424, 0.96670511341791621, 0.89619377162629754, 1.0) -(0.91104959630911186, 0.96584390618992699, 0.8936101499423299, 1.0) -(0.9088350634371396, 0.96498269896193778, 0.89102652825836215, 1.0) -(0.90662053056516723, 0.96412149173394845, 0.8884429065743944, 1.0) -(0.90440599769319496, 0.96326028450595924, 0.88585928489042676, 1.0) -(0.90219146482122259, 0.96239907727797003, 0.88327566320645901, 1.0) -(0.89997693194925033, 0.96153787004998081, 0.88069204152249136, 1.0) -(0.89757785467128026, 0.96059976931949254, 0.87793925413302576, 1.0) -(0.89388696655132649, 0.95912341407151103, 0.87400230680507496, 1.0) -(0.89019607843137261, 0.95764705882352941, 0.87006535947712416, 1.0) -(0.88650519031141872, 0.9561707035755479, 0.86612841214917335, 1.0) -(0.88281430219146484, 0.95469434832756639, 0.86219146482122255, 1.0) -(0.87912341407151096, 0.95321799307958477, 0.85825451749327186, 1.0) -(0.87543252595155707, 0.95174163783160326, 0.85431757016532106, 1.0) -(0.8717416378316033, 0.95026528258362175, 0.85038062283737026, 1.0) -(0.86805074971164942, 0.94878892733564013, 0.84644367550941946, 1.0) -(0.86435986159169553, 0.94731257208765862, 0.84250672818146866, 1.0) -(0.86066897347174165, 0.94583621683967711, 0.83856978085351785, 1.0) -(0.85697808535178777, 0.94435986159169549, 0.83463283352556705, 1.0) -(0.85328719723183388, 0.94288350634371398, 0.83069588619761625, 1.0) -(0.84959630911188011, 0.94140715109573248, 0.82675893886966556, 1.0) -(0.84590542099192623, 0.93993079584775086, 0.82282199154171476, 1.0) -(0.84221453287197234, 0.93845444059976935, 0.81888504421376396, 1.0) -(0.83852364475201846, 0.93697808535178773, 0.81494809688581316, 1.0) -(0.83483275663206458, 0.93550173010380622, 0.81101114955786235, 1.0) -(0.8311418685121108, 0.93402537485582471, 0.80707420222991155, 1.0) -(0.82745098039215692, 0.93254901960784309, 0.80313725490196075, 1.0) -(0.82376009227220304, 0.93107266435986158, 0.79920030757400995, 1.0) -(0.82006920415224915, 0.92959630911188007, 0.79526336024605926, 1.0) -(0.81637831603229527, 0.92811995386389845, 0.79132641291810846, 1.0) -(0.81268742791234139, 0.92664359861591694, 0.78738946559015766, 1.0) -(0.8089965397923875, 0.92516724336793543, 0.78345251826220685, 1.0) -(0.80530565167243373, 0.92369088811995381, 0.77951557093425605, 1.0) -(0.80161476355247985, 0.9222145328719723, 0.77557862360630525, 1.0) -(0.79792387543252596, 0.92073817762399079, 0.77164167627835445, 1.0) -(0.79423298731257208, 0.91926182237600917, 0.76770472895040365, 1.0) -(0.7905420991926182, 0.91778546712802767, 0.76376778162245296, 1.0) -(0.78685121107266442, 0.91630911188004616, 0.75983083429450216, 1.0) -(0.78316032295271054, 0.91483275663206454, 0.75589388696655135, 1.0) -(0.77922337562475974, 0.91323337178008457, 0.75180315263360242, 1.0) -(0.77454825067281818, 0.91126489811610911, 0.74725105728565933, 1.0) -(0.76987312572087663, 0.90929642445213377, 0.74269896193771634, 1.0) -(0.76519800076893507, 0.90732795078815842, 0.73814686658977313, 1.0) -(0.76052287581699352, 0.90535947712418297, 0.73359477124183003, 1.0) -(0.75584775086505185, 0.90339100346020762, 0.72904267589388694, 1.0) -(0.75117262591311029, 0.90142252979623216, 0.72449058054594384, 1.0) -(0.74649750096116874, 0.89945405613225682, 0.71993848519800074, 1.0) -(0.74182237600922718, 0.89748558246828136, 0.71538638985005765, 1.0) -(0.73714725105728562, 0.89551710880430602, 0.71083429450211455, 1.0) -(0.73247212610534418, 0.89354863514033067, 0.70628219915417145, 1.0) -(0.72779700115340251, 0.89158016147635522, 0.70173010380622836, 1.0) -(0.72312187620146096, 0.88961168781237987, 0.69717800845828526, 1.0) -(0.7184467512495194, 0.88764321414840441, 0.69262591311034216, 1.0) -(0.71377162629757784, 0.88567474048442907, 0.68807381776239906, 1.0) -(0.70909650134563629, 0.88370626682045361, 0.68352172241445597, 1.0) -(0.70442137639369473, 0.88173779315647827, 0.67896962706651287, 1.0) -(0.69974625144175318, 0.87976931949250281, 0.67441753171856977, 1.0) -(0.69507112648981173, 0.87780084582852747, 0.66986543637062668, 1.0) -(0.69039600153787006, 0.87583237216455212, 0.66531334102268358, 1.0) -(0.68572087658592851, 0.87386389850057666, 0.66076124567474048, 1.0) -(0.68104575163398695, 0.87189542483660132, 0.65620915032679739, 1.0) -(0.67637062668204539, 0.86992695117262586, 0.65165705497885429, 1.0) -(0.67169550173010384, 0.86795847750865052, 0.64710495963091119, 1.0) -(0.66702037677816228, 0.86599000384467506, 0.64255286428296809, 1.0) -(0.66234525182622073, 0.86402153018069972, 0.638000768935025, 1.0) -(0.65767012687427917, 0.86205305651672437, 0.6334486735870819, 1.0) -(0.65299500192233761, 0.86008458285274891, 0.62889657823913869, 1.0) -(0.64831987697039595, 0.85811610918877357, 0.62434448289119571, 1.0) -(0.64364475201845439, 0.85614763552479811, 0.6197923875432525, 1.0) -(0.63896962706651284, 0.85417916186082277, 0.61524029219530951, 1.0) -(0.63429450211457128, 0.85221068819684731, 0.6106881968473663, 1.0) -(0.62929642445213374, 0.85001153402537488, 0.60613610149942321, 1.0) -(0.62376009227220297, 0.84742791234140713, 0.60158400615148011, 1.0) -(0.61822376009227231, 0.84484429065743949, 0.59703191080353712, 1.0) -(0.61268742791234143, 0.84226066897347174, 0.59247981545559392, 1.0) -(0.60715109573241055, 0.83967704728950399, 0.58792772010765082, 1.0) -(0.60161476355247978, 0.83709342560553635, 0.58337562475970772, 1.0) -(0.59607843137254901, 0.83450980392156859, 0.57882352941176463, 1.0) -(0.59054209919261824, 0.83192618223760095, 0.57427143406382153, 1.0) -(0.58500576701268736, 0.8293425605536332, 0.56971933871587843, 1.0) -(0.57946943483275659, 0.82675893886966556, 0.56516724336793533, 1.0) -(0.57393310265282593, 0.82417531718569781, 0.56061514801999235, 1.0) -(0.56839677047289505, 0.82159169550173006, 0.55606305267204914, 1.0) -(0.56286043829296428, 0.81900807381776242, 0.55151095732410604, 1.0) -(0.5573241061130334, 0.81642445213379466, 0.54695886197616295, 1.0) -(0.55178777393310263, 0.81384083044982702, 0.54240676662821985, 1.0) -(0.54625144175317186, 0.81125720876585927, 0.53785467128027675, 1.0) -(0.54071510957324109, 0.80867358708189163, 0.53330257593233377, 1.0) -(0.53517877739331021, 0.80608996539792388, 0.52875048058439056, 1.0) -(0.52964244521337955, 0.80350634371395624, 0.52419838523644757, 1.0) -(0.52410611303344867, 0.80092272202998849, 0.51964628988850436, 1.0) -(0.5185697808535179, 0.79833910034602074, 0.51509419454056138, 1.0) -(0.51303344867358702, 0.7957554786620531, 0.51054209919261817, 1.0) -(0.50749711649365625, 0.79317185697808534, 0.50599000384467518, 1.0) -(0.50196078431372548, 0.7905882352941177, 0.50143790849673198, 1.0) -(0.49642445213379471, 0.78800461361014995, 0.49688581314878894, 1.0) -(0.49088811995386389, 0.78542099192618231, 0.49233371780084584, 1.0) -(0.48535178777393317, 0.78283737024221456, 0.4877816224529028, 1.0) -(0.47981545559400229, 0.78025374855824681, 0.48322952710495964, 1.0) -(0.47427912341407152, 0.77767012687427917, 0.47867743175701655, 1.0) -(0.46874279123414075, 0.77508650519031141, 0.47412533640907345, 1.0) -(0.46320645905420993, 0.77250288350634377, 0.46957324106113035, 1.0) -(0.4576701268742791, 0.76991926182237602, 0.46502114571318726, 1.0) -(0.45176470588235296, 0.76708958093041146, 0.46120722798923491, 1.0) -(0.44549019607843138, 0.76401384083044988, 0.45813148788927338, 1.0) -(0.4392156862745098, 0.76093810073048829, 0.45505574778931185, 1.0) -(0.43294117647058822, 0.75786236063052681, 0.45198000768935026, 1.0) -(0.42666666666666686, 0.75478662053056533, 0.44890426758938878, 1.0) -(0.42039215686274511, 0.75171088043060363, 0.44582852748942714, 1.0) -(0.41411764705882353, 0.74863514033064205, 0.44275278738946561, 1.0) -(0.40784313725490196, 0.74555940023068057, 0.43967704728950407, 1.0) -(0.40156862745098038, 0.74248366013071898, 0.43660130718954249, 1.0) -(0.3952941176470588, 0.73940792003075739, 0.43352556708958095, 1.0) -(0.38901960784313727, 0.7363321799307958, 0.43044982698961937, 1.0) -(0.38274509803921569, 0.73325643983083433, 0.42737408688965783, 1.0) -(0.37647058823529411, 0.73018069973087274, 0.42429834678969625, 1.0) -(0.37019607843137253, 0.72710495963091115, 0.42122260668973471, 1.0) -(0.36392156862745095, 0.72402921953094967, 0.41814686658977318, 1.0) -(0.35764705882352943, 0.72095347943098809, 0.41507112648981159, 1.0) -(0.35137254901960779, 0.7178777393310265, 0.41199538638985006, 1.0) -(0.34509803921568627, 0.71480199923106491, 0.40891964628988853, 1.0) -(0.33882352941176469, 0.71172625913110343, 0.40584390618992694, 1.0) -(0.33254901960784311, 0.70865051903114185, 0.40276816608996541, 1.0) -(0.3262745098039217, 0.70557477893118037, 0.39969242599000393, 1.0) -(0.31999999999999995, 0.70249903883121878, 0.39661668589004229, 1.0) -(0.31372549019607843, 0.69942329873125719, 0.3935409457900807, 1.0) -(0.30745098039215685, 0.6963475586312956, 0.39046520569011917, 1.0) -(0.30117647058823527, 0.69327181853133402, 0.38738946559015763, 1.0) -(0.29490196078431369, 0.69019607843137254, 0.38431372549019605, 1.0) -(0.28862745098039211, 0.68712033833141095, 0.38123798539023451, 1.0) -(0.28235294117647058, 0.68404459823144936, 0.37816224529027298, 1.0) -(0.276078431372549, 0.68096885813148789, 0.37508650519031139, 1.0) -(0.26980392156862743, 0.6778931180315263, 0.37201076509034986, 1.0) -(0.26352941176470585, 0.67481737793156471, 0.36893502499038827, 1.0) -(0.25725490196078427, 0.67174163783160323, 0.36585928489042674, 1.0) -(0.25259515570934254, 0.6681276432141483, 0.36286043829296422, 1.0) -(0.24890426758938869, 0.66419069588619761, 0.35990772779700114, 1.0) -(0.24521337946943481, 0.66025374855824681, 0.35695501730103807, 1.0) -(0.24152249134948095, 0.65631680123029601, 0.35400230680507494, 1.0) -(0.23783160322952721, 0.65237985390234532, 0.35104959630911192, 1.0) -(0.23414071510957324, 0.64844290657439441, 0.34809688581314879, 1.0) -(0.23044982698961936, 0.6445059592464436, 0.34514417531718566, 1.0) -(0.2267589388696655, 0.6405690119184928, 0.34219146482122259, 1.0) -(0.22306805074971164, 0.636632064590542, 0.33923875432525952, 1.0) -(0.21937716262975779, 0.63269511726259131, 0.33628604382929639, 1.0) -(0.21568627450980393, 0.62875816993464051, 0.33333333333333331, 1.0) -(0.21199538638985005, 0.62482122260668971, 0.33038062283737024, 1.0) -(0.20830449826989619, 0.62088427527873891, 0.32742791234140711, 1.0) -(0.20461361014994234, 0.6169473279507881, 0.32447520184544404, 1.0) -(0.20092272202998845, 0.6130103806228373, 0.32152249134948097, 1.0) -(0.1972318339100346, 0.6090734332948865, 0.31856978085351784, 1.0) -(0.19354094579008074, 0.6051364859669357, 0.31561707035755476, 1.0) -(0.18985005767012686, 0.60119953863898501, 0.31266435986159169, 1.0) -(0.186159169550173, 0.59726259131103421, 0.30971164936562856, 1.0) -(0.18246828143021915, 0.59332564398308341, 0.30675893886966549, 1.0) -(0.17877739331026538, 0.58938869665513272, 0.30380622837370247, 1.0) -(0.17508650519031144, 0.5854517493271818, 0.30085351787773928, 1.0) -(0.17139561707035755, 0.581514801999231, 0.29790080738177621, 1.0) -(0.1677047289504037, 0.5775778546712802, 0.29494809688581314, 1.0) -(0.16401384083044984, 0.5736409073433294, 0.29199538638985001, 1.0) -(0.16032295271049596, 0.5697039600153786, 0.28904267589388694, 1.0) -(0.1566320645905421, 0.56576701268742791, 0.28608996539792386, 1.0) -(0.15294117647058825, 0.5618300653594771, 0.28313725490196073, 1.0) -(0.14925028835063436, 0.5578931180315263, 0.28018454440599766, 1.0) -(0.14555940023068051, 0.5539561707035755, 0.27723183391003459, 1.0) -(0.14186851211072665, 0.5500192233756247, 0.27427912341407146, 1.0) -(0.13817762399077277, 0.5460822760476739, 0.27132641291810838, 1.0) -(0.13402537485582469, 0.54232987312572078, 0.26828143021914647, 1.0) -(0.12971933871587851, 0.53863898500576701, 0.26520569011918493, 1.0) -(0.12541330257593233, 0.53494809688581313, 0.26212995001922335, 1.0) -(0.12110726643598617, 0.53125720876585925, 0.25905420991926181, 1.0) -(0.11680123029604011, 0.52756632064590547, 0.25597846981930034, 1.0) -(0.11249519415609383, 0.52387543252595148, 0.25290272971933869, 1.0) -(0.10818915801614765, 0.5201845444059976, 0.24982698961937716, 1.0) -(0.10388312187620147, 0.51649365628604382, 0.2467512495194156, 1.0) -(0.099577085736255289, 0.51280276816608994, 0.24367550941945404, 1.0) -(0.09527104959630911, 0.50911188004613606, 0.24059976931949248, 1.0) -(0.090965013456362945, 0.50542099192618217, 0.23752402921953092, 1.0) -(0.086658977316416766, 0.50173010380622829, 0.23444828911956939, 1.0) -(0.082352941176470601, 0.49803921568627446, 0.23137254901960783, 1.0) -(0.078046905036524422, 0.49434832756632063, 0.22829680891964627, 1.0) -(0.073740868896578243, 0.49065743944636675, 0.22522106881968473, 1.0) -(0.069434832756632064, 0.48696655132641287, 0.22214532871972317, 1.0) -(0.065128796616685899, 0.48327566320645904, 0.21906958861976161, 1.0) -(0.060822760476739721, 0.47958477508650516, 0.21599384851980008, 1.0) -(0.056516724336793542, 0.47589388696655127, 0.21291810841983852, 1.0) -(0.052210688196847363, 0.47220299884659744, 0.20984236831987696, 1.0) -(0.047904652056901309, 0.46851211072664367, 0.20676662821991548, 1.0) -(0.043598615916955019, 0.46482122260668968, 0.20369088811995384, 1.0) -(0.03929257977700884, 0.46113033448673585, 0.20061514801999231, 1.0) -(0.034986543637062675, 0.45743944636678197, 0.19753940792003075, 1.0) -(0.030680507497116496, 0.45374855824682814, 0.19446366782006919, 1.0) -(0.026374471357170318, 0.45005767012687425, 0.19138792772010765, 1.0) -(0.022068435217224139, 0.44636678200692037, 0.18831218762014609, 1.0) -(0.017762399077277974, 0.44267589388696654, 0.18523644752018453, 1.0) -(0.013456362937331795, 0.43898500576701266, 0.182160707420223, 1.0) -(0.0091503267973856162, 0.43529411764705883, 0.17908496732026141, 1.0) -(0.0048442906574394373, 0.43160322952710495, 0.17600922722029988, 1.0) -(0.00053825451749325848, 0.42791234140715106, 0.17293348712033835, 1.0) -(0.0, 0.42303729334871204, 0.170718954248366, 1.0) -(0.0, 0.41799307958477505, 0.16862745098039217, 1.0) -(0.0, 0.41294886582083812, 0.16653594771241831, 1.0) -(0.0, 0.40790465205690118, 0.16444444444444445, 1.0) -(0.0, 0.40286043829296436, 0.16235294117647064, 1.0) -(0.0, 0.39781622452902726, 0.16026143790849673, 1.0) -(0.0, 0.39277201076509033, 0.15816993464052287, 1.0) -(0.0, 0.3877277970011534, 0.15607843137254901, 1.0) -(0.0, 0.38268358323721646, 0.15398692810457515, 1.0) -(0.0, 0.37763936947327947, 0.15189542483660129, 1.0) -(0.0, 0.37259515570934254, 0.14980392156862746, 1.0) -(0.0, 0.36755094194540561, 0.1477124183006536, 1.0) -(0.0, 0.36250672818146867, 0.14562091503267974, 1.0) -(0.0, 0.35746251441753168, 0.14352941176470588, 1.0) -(0.0, 0.35241830065359475, 0.14143790849673202, 1.0) -(0.0, 0.34737408688965782, 0.13934640522875816, 1.0) -(0.0, 0.34232987312572088, 0.13725490196078433, 1.0) -(0.0, 0.3372856593617839, 0.13516339869281047, 1.0) -(0.0, 0.33224144559784696, 0.13307189542483661, 1.0) -(0.0, 0.32719723183391003, 0.13098039215686275, 1.0) -(0.0, 0.32215301806997321, 0.12888888888888894, 1.0) -(0.0, 0.31710880430603616, 0.12679738562091503, 1.0) -(0.0, 0.31206459054209917, 0.12470588235294117, 1.0) -(0.0, 0.30702037677816224, 0.12261437908496732, 1.0) -(0.0, 0.30197616301422525, 0.12052287581699346, 1.0) -(0.0, 0.29693194925028832, 0.11843137254901961, 1.0) -(0.0, 0.29188773548635139, 0.11633986928104575, 1.0) -(0.0, 0.28684352172241445, 0.11424836601307189, 1.0) -(0.0, 0.28179930795847752, 0.11215686274509803, 1.0) -(0.0, 0.27675509419454059, 0.11006535947712418, 1.0) -(0.0, 0.2717108804306036, 0.10797385620915033, 1.0) -(0.0, 0.26666666666666666, 0.10588235294117647, 1.0) diff --git a/extern/tfn/colormaps/sequential/Greys.cpp b/extern/tfn/colormaps/sequential/Greys.cpp deleted file mode 100644 index 5b6fa2c..0000000 --- a/extern/tfn/colormaps/sequential/Greys.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential_Greys; -} -const std::vector colormap::data_sequential_Greys = /* NOLINT(cert-err58-cpp) */ -{ -{1.0f, 1.0f, 1.0f, 1.0f}, -{0.99815455594002311f, 0.99815455594002311f, 0.99815455594002311f, 1.0f}, -{0.99630911188004612f, 0.99630911188004612f, 0.99630911188004612f, 1.0f}, -{0.99446366782006923f, 0.99446366782006923f, 0.99446366782006923f, 1.0f}, -{0.99261822376009223f, 0.99261822376009223f, 0.99261822376009223f, 1.0f}, -{0.99077277970011535f, 0.99077277970011535f, 0.99077277970011535f, 1.0f}, -{0.98892733564013846f, 0.98892733564013846f, 0.98892733564013846f, 1.0f}, -{0.98708189158016146f, 0.98708189158016146f, 0.98708189158016146f, 1.0f}, -{0.98523644752018458f, 0.98523644752018458f, 0.98523644752018458f, 1.0f}, -{0.98339100346020758f, 0.98339100346020758f, 0.98339100346020758f, 1.0f}, -{0.98154555940023069f, 0.98154555940023069f, 0.98154555940023069f, 1.0f}, -{0.9797001153402537f, 0.9797001153402537f, 0.9797001153402537f, 1.0f}, -{0.97785467128027681f, 0.97785467128027681f, 0.97785467128027681f, 1.0f}, -{0.97600922722029992f, 0.97600922722029992f, 0.97600922722029992f, 1.0f}, -{0.97416378316032293f, 0.97416378316032293f, 0.97416378316032293f, 1.0f}, -{0.97231833910034604f, 0.97231833910034604f, 0.97231833910034604f, 1.0f}, -{0.97047289504036904f, 0.97047289504036904f, 0.97047289504036904f, 1.0f}, -{0.96862745098039216f, 0.96862745098039216f, 0.96862745098039216f, 1.0f}, -{0.96678200692041516f, 0.96678200692041516f, 0.96678200692041516f, 1.0f}, -{0.96493656286043827f, 0.96493656286043827f, 0.96493656286043827f, 1.0f}, -{0.96309111880046139f, 0.96309111880046139f, 0.96309111880046139f, 1.0f}, -{0.96124567474048439f, 0.96124567474048439f, 0.96124567474048439f, 1.0f}, -{0.9594002306805075f, 0.9594002306805075f, 0.9594002306805075f, 1.0f}, -{0.95755478662053051f, 0.95755478662053051f, 0.95755478662053051f, 1.0f}, -{0.95570934256055362f, 0.95570934256055362f, 0.95570934256055362f, 1.0f}, -{0.95386389850057673f, 0.95386389850057673f, 0.95386389850057673f, 1.0f}, -{0.95201845444059974f, 0.95201845444059974f, 0.95201845444059974f, 1.0f}, -{0.95017301038062285f, 0.95017301038062285f, 0.95017301038062285f, 1.0f}, -{0.94832756632064585f, 0.94832756632064585f, 0.94832756632064585f, 1.0f}, -{0.94648212226066897f, 0.94648212226066897f, 0.94648212226066897f, 1.0f}, -{0.94463667820069208f, 0.94463667820069208f, 0.94463667820069208f, 1.0f}, -{0.94279123414071508f, 0.94279123414071508f, 0.94279123414071508f, 1.0f}, -{0.94082276047673974f, 0.94082276047673974f, 0.94082276047673974f, 1.0f}, -{0.93799307958477507f, 0.93799307958477507f, 0.93799307958477507f, 1.0f}, -{0.9351633986928104f, 0.9351633986928104f, 0.9351633986928104f, 1.0f}, -{0.93233371780084584f, 0.93233371780084584f, 0.93233371780084584f, 1.0f}, -{0.92950403690888117f, 0.92950403690888117f, 0.92950403690888117f, 1.0f}, -{0.92667435601691661f, 0.92667435601691661f, 0.92667435601691661f, 1.0f}, -{0.92384467512495194f, 0.92384467512495194f, 0.92384467512495194f, 1.0f}, -{0.92101499423298727f, 0.92101499423298727f, 0.92101499423298727f, 1.0f}, -{0.91818531334102271f, 0.91818531334102271f, 0.91818531334102271f, 1.0f}, -{0.91535563244905804f, 0.91535563244905804f, 0.91535563244905804f, 1.0f}, -{0.91252595155709337f, 0.91252595155709337f, 0.91252595155709337f, 1.0f}, -{0.90969627066512881f, 0.90969627066512881f, 0.90969627066512881f, 1.0f}, -{0.90686658977316414f, 0.90686658977316414f, 0.90686658977316414f, 1.0f}, -{0.90403690888119959f, 0.90403690888119959f, 0.90403690888119959f, 1.0f}, -{0.90120722798923492f, 0.90120722798923492f, 0.90120722798923492f, 1.0f}, -{0.89837754709727025f, 0.89837754709727025f, 0.89837754709727025f, 1.0f}, -{0.89554786620530558f, 0.89554786620530558f, 0.89554786620530558f, 1.0f}, -{0.89271818531334102f, 0.89271818531334102f, 0.89271818531334102f, 1.0f}, -{0.88988850442137635f, 0.88988850442137635f, 0.88988850442137635f, 1.0f}, -{0.88705882352941179f, 0.88705882352941179f, 0.88705882352941179f, 1.0f}, -{0.88422914263744712f, 0.88422914263744712f, 0.88422914263744712f, 1.0f}, -{0.88139946174548256f, 0.88139946174548256f, 0.88139946174548256f, 1.0f}, -{0.87856978085351789f, 0.87856978085351789f, 0.87856978085351789f, 1.0f}, -{0.87574009996155322f, 0.87574009996155322f, 0.87574009996155322f, 1.0f}, -{0.87291041906958866f, 0.87291041906958866f, 0.87291041906958866f, 1.0f}, -{0.87008073817762399f, 0.87008073817762399f, 0.87008073817762399f, 1.0f}, -{0.86725105728565932f, 0.86725105728565932f, 0.86725105728565932f, 1.0f}, -{0.86442137639369476f, 0.86442137639369476f, 0.86442137639369476f, 1.0f}, -{0.86159169550173009f, 0.86159169550173009f, 0.86159169550173009f, 1.0f}, -{0.85876201460976542f, 0.85876201460976542f, 0.85876201460976542f, 1.0f}, -{0.85593233371780086f, 0.85593233371780086f, 0.85593233371780086f, 1.0f}, -{0.85310265282583619f, 0.85310265282583619f, 0.85310265282583619f, 1.0f}, -{0.85011918492887351f, 0.85011918492887351f, 0.85011918492887351f, 1.0f}, -{0.84667435601691654f, 0.84667435601691654f, 0.84667435601691654f, 1.0f}, -{0.84322952710495969f, 0.84322952710495969f, 0.84322952710495969f, 1.0f}, -{0.83978469819300272f, 0.83978469819300272f, 0.83978469819300272f, 1.0f}, -{0.83633986928104576f, 0.83633986928104576f, 0.83633986928104576f, 1.0f}, -{0.83289504036908879f, 0.83289504036908879f, 0.83289504036908879f, 1.0f}, -{0.82945021145713183f, 0.82945021145713183f, 0.82945021145713183f, 1.0f}, -{0.82600538254517497f, 0.82600538254517497f, 0.82600538254517497f, 1.0f}, -{0.82256055363321801f, 0.82256055363321801f, 0.82256055363321801f, 1.0f}, -{0.81911572472126104f, 0.81911572472126104f, 0.81911572472126104f, 1.0f}, -{0.81567089580930419f, 0.81567089580930419f, 0.81567089580930419f, 1.0f}, -{0.81222606689734711f, 0.81222606689734711f, 0.81222606689734711f, 1.0f}, -{0.80878123798539026f, 0.80878123798539026f, 0.80878123798539026f, 1.0f}, -{0.80533640907343329f, 0.80533640907343329f, 0.80533640907343329f, 1.0f}, -{0.80189158016147633f, 0.80189158016147633f, 0.80189158016147633f, 1.0f}, -{0.79844675124951947f, 0.79844675124951947f, 0.79844675124951947f, 1.0f}, -{0.79500192233756251f, 0.79500192233756251f, 0.79500192233756251f, 1.0f}, -{0.79155709342560554f, 0.79155709342560554f, 0.79155709342560554f, 1.0f}, -{0.78811226451364869f, 0.78811226451364869f, 0.78811226451364869f, 1.0f}, -{0.78466743560169161f, 0.78466743560169161f, 0.78466743560169161f, 1.0f}, -{0.78122260668973476f, 0.78122260668973476f, 0.78122260668973476f, 1.0f}, -{0.77777777777777779f, 0.77777777777777779f, 0.77777777777777779f, 1.0f}, -{0.77433294886582082f, 0.77433294886582082f, 0.77433294886582082f, 1.0f}, -{0.77088811995386397f, 0.77088811995386397f, 0.77088811995386397f, 1.0f}, -{0.76744329104190701f, 0.76744329104190701f, 0.76744329104190701f, 1.0f}, -{0.76399846212995004f, 0.76399846212995004f, 0.76399846212995004f, 1.0f}, -{0.76055363321799319f, 0.76055363321799319f, 0.76055363321799319f, 1.0f}, -{0.75710880430603611f, 0.75710880430603611f, 0.75710880430603611f, 1.0f}, -{0.75366397539407926f, 0.75366397539407926f, 0.75366397539407926f, 1.0f}, -{0.75021914648212229f, 0.75021914648212229f, 0.75021914648212229f, 1.0f}, -{0.74677431757016532f, 0.74677431757016532f, 0.74677431757016532f, 1.0f}, -{0.74332948865820847f, 0.74332948865820847f, 0.74332948865820847f, 1.0f}, -{0.73937716262975783f, 0.73937716262975783f, 0.73937716262975783f, 1.0f}, -{0.73457900807381782f, 0.73457900807381782f, 0.73457900807381782f, 1.0f}, -{0.7297808535178778f, 0.7297808535178778f, 0.7297808535178778f, 1.0f}, -{0.72498269896193779f, 0.72498269896193779f, 0.72498269896193779f, 1.0f}, -{0.72018454440599777f, 0.72018454440599777f, 0.72018454440599777f, 1.0f}, -{0.71538638985005765f, 0.71538638985005765f, 0.71538638985005765f, 1.0f}, -{0.71058823529411763f, 0.71058823529411763f, 0.71058823529411763f, 1.0f}, -{0.70579008073817762f, 0.70579008073817762f, 0.70579008073817762f, 1.0f}, -{0.7009919261822376f, 0.7009919261822376f, 0.7009919261822376f, 1.0f}, -{0.69619377162629759f, 0.69619377162629759f, 0.69619377162629759f, 1.0f}, -{0.69139561707035768f, 0.69139561707035768f, 0.69139561707035768f, 1.0f}, -{0.68659746251441756f, 0.68659746251441756f, 0.68659746251441756f, 1.0f}, -{0.68179930795847754f, 0.68179930795847754f, 0.68179930795847754f, 1.0f}, -{0.67700115340253753f, 0.67700115340253753f, 0.67700115340253753f, 1.0f}, -{0.67220299884659751f, 0.67220299884659751f, 0.67220299884659751f, 1.0f}, -{0.6674048442906575f, 0.6674048442906575f, 0.6674048442906575f, 1.0f}, -{0.66260668973471748f, 0.66260668973471748f, 0.66260668973471748f, 1.0f}, -{0.65780853517877746f, 0.65780853517877746f, 0.65780853517877746f, 1.0f}, -{0.65301038062283745f, 0.65301038062283745f, 0.65301038062283745f, 1.0f}, -{0.64821222606689743f, 0.64821222606689743f, 0.64821222606689743f, 1.0f}, -{0.64341407151095731f, 0.64341407151095731f, 0.64341407151095731f, 1.0f}, -{0.63861591695501729f, 0.63861591695501729f, 0.63861591695501729f, 1.0f}, -{0.63381776239907728f, 0.63381776239907728f, 0.63381776239907728f, 1.0f}, -{0.62901960784313726f, 0.62901960784313726f, 0.62901960784313726f, 1.0f}, -{0.62422145328719725f, 0.62422145328719725f, 0.62422145328719725f, 1.0f}, -{0.61942329873125723f, 0.61942329873125723f, 0.61942329873125723f, 1.0f}, -{0.61462514417531722f, 0.61462514417531722f, 0.61462514417531722f, 1.0f}, -{0.6098269896193772f, 0.6098269896193772f, 0.6098269896193772f, 1.0f}, -{0.60502883506343719f, 0.60502883506343719f, 0.60502883506343719f, 1.0f}, -{0.60023068050749717f, 0.60023068050749717f, 0.60023068050749717f, 1.0f}, -{0.59543252595155716f, 0.59543252595155716f, 0.59543252595155716f, 1.0f}, -{0.59063437139561703f, 0.59063437139561703f, 0.59063437139561703f, 1.0f}, -{0.58608227604767404f, 0.58608227604767404f, 0.58608227604767404f, 1.0f}, -{0.58177623990772787f, 0.58177623990772787f, 0.58177623990772787f, 1.0f}, -{0.57747020376778169f, 0.57747020376778169f, 0.57747020376778169f, 1.0f}, -{0.57316416762783551f, 0.57316416762783551f, 0.57316416762783551f, 1.0f}, -{0.56885813148788944f, 0.56885813148788944f, 0.56885813148788944f, 1.0f}, -{0.56455209534794315f, 0.56455209534794315f, 0.56455209534794315f, 1.0f}, -{0.56024605920799697f, 0.56024605920799697f, 0.56024605920799697f, 1.0f}, -{0.55594002306805079f, 0.55594002306805079f, 0.55594002306805079f, 1.0f}, -{0.55163398692810461f, 0.55163398692810461f, 0.55163398692810461f, 1.0f}, -{0.54732795078815843f, 0.54732795078815843f, 0.54732795078815843f, 1.0f}, -{0.54302191464821226f, 0.54302191464821226f, 0.54302191464821226f, 1.0f}, -{0.53871587850826608f, 0.53871587850826608f, 0.53871587850826608f, 1.0f}, -{0.5344098423683199f, 0.5344098423683199f, 0.5344098423683199f, 1.0f}, -{0.53010380622837372f, 0.53010380622837372f, 0.53010380622837372f, 1.0f}, -{0.52579777008842754f, 0.52579777008842754f, 0.52579777008842754f, 1.0f}, -{0.52149173394848136f, 0.52149173394848136f, 0.52149173394848136f, 1.0f}, -{0.51718569780853518f, 0.51718569780853518f, 0.51718569780853518f, 1.0f}, -{0.512879661668589f, 0.512879661668589f, 0.512879661668589f, 1.0f}, -{0.50857362552864283f, 0.50857362552864283f, 0.50857362552864283f, 1.0f}, -{0.50426758938869665f, 0.50426758938869665f, 0.50426758938869665f, 1.0f}, -{0.49996155324875058f, 0.49996155324875058f, 0.49996155324875058f, 1.0f}, -{0.49565551710880429f, 0.49565551710880429f, 0.49565551710880429f, 1.0f}, -{0.49134948096885811f, 0.49134948096885811f, 0.49134948096885811f, 1.0f}, -{0.48704344482891193f, 0.48704344482891193f, 0.48704344482891193f, 1.0f}, -{0.48273740868896575f, 0.48273740868896575f, 0.48273740868896575f, 1.0f}, -{0.47843137254901963f, 0.47843137254901963f, 0.47843137254901963f, 1.0f}, -{0.47412533640907345f, 0.47412533640907345f, 0.47412533640907345f, 1.0f}, -{0.46981930026912727f, 0.46981930026912727f, 0.46981930026912727f, 1.0f}, -{0.46551326412918109f, 0.46551326412918109f, 0.46551326412918109f, 1.0f}, -{0.46120722798923491f, 0.46120722798923491f, 0.46120722798923491f, 1.0f}, -{0.45690119184928873f, 0.45690119184928873f, 0.45690119184928873f, 1.0f}, -{0.45259515570934256f, 0.45259515570934256f, 0.45259515570934256f, 1.0f}, -{0.44844290657439445f, 0.44844290657439445f, 0.44844290657439445f, 1.0f}, -{0.44438292964244525f, 0.44438292964244525f, 0.44438292964244525f, 1.0f}, -{0.44032295271049599f, 0.44032295271049599f, 0.44032295271049599f, 1.0f}, -{0.43626297577854672f, 0.43626297577854672f, 0.43626297577854672f, 1.0f}, -{0.43220299884659757f, 0.43220299884659757f, 0.43220299884659757f, 1.0f}, -{0.4281430219146482f, 0.4281430219146482f, 0.4281430219146482f, 1.0f}, -{0.424083044982699f, 0.424083044982699f, 0.424083044982699f, 1.0f}, -{0.42002306805074974f, 0.42002306805074974f, 0.42002306805074974f, 1.0f}, -{0.41596309111880048f, 0.41596309111880048f, 0.41596309111880048f, 1.0f}, -{0.41190311418685122f, 0.41190311418685122f, 0.41190311418685122f, 1.0f}, -{0.40784313725490196f, 0.40784313725490196f, 0.40784313725490196f, 1.0f}, -{0.40378316032295275f, 0.40378316032295275f, 0.40378316032295275f, 1.0f}, -{0.39972318339100349f, 0.39972318339100349f, 0.39972318339100349f, 1.0f}, -{0.39566320645905423f, 0.39566320645905423f, 0.39566320645905423f, 1.0f}, -{0.39160322952710497f, 0.39160322952710497f, 0.39160322952710497f, 1.0f}, -{0.38754325259515571f, 0.38754325259515571f, 0.38754325259515571f, 1.0f}, -{0.3834832756632065f, 0.3834832756632065f, 0.3834832756632065f, 1.0f}, -{0.37942329873125724f, 0.37942329873125724f, 0.37942329873125724f, 1.0f}, -{0.37536332179930798f, 0.37536332179930798f, 0.37536332179930798f, 1.0f}, -{0.37130334486735872f, 0.37130334486735872f, 0.37130334486735872f, 1.0f}, -{0.36724336793540957f, 0.36724336793540957f, 0.36724336793540957f, 1.0f}, -{0.3631833910034602f, 0.3631833910034602f, 0.3631833910034602f, 1.0f}, -{0.35912341407151094f, 0.35912341407151094f, 0.35912341407151094f, 1.0f}, -{0.35506343713956173f, 0.35506343713956173f, 0.35506343713956173f, 1.0f}, -{0.35100346020761247f, 0.35100346020761247f, 0.35100346020761247f, 1.0f}, -{0.34694348327566321f, 0.34694348327566321f, 0.34694348327566321f, 1.0f}, -{0.34288350634371401f, 0.34288350634371401f, 0.34288350634371401f, 1.0f}, -{0.33882352941176475f, 0.33882352941176475f, 0.33882352941176475f, 1.0f}, -{0.33476355247981548f, 0.33476355247981548f, 0.33476355247981548f, 1.0f}, -{0.33070357554786622f, 0.33070357554786622f, 0.33070357554786622f, 1.0f}, -{0.32664359861591696f, 0.32664359861591696f, 0.32664359861591696f, 1.0f}, -{0.3225836216839677f, 0.3225836216839677f, 0.3225836216839677f, 1.0f}, -{0.31741637831603231f, 0.31741637831603231f, 0.31741637831603231f, 1.0f}, -{0.31188004613610154f, 0.31188004613610154f, 0.31188004613610154f, 1.0f}, -{0.30634371395617072f, 0.30634371395617072f, 0.30634371395617072f, 1.0f}, -{0.30080738177623995f, 0.30080738177623995f, 0.30080738177623995f, 1.0f}, -{0.29527104959630929f, 0.29527104959630929f, 0.29527104959630929f, 1.0f}, -{0.28973471741637835f, 0.28973471741637835f, 0.28973471741637835f, 1.0f}, -{0.28419838523644753f, 0.28419838523644753f, 0.28419838523644753f, 1.0f}, -{0.27866205305651676f, 0.27866205305651676f, 0.27866205305651676f, 1.0f}, -{0.27312572087658593f, 0.27312572087658593f, 0.27312572087658593f, 1.0f}, -{0.26758938869665516f, 0.26758938869665516f, 0.26758938869665516f, 1.0f}, -{0.26205305651672434f, 0.26205305651672434f, 0.26205305651672434f, 1.0f}, -{0.25651672433679357f, 0.25651672433679357f, 0.25651672433679357f, 1.0f}, -{0.25098039215686274f, 0.25098039215686274f, 0.25098039215686274f, 1.0f}, -{0.24544405997693197f, 0.24544405997693197f, 0.24544405997693197f, 1.0f}, -{0.23990772779700117f, 0.23990772779700117f, 0.23990772779700117f, 1.0f}, -{0.23437139561707038f, 0.23437139561707038f, 0.23437139561707038f, 1.0f}, -{0.22883506343713958f, 0.22883506343713958f, 0.22883506343713958f, 1.0f}, -{0.22329873125720878f, 0.22329873125720878f, 0.22329873125720878f, 1.0f}, -{0.21776239907727798f, 0.21776239907727798f, 0.21776239907727798f, 1.0f}, -{0.21222606689734719f, 0.21222606689734719f, 0.21222606689734719f, 1.0f}, -{0.20668973471741653f, 0.20668973471741653f, 0.20668973471741653f, 1.0f}, -{0.20115340253748559f, 0.20115340253748559f, 0.20115340253748559f, 1.0f}, -{0.1956170703575548f, 0.1956170703575548f, 0.1956170703575548f, 1.0f}, -{0.190080738177624f, 0.190080738177624f, 0.190080738177624f, 1.0f}, -{0.1845444059976932f, 0.1845444059976932f, 0.1845444059976932f, 1.0f}, -{0.1790080738177624f, 0.1790080738177624f, 0.1790080738177624f, 1.0f}, -{0.17347174163783161f, 0.17347174163783161f, 0.17347174163783161f, 1.0f}, -{0.16793540945790081f, 0.16793540945790081f, 0.16793540945790081f, 1.0f}, -{0.16239907727797001f, 0.16239907727797001f, 0.16239907727797001f, 1.0f}, -{0.15686274509803921f, 0.15686274509803921f, 0.15686274509803921f, 1.0f}, -{0.15132641291810842f, 0.15132641291810842f, 0.15132641291810842f, 1.0f}, -{0.14579008073817765f, 0.14579008073817765f, 0.14579008073817765f, 1.0f}, -{0.14111495578623606f, 0.14111495578623606f, 0.14111495578623606f, 1.0f}, -{0.13656286043829297f, 0.13656286043829297f, 0.13656286043829297f, 1.0f}, -{0.13201076509034987f, 0.13201076509034987f, 0.13201076509034987f, 1.0f}, -{0.12745866974240677f, 0.12745866974240677f, 0.12745866974240677f, 1.0f}, -{0.12290657439446381f, 0.12290657439446381f, 0.12290657439446381f, 1.0f}, -{0.11835447904652058f, 0.11835447904652058f, 0.11835447904652058f, 1.0f}, -{0.11380238369857748f, 0.11380238369857748f, 0.11380238369857748f, 1.0f}, -{0.10925028835063438f, 0.10925028835063438f, 0.10925028835063438f, 1.0f}, -{0.10469819300269129f, 0.10469819300269129f, 0.10469819300269129f, 1.0f}, -{0.10014609765474819f, 0.10014609765474819f, 0.10014609765474819f, 1.0f}, -{0.095594002306805079f, 0.095594002306805079f, 0.095594002306805079f, 1.0f}, -{0.091041906958861982f, 0.091041906958861982f, 0.091041906958861982f, 1.0f}, -{0.086489811610918885f, 0.086489811610918885f, 0.086489811610918885f, 1.0f}, -{0.081937716262975788f, 0.081937716262975788f, 0.081937716262975788f, 1.0f}, -{0.077385620915032691f, 0.077385620915032691f, 0.077385620915032691f, 1.0f}, -{0.07283352556708958f, 0.07283352556708958f, 0.07283352556708958f, 1.0f}, -{0.068281430219146483f, 0.068281430219146483f, 0.068281430219146483f, 1.0f}, -{0.063729334871203386f, 0.063729334871203386f, 0.063729334871203386f, 1.0f}, -{0.059177239523260289f, 0.059177239523260289f, 0.059177239523260289f, 1.0f}, -{0.054625144175317192f, 0.054625144175317192f, 0.054625144175317192f, 1.0f}, -{0.05007304882737422f, 0.05007304882737422f, 0.05007304882737422f, 1.0f}, -{0.045520953479430998f, 0.045520953479430998f, 0.045520953479430998f, 1.0f}, -{0.040968858131487887f, 0.040968858131487887f, 0.040968858131487887f, 1.0f}, -{0.03641676278354479f, 0.03641676278354479f, 0.03641676278354479f, 1.0f}, -{0.031864667435601693f, 0.031864667435601693f, 0.031864667435601693f, 1.0f}, -{0.027312572087658596f, 0.027312572087658596f, 0.027312572087658596f, 1.0f}, -{0.022760476739715499f, 0.022760476739715499f, 0.022760476739715499f, 1.0f}, -{0.018208381391772388f, 0.018208381391772388f, 0.018208381391772388f, 1.0f}, -{0.013656286043829291f, 0.013656286043829291f, 0.013656286043829291f, 1.0f}, -{0.009104190695886194f, 0.009104190695886194f, 0.009104190695886194f, 1.0f}, -{0.004552095347943097f, 0.004552095347943097f, 0.004552095347943097f, 1.0f}, -{0.0f, 0.0f, 0.0f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential/Greys.txt b/extern/tfn/colormaps/sequential/Greys.txt deleted file mode 100644 index d276678..0000000 --- a/extern/tfn/colormaps/sequential/Greys.txt +++ /dev/null @@ -1,256 +0,0 @@ -(1.0, 1.0, 1.0, 1.0) -(0.99815455594002311, 0.99815455594002311, 0.99815455594002311, 1.0) -(0.99630911188004612, 0.99630911188004612, 0.99630911188004612, 1.0) -(0.99446366782006923, 0.99446366782006923, 0.99446366782006923, 1.0) -(0.99261822376009223, 0.99261822376009223, 0.99261822376009223, 1.0) -(0.99077277970011535, 0.99077277970011535, 0.99077277970011535, 1.0) -(0.98892733564013846, 0.98892733564013846, 0.98892733564013846, 1.0) -(0.98708189158016146, 0.98708189158016146, 0.98708189158016146, 1.0) -(0.98523644752018458, 0.98523644752018458, 0.98523644752018458, 1.0) -(0.98339100346020758, 0.98339100346020758, 0.98339100346020758, 1.0) -(0.98154555940023069, 0.98154555940023069, 0.98154555940023069, 1.0) -(0.9797001153402537, 0.9797001153402537, 0.9797001153402537, 1.0) -(0.97785467128027681, 0.97785467128027681, 0.97785467128027681, 1.0) -(0.97600922722029992, 0.97600922722029992, 0.97600922722029992, 1.0) -(0.97416378316032293, 0.97416378316032293, 0.97416378316032293, 1.0) -(0.97231833910034604, 0.97231833910034604, 0.97231833910034604, 1.0) -(0.97047289504036904, 0.97047289504036904, 0.97047289504036904, 1.0) -(0.96862745098039216, 0.96862745098039216, 0.96862745098039216, 1.0) -(0.96678200692041516, 0.96678200692041516, 0.96678200692041516, 1.0) -(0.96493656286043827, 0.96493656286043827, 0.96493656286043827, 1.0) -(0.96309111880046139, 0.96309111880046139, 0.96309111880046139, 1.0) -(0.96124567474048439, 0.96124567474048439, 0.96124567474048439, 1.0) -(0.9594002306805075, 0.9594002306805075, 0.9594002306805075, 1.0) -(0.95755478662053051, 0.95755478662053051, 0.95755478662053051, 1.0) -(0.95570934256055362, 0.95570934256055362, 0.95570934256055362, 1.0) -(0.95386389850057673, 0.95386389850057673, 0.95386389850057673, 1.0) -(0.95201845444059974, 0.95201845444059974, 0.95201845444059974, 1.0) -(0.95017301038062285, 0.95017301038062285, 0.95017301038062285, 1.0) -(0.94832756632064585, 0.94832756632064585, 0.94832756632064585, 1.0) -(0.94648212226066897, 0.94648212226066897, 0.94648212226066897, 1.0) -(0.94463667820069208, 0.94463667820069208, 0.94463667820069208, 1.0) -(0.94279123414071508, 0.94279123414071508, 0.94279123414071508, 1.0) -(0.94082276047673974, 0.94082276047673974, 0.94082276047673974, 1.0) -(0.93799307958477507, 0.93799307958477507, 0.93799307958477507, 1.0) -(0.9351633986928104, 0.9351633986928104, 0.9351633986928104, 1.0) -(0.93233371780084584, 0.93233371780084584, 0.93233371780084584, 1.0) -(0.92950403690888117, 0.92950403690888117, 0.92950403690888117, 1.0) -(0.92667435601691661, 0.92667435601691661, 0.92667435601691661, 1.0) -(0.92384467512495194, 0.92384467512495194, 0.92384467512495194, 1.0) -(0.92101499423298727, 0.92101499423298727, 0.92101499423298727, 1.0) -(0.91818531334102271, 0.91818531334102271, 0.91818531334102271, 1.0) -(0.91535563244905804, 0.91535563244905804, 0.91535563244905804, 1.0) -(0.91252595155709337, 0.91252595155709337, 0.91252595155709337, 1.0) -(0.90969627066512881, 0.90969627066512881, 0.90969627066512881, 1.0) -(0.90686658977316414, 0.90686658977316414, 0.90686658977316414, 1.0) -(0.90403690888119959, 0.90403690888119959, 0.90403690888119959, 1.0) -(0.90120722798923492, 0.90120722798923492, 0.90120722798923492, 1.0) -(0.89837754709727025, 0.89837754709727025, 0.89837754709727025, 1.0) -(0.89554786620530558, 0.89554786620530558, 0.89554786620530558, 1.0) -(0.89271818531334102, 0.89271818531334102, 0.89271818531334102, 1.0) -(0.88988850442137635, 0.88988850442137635, 0.88988850442137635, 1.0) -(0.88705882352941179, 0.88705882352941179, 0.88705882352941179, 1.0) -(0.88422914263744712, 0.88422914263744712, 0.88422914263744712, 1.0) -(0.88139946174548256, 0.88139946174548256, 0.88139946174548256, 1.0) -(0.87856978085351789, 0.87856978085351789, 0.87856978085351789, 1.0) -(0.87574009996155322, 0.87574009996155322, 0.87574009996155322, 1.0) -(0.87291041906958866, 0.87291041906958866, 0.87291041906958866, 1.0) -(0.87008073817762399, 0.87008073817762399, 0.87008073817762399, 1.0) -(0.86725105728565932, 0.86725105728565932, 0.86725105728565932, 1.0) -(0.86442137639369476, 0.86442137639369476, 0.86442137639369476, 1.0) -(0.86159169550173009, 0.86159169550173009, 0.86159169550173009, 1.0) -(0.85876201460976542, 0.85876201460976542, 0.85876201460976542, 1.0) -(0.85593233371780086, 0.85593233371780086, 0.85593233371780086, 1.0) -(0.85310265282583619, 0.85310265282583619, 0.85310265282583619, 1.0) -(0.85011918492887351, 0.85011918492887351, 0.85011918492887351, 1.0) -(0.84667435601691654, 0.84667435601691654, 0.84667435601691654, 1.0) -(0.84322952710495969, 0.84322952710495969, 0.84322952710495969, 1.0) -(0.83978469819300272, 0.83978469819300272, 0.83978469819300272, 1.0) -(0.83633986928104576, 0.83633986928104576, 0.83633986928104576, 1.0) -(0.83289504036908879, 0.83289504036908879, 0.83289504036908879, 1.0) -(0.82945021145713183, 0.82945021145713183, 0.82945021145713183, 1.0) -(0.82600538254517497, 0.82600538254517497, 0.82600538254517497, 1.0) -(0.82256055363321801, 0.82256055363321801, 0.82256055363321801, 1.0) -(0.81911572472126104, 0.81911572472126104, 0.81911572472126104, 1.0) -(0.81567089580930419, 0.81567089580930419, 0.81567089580930419, 1.0) -(0.81222606689734711, 0.81222606689734711, 0.81222606689734711, 1.0) -(0.80878123798539026, 0.80878123798539026, 0.80878123798539026, 1.0) -(0.80533640907343329, 0.80533640907343329, 0.80533640907343329, 1.0) -(0.80189158016147633, 0.80189158016147633, 0.80189158016147633, 1.0) -(0.79844675124951947, 0.79844675124951947, 0.79844675124951947, 1.0) -(0.79500192233756251, 0.79500192233756251, 0.79500192233756251, 1.0) -(0.79155709342560554, 0.79155709342560554, 0.79155709342560554, 1.0) -(0.78811226451364869, 0.78811226451364869, 0.78811226451364869, 1.0) -(0.78466743560169161, 0.78466743560169161, 0.78466743560169161, 1.0) -(0.78122260668973476, 0.78122260668973476, 0.78122260668973476, 1.0) -(0.77777777777777779, 0.77777777777777779, 0.77777777777777779, 1.0) -(0.77433294886582082, 0.77433294886582082, 0.77433294886582082, 1.0) -(0.77088811995386397, 0.77088811995386397, 0.77088811995386397, 1.0) -(0.76744329104190701, 0.76744329104190701, 0.76744329104190701, 1.0) -(0.76399846212995004, 0.76399846212995004, 0.76399846212995004, 1.0) -(0.76055363321799319, 0.76055363321799319, 0.76055363321799319, 1.0) -(0.75710880430603611, 0.75710880430603611, 0.75710880430603611, 1.0) -(0.75366397539407926, 0.75366397539407926, 0.75366397539407926, 1.0) -(0.75021914648212229, 0.75021914648212229, 0.75021914648212229, 1.0) -(0.74677431757016532, 0.74677431757016532, 0.74677431757016532, 1.0) -(0.74332948865820847, 0.74332948865820847, 0.74332948865820847, 1.0) -(0.73937716262975783, 0.73937716262975783, 0.73937716262975783, 1.0) -(0.73457900807381782, 0.73457900807381782, 0.73457900807381782, 1.0) -(0.7297808535178778, 0.7297808535178778, 0.7297808535178778, 1.0) -(0.72498269896193779, 0.72498269896193779, 0.72498269896193779, 1.0) -(0.72018454440599777, 0.72018454440599777, 0.72018454440599777, 1.0) -(0.71538638985005765, 0.71538638985005765, 0.71538638985005765, 1.0) -(0.71058823529411763, 0.71058823529411763, 0.71058823529411763, 1.0) -(0.70579008073817762, 0.70579008073817762, 0.70579008073817762, 1.0) -(0.7009919261822376, 0.7009919261822376, 0.7009919261822376, 1.0) -(0.69619377162629759, 0.69619377162629759, 0.69619377162629759, 1.0) -(0.69139561707035768, 0.69139561707035768, 0.69139561707035768, 1.0) -(0.68659746251441756, 0.68659746251441756, 0.68659746251441756, 1.0) -(0.68179930795847754, 0.68179930795847754, 0.68179930795847754, 1.0) -(0.67700115340253753, 0.67700115340253753, 0.67700115340253753, 1.0) -(0.67220299884659751, 0.67220299884659751, 0.67220299884659751, 1.0) -(0.6674048442906575, 0.6674048442906575, 0.6674048442906575, 1.0) -(0.66260668973471748, 0.66260668973471748, 0.66260668973471748, 1.0) -(0.65780853517877746, 0.65780853517877746, 0.65780853517877746, 1.0) -(0.65301038062283745, 0.65301038062283745, 0.65301038062283745, 1.0) -(0.64821222606689743, 0.64821222606689743, 0.64821222606689743, 1.0) -(0.64341407151095731, 0.64341407151095731, 0.64341407151095731, 1.0) -(0.63861591695501729, 0.63861591695501729, 0.63861591695501729, 1.0) -(0.63381776239907728, 0.63381776239907728, 0.63381776239907728, 1.0) -(0.62901960784313726, 0.62901960784313726, 0.62901960784313726, 1.0) -(0.62422145328719725, 0.62422145328719725, 0.62422145328719725, 1.0) -(0.61942329873125723, 0.61942329873125723, 0.61942329873125723, 1.0) -(0.61462514417531722, 0.61462514417531722, 0.61462514417531722, 1.0) -(0.6098269896193772, 0.6098269896193772, 0.6098269896193772, 1.0) -(0.60502883506343719, 0.60502883506343719, 0.60502883506343719, 1.0) -(0.60023068050749717, 0.60023068050749717, 0.60023068050749717, 1.0) -(0.59543252595155716, 0.59543252595155716, 0.59543252595155716, 1.0) -(0.59063437139561703, 0.59063437139561703, 0.59063437139561703, 1.0) -(0.58608227604767404, 0.58608227604767404, 0.58608227604767404, 1.0) -(0.58177623990772787, 0.58177623990772787, 0.58177623990772787, 1.0) -(0.57747020376778169, 0.57747020376778169, 0.57747020376778169, 1.0) -(0.57316416762783551, 0.57316416762783551, 0.57316416762783551, 1.0) -(0.56885813148788944, 0.56885813148788944, 0.56885813148788944, 1.0) -(0.56455209534794315, 0.56455209534794315, 0.56455209534794315, 1.0) -(0.56024605920799697, 0.56024605920799697, 0.56024605920799697, 1.0) -(0.55594002306805079, 0.55594002306805079, 0.55594002306805079, 1.0) -(0.55163398692810461, 0.55163398692810461, 0.55163398692810461, 1.0) -(0.54732795078815843, 0.54732795078815843, 0.54732795078815843, 1.0) -(0.54302191464821226, 0.54302191464821226, 0.54302191464821226, 1.0) -(0.53871587850826608, 0.53871587850826608, 0.53871587850826608, 1.0) -(0.5344098423683199, 0.5344098423683199, 0.5344098423683199, 1.0) -(0.53010380622837372, 0.53010380622837372, 0.53010380622837372, 1.0) -(0.52579777008842754, 0.52579777008842754, 0.52579777008842754, 1.0) -(0.52149173394848136, 0.52149173394848136, 0.52149173394848136, 1.0) -(0.51718569780853518, 0.51718569780853518, 0.51718569780853518, 1.0) -(0.512879661668589, 0.512879661668589, 0.512879661668589, 1.0) -(0.50857362552864283, 0.50857362552864283, 0.50857362552864283, 1.0) -(0.50426758938869665, 0.50426758938869665, 0.50426758938869665, 1.0) -(0.49996155324875058, 0.49996155324875058, 0.49996155324875058, 1.0) -(0.49565551710880429, 0.49565551710880429, 0.49565551710880429, 1.0) -(0.49134948096885811, 0.49134948096885811, 0.49134948096885811, 1.0) -(0.48704344482891193, 0.48704344482891193, 0.48704344482891193, 1.0) -(0.48273740868896575, 0.48273740868896575, 0.48273740868896575, 1.0) -(0.47843137254901963, 0.47843137254901963, 0.47843137254901963, 1.0) -(0.47412533640907345, 0.47412533640907345, 0.47412533640907345, 1.0) -(0.46981930026912727, 0.46981930026912727, 0.46981930026912727, 1.0) -(0.46551326412918109, 0.46551326412918109, 0.46551326412918109, 1.0) -(0.46120722798923491, 0.46120722798923491, 0.46120722798923491, 1.0) -(0.45690119184928873, 0.45690119184928873, 0.45690119184928873, 1.0) -(0.45259515570934256, 0.45259515570934256, 0.45259515570934256, 1.0) -(0.44844290657439445, 0.44844290657439445, 0.44844290657439445, 1.0) -(0.44438292964244525, 0.44438292964244525, 0.44438292964244525, 1.0) -(0.44032295271049599, 0.44032295271049599, 0.44032295271049599, 1.0) -(0.43626297577854672, 0.43626297577854672, 0.43626297577854672, 1.0) -(0.43220299884659757, 0.43220299884659757, 0.43220299884659757, 1.0) -(0.4281430219146482, 0.4281430219146482, 0.4281430219146482, 1.0) -(0.424083044982699, 0.424083044982699, 0.424083044982699, 1.0) -(0.42002306805074974, 0.42002306805074974, 0.42002306805074974, 1.0) -(0.41596309111880048, 0.41596309111880048, 0.41596309111880048, 1.0) -(0.41190311418685122, 0.41190311418685122, 0.41190311418685122, 1.0) -(0.40784313725490196, 0.40784313725490196, 0.40784313725490196, 1.0) -(0.40378316032295275, 0.40378316032295275, 0.40378316032295275, 1.0) -(0.39972318339100349, 0.39972318339100349, 0.39972318339100349, 1.0) -(0.39566320645905423, 0.39566320645905423, 0.39566320645905423, 1.0) -(0.39160322952710497, 0.39160322952710497, 0.39160322952710497, 1.0) -(0.38754325259515571, 0.38754325259515571, 0.38754325259515571, 1.0) -(0.3834832756632065, 0.3834832756632065, 0.3834832756632065, 1.0) -(0.37942329873125724, 0.37942329873125724, 0.37942329873125724, 1.0) -(0.37536332179930798, 0.37536332179930798, 0.37536332179930798, 1.0) -(0.37130334486735872, 0.37130334486735872, 0.37130334486735872, 1.0) -(0.36724336793540957, 0.36724336793540957, 0.36724336793540957, 1.0) -(0.3631833910034602, 0.3631833910034602, 0.3631833910034602, 1.0) -(0.35912341407151094, 0.35912341407151094, 0.35912341407151094, 1.0) -(0.35506343713956173, 0.35506343713956173, 0.35506343713956173, 1.0) -(0.35100346020761247, 0.35100346020761247, 0.35100346020761247, 1.0) -(0.34694348327566321, 0.34694348327566321, 0.34694348327566321, 1.0) -(0.34288350634371401, 0.34288350634371401, 0.34288350634371401, 1.0) -(0.33882352941176475, 0.33882352941176475, 0.33882352941176475, 1.0) -(0.33476355247981548, 0.33476355247981548, 0.33476355247981548, 1.0) -(0.33070357554786622, 0.33070357554786622, 0.33070357554786622, 1.0) -(0.32664359861591696, 0.32664359861591696, 0.32664359861591696, 1.0) -(0.3225836216839677, 0.3225836216839677, 0.3225836216839677, 1.0) -(0.31741637831603231, 0.31741637831603231, 0.31741637831603231, 1.0) -(0.31188004613610154, 0.31188004613610154, 0.31188004613610154, 1.0) -(0.30634371395617072, 0.30634371395617072, 0.30634371395617072, 1.0) -(0.30080738177623995, 0.30080738177623995, 0.30080738177623995, 1.0) -(0.29527104959630929, 0.29527104959630929, 0.29527104959630929, 1.0) -(0.28973471741637835, 0.28973471741637835, 0.28973471741637835, 1.0) -(0.28419838523644753, 0.28419838523644753, 0.28419838523644753, 1.0) -(0.27866205305651676, 0.27866205305651676, 0.27866205305651676, 1.0) -(0.27312572087658593, 0.27312572087658593, 0.27312572087658593, 1.0) -(0.26758938869665516, 0.26758938869665516, 0.26758938869665516, 1.0) -(0.26205305651672434, 0.26205305651672434, 0.26205305651672434, 1.0) -(0.25651672433679357, 0.25651672433679357, 0.25651672433679357, 1.0) -(0.25098039215686274, 0.25098039215686274, 0.25098039215686274, 1.0) -(0.24544405997693197, 0.24544405997693197, 0.24544405997693197, 1.0) -(0.23990772779700117, 0.23990772779700117, 0.23990772779700117, 1.0) -(0.23437139561707038, 0.23437139561707038, 0.23437139561707038, 1.0) -(0.22883506343713958, 0.22883506343713958, 0.22883506343713958, 1.0) -(0.22329873125720878, 0.22329873125720878, 0.22329873125720878, 1.0) -(0.21776239907727798, 0.21776239907727798, 0.21776239907727798, 1.0) -(0.21222606689734719, 0.21222606689734719, 0.21222606689734719, 1.0) -(0.20668973471741653, 0.20668973471741653, 0.20668973471741653, 1.0) -(0.20115340253748559, 0.20115340253748559, 0.20115340253748559, 1.0) -(0.1956170703575548, 0.1956170703575548, 0.1956170703575548, 1.0) -(0.190080738177624, 0.190080738177624, 0.190080738177624, 1.0) -(0.1845444059976932, 0.1845444059976932, 0.1845444059976932, 1.0) -(0.1790080738177624, 0.1790080738177624, 0.1790080738177624, 1.0) -(0.17347174163783161, 0.17347174163783161, 0.17347174163783161, 1.0) -(0.16793540945790081, 0.16793540945790081, 0.16793540945790081, 1.0) -(0.16239907727797001, 0.16239907727797001, 0.16239907727797001, 1.0) -(0.15686274509803921, 0.15686274509803921, 0.15686274509803921, 1.0) -(0.15132641291810842, 0.15132641291810842, 0.15132641291810842, 1.0) -(0.14579008073817765, 0.14579008073817765, 0.14579008073817765, 1.0) -(0.14111495578623606, 0.14111495578623606, 0.14111495578623606, 1.0) -(0.13656286043829297, 0.13656286043829297, 0.13656286043829297, 1.0) -(0.13201076509034987, 0.13201076509034987, 0.13201076509034987, 1.0) -(0.12745866974240677, 0.12745866974240677, 0.12745866974240677, 1.0) -(0.12290657439446381, 0.12290657439446381, 0.12290657439446381, 1.0) -(0.11835447904652058, 0.11835447904652058, 0.11835447904652058, 1.0) -(0.11380238369857748, 0.11380238369857748, 0.11380238369857748, 1.0) -(0.10925028835063438, 0.10925028835063438, 0.10925028835063438, 1.0) -(0.10469819300269129, 0.10469819300269129, 0.10469819300269129, 1.0) -(0.10014609765474819, 0.10014609765474819, 0.10014609765474819, 1.0) -(0.095594002306805079, 0.095594002306805079, 0.095594002306805079, 1.0) -(0.091041906958861982, 0.091041906958861982, 0.091041906958861982, 1.0) -(0.086489811610918885, 0.086489811610918885, 0.086489811610918885, 1.0) -(0.081937716262975788, 0.081937716262975788, 0.081937716262975788, 1.0) -(0.077385620915032691, 0.077385620915032691, 0.077385620915032691, 1.0) -(0.07283352556708958, 0.07283352556708958, 0.07283352556708958, 1.0) -(0.068281430219146483, 0.068281430219146483, 0.068281430219146483, 1.0) -(0.063729334871203386, 0.063729334871203386, 0.063729334871203386, 1.0) -(0.059177239523260289, 0.059177239523260289, 0.059177239523260289, 1.0) -(0.054625144175317192, 0.054625144175317192, 0.054625144175317192, 1.0) -(0.05007304882737422, 0.05007304882737422, 0.05007304882737422, 1.0) -(0.045520953479430998, 0.045520953479430998, 0.045520953479430998, 1.0) -(0.040968858131487887, 0.040968858131487887, 0.040968858131487887, 1.0) -(0.03641676278354479, 0.03641676278354479, 0.03641676278354479, 1.0) -(0.031864667435601693, 0.031864667435601693, 0.031864667435601693, 1.0) -(0.027312572087658596, 0.027312572087658596, 0.027312572087658596, 1.0) -(0.022760476739715499, 0.022760476739715499, 0.022760476739715499, 1.0) -(0.018208381391772388, 0.018208381391772388, 0.018208381391772388, 1.0) -(0.013656286043829291, 0.013656286043829291, 0.013656286043829291, 1.0) -(0.009104190695886194, 0.009104190695886194, 0.009104190695886194, 1.0) -(0.004552095347943097, 0.004552095347943097, 0.004552095347943097, 1.0) -(0.0, 0.0, 0.0, 1.0) diff --git a/extern/tfn/colormaps/sequential/OrRd.cpp b/extern/tfn/colormaps/sequential/OrRd.cpp deleted file mode 100644 index a337e11..0000000 --- a/extern/tfn/colormaps/sequential/OrRd.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential_OrRd; -} -const std::vector colormap::data_sequential_OrRd = /* NOLINT(cert-err58-cpp) */ -{ -{1.0f, 0.96862745098039216f, 0.92549019607843142f, 1.0f}, -{0.99987697039600154f, 0.96678200692041527f, 0.92106113033448678f, 1.0f}, -{0.99975394079200308f, 0.96493656286043827f, 0.91663206459054214f, 1.0f}, -{0.99963091118800462f, 0.96309111880046139f, 0.9122029988465975f, 1.0f}, -{0.99950788158400616f, 0.96124567474048439f, 0.90777393310265286f, 1.0f}, -{0.9993848519800077f, 0.9594002306805075f, 0.90334486735870823f, 1.0f}, -{0.99926182237600925f, 0.95755478662053051f, 0.89891580161476359f, 1.0f}, -{0.99913879277201079f, 0.95570934256055362f, 0.89448673587081895f, 1.0f}, -{0.99901576316801233f, 0.95386389850057673f, 0.89005767012687431f, 1.0f}, -{0.99889273356401387f, 0.95201845444059974f, 0.88562860438292967f, 1.0f}, -{0.99876970396001541f, 0.95017301038062285f, 0.88119953863898504f, 1.0f}, -{0.99864667435601695f, 0.94832756632064585f, 0.8767704728950404f, 1.0f}, -{0.99852364475201849f, 0.94648212226066897f, 0.87234140715109576f, 1.0f}, -{0.99840061514802003f, 0.94463667820069208f, 0.86791234140715112f, 1.0f}, -{0.99827758554402157f, 0.94279123414071508f, 0.86348327566320648f, 1.0f}, -{0.99815455594002311f, 0.9409457900807382f, 0.85905420991926185f, 1.0f}, -{0.99803152633602465f, 0.9391003460207612f, 0.85462514417531721f, 1.0f}, -{0.9979084967320262f, 0.93725490196078431f, 0.85019607843137257f, 1.0f}, -{0.99778546712802774f, 0.93540945790080743f, 0.84576701268742793f, 1.0f}, -{0.99766243752402928f, 0.93356401384083043f, 0.84133794694348329f, 1.0f}, -{0.99753940792003082f, 0.93171856978085354f, 0.83690888119953866f, 1.0f}, -{0.99741637831603236f, 0.92987312572087655f, 0.83247981545559402f, 1.0f}, -{0.99729334871203379f, 0.92802768166089966f, 0.82805074971164938f, 1.0f}, -{0.99717031910803533f, 0.92618223760092266f, 0.82362168396770474f, 1.0f}, -{0.99704728950403687f, 0.92433679354094578f, 0.81919261822376011f, 1.0f}, -{0.99692425990003841f, 0.92249134948096889f, 0.81476355247981547f, 1.0f}, -{0.99680123029603995f, 0.92064590542099189f, 0.81033448673587083f, 1.0f}, -{0.99667820069204149f, 0.91880046136101501f, 0.80590542099192619f, 1.0f}, -{0.99655517108804303f, 0.91695501730103801f, 0.80147635524798155f, 1.0f}, -{0.99643214148404458f, 0.91510957324106112f, 0.79704728950403692f, 1.0f}, -{0.99630911188004612f, 0.91326412918108424f, 0.79261822376009228f, 1.0f}, -{0.99618608227604766f, 0.91141868512110724f, 0.78818915801614764f, 1.0f}, -{0.9960630526720492f, 0.90949634755863129f, 0.7836678200692041f, 1.0f}, -{0.99594002306805074f, 0.90703575547866211f, 0.77850057670126882f, 1.0f}, -{0.99581699346405228f, 0.90457516339869282f, 0.77333333333333332f, 1.0f}, -{0.99569396386005382f, 0.90211457131872352f, 0.76816608996539792f, 1.0f}, -{0.99557093425605536f, 0.89965397923875434f, 0.76299884659746253f, 1.0f}, -{0.9954479046520569f, 0.89719338715878505f, 0.75783160322952714f, 1.0f}, -{0.99532487504805844f, 0.89473279507881587f, 0.75266435986159164f, 1.0f}, -{0.99520184544405998f, 0.89227220299884658f, 0.74749711649365624f, 1.0f}, -{0.99507881584006153f, 0.88981161091887739f, 0.74232987312572085f, 1.0f}, -{0.99495578623606307f, 0.8873510188389081f, 0.73716262975778546f, 1.0f}, -{0.99483275663206461f, 0.88489042675893892f, 0.73199538638985007f, 1.0f}, -{0.99470972702806615f, 0.88242983467896963f, 0.72682814302191467f, 1.0f}, -{0.99458669742406769f, 0.87996924259900045f, 0.72166089965397928f, 1.0f}, -{0.99446366782006923f, 0.87750865051903115f, 0.71649365628604389f, 1.0f}, -{0.99434063821607077f, 0.87504805843906186f, 0.71132641291810839f, 1.0f}, -{0.99421760861207231f, 0.87258746635909268f, 0.70615916955017299f, 1.0f}, -{0.99409457900807385f, 0.87012687427912339f, 0.7009919261822376f, 1.0f}, -{0.99397154940407539f, 0.8676662821991542f, 0.69582468281430221f, 1.0f}, -{0.99384851980007693f, 0.86520569011918491f, 0.69065743944636682f, 1.0f}, -{0.99372549019607848f, 0.86274509803921573f, 0.68549019607843142f, 1.0f}, -{0.99360246059208002f, 0.86028450595924644f, 0.68032295271049592f, 1.0f}, -{0.99347943098808156f, 0.85782391387927726f, 0.67515570934256064f, 1.0f}, -{0.9933564013840831f, 0.85536332179930796f, 0.66998846597462514f, 1.0f}, -{0.99323337178008464f, 0.85290272971933878f, 0.66482122260668974f, 1.0f}, -{0.99311034217608618f, 0.85044213763936949f, 0.65965397923875435f, 1.0f}, -{0.99298731257208772f, 0.84798154555940031f, 0.65448673587081896f, 1.0f}, -{0.99286428296808926f, 0.84552095347943101f, 0.64931949250288357f, 1.0f}, -{0.9927412533640908f, 0.84306036139946183f, 0.64415224913494806f, 1.0f}, -{0.99261822376009234f, 0.84059976931949254f, 0.63898500576701267f, 1.0f}, -{0.99249519415609389f, 0.83813917723952336f, 0.63381776239907728f, 1.0f}, -{0.99237216455209543f, 0.83567858515955407f, 0.62865051903114189f, 1.0f}, -{0.99224913494809697f, 0.83321799307958477f, 0.62348327566320649f, 1.0f}, -{0.99215686274509807f, 0.83060361399461746f, 0.61880815071126494f, 1.0f}, -{0.99215686274509807f, 0.82752787389465599f, 0.61560938100730489f, 1.0f}, -{0.99215686274509807f, 0.8244521337946944f, 0.61241061130334495f, 1.0f}, -{0.99215686274509807f, 0.82137639369473281f, 0.60921184159938491f, 1.0f}, -{0.99215686274509807f, 0.81830065359477122f, 0.60601307189542486f, 1.0f}, -{0.99215686274509807f, 0.81522491349480974f, 0.60281430219146481f, 1.0f}, -{0.99215686274509807f, 0.81214917339484816f, 0.59961553248750488f, 1.0f}, -{0.99215686274509807f, 0.80907343329488657f, 0.59641676278354483f, 1.0f}, -{0.99215686274509807f, 0.80599769319492509f, 0.59321799307958478f, 1.0f}, -{0.99215686274509807f, 0.8029219530949635f, 0.59001922337562474f, 1.0f}, -{0.99215686274509807f, 0.79984621299500203f, 0.5868204536716648f, 1.0f}, -{0.99215686274509807f, 0.79677047289504033f, 0.58362168396770475f, 1.0f}, -{0.99215686274509807f, 0.79369473279507885f, 0.5804229142637447f, 1.0f}, -{0.99215686274509807f, 0.79061899269511726f, 0.57722414455978477f, 1.0f}, -{0.99215686274509807f, 0.78754325259515567f, 0.57402537485582472f, 1.0f}, -{0.99215686274509807f, 0.7844675124951942f, 0.57082660515186467f, 1.0f}, -{0.99215686274509807f, 0.78139177239523261f, 0.56762783544790474f, 1.0f}, -{0.99215686274509807f, 0.77831603229527102f, 0.56442906574394469f, 1.0f}, -{0.99215686274509807f, 0.77524029219530954f, 0.56123029603998476f, 1.0f}, -{0.99215686274509807f, 0.77216455209534796f, 0.5580315263360246f, 1.0f}, -{0.99215686274509807f, 0.76908881199538637f, 0.55483275663206466f, 1.0f}, -{0.99215686274509807f, 0.76601307189542478f, 0.55163398692810461f, 1.0f}, -{0.99215686274509807f, 0.7629373317954633f, 0.54843521722414457f, 1.0f}, -{0.99215686274509807f, 0.75986159169550171f, 0.54523644752018463f, 1.0f}, -{0.99215686274509807f, 0.75678585159554013f, 0.54203767781622458f, 1.0f}, -{0.99215686274509807f, 0.75371011149557865f, 0.53883890811226454f, 1.0f}, -{0.99215686274509807f, 0.75063437139561706f, 0.5356401384083046f, 1.0f}, -{0.99215686274509807f, 0.74755863129565547f, 0.53244136870434455f, 1.0f}, -{0.99215686274509807f, 0.74448289119569389f, 0.52924259900038451f, 1.0f}, -{0.99215686274509807f, 0.74140715109573241f, 0.52604382929642446f, 1.0f}, -{0.99215686274509807f, 0.73833141099577082f, 0.52284505959246452f, 1.0f}, -{0.99215686274509807f, 0.73525567089580923f, 0.51964628988850448f, 1.0f}, -{0.99211072664359867f, 0.73121107266435981f, 0.51566320645905428f, 1.0f}, -{0.99198769703960021f, 0.72555171088043058f, 0.51037293348712043f, 1.0f}, -{0.99186466743560175f, 0.71989234909650135f, 0.50508266051518658f, 1.0f}, -{0.9917416378316033f, 0.71423298731257201f, 0.49979238754325261f, 1.0f}, -{0.99161860822760484f, 0.70857362552864278f, 0.49450211457131876f, 1.0f}, -{0.99149557862360638f, 0.70291426374471355f, 0.48921184159938491f, 1.0f}, -{0.99137254901960792f, 0.69725490196078432f, 0.483921568627451f, 1.0f}, -{0.99124951941560946f, 0.69159554017685498f, 0.47863129565551715f, 1.0f}, -{0.991126489811611f, 0.68593617839292575f, 0.47334102268358325f, 1.0f}, -{0.99100346020761254f, 0.68027681660899653f, 0.46805074971164939f, 1.0f}, -{0.99088043060361408f, 0.6746174548250673f, 0.4627604767397156f, 1.0f}, -{0.99075740099961551f, 0.66895809304113796f, 0.45747020376778164f, 1.0f}, -{0.99063437139561705f, 0.66329873125720873f, 0.45217993079584778f, 1.0f}, -{0.99051134179161859f, 0.6576393694732795f, 0.44688965782391388f, 1.0f}, -{0.99038831218762013f, 0.65198000768935027f, 0.44159938485198003f, 1.0f}, -{0.99026528258362168f, 0.64632064590542093f, 0.43630911188004617f, 1.0f}, -{0.99014225297962322f, 0.6406612841214917f, 0.43101883890811227f, 1.0f}, -{0.99001922337562476f, 0.63500192233756247f, 0.42572856593617842f, 1.0f}, -{0.9898961937716263f, 0.62934256055363336f, 0.42043829296424462f, 1.0f}, -{0.98977316416762784f, 0.62368319876970402f, 0.41514801999231066f, 1.0f}, -{0.98965013456362938f, 0.61802383698577468f, 0.40985774702037681f, 1.0f}, -{0.98952710495963092f, 0.61236447520184545f, 0.4045674740484429f, 1.0f}, -{0.98940407535563246f, 0.60670511341791622f, 0.39927720107650905f, 1.0f}, -{0.989281045751634f, 0.60104575163398688f, 0.39398692810457514f, 1.0f}, -{0.98915801614763554f, 0.59538638985005776f, 0.38869665513264129f, 1.0f}, -{0.98903498654363708f, 0.58972702806612842f, 0.38340638216070744f, 1.0f}, -{0.98891195693963863f, 0.5840676662821993f, 0.37811610918877359f, 1.0f}, -{0.98878892733564017f, 0.57840830449826997f, 0.37282583621683968f, 1.0f}, -{0.98866589773164171f, 0.57274894271434063f, 0.36753556324490577f, 1.0f}, -{0.98854286812764325f, 0.5670895809304114f, 0.36224529027297192f, 1.0f}, -{0.98841983852364479f, 0.56143021914648217f, 0.35695501730103807f, 1.0f}, -{0.98829680891964633f, 0.55577085736255294f, 0.35166474432910422f, 1.0f}, -{0.98743560169165712f, 0.55048058439061898f, 0.34797385620915033f, 1.0f}, -{0.98583621683967704f, 0.5455594002306805f, 0.34588235294117647f, 1.0f}, -{0.98423683198769707f, 0.54063821607074203f, 0.34379084967320261f, 1.0f}, -{0.9826374471357171f, 0.53571703191080355f, 0.34169934640522875f, 1.0f}, -{0.98103806228373713f, 0.53079584775086519f, 0.33960784313725495f, 1.0f}, -{0.97943867743175705f, 0.52587466359092661f, 0.33751633986928103f, 1.0f}, -{0.97783929257977709f, 0.52095347943098813f, 0.33542483660130717f, 1.0f}, -{0.97623990772779701f, 0.51603229527104966f, 0.33333333333333331f, 1.0f}, -{0.97464052287581704f, 0.51111111111111118f, 0.33124183006535945f, 1.0f}, -{0.97304113802383707f, 0.5061899269511726f, 0.3291503267973856f, 1.0f}, -{0.97144175317185699f, 0.50126874279123412f, 0.32705882352941174f, 1.0f}, -{0.96984236831987702f, 0.49634755863129565f, 0.32496732026143788f, 1.0f}, -{0.96824298346789694f, 0.49142637447135717f, 0.32287581699346402f, 1.0f}, -{0.96664359861591698f, 0.4865051903114187f, 0.32078431372549021f, 1.0f}, -{0.96504421376393701f, 0.48158400615148023f, 0.31869281045751635f, 1.0f}, -{0.96344482891195693f, 0.47666282199154175f, 0.31660130718954249f, 1.0f}, -{0.96184544405997696f, 0.47174163783160322f, 0.31450980392156863f, 1.0f}, -{0.96024605920799699f, 0.46682045367166475f, 0.31241830065359477f, 1.0f}, -{0.95864667435601691f, 0.46189926951172627f, 0.31032679738562091f, 1.0f}, -{0.95704728950403695f, 0.45697808535178774f, 0.30823529411764705f, 1.0f}, -{0.95544790465205698f, 0.45205690119184944f, 0.30614379084967325f, 1.0f}, -{0.9538485198000769f, 0.4471357170319108f, 0.30405228758169933f, 1.0f}, -{0.95224913494809693f, 0.44221453287197232f, 0.30196078431372547f, 1.0f}, -{0.95064975009611685f, 0.43729334871203385f, 0.29986928104575161f, 1.0f}, -{0.94905036524413688f, 0.43237216455209532f, 0.29777777777777775f, 1.0f}, -{0.94745098039215692f, 0.42745098039215684f, 0.29568627450980389f, 1.0f}, -{0.94585159554017684f, 0.42252979623221837f, 0.29359477124183003f, 1.0f}, -{0.94425221068819687f, 0.41760861207227984f, 0.29150326797385617f, 1.0f}, -{0.94265282583621679f, 0.41268742791234136f, 0.28941176470588237f, 1.0f}, -{0.94105344098423682f, 0.40776624375240289f, 0.28732026143790851f, 1.0f}, -{0.93945405613225685f, 0.40284505959246442f, 0.28522875816993465f, 1.0f}, -{0.93785467128027677f, 0.39792387543252594f, 0.28313725490196079f, 1.0f}, -{0.93540945790080743f, 0.39200307574009996f, 0.27920030757400999f, 1.0f}, -{0.9324567474048443f, 0.38548250672818146f, 0.27415609381007305f, 1.0f}, -{0.92950403690888117f, 0.37896193771626296f, 0.26911188004613612f, 1.0f}, -{0.92655132641291815f, 0.37244136870434447f, 0.26406766628219913f, 1.0f}, -{0.92359861591695513f, 0.36592079969242614f, 0.25902345251826236f, 1.0f}, -{0.92064590542099189f, 0.35940023068050747f, 0.25397923875432526f, 1.0f}, -{0.91769319492502888f, 0.35287966166858897f, 0.2489350249903883f, 1.0f}, -{0.91474048442906575f, 0.34635909265667048f, 0.24389081122645137f, 1.0f}, -{0.91178777393310262f, 0.33983852364475198f, 0.23884659746251441f, 1.0f}, -{0.9088350634371396f, 0.33331795463283354f, 0.23380238369857748f, 1.0f}, -{0.90588235294117647f, 0.32679738562091504f, 0.22875816993464054f, 1.0f}, -{0.90292964244521334f, 0.32027681660899654f, 0.22371395617070358f, 1.0f}, -{0.89997693194925033f, 0.31375624759707804f, 0.21866974240676662f, 1.0f}, -{0.8970242214532872f, 0.30723567858515954f, 0.21362552864282969f, 1.0f}, -{0.89407151095732407f, 0.30071510957324105f, 0.20858131487889275f, 1.0f}, -{0.89111880046136105f, 0.29419454056132255f, 0.20353710111495579f, 1.0f}, -{0.88816608996539792f, 0.28767397154940405f, 0.19849288735101883f, 1.0f}, -{0.88521337946943479f, 0.28115340253748555f, 0.1934486735870819f, 1.0f}, -{0.88226066897347177f, 0.27463283352556705f, 0.18840445982314494f, 1.0f}, -{0.87930795847750864f, 0.26811226451364856f, 0.183360246059208f, 1.0f}, -{0.87635524798154563f, 0.26159169550173028f, 0.17831603229527121f, 1.0f}, -{0.8734025374855825f, 0.25507112648981156f, 0.17327181853133411f, 1.0f}, -{0.87044982698961937f, 0.24855055747789309f, 0.16822760476739718f, 1.0f}, -{0.86749711649365624f, 0.24202998846597462f, 0.16318339100346022f, 1.0f}, -{0.86454440599769322f, 0.23550941945405612f, 0.15813917723952325f, 1.0f}, -{0.86159169550173009f, 0.22898885044213763f, 0.15309496347558632f, 1.0f}, -{0.85863898500576696f, 0.22246828143021913f, 0.14805074971164936f, 1.0f}, -{0.85568627450980395f, 0.21594771241830063f, 0.14300653594771243f, 1.0f}, -{0.85273356401384082f, 0.20942714340638216f, 0.13796232218377547f, 1.0f}, -{0.84978085351787769f, 0.20290657439446366f, 0.13291810841983853f, 1.0f}, -{0.84682814302191467f, 0.19638600538254516f, 0.12787389465590157f, 1.0f}, -{0.84387543252595154f, 0.18986543637062667f, 0.12282968089196464f, 1.0f}, -{0.83981545559400228f, 0.18380622837370242f, 0.11870818915801615f, 1.0f}, -{0.83538638985005764f, 0.17790080738177624f, 0.11489427143406382f, 1.0f}, -{0.830957324106113f, 0.17199538638985007f, 0.11108035371011149f, 1.0f}, -{0.82652825836216837f, 0.16608996539792387f, 0.10726643598615918f, 1.0f}, -{0.82209919261822384f, 0.16018454440599786f, 0.10345251826220694f, 1.0f}, -{0.81767012687427909f, 0.15427912341407152f, 0.099638600538254518f, 1.0f}, -{0.81324106113033445f, 0.14837370242214531f, 0.095824682814302189f, 1.0f}, -{0.80881199538638981f, 0.14246828143021914f, 0.092010765090349861f, 1.0f}, -{0.80438292964244518f, 0.13656286043829297f, 0.088196847366397532f, 1.0f}, -{0.79995386389850054f, 0.13065743944636676f, 0.084382929642445204f, 1.0f}, -{0.7955247981545559f, 0.12475201845444059f, 0.080569011918492889f, 1.0f}, -{0.79109573241061126f, 0.11884659746251441f, 0.07675509419454056f, 1.0f}, -{0.78666666666666663f, 0.11294117647058823f, 0.072941176470588232f, 1.0f}, -{0.78223760092272199f, 0.10703575547866205f, 0.069127258746635903f, 1.0f}, -{0.77780853517877735f, 0.10113033448673586f, 0.065313341022683574f, 1.0f}, -{0.77337946943483271f, 0.095224913494809688f, 0.061499423298731253f, 1.0f}, -{0.76895040369088807f, 0.089319492502883499f, 0.057685505574778931f, 1.0f}, -{0.76452133794694344f, 0.083414071510957324f, 0.053871587850826602f, 1.0f}, -{0.7600922722029988f, 0.077508650519031136f, 0.050057670126874274f, 1.0f}, -{0.75566320645905416f, 0.071603229527104961f, 0.046243752402921945f, 1.0f}, -{0.75123414071510963f, 0.065697808535178939f, 0.042429834678969727f, 1.0f}, -{0.74680507497116488f, 0.059792387543252584f, 0.038615916955017301f, 1.0f}, -{0.74237600922722025f, 0.05388696655132641f, 0.034801999231064973f, 1.0f}, -{0.73794694348327561f, 0.047981545559400235f, 0.030988081507112644f, 1.0f}, -{0.73351787773933097f, 0.042076124567474033f, 0.027174163783160316f, 1.0f}, -{0.72908881199538633f, 0.036170703575547858f, 0.023360246059208001f, 1.0f}, -{0.72465974625144169f, 0.030265282583621683f, 0.019546328335255672f, 1.0f}, -{0.72023068050749706f, 0.024359861591695509f, 0.015732410611303344f, 1.0f}, -{0.71580161476355242f, 0.018454440599769306f, 0.011918492887351015f, 1.0f}, -{0.71137254901960778f, 0.012549019607843132f, 0.0081045751633986862f, 1.0f}, -{0.70694348327566314f, 0.0066435986159169569f, 0.0042906574394463715f, 1.0f}, -{0.7025144175317185f, 0.00073817762399078224f, 0.00047673971549404282f, 1.0f}, -{0.69636293733179544f, 0.0f, 0.0f, 1.0f}, -{0.68996539792387535f, 0.0f, 0.0f, 1.0f}, -{0.68356785851595536f, 0.0f, 0.0f, 1.0f}, -{0.67717031910803538f, 0.0f, 0.0f, 1.0f}, -{0.67077277970011551f, 0.0f, 0.0f, 1.0f}, -{0.6643752402921953f, 0.0f, 0.0f, 1.0f}, -{0.65797770088427521f, 0.0f, 0.0f, 1.0f}, -{0.65158016147635522f, 0.0f, 0.0f, 1.0f}, -{0.64518262206843513f, 0.0f, 0.0f, 1.0f}, -{0.63878508266051515f, 0.0f, 0.0f, 1.0f}, -{0.63238754325259516f, 0.0f, 0.0f, 1.0f}, -{0.62599000384467507f, 0.0f, 0.0f, 1.0f}, -{0.61959246443675509f, 0.0f, 0.0f, 1.0f}, -{0.61319492502883499f, 0.0f, 0.0f, 1.0f}, -{0.60679738562091501f, 0.0f, 0.0f, 1.0f}, -{0.60039984621299503f, 0.0f, 0.0f, 1.0f}, -{0.59400230680507493f, 0.0f, 0.0f, 1.0f}, -{0.58760476739715495f, 0.0f, 0.0f, 1.0f}, -{0.58120722798923485f, 0.0f, 0.0f, 1.0f}, -{0.57480968858131487f, 0.0f, 0.0f, 1.0f}, -{0.568412149173395f, 0.0f, 0.0f, 1.0f}, -{0.56201460976547479f, 0.0f, 0.0f, 1.0f}, -{0.55561707035755481f, 0.0f, 0.0f, 1.0f}, -{0.54921953094963472f, 0.0f, 0.0f, 1.0f}, -{0.54282199154171473f, 0.0f, 0.0f, 1.0f}, -{0.53642445213379464f, 0.0f, 0.0f, 1.0f}, -{0.53002691272587465f, 0.0f, 0.0f, 1.0f}, -{0.52362937331795467f, 0.0f, 0.0f, 1.0f}, -{0.51723183391003458f, 0.0f, 0.0f, 1.0f}, -{0.51083429450211459f, 0.0f, 0.0f, 1.0f}, -{0.50443675509419461f, 0.0f, 0.0f, 1.0f}, -{0.49803921568627452f, 0.0f, 0.0f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential/OrRd.txt b/extern/tfn/colormaps/sequential/OrRd.txt deleted file mode 100644 index 4bd1002..0000000 --- a/extern/tfn/colormaps/sequential/OrRd.txt +++ /dev/null @@ -1,256 +0,0 @@ -(1.0, 0.96862745098039216, 0.92549019607843142, 1.0) -(0.99987697039600154, 0.96678200692041527, 0.92106113033448678, 1.0) -(0.99975394079200308, 0.96493656286043827, 0.91663206459054214, 1.0) -(0.99963091118800462, 0.96309111880046139, 0.9122029988465975, 1.0) -(0.99950788158400616, 0.96124567474048439, 0.90777393310265286, 1.0) -(0.9993848519800077, 0.9594002306805075, 0.90334486735870823, 1.0) -(0.99926182237600925, 0.95755478662053051, 0.89891580161476359, 1.0) -(0.99913879277201079, 0.95570934256055362, 0.89448673587081895, 1.0) -(0.99901576316801233, 0.95386389850057673, 0.89005767012687431, 1.0) -(0.99889273356401387, 0.95201845444059974, 0.88562860438292967, 1.0) -(0.99876970396001541, 0.95017301038062285, 0.88119953863898504, 1.0) -(0.99864667435601695, 0.94832756632064585, 0.8767704728950404, 1.0) -(0.99852364475201849, 0.94648212226066897, 0.87234140715109576, 1.0) -(0.99840061514802003, 0.94463667820069208, 0.86791234140715112, 1.0) -(0.99827758554402157, 0.94279123414071508, 0.86348327566320648, 1.0) -(0.99815455594002311, 0.9409457900807382, 0.85905420991926185, 1.0) -(0.99803152633602465, 0.9391003460207612, 0.85462514417531721, 1.0) -(0.9979084967320262, 0.93725490196078431, 0.85019607843137257, 1.0) -(0.99778546712802774, 0.93540945790080743, 0.84576701268742793, 1.0) -(0.99766243752402928, 0.93356401384083043, 0.84133794694348329, 1.0) -(0.99753940792003082, 0.93171856978085354, 0.83690888119953866, 1.0) -(0.99741637831603236, 0.92987312572087655, 0.83247981545559402, 1.0) -(0.99729334871203379, 0.92802768166089966, 0.82805074971164938, 1.0) -(0.99717031910803533, 0.92618223760092266, 0.82362168396770474, 1.0) -(0.99704728950403687, 0.92433679354094578, 0.81919261822376011, 1.0) -(0.99692425990003841, 0.92249134948096889, 0.81476355247981547, 1.0) -(0.99680123029603995, 0.92064590542099189, 0.81033448673587083, 1.0) -(0.99667820069204149, 0.91880046136101501, 0.80590542099192619, 1.0) -(0.99655517108804303, 0.91695501730103801, 0.80147635524798155, 1.0) -(0.99643214148404458, 0.91510957324106112, 0.79704728950403692, 1.0) -(0.99630911188004612, 0.91326412918108424, 0.79261822376009228, 1.0) -(0.99618608227604766, 0.91141868512110724, 0.78818915801614764, 1.0) -(0.9960630526720492, 0.90949634755863129, 0.7836678200692041, 1.0) -(0.99594002306805074, 0.90703575547866211, 0.77850057670126882, 1.0) -(0.99581699346405228, 0.90457516339869282, 0.77333333333333332, 1.0) -(0.99569396386005382, 0.90211457131872352, 0.76816608996539792, 1.0) -(0.99557093425605536, 0.89965397923875434, 0.76299884659746253, 1.0) -(0.9954479046520569, 0.89719338715878505, 0.75783160322952714, 1.0) -(0.99532487504805844, 0.89473279507881587, 0.75266435986159164, 1.0) -(0.99520184544405998, 0.89227220299884658, 0.74749711649365624, 1.0) -(0.99507881584006153, 0.88981161091887739, 0.74232987312572085, 1.0) -(0.99495578623606307, 0.8873510188389081, 0.73716262975778546, 1.0) -(0.99483275663206461, 0.88489042675893892, 0.73199538638985007, 1.0) -(0.99470972702806615, 0.88242983467896963, 0.72682814302191467, 1.0) -(0.99458669742406769, 0.87996924259900045, 0.72166089965397928, 1.0) -(0.99446366782006923, 0.87750865051903115, 0.71649365628604389, 1.0) -(0.99434063821607077, 0.87504805843906186, 0.71132641291810839, 1.0) -(0.99421760861207231, 0.87258746635909268, 0.70615916955017299, 1.0) -(0.99409457900807385, 0.87012687427912339, 0.7009919261822376, 1.0) -(0.99397154940407539, 0.8676662821991542, 0.69582468281430221, 1.0) -(0.99384851980007693, 0.86520569011918491, 0.69065743944636682, 1.0) -(0.99372549019607848, 0.86274509803921573, 0.68549019607843142, 1.0) -(0.99360246059208002, 0.86028450595924644, 0.68032295271049592, 1.0) -(0.99347943098808156, 0.85782391387927726, 0.67515570934256064, 1.0) -(0.9933564013840831, 0.85536332179930796, 0.66998846597462514, 1.0) -(0.99323337178008464, 0.85290272971933878, 0.66482122260668974, 1.0) -(0.99311034217608618, 0.85044213763936949, 0.65965397923875435, 1.0) -(0.99298731257208772, 0.84798154555940031, 0.65448673587081896, 1.0) -(0.99286428296808926, 0.84552095347943101, 0.64931949250288357, 1.0) -(0.9927412533640908, 0.84306036139946183, 0.64415224913494806, 1.0) -(0.99261822376009234, 0.84059976931949254, 0.63898500576701267, 1.0) -(0.99249519415609389, 0.83813917723952336, 0.63381776239907728, 1.0) -(0.99237216455209543, 0.83567858515955407, 0.62865051903114189, 1.0) -(0.99224913494809697, 0.83321799307958477, 0.62348327566320649, 1.0) -(0.99215686274509807, 0.83060361399461746, 0.61880815071126494, 1.0) -(0.99215686274509807, 0.82752787389465599, 0.61560938100730489, 1.0) -(0.99215686274509807, 0.8244521337946944, 0.61241061130334495, 1.0) -(0.99215686274509807, 0.82137639369473281, 0.60921184159938491, 1.0) -(0.99215686274509807, 0.81830065359477122, 0.60601307189542486, 1.0) -(0.99215686274509807, 0.81522491349480974, 0.60281430219146481, 1.0) -(0.99215686274509807, 0.81214917339484816, 0.59961553248750488, 1.0) -(0.99215686274509807, 0.80907343329488657, 0.59641676278354483, 1.0) -(0.99215686274509807, 0.80599769319492509, 0.59321799307958478, 1.0) -(0.99215686274509807, 0.8029219530949635, 0.59001922337562474, 1.0) -(0.99215686274509807, 0.79984621299500203, 0.5868204536716648, 1.0) -(0.99215686274509807, 0.79677047289504033, 0.58362168396770475, 1.0) -(0.99215686274509807, 0.79369473279507885, 0.5804229142637447, 1.0) -(0.99215686274509807, 0.79061899269511726, 0.57722414455978477, 1.0) -(0.99215686274509807, 0.78754325259515567, 0.57402537485582472, 1.0) -(0.99215686274509807, 0.7844675124951942, 0.57082660515186467, 1.0) -(0.99215686274509807, 0.78139177239523261, 0.56762783544790474, 1.0) -(0.99215686274509807, 0.77831603229527102, 0.56442906574394469, 1.0) -(0.99215686274509807, 0.77524029219530954, 0.56123029603998476, 1.0) -(0.99215686274509807, 0.77216455209534796, 0.5580315263360246, 1.0) -(0.99215686274509807, 0.76908881199538637, 0.55483275663206466, 1.0) -(0.99215686274509807, 0.76601307189542478, 0.55163398692810461, 1.0) -(0.99215686274509807, 0.7629373317954633, 0.54843521722414457, 1.0) -(0.99215686274509807, 0.75986159169550171, 0.54523644752018463, 1.0) -(0.99215686274509807, 0.75678585159554013, 0.54203767781622458, 1.0) -(0.99215686274509807, 0.75371011149557865, 0.53883890811226454, 1.0) -(0.99215686274509807, 0.75063437139561706, 0.5356401384083046, 1.0) -(0.99215686274509807, 0.74755863129565547, 0.53244136870434455, 1.0) -(0.99215686274509807, 0.74448289119569389, 0.52924259900038451, 1.0) -(0.99215686274509807, 0.74140715109573241, 0.52604382929642446, 1.0) -(0.99215686274509807, 0.73833141099577082, 0.52284505959246452, 1.0) -(0.99215686274509807, 0.73525567089580923, 0.51964628988850448, 1.0) -(0.99211072664359867, 0.73121107266435981, 0.51566320645905428, 1.0) -(0.99198769703960021, 0.72555171088043058, 0.51037293348712043, 1.0) -(0.99186466743560175, 0.71989234909650135, 0.50508266051518658, 1.0) -(0.9917416378316033, 0.71423298731257201, 0.49979238754325261, 1.0) -(0.99161860822760484, 0.70857362552864278, 0.49450211457131876, 1.0) -(0.99149557862360638, 0.70291426374471355, 0.48921184159938491, 1.0) -(0.99137254901960792, 0.69725490196078432, 0.483921568627451, 1.0) -(0.99124951941560946, 0.69159554017685498, 0.47863129565551715, 1.0) -(0.991126489811611, 0.68593617839292575, 0.47334102268358325, 1.0) -(0.99100346020761254, 0.68027681660899653, 0.46805074971164939, 1.0) -(0.99088043060361408, 0.6746174548250673, 0.4627604767397156, 1.0) -(0.99075740099961551, 0.66895809304113796, 0.45747020376778164, 1.0) -(0.99063437139561705, 0.66329873125720873, 0.45217993079584778, 1.0) -(0.99051134179161859, 0.6576393694732795, 0.44688965782391388, 1.0) -(0.99038831218762013, 0.65198000768935027, 0.44159938485198003, 1.0) -(0.99026528258362168, 0.64632064590542093, 0.43630911188004617, 1.0) -(0.99014225297962322, 0.6406612841214917, 0.43101883890811227, 1.0) -(0.99001922337562476, 0.63500192233756247, 0.42572856593617842, 1.0) -(0.9898961937716263, 0.62934256055363336, 0.42043829296424462, 1.0) -(0.98977316416762784, 0.62368319876970402, 0.41514801999231066, 1.0) -(0.98965013456362938, 0.61802383698577468, 0.40985774702037681, 1.0) -(0.98952710495963092, 0.61236447520184545, 0.4045674740484429, 1.0) -(0.98940407535563246, 0.60670511341791622, 0.39927720107650905, 1.0) -(0.989281045751634, 0.60104575163398688, 0.39398692810457514, 1.0) -(0.98915801614763554, 0.59538638985005776, 0.38869665513264129, 1.0) -(0.98903498654363708, 0.58972702806612842, 0.38340638216070744, 1.0) -(0.98891195693963863, 0.5840676662821993, 0.37811610918877359, 1.0) -(0.98878892733564017, 0.57840830449826997, 0.37282583621683968, 1.0) -(0.98866589773164171, 0.57274894271434063, 0.36753556324490577, 1.0) -(0.98854286812764325, 0.5670895809304114, 0.36224529027297192, 1.0) -(0.98841983852364479, 0.56143021914648217, 0.35695501730103807, 1.0) -(0.98829680891964633, 0.55577085736255294, 0.35166474432910422, 1.0) -(0.98743560169165712, 0.55048058439061898, 0.34797385620915033, 1.0) -(0.98583621683967704, 0.5455594002306805, 0.34588235294117647, 1.0) -(0.98423683198769707, 0.54063821607074203, 0.34379084967320261, 1.0) -(0.9826374471357171, 0.53571703191080355, 0.34169934640522875, 1.0) -(0.98103806228373713, 0.53079584775086519, 0.33960784313725495, 1.0) -(0.97943867743175705, 0.52587466359092661, 0.33751633986928103, 1.0) -(0.97783929257977709, 0.52095347943098813, 0.33542483660130717, 1.0) -(0.97623990772779701, 0.51603229527104966, 0.33333333333333331, 1.0) -(0.97464052287581704, 0.51111111111111118, 0.33124183006535945, 1.0) -(0.97304113802383707, 0.5061899269511726, 0.3291503267973856, 1.0) -(0.97144175317185699, 0.50126874279123412, 0.32705882352941174, 1.0) -(0.96984236831987702, 0.49634755863129565, 0.32496732026143788, 1.0) -(0.96824298346789694, 0.49142637447135717, 0.32287581699346402, 1.0) -(0.96664359861591698, 0.4865051903114187, 0.32078431372549021, 1.0) -(0.96504421376393701, 0.48158400615148023, 0.31869281045751635, 1.0) -(0.96344482891195693, 0.47666282199154175, 0.31660130718954249, 1.0) -(0.96184544405997696, 0.47174163783160322, 0.31450980392156863, 1.0) -(0.96024605920799699, 0.46682045367166475, 0.31241830065359477, 1.0) -(0.95864667435601691, 0.46189926951172627, 0.31032679738562091, 1.0) -(0.95704728950403695, 0.45697808535178774, 0.30823529411764705, 1.0) -(0.95544790465205698, 0.45205690119184944, 0.30614379084967325, 1.0) -(0.9538485198000769, 0.4471357170319108, 0.30405228758169933, 1.0) -(0.95224913494809693, 0.44221453287197232, 0.30196078431372547, 1.0) -(0.95064975009611685, 0.43729334871203385, 0.29986928104575161, 1.0) -(0.94905036524413688, 0.43237216455209532, 0.29777777777777775, 1.0) -(0.94745098039215692, 0.42745098039215684, 0.29568627450980389, 1.0) -(0.94585159554017684, 0.42252979623221837, 0.29359477124183003, 1.0) -(0.94425221068819687, 0.41760861207227984, 0.29150326797385617, 1.0) -(0.94265282583621679, 0.41268742791234136, 0.28941176470588237, 1.0) -(0.94105344098423682, 0.40776624375240289, 0.28732026143790851, 1.0) -(0.93945405613225685, 0.40284505959246442, 0.28522875816993465, 1.0) -(0.93785467128027677, 0.39792387543252594, 0.28313725490196079, 1.0) -(0.93540945790080743, 0.39200307574009996, 0.27920030757400999, 1.0) -(0.9324567474048443, 0.38548250672818146, 0.27415609381007305, 1.0) -(0.92950403690888117, 0.37896193771626296, 0.26911188004613612, 1.0) -(0.92655132641291815, 0.37244136870434447, 0.26406766628219913, 1.0) -(0.92359861591695513, 0.36592079969242614, 0.25902345251826236, 1.0) -(0.92064590542099189, 0.35940023068050747, 0.25397923875432526, 1.0) -(0.91769319492502888, 0.35287966166858897, 0.2489350249903883, 1.0) -(0.91474048442906575, 0.34635909265667048, 0.24389081122645137, 1.0) -(0.91178777393310262, 0.33983852364475198, 0.23884659746251441, 1.0) -(0.9088350634371396, 0.33331795463283354, 0.23380238369857748, 1.0) -(0.90588235294117647, 0.32679738562091504, 0.22875816993464054, 1.0) -(0.90292964244521334, 0.32027681660899654, 0.22371395617070358, 1.0) -(0.89997693194925033, 0.31375624759707804, 0.21866974240676662, 1.0) -(0.8970242214532872, 0.30723567858515954, 0.21362552864282969, 1.0) -(0.89407151095732407, 0.30071510957324105, 0.20858131487889275, 1.0) -(0.89111880046136105, 0.29419454056132255, 0.20353710111495579, 1.0) -(0.88816608996539792, 0.28767397154940405, 0.19849288735101883, 1.0) -(0.88521337946943479, 0.28115340253748555, 0.1934486735870819, 1.0) -(0.88226066897347177, 0.27463283352556705, 0.18840445982314494, 1.0) -(0.87930795847750864, 0.26811226451364856, 0.183360246059208, 1.0) -(0.87635524798154563, 0.26159169550173028, 0.17831603229527121, 1.0) -(0.8734025374855825, 0.25507112648981156, 0.17327181853133411, 1.0) -(0.87044982698961937, 0.24855055747789309, 0.16822760476739718, 1.0) -(0.86749711649365624, 0.24202998846597462, 0.16318339100346022, 1.0) -(0.86454440599769322, 0.23550941945405612, 0.15813917723952325, 1.0) -(0.86159169550173009, 0.22898885044213763, 0.15309496347558632, 1.0) -(0.85863898500576696, 0.22246828143021913, 0.14805074971164936, 1.0) -(0.85568627450980395, 0.21594771241830063, 0.14300653594771243, 1.0) -(0.85273356401384082, 0.20942714340638216, 0.13796232218377547, 1.0) -(0.84978085351787769, 0.20290657439446366, 0.13291810841983853, 1.0) -(0.84682814302191467, 0.19638600538254516, 0.12787389465590157, 1.0) -(0.84387543252595154, 0.18986543637062667, 0.12282968089196464, 1.0) -(0.83981545559400228, 0.18380622837370242, 0.11870818915801615, 1.0) -(0.83538638985005764, 0.17790080738177624, 0.11489427143406382, 1.0) -(0.830957324106113, 0.17199538638985007, 0.11108035371011149, 1.0) -(0.82652825836216837, 0.16608996539792387, 0.10726643598615918, 1.0) -(0.82209919261822384, 0.16018454440599786, 0.10345251826220694, 1.0) -(0.81767012687427909, 0.15427912341407152, 0.099638600538254518, 1.0) -(0.81324106113033445, 0.14837370242214531, 0.095824682814302189, 1.0) -(0.80881199538638981, 0.14246828143021914, 0.092010765090349861, 1.0) -(0.80438292964244518, 0.13656286043829297, 0.088196847366397532, 1.0) -(0.79995386389850054, 0.13065743944636676, 0.084382929642445204, 1.0) -(0.7955247981545559, 0.12475201845444059, 0.080569011918492889, 1.0) -(0.79109573241061126, 0.11884659746251441, 0.07675509419454056, 1.0) -(0.78666666666666663, 0.11294117647058823, 0.072941176470588232, 1.0) -(0.78223760092272199, 0.10703575547866205, 0.069127258746635903, 1.0) -(0.77780853517877735, 0.10113033448673586, 0.065313341022683574, 1.0) -(0.77337946943483271, 0.095224913494809688, 0.061499423298731253, 1.0) -(0.76895040369088807, 0.089319492502883499, 0.057685505574778931, 1.0) -(0.76452133794694344, 0.083414071510957324, 0.053871587850826602, 1.0) -(0.7600922722029988, 0.077508650519031136, 0.050057670126874274, 1.0) -(0.75566320645905416, 0.071603229527104961, 0.046243752402921945, 1.0) -(0.75123414071510963, 0.065697808535178939, 0.042429834678969727, 1.0) -(0.74680507497116488, 0.059792387543252584, 0.038615916955017301, 1.0) -(0.74237600922722025, 0.05388696655132641, 0.034801999231064973, 1.0) -(0.73794694348327561, 0.047981545559400235, 0.030988081507112644, 1.0) -(0.73351787773933097, 0.042076124567474033, 0.027174163783160316, 1.0) -(0.72908881199538633, 0.036170703575547858, 0.023360246059208001, 1.0) -(0.72465974625144169, 0.030265282583621683, 0.019546328335255672, 1.0) -(0.72023068050749706, 0.024359861591695509, 0.015732410611303344, 1.0) -(0.71580161476355242, 0.018454440599769306, 0.011918492887351015, 1.0) -(0.71137254901960778, 0.012549019607843132, 0.0081045751633986862, 1.0) -(0.70694348327566314, 0.0066435986159169569, 0.0042906574394463715, 1.0) -(0.7025144175317185, 0.00073817762399078224, 0.00047673971549404282, 1.0) -(0.69636293733179544, 0.0, 0.0, 1.0) -(0.68996539792387535, 0.0, 0.0, 1.0) -(0.68356785851595536, 0.0, 0.0, 1.0) -(0.67717031910803538, 0.0, 0.0, 1.0) -(0.67077277970011551, 0.0, 0.0, 1.0) -(0.6643752402921953, 0.0, 0.0, 1.0) -(0.65797770088427521, 0.0, 0.0, 1.0) -(0.65158016147635522, 0.0, 0.0, 1.0) -(0.64518262206843513, 0.0, 0.0, 1.0) -(0.63878508266051515, 0.0, 0.0, 1.0) -(0.63238754325259516, 0.0, 0.0, 1.0) -(0.62599000384467507, 0.0, 0.0, 1.0) -(0.61959246443675509, 0.0, 0.0, 1.0) -(0.61319492502883499, 0.0, 0.0, 1.0) -(0.60679738562091501, 0.0, 0.0, 1.0) -(0.60039984621299503, 0.0, 0.0, 1.0) -(0.59400230680507493, 0.0, 0.0, 1.0) -(0.58760476739715495, 0.0, 0.0, 1.0) -(0.58120722798923485, 0.0, 0.0, 1.0) -(0.57480968858131487, 0.0, 0.0, 1.0) -(0.568412149173395, 0.0, 0.0, 1.0) -(0.56201460976547479, 0.0, 0.0, 1.0) -(0.55561707035755481, 0.0, 0.0, 1.0) -(0.54921953094963472, 0.0, 0.0, 1.0) -(0.54282199154171473, 0.0, 0.0, 1.0) -(0.53642445213379464, 0.0, 0.0, 1.0) -(0.53002691272587465, 0.0, 0.0, 1.0) -(0.52362937331795467, 0.0, 0.0, 1.0) -(0.51723183391003458, 0.0, 0.0, 1.0) -(0.51083429450211459, 0.0, 0.0, 1.0) -(0.50443675509419461, 0.0, 0.0, 1.0) -(0.49803921568627452, 0.0, 0.0, 1.0) diff --git a/extern/tfn/colormaps/sequential/Oranges.cpp b/extern/tfn/colormaps/sequential/Oranges.cpp deleted file mode 100644 index 5595129..0000000 --- a/extern/tfn/colormaps/sequential/Oranges.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential_Oranges; -} -const std::vector colormap::data_sequential_Oranges = /* NOLINT(cert-err58-cpp) */ -{ -{1.0f, 0.96078431372549022f, 0.92156862745098034f, 1.0f}, -{0.99987697039600154f, 0.95893886966551334f, 0.91800076893502491f, 1.0f}, -{0.99975394079200308f, 0.95709342560553634f, 0.91443291041906949f, 1.0f}, -{0.99963091118800462f, 0.95524798154555945f, 0.91086505190311418f, 1.0f}, -{0.99950788158400616f, 0.95340253748558246f, 0.90729719338715875f, 1.0f}, -{0.9993848519800077f, 0.95155709342560557f, 0.90372933487120333f, 1.0f}, -{0.99926182237600925f, 0.94971164936562857f, 0.9001614763552479f, 1.0f}, -{0.99913879277201079f, 0.94786620530565169f, 0.89659361783929259f, 1.0f}, -{0.99901576316801233f, 0.9460207612456748f, 0.89302575932333716f, 1.0f}, -{0.99889273356401387f, 0.9441753171856978f, 0.88945790080738174f, 1.0f}, -{0.99876970396001541f, 0.94232987312572092f, 0.88589004229142632f, 1.0f}, -{0.99864667435601695f, 0.94048442906574392f, 0.88232218377547089f, 1.0f}, -{0.99852364475201849f, 0.93863898500576703f, 0.87875432525951558f, 1.0f}, -{0.99840061514802003f, 0.93679354094579015f, 0.87518646674356015f, 1.0f}, -{0.99827758554402157f, 0.93494809688581315f, 0.87161860822760473f, 1.0f}, -{0.99815455594002311f, 0.93310265282583627f, 0.86805074971164931f, 1.0f}, -{0.99803152633602465f, 0.93125720876585927f, 0.86448289119569399f, 1.0f}, -{0.9979084967320262f, 0.92941176470588238f, 0.86091503267973857f, 1.0f}, -{0.99778546712802774f, 0.9275663206459055f, 0.85734717416378314f, 1.0f}, -{0.99766243752402928f, 0.9257208765859285f, 0.85377931564782772f, 1.0f}, -{0.99753940792003082f, 0.92387543252595161f, 0.85021145713187241f, 1.0f}, -{0.99741637831603236f, 0.92202998846597461f, 0.84664359861591698f, 1.0f}, -{0.99729334871203379f, 0.92018454440599773f, 0.84307574009996156f, 1.0f}, -{0.99717031910803533f, 0.91833910034602073f, 0.83950788158400613f, 1.0f}, -{0.99704728950403687f, 0.91649365628604385f, 0.83594002306805071f, 1.0f}, -{0.99692425990003841f, 0.91464821222606696f, 0.83237216455209539f, 1.0f}, -{0.99680123029603995f, 0.91280276816608996f, 0.82880430603613997f, 1.0f}, -{0.99667820069204149f, 0.91095732410611308f, 0.82523644752018455f, 1.0f}, -{0.99655517108804303f, 0.90911188004613608f, 0.82166858900422912f, 1.0f}, -{0.99643214148404458f, 0.90726643598615919f, 0.8181007304882737f, 1.0f}, -{0.99630911188004612f, 0.90542099192618231f, 0.81453287197231838f, 1.0f}, -{0.99618608227604766f, 0.90357554786620531f, 0.81096501345636296f, 1.0f}, -{0.9960630526720492f, 0.90162245290272969f, 0.80716647443291045f, 1.0f}, -{0.99594002306805074f, 0.89891580161476359f, 0.80175317185697814f, 1.0f}, -{0.99581699346405228f, 0.89620915032679738f, 0.79633986928104572f, 1.0f}, -{0.99569396386005382f, 0.89350249903883128f, 0.79092656670511341f, 1.0f}, -{0.99557093425605536f, 0.89079584775086507f, 0.7855132641291811f, 1.0f}, -{0.9954479046520569f, 0.88808919646289897f, 0.78009996155324879f, 1.0f}, -{0.99532487504805844f, 0.88538254517493276f, 0.77468665897731648f, 1.0f}, -{0.99520184544405998f, 0.88267589388696654f, 0.76927335640138406f, 1.0f}, -{0.99507881584006153f, 0.87996924259900045f, 0.76386005382545175f, 1.0f}, -{0.99495578623606307f, 0.87726259131103423f, 0.75844675124951944f, 1.0f}, -{0.99483275663206461f, 0.87455594002306802f, 0.75303344867358712f, 1.0f}, -{0.99470972702806615f, 0.87184928873510192f, 0.7476201460976547f, 1.0f}, -{0.99458669742406769f, 0.86914263744713571f, 0.74220684352172239f, 1.0f}, -{0.99446366782006923f, 0.86643598615916961f, 0.73679354094579008f, 1.0f}, -{0.99434063821607077f, 0.8637293348712034f, 0.73138023836985777f, 1.0f}, -{0.99421760861207231f, 0.86102268358323719f, 0.72596693579392535f, 1.0f}, -{0.99409457900807385f, 0.85831603229527109f, 0.72055363321799304f, 1.0f}, -{0.99397154940407539f, 0.85560938100730488f, 0.71514033064206073f, 1.0f}, -{0.99384851980007693f, 0.85290272971933867f, 0.70972702806612842f, 1.0f}, -{0.99372549019607848f, 0.85019607843137257f, 0.70431372549019611f, 1.0f}, -{0.99360246059208002f, 0.84748942714340636f, 0.69890042291426369f, 1.0f}, -{0.99347943098808156f, 0.84478277585544026f, 0.69348712033833149f, 1.0f}, -{0.9933564013840831f, 0.84207612456747405f, 0.68807381776239906f, 1.0f}, -{0.99323337178008464f, 0.83936947327950784f, 0.68266051518646675f, 1.0f}, -{0.99311034217608618f, 0.83666282199154174f, 0.67724721261053444f, 1.0f}, -{0.99298731257208772f, 0.83395617070357553f, 0.67183391003460213f, 1.0f}, -{0.99286428296808926f, 0.83124951941560932f, 0.66642060745866971f, 1.0f}, -{0.9927412533640908f, 0.82854286812764322f, 0.6610073048827374f, 1.0f}, -{0.99261822376009234f, 0.82583621683967701f, 0.65559400230680509f, 1.0f}, -{0.99249519415609389f, 0.82312956555171091f, 0.65018069973087278f, 1.0f}, -{0.99237216455209543f, 0.8204229142637447f, 0.64476739715494036f, 1.0f}, -{0.99224913494809697f, 0.8177162629757786f, 0.63935409457900805f, 1.0f}, -{0.99215686274509807f, 0.81464052287581701f, 0.63360246059207992f, 1.0f}, -{0.99215686274509807f, 0.81045751633986929f, 0.62683583237216456f, 1.0f}, -{0.99215686274509807f, 0.80627450980392157f, 0.6200692041522492f, 1.0f}, -{0.99215686274509807f, 0.80209150326797385f, 0.61330257593233373f, 1.0f}, -{0.99215686274509807f, 0.79790849673202613f, 0.60653594771241826f, 1.0f}, -{0.99215686274509807f, 0.79372549019607841f, 0.59976931949250289f, 1.0f}, -{0.99215686274509807f, 0.78954248366013069f, 0.59300269127258742f, 1.0f}, -{0.99215686274509807f, 0.78535947712418297f, 0.58623606305267206f, 1.0f}, -{0.99215686274509807f, 0.78117647058823525f, 0.57946943483275659f, 1.0f}, -{0.99215686274509807f, 0.77699346405228753f, 0.57270280661284123f, 1.0f}, -{0.99215686274509807f, 0.77281045751633992f, 0.56593617839292587f, 1.0f}, -{0.99215686274509807f, 0.7686274509803922f, 0.5591695501730104f, 1.0f}, -{0.99215686274509807f, 0.76444444444444448f, 0.55240292195309493f, 1.0f}, -{0.99215686274509807f, 0.76026143790849676f, 0.54563629373317957f, 1.0f}, -{0.99215686274509807f, 0.75607843137254904f, 0.5388696655132641f, 1.0f}, -{0.99215686274509807f, 0.75189542483660132f, 0.53210303729334874f, 1.0f}, -{0.99215686274509807f, 0.7477124183006536f, 0.52533640907343326f, 1.0f}, -{0.99215686274509807f, 0.74352941176470588f, 0.5185697808535179f, 1.0f}, -{0.99215686274509807f, 0.73934640522875827f, 0.51180315263360254f, 1.0f}, -{0.99215686274509807f, 0.73516339869281044f, 0.50503652441368707f, 1.0f}, -{0.99215686274509807f, 0.73098039215686272f, 0.4982698961937716f, 1.0f}, -{0.99215686274509807f, 0.726797385620915f, 0.49150326797385624f, 1.0f}, -{0.99215686274509807f, 0.72261437908496728f, 0.48473663975394077f, 1.0f}, -{0.99215686274509807f, 0.71843137254901968f, 0.47797001153402541f, 1.0f}, -{0.99215686274509807f, 0.71424836601307196f, 0.47120338331410994f, 1.0f}, -{0.99215686274509807f, 0.71006535947712424f, 0.46443675509419458f, 1.0f}, -{0.99215686274509807f, 0.70588235294117652f, 0.45767012687427922f, 1.0f}, -{0.99215686274509807f, 0.7016993464052288f, 0.45090349865436374f, 1.0f}, -{0.99215686274509807f, 0.69751633986928108f, 0.44413687043444827f, 1.0f}, -{0.99215686274509807f, 0.69333333333333336f, 0.43737024221453291f, 1.0f}, -{0.99215686274509807f, 0.68915032679738564f, 0.43060361399461744f, 1.0f}, -{0.99215686274509807f, 0.68496732026143792f, 0.42383698577470208f, 1.0f}, -{0.99215686274509807f, 0.68083044982698959f, 0.41743944636678204f, 1.0f}, -{0.99215686274509807f, 0.67677047289504044f, 0.4116570549788543f, 1.0f}, -{0.99215686274509807f, 0.67271049596309118f, 0.40587466359092667f, 1.0f}, -{0.99215686274509807f, 0.66865051903114192f, 0.40009227220299887f, 1.0f}, -{0.99215686274509807f, 0.66459054209919266f, 0.39430988081507112f, 1.0f}, -{0.99215686274509807f, 0.6605305651672434f, 0.38852748942714344f, 1.0f}, -{0.99215686274509807f, 0.65647058823529414f, 0.38274509803921569f, 1.0f}, -{0.99215686274509807f, 0.65241061130334488f, 0.37696270665128795f, 1.0f}, -{0.99215686274509807f, 0.64835063437139562f, 0.37118031526336026f, 1.0f}, -{0.99215686274509807f, 0.64429065743944636f, 0.36539792387543252f, 1.0f}, -{0.99215686274509807f, 0.64023068050749721f, 0.35961553248750489f, 1.0f}, -{0.99215686274509807f, 0.63617070357554795f, 0.35383314109957709f, 1.0f}, -{0.99215686274509807f, 0.63211072664359869f, 0.3480507497116494f, 1.0f}, -{0.99215686274509807f, 0.62805074971164943f, 0.34226835832372166f, 1.0f}, -{0.99215686274509807f, 0.62399077277970016f, 0.33648596693579391f, 1.0f}, -{0.99215686274509807f, 0.6199307958477509f, 0.33070357554786622f, 1.0f}, -{0.99215686274509807f, 0.61587081891580164f, 0.32492118415993848f, 1.0f}, -{0.99215686274509807f, 0.61181084198385238f, 0.31913879277201079f, 1.0f}, -{0.99215686274509807f, 0.60775086505190323f, 0.31335640138408316f, 1.0f}, -{0.99215686274509807f, 0.60369088811995386f, 0.30757400999615536f, 1.0f}, -{0.99215686274509807f, 0.5996309111880046f, 0.30179161860822762f, 1.0f}, -{0.99215686274509807f, 0.59557093425605534f, 0.29600922722029988f, 1.0f}, -{0.99215686274509807f, 0.59151095732410619f, 0.29022683583237219f, 1.0f}, -{0.99215686274509807f, 0.58745098039215693f, 0.28444444444444444f, 1.0f}, -{0.99215686274509807f, 0.58339100346020767f, 0.2786620530565167f, 1.0f}, -{0.99215686274509807f, 0.57933102652825841f, 0.27287966166858901f, 1.0f}, -{0.99215686274509807f, 0.57527104959630915f, 0.26709727028066138f, 1.0f}, -{0.99215686274509807f, 0.57121107266435989f, 0.26131487889273358f, 1.0f}, -{0.99215686274509807f, 0.56715109573241063f, 0.25553248750480584f, 1.0f}, -{0.99215686274509807f, 0.56309111880046137f, 0.24975009611687812f, 1.0f}, -{0.99215686274509807f, 0.5590311418685121f, 0.24396770472895041f, 1.0f}, -{0.99215686274509807f, 0.55497116493656296f, 0.23818531334102269f, 1.0f}, -{0.99141868512110731f, 0.55072664359861601f, 0.23277201076509035f, 1.0f}, -{0.98994232987312569f, 0.54629757785467126f, 0.22772779700115339f, 1.0f}, -{0.98846597462514418f, 0.54186851211072662f, 0.22268358323721646f, 1.0f}, -{0.98698961937716267f, 0.53743944636678198f, 0.2176393694732795f, 1.0f}, -{0.98551326412918117f, 0.53301038062283757f, 0.2125951557093427f, 1.0f}, -{0.98403690888119955f, 0.52858131487889271f, 0.2075509419454056f, 1.0f}, -{0.98256055363321804f, 0.52415224913494807f, 0.20250672818146867f, 1.0f}, -{0.98108419838523642f, 0.51972318339100343f, 0.19746251441753171f, 1.0f}, -{0.97960784313725491f, 0.5152941176470589f, 0.19241830065359478f, 1.0f}, -{0.9781314878892734f, 0.51086505190311415f, 0.18737408688965784f, 1.0f}, -{0.97665513264129178f, 0.50643598615916952f, 0.18232987312572088f, 1.0f}, -{0.97517877739331027f, 0.50200692041522488f, 0.17728565936178392f, 1.0f}, -{0.97370242214532876f, 0.4975778546712803f, 0.17224144559784699f, 1.0f}, -{0.97222606689734714f, 0.49314878892733566f, 0.16719723183391005f, 1.0f}, -{0.97074971164936563f, 0.48871972318339102f, 0.16215301806997309f, 1.0f}, -{0.96927335640138412f, 0.48429065743944638f, 0.15710880430603613f, 1.0f}, -{0.9677970011534025f, 0.47986159169550174f, 0.1520645905420992f, 1.0f}, -{0.96632064590542099f, 0.47543252595155711f, 0.14702037677816224f, 1.0f}, -{0.96484429065743949f, 0.47100346020761247f, 0.14197616301422528f, 1.0f}, -{0.96336793540945787f, 0.46657439446366783f, 0.13693194925028834f, 1.0f}, -{0.96189158016147636f, 0.4621453287197233f, 0.13188773548635155f, 1.0f}, -{0.96041522491349485f, 0.45771626297577855f, 0.12684352172241448f, 1.0f}, -{0.95893886966551323f, 0.45328719723183392f, 0.12179930795847752f, 1.0f}, -{0.95746251441753172f, 0.44885813148788928f, 0.11675509419454057f, 1.0f}, -{0.95598615916955021f, 0.44442906574394464f, 0.11171088043060362f, 1.0f}, -{0.95450980392156859f, 0.44f, 0.10666666666666666f, 1.0f}, -{0.95303344867358708f, 0.43557093425605536f, 0.10162245290272973f, 1.0f}, -{0.95155709342560546f, 0.43114186851211073f, 0.096578239138792765f, 1.0f}, -{0.95008073817762395f, 0.42671280276816603f, 0.091534025374855832f, 1.0f}, -{0.94860438292964244f, 0.4222837370242214f, 0.086489811610918871f, 1.0f}, -{0.94712802768166082f, 0.41785467128027676f, 0.081445597846981937f, 1.0f}, -{0.94565167243367931f, 0.41342560553633212f, 0.076401384083044976f, 1.0f}, -{0.94325259515570936f, 0.40922722029988462f, 0.073125720876585934f, 1.0f}, -{0.94029988465974623f, 0.40516724336793541f, 0.070911188004613615f, 1.0f}, -{0.9373471741637831f, 0.40110726643598615f, 0.068696655132641296f, 1.0f}, -{0.93439446366782009f, 0.39704728950403689f, 0.066482122260668977f, 1.0f}, -{0.93144175317185707f, 0.39298731257208774f, 0.064267589388696714f, 1.0f}, -{0.92848904267589383f, 0.38892733564013837f, 0.062053056516724339f, 1.0f}, -{0.92553633217993081f, 0.38486735870818911f, 0.05983852364475202f, 1.0f}, -{0.92258362168396768f, 0.38080738177623991f, 0.057623990772779701f, 1.0f}, -{0.91963091118800455f, 0.37674740484429065f, 0.055409457900807382f, 1.0f}, -{0.91667820069204153f, 0.37268742791234138f, 0.053194925028835063f, 1.0f}, -{0.9137254901960784f, 0.36862745098039212f, 0.050980392156862744f, 1.0f}, -{0.91077277970011528f, 0.36456747404844292f, 0.048765859284890425f, 1.0f}, -{0.90782006920415226f, 0.36050749711649366f, 0.046551326412918106f, 1.0f}, -{0.90486735870818913f, 0.3564475201845444f, 0.044336793540945788f, 1.0f}, -{0.901914648212226f, 0.35238754325259514f, 0.042122260668973475f, 1.0f}, -{0.89896193771626298f, 0.34832756632064588f, 0.039907727797001157f, 1.0f}, -{0.89600922722029985f, 0.34426758938869662f, 0.037693194925028831f, 1.0f}, -{0.89305651672433672f, 0.34020761245674741f, 0.035478662053056512f, 1.0f}, -{0.89010380622837371f, 0.33614763552479815f, 0.033264129181084193f, 1.0f}, -{0.88715109573241058f, 0.33208765859284889f, 0.031049596309111881f, 1.0f}, -{0.88419838523644756f, 0.32802768166089974f, 0.028835063437139624f, 1.0f}, -{0.88124567474048443f, 0.32396770472895042f, 0.026620530565167243f, 1.0f}, -{0.8782929642445213f, 0.31990772779700116f, 0.024405997693194924f, 1.0f}, -{0.87534025374855817f, 0.3158477508650519f, 0.022191464821222605f, 1.0f}, -{0.87238754325259515f, 0.31178777393310264f, 0.019976931949250286f, 1.0f}, -{0.86943483275663203f, 0.30772779700115338f, 0.017762399077277967f, 1.0f}, -{0.8664821222606689f, 0.30366782006920412f, 0.015547866205305648f, 1.0f}, -{0.86352941176470588f, 0.29960784313725486f, 0.013333333333333329f, 1.0f}, -{0.86057670126874275f, 0.29554786620530565f, 0.011118800461361017f, 1.0f}, -{0.85762399077277962f, 0.29148788927335639f, 0.008904267589388698f, 1.0f}, -{0.8546712802768166f, 0.28742791234140713f, 0.006689734717416379f, 1.0f}, -{0.85171856978085347f, 0.28336793540945793f, 0.0044752018454440601f, 1.0f}, -{0.84627450980392149f, 0.28069204152249133f, 0.0041061130334486733f, 1.0f}, -{0.83999999999999997f, 0.27847750865051901f, 0.0043521722414455975f, 1.0f}, -{0.83372549019607844f, 0.27626297577854669f, 0.0045982314494425218f, 1.0f}, -{0.82745098039215681f, 0.27404844290657437f, 0.004844290657439446f, 1.0f}, -{0.8211764705882354f, 0.27183391003460211f, 0.0050903498654363633f, 1.0f}, -{0.81490196078431376f, 0.26961937716262974f, 0.0053364090734332945f, 1.0f}, -{0.80862745098039213f, 0.26740484429065742f, 0.0055824682814302187f, 1.0f}, -{0.8023529411764706f, 0.2651903114186851f, 0.0058285274894271429f, 1.0f}, -{0.79607843137254897f, 0.26297577854671278f, 0.0060745866974240672f, 1.0f}, -{0.78980392156862744f, 0.26076124567474046f, 0.0063206459054209914f, 1.0f}, -{0.78352941176470581f, 0.25854671280276814f, 0.0065667051134179156f, 1.0f}, -{0.77725490196078428f, 0.25633217993079582f, 0.0068127643214148399f, 1.0f}, -{0.77098039215686276f, 0.2541176470588235f, 0.0070588235294117641f, 1.0f}, -{0.76470588235294112f, 0.25190311418685118f, 0.0073048827374086883f, 1.0f}, -{0.7584313725490196f, 0.24968858131487889f, 0.0075509419454056126f, 1.0f}, -{0.75215686274509808f, 0.24747404844290657f, 0.0077970011534025368f, 1.0f}, -{0.74588235294117644f, 0.24525951557093426f, 0.0080430603613994602f, 1.0f}, -{0.73960784313725492f, 0.24304498269896194f, 0.0082891195693963853f, 1.0f}, -{0.73333333333333328f, 0.24083044982698962f, 0.0085351787773933104f, 1.0f}, -{0.72705882352941176f, 0.2386159169550173f, 0.0087812379853902337f, 1.0f}, -{0.72078431372549034f, 0.23640138408304504f, 0.0090272971933871501f, 1.0f}, -{0.7145098039215686f, 0.23418685121107266f, 0.0092733564013840822f, 1.0f}, -{0.70823529411764707f, 0.23197231833910034f, 0.0095194156093810073f, 1.0f}, -{0.70196078431372544f, 0.22975778546712802f, 0.0097654748173779306f, 1.0f}, -{0.69568627450980391f, 0.2275432525951557f, 0.010011534025374854f, 1.0f}, -{0.68941176470588239f, 0.22532871972318338f, 0.010257593233371779f, 1.0f}, -{0.68313725490196076f, 0.22311418685121107f, 0.010503652441368702f, 1.0f}, -{0.67686274509803923f, 0.22089965397923875f, 0.010749711649365626f, 1.0f}, -{0.67058823529411771f, 0.21868512110726643f, 0.010995770857362551f, 1.0f}, -{0.66431372549019607f, 0.21647058823529411f, 0.011241830065359476f, 1.0f}, -{0.65803921568627455f, 0.21425605536332179f, 0.011487889273356399f, 1.0f}, -{0.65176470588235302f, 0.21204152249134947f, 0.011733948481353323f, 1.0f}, -{0.64678200692041521f, 0.21014994232987314f, 0.011872356785851594f, 1.0f}, -{0.64198385236447519f, 0.20830449826989619f, 0.011995386389850055f, 1.0f}, -{0.63718569780853518f, 0.20645905420991925f, 0.012118415993848518f, 1.0f}, -{0.63238754325259516f, 0.20461361014994234f, 0.01224144559784698f, 1.0f}, -{0.62758938869665526f, 0.20276816608996545f, 0.012364475201845439f, 1.0f}, -{0.62279123414071513f, 0.20092272202998845f, 0.012487504805843905f, 1.0f}, -{0.61799307958477512f, 0.19907727797001154f, 0.012610534409842366f, 1.0f}, -{0.6131949250288351f, 0.1972318339100346f, 0.012733564013840829f, 1.0f}, -{0.60839677047289509f, 0.19538638985005768f, 0.012856593617839291f, 1.0f}, -{0.60359861591695507f, 0.19354094579008074f, 0.012979623221837754f, 1.0f}, -{0.59880046136101506f, 0.1916955017301038f, 0.013102652825836215f, 1.0f}, -{0.59400230680507504f, 0.18985005767012689f, 0.013225682429834677f, 1.0f}, -{0.58920415224913492f, 0.18800461361014995f, 0.01334871203383314f, 1.0f}, -{0.5844059976931949f, 0.186159169550173f, 0.013471741637831602f, 1.0f}, -{0.57960784313725489f, 0.18431372549019609f, 0.013594771241830065f, 1.0f}, -{0.57480968858131487f, 0.18246828143021915f, 0.013717800845828526f, 1.0f}, -{0.57001153402537486f, 0.18062283737024221f, 0.013840830449826988f, 1.0f}, -{0.56521337946943484f, 0.17877739331026529f, 0.013963860053825451f, 1.0f}, -{0.56041522491349482f, 0.17693194925028835f, 0.014086889657823913f, 1.0f}, -{0.55561707035755481f, 0.17508650519031144f, 0.014209919261822374f, 1.0f}, -{0.55081891580161491f, 0.17324106113033455f, 0.014332948865820833f, 1.0f}, -{0.54602076124567478f, 0.17139561707035755f, 0.014455978469819299f, 1.0f}, -{0.54122260668973476f, 0.16955017301038064f, 0.014579008073817762f, 1.0f}, -{0.53642445213379475f, 0.1677047289504037f, 0.014702037677816224f, 1.0f}, -{0.53162629757785473f, 0.16585928489042678f, 0.014825067281814687f, 1.0f}, -{0.52682814302191461f, 0.16401384083044984f, 0.014948096885813148f, 1.0f}, -{0.52202998846597459f, 0.1621683967704729f, 0.01507112648981161f, 1.0f}, -{0.51723183391003458f, 0.16032295271049596f, 0.015194156093810073f, 1.0f}, -{0.51243367935409456f, 0.15847750865051904f, 0.015317185697808535f, 1.0f}, -{0.50763552479815455f, 0.1566320645905421f, 0.015440215301806996f, 1.0f}, -{0.50283737024221453f, 0.15478662053056519f, 0.015563244905805459f, 1.0f}, -{0.49803921568627452f, 0.15294117647058825f, 0.015686274509803921f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential/Oranges.txt b/extern/tfn/colormaps/sequential/Oranges.txt deleted file mode 100644 index addd91c..0000000 --- a/extern/tfn/colormaps/sequential/Oranges.txt +++ /dev/null @@ -1,256 +0,0 @@ -(1.0, 0.96078431372549022, 0.92156862745098034, 1.0) -(0.99987697039600154, 0.95893886966551334, 0.91800076893502491, 1.0) -(0.99975394079200308, 0.95709342560553634, 0.91443291041906949, 1.0) -(0.99963091118800462, 0.95524798154555945, 0.91086505190311418, 1.0) -(0.99950788158400616, 0.95340253748558246, 0.90729719338715875, 1.0) -(0.9993848519800077, 0.95155709342560557, 0.90372933487120333, 1.0) -(0.99926182237600925, 0.94971164936562857, 0.9001614763552479, 1.0) -(0.99913879277201079, 0.94786620530565169, 0.89659361783929259, 1.0) -(0.99901576316801233, 0.9460207612456748, 0.89302575932333716, 1.0) -(0.99889273356401387, 0.9441753171856978, 0.88945790080738174, 1.0) -(0.99876970396001541, 0.94232987312572092, 0.88589004229142632, 1.0) -(0.99864667435601695, 0.94048442906574392, 0.88232218377547089, 1.0) -(0.99852364475201849, 0.93863898500576703, 0.87875432525951558, 1.0) -(0.99840061514802003, 0.93679354094579015, 0.87518646674356015, 1.0) -(0.99827758554402157, 0.93494809688581315, 0.87161860822760473, 1.0) -(0.99815455594002311, 0.93310265282583627, 0.86805074971164931, 1.0) -(0.99803152633602465, 0.93125720876585927, 0.86448289119569399, 1.0) -(0.9979084967320262, 0.92941176470588238, 0.86091503267973857, 1.0) -(0.99778546712802774, 0.9275663206459055, 0.85734717416378314, 1.0) -(0.99766243752402928, 0.9257208765859285, 0.85377931564782772, 1.0) -(0.99753940792003082, 0.92387543252595161, 0.85021145713187241, 1.0) -(0.99741637831603236, 0.92202998846597461, 0.84664359861591698, 1.0) -(0.99729334871203379, 0.92018454440599773, 0.84307574009996156, 1.0) -(0.99717031910803533, 0.91833910034602073, 0.83950788158400613, 1.0) -(0.99704728950403687, 0.91649365628604385, 0.83594002306805071, 1.0) -(0.99692425990003841, 0.91464821222606696, 0.83237216455209539, 1.0) -(0.99680123029603995, 0.91280276816608996, 0.82880430603613997, 1.0) -(0.99667820069204149, 0.91095732410611308, 0.82523644752018455, 1.0) -(0.99655517108804303, 0.90911188004613608, 0.82166858900422912, 1.0) -(0.99643214148404458, 0.90726643598615919, 0.8181007304882737, 1.0) -(0.99630911188004612, 0.90542099192618231, 0.81453287197231838, 1.0) -(0.99618608227604766, 0.90357554786620531, 0.81096501345636296, 1.0) -(0.9960630526720492, 0.90162245290272969, 0.80716647443291045, 1.0) -(0.99594002306805074, 0.89891580161476359, 0.80175317185697814, 1.0) -(0.99581699346405228, 0.89620915032679738, 0.79633986928104572, 1.0) -(0.99569396386005382, 0.89350249903883128, 0.79092656670511341, 1.0) -(0.99557093425605536, 0.89079584775086507, 0.7855132641291811, 1.0) -(0.9954479046520569, 0.88808919646289897, 0.78009996155324879, 1.0) -(0.99532487504805844, 0.88538254517493276, 0.77468665897731648, 1.0) -(0.99520184544405998, 0.88267589388696654, 0.76927335640138406, 1.0) -(0.99507881584006153, 0.87996924259900045, 0.76386005382545175, 1.0) -(0.99495578623606307, 0.87726259131103423, 0.75844675124951944, 1.0) -(0.99483275663206461, 0.87455594002306802, 0.75303344867358712, 1.0) -(0.99470972702806615, 0.87184928873510192, 0.7476201460976547, 1.0) -(0.99458669742406769, 0.86914263744713571, 0.74220684352172239, 1.0) -(0.99446366782006923, 0.86643598615916961, 0.73679354094579008, 1.0) -(0.99434063821607077, 0.8637293348712034, 0.73138023836985777, 1.0) -(0.99421760861207231, 0.86102268358323719, 0.72596693579392535, 1.0) -(0.99409457900807385, 0.85831603229527109, 0.72055363321799304, 1.0) -(0.99397154940407539, 0.85560938100730488, 0.71514033064206073, 1.0) -(0.99384851980007693, 0.85290272971933867, 0.70972702806612842, 1.0) -(0.99372549019607848, 0.85019607843137257, 0.70431372549019611, 1.0) -(0.99360246059208002, 0.84748942714340636, 0.69890042291426369, 1.0) -(0.99347943098808156, 0.84478277585544026, 0.69348712033833149, 1.0) -(0.9933564013840831, 0.84207612456747405, 0.68807381776239906, 1.0) -(0.99323337178008464, 0.83936947327950784, 0.68266051518646675, 1.0) -(0.99311034217608618, 0.83666282199154174, 0.67724721261053444, 1.0) -(0.99298731257208772, 0.83395617070357553, 0.67183391003460213, 1.0) -(0.99286428296808926, 0.83124951941560932, 0.66642060745866971, 1.0) -(0.9927412533640908, 0.82854286812764322, 0.6610073048827374, 1.0) -(0.99261822376009234, 0.82583621683967701, 0.65559400230680509, 1.0) -(0.99249519415609389, 0.82312956555171091, 0.65018069973087278, 1.0) -(0.99237216455209543, 0.8204229142637447, 0.64476739715494036, 1.0) -(0.99224913494809697, 0.8177162629757786, 0.63935409457900805, 1.0) -(0.99215686274509807, 0.81464052287581701, 0.63360246059207992, 1.0) -(0.99215686274509807, 0.81045751633986929, 0.62683583237216456, 1.0) -(0.99215686274509807, 0.80627450980392157, 0.6200692041522492, 1.0) -(0.99215686274509807, 0.80209150326797385, 0.61330257593233373, 1.0) -(0.99215686274509807, 0.79790849673202613, 0.60653594771241826, 1.0) -(0.99215686274509807, 0.79372549019607841, 0.59976931949250289, 1.0) -(0.99215686274509807, 0.78954248366013069, 0.59300269127258742, 1.0) -(0.99215686274509807, 0.78535947712418297, 0.58623606305267206, 1.0) -(0.99215686274509807, 0.78117647058823525, 0.57946943483275659, 1.0) -(0.99215686274509807, 0.77699346405228753, 0.57270280661284123, 1.0) -(0.99215686274509807, 0.77281045751633992, 0.56593617839292587, 1.0) -(0.99215686274509807, 0.7686274509803922, 0.5591695501730104, 1.0) -(0.99215686274509807, 0.76444444444444448, 0.55240292195309493, 1.0) -(0.99215686274509807, 0.76026143790849676, 0.54563629373317957, 1.0) -(0.99215686274509807, 0.75607843137254904, 0.5388696655132641, 1.0) -(0.99215686274509807, 0.75189542483660132, 0.53210303729334874, 1.0) -(0.99215686274509807, 0.7477124183006536, 0.52533640907343326, 1.0) -(0.99215686274509807, 0.74352941176470588, 0.5185697808535179, 1.0) -(0.99215686274509807, 0.73934640522875827, 0.51180315263360254, 1.0) -(0.99215686274509807, 0.73516339869281044, 0.50503652441368707, 1.0) -(0.99215686274509807, 0.73098039215686272, 0.4982698961937716, 1.0) -(0.99215686274509807, 0.726797385620915, 0.49150326797385624, 1.0) -(0.99215686274509807, 0.72261437908496728, 0.48473663975394077, 1.0) -(0.99215686274509807, 0.71843137254901968, 0.47797001153402541, 1.0) -(0.99215686274509807, 0.71424836601307196, 0.47120338331410994, 1.0) -(0.99215686274509807, 0.71006535947712424, 0.46443675509419458, 1.0) -(0.99215686274509807, 0.70588235294117652, 0.45767012687427922, 1.0) -(0.99215686274509807, 0.7016993464052288, 0.45090349865436374, 1.0) -(0.99215686274509807, 0.69751633986928108, 0.44413687043444827, 1.0) -(0.99215686274509807, 0.69333333333333336, 0.43737024221453291, 1.0) -(0.99215686274509807, 0.68915032679738564, 0.43060361399461744, 1.0) -(0.99215686274509807, 0.68496732026143792, 0.42383698577470208, 1.0) -(0.99215686274509807, 0.68083044982698959, 0.41743944636678204, 1.0) -(0.99215686274509807, 0.67677047289504044, 0.4116570549788543, 1.0) -(0.99215686274509807, 0.67271049596309118, 0.40587466359092667, 1.0) -(0.99215686274509807, 0.66865051903114192, 0.40009227220299887, 1.0) -(0.99215686274509807, 0.66459054209919266, 0.39430988081507112, 1.0) -(0.99215686274509807, 0.6605305651672434, 0.38852748942714344, 1.0) -(0.99215686274509807, 0.65647058823529414, 0.38274509803921569, 1.0) -(0.99215686274509807, 0.65241061130334488, 0.37696270665128795, 1.0) -(0.99215686274509807, 0.64835063437139562, 0.37118031526336026, 1.0) -(0.99215686274509807, 0.64429065743944636, 0.36539792387543252, 1.0) -(0.99215686274509807, 0.64023068050749721, 0.35961553248750489, 1.0) -(0.99215686274509807, 0.63617070357554795, 0.35383314109957709, 1.0) -(0.99215686274509807, 0.63211072664359869, 0.3480507497116494, 1.0) -(0.99215686274509807, 0.62805074971164943, 0.34226835832372166, 1.0) -(0.99215686274509807, 0.62399077277970016, 0.33648596693579391, 1.0) -(0.99215686274509807, 0.6199307958477509, 0.33070357554786622, 1.0) -(0.99215686274509807, 0.61587081891580164, 0.32492118415993848, 1.0) -(0.99215686274509807, 0.61181084198385238, 0.31913879277201079, 1.0) -(0.99215686274509807, 0.60775086505190323, 0.31335640138408316, 1.0) -(0.99215686274509807, 0.60369088811995386, 0.30757400999615536, 1.0) -(0.99215686274509807, 0.5996309111880046, 0.30179161860822762, 1.0) -(0.99215686274509807, 0.59557093425605534, 0.29600922722029988, 1.0) -(0.99215686274509807, 0.59151095732410619, 0.29022683583237219, 1.0) -(0.99215686274509807, 0.58745098039215693, 0.28444444444444444, 1.0) -(0.99215686274509807, 0.58339100346020767, 0.2786620530565167, 1.0) -(0.99215686274509807, 0.57933102652825841, 0.27287966166858901, 1.0) -(0.99215686274509807, 0.57527104959630915, 0.26709727028066138, 1.0) -(0.99215686274509807, 0.57121107266435989, 0.26131487889273358, 1.0) -(0.99215686274509807, 0.56715109573241063, 0.25553248750480584, 1.0) -(0.99215686274509807, 0.56309111880046137, 0.24975009611687812, 1.0) -(0.99215686274509807, 0.5590311418685121, 0.24396770472895041, 1.0) -(0.99215686274509807, 0.55497116493656296, 0.23818531334102269, 1.0) -(0.99141868512110731, 0.55072664359861601, 0.23277201076509035, 1.0) -(0.98994232987312569, 0.54629757785467126, 0.22772779700115339, 1.0) -(0.98846597462514418, 0.54186851211072662, 0.22268358323721646, 1.0) -(0.98698961937716267, 0.53743944636678198, 0.2176393694732795, 1.0) -(0.98551326412918117, 0.53301038062283757, 0.2125951557093427, 1.0) -(0.98403690888119955, 0.52858131487889271, 0.2075509419454056, 1.0) -(0.98256055363321804, 0.52415224913494807, 0.20250672818146867, 1.0) -(0.98108419838523642, 0.51972318339100343, 0.19746251441753171, 1.0) -(0.97960784313725491, 0.5152941176470589, 0.19241830065359478, 1.0) -(0.9781314878892734, 0.51086505190311415, 0.18737408688965784, 1.0) -(0.97665513264129178, 0.50643598615916952, 0.18232987312572088, 1.0) -(0.97517877739331027, 0.50200692041522488, 0.17728565936178392, 1.0) -(0.97370242214532876, 0.4975778546712803, 0.17224144559784699, 1.0) -(0.97222606689734714, 0.49314878892733566, 0.16719723183391005, 1.0) -(0.97074971164936563, 0.48871972318339102, 0.16215301806997309, 1.0) -(0.96927335640138412, 0.48429065743944638, 0.15710880430603613, 1.0) -(0.9677970011534025, 0.47986159169550174, 0.1520645905420992, 1.0) -(0.96632064590542099, 0.47543252595155711, 0.14702037677816224, 1.0) -(0.96484429065743949, 0.47100346020761247, 0.14197616301422528, 1.0) -(0.96336793540945787, 0.46657439446366783, 0.13693194925028834, 1.0) -(0.96189158016147636, 0.4621453287197233, 0.13188773548635155, 1.0) -(0.96041522491349485, 0.45771626297577855, 0.12684352172241448, 1.0) -(0.95893886966551323, 0.45328719723183392, 0.12179930795847752, 1.0) -(0.95746251441753172, 0.44885813148788928, 0.11675509419454057, 1.0) -(0.95598615916955021, 0.44442906574394464, 0.11171088043060362, 1.0) -(0.95450980392156859, 0.44, 0.10666666666666666, 1.0) -(0.95303344867358708, 0.43557093425605536, 0.10162245290272973, 1.0) -(0.95155709342560546, 0.43114186851211073, 0.096578239138792765, 1.0) -(0.95008073817762395, 0.42671280276816603, 0.091534025374855832, 1.0) -(0.94860438292964244, 0.4222837370242214, 0.086489811610918871, 1.0) -(0.94712802768166082, 0.41785467128027676, 0.081445597846981937, 1.0) -(0.94565167243367931, 0.41342560553633212, 0.076401384083044976, 1.0) -(0.94325259515570936, 0.40922722029988462, 0.073125720876585934, 1.0) -(0.94029988465974623, 0.40516724336793541, 0.070911188004613615, 1.0) -(0.9373471741637831, 0.40110726643598615, 0.068696655132641296, 1.0) -(0.93439446366782009, 0.39704728950403689, 0.066482122260668977, 1.0) -(0.93144175317185707, 0.39298731257208774, 0.064267589388696714, 1.0) -(0.92848904267589383, 0.38892733564013837, 0.062053056516724339, 1.0) -(0.92553633217993081, 0.38486735870818911, 0.05983852364475202, 1.0) -(0.92258362168396768, 0.38080738177623991, 0.057623990772779701, 1.0) -(0.91963091118800455, 0.37674740484429065, 0.055409457900807382, 1.0) -(0.91667820069204153, 0.37268742791234138, 0.053194925028835063, 1.0) -(0.9137254901960784, 0.36862745098039212, 0.050980392156862744, 1.0) -(0.91077277970011528, 0.36456747404844292, 0.048765859284890425, 1.0) -(0.90782006920415226, 0.36050749711649366, 0.046551326412918106, 1.0) -(0.90486735870818913, 0.3564475201845444, 0.044336793540945788, 1.0) -(0.901914648212226, 0.35238754325259514, 0.042122260668973475, 1.0) -(0.89896193771626298, 0.34832756632064588, 0.039907727797001157, 1.0) -(0.89600922722029985, 0.34426758938869662, 0.037693194925028831, 1.0) -(0.89305651672433672, 0.34020761245674741, 0.035478662053056512, 1.0) -(0.89010380622837371, 0.33614763552479815, 0.033264129181084193, 1.0) -(0.88715109573241058, 0.33208765859284889, 0.031049596309111881, 1.0) -(0.88419838523644756, 0.32802768166089974, 0.028835063437139624, 1.0) -(0.88124567474048443, 0.32396770472895042, 0.026620530565167243, 1.0) -(0.8782929642445213, 0.31990772779700116, 0.024405997693194924, 1.0) -(0.87534025374855817, 0.3158477508650519, 0.022191464821222605, 1.0) -(0.87238754325259515, 0.31178777393310264, 0.019976931949250286, 1.0) -(0.86943483275663203, 0.30772779700115338, 0.017762399077277967, 1.0) -(0.8664821222606689, 0.30366782006920412, 0.015547866205305648, 1.0) -(0.86352941176470588, 0.29960784313725486, 0.013333333333333329, 1.0) -(0.86057670126874275, 0.29554786620530565, 0.011118800461361017, 1.0) -(0.85762399077277962, 0.29148788927335639, 0.008904267589388698, 1.0) -(0.8546712802768166, 0.28742791234140713, 0.006689734717416379, 1.0) -(0.85171856978085347, 0.28336793540945793, 0.0044752018454440601, 1.0) -(0.84627450980392149, 0.28069204152249133, 0.0041061130334486733, 1.0) -(0.83999999999999997, 0.27847750865051901, 0.0043521722414455975, 1.0) -(0.83372549019607844, 0.27626297577854669, 0.0045982314494425218, 1.0) -(0.82745098039215681, 0.27404844290657437, 0.004844290657439446, 1.0) -(0.8211764705882354, 0.27183391003460211, 0.0050903498654363633, 1.0) -(0.81490196078431376, 0.26961937716262974, 0.0053364090734332945, 1.0) -(0.80862745098039213, 0.26740484429065742, 0.0055824682814302187, 1.0) -(0.8023529411764706, 0.2651903114186851, 0.0058285274894271429, 1.0) -(0.79607843137254897, 0.26297577854671278, 0.0060745866974240672, 1.0) -(0.78980392156862744, 0.26076124567474046, 0.0063206459054209914, 1.0) -(0.78352941176470581, 0.25854671280276814, 0.0065667051134179156, 1.0) -(0.77725490196078428, 0.25633217993079582, 0.0068127643214148399, 1.0) -(0.77098039215686276, 0.2541176470588235, 0.0070588235294117641, 1.0) -(0.76470588235294112, 0.25190311418685118, 0.0073048827374086883, 1.0) -(0.7584313725490196, 0.24968858131487889, 0.0075509419454056126, 1.0) -(0.75215686274509808, 0.24747404844290657, 0.0077970011534025368, 1.0) -(0.74588235294117644, 0.24525951557093426, 0.0080430603613994602, 1.0) -(0.73960784313725492, 0.24304498269896194, 0.0082891195693963853, 1.0) -(0.73333333333333328, 0.24083044982698962, 0.0085351787773933104, 1.0) -(0.72705882352941176, 0.2386159169550173, 0.0087812379853902337, 1.0) -(0.72078431372549034, 0.23640138408304504, 0.0090272971933871501, 1.0) -(0.7145098039215686, 0.23418685121107266, 0.0092733564013840822, 1.0) -(0.70823529411764707, 0.23197231833910034, 0.0095194156093810073, 1.0) -(0.70196078431372544, 0.22975778546712802, 0.0097654748173779306, 1.0) -(0.69568627450980391, 0.2275432525951557, 0.010011534025374854, 1.0) -(0.68941176470588239, 0.22532871972318338, 0.010257593233371779, 1.0) -(0.68313725490196076, 0.22311418685121107, 0.010503652441368702, 1.0) -(0.67686274509803923, 0.22089965397923875, 0.010749711649365626, 1.0) -(0.67058823529411771, 0.21868512110726643, 0.010995770857362551, 1.0) -(0.66431372549019607, 0.21647058823529411, 0.011241830065359476, 1.0) -(0.65803921568627455, 0.21425605536332179, 0.011487889273356399, 1.0) -(0.65176470588235302, 0.21204152249134947, 0.011733948481353323, 1.0) -(0.64678200692041521, 0.21014994232987314, 0.011872356785851594, 1.0) -(0.64198385236447519, 0.20830449826989619, 0.011995386389850055, 1.0) -(0.63718569780853518, 0.20645905420991925, 0.012118415993848518, 1.0) -(0.63238754325259516, 0.20461361014994234, 0.01224144559784698, 1.0) -(0.62758938869665526, 0.20276816608996545, 0.012364475201845439, 1.0) -(0.62279123414071513, 0.20092272202998845, 0.012487504805843905, 1.0) -(0.61799307958477512, 0.19907727797001154, 0.012610534409842366, 1.0) -(0.6131949250288351, 0.1972318339100346, 0.012733564013840829, 1.0) -(0.60839677047289509, 0.19538638985005768, 0.012856593617839291, 1.0) -(0.60359861591695507, 0.19354094579008074, 0.012979623221837754, 1.0) -(0.59880046136101506, 0.1916955017301038, 0.013102652825836215, 1.0) -(0.59400230680507504, 0.18985005767012689, 0.013225682429834677, 1.0) -(0.58920415224913492, 0.18800461361014995, 0.01334871203383314, 1.0) -(0.5844059976931949, 0.186159169550173, 0.013471741637831602, 1.0) -(0.57960784313725489, 0.18431372549019609, 0.013594771241830065, 1.0) -(0.57480968858131487, 0.18246828143021915, 0.013717800845828526, 1.0) -(0.57001153402537486, 0.18062283737024221, 0.013840830449826988, 1.0) -(0.56521337946943484, 0.17877739331026529, 0.013963860053825451, 1.0) -(0.56041522491349482, 0.17693194925028835, 0.014086889657823913, 1.0) -(0.55561707035755481, 0.17508650519031144, 0.014209919261822374, 1.0) -(0.55081891580161491, 0.17324106113033455, 0.014332948865820833, 1.0) -(0.54602076124567478, 0.17139561707035755, 0.014455978469819299, 1.0) -(0.54122260668973476, 0.16955017301038064, 0.014579008073817762, 1.0) -(0.53642445213379475, 0.1677047289504037, 0.014702037677816224, 1.0) -(0.53162629757785473, 0.16585928489042678, 0.014825067281814687, 1.0) -(0.52682814302191461, 0.16401384083044984, 0.014948096885813148, 1.0) -(0.52202998846597459, 0.1621683967704729, 0.01507112648981161, 1.0) -(0.51723183391003458, 0.16032295271049596, 0.015194156093810073, 1.0) -(0.51243367935409456, 0.15847750865051904, 0.015317185697808535, 1.0) -(0.50763552479815455, 0.1566320645905421, 0.015440215301806996, 1.0) -(0.50283737024221453, 0.15478662053056519, 0.015563244905805459, 1.0) -(0.49803921568627452, 0.15294117647058825, 0.015686274509803921, 1.0) diff --git a/extern/tfn/colormaps/sequential/PuBu.cpp b/extern/tfn/colormaps/sequential/PuBu.cpp deleted file mode 100644 index 9e0dc37..0000000 --- a/extern/tfn/colormaps/sequential/PuBu.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential_PuBu; -} -const std::vector colormap::data_sequential_PuBu = /* NOLINT(cert-err58-cpp) */ -{ -{1.0f, 0.96862745098039216f, 0.98431372549019602f, 1.0f}, -{0.99766243752402917f, 0.96665897731641681f, 0.98320645905420989f, 1.0f}, -{0.99532487504805844f, 0.96469050365244136f, 0.98209919261822376f, 1.0f}, -{0.99298731257208761f, 0.96272202998846601f, 0.98099192618223752f, 1.0f}, -{0.99064975009611689f, 0.96075355632449055f, 0.97988465974625139f, 1.0f}, -{0.98831218762014605f, 0.95878508266051521f, 0.97877739331026525f, 1.0f}, -{0.98597462514417533f, 0.95681660899653975f, 0.97767012687427912f, 1.0f}, -{0.9836370626682045f, 0.95484813533256441f, 0.97656286043829288f, 1.0f}, -{0.98129950019223378f, 0.95287966166858906f, 0.97545559400230675f, 1.0f}, -{0.97896193771626294f, 0.95091118800461361f, 0.97434832756632062f, 1.0f}, -{0.97662437524029222f, 0.94894271434063826f, 0.97324106113033448f, 1.0f}, -{0.97428681276432139f, 0.9469742406766628f, 0.97213379469434824f, 1.0f}, -{0.97194925028835066f, 0.94500576701268746f, 0.97102652825836211f, 1.0f}, -{0.96961168781237983f, 0.943037293348712f, 0.96991926182237598f, 1.0f}, -{0.96727412533640911f, 0.94106881968473666f, 0.96881199538638985f, 1.0f}, -{0.96493656286043827f, 0.9391003460207612f, 0.9677047289504036f, 1.0f}, -{0.96259900038446755f, 0.93713187235678586f, 0.96659746251441747f, 1.0f}, -{0.96026143790849672f, 0.93516339869281051f, 0.96549019607843134f, 1.0f}, -{0.957923875432526f, 0.93319492502883505f, 0.96438292964244521f, 1.0f}, -{0.95558631295655516f, 0.93122645136485971f, 0.96327566320645897f, 1.0f}, -{0.95324875048058444f, 0.92925797770088425f, 0.96216839677047283f, 1.0f}, -{0.95091118800461361f, 0.92728950403690891f, 0.9610611303344867f, 1.0f}, -{0.94857362552864288f, 0.92532103037293345f, 0.95995386389850057f, 1.0f}, -{0.94623606305267205f, 0.92335255670895811f, 0.95884659746251433f, 1.0f}, -{0.94389850057670133f, 0.92138408304498265f, 0.9577393310265282f, 1.0f}, -{0.94156093810073049f, 0.9194156093810073f, 0.95663206459054206f, 1.0f}, -{0.93922337562475977f, 0.91744713571703196f, 0.95552479815455593f, 1.0f}, -{0.93688581314878894f, 0.9154786620530565f, 0.95441753171856969f, 1.0f}, -{0.93454825067281821f, 0.91351018838908116f, 0.95331026528258356f, 1.0f}, -{0.93221068819684738f, 0.9115417147251057f, 0.95220299884659743f, 1.0f}, -{0.92987312572087666f, 0.90957324106113036f, 0.95109573241061129f, 1.0f}, -{0.92753556324490583f, 0.9076047673971549f, 0.94998846597462505f, 1.0f}, -{0.92505959246443681f, 0.90554402153018065f, 0.94883506343713953f, 1.0f}, -{0.92161476355247984f, 0.90283737024221455f, 0.94735870818915802f, 1.0f}, -{0.91816993464052288f, 0.90013071895424834f, 0.9458823529411764f, 1.0f}, -{0.91472510572856602f, 0.89742406766628224f, 0.94440599769319489f, 1.0f}, -{0.91128027681660906f, 0.89471741637831603f, 0.94292964244521338f, 1.0f}, -{0.90783544790465209f, 0.89201076509034993f, 0.94145328719723176f, 1.0f}, -{0.90439061899269513f, 0.88930411380238372f, 0.93997693194925025f, 1.0f}, -{0.90094579008073816f, 0.88659746251441751f, 0.93850057670126874f, 1.0f}, -{0.89750096116878131f, 0.88389081122645141f, 0.93702422145328712f, 1.0f}, -{0.89405613225682434f, 0.8811841599384852f, 0.93554786620530561f, 1.0f}, -{0.89061130334486738f, 0.87847750865051899f, 0.9340715109573241f, 1.0f}, -{0.88716647443291041f, 0.87577085736255289f, 0.93259515570934259f, 1.0f}, -{0.88372164552095356f, 0.87306420607458668f, 0.93111880046136097f, 1.0f}, -{0.88027681660899659f, 0.87035755478662058f, 0.92964244521337946f, 1.0f}, -{0.87683198769703963f, 0.86765090349865437f, 0.92816608996539796f, 1.0f}, -{0.87338715878508266f, 0.86494425221068816f, 0.92668973471741634f, 1.0f}, -{0.8699423298731257f, 0.86223760092272206f, 0.92521337946943483f, 1.0f}, -{0.86649750096116884f, 0.85953094963475585f, 0.92373702422145332f, 1.0f}, -{0.86305267204921188f, 0.85682429834678964f, 0.9222606689734717f, 1.0f}, -{0.85960784313725491f, 0.85411764705882354f, 0.92078431372549019f, 1.0f}, -{0.85616301422529795f, 0.85141099577085733f, 0.91930795847750868f, 1.0f}, -{0.85271818531334109f, 0.84870434448289123f, 0.91783160322952706f, 1.0f}, -{0.84927335640138413f, 0.84599769319492502f, 0.91635524798154555f, 1.0f}, -{0.84582852748942716f, 0.8432910419069588f, 0.91487889273356404f, 1.0f}, -{0.8423836985774702f, 0.84058439061899271f, 0.91340253748558242f, 1.0f}, -{0.83893886966551334f, 0.83787773933102649f, 0.91192618223760091f, 1.0f}, -{0.83549404075355627f, 0.83517108804306028f, 0.9104498269896194f, 1.0f}, -{0.83204921184159941f, 0.83246443675509418f, 0.90897347174163778f, 1.0f}, -{0.82860438292964245f, 0.82975778546712797f, 0.90749711649365628f, 1.0f}, -{0.82515955401768548f, 0.82705113417916187f, 0.90602076124567477f, 1.0f}, -{0.82171472510572852f, 0.82434448289119566f, 0.90454440599769326f, 1.0f}, -{0.81826989619377166f, 0.82163783160322956f, 0.90306805074971164f, 1.0f}, -{0.81439446366782009f, 0.81899269511726258f, 0.90162245290272969f, 1.0f}, -{0.8092272202998847f, 0.81653210303729329f, 0.90026912725874664f, 1.0f}, -{0.80405997693194931f, 0.81407151095732411f, 0.89891580161476359f, 1.0f}, -{0.7988927335640138f, 0.81161091887735481f, 0.89756247597078043f, 1.0f}, -{0.79372549019607841f, 0.80915032679738563f, 0.89620915032679738f, 1.0f}, -{0.78855824682814302f, 0.80668973471741634f, 0.89485582468281433f, 1.0f}, -{0.78339100346020762f, 0.80422914263744716f, 0.89350249903883117f, 1.0f}, -{0.77822376009227223f, 0.80176855055747787f, 0.89214917339484812f, 1.0f}, -{0.77305651672433684f, 0.79930795847750868f, 0.89079584775086507f, 1.0f}, -{0.76788927335640134f, 0.79684736639753939f, 0.88944252210688202f, 1.0f}, -{0.76272202998846605f, 0.79438677431757021f, 0.88808919646289886f, 1.0f}, -{0.75755478662053055f, 0.79192618223760092f, 0.88673587081891581f, 1.0f}, -{0.75238754325259516f, 0.78946559015763162f, 0.88538254517493276f, 1.0f}, -{0.74722029988465977f, 0.78700499807766244f, 0.88402921953094959f, 1.0f}, -{0.74205305651672437f, 0.78454440599769315f, 0.88267589388696654f, 1.0f}, -{0.73688581314878898f, 0.78208381391772397f, 0.8813225682429835f, 1.0f}, -{0.73171856978085348f, 0.77962322183775468f, 0.87996924259900033f, 1.0f}, -{0.72655132641291809f, 0.77716262975778549f, 0.87861591695501728f, 1.0f}, -{0.7213840830449828f, 0.77470203767781631f, 0.87726259131103423f, 1.0f}, -{0.7162168396770473f, 0.77224144559784702f, 0.87590926566705107f, 1.0f}, -{0.71104959630911191f, 0.76978085351787773f, 0.87455594002306802f, 1.0f}, -{0.70588235294117652f, 0.76732026143790855f, 0.87320261437908497f, 1.0f}, -{0.70071510957324112f, 0.76485966935793925f, 0.87184928873510181f, 1.0f}, -{0.69554786620530562f, 0.76239907727797007f, 0.87049596309111876f, 1.0f}, -{0.69038062283737023f, 0.75993848519800078f, 0.86914263744713571f, 1.0f}, -{0.68521337946943484f, 0.7574778931180316f, 0.86778931180315255f, 1.0f}, -{0.68004613610149955f, 0.75501730103806231f, 0.8664359861591695f, 1.0f}, -{0.67487889273356405f, 0.75255670895809312f, 0.86508266051518645f, 1.0f}, -{0.66971164936562866f, 0.75009611687812383f, 0.86372933487120329f, 1.0f}, -{0.66454440599769327f, 0.74763552479815454f, 0.86237600922722024f, 1.0f}, -{0.65937716262975776f, 0.74517493271818536f, 0.86102268358323719f, 1.0f}, -{0.65420991926182237f, 0.74271434063821606f, 0.85966935793925403f, 1.0f}, -{0.6486735870818916f, 0.74025374855824688f, 0.85826989619377159f, 1.0f}, -{0.64252210688196854f, 0.73779315647827759f, 0.85679354094579008f, 1.0f}, -{0.63637062668204547f, 0.73533256439830841f, 0.85531718569780846f, 1.0f}, -{0.63021914648212229f, 0.73287197231833912f, 0.85384083044982695f, 1.0f}, -{0.62406766628219912f, 0.73041138023836993f, 0.85236447520184544f, 1.0f}, -{0.61791618608227605f, 0.72795078815840064f, 0.85088811995386382f, 1.0f}, -{0.61176470588235299f, 0.72549019607843135f, 0.84941176470588231f, 1.0f}, -{0.60561322568242981f, 0.72302960399846217f, 0.8479354094579008f, 1.0f}, -{0.59946174548250675f, 0.72056901191849287f, 0.84645905420991918f, 1.0f}, -{0.59331026528258368f, 0.71810841983852369f, 0.84498269896193767f, 1.0f}, -{0.58715878508266062f, 0.7156478277585544f, 0.84350634371395616f, 1.0f}, -{0.58100730488273744f, 0.71318723567858522f, 0.84202998846597454f, 1.0f}, -{0.57485582468281426f, 0.71072664359861593f, 0.84055363321799303f, 1.0f}, -{0.5687043444828912f, 0.70826605151864663f, 0.83907727797001153f, 1.0f}, -{0.56255286428296813f, 0.70580545943867745f, 0.83760092272203002f, 1.0f}, -{0.55640138408304496f, 0.70334486735870816f, 0.8361245674740484f, 1.0f}, -{0.55024990388312189f, 0.70088427527873898f, 0.83464821222606689f, 1.0f}, -{0.54409842368319883f, 0.69842368319876968f, 0.83317185697808538f, 1.0f}, -{0.53794694348327576f, 0.6959630911188005f, 0.83169550173010376f, 1.0f}, -{0.53179546328335259f, 0.69350249903883121f, 0.83021914648212225f, 1.0f}, -{0.52564398308342941f, 0.69104190695886203f, 0.82874279123414074f, 1.0f}, -{0.51949250288350635f, 0.68858131487889274f, 0.82726643598615912f, 1.0f}, -{0.51334102268358328f, 0.68612072279892344f, 0.82579008073817761f, 1.0f}, -{0.50718954248366011f, 0.68366013071895426f, 0.8243137254901961f, 1.0f}, -{0.50103806228373704f, 0.68119953863898497f, 0.82283737024221448f, 1.0f}, -{0.49488658208381392f, 0.67873894655901579f, 0.82136101499423297f, 1.0f}, -{0.48873510188389091f, 0.6762783544790465f, 0.81988465974625147f, 1.0f}, -{0.48258362168396773f, 0.67381776239907731f, 0.81840830449826985f, 1.0f}, -{0.47643214148404461f, 0.67135717031910802f, 0.81693194925028834f, 1.0f}, -{0.47028066128412149f, 0.66889657823913873f, 0.81545559400230683f, 1.0f}, -{0.46412918108419843f, 0.66643598615916955f, 0.81397923875432521f, 1.0f}, -{0.45797770088427525f, 0.66397539407920025f, 0.8125028835063437f, 1.0f}, -{0.45108804306036138f, 0.66120722798923492f, 0.8108419838523645f, 1.0f}, -{0.44346020761245675f, 0.65813148788927334f, 0.8089965397923875f, 1.0f}, -{0.43583237216455206f, 0.65505574778931175f, 0.80715109573241062f, 1.0f}, -{0.42820453671664743f, 0.65198000768935027f, 0.80530565167243373f, 1.0f}, -{0.42057670126874303f, 0.64890426758938879f, 0.80346020761245684f, 1.0f}, -{0.41294886582083812f, 0.6458285274894271f, 0.80161476355247985f, 1.0f}, -{0.40532103037293349f, 0.64275278738946562f, 0.79976931949250285f, 1.0f}, -{0.39769319492502886f, 0.63967704728950403f, 0.79792387543252596f, 1.0f}, -{0.39006535947712417f, 0.63660130718954244f, 0.79607843137254897f, 1.0f}, -{0.38243752402921954f, 0.63352556708958097f, 0.79423298731257208f, 1.0f}, -{0.37480968858131486f, 0.63044982698961938f, 0.79238754325259519f, 1.0f}, -{0.36718185313341023f, 0.62737408688965779f, 0.7905420991926182f, 1.0f}, -{0.35955401768550554f, 0.62429834678969631f, 0.78869665513264131f, 1.0f}, -{0.35192618223760092f, 0.62122260668973472f, 0.78685121107266431f, 1.0f}, -{0.34429834678969629f, 0.61814686658977314f, 0.78500576701268743f, 1.0f}, -{0.3366705113417916f, 0.61507112648981155f, 0.78316032295271054f, 1.0f}, -{0.32904267589388692f, 0.61199538638985007f, 0.78131487889273354f, 1.0f}, -{0.32141484044598229f, 0.60891964628988848f, 0.77946943483275666f, 1.0f}, -{0.31378700499807766f, 0.6058439061899269f, 0.77762399077277966f, 1.0f}, -{0.30615916955017297f, 0.60276816608996542f, 0.77577854671280277f, 1.0f}, -{0.29853133410226856f, 0.59969242599000394f, 0.77393310265282589f, 1.0f}, -{0.29090349865436371f, 0.59661668589004224f, 0.77208765859284889f, 1.0f}, -{0.28327566320645903f, 0.59354094579008077f, 0.770242214532872f, 1.0f}, -{0.2756478277585544f, 0.59046520569011918f, 0.76839677047289501f, 1.0f}, -{0.26801999231064977f, 0.58738946559015759f, 0.76655132641291812f, 1.0f}, -{0.26039215686274508f, 0.584313725490196f, 0.76470588235294112f, 1.0f}, -{0.2527643214148404f, 0.58123798539023452f, 0.76286043829296424f, 1.0f}, -{0.24513648596693577f, 0.57816224529027294f, 0.76101499423298735f, 1.0f}, -{0.23750865051903114f, 0.57508650519031135f, 0.75916955017301035f, 1.0f}, -{0.22988081507112648f, 0.57201076509034987f, 0.75732410611303347f, 1.0f}, -{0.22225297962322182f, 0.56893502499038828f, 0.75547866205305647f, 1.0f}, -{0.21462514417531717f, 0.56585928489042669f, 0.75363321799307958f, 1.0f}, -{0.20799692425990005f, 0.56224529027297188f, 0.75171088043060363f, 1.0f}, -{0.20196847366397538f, 0.55830834294502119f, 0.74974240676662818f, 1.0f}, -{0.19594002306805075f, 0.55437139561707038f, 0.74777393310265283f, 1.0f}, -{0.18991157247212612f, 0.55043444828911958f, 0.74580545943867738f, 1.0f}, -{0.18388312187620165f, 0.54649750096116889f, 0.74383698577470203f, 1.0f}, -{0.17785467128027682f, 0.54256055363321798f, 0.74186851211072669f, 1.0f}, -{0.17182622068435216f, 0.53862360630526718f, 0.73990003844675123f, 1.0f}, -{0.16579777008842753f, 0.53468665897731638f, 0.73793156478277588f, 1.0f}, -{0.15976931949250289f, 0.53074971164936557f, 0.73596309111880043f, 1.0f}, -{0.15374086889657823f, 0.52681276432141488f, 0.73399461745482508f, 1.0f}, -{0.1477124183006536f, 0.52287581699346408f, 0.73202614379084963f, 1.0f}, -{0.14168396770472896f, 0.51893886966551328f, 0.73005767012687428f, 1.0f}, -{0.1356555171088043f, 0.51500192233756248f, 0.72808919646289882f, 1.0f}, -{0.12962706651287967f, 0.51106497500961168f, 0.72612072279892348f, 1.0f}, -{0.12359861591695502f, 0.50712802768166088f, 0.72415224913494813f, 1.0f}, -{0.11757016532103039f, 0.50319108035371007f, 0.72218377547097268f, 1.0f}, -{0.11154171472510573f, 0.49925413302575933f, 0.72021530180699733f, 1.0f}, -{0.10551326412918108f, 0.49531718569780853f, 0.71824682814302188f, 1.0f}, -{0.099484813533256444f, 0.49138023836985772f, 0.71627835447904653f, 1.0f}, -{0.093456362937331797f, 0.48744329104190698f, 0.71430988081507107f, 1.0f}, -{0.087427912341407329f, 0.48350634371395629f, 0.71234140715109573f, 1.0f}, -{0.081399461745482515f, 0.47956939638600538f, 0.71037293348712027f, 1.0f}, -{0.075371011149557854f, 0.47563244905805457f, 0.70840445982314493f, 1.0f}, -{0.06934256055363322f, 0.47169550173010377f, 0.70643598615916958f, 1.0f}, -{0.063314109957708586f, 0.46775855440215303f, 0.70446751249519413f, 1.0f}, -{0.057285659361783925f, 0.46382160707420222f, 0.70249903883121878f, 1.0f}, -{0.051257208765859291f, 0.45988465974625142f, 0.70053056516724332f, 1.0f}, -{0.045228758169934657f, 0.45594771241830068f, 0.69856209150326798f, 1.0f}, -{0.039200307574009996f, 0.45201076509034988f, 0.69659361783929252f, 1.0f}, -{0.033171856978085362f, 0.44807381776239907f, 0.69462514417531718f, 1.0f}, -{0.027143406382160729f, 0.44413687043444827f, 0.69265667051134183f, 1.0f}, -{0.021114955786236067f, 0.44019992310649747f, 0.69068819684736638f, 1.0f}, -{0.019515570934256054f, 0.43718569780853517f, 0.68696655132641293f, 1.0f}, -{0.019392541330257591f, 0.43447904652056901f, 0.68266051518646675f, 1.0f}, -{0.019269511726259132f, 0.43177239523260286f, 0.67835447904652058f, 1.0f}, -{0.01914648212226067f, 0.4290657439446367f, 0.6740484429065744f, 1.0f}, -{0.019023452518262211f, 0.4263590926566706f, 0.66974240676662833f, 1.0f}, -{0.018900422914263745f, 0.42365244136870434f, 0.66543637062668204f, 1.0f}, -{0.018777393310265282f, 0.42094579008073818f, 0.66113033448673586f, 1.0f}, -{0.01865436370626682f, 0.41823913879277202f, 0.65682429834678968f, 1.0f}, -{0.018531334102268357f, 0.41553248750480587f, 0.6525182622068435f, 1.0f}, -{0.018408304498269894f, 0.41282583621683966f, 0.64821222606689732f, 1.0f}, -{0.018285274894271432f, 0.4101191849288735f, 0.64390618992695114f, 1.0f}, -{0.018162245290272973f, 0.40741253364090735f, 0.63960015378700497f, 1.0f}, -{0.01803921568627451f, 0.40470588235294119f, 0.63529411764705879f, 1.0f}, -{0.017916186082276048f, 0.40199923106497504f, 0.63098808150711261f, 1.0f}, -{0.017793156478277585f, 0.39929257977700883f, 0.62668204536716643f, 1.0f}, -{0.017670126874279123f, 0.39658592848904267f, 0.62237600922722036f, 1.0f}, -{0.01754709727028066f, 0.39387927720107652f, 0.61806997308727418f, 1.0f}, -{0.017424067666282197f, 0.39117262591311036f, 0.613763936947328f, 1.0f}, -{0.017301038062283738f, 0.38846597462514421f, 0.60945790080738182f, 1.0f}, -{0.017178008458285276f, 0.385759323337178f, 0.60515186466743565f, 1.0f}, -{0.017054978854286817f, 0.38305267204921195f, 0.60084582852748958f, 1.0f}, -{0.016931949250288351f, 0.38034602076124568f, 0.59653979238754329f, 1.0f}, -{0.016808919646289888f, 0.37763936947327953f, 0.59223375624759711f, 1.0f}, -{0.016685890042291426f, 0.37493271818531337f, 0.58792772010765093f, 1.0f}, -{0.016562860438292963f, 0.37222606689734716f, 0.58362168396770475f, 1.0f}, -{0.016439830834294501f, 0.36951941560938101f, 0.57931564782775857f, 1.0f}, -{0.016316801230296038f, 0.36681276432141485f, 0.57500961168781239f, 1.0f}, -{0.016193771626297579f, 0.3641061130334487f, 0.57070357554786622f, 1.0f}, -{0.016070742022299116f, 0.36139946174548254f, 0.56639753940792004f, 1.0f}, -{0.015947712418300654f, 0.35869281045751633f, 0.56209150326797386f, 1.0f}, -{0.015824682814302191f, 0.35598615916955018f, 0.55778546712802768f, 1.0f}, -{0.015701653210303729f, 0.35327950788158402f, 0.5534794309880815f, 1.0f}, -{0.015470972702806613f, 0.34928104575163399f, 0.54723567858515954f, 1.0f}, -{0.015224913494809688f, 0.34509803921568627f, 0.54071510957324109f, 1.0f}, -{0.014978854286812764f, 0.34091503267973861f, 0.53419454056132265f, 1.0f}, -{0.014732795078815839f, 0.33673202614379089f, 0.5276739715494041f, 1.0f}, -{0.014486735870818923f, 0.33254901960784328f, 0.52115340253748577f, 1.0f}, -{0.014240676662821991f, 0.32836601307189545f, 0.5146328335255671f, 1.0f}, -{0.013994617454825067f, 0.32418300653594773f, 0.50811226451364866f, 1.0f}, -{0.013748558246828142f, 0.32000000000000001f, 0.50159169550173011f, 1.0f}, -{0.013502499038831219f, 0.31581699346405229f, 0.49507112648981161f, 1.0f}, -{0.013256439830834294f, 0.31163398692810457f, 0.48855055747789311f, 1.0f}, -{0.01301038062283737f, 0.3074509803921569f, 0.48202998846597467f, 1.0f}, -{0.012764321414840445f, 0.30326797385620918f, 0.47550941945405617f, 1.0f}, -{0.012518262206843522f, 0.29908496732026146f, 0.46898885044213767f, 1.0f}, -{0.012272202998846597f, 0.29490196078431374f, 0.46246828143021917f, 1.0f}, -{0.012026143790849673f, 0.29071895424836602f, 0.45594771241830068f, 1.0f}, -{0.011780084582852748f, 0.2865359477124183f, 0.44942714340638218f, 1.0f}, -{0.011534025374855823f, 0.28235294117647058f, 0.44290657439446368f, 1.0f}, -{0.0112879661668589f, 0.27816993464052286f, 0.43638600538254518f, 1.0f}, -{0.011041906958861977f, 0.27398692810457514f, 0.42986543637062669f, 1.0f}, -{0.010795847750865051f, 0.26980392156862743f, 0.42334486735870819f, 1.0f}, -{0.010549788542868133f, 0.26562091503267987f, 0.41682429834678991f, 1.0f}, -{0.010303729334871203f, 0.26143790849673204f, 0.41030372933487125f, 1.0f}, -{0.01005767012687428f, 0.25725490196078432f, 0.40378316032295269f, 1.0f}, -{0.0098116109188773545f, 0.2530718954248366f, 0.39726259131103425f, 1.0f}, -{0.0095655517108804294f, 0.24888888888888888f, 0.3907420222991157f, 1.0f}, -{0.0093194925028835061f, 0.24470588235294116f, 0.38422145328719726f, 1.0f}, -{0.0090734332948865827f, 0.24052287581699347f, 0.3777008842752787f, 1.0f}, -{0.0088273740868896576f, 0.23633986928104575f, 0.37118031526336026f, 1.0f}, -{0.0085813148788927325f, 0.23215686274509806f, 0.36465974625144176f, 1.0f}, -{0.0083352556708958091f, 0.22797385620915034f, 0.35813917723952327f, 1.0f}, -{0.0080891964628988858f, 0.22379084967320262f, 0.35161860822760477f, 1.0f}, -{0.0078431372549019607f, 0.2196078431372549f, 0.34509803921568627f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential/PuBu.txt b/extern/tfn/colormaps/sequential/PuBu.txt deleted file mode 100644 index b2edf35..0000000 --- a/extern/tfn/colormaps/sequential/PuBu.txt +++ /dev/null @@ -1,256 +0,0 @@ -(1.0, 0.96862745098039216, 0.98431372549019602, 1.0) -(0.99766243752402917, 0.96665897731641681, 0.98320645905420989, 1.0) -(0.99532487504805844, 0.96469050365244136, 0.98209919261822376, 1.0) -(0.99298731257208761, 0.96272202998846601, 0.98099192618223752, 1.0) -(0.99064975009611689, 0.96075355632449055, 0.97988465974625139, 1.0) -(0.98831218762014605, 0.95878508266051521, 0.97877739331026525, 1.0) -(0.98597462514417533, 0.95681660899653975, 0.97767012687427912, 1.0) -(0.9836370626682045, 0.95484813533256441, 0.97656286043829288, 1.0) -(0.98129950019223378, 0.95287966166858906, 0.97545559400230675, 1.0) -(0.97896193771626294, 0.95091118800461361, 0.97434832756632062, 1.0) -(0.97662437524029222, 0.94894271434063826, 0.97324106113033448, 1.0) -(0.97428681276432139, 0.9469742406766628, 0.97213379469434824, 1.0) -(0.97194925028835066, 0.94500576701268746, 0.97102652825836211, 1.0) -(0.96961168781237983, 0.943037293348712, 0.96991926182237598, 1.0) -(0.96727412533640911, 0.94106881968473666, 0.96881199538638985, 1.0) -(0.96493656286043827, 0.9391003460207612, 0.9677047289504036, 1.0) -(0.96259900038446755, 0.93713187235678586, 0.96659746251441747, 1.0) -(0.96026143790849672, 0.93516339869281051, 0.96549019607843134, 1.0) -(0.957923875432526, 0.93319492502883505, 0.96438292964244521, 1.0) -(0.95558631295655516, 0.93122645136485971, 0.96327566320645897, 1.0) -(0.95324875048058444, 0.92925797770088425, 0.96216839677047283, 1.0) -(0.95091118800461361, 0.92728950403690891, 0.9610611303344867, 1.0) -(0.94857362552864288, 0.92532103037293345, 0.95995386389850057, 1.0) -(0.94623606305267205, 0.92335255670895811, 0.95884659746251433, 1.0) -(0.94389850057670133, 0.92138408304498265, 0.9577393310265282, 1.0) -(0.94156093810073049, 0.9194156093810073, 0.95663206459054206, 1.0) -(0.93922337562475977, 0.91744713571703196, 0.95552479815455593, 1.0) -(0.93688581314878894, 0.9154786620530565, 0.95441753171856969, 1.0) -(0.93454825067281821, 0.91351018838908116, 0.95331026528258356, 1.0) -(0.93221068819684738, 0.9115417147251057, 0.95220299884659743, 1.0) -(0.92987312572087666, 0.90957324106113036, 0.95109573241061129, 1.0) -(0.92753556324490583, 0.9076047673971549, 0.94998846597462505, 1.0) -(0.92505959246443681, 0.90554402153018065, 0.94883506343713953, 1.0) -(0.92161476355247984, 0.90283737024221455, 0.94735870818915802, 1.0) -(0.91816993464052288, 0.90013071895424834, 0.9458823529411764, 1.0) -(0.91472510572856602, 0.89742406766628224, 0.94440599769319489, 1.0) -(0.91128027681660906, 0.89471741637831603, 0.94292964244521338, 1.0) -(0.90783544790465209, 0.89201076509034993, 0.94145328719723176, 1.0) -(0.90439061899269513, 0.88930411380238372, 0.93997693194925025, 1.0) -(0.90094579008073816, 0.88659746251441751, 0.93850057670126874, 1.0) -(0.89750096116878131, 0.88389081122645141, 0.93702422145328712, 1.0) -(0.89405613225682434, 0.8811841599384852, 0.93554786620530561, 1.0) -(0.89061130334486738, 0.87847750865051899, 0.9340715109573241, 1.0) -(0.88716647443291041, 0.87577085736255289, 0.93259515570934259, 1.0) -(0.88372164552095356, 0.87306420607458668, 0.93111880046136097, 1.0) -(0.88027681660899659, 0.87035755478662058, 0.92964244521337946, 1.0) -(0.87683198769703963, 0.86765090349865437, 0.92816608996539796, 1.0) -(0.87338715878508266, 0.86494425221068816, 0.92668973471741634, 1.0) -(0.8699423298731257, 0.86223760092272206, 0.92521337946943483, 1.0) -(0.86649750096116884, 0.85953094963475585, 0.92373702422145332, 1.0) -(0.86305267204921188, 0.85682429834678964, 0.9222606689734717, 1.0) -(0.85960784313725491, 0.85411764705882354, 0.92078431372549019, 1.0) -(0.85616301422529795, 0.85141099577085733, 0.91930795847750868, 1.0) -(0.85271818531334109, 0.84870434448289123, 0.91783160322952706, 1.0) -(0.84927335640138413, 0.84599769319492502, 0.91635524798154555, 1.0) -(0.84582852748942716, 0.8432910419069588, 0.91487889273356404, 1.0) -(0.8423836985774702, 0.84058439061899271, 0.91340253748558242, 1.0) -(0.83893886966551334, 0.83787773933102649, 0.91192618223760091, 1.0) -(0.83549404075355627, 0.83517108804306028, 0.9104498269896194, 1.0) -(0.83204921184159941, 0.83246443675509418, 0.90897347174163778, 1.0) -(0.82860438292964245, 0.82975778546712797, 0.90749711649365628, 1.0) -(0.82515955401768548, 0.82705113417916187, 0.90602076124567477, 1.0) -(0.82171472510572852, 0.82434448289119566, 0.90454440599769326, 1.0) -(0.81826989619377166, 0.82163783160322956, 0.90306805074971164, 1.0) -(0.81439446366782009, 0.81899269511726258, 0.90162245290272969, 1.0) -(0.8092272202998847, 0.81653210303729329, 0.90026912725874664, 1.0) -(0.80405997693194931, 0.81407151095732411, 0.89891580161476359, 1.0) -(0.7988927335640138, 0.81161091887735481, 0.89756247597078043, 1.0) -(0.79372549019607841, 0.80915032679738563, 0.89620915032679738, 1.0) -(0.78855824682814302, 0.80668973471741634, 0.89485582468281433, 1.0) -(0.78339100346020762, 0.80422914263744716, 0.89350249903883117, 1.0) -(0.77822376009227223, 0.80176855055747787, 0.89214917339484812, 1.0) -(0.77305651672433684, 0.79930795847750868, 0.89079584775086507, 1.0) -(0.76788927335640134, 0.79684736639753939, 0.88944252210688202, 1.0) -(0.76272202998846605, 0.79438677431757021, 0.88808919646289886, 1.0) -(0.75755478662053055, 0.79192618223760092, 0.88673587081891581, 1.0) -(0.75238754325259516, 0.78946559015763162, 0.88538254517493276, 1.0) -(0.74722029988465977, 0.78700499807766244, 0.88402921953094959, 1.0) -(0.74205305651672437, 0.78454440599769315, 0.88267589388696654, 1.0) -(0.73688581314878898, 0.78208381391772397, 0.8813225682429835, 1.0) -(0.73171856978085348, 0.77962322183775468, 0.87996924259900033, 1.0) -(0.72655132641291809, 0.77716262975778549, 0.87861591695501728, 1.0) -(0.7213840830449828, 0.77470203767781631, 0.87726259131103423, 1.0) -(0.7162168396770473, 0.77224144559784702, 0.87590926566705107, 1.0) -(0.71104959630911191, 0.76978085351787773, 0.87455594002306802, 1.0) -(0.70588235294117652, 0.76732026143790855, 0.87320261437908497, 1.0) -(0.70071510957324112, 0.76485966935793925, 0.87184928873510181, 1.0) -(0.69554786620530562, 0.76239907727797007, 0.87049596309111876, 1.0) -(0.69038062283737023, 0.75993848519800078, 0.86914263744713571, 1.0) -(0.68521337946943484, 0.7574778931180316, 0.86778931180315255, 1.0) -(0.68004613610149955, 0.75501730103806231, 0.8664359861591695, 1.0) -(0.67487889273356405, 0.75255670895809312, 0.86508266051518645, 1.0) -(0.66971164936562866, 0.75009611687812383, 0.86372933487120329, 1.0) -(0.66454440599769327, 0.74763552479815454, 0.86237600922722024, 1.0) -(0.65937716262975776, 0.74517493271818536, 0.86102268358323719, 1.0) -(0.65420991926182237, 0.74271434063821606, 0.85966935793925403, 1.0) -(0.6486735870818916, 0.74025374855824688, 0.85826989619377159, 1.0) -(0.64252210688196854, 0.73779315647827759, 0.85679354094579008, 1.0) -(0.63637062668204547, 0.73533256439830841, 0.85531718569780846, 1.0) -(0.63021914648212229, 0.73287197231833912, 0.85384083044982695, 1.0) -(0.62406766628219912, 0.73041138023836993, 0.85236447520184544, 1.0) -(0.61791618608227605, 0.72795078815840064, 0.85088811995386382, 1.0) -(0.61176470588235299, 0.72549019607843135, 0.84941176470588231, 1.0) -(0.60561322568242981, 0.72302960399846217, 0.8479354094579008, 1.0) -(0.59946174548250675, 0.72056901191849287, 0.84645905420991918, 1.0) -(0.59331026528258368, 0.71810841983852369, 0.84498269896193767, 1.0) -(0.58715878508266062, 0.7156478277585544, 0.84350634371395616, 1.0) -(0.58100730488273744, 0.71318723567858522, 0.84202998846597454, 1.0) -(0.57485582468281426, 0.71072664359861593, 0.84055363321799303, 1.0) -(0.5687043444828912, 0.70826605151864663, 0.83907727797001153, 1.0) -(0.56255286428296813, 0.70580545943867745, 0.83760092272203002, 1.0) -(0.55640138408304496, 0.70334486735870816, 0.8361245674740484, 1.0) -(0.55024990388312189, 0.70088427527873898, 0.83464821222606689, 1.0) -(0.54409842368319883, 0.69842368319876968, 0.83317185697808538, 1.0) -(0.53794694348327576, 0.6959630911188005, 0.83169550173010376, 1.0) -(0.53179546328335259, 0.69350249903883121, 0.83021914648212225, 1.0) -(0.52564398308342941, 0.69104190695886203, 0.82874279123414074, 1.0) -(0.51949250288350635, 0.68858131487889274, 0.82726643598615912, 1.0) -(0.51334102268358328, 0.68612072279892344, 0.82579008073817761, 1.0) -(0.50718954248366011, 0.68366013071895426, 0.8243137254901961, 1.0) -(0.50103806228373704, 0.68119953863898497, 0.82283737024221448, 1.0) -(0.49488658208381392, 0.67873894655901579, 0.82136101499423297, 1.0) -(0.48873510188389091, 0.6762783544790465, 0.81988465974625147, 1.0) -(0.48258362168396773, 0.67381776239907731, 0.81840830449826985, 1.0) -(0.47643214148404461, 0.67135717031910802, 0.81693194925028834, 1.0) -(0.47028066128412149, 0.66889657823913873, 0.81545559400230683, 1.0) -(0.46412918108419843, 0.66643598615916955, 0.81397923875432521, 1.0) -(0.45797770088427525, 0.66397539407920025, 0.8125028835063437, 1.0) -(0.45108804306036138, 0.66120722798923492, 0.8108419838523645, 1.0) -(0.44346020761245675, 0.65813148788927334, 0.8089965397923875, 1.0) -(0.43583237216455206, 0.65505574778931175, 0.80715109573241062, 1.0) -(0.42820453671664743, 0.65198000768935027, 0.80530565167243373, 1.0) -(0.42057670126874303, 0.64890426758938879, 0.80346020761245684, 1.0) -(0.41294886582083812, 0.6458285274894271, 0.80161476355247985, 1.0) -(0.40532103037293349, 0.64275278738946562, 0.79976931949250285, 1.0) -(0.39769319492502886, 0.63967704728950403, 0.79792387543252596, 1.0) -(0.39006535947712417, 0.63660130718954244, 0.79607843137254897, 1.0) -(0.38243752402921954, 0.63352556708958097, 0.79423298731257208, 1.0) -(0.37480968858131486, 0.63044982698961938, 0.79238754325259519, 1.0) -(0.36718185313341023, 0.62737408688965779, 0.7905420991926182, 1.0) -(0.35955401768550554, 0.62429834678969631, 0.78869665513264131, 1.0) -(0.35192618223760092, 0.62122260668973472, 0.78685121107266431, 1.0) -(0.34429834678969629, 0.61814686658977314, 0.78500576701268743, 1.0) -(0.3366705113417916, 0.61507112648981155, 0.78316032295271054, 1.0) -(0.32904267589388692, 0.61199538638985007, 0.78131487889273354, 1.0) -(0.32141484044598229, 0.60891964628988848, 0.77946943483275666, 1.0) -(0.31378700499807766, 0.6058439061899269, 0.77762399077277966, 1.0) -(0.30615916955017297, 0.60276816608996542, 0.77577854671280277, 1.0) -(0.29853133410226856, 0.59969242599000394, 0.77393310265282589, 1.0) -(0.29090349865436371, 0.59661668589004224, 0.77208765859284889, 1.0) -(0.28327566320645903, 0.59354094579008077, 0.770242214532872, 1.0) -(0.2756478277585544, 0.59046520569011918, 0.76839677047289501, 1.0) -(0.26801999231064977, 0.58738946559015759, 0.76655132641291812, 1.0) -(0.26039215686274508, 0.584313725490196, 0.76470588235294112, 1.0) -(0.2527643214148404, 0.58123798539023452, 0.76286043829296424, 1.0) -(0.24513648596693577, 0.57816224529027294, 0.76101499423298735, 1.0) -(0.23750865051903114, 0.57508650519031135, 0.75916955017301035, 1.0) -(0.22988081507112648, 0.57201076509034987, 0.75732410611303347, 1.0) -(0.22225297962322182, 0.56893502499038828, 0.75547866205305647, 1.0) -(0.21462514417531717, 0.56585928489042669, 0.75363321799307958, 1.0) -(0.20799692425990005, 0.56224529027297188, 0.75171088043060363, 1.0) -(0.20196847366397538, 0.55830834294502119, 0.74974240676662818, 1.0) -(0.19594002306805075, 0.55437139561707038, 0.74777393310265283, 1.0) -(0.18991157247212612, 0.55043444828911958, 0.74580545943867738, 1.0) -(0.18388312187620165, 0.54649750096116889, 0.74383698577470203, 1.0) -(0.17785467128027682, 0.54256055363321798, 0.74186851211072669, 1.0) -(0.17182622068435216, 0.53862360630526718, 0.73990003844675123, 1.0) -(0.16579777008842753, 0.53468665897731638, 0.73793156478277588, 1.0) -(0.15976931949250289, 0.53074971164936557, 0.73596309111880043, 1.0) -(0.15374086889657823, 0.52681276432141488, 0.73399461745482508, 1.0) -(0.1477124183006536, 0.52287581699346408, 0.73202614379084963, 1.0) -(0.14168396770472896, 0.51893886966551328, 0.73005767012687428, 1.0) -(0.1356555171088043, 0.51500192233756248, 0.72808919646289882, 1.0) -(0.12962706651287967, 0.51106497500961168, 0.72612072279892348, 1.0) -(0.12359861591695502, 0.50712802768166088, 0.72415224913494813, 1.0) -(0.11757016532103039, 0.50319108035371007, 0.72218377547097268, 1.0) -(0.11154171472510573, 0.49925413302575933, 0.72021530180699733, 1.0) -(0.10551326412918108, 0.49531718569780853, 0.71824682814302188, 1.0) -(0.099484813533256444, 0.49138023836985772, 0.71627835447904653, 1.0) -(0.093456362937331797, 0.48744329104190698, 0.71430988081507107, 1.0) -(0.087427912341407329, 0.48350634371395629, 0.71234140715109573, 1.0) -(0.081399461745482515, 0.47956939638600538, 0.71037293348712027, 1.0) -(0.075371011149557854, 0.47563244905805457, 0.70840445982314493, 1.0) -(0.06934256055363322, 0.47169550173010377, 0.70643598615916958, 1.0) -(0.063314109957708586, 0.46775855440215303, 0.70446751249519413, 1.0) -(0.057285659361783925, 0.46382160707420222, 0.70249903883121878, 1.0) -(0.051257208765859291, 0.45988465974625142, 0.70053056516724332, 1.0) -(0.045228758169934657, 0.45594771241830068, 0.69856209150326798, 1.0) -(0.039200307574009996, 0.45201076509034988, 0.69659361783929252, 1.0) -(0.033171856978085362, 0.44807381776239907, 0.69462514417531718, 1.0) -(0.027143406382160729, 0.44413687043444827, 0.69265667051134183, 1.0) -(0.021114955786236067, 0.44019992310649747, 0.69068819684736638, 1.0) -(0.019515570934256054, 0.43718569780853517, 0.68696655132641293, 1.0) -(0.019392541330257591, 0.43447904652056901, 0.68266051518646675, 1.0) -(0.019269511726259132, 0.43177239523260286, 0.67835447904652058, 1.0) -(0.01914648212226067, 0.4290657439446367, 0.6740484429065744, 1.0) -(0.019023452518262211, 0.4263590926566706, 0.66974240676662833, 1.0) -(0.018900422914263745, 0.42365244136870434, 0.66543637062668204, 1.0) -(0.018777393310265282, 0.42094579008073818, 0.66113033448673586, 1.0) -(0.01865436370626682, 0.41823913879277202, 0.65682429834678968, 1.0) -(0.018531334102268357, 0.41553248750480587, 0.6525182622068435, 1.0) -(0.018408304498269894, 0.41282583621683966, 0.64821222606689732, 1.0) -(0.018285274894271432, 0.4101191849288735, 0.64390618992695114, 1.0) -(0.018162245290272973, 0.40741253364090735, 0.63960015378700497, 1.0) -(0.01803921568627451, 0.40470588235294119, 0.63529411764705879, 1.0) -(0.017916186082276048, 0.40199923106497504, 0.63098808150711261, 1.0) -(0.017793156478277585, 0.39929257977700883, 0.62668204536716643, 1.0) -(0.017670126874279123, 0.39658592848904267, 0.62237600922722036, 1.0) -(0.01754709727028066, 0.39387927720107652, 0.61806997308727418, 1.0) -(0.017424067666282197, 0.39117262591311036, 0.613763936947328, 1.0) -(0.017301038062283738, 0.38846597462514421, 0.60945790080738182, 1.0) -(0.017178008458285276, 0.385759323337178, 0.60515186466743565, 1.0) -(0.017054978854286817, 0.38305267204921195, 0.60084582852748958, 1.0) -(0.016931949250288351, 0.38034602076124568, 0.59653979238754329, 1.0) -(0.016808919646289888, 0.37763936947327953, 0.59223375624759711, 1.0) -(0.016685890042291426, 0.37493271818531337, 0.58792772010765093, 1.0) -(0.016562860438292963, 0.37222606689734716, 0.58362168396770475, 1.0) -(0.016439830834294501, 0.36951941560938101, 0.57931564782775857, 1.0) -(0.016316801230296038, 0.36681276432141485, 0.57500961168781239, 1.0) -(0.016193771626297579, 0.3641061130334487, 0.57070357554786622, 1.0) -(0.016070742022299116, 0.36139946174548254, 0.56639753940792004, 1.0) -(0.015947712418300654, 0.35869281045751633, 0.56209150326797386, 1.0) -(0.015824682814302191, 0.35598615916955018, 0.55778546712802768, 1.0) -(0.015701653210303729, 0.35327950788158402, 0.5534794309880815, 1.0) -(0.015470972702806613, 0.34928104575163399, 0.54723567858515954, 1.0) -(0.015224913494809688, 0.34509803921568627, 0.54071510957324109, 1.0) -(0.014978854286812764, 0.34091503267973861, 0.53419454056132265, 1.0) -(0.014732795078815839, 0.33673202614379089, 0.5276739715494041, 1.0) -(0.014486735870818923, 0.33254901960784328, 0.52115340253748577, 1.0) -(0.014240676662821991, 0.32836601307189545, 0.5146328335255671, 1.0) -(0.013994617454825067, 0.32418300653594773, 0.50811226451364866, 1.0) -(0.013748558246828142, 0.32000000000000001, 0.50159169550173011, 1.0) -(0.013502499038831219, 0.31581699346405229, 0.49507112648981161, 1.0) -(0.013256439830834294, 0.31163398692810457, 0.48855055747789311, 1.0) -(0.01301038062283737, 0.3074509803921569, 0.48202998846597467, 1.0) -(0.012764321414840445, 0.30326797385620918, 0.47550941945405617, 1.0) -(0.012518262206843522, 0.29908496732026146, 0.46898885044213767, 1.0) -(0.012272202998846597, 0.29490196078431374, 0.46246828143021917, 1.0) -(0.012026143790849673, 0.29071895424836602, 0.45594771241830068, 1.0) -(0.011780084582852748, 0.2865359477124183, 0.44942714340638218, 1.0) -(0.011534025374855823, 0.28235294117647058, 0.44290657439446368, 1.0) -(0.0112879661668589, 0.27816993464052286, 0.43638600538254518, 1.0) -(0.011041906958861977, 0.27398692810457514, 0.42986543637062669, 1.0) -(0.010795847750865051, 0.26980392156862743, 0.42334486735870819, 1.0) -(0.010549788542868133, 0.26562091503267987, 0.41682429834678991, 1.0) -(0.010303729334871203, 0.26143790849673204, 0.41030372933487125, 1.0) -(0.01005767012687428, 0.25725490196078432, 0.40378316032295269, 1.0) -(0.0098116109188773545, 0.2530718954248366, 0.39726259131103425, 1.0) -(0.0095655517108804294, 0.24888888888888888, 0.3907420222991157, 1.0) -(0.0093194925028835061, 0.24470588235294116, 0.38422145328719726, 1.0) -(0.0090734332948865827, 0.24052287581699347, 0.3777008842752787, 1.0) -(0.0088273740868896576, 0.23633986928104575, 0.37118031526336026, 1.0) -(0.0085813148788927325, 0.23215686274509806, 0.36465974625144176, 1.0) -(0.0083352556708958091, 0.22797385620915034, 0.35813917723952327, 1.0) -(0.0080891964628988858, 0.22379084967320262, 0.35161860822760477, 1.0) -(0.0078431372549019607, 0.2196078431372549, 0.34509803921568627, 1.0) diff --git a/extern/tfn/colormaps/sequential/PuBuGn.cpp b/extern/tfn/colormaps/sequential/PuBuGn.cpp deleted file mode 100644 index c1d5535..0000000 --- a/extern/tfn/colormaps/sequential/PuBuGn.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential_PuBuGn; -} -const std::vector colormap::data_sequential_PuBuGn = /* NOLINT(cert-err58-cpp) */ -{ -{1.0f, 0.96862745098039216f, 0.98431372549019602f, 1.0f}, -{0.99766243752402917f, 0.96604382929642441f, 0.98296039984621297f, 1.0f}, -{0.99532487504805844f, 0.96346020761245676f, 0.98160707420222981f, 1.0f}, -{0.99298731257208761f, 0.96087658592848901f, 0.98025374855824676f, 1.0f}, -{0.99064975009611689f, 0.95829296424452137f, 0.97890042291426371f, 1.0f}, -{0.98831218762014605f, 0.95570934256055362f, 0.97754709727028066f, 1.0f}, -{0.98597462514417533f, 0.95312572087658587f, 0.9761937716262975f, 1.0f}, -{0.9836370626682045f, 0.95054209919261823f, 0.97484044598231445f, 1.0f}, -{0.98129950019223378f, 0.94795847750865048f, 0.9734871203383314f, 1.0f}, -{0.97896193771626294f, 0.94537485582468284f, 0.97213379469434824f, 1.0f}, -{0.97662437524029222f, 0.94279123414071508f, 0.97078046905036519f, 1.0f}, -{0.97428681276432139f, 0.94020761245674744f, 0.96942714340638214f, 1.0f}, -{0.97194925028835066f, 0.93762399077277969f, 0.96807381776239909f, 1.0f}, -{0.96961168781237983f, 0.93504036908881194f, 0.96672049211841593f, 1.0f}, -{0.96727412533640911f, 0.9324567474048443f, 0.96536716647443288f, 1.0f}, -{0.96493656286043827f, 0.92987312572087655f, 0.96401384083044983f, 1.0f}, -{0.96259900038446755f, 0.92728950403690891f, 0.96266051518646667f, 1.0f}, -{0.96026143790849672f, 0.92470588235294116f, 0.96130718954248362f, 1.0f}, -{0.957923875432526f, 0.9221222606689734f, 0.95995386389850057f, 1.0f}, -{0.95558631295655516f, 0.91953863898500576f, 0.95860053825451752f, 1.0f}, -{0.95324875048058444f, 0.91695501730103801f, 0.95724721261053436f, 1.0f}, -{0.95091118800461361f, 0.91437139561707037f, 0.95589388696655131f, 1.0f}, -{0.94857362552864288f, 0.91178777393310262f, 0.95454056132256826f, 1.0f}, -{0.94623606305267205f, 0.90920415224913498f, 0.9531872356785851f, 1.0f}, -{0.94389850057670133f, 0.90662053056516723f, 0.95183391003460205f, 1.0f}, -{0.94156093810073049f, 0.90403690888119947f, 0.950480584390619f, 1.0f}, -{0.93922337562475977f, 0.90145328719723183f, 0.94912725874663584f, 1.0f}, -{0.93688581314878894f, 0.89886966551326408f, 0.94777393310265279f, 1.0f}, -{0.93454825067281821f, 0.89628604382929633f, 0.94642060745866974f, 1.0f}, -{0.93221068819684738f, 0.89370242214532869f, 0.94506728181468669f, 1.0f}, -{0.92987312572087666f, 0.89111880046136094f, 0.94371395617070353f, 1.0f}, -{0.92753556324490583f, 0.8885351787773933f, 0.94236063052672048f, 1.0f}, -{0.92505959246443681f, 0.88601307189542478f, 0.94102268358323715f, 1.0f}, -{0.92161476355247984f, 0.88392156862745097f, 0.93979238754325256f, 1.0f}, -{0.91816993464052288f, 0.88183006535947706f, 0.93856209150326797f, 1.0f}, -{0.91472510572856602f, 0.87973856209150325f, 0.93733179546328338f, 1.0f}, -{0.91128027681660906f, 0.87764705882352934f, 0.93610149942329868f, 1.0f}, -{0.90783544790465209f, 0.87555555555555553f, 0.93487120338331409f, 1.0f}, -{0.90439061899269513f, 0.87346405228758162f, 0.9336409073433295f, 1.0f}, -{0.90094579008073816f, 0.87137254901960781f, 0.93241061130334491f, 1.0f}, -{0.89750096116878131f, 0.86928104575163401f, 0.9311803152633602f, 1.0f}, -{0.89405613225682434f, 0.86718954248366009f, 0.92995001922337561f, 1.0f}, -{0.89061130334486738f, 0.86509803921568629f, 0.92871972318339102f, 1.0f}, -{0.88716647443291041f, 0.86300653594771237f, 0.92748942714340643f, 1.0f}, -{0.88372164552095356f, 0.86091503267973857f, 0.92625913110342173f, 1.0f}, -{0.88027681660899659f, 0.85882352941176465f, 0.92502883506343714f, 1.0f}, -{0.87683198769703963f, 0.85673202614379085f, 0.92379853902345255f, 1.0f}, -{0.87338715878508266f, 0.85464052287581693f, 0.92256824298346785f, 1.0f}, -{0.8699423298731257f, 0.85254901960784313f, 0.92133794694348325f, 1.0f}, -{0.86649750096116884f, 0.85045751633986932f, 0.92010765090349866f, 1.0f}, -{0.86305267204921188f, 0.84836601307189541f, 0.91887735486351407f, 1.0f}, -{0.85960784313725491f, 0.84627450980392149f, 0.91764705882352937f, 1.0f}, -{0.85616301422529795f, 0.84418300653594769f, 0.91641676278354478f, 1.0f}, -{0.85271818531334109f, 0.84209150326797388f, 0.91518646674356019f, 1.0f}, -{0.84927335640138413f, 0.83999999999999997f, 0.9139561707035756f, 1.0f}, -{0.84582852748942716f, 0.83790849673202616f, 0.9127258746635909f, 1.0f}, -{0.8423836985774702f, 0.83581699346405225f, 0.91149557862360631f, 1.0f}, -{0.83893886966551334f, 0.83372549019607844f, 0.91026528258362172f, 1.0f}, -{0.83549404075355627f, 0.83163398692810453f, 0.90903498654363712f, 1.0f}, -{0.83204921184159941f, 0.82954248366013073f, 0.90780469050365242f, 1.0f}, -{0.82860438292964245f, 0.82745098039215681f, 0.90657439446366783f, 1.0f}, -{0.82515955401768548f, 0.82535947712418301f, 0.90534409842368324f, 1.0f}, -{0.82171472510572852f, 0.82326797385620909f, 0.90411380238369854f, 1.0f}, -{0.81826989619377166f, 0.82117647058823529f, 0.90288350634371395f, 1.0f}, -{0.81439446366782009f, 0.81899269511726258f, 0.90162245290272969f, 1.0f}, -{0.8092272202998847f, 0.81653210303729329f, 0.90026912725874664f, 1.0f}, -{0.80405997693194931f, 0.81407151095732411f, 0.89891580161476359f, 1.0f}, -{0.7988927335640138f, 0.81161091887735481f, 0.89756247597078043f, 1.0f}, -{0.79372549019607841f, 0.80915032679738563f, 0.89620915032679738f, 1.0f}, -{0.78855824682814302f, 0.80668973471741634f, 0.89485582468281433f, 1.0f}, -{0.78339100346020762f, 0.80422914263744716f, 0.89350249903883117f, 1.0f}, -{0.77822376009227223f, 0.80176855055747787f, 0.89214917339484812f, 1.0f}, -{0.77305651672433684f, 0.79930795847750868f, 0.89079584775086507f, 1.0f}, -{0.76788927335640134f, 0.79684736639753939f, 0.88944252210688202f, 1.0f}, -{0.76272202998846605f, 0.79438677431757021f, 0.88808919646289886f, 1.0f}, -{0.75755478662053055f, 0.79192618223760092f, 0.88673587081891581f, 1.0f}, -{0.75238754325259516f, 0.78946559015763162f, 0.88538254517493276f, 1.0f}, -{0.74722029988465977f, 0.78700499807766244f, 0.88402921953094959f, 1.0f}, -{0.74205305651672437f, 0.78454440599769315f, 0.88267589388696654f, 1.0f}, -{0.73688581314878898f, 0.78208381391772397f, 0.8813225682429835f, 1.0f}, -{0.73171856978085348f, 0.77962322183775468f, 0.87996924259900033f, 1.0f}, -{0.72655132641291809f, 0.77716262975778549f, 0.87861591695501728f, 1.0f}, -{0.7213840830449828f, 0.77470203767781631f, 0.87726259131103423f, 1.0f}, -{0.7162168396770473f, 0.77224144559784702f, 0.87590926566705107f, 1.0f}, -{0.71104959630911191f, 0.76978085351787773f, 0.87455594002306802f, 1.0f}, -{0.70588235294117652f, 0.76732026143790855f, 0.87320261437908497f, 1.0f}, -{0.70071510957324112f, 0.76485966935793925f, 0.87184928873510181f, 1.0f}, -{0.69554786620530562f, 0.76239907727797007f, 0.87049596309111876f, 1.0f}, -{0.69038062283737023f, 0.75993848519800078f, 0.86914263744713571f, 1.0f}, -{0.68521337946943484f, 0.7574778931180316f, 0.86778931180315255f, 1.0f}, -{0.68004613610149955f, 0.75501730103806231f, 0.8664359861591695f, 1.0f}, -{0.67487889273356405f, 0.75255670895809312f, 0.86508266051518645f, 1.0f}, -{0.66971164936562866f, 0.75009611687812383f, 0.86372933487120329f, 1.0f}, -{0.66454440599769327f, 0.74763552479815454f, 0.86237600922722024f, 1.0f}, -{0.65937716262975776f, 0.74517493271818536f, 0.86102268358323719f, 1.0f}, -{0.65420991926182237f, 0.74271434063821606f, 0.85966935793925403f, 1.0f}, -{0.64807381776239914f, 0.74025374855824688f, 0.85826989619377159f, 1.0f}, -{0.640322952710496f, 0.73779315647827759f, 0.85679354094579008f, 1.0f}, -{0.63257208765859296f, 0.73533256439830841f, 0.85531718569780846f, 1.0f}, -{0.62482122260668971f, 0.73287197231833912f, 0.85384083044982695f, 1.0f}, -{0.61707035755478667f, 0.73041138023836993f, 0.85236447520184544f, 1.0f}, -{0.60931949250288353f, 0.72795078815840064f, 0.85088811995386382f, 1.0f}, -{0.60156862745098039f, 0.72549019607843135f, 0.84941176470588231f, 1.0f}, -{0.59381776239907724f, 0.72302960399846217f, 0.8479354094579008f, 1.0f}, -{0.58606689734717421f, 0.72056901191849287f, 0.84645905420991918f, 1.0f}, -{0.57831603229527107f, 0.71810841983852369f, 0.84498269896193767f, 1.0f}, -{0.57056516724336803f, 0.7156478277585544f, 0.84350634371395616f, 1.0f}, -{0.56281430219146489f, 0.71318723567858522f, 0.84202998846597454f, 1.0f}, -{0.55506343713956174f, 0.71072664359861593f, 0.84055363321799303f, 1.0f}, -{0.5473125720876586f, 0.70826605151864663f, 0.83907727797001153f, 1.0f}, -{0.53956170703575546f, 0.70580545943867745f, 0.83760092272203002f, 1.0f}, -{0.53181084198385242f, 0.70334486735870816f, 0.8361245674740484f, 1.0f}, -{0.52405997693194928f, 0.70088427527873898f, 0.83464821222606689f, 1.0f}, -{0.51630911188004613f, 0.69842368319876968f, 0.83317185697808538f, 1.0f}, -{0.5085582468281431f, 0.6959630911188005f, 0.83169550173010376f, 1.0f}, -{0.50080738177623996f, 0.69350249903883121f, 0.83021914648212225f, 1.0f}, -{0.49305651672433681f, 0.69104190695886203f, 0.82874279123414074f, 1.0f}, -{0.48530565167243367f, 0.68858131487889274f, 0.82726643598615912f, 1.0f}, -{0.47755478662053058f, 0.68612072279892344f, 0.82579008073817761f, 1.0f}, -{0.46980392156862749f, 0.68366013071895426f, 0.8243137254901961f, 1.0f}, -{0.46205305651672435f, 0.68119953863898497f, 0.82283737024221448f, 1.0f}, -{0.45430219146482126f, 0.67873894655901579f, 0.82136101499423297f, 1.0f}, -{0.44655132641291828f, 0.6762783544790465f, 0.81988465974625147f, 1.0f}, -{0.43880046136101503f, 0.67381776239907731f, 0.81840830449826985f, 1.0f}, -{0.43104959630911188f, 0.67135717031910802f, 0.81693194925028834f, 1.0f}, -{0.42329873125720879f, 0.66889657823913873f, 0.81545559400230683f, 1.0f}, -{0.4155478662053057f, 0.66643598615916955f, 0.81397923875432521f, 1.0f}, -{0.40779700115340256f, 0.66397539407920025f, 0.8125028835063437f, 1.0f}, -{0.40090734332948869f, 0.66120722798923492f, 0.8108419838523645f, 1.0f}, -{0.39487889273356402f, 0.65813148788927334f, 0.8089965397923875f, 1.0f}, -{0.38885044213763936f, 0.65505574778931175f, 0.80715109573241062f, 1.0f}, -{0.38282199154171476f, 0.65198000768935027f, 0.80530565167243373f, 1.0f}, -{0.37679354094579026f, 0.64890426758938879f, 0.80346020761245684f, 1.0f}, -{0.37076509034986543f, 0.6458285274894271f, 0.80161476355247985f, 1.0f}, -{0.36473663975394077f, 0.64275278738946562f, 0.79976931949250285f, 1.0f}, -{0.35870818915801617f, 0.63967704728950403f, 0.79792387543252596f, 1.0f}, -{0.3526797385620915f, 0.63660130718954244f, 0.79607843137254897f, 1.0f}, -{0.34665128796616684f, 0.63352556708958097f, 0.79423298731257208f, 1.0f}, -{0.34062283737024224f, 0.63044982698961938f, 0.79238754325259519f, 1.0f}, -{0.33459438677431758f, 0.62737408688965779f, 0.7905420991926182f, 1.0f}, -{0.32856593617839291f, 0.62429834678969631f, 0.78869665513264131f, 1.0f}, -{0.32253748558246831f, 0.62122260668973472f, 0.78685121107266431f, 1.0f}, -{0.31650903498654365f, 0.61814686658977314f, 0.78500576701268743f, 1.0f}, -{0.31048058439061899f, 0.61507112648981155f, 0.78316032295271054f, 1.0f}, -{0.30445213379469432f, 0.61199538638985007f, 0.78131487889273354f, 1.0f}, -{0.29842368319876966f, 0.60891964628988848f, 0.77946943483275666f, 1.0f}, -{0.29239523260284506f, 0.6058439061899269f, 0.77762399077277966f, 1.0f}, -{0.2863667820069204f, 0.60276816608996542f, 0.77577854671280277f, 1.0f}, -{0.28033833141099596f, 0.59969242599000394f, 0.77393310265282589f, 1.0f}, -{0.27430988081507113f, 0.59661668589004224f, 0.77208765859284889f, 1.0f}, -{0.26828143021914647f, 0.59354094579008077f, 0.770242214532872f, 1.0f}, -{0.2622529796232218f, 0.59046520569011918f, 0.76839677047289501f, 1.0f}, -{0.2562245290272972f, 0.58738946559015759f, 0.76655132641291812f, 1.0f}, -{0.25019607843137254f, 0.584313725490196f, 0.76470588235294112f, 1.0f}, -{0.2441676278354479f, 0.58123798539023452f, 0.76286043829296424f, 1.0f}, -{0.23813917723952324f, 0.57816224529027294f, 0.76101499423298735f, 1.0f}, -{0.23211072664359861f, 0.57508650519031135f, 0.75916955017301035f, 1.0f}, -{0.22608227604767397f, 0.57201076509034987f, 0.75732410611303347f, 1.0f}, -{0.22005382545174931f, 0.56893502499038828f, 0.75547866205305647f, 1.0f}, -{0.21402537485582468f, 0.56585928489042669f, 0.75363321799307958f, 1.0f}, -{0.20776624375240291f, 0.56355247981545553f, 0.74878892733564018f, 1.0f}, -{0.2013687043444829f, 0.56170703575547865f, 0.74214532871972316f, 1.0f}, -{0.19497116493656286f, 0.55986159169550176f, 0.73550173010380626f, 1.0f}, -{0.18857362552864282f, 0.55801614763552476f, 0.72885813148788925f, 1.0f}, -{0.18217608612072297f, 0.55617070357554788f, 0.72221453287197246f, 1.0f}, -{0.17577854671280277f, 0.55432525951557088f, 0.71557093425605534f, 1.0f}, -{0.16938100730488273f, 0.55247981545559399f, 0.70892733564013843f, 1.0f}, -{0.16298346789696272f, 0.55063437139561711f, 0.70228373702422142f, 1.0f}, -{0.15658592848904268f, 0.54878892733564011f, 0.69564013840830452f, 1.0f}, -{0.15018838908112264f, 0.54694348327566322f, 0.68899653979238751f, 1.0f}, -{0.1437908496732026f, 0.54509803921568623f, 0.68235294117647061f, 1.0f}, -{0.13739331026528259f, 0.54325259515570934f, 0.67570934256055359f, 1.0f}, -{0.13099577085736255f, 0.54140715109573234f, 0.66906574394463669f, 1.0f}, -{0.12459823144944253f, 0.53956170703575546f, 0.66242214532871968f, 1.0f}, -{0.11820069204152249f, 0.53771626297577857f, 0.65577854671280278f, 1.0f}, -{0.11180315263360247f, 0.53587081891580157f, 0.64913494809688577f, 1.0f}, -{0.10540561322568243f, 0.53402537485582469f, 0.64249134948096887f, 1.0f}, -{0.099008073817762388f, 0.53217993079584769f, 0.63584775086505185f, 1.0f}, -{0.092610534409842363f, 0.5303344867358708f, 0.62920415224913495f, 1.0f}, -{0.086212995001922338f, 0.52848904267589392f, 0.62256055363321794f, 1.0f}, -{0.079815455594002493f, 0.52664359861591703f, 0.61591695501730115f, 1.0f}, -{0.07341791618608226f, 0.52479815455594003f, 0.60927335640138403f, 1.0f}, -{0.067020376778162249f, 0.52295271049596304f, 0.60262975778546712f, 1.0f}, -{0.060622837370242211f, 0.52110726643598615f, 0.59598615916955011f, 1.0f}, -{0.054225297962322172f, 0.51926182237600926f, 0.58934256055363321f, 1.0f}, -{0.047827758554402133f, 0.51741637831603227f, 0.5826989619377162f, 1.0f}, -{0.041430219146482122f, 0.51557093425605538f, 0.5760553633217993f, 1.0f}, -{0.035032679738562084f, 0.51372549019607838f, 0.56941176470588228f, 1.0f}, -{0.028635140330642045f, 0.5118800461361015f, 0.56276816608996538f, 1.0f}, -{0.022237600922722034f, 0.5100346020761245f, 0.55612456747404837f, 1.0f}, -{0.015840061514801995f, 0.50818915801614761f, 0.54948096885813147f, 1.0f}, -{0.0094425221068819565f, 0.50634371395617073f, 0.54283737024221446f, 1.0f}, -{0.0077508650519031138f, 0.50394463667820066f, 0.53665513264129172f, 1.0f}, -{0.0076278354479046521f, 0.50136101499423291f, 0.53062668204536712f, 1.0f}, -{0.0075048058439061895f, 0.49877739331026527f, 0.52459823144944251f, 1.0f}, -{0.0073817762399077278f, 0.49619377162629758f, 0.51856978085351779f, 1.0f}, -{0.0072587466359092688f, 0.49361014994232993f, 0.51254133025759341f, 1.0f}, -{0.0071357170319108036f, 0.49102652825836213f, 0.50651287966166858f, 1.0f}, -{0.0070126874279123411f, 0.48844290657439443f, 0.50048442906574386f, 1.0f}, -{0.0068896578239138794f, 0.48585928489042673f, 0.49445597846981926f, 1.0f}, -{0.0067666282199154168f, 0.48327566320645904f, 0.48842752787389465f, 1.0f}, -{0.0066435986159169551f, 0.48069204152249134f, 0.48239907727796999f, 1.0f}, -{0.0065205690119184926f, 0.47810841983852365f, 0.47637062668204533f, 1.0f}, -{0.00639753940792003f, 0.47552479815455595f, 0.47034217608612072f, 1.0f}, -{0.0062745098039215684f, 0.4729411764705882f, 0.46431372549019606f, 1.0f}, -{0.0061514801999231067f, 0.4703575547866205f, 0.4582852748942714f, 1.0f}, -{0.0060284505959246441f, 0.46777393310265281f, 0.45225682429834674f, 1.0f}, -{0.0059054209919261816f, 0.46519031141868511f, 0.44622837370242213f, 1.0f}, -{0.0057823913879277199f, 0.46260668973471741f, 0.44019992310649747f, 1.0f}, -{0.0056593617839292582f, 0.46002306805074972f, 0.43417147251057281f, 1.0f}, -{0.0055363321799307957f, 0.45743944636678202f, 0.4281430219146482f, 1.0f}, -{0.0054133025759323331f, 0.45485582468281427f, 0.42211457131872354f, 1.0f}, -{0.0052902729719338749f, 0.45227220299884663f, 0.41608612072279905f, 1.0f}, -{0.0051672433679354098f, 0.44968858131487888f, 0.41005767012687422f, 1.0f}, -{0.0050442137639369472f, 0.44710495963091118f, 0.40402921953094961f, 1.0f}, -{0.0049211841599384847f, 0.44452133794694348f, 0.39800076893502495f, 1.0f}, -{0.004798154555940023f, 0.44193771626297579f, 0.39197231833910029f, 1.0f}, -{0.0046751249519415613f, 0.43935409457900809f, 0.38594386774317568f, 1.0f}, -{0.0045520953479430987f, 0.43677047289504034f, 0.37991541714725102f, 1.0f}, -{0.0044290657439446362f, 0.43418685121107264f, 0.37388696655132636f, 1.0f}, -{0.0043060361399461745f, 0.43160322952710495f, 0.36785851595540175f, 1.0f}, -{0.0041830065359477128f, 0.42901960784313725f, 0.36183006535947709f, 1.0f}, -{0.0040599769319492503f, 0.42643598615916956f, 0.35580161476355243f, 1.0f}, -{0.0039369473279507877f, 0.4238523644752018f, 0.34977316416762783f, 1.0f}, -{0.0039215686274509803f, 0.419438677431757f, 0.34525182622068434f, 1.0f}, -{0.0039215686274509803f, 0.41476355247981544f, 0.34094579008073816f, 1.0f}, -{0.0039215686274509803f, 0.41008842752787389f, 0.33663975394079199f, 1.0f}, -{0.0039215686274509803f, 0.40541330257593233f, 0.33233371780084581f, 1.0f}, -{0.0039215686274509803f, 0.40073817762399089f, 0.32802768166089974f, 1.0f}, -{0.0039215686274509803f, 0.39606305267204922f, 0.32372164552095345f, 1.0f}, -{0.0039215686274509803f, 0.39138792772010766f, 0.31941560938100727f, 1.0f}, -{0.0039215686274509803f, 0.38671280276816611f, 0.31510957324106109f, 1.0f}, -{0.0039215686274509803f, 0.38203767781622455f, 0.31080353710111497f, 1.0f}, -{0.0039215686274509803f, 0.377362552864283f, 0.30649750096116879f, 1.0f}, -{0.0039215686274509803f, 0.37268742791234144f, 0.30219146482122261f, 1.0f}, -{0.0039215686274509803f, 0.36801230296039983f, 0.29788542868127643f, 1.0f}, -{0.0039215686274509803f, 0.36333717800845827f, 0.29357939254133025f, 1.0f}, -{0.0039215686274509803f, 0.35866205305651672f, 0.28927335640138407f, 1.0f}, -{0.0039215686274509803f, 0.35398692810457516f, 0.2849673202614379f, 1.0f}, -{0.0039215686274509803f, 0.3493118031526336f, 0.28066128412149172f, 1.0f}, -{0.0039215686274509803f, 0.34463667820069205f, 0.27635524798154554f, 1.0f}, -{0.0039215686274509803f, 0.33996155324875049f, 0.27204921184159936f, 1.0f}, -{0.0039215686274509803f, 0.33528642829680894f, 0.26774317570165318f, 1.0f}, -{0.0039215686274509803f, 0.33061130334486738f, 0.263437139561707f, 1.0f}, -{0.0039215686274509803f, 0.32593617839292593f, 0.25913110342176099f, 1.0f}, -{0.0039215686274509803f, 0.32126105344098427f, 0.2548250672818147f, 1.0f}, -{0.0039215686274509803f, 0.31658592848904266f, 0.25051903114186852f, 1.0f}, -{0.0039215686274509803f, 0.3119108035371011f, 0.24621299500192234f, 1.0f}, -{0.0039215686274509803f, 0.30723567858515954f, 0.24190695886197616f, 1.0f}, -{0.0039215686274509803f, 0.30256055363321799f, 0.23760092272202998f, 1.0f}, -{0.0039215686274509803f, 0.29788542868127643f, 0.2332948865820838f, 1.0f}, -{0.0039215686274509803f, 0.29321030372933488f, 0.22898885044213763f, 1.0f}, -{0.0039215686274509803f, 0.28853517877739332f, 0.22468281430219145f, 1.0f}, -{0.0039215686274509803f, 0.28386005382545176f, 0.2203767781622453f, 1.0f}, -{0.0039215686274509803f, 0.27918492887351021f, 0.21607074202229912f, 1.0f}, -{0.0039215686274509803f, 0.27450980392156865f, 0.21176470588235294f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential/PuBuGn.txt b/extern/tfn/colormaps/sequential/PuBuGn.txt deleted file mode 100644 index 1f65b5a..0000000 --- a/extern/tfn/colormaps/sequential/PuBuGn.txt +++ /dev/null @@ -1,256 +0,0 @@ -(1.0, 0.96862745098039216, 0.98431372549019602, 1.0) -(0.99766243752402917, 0.96604382929642441, 0.98296039984621297, 1.0) -(0.99532487504805844, 0.96346020761245676, 0.98160707420222981, 1.0) -(0.99298731257208761, 0.96087658592848901, 0.98025374855824676, 1.0) -(0.99064975009611689, 0.95829296424452137, 0.97890042291426371, 1.0) -(0.98831218762014605, 0.95570934256055362, 0.97754709727028066, 1.0) -(0.98597462514417533, 0.95312572087658587, 0.9761937716262975, 1.0) -(0.9836370626682045, 0.95054209919261823, 0.97484044598231445, 1.0) -(0.98129950019223378, 0.94795847750865048, 0.9734871203383314, 1.0) -(0.97896193771626294, 0.94537485582468284, 0.97213379469434824, 1.0) -(0.97662437524029222, 0.94279123414071508, 0.97078046905036519, 1.0) -(0.97428681276432139, 0.94020761245674744, 0.96942714340638214, 1.0) -(0.97194925028835066, 0.93762399077277969, 0.96807381776239909, 1.0) -(0.96961168781237983, 0.93504036908881194, 0.96672049211841593, 1.0) -(0.96727412533640911, 0.9324567474048443, 0.96536716647443288, 1.0) -(0.96493656286043827, 0.92987312572087655, 0.96401384083044983, 1.0) -(0.96259900038446755, 0.92728950403690891, 0.96266051518646667, 1.0) -(0.96026143790849672, 0.92470588235294116, 0.96130718954248362, 1.0) -(0.957923875432526, 0.9221222606689734, 0.95995386389850057, 1.0) -(0.95558631295655516, 0.91953863898500576, 0.95860053825451752, 1.0) -(0.95324875048058444, 0.91695501730103801, 0.95724721261053436, 1.0) -(0.95091118800461361, 0.91437139561707037, 0.95589388696655131, 1.0) -(0.94857362552864288, 0.91178777393310262, 0.95454056132256826, 1.0) -(0.94623606305267205, 0.90920415224913498, 0.9531872356785851, 1.0) -(0.94389850057670133, 0.90662053056516723, 0.95183391003460205, 1.0) -(0.94156093810073049, 0.90403690888119947, 0.950480584390619, 1.0) -(0.93922337562475977, 0.90145328719723183, 0.94912725874663584, 1.0) -(0.93688581314878894, 0.89886966551326408, 0.94777393310265279, 1.0) -(0.93454825067281821, 0.89628604382929633, 0.94642060745866974, 1.0) -(0.93221068819684738, 0.89370242214532869, 0.94506728181468669, 1.0) -(0.92987312572087666, 0.89111880046136094, 0.94371395617070353, 1.0) -(0.92753556324490583, 0.8885351787773933, 0.94236063052672048, 1.0) -(0.92505959246443681, 0.88601307189542478, 0.94102268358323715, 1.0) -(0.92161476355247984, 0.88392156862745097, 0.93979238754325256, 1.0) -(0.91816993464052288, 0.88183006535947706, 0.93856209150326797, 1.0) -(0.91472510572856602, 0.87973856209150325, 0.93733179546328338, 1.0) -(0.91128027681660906, 0.87764705882352934, 0.93610149942329868, 1.0) -(0.90783544790465209, 0.87555555555555553, 0.93487120338331409, 1.0) -(0.90439061899269513, 0.87346405228758162, 0.9336409073433295, 1.0) -(0.90094579008073816, 0.87137254901960781, 0.93241061130334491, 1.0) -(0.89750096116878131, 0.86928104575163401, 0.9311803152633602, 1.0) -(0.89405613225682434, 0.86718954248366009, 0.92995001922337561, 1.0) -(0.89061130334486738, 0.86509803921568629, 0.92871972318339102, 1.0) -(0.88716647443291041, 0.86300653594771237, 0.92748942714340643, 1.0) -(0.88372164552095356, 0.86091503267973857, 0.92625913110342173, 1.0) -(0.88027681660899659, 0.85882352941176465, 0.92502883506343714, 1.0) -(0.87683198769703963, 0.85673202614379085, 0.92379853902345255, 1.0) -(0.87338715878508266, 0.85464052287581693, 0.92256824298346785, 1.0) -(0.8699423298731257, 0.85254901960784313, 0.92133794694348325, 1.0) -(0.86649750096116884, 0.85045751633986932, 0.92010765090349866, 1.0) -(0.86305267204921188, 0.84836601307189541, 0.91887735486351407, 1.0) -(0.85960784313725491, 0.84627450980392149, 0.91764705882352937, 1.0) -(0.85616301422529795, 0.84418300653594769, 0.91641676278354478, 1.0) -(0.85271818531334109, 0.84209150326797388, 0.91518646674356019, 1.0) -(0.84927335640138413, 0.83999999999999997, 0.9139561707035756, 1.0) -(0.84582852748942716, 0.83790849673202616, 0.9127258746635909, 1.0) -(0.8423836985774702, 0.83581699346405225, 0.91149557862360631, 1.0) -(0.83893886966551334, 0.83372549019607844, 0.91026528258362172, 1.0) -(0.83549404075355627, 0.83163398692810453, 0.90903498654363712, 1.0) -(0.83204921184159941, 0.82954248366013073, 0.90780469050365242, 1.0) -(0.82860438292964245, 0.82745098039215681, 0.90657439446366783, 1.0) -(0.82515955401768548, 0.82535947712418301, 0.90534409842368324, 1.0) -(0.82171472510572852, 0.82326797385620909, 0.90411380238369854, 1.0) -(0.81826989619377166, 0.82117647058823529, 0.90288350634371395, 1.0) -(0.81439446366782009, 0.81899269511726258, 0.90162245290272969, 1.0) -(0.8092272202998847, 0.81653210303729329, 0.90026912725874664, 1.0) -(0.80405997693194931, 0.81407151095732411, 0.89891580161476359, 1.0) -(0.7988927335640138, 0.81161091887735481, 0.89756247597078043, 1.0) -(0.79372549019607841, 0.80915032679738563, 0.89620915032679738, 1.0) -(0.78855824682814302, 0.80668973471741634, 0.89485582468281433, 1.0) -(0.78339100346020762, 0.80422914263744716, 0.89350249903883117, 1.0) -(0.77822376009227223, 0.80176855055747787, 0.89214917339484812, 1.0) -(0.77305651672433684, 0.79930795847750868, 0.89079584775086507, 1.0) -(0.76788927335640134, 0.79684736639753939, 0.88944252210688202, 1.0) -(0.76272202998846605, 0.79438677431757021, 0.88808919646289886, 1.0) -(0.75755478662053055, 0.79192618223760092, 0.88673587081891581, 1.0) -(0.75238754325259516, 0.78946559015763162, 0.88538254517493276, 1.0) -(0.74722029988465977, 0.78700499807766244, 0.88402921953094959, 1.0) -(0.74205305651672437, 0.78454440599769315, 0.88267589388696654, 1.0) -(0.73688581314878898, 0.78208381391772397, 0.8813225682429835, 1.0) -(0.73171856978085348, 0.77962322183775468, 0.87996924259900033, 1.0) -(0.72655132641291809, 0.77716262975778549, 0.87861591695501728, 1.0) -(0.7213840830449828, 0.77470203767781631, 0.87726259131103423, 1.0) -(0.7162168396770473, 0.77224144559784702, 0.87590926566705107, 1.0) -(0.71104959630911191, 0.76978085351787773, 0.87455594002306802, 1.0) -(0.70588235294117652, 0.76732026143790855, 0.87320261437908497, 1.0) -(0.70071510957324112, 0.76485966935793925, 0.87184928873510181, 1.0) -(0.69554786620530562, 0.76239907727797007, 0.87049596309111876, 1.0) -(0.69038062283737023, 0.75993848519800078, 0.86914263744713571, 1.0) -(0.68521337946943484, 0.7574778931180316, 0.86778931180315255, 1.0) -(0.68004613610149955, 0.75501730103806231, 0.8664359861591695, 1.0) -(0.67487889273356405, 0.75255670895809312, 0.86508266051518645, 1.0) -(0.66971164936562866, 0.75009611687812383, 0.86372933487120329, 1.0) -(0.66454440599769327, 0.74763552479815454, 0.86237600922722024, 1.0) -(0.65937716262975776, 0.74517493271818536, 0.86102268358323719, 1.0) -(0.65420991926182237, 0.74271434063821606, 0.85966935793925403, 1.0) -(0.64807381776239914, 0.74025374855824688, 0.85826989619377159, 1.0) -(0.640322952710496, 0.73779315647827759, 0.85679354094579008, 1.0) -(0.63257208765859296, 0.73533256439830841, 0.85531718569780846, 1.0) -(0.62482122260668971, 0.73287197231833912, 0.85384083044982695, 1.0) -(0.61707035755478667, 0.73041138023836993, 0.85236447520184544, 1.0) -(0.60931949250288353, 0.72795078815840064, 0.85088811995386382, 1.0) -(0.60156862745098039, 0.72549019607843135, 0.84941176470588231, 1.0) -(0.59381776239907724, 0.72302960399846217, 0.8479354094579008, 1.0) -(0.58606689734717421, 0.72056901191849287, 0.84645905420991918, 1.0) -(0.57831603229527107, 0.71810841983852369, 0.84498269896193767, 1.0) -(0.57056516724336803, 0.7156478277585544, 0.84350634371395616, 1.0) -(0.56281430219146489, 0.71318723567858522, 0.84202998846597454, 1.0) -(0.55506343713956174, 0.71072664359861593, 0.84055363321799303, 1.0) -(0.5473125720876586, 0.70826605151864663, 0.83907727797001153, 1.0) -(0.53956170703575546, 0.70580545943867745, 0.83760092272203002, 1.0) -(0.53181084198385242, 0.70334486735870816, 0.8361245674740484, 1.0) -(0.52405997693194928, 0.70088427527873898, 0.83464821222606689, 1.0) -(0.51630911188004613, 0.69842368319876968, 0.83317185697808538, 1.0) -(0.5085582468281431, 0.6959630911188005, 0.83169550173010376, 1.0) -(0.50080738177623996, 0.69350249903883121, 0.83021914648212225, 1.0) -(0.49305651672433681, 0.69104190695886203, 0.82874279123414074, 1.0) -(0.48530565167243367, 0.68858131487889274, 0.82726643598615912, 1.0) -(0.47755478662053058, 0.68612072279892344, 0.82579008073817761, 1.0) -(0.46980392156862749, 0.68366013071895426, 0.8243137254901961, 1.0) -(0.46205305651672435, 0.68119953863898497, 0.82283737024221448, 1.0) -(0.45430219146482126, 0.67873894655901579, 0.82136101499423297, 1.0) -(0.44655132641291828, 0.6762783544790465, 0.81988465974625147, 1.0) -(0.43880046136101503, 0.67381776239907731, 0.81840830449826985, 1.0) -(0.43104959630911188, 0.67135717031910802, 0.81693194925028834, 1.0) -(0.42329873125720879, 0.66889657823913873, 0.81545559400230683, 1.0) -(0.4155478662053057, 0.66643598615916955, 0.81397923875432521, 1.0) -(0.40779700115340256, 0.66397539407920025, 0.8125028835063437, 1.0) -(0.40090734332948869, 0.66120722798923492, 0.8108419838523645, 1.0) -(0.39487889273356402, 0.65813148788927334, 0.8089965397923875, 1.0) -(0.38885044213763936, 0.65505574778931175, 0.80715109573241062, 1.0) -(0.38282199154171476, 0.65198000768935027, 0.80530565167243373, 1.0) -(0.37679354094579026, 0.64890426758938879, 0.80346020761245684, 1.0) -(0.37076509034986543, 0.6458285274894271, 0.80161476355247985, 1.0) -(0.36473663975394077, 0.64275278738946562, 0.79976931949250285, 1.0) -(0.35870818915801617, 0.63967704728950403, 0.79792387543252596, 1.0) -(0.3526797385620915, 0.63660130718954244, 0.79607843137254897, 1.0) -(0.34665128796616684, 0.63352556708958097, 0.79423298731257208, 1.0) -(0.34062283737024224, 0.63044982698961938, 0.79238754325259519, 1.0) -(0.33459438677431758, 0.62737408688965779, 0.7905420991926182, 1.0) -(0.32856593617839291, 0.62429834678969631, 0.78869665513264131, 1.0) -(0.32253748558246831, 0.62122260668973472, 0.78685121107266431, 1.0) -(0.31650903498654365, 0.61814686658977314, 0.78500576701268743, 1.0) -(0.31048058439061899, 0.61507112648981155, 0.78316032295271054, 1.0) -(0.30445213379469432, 0.61199538638985007, 0.78131487889273354, 1.0) -(0.29842368319876966, 0.60891964628988848, 0.77946943483275666, 1.0) -(0.29239523260284506, 0.6058439061899269, 0.77762399077277966, 1.0) -(0.2863667820069204, 0.60276816608996542, 0.77577854671280277, 1.0) -(0.28033833141099596, 0.59969242599000394, 0.77393310265282589, 1.0) -(0.27430988081507113, 0.59661668589004224, 0.77208765859284889, 1.0) -(0.26828143021914647, 0.59354094579008077, 0.770242214532872, 1.0) -(0.2622529796232218, 0.59046520569011918, 0.76839677047289501, 1.0) -(0.2562245290272972, 0.58738946559015759, 0.76655132641291812, 1.0) -(0.25019607843137254, 0.584313725490196, 0.76470588235294112, 1.0) -(0.2441676278354479, 0.58123798539023452, 0.76286043829296424, 1.0) -(0.23813917723952324, 0.57816224529027294, 0.76101499423298735, 1.0) -(0.23211072664359861, 0.57508650519031135, 0.75916955017301035, 1.0) -(0.22608227604767397, 0.57201076509034987, 0.75732410611303347, 1.0) -(0.22005382545174931, 0.56893502499038828, 0.75547866205305647, 1.0) -(0.21402537485582468, 0.56585928489042669, 0.75363321799307958, 1.0) -(0.20776624375240291, 0.56355247981545553, 0.74878892733564018, 1.0) -(0.2013687043444829, 0.56170703575547865, 0.74214532871972316, 1.0) -(0.19497116493656286, 0.55986159169550176, 0.73550173010380626, 1.0) -(0.18857362552864282, 0.55801614763552476, 0.72885813148788925, 1.0) -(0.18217608612072297, 0.55617070357554788, 0.72221453287197246, 1.0) -(0.17577854671280277, 0.55432525951557088, 0.71557093425605534, 1.0) -(0.16938100730488273, 0.55247981545559399, 0.70892733564013843, 1.0) -(0.16298346789696272, 0.55063437139561711, 0.70228373702422142, 1.0) -(0.15658592848904268, 0.54878892733564011, 0.69564013840830452, 1.0) -(0.15018838908112264, 0.54694348327566322, 0.68899653979238751, 1.0) -(0.1437908496732026, 0.54509803921568623, 0.68235294117647061, 1.0) -(0.13739331026528259, 0.54325259515570934, 0.67570934256055359, 1.0) -(0.13099577085736255, 0.54140715109573234, 0.66906574394463669, 1.0) -(0.12459823144944253, 0.53956170703575546, 0.66242214532871968, 1.0) -(0.11820069204152249, 0.53771626297577857, 0.65577854671280278, 1.0) -(0.11180315263360247, 0.53587081891580157, 0.64913494809688577, 1.0) -(0.10540561322568243, 0.53402537485582469, 0.64249134948096887, 1.0) -(0.099008073817762388, 0.53217993079584769, 0.63584775086505185, 1.0) -(0.092610534409842363, 0.5303344867358708, 0.62920415224913495, 1.0) -(0.086212995001922338, 0.52848904267589392, 0.62256055363321794, 1.0) -(0.079815455594002493, 0.52664359861591703, 0.61591695501730115, 1.0) -(0.07341791618608226, 0.52479815455594003, 0.60927335640138403, 1.0) -(0.067020376778162249, 0.52295271049596304, 0.60262975778546712, 1.0) -(0.060622837370242211, 0.52110726643598615, 0.59598615916955011, 1.0) -(0.054225297962322172, 0.51926182237600926, 0.58934256055363321, 1.0) -(0.047827758554402133, 0.51741637831603227, 0.5826989619377162, 1.0) -(0.041430219146482122, 0.51557093425605538, 0.5760553633217993, 1.0) -(0.035032679738562084, 0.51372549019607838, 0.56941176470588228, 1.0) -(0.028635140330642045, 0.5118800461361015, 0.56276816608996538, 1.0) -(0.022237600922722034, 0.5100346020761245, 0.55612456747404837, 1.0) -(0.015840061514801995, 0.50818915801614761, 0.54948096885813147, 1.0) -(0.0094425221068819565, 0.50634371395617073, 0.54283737024221446, 1.0) -(0.0077508650519031138, 0.50394463667820066, 0.53665513264129172, 1.0) -(0.0076278354479046521, 0.50136101499423291, 0.53062668204536712, 1.0) -(0.0075048058439061895, 0.49877739331026527, 0.52459823144944251, 1.0) -(0.0073817762399077278, 0.49619377162629758, 0.51856978085351779, 1.0) -(0.0072587466359092688, 0.49361014994232993, 0.51254133025759341, 1.0) -(0.0071357170319108036, 0.49102652825836213, 0.50651287966166858, 1.0) -(0.0070126874279123411, 0.48844290657439443, 0.50048442906574386, 1.0) -(0.0068896578239138794, 0.48585928489042673, 0.49445597846981926, 1.0) -(0.0067666282199154168, 0.48327566320645904, 0.48842752787389465, 1.0) -(0.0066435986159169551, 0.48069204152249134, 0.48239907727796999, 1.0) -(0.0065205690119184926, 0.47810841983852365, 0.47637062668204533, 1.0) -(0.00639753940792003, 0.47552479815455595, 0.47034217608612072, 1.0) -(0.0062745098039215684, 0.4729411764705882, 0.46431372549019606, 1.0) -(0.0061514801999231067, 0.4703575547866205, 0.4582852748942714, 1.0) -(0.0060284505959246441, 0.46777393310265281, 0.45225682429834674, 1.0) -(0.0059054209919261816, 0.46519031141868511, 0.44622837370242213, 1.0) -(0.0057823913879277199, 0.46260668973471741, 0.44019992310649747, 1.0) -(0.0056593617839292582, 0.46002306805074972, 0.43417147251057281, 1.0) -(0.0055363321799307957, 0.45743944636678202, 0.4281430219146482, 1.0) -(0.0054133025759323331, 0.45485582468281427, 0.42211457131872354, 1.0) -(0.0052902729719338749, 0.45227220299884663, 0.41608612072279905, 1.0) -(0.0051672433679354098, 0.44968858131487888, 0.41005767012687422, 1.0) -(0.0050442137639369472, 0.44710495963091118, 0.40402921953094961, 1.0) -(0.0049211841599384847, 0.44452133794694348, 0.39800076893502495, 1.0) -(0.004798154555940023, 0.44193771626297579, 0.39197231833910029, 1.0) -(0.0046751249519415613, 0.43935409457900809, 0.38594386774317568, 1.0) -(0.0045520953479430987, 0.43677047289504034, 0.37991541714725102, 1.0) -(0.0044290657439446362, 0.43418685121107264, 0.37388696655132636, 1.0) -(0.0043060361399461745, 0.43160322952710495, 0.36785851595540175, 1.0) -(0.0041830065359477128, 0.42901960784313725, 0.36183006535947709, 1.0) -(0.0040599769319492503, 0.42643598615916956, 0.35580161476355243, 1.0) -(0.0039369473279507877, 0.4238523644752018, 0.34977316416762783, 1.0) -(0.0039215686274509803, 0.419438677431757, 0.34525182622068434, 1.0) -(0.0039215686274509803, 0.41476355247981544, 0.34094579008073816, 1.0) -(0.0039215686274509803, 0.41008842752787389, 0.33663975394079199, 1.0) -(0.0039215686274509803, 0.40541330257593233, 0.33233371780084581, 1.0) -(0.0039215686274509803, 0.40073817762399089, 0.32802768166089974, 1.0) -(0.0039215686274509803, 0.39606305267204922, 0.32372164552095345, 1.0) -(0.0039215686274509803, 0.39138792772010766, 0.31941560938100727, 1.0) -(0.0039215686274509803, 0.38671280276816611, 0.31510957324106109, 1.0) -(0.0039215686274509803, 0.38203767781622455, 0.31080353710111497, 1.0) -(0.0039215686274509803, 0.377362552864283, 0.30649750096116879, 1.0) -(0.0039215686274509803, 0.37268742791234144, 0.30219146482122261, 1.0) -(0.0039215686274509803, 0.36801230296039983, 0.29788542868127643, 1.0) -(0.0039215686274509803, 0.36333717800845827, 0.29357939254133025, 1.0) -(0.0039215686274509803, 0.35866205305651672, 0.28927335640138407, 1.0) -(0.0039215686274509803, 0.35398692810457516, 0.2849673202614379, 1.0) -(0.0039215686274509803, 0.3493118031526336, 0.28066128412149172, 1.0) -(0.0039215686274509803, 0.34463667820069205, 0.27635524798154554, 1.0) -(0.0039215686274509803, 0.33996155324875049, 0.27204921184159936, 1.0) -(0.0039215686274509803, 0.33528642829680894, 0.26774317570165318, 1.0) -(0.0039215686274509803, 0.33061130334486738, 0.263437139561707, 1.0) -(0.0039215686274509803, 0.32593617839292593, 0.25913110342176099, 1.0) -(0.0039215686274509803, 0.32126105344098427, 0.2548250672818147, 1.0) -(0.0039215686274509803, 0.31658592848904266, 0.25051903114186852, 1.0) -(0.0039215686274509803, 0.3119108035371011, 0.24621299500192234, 1.0) -(0.0039215686274509803, 0.30723567858515954, 0.24190695886197616, 1.0) -(0.0039215686274509803, 0.30256055363321799, 0.23760092272202998, 1.0) -(0.0039215686274509803, 0.29788542868127643, 0.2332948865820838, 1.0) -(0.0039215686274509803, 0.29321030372933488, 0.22898885044213763, 1.0) -(0.0039215686274509803, 0.28853517877739332, 0.22468281430219145, 1.0) -(0.0039215686274509803, 0.28386005382545176, 0.2203767781622453, 1.0) -(0.0039215686274509803, 0.27918492887351021, 0.21607074202229912, 1.0) -(0.0039215686274509803, 0.27450980392156865, 0.21176470588235294, 1.0) diff --git a/extern/tfn/colormaps/sequential/PuRd.cpp b/extern/tfn/colormaps/sequential/PuRd.cpp deleted file mode 100644 index 594f9b2..0000000 --- a/extern/tfn/colormaps/sequential/PuRd.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential_PuRd; -} -const std::vector colormap::data_sequential_PuRd = /* NOLINT(cert-err58-cpp) */ -{ -{0.96862745098039216f, 0.95686274509803926f, 0.97647058823529409f, 1.0f}, -{0.96665897731641681f, 0.95452518262206842f, 0.9752402921953095f, 1.0f}, -{0.96469050365244136f, 0.9521876201460977f, 0.9740099961553248f, 1.0f}, -{0.96272202998846601f, 0.94985005767012687f, 0.97277970011534021f, 1.0f}, -{0.96075355632449055f, 0.94751249519415615f, 0.97154940407535562f, 1.0f}, -{0.95878508266051521f, 0.94517493271818531f, 0.97031910803537103f, 1.0f}, -{0.95681660899653975f, 0.94283737024221459f, 0.96908881199538632f, 1.0f}, -{0.95484813533256441f, 0.94049980776624376f, 0.96785851595540173f, 1.0f}, -{0.95287966166858906f, 0.93816224529027303f, 0.96662821991541714f, 1.0f}, -{0.95091118800461361f, 0.9358246828143022f, 0.96539792387543255f, 1.0f}, -{0.94894271434063826f, 0.93348712033833148f, 0.96416762783544785f, 1.0f}, -{0.9469742406766628f, 0.93114955786236064f, 0.96293733179546326f, 1.0f}, -{0.94500576701268746f, 0.92881199538638981f, 0.96170703575547867f, 1.0f}, -{0.943037293348712f, 0.92647443291041909f, 0.96047673971549408f, 1.0f}, -{0.94106881968473666f, 0.92413687043444825f, 0.95924644367550937f, 1.0f}, -{0.9391003460207612f, 0.92179930795847753f, 0.95801614763552478f, 1.0f}, -{0.93713187235678586f, 0.9194617454825067f, 0.95678585159554019f, 1.0f}, -{0.93516339869281051f, 0.91712418300653598f, 0.95555555555555549f, 1.0f}, -{0.93319492502883505f, 0.91478662053056514f, 0.9543252595155709f, 1.0f}, -{0.93122645136485971f, 0.91244905805459442f, 0.95309496347558631f, 1.0f}, -{0.92925797770088425f, 0.91011149557862359f, 0.95186466743560172f, 1.0f}, -{0.92728950403690891f, 0.90777393310265286f, 0.95063437139561702f, 1.0f}, -{0.92532103037293345f, 0.90543637062668203f, 0.94940407535563243f, 1.0f}, -{0.92335255670895811f, 0.90309880815071131f, 0.94817377931564784f, 1.0f}, -{0.92138408304498265f, 0.90076124567474047f, 0.94694348327566324f, 1.0f}, -{0.9194156093810073f, 0.89842368319876975f, 0.94571318723567854f, 1.0f}, -{0.91744713571703196f, 0.89608612072279892f, 0.94448289119569395f, 1.0f}, -{0.9154786620530565f, 0.89374855824682808f, 0.94325259515570936f, 1.0f}, -{0.91351018838908116f, 0.89141099577085736f, 0.94202229911572477f, 1.0f}, -{0.9115417147251057f, 0.88907343329488653f, 0.94079200307574007f, 1.0f}, -{0.90957324106113036f, 0.88673587081891581f, 0.93956170703575548f, 1.0f}, -{0.9076047673971549f, 0.88439830834294497f, 0.93833141099577089f, 1.0f}, -{0.90559015763168016f, 0.88173779315647827f, 0.93693194925028833f, 1.0f}, -{0.90325259515570933f, 0.87681660899653979f, 0.93434832756632069f, 1.0f}, -{0.9009150326797386f, 0.87189542483660132f, 0.93176470588235294f, 1.0f}, -{0.89857747020376777f, 0.86697424067666284f, 0.92918108419838519f, 1.0f}, -{0.89623990772779705f, 0.86205305651672426f, 0.92659746251441755f, 1.0f}, -{0.89390234525182621f, 0.8571318723567859f, 0.9240138408304498f, 1.0f}, -{0.89156478277585549f, 0.85221068819684731f, 0.92143021914648215f, 1.0f}, -{0.88922722029988466f, 0.84728950403690884f, 0.9188465974625144f, 1.0f}, -{0.88688965782391393f, 0.84236831987697036f, 0.91626297577854665f, 1.0f}, -{0.8845520953479431f, 0.83744713571703189f, 0.91367935409457901f, 1.0f}, -{0.88221453287197238f, 0.83252595155709341f, 0.91109573241061126f, 1.0f}, -{0.87987697039600155f, 0.82760476739715494f, 0.90851211072664362f, 1.0f}, -{0.87753940792003082f, 0.82268358323721646f, 0.90592848904267587f, 1.0f}, -{0.87520184544405999f, 0.81776239907727799f, 0.90334486735870823f, 1.0f}, -{0.87286428296808927f, 0.81284121491733941f, 0.90076124567474047f, 1.0f}, -{0.87052672049211843f, 0.80792003075740093f, 0.89817762399077272f, 1.0f}, -{0.86818915801614771f, 0.80299884659746246f, 0.89559400230680508f, 1.0f}, -{0.86585159554017688f, 0.79807766243752409f, 0.89301038062283733f, 1.0f}, -{0.86351403306420615f, 0.79315647827758551f, 0.89042675893886969f, 1.0f}, -{0.86117647058823532f, 0.78823529411764703f, 0.88784313725490194f, 1.0f}, -{0.85883890811226449f, 0.78331410995770856f, 0.88525951557093419f, 1.0f}, -{0.85650134563629376f, 0.77839292579777009f, 0.88267589388696654f, 1.0f}, -{0.85416378316032304f, 0.77347174163783161f, 0.88009227220299879f, 1.0f}, -{0.85182622068435221f, 0.76855055747789314f, 0.87750865051903115f, 1.0f}, -{0.84948865820838138f, 0.76362937331795466f, 0.8749250288350634f, 1.0f}, -{0.84715109573241065f, 0.75870818915801619f, 0.87234140715109576f, 1.0f}, -{0.84481353325643982f, 0.7537870049980776f, 0.86975778546712801f, 1.0f}, -{0.8424759707804691f, 0.74886582083813913f, 0.86717416378316026f, 1.0f}, -{0.84013840830449826f, 0.74394463667820065f, 0.86459054209919262f, 1.0f}, -{0.83780084582852754f, 0.73902345251826218f, 0.86200692041522486f, 1.0f}, -{0.83546328335255671f, 0.73410226835832371f, 0.85942329873125711f, 1.0f}, -{0.83312572087658598f, 0.72918108419838523f, 0.85683967704728947f, 1.0f}, -{0.83103421760861207f, 0.72435217224144555f, 0.85431757016532095f, 1.0f}, -{0.82968089196462902f, 0.71980007689350245f, 0.85198000768935023f, 1.0f}, -{0.82832756632064597f, 0.71524798154555946f, 0.8496424452133795f, 1.0f}, -{0.82697424067666281f, 0.71069588619761626f, 0.84730488273740867f, 1.0f}, -{0.82562091503267976f, 0.70614379084967316f, 0.84496732026143784f, 1.0f}, -{0.82426758938869671f, 0.70159169550173006f, 0.84262975778546712f, 1.0f}, -{0.82291426374471355f, 0.69703960015378696f, 0.84029219530949628f, 1.0f}, -{0.8215609381007305f, 0.69248750480584387f, 0.83795463283352556f, 1.0f}, -{0.82020761245674745f, 0.68793540945790077f, 0.83561707035755473f, 1.0f}, -{0.8188542868127644f, 0.68338331410995767f, 0.833279507881584f, 1.0f}, -{0.81750096116878124f, 0.67883121876201469f, 0.83094194540561328f, 1.0f}, -{0.81614763552479819f, 0.67427912341407148f, 0.82860438292964245f, 1.0f}, -{0.81479430988081514f, 0.66972702806612838f, 0.82626682045367161f, 1.0f}, -{0.81344098423683198f, 0.66517493271818529f, 0.82392925797770089f, 1.0f}, -{0.81208765859284893f, 0.66062283737024219f, 0.82159169550173006f, 1.0f}, -{0.81073433294886588f, 0.65607074202229909f, 0.81925413302575933f, 1.0f}, -{0.80938100730488272f, 0.65151864667435599f, 0.8169165705497885f, 1.0f}, -{0.80802768166089967f, 0.6469665513264129f, 0.81457900807381778f, 1.0f}, -{0.80667435601691662f, 0.64241445597846991f, 0.81224144559784706f, 1.0f}, -{0.80532103037293346f, 0.6378623606305267f, 0.80990388312187622f, 1.0f}, -{0.80396770472895041f, 0.63331026528258361f, 0.80756632064590539f, 1.0f}, -{0.80261437908496736f, 0.62875816993464051f, 0.80522875816993467f, 1.0f}, -{0.80126105344098419f, 0.62420607458669741f, 0.80289119569396383f, 1.0f}, -{0.79990772779700114f, 0.61965397923875432f, 0.80055363321799311f, 1.0f}, -{0.79855440215301809f, 0.61510188389081122f, 0.79821607074202228f, 1.0f}, -{0.79720107650903493f, 0.61054978854286812f, 0.79587850826605155f, 1.0f}, -{0.79584775086505188f, 0.60599769319492514f, 0.79354094579008072f, 1.0f}, -{0.79449442522106883f, 0.60144559784698193f, 0.79120338331411f, 1.0f}, -{0.79314109957708567f, 0.59689350249903894f, 0.78886582083813916f, 1.0f}, -{0.79178777393310262f, 0.59234140715109573f, 0.78652825836216844f, 1.0f}, -{0.79043444828911957f, 0.58778931180315275f, 0.78419069588619761f, 1.0f}, -{0.78908112264513641f, 0.58323721645520954f, 0.78185313341022689f, 1.0f}, -{0.78925028835063438f, 0.57822376009227228f, 0.77933102652825836f, 1.0f}, -{0.79195693963860048f, 0.57244136870434448f, 0.77650134563629369f, 1.0f}, -{0.79466359092656669f, 0.5666589773164169f, 0.77367166474432914f, 1.0f}, -{0.7973702422145329f, 0.5608765859284891f, 0.77084198385236447f, 1.0f}, -{0.800076893502499f, 0.55509419454056141f, 0.7680123029603998f, 1.0f}, -{0.80278354479046521f, 0.54931180315263362f, 0.76518262206843524f, 1.0f}, -{0.80549019607843131f, 0.54352941176470593f, 0.76235294117647057f, 1.0f}, -{0.80819684736639752f, 0.53774702037677824f, 0.75952326028450601f, 1.0f}, -{0.81090349865436373f, 0.53196462898885044f, 0.75669357939254134f, 1.0f}, -{0.81361014994232983f, 0.52618223760092275f, 0.75386389850057667f, 1.0f}, -{0.81631680123029593f, 0.52039984621299507f, 0.75103421760861211f, 1.0f}, -{0.81902345251826214f, 0.51461745482506727f, 0.74820453671664744f, 1.0f}, -{0.82173010380622835f, 0.50883506343713958f, 0.74537485582468277f, 1.0f}, -{0.82443675509419456f, 0.50305267204921189f, 0.74254517493271821f, 1.0f}, -{0.82714340638216066f, 0.49727028066128415f, 0.73971549404075354f, 1.0f}, -{0.82985005767012687f, 0.4914878892733564f, 0.73688581314878898f, 1.0f}, -{0.83255670895809297f, 0.48570549788542872f, 0.73405613225682431f, 1.0f}, -{0.83526336024605918f, 0.47992310649750097f, 0.73122645136485964f, 1.0f}, -{0.83797001153402528f, 0.47414071510957334f, 0.72839677047289508f, 1.0f}, -{0.84067666282199149f, 0.46835832372164554f, 0.72556708958093041f, 1.0f}, -{0.8433833141099577f, 0.4625759323337178f, 0.72273740868896574f, 1.0f}, -{0.84608996539792392f, 0.45679354094579011f, 0.71990772779700118f, 1.0f}, -{0.84879661668589002f, 0.45101114955786237f, 0.71707804690503651f, 1.0f}, -{0.85150326797385623f, 0.44522875816993468f, 0.71424836601307184f, 1.0f}, -{0.85420991926182233f, 0.43944636678200694f, 0.71141868512110729f, 1.0f}, -{0.85691657054978854f, 0.43366397539407919f, 0.70858900422914262f, 1.0f}, -{0.85962322183775464f, 0.42788158400615156f, 0.70575932333717806f, 1.0f}, -{0.86232987312572085f, 0.42209919261822376f, 0.70292964244521339f, 1.0f}, -{0.86503652441368706f, 0.41631680123029602f, 0.70009996155324872f, 1.0f}, -{0.86774317570165316f, 0.41053440984236833f, 0.69727028066128416f, 1.0f}, -{0.87044982698961937f, 0.40475201845444059f, 0.69444059976931949f, 1.0f}, -{0.87315647827758558f, 0.39896962706651284f, 0.69161091887735482f, 1.0f}, -{0.87500192233756247f, 0.39238754325259512f, 0.68785851595540171f, 1.0f}, -{0.87598615916955014f, 0.38500576701268741f, 0.68318339100346015f, 1.0f}, -{0.87697039600153792f, 0.37762399077277969f, 0.67850826605151859f, 1.0f}, -{0.87795463283352559f, 0.37024221453287198f, 0.67383314109957704f, 1.0f}, -{0.87893886966551327f, 0.36286043829296444f, 0.66915801614763559f, 1.0f}, -{0.87992310649750094f, 0.3554786620530565f, 0.66448289119569393f, 1.0f}, -{0.88090734332948861f, 0.34809688581314879f, 0.65980776624375237f, 1.0f}, -{0.8818915801614764f, 0.34071510957324103f, 0.65513264129181081f, 1.0f}, -{0.88287581699346407f, 0.33333333333333331f, 0.65045751633986926f, 1.0f}, -{0.88386005382545174f, 0.3259515570934256f, 0.6457823913879277f, 1.0f}, -{0.88484429065743941f, 0.31856978085351784f, 0.64110726643598615f, 1.0f}, -{0.8858285274894272f, 0.31118800461361013f, 0.63643214148404459f, 1.0f}, -{0.88681276432141487f, 0.30380622837370241f, 0.63175701653210303f, 1.0f}, -{0.88779700115340254f, 0.2964244521337947f, 0.62708189158016148f, 1.0f}, -{0.88878123798539022f, 0.28904267589388699f, 0.62240676662821992f, 1.0f}, -{0.88976547481737789f, 0.28166089965397922f, 0.61773164167627836f, 1.0f}, -{0.89074971164936567f, 0.27427912341407151f, 0.61305651672433681f, 1.0f}, -{0.89173394848135334f, 0.2668973471741638f, 0.60838139177239525f, 1.0f}, -{0.89271818531334102f, 0.25951557093425603f, 0.60370626682045359f, 1.0f}, -{0.89370242214532869f, 0.25213379469434832f, 0.59903114186851214f, 1.0f}, -{0.89468665897731636f, 0.24475201845444081f, 0.5943560169165707f, 1.0f}, -{0.89567089580930415f, 0.23737024221453287f, 0.58968089196462892f, 1.0f}, -{0.89665513264129182f, 0.22998846597462513f, 0.58500576701268736f, 1.0f}, -{0.89763936947327949f, 0.22260668973471742f, 0.5803306420607458f, 1.0f}, -{0.89862360630526716f, 0.21522491349480968f, 0.57565551710880425f, 1.0f}, -{0.89960784313725495f, 0.20784313725490194f, 0.57098039215686269f, 1.0f}, -{0.90059207996924262f, 0.20046136101499423f, 0.56630526720492114f, 1.0f}, -{0.90157631680123029f, 0.19307958477508649f, 0.56163014225297958f, 1.0f}, -{0.90256055363321797f, 0.18569780853517878f, 0.55695501730103802f, 1.0f}, -{0.90354479046520564f, 0.17831603229527104f, 0.55227989234909647f, 1.0f}, -{0.90452902729719342f, 0.17093425605536333f, 0.54760476739715491f, 1.0f}, -{0.90551326412918109f, 0.16355247981545559f, 0.54292964244521336f, 1.0f}, -{0.90396001537870052f, 0.1590157631680123f, 0.53717800845828523f, 1.0f}, -{0.90088427527873893f, 0.15618608227604769f, 0.53078046905036524f, 1.0f}, -{0.89780853517877734f, 0.15335640138408305f, 0.52438292964244515f, 1.0f}, -{0.89473279507881587f, 0.15052672049211843f, 0.51798539023452517f, 1.0f}, -{0.89165705497885439f, 0.14769703960015387f, 0.51158785082660529f, 1.0f}, -{0.88858131487889269f, 0.14486735870818918f, 0.50519031141868509f, 1.0f}, -{0.88550557477893121f, 0.14203767781622453f, 0.49879277201076505f, 1.0f}, -{0.88242983467896963f, 0.13920799692425992f, 0.49239523260284501f, 1.0f}, -{0.87935409457900804f, 0.13637831603229528f, 0.48599769319492503f, 1.0f}, -{0.87627835447904656f, 0.13354863514033066f, 0.47960015378700499f, 1.0f}, -{0.87320261437908497f, 0.13071895424836602f, 0.47320261437908495f, 1.0f}, -{0.87012687427912339f, 0.12788927335640138f, 0.46680507497116491f, 1.0f}, -{0.86705113417916191f, 0.12505959246443676f, 0.46040753556324487f, 1.0f}, -{0.86397539407920032f, 0.12222991157247214f, 0.45400999615532489f, 1.0f}, -{0.86089965397923873f, 0.11940023068050751f, 0.44761245674740485f, 1.0f}, -{0.85782391387927726f, 0.11657054978854287f, 0.44121491733948481f, 1.0f}, -{0.85474817377931567f, 0.11374086889657825f, 0.43481737793156477f, 1.0f}, -{0.85167243367935408f, 0.11091118800461361f, 0.42841983852364474f, 1.0f}, -{0.84859669357939249f, 0.10808150711264898f, 0.4220222991157247f, 1.0f}, -{0.84552095347943101f, 0.10525182622068435f, 0.41562475970780466f, 1.0f}, -{0.84244521337946954f, 0.10242214532871979f, 0.40922722029988484f, 1.0f}, -{0.83936947327950784f, 0.099592464436755096f, 0.40282968089196464f, 1.0f}, -{0.83629373317954636f, 0.096762783544790468f, 0.3964321414840446f, 1.0f}, -{0.83321799307958477f, 0.093933102652825839f, 0.39003460207612456f, 1.0f}, -{0.83014225297962319f, 0.091103421760861211f, 0.38363706266820452f, 1.0f}, -{0.82706651287966171f, 0.088273740868896583f, 0.37723952326028454f, 1.0f}, -{0.82399077277970012f, 0.085444059976931941f, 0.37084198385236444f, 1.0f}, -{0.82091503267973853f, 0.082614379084967313f, 0.36444444444444446f, 1.0f}, -{0.81783929257977706f, 0.079784698193002684f, 0.35804690503652442f, 1.0f}, -{0.81476355247981547f, 0.076955017301038056f, 0.35164936562860438f, 1.0f}, -{0.81168781237985388f, 0.074125336409073428f, 0.3452518262206844f, 1.0f}, -{0.8086120722798924f, 0.0712956555171088f, 0.3388542868127643f, 1.0f}, -{0.80286043829296427f, 0.068927335640138407f, 0.33550173010380624f, 1.0f}, -{0.79621683967704726f, 0.066712802768166088f, 0.33316416762783546f, 1.0f}, -{0.78957324106113036f, 0.064498269896193769f, 0.33082660515186468f, 1.0f}, -{0.78292964244521335f, 0.06228373702422145f, 0.32848904267589391f, 1.0f}, -{0.77628604382929667f, 0.0600692041522492f, 0.32615148019992318f, 1.0f}, -{0.76964244521337943f, 0.057854671280276812f, 0.32381391772395235f, 1.0f}, -{0.76299884659746253f, 0.0556401384083045f, 0.32147635524798157f, 1.0f}, -{0.75635524798154552f, 0.053425605536332181f, 0.31913879277201079f, 1.0f}, -{0.74971164936562862f, 0.051211072664359855f, 0.31680123029604002f, 1.0f}, -{0.74306805074971161f, 0.048996539792387536f, 0.31446366782006924f, 1.0f}, -{0.7364244521337947f, 0.046782006920415224f, 0.31212610534409846f, 1.0f}, -{0.7297808535178778f, 0.044567474048442905f, 0.30978854286812768f, 1.0f}, -{0.72313725490196079f, 0.042352941176470586f, 0.3074509803921569f, 1.0f}, -{0.71649365628604378f, 0.040138408304498267f, 0.30511341791618607f, 1.0f}, -{0.70985005767012688f, 0.037923875432525948f, 0.30277585544021535f, 1.0f}, -{0.70320645905420998f, 0.035709342560553629f, 0.30043829296424451f, 1.0f}, -{0.69656286043829296f, 0.03349480968858131f, 0.29810073048827374f, 1.0f}, -{0.68991926182237595f, 0.031280276816608991f, 0.29576316801230296f, 1.0f}, -{0.68327566320645905f, 0.029065743944636679f, 0.29342560553633218f, 1.0f}, -{0.67663206459054215f, 0.02685121107266436f, 0.2910880430603614f, 1.0f}, -{0.66998846597462536f, 0.024636678200692104f, 0.28875048058439068f, 1.0f}, -{0.66334486735870812f, 0.022422145328719723f, 0.28641291810841984f, 1.0f}, -{0.65670126874279122f, 0.020207612456747404f, 0.28407535563244907f, 1.0f}, -{0.65005767012687432f, 0.017993079584775085f, 0.28173779315647829f, 1.0f}, -{0.64341407151095731f, 0.015778546712802766f, 0.27940023068050751f, 1.0f}, -{0.6367704728950403f, 0.013564013840830447f, 0.27706266820453673f, 1.0f}, -{0.63012687427912339f, 0.011349480968858128f, 0.27472510572856595f, 1.0f}, -{0.62348327566320649f, 0.0091349480968858088f, 0.27238754325259518f, 1.0f}, -{0.61683967704728948f, 0.0069204152249134898f, 0.2700499807766244f, 1.0f}, -{0.61019607843137258f, 0.0047058823529411709f, 0.26771241830065362f, 1.0f}, -{0.60355247981545557f, 0.0024913494809688519f, 0.26537485582468284f, 1.0f}, -{0.59690888119953867f, 0.00027681660899653293f, 0.26303729334871206f, 1.0f}, -{0.59080353710111499f, 0.0f, 0.25886966551326412f, 1.0f}, -{0.58477508650519028f, 0.0f, 0.25444059976931949f, 1.0f}, -{0.57874663590926567f, 0.0f, 0.25001153402537485f, 1.0f}, -{0.57271818531334107f, 0.0f, 0.24558246828143024f, 1.0f}, -{0.56668973471741657f, 0.0f, 0.24115340253748571f, 1.0f}, -{0.56066128412149174f, 0.0f, 0.23672433679354096f, 1.0f}, -{0.55463283352556703f, 0.0f, 0.23229527104959632f, 1.0f}, -{0.54860438292964242f, 0.0f, 0.22786620530565169f, 1.0f}, -{0.54257593233371781f, 0.0f, 0.22343713956170705f, 1.0f}, -{0.5365474817377931f, 0.0f, 0.21900807381776241f, 1.0f}, -{0.53051903114186849f, 0.0f, 0.21457900807381777f, 1.0f}, -{0.52449058054594389f, 0.0f, 0.21014994232987314f, 1.0f}, -{0.51846212995001917f, 0.0f, 0.2057208765859285f, 1.0f}, -{0.51243367935409456f, 0.0f, 0.20129181084198386f, 1.0f}, -{0.50640522875816996f, 0.0f, 0.19686274509803922f, 1.0f}, -{0.50037677816224524f, 0.0f, 0.19243367935409458f, 1.0f}, -{0.49434832756632063f, 0.0f, 0.18800461361014997f, 1.0f}, -{0.48831987697039603f, 0.0f, 0.18357554786620534f, 1.0f}, -{0.48229142637447137f, 0.0f, 0.1791464821222607f, 1.0f}, -{0.4762629757785467f, 0.0f, 0.17471741637831606f, 1.0f}, -{0.47023452518262221f, 0.0f, 0.17028835063437153f, 1.0f}, -{0.46420607458669744f, 0.0f, 0.16585928489042678f, 1.0f}, -{0.45817762399077278f, 0.0f, 0.16143021914648215f, 1.0f}, -{0.45214917339484817f, 0.0f, 0.15700115340253751f, 1.0f}, -{0.44612072279892351f, 0.0f, 0.15257208765859287f, 1.0f}, -{0.44009227220299885f, 0.0f, 0.14814302191464823f, 1.0f}, -{0.43406382160707424f, 0.0f, 0.14371395617070359f, 1.0f}, -{0.42803537101114952f, 0.0f, 0.13928489042675896f, 1.0f}, -{0.42200692041522492f, 0.0f, 0.13485582468281432f, 1.0f}, -{0.41597846981930031f, 0.0f, 0.13042675893886968f, 1.0f}, -{0.40995001922337559f, 0.0f, 0.12599769319492504f, 1.0f}, -{0.40392156862745099f, 0.0f, 0.12156862745098039f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential/PuRd.txt b/extern/tfn/colormaps/sequential/PuRd.txt deleted file mode 100644 index f7b696e..0000000 --- a/extern/tfn/colormaps/sequential/PuRd.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.96862745098039216, 0.95686274509803926, 0.97647058823529409, 1.0) -(0.96665897731641681, 0.95452518262206842, 0.9752402921953095, 1.0) -(0.96469050365244136, 0.9521876201460977, 0.9740099961553248, 1.0) -(0.96272202998846601, 0.94985005767012687, 0.97277970011534021, 1.0) -(0.96075355632449055, 0.94751249519415615, 0.97154940407535562, 1.0) -(0.95878508266051521, 0.94517493271818531, 0.97031910803537103, 1.0) -(0.95681660899653975, 0.94283737024221459, 0.96908881199538632, 1.0) -(0.95484813533256441, 0.94049980776624376, 0.96785851595540173, 1.0) -(0.95287966166858906, 0.93816224529027303, 0.96662821991541714, 1.0) -(0.95091118800461361, 0.9358246828143022, 0.96539792387543255, 1.0) -(0.94894271434063826, 0.93348712033833148, 0.96416762783544785, 1.0) -(0.9469742406766628, 0.93114955786236064, 0.96293733179546326, 1.0) -(0.94500576701268746, 0.92881199538638981, 0.96170703575547867, 1.0) -(0.943037293348712, 0.92647443291041909, 0.96047673971549408, 1.0) -(0.94106881968473666, 0.92413687043444825, 0.95924644367550937, 1.0) -(0.9391003460207612, 0.92179930795847753, 0.95801614763552478, 1.0) -(0.93713187235678586, 0.9194617454825067, 0.95678585159554019, 1.0) -(0.93516339869281051, 0.91712418300653598, 0.95555555555555549, 1.0) -(0.93319492502883505, 0.91478662053056514, 0.9543252595155709, 1.0) -(0.93122645136485971, 0.91244905805459442, 0.95309496347558631, 1.0) -(0.92925797770088425, 0.91011149557862359, 0.95186466743560172, 1.0) -(0.92728950403690891, 0.90777393310265286, 0.95063437139561702, 1.0) -(0.92532103037293345, 0.90543637062668203, 0.94940407535563243, 1.0) -(0.92335255670895811, 0.90309880815071131, 0.94817377931564784, 1.0) -(0.92138408304498265, 0.90076124567474047, 0.94694348327566324, 1.0) -(0.9194156093810073, 0.89842368319876975, 0.94571318723567854, 1.0) -(0.91744713571703196, 0.89608612072279892, 0.94448289119569395, 1.0) -(0.9154786620530565, 0.89374855824682808, 0.94325259515570936, 1.0) -(0.91351018838908116, 0.89141099577085736, 0.94202229911572477, 1.0) -(0.9115417147251057, 0.88907343329488653, 0.94079200307574007, 1.0) -(0.90957324106113036, 0.88673587081891581, 0.93956170703575548, 1.0) -(0.9076047673971549, 0.88439830834294497, 0.93833141099577089, 1.0) -(0.90559015763168016, 0.88173779315647827, 0.93693194925028833, 1.0) -(0.90325259515570933, 0.87681660899653979, 0.93434832756632069, 1.0) -(0.9009150326797386, 0.87189542483660132, 0.93176470588235294, 1.0) -(0.89857747020376777, 0.86697424067666284, 0.92918108419838519, 1.0) -(0.89623990772779705, 0.86205305651672426, 0.92659746251441755, 1.0) -(0.89390234525182621, 0.8571318723567859, 0.9240138408304498, 1.0) -(0.89156478277585549, 0.85221068819684731, 0.92143021914648215, 1.0) -(0.88922722029988466, 0.84728950403690884, 0.9188465974625144, 1.0) -(0.88688965782391393, 0.84236831987697036, 0.91626297577854665, 1.0) -(0.8845520953479431, 0.83744713571703189, 0.91367935409457901, 1.0) -(0.88221453287197238, 0.83252595155709341, 0.91109573241061126, 1.0) -(0.87987697039600155, 0.82760476739715494, 0.90851211072664362, 1.0) -(0.87753940792003082, 0.82268358323721646, 0.90592848904267587, 1.0) -(0.87520184544405999, 0.81776239907727799, 0.90334486735870823, 1.0) -(0.87286428296808927, 0.81284121491733941, 0.90076124567474047, 1.0) -(0.87052672049211843, 0.80792003075740093, 0.89817762399077272, 1.0) -(0.86818915801614771, 0.80299884659746246, 0.89559400230680508, 1.0) -(0.86585159554017688, 0.79807766243752409, 0.89301038062283733, 1.0) -(0.86351403306420615, 0.79315647827758551, 0.89042675893886969, 1.0) -(0.86117647058823532, 0.78823529411764703, 0.88784313725490194, 1.0) -(0.85883890811226449, 0.78331410995770856, 0.88525951557093419, 1.0) -(0.85650134563629376, 0.77839292579777009, 0.88267589388696654, 1.0) -(0.85416378316032304, 0.77347174163783161, 0.88009227220299879, 1.0) -(0.85182622068435221, 0.76855055747789314, 0.87750865051903115, 1.0) -(0.84948865820838138, 0.76362937331795466, 0.8749250288350634, 1.0) -(0.84715109573241065, 0.75870818915801619, 0.87234140715109576, 1.0) -(0.84481353325643982, 0.7537870049980776, 0.86975778546712801, 1.0) -(0.8424759707804691, 0.74886582083813913, 0.86717416378316026, 1.0) -(0.84013840830449826, 0.74394463667820065, 0.86459054209919262, 1.0) -(0.83780084582852754, 0.73902345251826218, 0.86200692041522486, 1.0) -(0.83546328335255671, 0.73410226835832371, 0.85942329873125711, 1.0) -(0.83312572087658598, 0.72918108419838523, 0.85683967704728947, 1.0) -(0.83103421760861207, 0.72435217224144555, 0.85431757016532095, 1.0) -(0.82968089196462902, 0.71980007689350245, 0.85198000768935023, 1.0) -(0.82832756632064597, 0.71524798154555946, 0.8496424452133795, 1.0) -(0.82697424067666281, 0.71069588619761626, 0.84730488273740867, 1.0) -(0.82562091503267976, 0.70614379084967316, 0.84496732026143784, 1.0) -(0.82426758938869671, 0.70159169550173006, 0.84262975778546712, 1.0) -(0.82291426374471355, 0.69703960015378696, 0.84029219530949628, 1.0) -(0.8215609381007305, 0.69248750480584387, 0.83795463283352556, 1.0) -(0.82020761245674745, 0.68793540945790077, 0.83561707035755473, 1.0) -(0.8188542868127644, 0.68338331410995767, 0.833279507881584, 1.0) -(0.81750096116878124, 0.67883121876201469, 0.83094194540561328, 1.0) -(0.81614763552479819, 0.67427912341407148, 0.82860438292964245, 1.0) -(0.81479430988081514, 0.66972702806612838, 0.82626682045367161, 1.0) -(0.81344098423683198, 0.66517493271818529, 0.82392925797770089, 1.0) -(0.81208765859284893, 0.66062283737024219, 0.82159169550173006, 1.0) -(0.81073433294886588, 0.65607074202229909, 0.81925413302575933, 1.0) -(0.80938100730488272, 0.65151864667435599, 0.8169165705497885, 1.0) -(0.80802768166089967, 0.6469665513264129, 0.81457900807381778, 1.0) -(0.80667435601691662, 0.64241445597846991, 0.81224144559784706, 1.0) -(0.80532103037293346, 0.6378623606305267, 0.80990388312187622, 1.0) -(0.80396770472895041, 0.63331026528258361, 0.80756632064590539, 1.0) -(0.80261437908496736, 0.62875816993464051, 0.80522875816993467, 1.0) -(0.80126105344098419, 0.62420607458669741, 0.80289119569396383, 1.0) -(0.79990772779700114, 0.61965397923875432, 0.80055363321799311, 1.0) -(0.79855440215301809, 0.61510188389081122, 0.79821607074202228, 1.0) -(0.79720107650903493, 0.61054978854286812, 0.79587850826605155, 1.0) -(0.79584775086505188, 0.60599769319492514, 0.79354094579008072, 1.0) -(0.79449442522106883, 0.60144559784698193, 0.79120338331411, 1.0) -(0.79314109957708567, 0.59689350249903894, 0.78886582083813916, 1.0) -(0.79178777393310262, 0.59234140715109573, 0.78652825836216844, 1.0) -(0.79043444828911957, 0.58778931180315275, 0.78419069588619761, 1.0) -(0.78908112264513641, 0.58323721645520954, 0.78185313341022689, 1.0) -(0.78925028835063438, 0.57822376009227228, 0.77933102652825836, 1.0) -(0.79195693963860048, 0.57244136870434448, 0.77650134563629369, 1.0) -(0.79466359092656669, 0.5666589773164169, 0.77367166474432914, 1.0) -(0.7973702422145329, 0.5608765859284891, 0.77084198385236447, 1.0) -(0.800076893502499, 0.55509419454056141, 0.7680123029603998, 1.0) -(0.80278354479046521, 0.54931180315263362, 0.76518262206843524, 1.0) -(0.80549019607843131, 0.54352941176470593, 0.76235294117647057, 1.0) -(0.80819684736639752, 0.53774702037677824, 0.75952326028450601, 1.0) -(0.81090349865436373, 0.53196462898885044, 0.75669357939254134, 1.0) -(0.81361014994232983, 0.52618223760092275, 0.75386389850057667, 1.0) -(0.81631680123029593, 0.52039984621299507, 0.75103421760861211, 1.0) -(0.81902345251826214, 0.51461745482506727, 0.74820453671664744, 1.0) -(0.82173010380622835, 0.50883506343713958, 0.74537485582468277, 1.0) -(0.82443675509419456, 0.50305267204921189, 0.74254517493271821, 1.0) -(0.82714340638216066, 0.49727028066128415, 0.73971549404075354, 1.0) -(0.82985005767012687, 0.4914878892733564, 0.73688581314878898, 1.0) -(0.83255670895809297, 0.48570549788542872, 0.73405613225682431, 1.0) -(0.83526336024605918, 0.47992310649750097, 0.73122645136485964, 1.0) -(0.83797001153402528, 0.47414071510957334, 0.72839677047289508, 1.0) -(0.84067666282199149, 0.46835832372164554, 0.72556708958093041, 1.0) -(0.8433833141099577, 0.4625759323337178, 0.72273740868896574, 1.0) -(0.84608996539792392, 0.45679354094579011, 0.71990772779700118, 1.0) -(0.84879661668589002, 0.45101114955786237, 0.71707804690503651, 1.0) -(0.85150326797385623, 0.44522875816993468, 0.71424836601307184, 1.0) -(0.85420991926182233, 0.43944636678200694, 0.71141868512110729, 1.0) -(0.85691657054978854, 0.43366397539407919, 0.70858900422914262, 1.0) -(0.85962322183775464, 0.42788158400615156, 0.70575932333717806, 1.0) -(0.86232987312572085, 0.42209919261822376, 0.70292964244521339, 1.0) -(0.86503652441368706, 0.41631680123029602, 0.70009996155324872, 1.0) -(0.86774317570165316, 0.41053440984236833, 0.69727028066128416, 1.0) -(0.87044982698961937, 0.40475201845444059, 0.69444059976931949, 1.0) -(0.87315647827758558, 0.39896962706651284, 0.69161091887735482, 1.0) -(0.87500192233756247, 0.39238754325259512, 0.68785851595540171, 1.0) -(0.87598615916955014, 0.38500576701268741, 0.68318339100346015, 1.0) -(0.87697039600153792, 0.37762399077277969, 0.67850826605151859, 1.0) -(0.87795463283352559, 0.37024221453287198, 0.67383314109957704, 1.0) -(0.87893886966551327, 0.36286043829296444, 0.66915801614763559, 1.0) -(0.87992310649750094, 0.3554786620530565, 0.66448289119569393, 1.0) -(0.88090734332948861, 0.34809688581314879, 0.65980776624375237, 1.0) -(0.8818915801614764, 0.34071510957324103, 0.65513264129181081, 1.0) -(0.88287581699346407, 0.33333333333333331, 0.65045751633986926, 1.0) -(0.88386005382545174, 0.3259515570934256, 0.6457823913879277, 1.0) -(0.88484429065743941, 0.31856978085351784, 0.64110726643598615, 1.0) -(0.8858285274894272, 0.31118800461361013, 0.63643214148404459, 1.0) -(0.88681276432141487, 0.30380622837370241, 0.63175701653210303, 1.0) -(0.88779700115340254, 0.2964244521337947, 0.62708189158016148, 1.0) -(0.88878123798539022, 0.28904267589388699, 0.62240676662821992, 1.0) -(0.88976547481737789, 0.28166089965397922, 0.61773164167627836, 1.0) -(0.89074971164936567, 0.27427912341407151, 0.61305651672433681, 1.0) -(0.89173394848135334, 0.2668973471741638, 0.60838139177239525, 1.0) -(0.89271818531334102, 0.25951557093425603, 0.60370626682045359, 1.0) -(0.89370242214532869, 0.25213379469434832, 0.59903114186851214, 1.0) -(0.89468665897731636, 0.24475201845444081, 0.5943560169165707, 1.0) -(0.89567089580930415, 0.23737024221453287, 0.58968089196462892, 1.0) -(0.89665513264129182, 0.22998846597462513, 0.58500576701268736, 1.0) -(0.89763936947327949, 0.22260668973471742, 0.5803306420607458, 1.0) -(0.89862360630526716, 0.21522491349480968, 0.57565551710880425, 1.0) -(0.89960784313725495, 0.20784313725490194, 0.57098039215686269, 1.0) -(0.90059207996924262, 0.20046136101499423, 0.56630526720492114, 1.0) -(0.90157631680123029, 0.19307958477508649, 0.56163014225297958, 1.0) -(0.90256055363321797, 0.18569780853517878, 0.55695501730103802, 1.0) -(0.90354479046520564, 0.17831603229527104, 0.55227989234909647, 1.0) -(0.90452902729719342, 0.17093425605536333, 0.54760476739715491, 1.0) -(0.90551326412918109, 0.16355247981545559, 0.54292964244521336, 1.0) -(0.90396001537870052, 0.1590157631680123, 0.53717800845828523, 1.0) -(0.90088427527873893, 0.15618608227604769, 0.53078046905036524, 1.0) -(0.89780853517877734, 0.15335640138408305, 0.52438292964244515, 1.0) -(0.89473279507881587, 0.15052672049211843, 0.51798539023452517, 1.0) -(0.89165705497885439, 0.14769703960015387, 0.51158785082660529, 1.0) -(0.88858131487889269, 0.14486735870818918, 0.50519031141868509, 1.0) -(0.88550557477893121, 0.14203767781622453, 0.49879277201076505, 1.0) -(0.88242983467896963, 0.13920799692425992, 0.49239523260284501, 1.0) -(0.87935409457900804, 0.13637831603229528, 0.48599769319492503, 1.0) -(0.87627835447904656, 0.13354863514033066, 0.47960015378700499, 1.0) -(0.87320261437908497, 0.13071895424836602, 0.47320261437908495, 1.0) -(0.87012687427912339, 0.12788927335640138, 0.46680507497116491, 1.0) -(0.86705113417916191, 0.12505959246443676, 0.46040753556324487, 1.0) -(0.86397539407920032, 0.12222991157247214, 0.45400999615532489, 1.0) -(0.86089965397923873, 0.11940023068050751, 0.44761245674740485, 1.0) -(0.85782391387927726, 0.11657054978854287, 0.44121491733948481, 1.0) -(0.85474817377931567, 0.11374086889657825, 0.43481737793156477, 1.0) -(0.85167243367935408, 0.11091118800461361, 0.42841983852364474, 1.0) -(0.84859669357939249, 0.10808150711264898, 0.4220222991157247, 1.0) -(0.84552095347943101, 0.10525182622068435, 0.41562475970780466, 1.0) -(0.84244521337946954, 0.10242214532871979, 0.40922722029988484, 1.0) -(0.83936947327950784, 0.099592464436755096, 0.40282968089196464, 1.0) -(0.83629373317954636, 0.096762783544790468, 0.3964321414840446, 1.0) -(0.83321799307958477, 0.093933102652825839, 0.39003460207612456, 1.0) -(0.83014225297962319, 0.091103421760861211, 0.38363706266820452, 1.0) -(0.82706651287966171, 0.088273740868896583, 0.37723952326028454, 1.0) -(0.82399077277970012, 0.085444059976931941, 0.37084198385236444, 1.0) -(0.82091503267973853, 0.082614379084967313, 0.36444444444444446, 1.0) -(0.81783929257977706, 0.079784698193002684, 0.35804690503652442, 1.0) -(0.81476355247981547, 0.076955017301038056, 0.35164936562860438, 1.0) -(0.81168781237985388, 0.074125336409073428, 0.3452518262206844, 1.0) -(0.8086120722798924, 0.0712956555171088, 0.3388542868127643, 1.0) -(0.80286043829296427, 0.068927335640138407, 0.33550173010380624, 1.0) -(0.79621683967704726, 0.066712802768166088, 0.33316416762783546, 1.0) -(0.78957324106113036, 0.064498269896193769, 0.33082660515186468, 1.0) -(0.78292964244521335, 0.06228373702422145, 0.32848904267589391, 1.0) -(0.77628604382929667, 0.0600692041522492, 0.32615148019992318, 1.0) -(0.76964244521337943, 0.057854671280276812, 0.32381391772395235, 1.0) -(0.76299884659746253, 0.0556401384083045, 0.32147635524798157, 1.0) -(0.75635524798154552, 0.053425605536332181, 0.31913879277201079, 1.0) -(0.74971164936562862, 0.051211072664359855, 0.31680123029604002, 1.0) -(0.74306805074971161, 0.048996539792387536, 0.31446366782006924, 1.0) -(0.7364244521337947, 0.046782006920415224, 0.31212610534409846, 1.0) -(0.7297808535178778, 0.044567474048442905, 0.30978854286812768, 1.0) -(0.72313725490196079, 0.042352941176470586, 0.3074509803921569, 1.0) -(0.71649365628604378, 0.040138408304498267, 0.30511341791618607, 1.0) -(0.70985005767012688, 0.037923875432525948, 0.30277585544021535, 1.0) -(0.70320645905420998, 0.035709342560553629, 0.30043829296424451, 1.0) -(0.69656286043829296, 0.03349480968858131, 0.29810073048827374, 1.0) -(0.68991926182237595, 0.031280276816608991, 0.29576316801230296, 1.0) -(0.68327566320645905, 0.029065743944636679, 0.29342560553633218, 1.0) -(0.67663206459054215, 0.02685121107266436, 0.2910880430603614, 1.0) -(0.66998846597462536, 0.024636678200692104, 0.28875048058439068, 1.0) -(0.66334486735870812, 0.022422145328719723, 0.28641291810841984, 1.0) -(0.65670126874279122, 0.020207612456747404, 0.28407535563244907, 1.0) -(0.65005767012687432, 0.017993079584775085, 0.28173779315647829, 1.0) -(0.64341407151095731, 0.015778546712802766, 0.27940023068050751, 1.0) -(0.6367704728950403, 0.013564013840830447, 0.27706266820453673, 1.0) -(0.63012687427912339, 0.011349480968858128, 0.27472510572856595, 1.0) -(0.62348327566320649, 0.0091349480968858088, 0.27238754325259518, 1.0) -(0.61683967704728948, 0.0069204152249134898, 0.2700499807766244, 1.0) -(0.61019607843137258, 0.0047058823529411709, 0.26771241830065362, 1.0) -(0.60355247981545557, 0.0024913494809688519, 0.26537485582468284, 1.0) -(0.59690888119953867, 0.00027681660899653293, 0.26303729334871206, 1.0) -(0.59080353710111499, 0.0, 0.25886966551326412, 1.0) -(0.58477508650519028, 0.0, 0.25444059976931949, 1.0) -(0.57874663590926567, 0.0, 0.25001153402537485, 1.0) -(0.57271818531334107, 0.0, 0.24558246828143024, 1.0) -(0.56668973471741657, 0.0, 0.24115340253748571, 1.0) -(0.56066128412149174, 0.0, 0.23672433679354096, 1.0) -(0.55463283352556703, 0.0, 0.23229527104959632, 1.0) -(0.54860438292964242, 0.0, 0.22786620530565169, 1.0) -(0.54257593233371781, 0.0, 0.22343713956170705, 1.0) -(0.5365474817377931, 0.0, 0.21900807381776241, 1.0) -(0.53051903114186849, 0.0, 0.21457900807381777, 1.0) -(0.52449058054594389, 0.0, 0.21014994232987314, 1.0) -(0.51846212995001917, 0.0, 0.2057208765859285, 1.0) -(0.51243367935409456, 0.0, 0.20129181084198386, 1.0) -(0.50640522875816996, 0.0, 0.19686274509803922, 1.0) -(0.50037677816224524, 0.0, 0.19243367935409458, 1.0) -(0.49434832756632063, 0.0, 0.18800461361014997, 1.0) -(0.48831987697039603, 0.0, 0.18357554786620534, 1.0) -(0.48229142637447137, 0.0, 0.1791464821222607, 1.0) -(0.4762629757785467, 0.0, 0.17471741637831606, 1.0) -(0.47023452518262221, 0.0, 0.17028835063437153, 1.0) -(0.46420607458669744, 0.0, 0.16585928489042678, 1.0) -(0.45817762399077278, 0.0, 0.16143021914648215, 1.0) -(0.45214917339484817, 0.0, 0.15700115340253751, 1.0) -(0.44612072279892351, 0.0, 0.15257208765859287, 1.0) -(0.44009227220299885, 0.0, 0.14814302191464823, 1.0) -(0.43406382160707424, 0.0, 0.14371395617070359, 1.0) -(0.42803537101114952, 0.0, 0.13928489042675896, 1.0) -(0.42200692041522492, 0.0, 0.13485582468281432, 1.0) -(0.41597846981930031, 0.0, 0.13042675893886968, 1.0) -(0.40995001922337559, 0.0, 0.12599769319492504, 1.0) -(0.40392156862745099, 0.0, 0.12156862745098039, 1.0) diff --git a/extern/tfn/colormaps/sequential/Purples.cpp b/extern/tfn/colormaps/sequential/Purples.cpp deleted file mode 100644 index bce831f..0000000 --- a/extern/tfn/colormaps/sequential/Purples.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential_Purples; -} -const std::vector colormap::data_sequential_Purples = /* NOLINT(cert-err58-cpp) */ -{ -{0.9882352941176471f, 0.98431372549019602f, 0.99215686274509807f, 1.0f}, -{0.98663590926566713f, 0.9825913110342176f, 0.99117262591311039f, 1.0f}, -{0.98503652441368705f, 0.98086889657823906f, 0.99018838908112272f, 1.0f}, -{0.98343713956170709f, 0.97914648212226063f, 0.98920415224913494f, 1.0f}, -{0.98183775470972712f, 0.9774240676662822f, 0.98821991541714727f, 1.0f}, -{0.98023836985774704f, 0.97570165321030367f, 0.98723567858515959f, 1.0f}, -{0.97863898500576707f, 0.97397923875432524f, 0.98625144175317192f, 1.0f}, -{0.97703960015378699f, 0.9722568242983467f, 0.98526720492118414f, 1.0f}, -{0.97544021530180702f, 0.97053440984236827f, 0.98428296808919646f, 1.0f}, -{0.97384083044982706f, 0.96881199538638985f, 0.98329873125720879f, 1.0f}, -{0.97224144559784698f, 0.96708958093041131f, 0.98231449442522112f, 1.0f}, -{0.97064206074586701f, 0.96536716647443288f, 0.98133025759323345f, 1.0f}, -{0.96904267589388704f, 0.96364475201845445f, 0.98034602076124566f, 1.0f}, -{0.96744329104190696f, 0.96192233756247592f, 0.97936178392925799f, 1.0f}, -{0.96584390618992699f, 0.96019992310649749f, 0.97837754709727032f, 1.0f}, -{0.96424452133794691f, 0.95847750865051906f, 0.97739331026528264f, 1.0f}, -{0.96264513648596695f, 0.95675509419454052f, 0.97640907343329486f, 1.0f}, -{0.96104575163398698f, 0.9550326797385621f, 0.97542483660130719f, 1.0f}, -{0.9594463667820069f, 0.95331026528258356f, 0.97444059976931952f, 1.0f}, -{0.95784698193002693f, 0.95158785082660513f, 0.97345636293733184f, 1.0f}, -{0.95624759707804696f, 0.9498654363706267f, 0.97247212610534417f, 1.0f}, -{0.95464821222606688f, 0.94814302191464817f, 0.97148788927335639f, 1.0f}, -{0.95304882737408692f, 0.94642060745866974f, 0.97050365244136871f, 1.0f}, -{0.95144944252210695f, 0.94469819300269131f, 0.96951941560938104f, 1.0f}, -{0.94985005767012687f, 0.94297577854671277f, 0.96853517877739337f, 1.0f}, -{0.9482506728181469f, 0.94125336409073435f, 0.96755094194540558f, 1.0f}, -{0.94665128796616682f, 0.93953094963475592f, 0.96656670511341791f, 1.0f}, -{0.94505190311418685f, 0.93780853517877738f, 0.96558246828143024f, 1.0f}, -{0.94345251826220689f, 0.93608612072279895f, 0.96459823144944257f, 1.0f}, -{0.94185313341022681f, 0.93436370626682053f, 0.96361399461745489f, 1.0f}, -{0.94025374855824684f, 0.93264129181084199f, 0.96262975778546711f, 1.0f}, -{0.93865436370626687f, 0.93091887735486356f, 0.96164552095347944f, 1.0f}, -{0.93693194925028833f, 0.92911956939638607f, 0.9606305267204921f, 1.0f}, -{0.93434832756632069f, 0.92678200692041524f, 0.9594002306805075f, 1.0f}, -{0.93176470588235294f, 0.92444444444444451f, 0.95816993464052291f, 1.0f}, -{0.92918108419838519f, 0.92210688196847368f, 0.95693963860053832f, 1.0f}, -{0.92659746251441755f, 0.91976931949250296f, 0.95570934256055362f, 1.0f}, -{0.9240138408304498f, 0.91743175701653212f, 0.95447904652056903f, 1.0f}, -{0.92143021914648215f, 0.91509419454056129f, 0.95324875048058444f, 1.0f}, -{0.9188465974625144f, 0.91275663206459057f, 0.95201845444059974f, 1.0f}, -{0.91626297577854665f, 0.91041906958861973f, 0.95078815840061515f, 1.0f}, -{0.91367935409457901f, 0.90808150711264901f, 0.94955786236063056f, 1.0f}, -{0.91109573241061126f, 0.90574394463667818f, 0.94832756632064585f, 1.0f}, -{0.90851211072664362f, 0.90340638216070746f, 0.94709727028066126f, 1.0f}, -{0.90592848904267587f, 0.90106881968473662f, 0.94586697424067667f, 1.0f}, -{0.90334486735870823f, 0.8987312572087659f, 0.94463667820069208f, 1.0f}, -{0.90076124567474047f, 0.89639369473279507f, 0.94340638216070738f, 1.0f}, -{0.89817762399077272f, 0.89405613225682434f, 0.94217608612072279f, 1.0f}, -{0.89559400230680508f, 0.89171856978085351f, 0.9409457900807382f, 1.0f}, -{0.89301038062283733f, 0.88938100730488279f, 0.9397154940407535f, 1.0f}, -{0.89042675893886969f, 0.88704344482891195f, 0.93848519800076891f, 1.0f}, -{0.88784313725490194f, 0.88470588235294112f, 0.93725490196078431f, 1.0f}, -{0.88525951557093419f, 0.8823683198769704f, 0.93602460592079972f, 1.0f}, -{0.88267589388696654f, 0.88003075740099956f, 0.93479430988081502f, 1.0f}, -{0.88009227220299879f, 0.87769319492502884f, 0.93356401384083043f, 1.0f}, -{0.87750865051903115f, 0.87535563244905801f, 0.93233371780084584f, 1.0f}, -{0.8749250288350634f, 0.87301806997308729f, 0.93110342176086114f, 1.0f}, -{0.87234140715109576f, 0.87068050749711645f, 0.92987312572087655f, 1.0f}, -{0.86975778546712801f, 0.86834294502114573f, 0.92864282968089196f, 1.0f}, -{0.86717416378316026f, 0.8660053825451749f, 0.92741253364090726f, 1.0f}, -{0.86459054209919262f, 0.86366782006920406f, 0.92618223760092266f, 1.0f}, -{0.86200692041522486f, 0.86133025759323334f, 0.92495194156093807f, 1.0f}, -{0.85942329873125711f, 0.85899269511726262f, 0.92372164552095337f, 1.0f}, -{0.85683967704728947f, 0.85665513264129178f, 0.92249134948096878f, 1.0f}, -{0.85397923875432524f, 0.8540099961553248f, 0.92110726643598606f, 1.0f}, -{0.85028835063437136f, 0.85044213763936949f, 0.91926182237600917f, 1.0f}, -{0.84659746251441759f, 0.84687427912341406f, 0.91741637831603229f, 1.0f}, -{0.84290657439446359f, 0.84330642060745864f, 0.91557093425605529f, 1.0f}, -{0.83921568627450982f, 0.83973856209150322f, 0.9137254901960784f, 1.0f}, -{0.83552479815455594f, 0.83617070357554779f, 0.91188004613610141f, 1.0f}, -{0.83183391003460205f, 0.83260284505959248f, 0.91003460207612452f, 1.0f}, -{0.82814302191464817f, 0.82903498654363705f, 0.90818915801614764f, 1.0f}, -{0.82445213379469429f, 0.82546712802768163f, 0.90634371395617064f, 1.0f}, -{0.82076124567474051f, 0.8218992695117262f, 0.90449826989619375f, 1.0f}, -{0.81707035755478663f, 0.81833141099577089f, 0.90265282583621687f, 1.0f}, -{0.81337946943483275f, 0.81476355247981547f, 0.90080738177623987f, 1.0f}, -{0.80968858131487886f, 0.81119569396386004f, 0.89896193771626298f, 1.0f}, -{0.80599769319492498f, 0.80762783544790462f, 0.89711649365628598f, 1.0f}, -{0.80230680507497121f, 0.80405997693194919f, 0.8952710495963091f, 1.0f}, -{0.79861591695501732f, 0.80049211841599388f, 0.89342560553633221f, 1.0f}, -{0.79492502883506344f, 0.79692425990003846f, 0.89158016147635522f, 1.0f}, -{0.79123414071510956f, 0.79335640138408303f, 0.88973471741637833f, 1.0f}, -{0.78754325259515578f, 0.78978854286812772f, 0.88788927335640144f, 1.0f}, -{0.7838523644752019f, 0.78622068435217229f, 0.88604382929642445f, 1.0f}, -{0.78016147635524802f, 0.78265282583621687f, 0.88419838523644756f, 1.0f}, -{0.77647058823529413f, 0.77908496732026145f, 0.88235294117647056f, 1.0f}, -{0.77277970011534025f, 0.77551710880430602f, 0.88050749711649368f, 1.0f}, -{0.76908881199538648f, 0.77194925028835071f, 0.87866205305651679f, 1.0f}, -{0.7653979238754326f, 0.76838139177239528f, 0.87681660899653979f, 1.0f}, -{0.76170703575547871f, 0.76481353325643986f, 0.87497116493656291f, 1.0f}, -{0.75801614763552494f, 0.76124567474048455f, 0.87312572087658602f, 1.0f}, -{0.75432525951557095f, 0.75767781622452901f, 0.87128027681660902f, 1.0f}, -{0.75063437139561717f, 0.7541099577085737f, 0.86943483275663214f, 1.0f}, -{0.74694348327566329f, 0.75054209919261827f, 0.86758938869665514f, 1.0f}, -{0.74325259515570941f, 0.74697424067666285f, 0.86574394463667825f, 1.0f}, -{0.73956170703575552f, 0.74340638216070742f, 0.86389850057670126f, 1.0f}, -{0.73587081891580164f, 0.73956170703575552f, 0.86182237600922729f, 1.0f}, -{0.73217993079584776f, 0.73525567089580934f, 0.85936178392925799f, 1.0f}, -{0.72848904267589398f, 0.73094963475586316f, 0.85690119184928881f, 1.0f}, -{0.7247981545559401f, 0.72664359861591699f, 0.85444059976931952f, 1.0f}, -{0.72110726643598622f, 0.72233756247597081f, 0.85198000768935034f, 1.0f}, -{0.71741637831603233f, 0.71803152633602463f, 0.84951941560938105f, 1.0f}, -{0.71372549019607845f, 0.71372549019607845f, 0.84705882352941175f, 1.0f}, -{0.71003460207612457f, 0.70941945405613227f, 0.84459823144944257f, 1.0f}, -{0.70634371395617079f, 0.70511341791618609f, 0.84213763936947328f, 1.0f}, -{0.70265282583621691f, 0.70080738177623991f, 0.8396770472895041f, 1.0f}, -{0.69896193771626303f, 0.69650134563629384f, 0.8372164552095348f, 1.0f}, -{0.69527104959630914f, 0.69219530949634756f, 0.83475586312956562f, 1.0f}, -{0.69158016147635526f, 0.68788927335640138f, 0.83229527104959633f, 1.0f}, -{0.68788927335640138f, 0.6835832372164552f, 0.82983467896962704f, 1.0f}, -{0.6841983852364476f, 0.67927720107650902f, 0.82737408688965786f, 1.0f}, -{0.68050749711649372f, 0.67497116493656284f, 0.82491349480968856f, 1.0f}, -{0.67681660899653984f, 0.67066512879661666f, 0.82245290272971938f, 1.0f}, -{0.67312572087658595f, 0.66635909265667048f, 0.81999231064975009f, 1.0f}, -{0.66943483275663218f, 0.66205305651672441f, 0.81753171856978091f, 1.0f}, -{0.66574394463667819f, 0.65774702037677812f, 0.81507112648981161f, 1.0f}, -{0.66205305651672441f, 0.65344098423683195f, 0.81261053440984243f, 1.0f}, -{0.65836216839677053f, 0.64913494809688577f, 0.81014994232987314f, 1.0f}, -{0.65467128027681665f, 0.64482891195693959f, 0.80768935024990385f, 1.0f}, -{0.65098039215686276f, 0.64052287581699341f, 0.80522875816993467f, 1.0f}, -{0.64728950403690888f, 0.63621683967704723f, 0.80276816608996537f, 1.0f}, -{0.64359861591695511f, 0.63191080353710105f, 0.80030757400999619f, 1.0f}, -{0.63990772779700122f, 0.62760476739715498f, 0.7978469819300269f, 1.0f}, -{0.63621683967704734f, 0.62329873125720869f, 0.79538638985005772f, 1.0f}, -{0.63252595155709346f, 0.61899269511726263f, 0.79292579777008843f, 1.0f}, -{0.62883506343713957f, 0.61468665897731634f, 0.79046520569011913f, 1.0f}, -{0.62514417531718569f, 0.61038062283737027f, 0.78800461361014995f, 1.0f}, -{0.62145328719723181f, 0.60607458669742398f, 0.78554402153018066f, 1.0f}, -{0.61776239907727803f, 0.60213763936947329f, 0.78345251826220685f, 1.0f}, -{0.61407151095732415f, 0.59856978085351786f, 0.78173010380622832f, 1.0f}, -{0.61038062283737027f, 0.59500192233756244f, 0.78000768935024989f, 1.0f}, -{0.60668973471741638f, 0.59143406382160701f, 0.77828527489427146f, 1.0f}, -{0.60299884659746261f, 0.5878662053056517f, 0.77656286043829303f, 1.0f}, -{0.59930795847750862f, 0.58429834678969628f, 0.7748404459823145f, 1.0f}, -{0.59561707035755485f, 0.58073048827374085f, 0.77311803152633596f, 1.0f}, -{0.59192618223760096f, 0.57716262975778543f, 0.77139561707035753f, 1.0f}, -{0.58823529411764708f, 0.57359477124183f, 0.7696732026143791f, 1.0f}, -{0.58454440599769319f, 0.57002691272587458f, 0.76795078815840057f, 1.0f}, -{0.58085351787773931f, 0.56645905420991927f, 0.76622837370242214f, 1.0f}, -{0.57716262975778543f, 0.56289119569396384f, 0.7645059592464436f, 1.0f}, -{0.57347174163783166f, 0.55932333717800842f, 0.76278354479046517f, 1.0f}, -{0.56978085351787777f, 0.55575547866205299f, 0.76106113033448675f, 1.0f}, -{0.56608996539792389f, 0.55218762014609757f, 0.75933871587850821f, 1.0f}, -{0.56239907727797001f, 0.54861976163014226f, 0.75761630142252978f, 1.0f}, -{0.55870818915801612f, 0.54505190311418683f, 0.75589388696655124f, 1.0f}, -{0.55501730103806224f, 0.54148404459823141f, 0.75417147251057282f, 1.0f}, -{0.55132641291810847f, 0.53791618608227598f, 0.75244905805459439f, 1.0f}, -{0.54763552479815458f, 0.53434832756632056f, 0.75072664359861585f, 1.0f}, -{0.54394463667820081f, 0.53078046905036536f, 0.74900422914263742f, 1.0f}, -{0.54025374855824682f, 0.52721261053440982f, 0.747281814686659f, 1.0f}, -{0.53656286043829293f, 0.5236447520184544f, 0.74555940023068046f, 1.0f}, -{0.53287197231833905f, 0.52007689350249897f, 0.74383698577470203f, 1.0f}, -{0.52918108419838528f, 0.51650903498654355f, 0.74211457131872349f, 1.0f}, -{0.52549019607843139f, 0.51294117647058823f, 0.74039215686274507f, 1.0f}, -{0.52179930795847751f, 0.50937331795463281f, 0.73866974240676664f, 1.0f}, -{0.51810841983852363f, 0.50580545943867739f, 0.7369473279507881f, 1.0f}, -{0.51441753171856974f, 0.50223760092272196f, 0.73522491349480967f, 1.0f}, -{0.51072664359861586f, 0.49866974240676659f, 0.73350249903883114f, 1.0f}, -{0.50703575547866209f, 0.49510188389081122f, 0.73178008458285271f, 1.0f}, -{0.5033448673587082f, 0.4915340253748558f, 0.73005767012687428f, 1.0f}, -{0.50026912725874662f, 0.48681276432141479f, 0.72764321414840438f, 1.0f}, -{0.49756247597078046f, 0.48139946174548248f, 0.72481353325643982f, 1.0f}, -{0.4948558246828143f, 0.47598615916955017f, 0.72198385236447515f, 1.0f}, -{0.49214917339484815f, 0.47057285659361781f, 0.71915417147251048f, 1.0f}, -{0.48944252210688205f, 0.46515955401768566f, 0.71632449058054604f, 1.0f}, -{0.48673587081891578f, 0.45974625144175313f, 0.71349480968858126f, 1.0f}, -{0.48402921953094963f, 0.45433294886582082f, 0.7106651287966167f, 1.0f}, -{0.48132256824298347f, 0.44891964628988845f, 0.70783544790465203f, 1.0f}, -{0.47861591695501732f, 0.44350634371395614f, 0.70500576701268736f, 1.0f}, -{0.47590926566705116f, 0.43809304113802383f, 0.7021760861207228f, 1.0f}, -{0.47320261437908495f, 0.43267973856209146f, 0.69934640522875813f, 1.0f}, -{0.4704959630911188f, 0.42726643598615915f, 0.69651672433679346f, 1.0f}, -{0.46778931180315264f, 0.42185313341022679f, 0.6936870434448289f, 1.0f}, -{0.46508266051518649f, 0.41643983083429448f, 0.69085736255286423f, 1.0f}, -{0.46237600922722033f, 0.41102652825836217f, 0.68802768166089967f, 1.0f}, -{0.45966935793925412f, 0.4056132256824298f, 0.685198000768935f, 1.0f}, -{0.45696270665128796f, 0.40019992310649749f, 0.68236831987697033f, 1.0f}, -{0.45425605536332181f, 0.39478662053056512f, 0.67953863898500577f, 1.0f}, -{0.45154940407535565f, 0.38937331795463281f, 0.6767089580930411f, 1.0f}, -{0.4488427527873895f, 0.3839600153787005f, 0.67387927720107643f, 1.0f}, -{0.4461361014994234f, 0.3785467128027683f, 0.67104959630911187f, 1.0f}, -{0.44342945021145713f, 0.37313341022683583f, 0.6682199154171472f, 1.0f}, -{0.44072279892349098f, 0.36772010765090346f, 0.66539023452518253f, 1.0f}, -{0.43801614763552482f, 0.36230680507497115f, 0.66256055363321797f, 1.0f}, -{0.43530949634755867f, 0.35689350249903884f, 0.6597308727412533f, 1.0f}, -{0.43260284505959246f, 0.35148019992310647f, 0.65690119184928863f, 1.0f}, -{0.4298961937716263f, 0.34606689734717411f, 0.65407151095732408f, 1.0f}, -{0.42718954248366015f, 0.3406535947712418f, 0.65124183006535941f, 1.0f}, -{0.42448289119569399f, 0.33524029219530949f, 0.64841214917339474f, 1.0f}, -{0.42177623990772783f, 0.32982698961937718f, 0.64558246828143018f, 1.0f}, -{0.41906958861976162f, 0.32441368704344481f, 0.64275278738946551f, 1.0f}, -{0.41636293733179547f, 0.31900038446751244f, 0.63992310649750095f, 1.0f}, -{0.41365628604382931f, 0.31377162629757782f, 0.63737024221453287f, 1.0f}, -{0.41094963475586316f, 0.30860438292964243f, 0.63490965013456357f, 1.0f}, -{0.408242983467897f, 0.30343713956170704f, 0.63244905805459439f, 1.0f}, -{0.40553633217993079f, 0.29826989619377159f, 0.6299884659746251f, 1.0f}, -{0.40282968089196475f, 0.29310265282583636f, 0.62752787389465592f, 1.0f}, -{0.40012302960399848f, 0.2879354094579008f, 0.62506728181468663f, 1.0f}, -{0.39741637831603233f, 0.28276816608996536f, 0.62260668973471733f, 1.0f}, -{0.39470972702806617f, 0.27760092272202996f, 0.62014609765474815f, 1.0f}, -{0.39200307574009996f, 0.27243367935409457f, 0.61768550557477886f, 1.0f}, -{0.3892964244521338f, 0.26726643598615918f, 0.61522491349480968f, 1.0f}, -{0.38658977316416765f, 0.26209919261822373f, 0.61276432141484038f, 1.0f}, -{0.38388312187620149f, 0.25693194925028834f, 0.6103037293348712f, 1.0f}, -{0.38117647058823528f, 0.25176470588235295f, 0.60784313725490191f, 1.0f}, -{0.37846981930026913f, 0.24659746251441753f, 0.60538254517493273f, 1.0f}, -{0.37576316801230297f, 0.24143021914648211f, 0.60292195309496344f, 1.0f}, -{0.37305651672433682f, 0.23626297577854671f, 0.60046136101499425f, 1.0f}, -{0.37034986543637061f, 0.23109573241061129f, 0.59800076893502496f, 1.0f}, -{0.36764321414840445f, 0.22592848904267587f, 0.59554017685505567f, 1.0f}, -{0.3649365628604383f, 0.22076124567474048f, 0.59307958477508649f, 1.0f}, -{0.36222991157247214f, 0.21559400230680509f, 0.5906189926951172f, 1.0f}, -{0.35952326028450604f, 0.21042675893886981f, 0.58815840061514812f, 1.0f}, -{0.35681660899653977f, 0.20525951557093425f, 0.58569780853517872f, 1.0f}, -{0.35410995770857362f, 0.20009227220299886f, 0.58323721645520954f, 1.0f}, -{0.35140330642060746f, 0.19492502883506344f, 0.58077662437524025f, 1.0f}, -{0.34869665513264131f, 0.18975778546712804f, 0.57831603229527107f, 1.0f}, -{0.34599000384467515f, 0.18459054209919262f, 0.57585544021530177f, 1.0f}, -{0.34328335255670894f, 0.1794232987312572f, 0.57339484813533259f, 1.0f}, -{0.34057670126874279f, 0.17425605536332181f, 0.5709342560553633f, 1.0f}, -{0.33787004998077663f, 0.16908881199538639f, 0.56847366397539412f, 1.0f}, -{0.33516339869281042f, 0.163921568627451f, 0.56601307189542482f, 1.0f}, -{0.33245674740484427f, 0.15875432525951558f, 0.56355247981545564f, 1.0f}, -{0.32975009611687811f, 0.15358708189158016f, 0.56109188773548635f, 1.0f}, -{0.32715109573241064f, 0.14874279123414072f, 0.55884659746251442f, 1.0f}, -{0.32456747404844288f, 0.1439446366782007f, 0.55663206459054215f, 1.0f}, -{0.32198385236447519f, 0.13914648212226069f, 0.55441753171856978f, 1.0f}, -{0.31940023068050749f, 0.13434832756632065f, 0.55220299884659751f, 1.0f}, -{0.31681660899653985f, 0.12955017301038077f, 0.54998846597462525f, 1.0f}, -{0.3142329873125721f, 0.1247520184544406f, 0.54777393310265288f, 1.0f}, -{0.3116493656286044f, 0.11995386389850059f, 0.5455594002306805f, 1.0f}, -{0.30906574394463665f, 0.11515570934256056f, 0.54334486735870824f, 1.0f}, -{0.30648212226066895f, 0.11035755478662054f, 0.54113033448673586f, 1.0f}, -{0.30389850057670126f, 0.10555940023068051f, 0.5389158016147636f, 1.0f}, -{0.30131487889273356f, 0.10076124567474048f, 0.53670126874279123f, 1.0f}, -{0.29873125720876587f, 0.09596309111880047f, 0.53448673587081896f, 1.0f}, -{0.29614763552479817f, 0.091164936562860441f, 0.53227220299884659f, 1.0f}, -{0.29356401384083047f, 0.086366782006920426f, 0.53005767012687433f, 1.0f}, -{0.29098039215686278f, 0.081568627450980397f, 0.52784313725490195f, 1.0f}, -{0.28839677047289503f, 0.076770472895040368f, 0.52562860438292969f, 1.0f}, -{0.28581314878892733f, 0.071972318339100352f, 0.52341407151095731f, 1.0f}, -{0.28322952710495963f, 0.067174163783160323f, 0.52119953863898494f, 1.0f}, -{0.28064590542099194f, 0.062376009227220308f, 0.51898500576701267f, 1.0f}, -{0.27806228373702424f, 0.057577854671280279f, 0.51677047289504041f, 1.0f}, -{0.2754786620530566f, 0.052779700115340389f, 0.51455594002306815f, 1.0f}, -{0.27289504036908885f, 0.047981545559400235f, 0.51234140715109566f, 1.0f}, -{0.2703114186851211f, 0.043183391003460206f, 0.5101268742791234f, 1.0f}, -{0.2677277970011534f, 0.038385236447520191f, 0.50791234140715114f, 1.0f}, -{0.2651441753171857f, 0.033587081891580162f, 0.50569780853517876f, 1.0f}, -{0.26256055363321801f, 0.028788927335640146f, 0.50348327566320639f, 1.0f}, -{0.25997693194925031f, 0.023990772779700104f, 0.50126874279123412f, 1.0f}, -{0.25739331026528256f, 0.019192618223760088f, 0.4990542099192618f, 1.0f}, -{0.25480968858131492f, 0.014394463667820073f, 0.49683967704728949f, 1.0f}, -{0.25222606689734717f, 0.0095963091118800581f, 0.49462514417531717f, 1.0f}, -{0.24964244521337947f, 0.0047981545559400152f, 0.49241061130334485f, 1.0f}, -{0.24705882352941178f, 0.0f, 0.49019607843137253f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential/Purples.txt b/extern/tfn/colormaps/sequential/Purples.txt deleted file mode 100644 index 031d892..0000000 --- a/extern/tfn/colormaps/sequential/Purples.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.9882352941176471, 0.98431372549019602, 0.99215686274509807, 1.0) -(0.98663590926566713, 0.9825913110342176, 0.99117262591311039, 1.0) -(0.98503652441368705, 0.98086889657823906, 0.99018838908112272, 1.0) -(0.98343713956170709, 0.97914648212226063, 0.98920415224913494, 1.0) -(0.98183775470972712, 0.9774240676662822, 0.98821991541714727, 1.0) -(0.98023836985774704, 0.97570165321030367, 0.98723567858515959, 1.0) -(0.97863898500576707, 0.97397923875432524, 0.98625144175317192, 1.0) -(0.97703960015378699, 0.9722568242983467, 0.98526720492118414, 1.0) -(0.97544021530180702, 0.97053440984236827, 0.98428296808919646, 1.0) -(0.97384083044982706, 0.96881199538638985, 0.98329873125720879, 1.0) -(0.97224144559784698, 0.96708958093041131, 0.98231449442522112, 1.0) -(0.97064206074586701, 0.96536716647443288, 0.98133025759323345, 1.0) -(0.96904267589388704, 0.96364475201845445, 0.98034602076124566, 1.0) -(0.96744329104190696, 0.96192233756247592, 0.97936178392925799, 1.0) -(0.96584390618992699, 0.96019992310649749, 0.97837754709727032, 1.0) -(0.96424452133794691, 0.95847750865051906, 0.97739331026528264, 1.0) -(0.96264513648596695, 0.95675509419454052, 0.97640907343329486, 1.0) -(0.96104575163398698, 0.9550326797385621, 0.97542483660130719, 1.0) -(0.9594463667820069, 0.95331026528258356, 0.97444059976931952, 1.0) -(0.95784698193002693, 0.95158785082660513, 0.97345636293733184, 1.0) -(0.95624759707804696, 0.9498654363706267, 0.97247212610534417, 1.0) -(0.95464821222606688, 0.94814302191464817, 0.97148788927335639, 1.0) -(0.95304882737408692, 0.94642060745866974, 0.97050365244136871, 1.0) -(0.95144944252210695, 0.94469819300269131, 0.96951941560938104, 1.0) -(0.94985005767012687, 0.94297577854671277, 0.96853517877739337, 1.0) -(0.9482506728181469, 0.94125336409073435, 0.96755094194540558, 1.0) -(0.94665128796616682, 0.93953094963475592, 0.96656670511341791, 1.0) -(0.94505190311418685, 0.93780853517877738, 0.96558246828143024, 1.0) -(0.94345251826220689, 0.93608612072279895, 0.96459823144944257, 1.0) -(0.94185313341022681, 0.93436370626682053, 0.96361399461745489, 1.0) -(0.94025374855824684, 0.93264129181084199, 0.96262975778546711, 1.0) -(0.93865436370626687, 0.93091887735486356, 0.96164552095347944, 1.0) -(0.93693194925028833, 0.92911956939638607, 0.9606305267204921, 1.0) -(0.93434832756632069, 0.92678200692041524, 0.9594002306805075, 1.0) -(0.93176470588235294, 0.92444444444444451, 0.95816993464052291, 1.0) -(0.92918108419838519, 0.92210688196847368, 0.95693963860053832, 1.0) -(0.92659746251441755, 0.91976931949250296, 0.95570934256055362, 1.0) -(0.9240138408304498, 0.91743175701653212, 0.95447904652056903, 1.0) -(0.92143021914648215, 0.91509419454056129, 0.95324875048058444, 1.0) -(0.9188465974625144, 0.91275663206459057, 0.95201845444059974, 1.0) -(0.91626297577854665, 0.91041906958861973, 0.95078815840061515, 1.0) -(0.91367935409457901, 0.90808150711264901, 0.94955786236063056, 1.0) -(0.91109573241061126, 0.90574394463667818, 0.94832756632064585, 1.0) -(0.90851211072664362, 0.90340638216070746, 0.94709727028066126, 1.0) -(0.90592848904267587, 0.90106881968473662, 0.94586697424067667, 1.0) -(0.90334486735870823, 0.8987312572087659, 0.94463667820069208, 1.0) -(0.90076124567474047, 0.89639369473279507, 0.94340638216070738, 1.0) -(0.89817762399077272, 0.89405613225682434, 0.94217608612072279, 1.0) -(0.89559400230680508, 0.89171856978085351, 0.9409457900807382, 1.0) -(0.89301038062283733, 0.88938100730488279, 0.9397154940407535, 1.0) -(0.89042675893886969, 0.88704344482891195, 0.93848519800076891, 1.0) -(0.88784313725490194, 0.88470588235294112, 0.93725490196078431, 1.0) -(0.88525951557093419, 0.8823683198769704, 0.93602460592079972, 1.0) -(0.88267589388696654, 0.88003075740099956, 0.93479430988081502, 1.0) -(0.88009227220299879, 0.87769319492502884, 0.93356401384083043, 1.0) -(0.87750865051903115, 0.87535563244905801, 0.93233371780084584, 1.0) -(0.8749250288350634, 0.87301806997308729, 0.93110342176086114, 1.0) -(0.87234140715109576, 0.87068050749711645, 0.92987312572087655, 1.0) -(0.86975778546712801, 0.86834294502114573, 0.92864282968089196, 1.0) -(0.86717416378316026, 0.8660053825451749, 0.92741253364090726, 1.0) -(0.86459054209919262, 0.86366782006920406, 0.92618223760092266, 1.0) -(0.86200692041522486, 0.86133025759323334, 0.92495194156093807, 1.0) -(0.85942329873125711, 0.85899269511726262, 0.92372164552095337, 1.0) -(0.85683967704728947, 0.85665513264129178, 0.92249134948096878, 1.0) -(0.85397923875432524, 0.8540099961553248, 0.92110726643598606, 1.0) -(0.85028835063437136, 0.85044213763936949, 0.91926182237600917, 1.0) -(0.84659746251441759, 0.84687427912341406, 0.91741637831603229, 1.0) -(0.84290657439446359, 0.84330642060745864, 0.91557093425605529, 1.0) -(0.83921568627450982, 0.83973856209150322, 0.9137254901960784, 1.0) -(0.83552479815455594, 0.83617070357554779, 0.91188004613610141, 1.0) -(0.83183391003460205, 0.83260284505959248, 0.91003460207612452, 1.0) -(0.82814302191464817, 0.82903498654363705, 0.90818915801614764, 1.0) -(0.82445213379469429, 0.82546712802768163, 0.90634371395617064, 1.0) -(0.82076124567474051, 0.8218992695117262, 0.90449826989619375, 1.0) -(0.81707035755478663, 0.81833141099577089, 0.90265282583621687, 1.0) -(0.81337946943483275, 0.81476355247981547, 0.90080738177623987, 1.0) -(0.80968858131487886, 0.81119569396386004, 0.89896193771626298, 1.0) -(0.80599769319492498, 0.80762783544790462, 0.89711649365628598, 1.0) -(0.80230680507497121, 0.80405997693194919, 0.8952710495963091, 1.0) -(0.79861591695501732, 0.80049211841599388, 0.89342560553633221, 1.0) -(0.79492502883506344, 0.79692425990003846, 0.89158016147635522, 1.0) -(0.79123414071510956, 0.79335640138408303, 0.88973471741637833, 1.0) -(0.78754325259515578, 0.78978854286812772, 0.88788927335640144, 1.0) -(0.7838523644752019, 0.78622068435217229, 0.88604382929642445, 1.0) -(0.78016147635524802, 0.78265282583621687, 0.88419838523644756, 1.0) -(0.77647058823529413, 0.77908496732026145, 0.88235294117647056, 1.0) -(0.77277970011534025, 0.77551710880430602, 0.88050749711649368, 1.0) -(0.76908881199538648, 0.77194925028835071, 0.87866205305651679, 1.0) -(0.7653979238754326, 0.76838139177239528, 0.87681660899653979, 1.0) -(0.76170703575547871, 0.76481353325643986, 0.87497116493656291, 1.0) -(0.75801614763552494, 0.76124567474048455, 0.87312572087658602, 1.0) -(0.75432525951557095, 0.75767781622452901, 0.87128027681660902, 1.0) -(0.75063437139561717, 0.7541099577085737, 0.86943483275663214, 1.0) -(0.74694348327566329, 0.75054209919261827, 0.86758938869665514, 1.0) -(0.74325259515570941, 0.74697424067666285, 0.86574394463667825, 1.0) -(0.73956170703575552, 0.74340638216070742, 0.86389850057670126, 1.0) -(0.73587081891580164, 0.73956170703575552, 0.86182237600922729, 1.0) -(0.73217993079584776, 0.73525567089580934, 0.85936178392925799, 1.0) -(0.72848904267589398, 0.73094963475586316, 0.85690119184928881, 1.0) -(0.7247981545559401, 0.72664359861591699, 0.85444059976931952, 1.0) -(0.72110726643598622, 0.72233756247597081, 0.85198000768935034, 1.0) -(0.71741637831603233, 0.71803152633602463, 0.84951941560938105, 1.0) -(0.71372549019607845, 0.71372549019607845, 0.84705882352941175, 1.0) -(0.71003460207612457, 0.70941945405613227, 0.84459823144944257, 1.0) -(0.70634371395617079, 0.70511341791618609, 0.84213763936947328, 1.0) -(0.70265282583621691, 0.70080738177623991, 0.8396770472895041, 1.0) -(0.69896193771626303, 0.69650134563629384, 0.8372164552095348, 1.0) -(0.69527104959630914, 0.69219530949634756, 0.83475586312956562, 1.0) -(0.69158016147635526, 0.68788927335640138, 0.83229527104959633, 1.0) -(0.68788927335640138, 0.6835832372164552, 0.82983467896962704, 1.0) -(0.6841983852364476, 0.67927720107650902, 0.82737408688965786, 1.0) -(0.68050749711649372, 0.67497116493656284, 0.82491349480968856, 1.0) -(0.67681660899653984, 0.67066512879661666, 0.82245290272971938, 1.0) -(0.67312572087658595, 0.66635909265667048, 0.81999231064975009, 1.0) -(0.66943483275663218, 0.66205305651672441, 0.81753171856978091, 1.0) -(0.66574394463667819, 0.65774702037677812, 0.81507112648981161, 1.0) -(0.66205305651672441, 0.65344098423683195, 0.81261053440984243, 1.0) -(0.65836216839677053, 0.64913494809688577, 0.81014994232987314, 1.0) -(0.65467128027681665, 0.64482891195693959, 0.80768935024990385, 1.0) -(0.65098039215686276, 0.64052287581699341, 0.80522875816993467, 1.0) -(0.64728950403690888, 0.63621683967704723, 0.80276816608996537, 1.0) -(0.64359861591695511, 0.63191080353710105, 0.80030757400999619, 1.0) -(0.63990772779700122, 0.62760476739715498, 0.7978469819300269, 1.0) -(0.63621683967704734, 0.62329873125720869, 0.79538638985005772, 1.0) -(0.63252595155709346, 0.61899269511726263, 0.79292579777008843, 1.0) -(0.62883506343713957, 0.61468665897731634, 0.79046520569011913, 1.0) -(0.62514417531718569, 0.61038062283737027, 0.78800461361014995, 1.0) -(0.62145328719723181, 0.60607458669742398, 0.78554402153018066, 1.0) -(0.61776239907727803, 0.60213763936947329, 0.78345251826220685, 1.0) -(0.61407151095732415, 0.59856978085351786, 0.78173010380622832, 1.0) -(0.61038062283737027, 0.59500192233756244, 0.78000768935024989, 1.0) -(0.60668973471741638, 0.59143406382160701, 0.77828527489427146, 1.0) -(0.60299884659746261, 0.5878662053056517, 0.77656286043829303, 1.0) -(0.59930795847750862, 0.58429834678969628, 0.7748404459823145, 1.0) -(0.59561707035755485, 0.58073048827374085, 0.77311803152633596, 1.0) -(0.59192618223760096, 0.57716262975778543, 0.77139561707035753, 1.0) -(0.58823529411764708, 0.57359477124183, 0.7696732026143791, 1.0) -(0.58454440599769319, 0.57002691272587458, 0.76795078815840057, 1.0) -(0.58085351787773931, 0.56645905420991927, 0.76622837370242214, 1.0) -(0.57716262975778543, 0.56289119569396384, 0.7645059592464436, 1.0) -(0.57347174163783166, 0.55932333717800842, 0.76278354479046517, 1.0) -(0.56978085351787777, 0.55575547866205299, 0.76106113033448675, 1.0) -(0.56608996539792389, 0.55218762014609757, 0.75933871587850821, 1.0) -(0.56239907727797001, 0.54861976163014226, 0.75761630142252978, 1.0) -(0.55870818915801612, 0.54505190311418683, 0.75589388696655124, 1.0) -(0.55501730103806224, 0.54148404459823141, 0.75417147251057282, 1.0) -(0.55132641291810847, 0.53791618608227598, 0.75244905805459439, 1.0) -(0.54763552479815458, 0.53434832756632056, 0.75072664359861585, 1.0) -(0.54394463667820081, 0.53078046905036536, 0.74900422914263742, 1.0) -(0.54025374855824682, 0.52721261053440982, 0.747281814686659, 1.0) -(0.53656286043829293, 0.5236447520184544, 0.74555940023068046, 1.0) -(0.53287197231833905, 0.52007689350249897, 0.74383698577470203, 1.0) -(0.52918108419838528, 0.51650903498654355, 0.74211457131872349, 1.0) -(0.52549019607843139, 0.51294117647058823, 0.74039215686274507, 1.0) -(0.52179930795847751, 0.50937331795463281, 0.73866974240676664, 1.0) -(0.51810841983852363, 0.50580545943867739, 0.7369473279507881, 1.0) -(0.51441753171856974, 0.50223760092272196, 0.73522491349480967, 1.0) -(0.51072664359861586, 0.49866974240676659, 0.73350249903883114, 1.0) -(0.50703575547866209, 0.49510188389081122, 0.73178008458285271, 1.0) -(0.5033448673587082, 0.4915340253748558, 0.73005767012687428, 1.0) -(0.50026912725874662, 0.48681276432141479, 0.72764321414840438, 1.0) -(0.49756247597078046, 0.48139946174548248, 0.72481353325643982, 1.0) -(0.4948558246828143, 0.47598615916955017, 0.72198385236447515, 1.0) -(0.49214917339484815, 0.47057285659361781, 0.71915417147251048, 1.0) -(0.48944252210688205, 0.46515955401768566, 0.71632449058054604, 1.0) -(0.48673587081891578, 0.45974625144175313, 0.71349480968858126, 1.0) -(0.48402921953094963, 0.45433294886582082, 0.7106651287966167, 1.0) -(0.48132256824298347, 0.44891964628988845, 0.70783544790465203, 1.0) -(0.47861591695501732, 0.44350634371395614, 0.70500576701268736, 1.0) -(0.47590926566705116, 0.43809304113802383, 0.7021760861207228, 1.0) -(0.47320261437908495, 0.43267973856209146, 0.69934640522875813, 1.0) -(0.4704959630911188, 0.42726643598615915, 0.69651672433679346, 1.0) -(0.46778931180315264, 0.42185313341022679, 0.6936870434448289, 1.0) -(0.46508266051518649, 0.41643983083429448, 0.69085736255286423, 1.0) -(0.46237600922722033, 0.41102652825836217, 0.68802768166089967, 1.0) -(0.45966935793925412, 0.4056132256824298, 0.685198000768935, 1.0) -(0.45696270665128796, 0.40019992310649749, 0.68236831987697033, 1.0) -(0.45425605536332181, 0.39478662053056512, 0.67953863898500577, 1.0) -(0.45154940407535565, 0.38937331795463281, 0.6767089580930411, 1.0) -(0.4488427527873895, 0.3839600153787005, 0.67387927720107643, 1.0) -(0.4461361014994234, 0.3785467128027683, 0.67104959630911187, 1.0) -(0.44342945021145713, 0.37313341022683583, 0.6682199154171472, 1.0) -(0.44072279892349098, 0.36772010765090346, 0.66539023452518253, 1.0) -(0.43801614763552482, 0.36230680507497115, 0.66256055363321797, 1.0) -(0.43530949634755867, 0.35689350249903884, 0.6597308727412533, 1.0) -(0.43260284505959246, 0.35148019992310647, 0.65690119184928863, 1.0) -(0.4298961937716263, 0.34606689734717411, 0.65407151095732408, 1.0) -(0.42718954248366015, 0.3406535947712418, 0.65124183006535941, 1.0) -(0.42448289119569399, 0.33524029219530949, 0.64841214917339474, 1.0) -(0.42177623990772783, 0.32982698961937718, 0.64558246828143018, 1.0) -(0.41906958861976162, 0.32441368704344481, 0.64275278738946551, 1.0) -(0.41636293733179547, 0.31900038446751244, 0.63992310649750095, 1.0) -(0.41365628604382931, 0.31377162629757782, 0.63737024221453287, 1.0) -(0.41094963475586316, 0.30860438292964243, 0.63490965013456357, 1.0) -(0.408242983467897, 0.30343713956170704, 0.63244905805459439, 1.0) -(0.40553633217993079, 0.29826989619377159, 0.6299884659746251, 1.0) -(0.40282968089196475, 0.29310265282583636, 0.62752787389465592, 1.0) -(0.40012302960399848, 0.2879354094579008, 0.62506728181468663, 1.0) -(0.39741637831603233, 0.28276816608996536, 0.62260668973471733, 1.0) -(0.39470972702806617, 0.27760092272202996, 0.62014609765474815, 1.0) -(0.39200307574009996, 0.27243367935409457, 0.61768550557477886, 1.0) -(0.3892964244521338, 0.26726643598615918, 0.61522491349480968, 1.0) -(0.38658977316416765, 0.26209919261822373, 0.61276432141484038, 1.0) -(0.38388312187620149, 0.25693194925028834, 0.6103037293348712, 1.0) -(0.38117647058823528, 0.25176470588235295, 0.60784313725490191, 1.0) -(0.37846981930026913, 0.24659746251441753, 0.60538254517493273, 1.0) -(0.37576316801230297, 0.24143021914648211, 0.60292195309496344, 1.0) -(0.37305651672433682, 0.23626297577854671, 0.60046136101499425, 1.0) -(0.37034986543637061, 0.23109573241061129, 0.59800076893502496, 1.0) -(0.36764321414840445, 0.22592848904267587, 0.59554017685505567, 1.0) -(0.3649365628604383, 0.22076124567474048, 0.59307958477508649, 1.0) -(0.36222991157247214, 0.21559400230680509, 0.5906189926951172, 1.0) -(0.35952326028450604, 0.21042675893886981, 0.58815840061514812, 1.0) -(0.35681660899653977, 0.20525951557093425, 0.58569780853517872, 1.0) -(0.35410995770857362, 0.20009227220299886, 0.58323721645520954, 1.0) -(0.35140330642060746, 0.19492502883506344, 0.58077662437524025, 1.0) -(0.34869665513264131, 0.18975778546712804, 0.57831603229527107, 1.0) -(0.34599000384467515, 0.18459054209919262, 0.57585544021530177, 1.0) -(0.34328335255670894, 0.1794232987312572, 0.57339484813533259, 1.0) -(0.34057670126874279, 0.17425605536332181, 0.5709342560553633, 1.0) -(0.33787004998077663, 0.16908881199538639, 0.56847366397539412, 1.0) -(0.33516339869281042, 0.163921568627451, 0.56601307189542482, 1.0) -(0.33245674740484427, 0.15875432525951558, 0.56355247981545564, 1.0) -(0.32975009611687811, 0.15358708189158016, 0.56109188773548635, 1.0) -(0.32715109573241064, 0.14874279123414072, 0.55884659746251442, 1.0) -(0.32456747404844288, 0.1439446366782007, 0.55663206459054215, 1.0) -(0.32198385236447519, 0.13914648212226069, 0.55441753171856978, 1.0) -(0.31940023068050749, 0.13434832756632065, 0.55220299884659751, 1.0) -(0.31681660899653985, 0.12955017301038077, 0.54998846597462525, 1.0) -(0.3142329873125721, 0.1247520184544406, 0.54777393310265288, 1.0) -(0.3116493656286044, 0.11995386389850059, 0.5455594002306805, 1.0) -(0.30906574394463665, 0.11515570934256056, 0.54334486735870824, 1.0) -(0.30648212226066895, 0.11035755478662054, 0.54113033448673586, 1.0) -(0.30389850057670126, 0.10555940023068051, 0.5389158016147636, 1.0) -(0.30131487889273356, 0.10076124567474048, 0.53670126874279123, 1.0) -(0.29873125720876587, 0.09596309111880047, 0.53448673587081896, 1.0) -(0.29614763552479817, 0.091164936562860441, 0.53227220299884659, 1.0) -(0.29356401384083047, 0.086366782006920426, 0.53005767012687433, 1.0) -(0.29098039215686278, 0.081568627450980397, 0.52784313725490195, 1.0) -(0.28839677047289503, 0.076770472895040368, 0.52562860438292969, 1.0) -(0.28581314878892733, 0.071972318339100352, 0.52341407151095731, 1.0) -(0.28322952710495963, 0.067174163783160323, 0.52119953863898494, 1.0) -(0.28064590542099194, 0.062376009227220308, 0.51898500576701267, 1.0) -(0.27806228373702424, 0.057577854671280279, 0.51677047289504041, 1.0) -(0.2754786620530566, 0.052779700115340389, 0.51455594002306815, 1.0) -(0.27289504036908885, 0.047981545559400235, 0.51234140715109566, 1.0) -(0.2703114186851211, 0.043183391003460206, 0.5101268742791234, 1.0) -(0.2677277970011534, 0.038385236447520191, 0.50791234140715114, 1.0) -(0.2651441753171857, 0.033587081891580162, 0.50569780853517876, 1.0) -(0.26256055363321801, 0.028788927335640146, 0.50348327566320639, 1.0) -(0.25997693194925031, 0.023990772779700104, 0.50126874279123412, 1.0) -(0.25739331026528256, 0.019192618223760088, 0.4990542099192618, 1.0) -(0.25480968858131492, 0.014394463667820073, 0.49683967704728949, 1.0) -(0.25222606689734717, 0.0095963091118800581, 0.49462514417531717, 1.0) -(0.24964244521337947, 0.0047981545559400152, 0.49241061130334485, 1.0) -(0.24705882352941178, 0.0, 0.49019607843137253, 1.0) diff --git a/extern/tfn/colormaps/sequential/RdPu.cpp b/extern/tfn/colormaps/sequential/RdPu.cpp deleted file mode 100644 index 78ac6b6..0000000 --- a/extern/tfn/colormaps/sequential/RdPu.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential_RdPu; -} -const std::vector colormap::data_sequential_RdPu = /* NOLINT(cert-err58-cpp) */ -{ -{1.0f, 0.96862745098039216f, 0.95294117647058818f, 1.0f}, -{0.99975394079200308f, 0.96579777008842749f, 0.95023452518262197f, 1.0f}, -{0.99950788158400616f, 0.96296808919646293f, 0.94752787389465587f, 1.0f}, -{0.99926182237600925f, 0.96013840830449826f, 0.94482122260668966f, 1.0f}, -{0.99901576316801233f, 0.95730872741253359f, 0.94211457131872356f, 1.0f}, -{0.99876970396001541f, 0.95447904652056903f, 0.93940792003075735f, 1.0f}, -{0.99852364475201849f, 0.95164936562860436f, 0.93670126874279125f, 1.0f}, -{0.99827758554402157f, 0.9488196847366398f, 0.93399461745482504f, 1.0f}, -{0.99803152633602465f, 0.94599000384467513f, 0.93128796616685883f, 1.0f}, -{0.99778546712802774f, 0.94316032295271046f, 0.92858131487889273f, 1.0f}, -{0.99753940792003082f, 0.9403306420607459f, 0.92587466359092652f, 1.0f}, -{0.99729334871203379f, 0.93750096116878123f, 0.92316801230296042f, 1.0f}, -{0.99704728950403687f, 0.93467128027681656f, 0.92046136101499421f, 1.0f}, -{0.99680123029603995f, 0.931841599384852f, 0.917754709727028f, 1.0f}, -{0.99655517108804303f, 0.92901191849288733f, 0.9150480584390619f, 1.0f}, -{0.99630911188004612f, 0.92618223760092278f, 0.91234140715109568f, 1.0f}, -{0.9960630526720492f, 0.92335255670895811f, 0.90963475586312958f, 1.0f}, -{0.99581699346405228f, 0.92052287581699344f, 0.90692810457516337f, 1.0f}, -{0.99557093425605536f, 0.91769319492502888f, 0.90422145328719727f, 1.0f}, -{0.99532487504805844f, 0.91486351403306421f, 0.90151480199923106f, 1.0f}, -{0.99507881584006153f, 0.91203383314109954f, 0.89880815071126485f, 1.0f}, -{0.99483275663206461f, 0.90920415224913498f, 0.89610149942329875f, 1.0f}, -{0.99458669742406769f, 0.90637447135717031f, 0.89339484813533254f, 1.0f}, -{0.99434063821607077f, 0.90354479046520564f, 0.89068819684736644f, 1.0f}, -{0.99409457900807385f, 0.90071510957324108f, 0.88798154555940023f, 1.0f}, -{0.99384851980007693f, 0.89788542868127641f, 0.88527489427143413f, 1.0f}, -{0.99360246059208002f, 0.89505574778931174f, 0.88256824298346792f, 1.0f}, -{0.9933564013840831f, 0.89222606689734718f, 0.87986159169550171f, 1.0f}, -{0.99311034217608618f, 0.88939638600538251f, 0.87715494040753561f, 1.0f}, -{0.99286428296808926f, 0.88656670511341795f, 0.8744482891195694f, 1.0f}, -{0.99261822376009234f, 0.88373702422145328f, 0.8717416378316033f, 1.0f}, -{0.99237216455209543f, 0.88090734332948861f, 0.86903498654363709f, 1.0f}, -{0.99214148404459823f, 0.87801614763552482f, 0.86622068435217225f, 1.0f}, -{0.99201845444059977f, 0.87469434832756632f, 0.86265282583621694f, 1.0f}, -{0.99189542483660131f, 0.87137254901960781f, 0.85908496732026152f, 1.0f}, -{0.99177239523260285f, 0.86805074971164931f, 0.85551710880430609f, 1.0f}, -{0.9916493656286044f, 0.86472895040369091f, 0.85194925028835067f, 1.0f}, -{0.99152633602460594f, 0.8614071510957324f, 0.84838139177239524f, 1.0f}, -{0.99140330642060748f, 0.8580853517877739f, 0.84481353325643982f, 1.0f}, -{0.99128027681660902f, 0.8547635524798155f, 0.84124567474048439f, 1.0f}, -{0.99115724721261056f, 0.851441753171857f, 0.83767781622452908f, 1.0f}, -{0.9910342176086121f, 0.84811995386389849f, 0.83410995770857366f, 1.0f}, -{0.99091118800461364f, 0.84479815455593998f, 0.83054209919261823f, 1.0f}, -{0.99078815840061518f, 0.84147635524798159f, 0.82697424067666281f, 1.0f}, -{0.99066512879661672f, 0.83815455594002308f, 0.82340638216070738f, 1.0f}, -{0.99054209919261826f, 0.83483275663206458f, 0.81983852364475207f, 1.0f}, -{0.9904190695886198f, 0.83151095732410607f, 0.81627066512879665f, 1.0f}, -{0.99029603998462135f, 0.82818915801614768f, 0.81270280661284122f, 1.0f}, -{0.99017301038062289f, 0.82486735870818917f, 0.8091349480968858f, 1.0f}, -{0.99004998077662443f, 0.82154555940023077f, 0.80556708958093048f, 1.0f}, -{0.98992695117262597f, 0.81822376009227227f, 0.80199923106497506f, 1.0f}, -{0.98980392156862751f, 0.81490196078431376f, 0.79843137254901964f, 1.0f}, -{0.98968089196462905f, 0.81158016147635526f, 0.79486351403306421f, 1.0f}, -{0.98955786236063059f, 0.80825836216839686f, 0.79129565551710879f, 1.0f}, -{0.98943483275663213f, 0.80493656286043835f, 0.78772779700115336f, 1.0f}, -{0.98931180315263367f, 0.80161476355247985f, 0.78415993848519805f, 1.0f}, -{0.98918877354863521f, 0.79829296424452134f, 0.78059207996924262f, 1.0f}, -{0.98906574394463675f, 0.79497116493656295f, 0.7770242214532872f, 1.0f}, -{0.9889427143406383f, 0.79164936562860444f, 0.77345636293733178f, 1.0f}, -{0.98881968473663984f, 0.78832756632064593f, 0.76988850442137635f, 1.0f}, -{0.98869665513264138f, 0.78500576701268743f, 0.76632064590542104f, 1.0f}, -{0.98857362552864292f, 0.78168396770472903f, 0.76275278738946561f, 1.0f}, -{0.98845059592464446f, 0.77836216839677053f, 0.75918492887351019f, 1.0f}, -{0.988327566320646f, 0.77504036908881202f, 0.75561707035755477f, 1.0f}, -{0.98817377931564787f, 0.77138023836985781f, 0.75260284505959241f, 1.0f}, -{0.98792772010765095f, 0.76670511341791625f, 0.75124951941560936f, 1.0f}, -{0.98768166089965403f, 0.76202998846597469f, 0.74989619377162631f, 1.0f}, -{0.98743560169165712f, 0.75735486351403314f, 0.74854286812764326f, 1.0f}, -{0.9871895424836602f, 0.75267973856209158f, 0.7471895424836601f, 1.0f}, -{0.98694348327566328f, 0.74800461361014992f, 0.74583621683967705f, 1.0f}, -{0.98669742406766636f, 0.74332948865820836f, 0.744482891195694f, 1.0f}, -{0.98645136485966933f, 0.7386543637062668f, 0.74312956555171084f, 1.0f}, -{0.98620530565167241f, 0.73397923875432525f, 0.74177623990772779f, 1.0f}, -{0.9859592464436755f, 0.72930411380238369f, 0.74042291426374474f, 1.0f}, -{0.98571318723567858f, 0.72462898885044225f, 0.73906958861976169f, 1.0f}, -{0.98546712802768166f, 0.71995386389850058f, 0.73771626297577853f, 1.0f}, -{0.98522106881968474f, 0.71527873894655902f, 0.73636293733179548f, 1.0f}, -{0.98497500961168782f, 0.71060361399461747f, 0.73500961168781243f, 1.0f}, -{0.98472895040369091f, 0.70592848904267591f, 0.73365628604382926f, 1.0f}, -{0.98448289119569399f, 0.70125336409073435f, 0.73230296039984621f, 1.0f}, -{0.98423683198769707f, 0.6965782391387928f, 0.73094963475586316f, 1.0f}, -{0.98399077277970015f, 0.69190311418685124f, 0.72959630911188f, 1.0f}, -{0.98374471357170323f, 0.6872279892349098f, 0.72824298346789695f, 1.0f}, -{0.9834986543637062f, 0.68255286428296813f, 0.7268896578239139f, 1.0f}, -{0.98325259515570929f, 0.67787773933102657f, 0.72553633217993085f, 1.0f}, -{0.98300653594771237f, 0.67320261437908502f, 0.72418300653594769f, 1.0f}, -{0.98276047673971545f, 0.66852748942714346f, 0.72282968089196464f, 1.0f}, -{0.98251441753171853f, 0.66385236447520191f, 0.72147635524798159f, 1.0f}, -{0.98226835832372161f, 0.65917723952326035f, 0.72012302960399843f, 1.0f}, -{0.9820222991157247f, 0.65450211457131879f, 0.71876970396001538f, 1.0f}, -{0.98177623990772778f, 0.64982698961937724f, 0.71741637831603233f, 1.0f}, -{0.98153018069973086f, 0.64515186466743568f, 0.71606305267204928f, 1.0f}, -{0.98128412149173394f, 0.64047673971549401f, 0.71470972702806612f, 1.0f}, -{0.98103806228373702f, 0.63580161476355246f, 0.71335640138408307f, 1.0f}, -{0.9807920030757401f, 0.6311264898116109f, 0.71200307574010002f, 1.0f}, -{0.98054594386774319f, 0.62645136485966935f, 0.71064975009611686f, 1.0f}, -{0.98025374855824676f, 0.62099192618223764f, 0.70888119953863904f, 1.0f}, -{0.97988465974625139f, 0.61422529796232217f, 0.70642060745866975f, 1.0f}, -{0.97951557093425601f, 0.60745866974240692f, 0.70396001537870057f, 1.0f}, -{0.97914648212226063f, 0.60069204152249134f, 0.70149942329873127f, 1.0f}, -{0.97877739331026525f, 0.59392541330257598f, 0.69903883121876209f, 1.0f}, -{0.97840830449826988f, 0.58715878508266051f, 0.6965782391387928f, 1.0f}, -{0.9780392156862745f, 0.58039215686274515f, 0.69411764705882351f, 1.0f}, -{0.97767012687427912f, 0.57362552864282967f, 0.69165705497885432f, 1.0f}, -{0.97730103806228374f, 0.56685890042291431f, 0.68919646289888503f, 1.0f}, -{0.97693194925028837f, 0.56009227220299884f, 0.68673587081891585f, 1.0f}, -{0.97656286043829299f, 0.55332564398308348f, 0.68427527873894656f, 1.0f}, -{0.9761937716262975f, 0.54655901576316801f, 0.68181468665897738f, 1.0f}, -{0.97582468281430212f, 0.53979238754325265f, 0.67935409457900808f, 1.0f}, -{0.97545559400230675f, 0.53302575932333718f, 0.67689350249903879f, 1.0f}, -{0.97508650519031137f, 0.52625913110342171f, 0.67443291041906961f, 1.0f}, -{0.97471741637831599f, 0.51949250288350635f, 0.67197231833910032f, 1.0f}, -{0.97434832756632062f, 0.51272587466359099f, 0.66951172625913113f, 1.0f}, -{0.97397923875432524f, 0.50595924644367551f, 0.66705113417916184f, 1.0f}, -{0.97361014994232986f, 0.49919261822376021f, 0.66459054209919266f, 1.0f}, -{0.97324106113033448f, 0.49242599000384468f, 0.66212995001922337f, 1.0f}, -{0.97287197231833911f, 0.48565936178392927f, 0.65966935793925408f, 1.0f}, -{0.97250288350634373f, 0.47889273356401385f, 0.65720876585928489f, 1.0f}, -{0.97213379469434835f, 0.47212610534409843f, 0.6547481737793156f, 1.0f}, -{0.97176470588235297f, 0.46535947712418302f, 0.65228758169934642f, 1.0f}, -{0.9713956170703576f, 0.4585928489042676f, 0.64982698961937713f, 1.0f}, -{0.97102652825836211f, 0.45182622068435219f, 0.64736639753940795f, 1.0f}, -{0.97065743944636673f, 0.44505959246443683f, 0.64490580545943876f, 1.0f}, -{0.97028835063437135f, 0.43829296424452135f, 0.64244521337946947f, 1.0f}, -{0.96991926182237598f, 0.43152633602460594f, 0.63998462129950018f, 1.0f}, -{0.9695501730103806f, 0.42475970780469052f, 0.637524029219531f, 1.0f}, -{0.96918108419838522f, 0.41799307958477511f, 0.6350634371395617f, 1.0f}, -{0.96881199538638985f, 0.41122645136485969f, 0.63260284505959241f, 1.0f}, -{0.96702806612841219f, 0.40464436755094196f, 0.63075740099961553f, 1.0f}, -{0.96382929642445214f, 0.39824682814302192f, 0.62952710495963093f, 1.0f}, -{0.9606305267204921f, 0.39184928873510189f, 0.62829680891964623f, 1.0f}, -{0.95743175701653216f, 0.38545174932718185f, 0.62706651287966164f, 1.0f}, -{0.95423298731257222f, 0.37905420991926198f, 0.62583621683967705f, 1.0f}, -{0.95103421760861206f, 0.37265667051134177f, 0.62460592079969246f, 1.0f}, -{0.94783544790465202f, 0.36625913110342179f, 0.62337562475970776f, 1.0f}, -{0.94463667820069208f, 0.35986159169550175f, 0.62214532871972317f, 1.0f}, -{0.94143790849673203f, 0.35346405228758171f, 0.62091503267973858f, 1.0f}, -{0.93823913879277199f, 0.34706651287966167f, 0.61968473663975387f, 1.0f}, -{0.93504036908881205f, 0.34066897347174163f, 0.61845444059976928f, 1.0f}, -{0.931841599384852f, 0.33427143406382159f, 0.61722414455978469f, 1.0f}, -{0.92864282968089196f, 0.32787389465590155f, 0.6159938485198001f, 1.0f}, -{0.92544405997693202f, 0.32147635524798157f, 0.6147635524798154f, 1.0f}, -{0.92224529027297197f, 0.31507881584006153f, 0.61353325643983081f, 1.0f}, -{0.91904652056901193f, 0.30868127643214149f, 0.61230296039984622f, 1.0f}, -{0.91584775086505188f, 0.30228373702422145f, 0.61107266435986163f, 1.0f}, -{0.91264898116109194f, 0.29588619761630142f, 0.60984236831987693f, 1.0f}, -{0.9094502114571319f, 0.28948865820838138f, 0.60861207227989234f, 1.0f}, -{0.90625144175317185f, 0.28309111880046134f, 0.60738177623990774f, 1.0f}, -{0.90305267204921191f, 0.27669357939254147f, 0.60615148019992315f, 1.0f}, -{0.89985390234525187f, 0.27029603998462126f, 0.60492118415993845f, 1.0f}, -{0.89665513264129182f, 0.26389850057670128f, 0.60369088811995386f, 1.0f}, -{0.89345636293733177f, 0.25750096116878118f, 0.60246059207996927f, 1.0f}, -{0.89025759323337184f, 0.2511034217608612f, 0.60123029603998457f, 1.0f}, -{0.88705882352941179f, 0.24470588235294116f, 0.59999999999999998f, 1.0f}, -{0.88386005382545174f, 0.23830834294502112f, 0.59876970396001539f, 1.0f}, -{0.88066128412149181f, 0.23191080353710111f, 0.5975394079200308f, 1.0f}, -{0.87746251441753176f, 0.22551326412918107f, 0.59630911188004609f, 1.0f}, -{0.87426374471357171f, 0.21911572472126103f, 0.5950788158400615f, 1.0f}, -{0.87106497500961166f, 0.21271818531334102f, 0.59384851980007691f, 1.0f}, -{0.86786620530565173f, 0.20632064590542099f, 0.59261822376009232f, 1.0f}, -{0.86305267204921188f, 0.20000000000000001f, 0.59023452518262209f, 1.0f}, -{0.85727028066128419f, 0.19372549019607843f, 0.58715878508266051f, 1.0f}, -{0.85148788927335639f, 0.18745098039215685f, 0.58408304498269892f, 1.0f}, -{0.8457054978854287f, 0.1811764705882353f, 0.58100730488273744f, 1.0f}, -{0.83992310649750113f, 0.17490196078431391f, 0.57793156478277596f, 1.0f}, -{0.83414071510957322f, 0.16862745098039214f, 0.57485582468281426f, 1.0f}, -{0.82835832372164553f, 0.16235294117647059f, 0.57178008458285279f, 1.0f}, -{0.82257593233371784f, 0.15607843137254901f, 0.5687043444828912f, 1.0f}, -{0.81679354094579015f, 0.14980392156862746f, 0.56562860438292961f, 1.0f}, -{0.81101114955786235f, 0.14352941176470588f, 0.56255286428296813f, 1.0f}, -{0.80522875816993467f, 0.13725490196078433f, 0.55947712418300655f, 1.0f}, -{0.79944636678200698f, 0.13098039215686275f, 0.55640138408304496f, 1.0f}, -{0.79366397539407929f, 0.12470588235294117f, 0.55332564398308348f, 1.0f}, -{0.78788158400615149f, 0.1184313725490196f, 0.55024990388312189f, 1.0f}, -{0.7820991926182238f, 0.11215686274509803f, 0.54717416378316031f, 1.0f}, -{0.77631680123029612f, 0.10588235294117647f, 0.54409842368319883f, 1.0f}, -{0.77053440984236832f, 0.099607843137254889f, 0.54102268358323724f, 1.0f}, -{0.76475201845444063f, 0.093333333333333324f, 0.53794694348327565f, 1.0f}, -{0.75896962706651294f, 0.087058823529411744f, 0.53487120338331406f, 1.0f}, -{0.75318723567858514f, 0.080784313725490178f, 0.53179546328335259f, 1.0f}, -{0.74740484429065757f, 0.074509803921568779f, 0.52871972318339111f, 1.0f}, -{0.74162245290272977f, 0.068235294117647033f, 0.52564398308342941f, 1.0f}, -{0.73584006151480197f, 0.061960784313725481f, 0.52256824298346793f, 1.0f}, -{0.73005767012687428f, 0.055686274509803901f, 0.51949250288350635f, 1.0f}, -{0.72427527873894659f, 0.049411764705882322f, 0.51641676278354476f, 1.0f}, -{0.71849288735101879f, 0.04313725490196077f, 0.51334102268358328f, 1.0f}, -{0.71271049596309111f, 0.03686274509803919f, 0.51026528258362169f, 1.0f}, -{0.70692810457516342f, 0.030588235294117638f, 0.50718954248366011f, 1.0f}, -{0.70114571318723573f, 0.024313725490196059f, 0.50411380238369863f, 1.0f}, -{0.69536332179930793f, 0.018039215686274479f, 0.50103806228373704f, 1.0f}, -{0.68958093041138024f, 0.011764705882352927f, 0.49796232218377551f, 1.0f}, -{0.68379853902345256f, 0.0054901960784313475f, 0.49488658208381392f, 1.0f}, -{0.67755478662053059f, 0.0039215686274509803f, 0.49347174163783164f, 1.0f}, -{0.67115724721261061f, 0.0039215686274509803f, 0.49261053440984237f, 1.0f}, -{0.66475970780469051f, 0.0039215686274509803f, 0.49174932718185316f, 1.0f}, -{0.65836216839677053f, 0.0039215686274509803f, 0.49088811995386394f, 1.0f}, -{0.65196462898885066f, 0.0039215686274509803f, 0.49002691272587473f, 1.0f}, -{0.64556708958093045f, 0.0039215686274509803f, 0.48916570549788546f, 1.0f}, -{0.63916955017301036f, 0.0039215686274509803f, 0.48830449826989619f, 1.0f}, -{0.63277201076509038f, 0.0039215686274509803f, 0.48744329104190698f, 1.0f}, -{0.62637447135717028f, 0.0039215686274509803f, 0.48658208381391777f, 1.0f}, -{0.6199769319492503f, 0.0039215686274509803f, 0.4857208765859285f, 1.0f}, -{0.61357939254133032f, 0.0039215686274509803f, 0.48485966935793928f, 1.0f}, -{0.60718185313341022f, 0.0039215686274509803f, 0.48399846212995001f, 1.0f}, -{0.60078431372549024f, 0.0039215686274509803f, 0.4831372549019608f, 1.0f}, -{0.59438677431757014f, 0.0039215686274509803f, 0.48227604767397159f, 1.0f}, -{0.58798923490965016f, 0.0039215686274509803f, 0.48141484044598232f, 1.0f}, -{0.58159169550173018f, 0.0039215686274509803f, 0.4805536332179931f, 1.0f}, -{0.57519415609381008f, 0.0039215686274509803f, 0.47969242599000383f, 1.0f}, -{0.5687966166858901f, 0.0039215686274509803f, 0.47883121876201462f, 1.0f}, -{0.56239907727797001f, 0.0039215686274509803f, 0.47797001153402541f, 1.0f}, -{0.55600153787005002f, 0.0039215686274509803f, 0.47710880430603614f, 1.0f}, -{0.54960399846213015f, 0.0039215686274509803f, 0.47624759707804692f, 1.0f}, -{0.54320645905420994f, 0.0039215686274509803f, 0.47538638985005766f, 1.0f}, -{0.53680891964628996f, 0.0039215686274509803f, 0.47452518262206844f, 1.0f}, -{0.53041138023836987f, 0.0039215686274509803f, 0.47366397539407923f, 1.0f}, -{0.52401384083044988f, 0.0039215686274509803f, 0.47280276816608996f, 1.0f}, -{0.51761630142252979f, 0.0039215686274509803f, 0.47194156093810075f, 1.0f}, -{0.51121876201460981f, 0.0039215686274509803f, 0.47108035371011148f, 1.0f}, -{0.50482122260668971f, 0.0039215686274509803f, 0.47021914648212226f, 1.0f}, -{0.49842368319876973f, 0.0039215686274509803f, 0.46935793925413305f, 1.0f}, -{0.49202614379084969f, 0.0039215686274509803f, 0.46849673202614378f, 1.0f}, -{0.48562860438292965f, 0.0039215686274509803f, 0.46763552479815457f, 1.0f}, -{0.47923106497500967f, 0.0039215686274509803f, 0.46677431757016535f, 1.0f}, -{0.47315647827758556f, 0.003813917723952326f, 0.46526720492118417f, 1.0f}, -{0.4671280276816609f, 0.0036908881199538639f, 0.46366782006920415f, 1.0f}, -{0.46109957708573629f, 0.0035678585159554018f, 0.46206843521722413f, 1.0f}, -{0.45507112648981163f, 0.0034448289119569397f, 0.46046905036524416f, 1.0f}, -{0.44904267589388713f, 0.003321799307958481f, 0.45886966551326419f, 1.0f}, -{0.44301422529796231f, 0.003198769703960015f, 0.45727028066128411f, 1.0f}, -{0.4369857747020377f, 0.0030757400999615533f, 0.45567089580930414f, 1.0f}, -{0.43095732410611304f, 0.0029527104959630908f, 0.45407151095732412f, 1.0f}, -{0.42492887351018838f, 0.0028296808919646291f, 0.4524721261053441f, 1.0f}, -{0.41890042291426377f, 0.0027066512879661666f, 0.45087274125336407f, 1.0f}, -{0.41287197231833911f, 0.0025836216839677049f, 0.44927335640138411f, 1.0f}, -{0.40684352172241445f, 0.0024605920799692423f, 0.44767397154940408f, 1.0f}, -{0.40081507112648984f, 0.0023375624759707806f, 0.44607458669742406f, 1.0f}, -{0.39478662053056518f, 0.0022145328719723181f, 0.44447520184544409f, 1.0f}, -{0.38875816993464052f, 0.0020915032679738564f, 0.44287581699346407f, 1.0f}, -{0.38272971933871591f, 0.0019684736639753939f, 0.44127643214148404f, 1.0f}, -{0.37670126874279125f, 0.0018454440599769317f, 0.43967704728950407f, 1.0f}, -{0.37067281814686659f, 0.0017224144559784696f, 0.43807766243752405f, 1.0f}, -{0.36464436755094193f, 0.0015993848519800075f, 0.43647827758554403f, 1.0f}, -{0.35861591695501727f, 0.0014763552479815454f, 0.43487889273356406f, 1.0f}, -{0.35258746635909283f, 0.0013533256439830867f, 0.43327950788158409f, 1.0f}, -{0.346559015763168f, 0.0012302960399846212f, 0.43168012302960401f, 1.0f}, -{0.34053056516724334f, 0.001107266435986159f, 0.43008073817762399f, 1.0f}, -{0.33450211457131873f, 0.00098423683198769693f, 0.42848135332564402f, 1.0f}, -{0.32847366397539407f, 0.00086120722798923481f, 0.426881968473664f, 1.0f}, -{0.32244521337946941f, 0.0007381776239907727f, 0.42528258362168397f, 1.0f}, -{0.3164167627835448f, 0.00061514801999231058f, 0.42368319876970395f, 1.0f}, -{0.31038831218762014f, 0.00049211841599384847f, 0.42208381391772398f, 1.0f}, -{0.30435986159169548f, 0.00036908881199538635f, 0.42048442906574396f, 1.0f}, -{0.29833141099577087f, 0.00024605920799692423f, 0.41888504421376394f, 1.0f}, -{0.29230296039984616f, 0.00012302960399846212f, 0.41728565936178397f, 1.0f}, -{0.28627450980392155f, 0.0f, 0.41568627450980394f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential/RdPu.txt b/extern/tfn/colormaps/sequential/RdPu.txt deleted file mode 100644 index 4d3cf99..0000000 --- a/extern/tfn/colormaps/sequential/RdPu.txt +++ /dev/null @@ -1,256 +0,0 @@ -(1.0, 0.96862745098039216, 0.95294117647058818, 1.0) -(0.99975394079200308, 0.96579777008842749, 0.95023452518262197, 1.0) -(0.99950788158400616, 0.96296808919646293, 0.94752787389465587, 1.0) -(0.99926182237600925, 0.96013840830449826, 0.94482122260668966, 1.0) -(0.99901576316801233, 0.95730872741253359, 0.94211457131872356, 1.0) -(0.99876970396001541, 0.95447904652056903, 0.93940792003075735, 1.0) -(0.99852364475201849, 0.95164936562860436, 0.93670126874279125, 1.0) -(0.99827758554402157, 0.9488196847366398, 0.93399461745482504, 1.0) -(0.99803152633602465, 0.94599000384467513, 0.93128796616685883, 1.0) -(0.99778546712802774, 0.94316032295271046, 0.92858131487889273, 1.0) -(0.99753940792003082, 0.9403306420607459, 0.92587466359092652, 1.0) -(0.99729334871203379, 0.93750096116878123, 0.92316801230296042, 1.0) -(0.99704728950403687, 0.93467128027681656, 0.92046136101499421, 1.0) -(0.99680123029603995, 0.931841599384852, 0.917754709727028, 1.0) -(0.99655517108804303, 0.92901191849288733, 0.9150480584390619, 1.0) -(0.99630911188004612, 0.92618223760092278, 0.91234140715109568, 1.0) -(0.9960630526720492, 0.92335255670895811, 0.90963475586312958, 1.0) -(0.99581699346405228, 0.92052287581699344, 0.90692810457516337, 1.0) -(0.99557093425605536, 0.91769319492502888, 0.90422145328719727, 1.0) -(0.99532487504805844, 0.91486351403306421, 0.90151480199923106, 1.0) -(0.99507881584006153, 0.91203383314109954, 0.89880815071126485, 1.0) -(0.99483275663206461, 0.90920415224913498, 0.89610149942329875, 1.0) -(0.99458669742406769, 0.90637447135717031, 0.89339484813533254, 1.0) -(0.99434063821607077, 0.90354479046520564, 0.89068819684736644, 1.0) -(0.99409457900807385, 0.90071510957324108, 0.88798154555940023, 1.0) -(0.99384851980007693, 0.89788542868127641, 0.88527489427143413, 1.0) -(0.99360246059208002, 0.89505574778931174, 0.88256824298346792, 1.0) -(0.9933564013840831, 0.89222606689734718, 0.87986159169550171, 1.0) -(0.99311034217608618, 0.88939638600538251, 0.87715494040753561, 1.0) -(0.99286428296808926, 0.88656670511341795, 0.8744482891195694, 1.0) -(0.99261822376009234, 0.88373702422145328, 0.8717416378316033, 1.0) -(0.99237216455209543, 0.88090734332948861, 0.86903498654363709, 1.0) -(0.99214148404459823, 0.87801614763552482, 0.86622068435217225, 1.0) -(0.99201845444059977, 0.87469434832756632, 0.86265282583621694, 1.0) -(0.99189542483660131, 0.87137254901960781, 0.85908496732026152, 1.0) -(0.99177239523260285, 0.86805074971164931, 0.85551710880430609, 1.0) -(0.9916493656286044, 0.86472895040369091, 0.85194925028835067, 1.0) -(0.99152633602460594, 0.8614071510957324, 0.84838139177239524, 1.0) -(0.99140330642060748, 0.8580853517877739, 0.84481353325643982, 1.0) -(0.99128027681660902, 0.8547635524798155, 0.84124567474048439, 1.0) -(0.99115724721261056, 0.851441753171857, 0.83767781622452908, 1.0) -(0.9910342176086121, 0.84811995386389849, 0.83410995770857366, 1.0) -(0.99091118800461364, 0.84479815455593998, 0.83054209919261823, 1.0) -(0.99078815840061518, 0.84147635524798159, 0.82697424067666281, 1.0) -(0.99066512879661672, 0.83815455594002308, 0.82340638216070738, 1.0) -(0.99054209919261826, 0.83483275663206458, 0.81983852364475207, 1.0) -(0.9904190695886198, 0.83151095732410607, 0.81627066512879665, 1.0) -(0.99029603998462135, 0.82818915801614768, 0.81270280661284122, 1.0) -(0.99017301038062289, 0.82486735870818917, 0.8091349480968858, 1.0) -(0.99004998077662443, 0.82154555940023077, 0.80556708958093048, 1.0) -(0.98992695117262597, 0.81822376009227227, 0.80199923106497506, 1.0) -(0.98980392156862751, 0.81490196078431376, 0.79843137254901964, 1.0) -(0.98968089196462905, 0.81158016147635526, 0.79486351403306421, 1.0) -(0.98955786236063059, 0.80825836216839686, 0.79129565551710879, 1.0) -(0.98943483275663213, 0.80493656286043835, 0.78772779700115336, 1.0) -(0.98931180315263367, 0.80161476355247985, 0.78415993848519805, 1.0) -(0.98918877354863521, 0.79829296424452134, 0.78059207996924262, 1.0) -(0.98906574394463675, 0.79497116493656295, 0.7770242214532872, 1.0) -(0.9889427143406383, 0.79164936562860444, 0.77345636293733178, 1.0) -(0.98881968473663984, 0.78832756632064593, 0.76988850442137635, 1.0) -(0.98869665513264138, 0.78500576701268743, 0.76632064590542104, 1.0) -(0.98857362552864292, 0.78168396770472903, 0.76275278738946561, 1.0) -(0.98845059592464446, 0.77836216839677053, 0.75918492887351019, 1.0) -(0.988327566320646, 0.77504036908881202, 0.75561707035755477, 1.0) -(0.98817377931564787, 0.77138023836985781, 0.75260284505959241, 1.0) -(0.98792772010765095, 0.76670511341791625, 0.75124951941560936, 1.0) -(0.98768166089965403, 0.76202998846597469, 0.74989619377162631, 1.0) -(0.98743560169165712, 0.75735486351403314, 0.74854286812764326, 1.0) -(0.9871895424836602, 0.75267973856209158, 0.7471895424836601, 1.0) -(0.98694348327566328, 0.74800461361014992, 0.74583621683967705, 1.0) -(0.98669742406766636, 0.74332948865820836, 0.744482891195694, 1.0) -(0.98645136485966933, 0.7386543637062668, 0.74312956555171084, 1.0) -(0.98620530565167241, 0.73397923875432525, 0.74177623990772779, 1.0) -(0.9859592464436755, 0.72930411380238369, 0.74042291426374474, 1.0) -(0.98571318723567858, 0.72462898885044225, 0.73906958861976169, 1.0) -(0.98546712802768166, 0.71995386389850058, 0.73771626297577853, 1.0) -(0.98522106881968474, 0.71527873894655902, 0.73636293733179548, 1.0) -(0.98497500961168782, 0.71060361399461747, 0.73500961168781243, 1.0) -(0.98472895040369091, 0.70592848904267591, 0.73365628604382926, 1.0) -(0.98448289119569399, 0.70125336409073435, 0.73230296039984621, 1.0) -(0.98423683198769707, 0.6965782391387928, 0.73094963475586316, 1.0) -(0.98399077277970015, 0.69190311418685124, 0.72959630911188, 1.0) -(0.98374471357170323, 0.6872279892349098, 0.72824298346789695, 1.0) -(0.9834986543637062, 0.68255286428296813, 0.7268896578239139, 1.0) -(0.98325259515570929, 0.67787773933102657, 0.72553633217993085, 1.0) -(0.98300653594771237, 0.67320261437908502, 0.72418300653594769, 1.0) -(0.98276047673971545, 0.66852748942714346, 0.72282968089196464, 1.0) -(0.98251441753171853, 0.66385236447520191, 0.72147635524798159, 1.0) -(0.98226835832372161, 0.65917723952326035, 0.72012302960399843, 1.0) -(0.9820222991157247, 0.65450211457131879, 0.71876970396001538, 1.0) -(0.98177623990772778, 0.64982698961937724, 0.71741637831603233, 1.0) -(0.98153018069973086, 0.64515186466743568, 0.71606305267204928, 1.0) -(0.98128412149173394, 0.64047673971549401, 0.71470972702806612, 1.0) -(0.98103806228373702, 0.63580161476355246, 0.71335640138408307, 1.0) -(0.9807920030757401, 0.6311264898116109, 0.71200307574010002, 1.0) -(0.98054594386774319, 0.62645136485966935, 0.71064975009611686, 1.0) -(0.98025374855824676, 0.62099192618223764, 0.70888119953863904, 1.0) -(0.97988465974625139, 0.61422529796232217, 0.70642060745866975, 1.0) -(0.97951557093425601, 0.60745866974240692, 0.70396001537870057, 1.0) -(0.97914648212226063, 0.60069204152249134, 0.70149942329873127, 1.0) -(0.97877739331026525, 0.59392541330257598, 0.69903883121876209, 1.0) -(0.97840830449826988, 0.58715878508266051, 0.6965782391387928, 1.0) -(0.9780392156862745, 0.58039215686274515, 0.69411764705882351, 1.0) -(0.97767012687427912, 0.57362552864282967, 0.69165705497885432, 1.0) -(0.97730103806228374, 0.56685890042291431, 0.68919646289888503, 1.0) -(0.97693194925028837, 0.56009227220299884, 0.68673587081891585, 1.0) -(0.97656286043829299, 0.55332564398308348, 0.68427527873894656, 1.0) -(0.9761937716262975, 0.54655901576316801, 0.68181468665897738, 1.0) -(0.97582468281430212, 0.53979238754325265, 0.67935409457900808, 1.0) -(0.97545559400230675, 0.53302575932333718, 0.67689350249903879, 1.0) -(0.97508650519031137, 0.52625913110342171, 0.67443291041906961, 1.0) -(0.97471741637831599, 0.51949250288350635, 0.67197231833910032, 1.0) -(0.97434832756632062, 0.51272587466359099, 0.66951172625913113, 1.0) -(0.97397923875432524, 0.50595924644367551, 0.66705113417916184, 1.0) -(0.97361014994232986, 0.49919261822376021, 0.66459054209919266, 1.0) -(0.97324106113033448, 0.49242599000384468, 0.66212995001922337, 1.0) -(0.97287197231833911, 0.48565936178392927, 0.65966935793925408, 1.0) -(0.97250288350634373, 0.47889273356401385, 0.65720876585928489, 1.0) -(0.97213379469434835, 0.47212610534409843, 0.6547481737793156, 1.0) -(0.97176470588235297, 0.46535947712418302, 0.65228758169934642, 1.0) -(0.9713956170703576, 0.4585928489042676, 0.64982698961937713, 1.0) -(0.97102652825836211, 0.45182622068435219, 0.64736639753940795, 1.0) -(0.97065743944636673, 0.44505959246443683, 0.64490580545943876, 1.0) -(0.97028835063437135, 0.43829296424452135, 0.64244521337946947, 1.0) -(0.96991926182237598, 0.43152633602460594, 0.63998462129950018, 1.0) -(0.9695501730103806, 0.42475970780469052, 0.637524029219531, 1.0) -(0.96918108419838522, 0.41799307958477511, 0.6350634371395617, 1.0) -(0.96881199538638985, 0.41122645136485969, 0.63260284505959241, 1.0) -(0.96702806612841219, 0.40464436755094196, 0.63075740099961553, 1.0) -(0.96382929642445214, 0.39824682814302192, 0.62952710495963093, 1.0) -(0.9606305267204921, 0.39184928873510189, 0.62829680891964623, 1.0) -(0.95743175701653216, 0.38545174932718185, 0.62706651287966164, 1.0) -(0.95423298731257222, 0.37905420991926198, 0.62583621683967705, 1.0) -(0.95103421760861206, 0.37265667051134177, 0.62460592079969246, 1.0) -(0.94783544790465202, 0.36625913110342179, 0.62337562475970776, 1.0) -(0.94463667820069208, 0.35986159169550175, 0.62214532871972317, 1.0) -(0.94143790849673203, 0.35346405228758171, 0.62091503267973858, 1.0) -(0.93823913879277199, 0.34706651287966167, 0.61968473663975387, 1.0) -(0.93504036908881205, 0.34066897347174163, 0.61845444059976928, 1.0) -(0.931841599384852, 0.33427143406382159, 0.61722414455978469, 1.0) -(0.92864282968089196, 0.32787389465590155, 0.6159938485198001, 1.0) -(0.92544405997693202, 0.32147635524798157, 0.6147635524798154, 1.0) -(0.92224529027297197, 0.31507881584006153, 0.61353325643983081, 1.0) -(0.91904652056901193, 0.30868127643214149, 0.61230296039984622, 1.0) -(0.91584775086505188, 0.30228373702422145, 0.61107266435986163, 1.0) -(0.91264898116109194, 0.29588619761630142, 0.60984236831987693, 1.0) -(0.9094502114571319, 0.28948865820838138, 0.60861207227989234, 1.0) -(0.90625144175317185, 0.28309111880046134, 0.60738177623990774, 1.0) -(0.90305267204921191, 0.27669357939254147, 0.60615148019992315, 1.0) -(0.89985390234525187, 0.27029603998462126, 0.60492118415993845, 1.0) -(0.89665513264129182, 0.26389850057670128, 0.60369088811995386, 1.0) -(0.89345636293733177, 0.25750096116878118, 0.60246059207996927, 1.0) -(0.89025759323337184, 0.2511034217608612, 0.60123029603998457, 1.0) -(0.88705882352941179, 0.24470588235294116, 0.59999999999999998, 1.0) -(0.88386005382545174, 0.23830834294502112, 0.59876970396001539, 1.0) -(0.88066128412149181, 0.23191080353710111, 0.5975394079200308, 1.0) -(0.87746251441753176, 0.22551326412918107, 0.59630911188004609, 1.0) -(0.87426374471357171, 0.21911572472126103, 0.5950788158400615, 1.0) -(0.87106497500961166, 0.21271818531334102, 0.59384851980007691, 1.0) -(0.86786620530565173, 0.20632064590542099, 0.59261822376009232, 1.0) -(0.86305267204921188, 0.20000000000000001, 0.59023452518262209, 1.0) -(0.85727028066128419, 0.19372549019607843, 0.58715878508266051, 1.0) -(0.85148788927335639, 0.18745098039215685, 0.58408304498269892, 1.0) -(0.8457054978854287, 0.1811764705882353, 0.58100730488273744, 1.0) -(0.83992310649750113, 0.17490196078431391, 0.57793156478277596, 1.0) -(0.83414071510957322, 0.16862745098039214, 0.57485582468281426, 1.0) -(0.82835832372164553, 0.16235294117647059, 0.57178008458285279, 1.0) -(0.82257593233371784, 0.15607843137254901, 0.5687043444828912, 1.0) -(0.81679354094579015, 0.14980392156862746, 0.56562860438292961, 1.0) -(0.81101114955786235, 0.14352941176470588, 0.56255286428296813, 1.0) -(0.80522875816993467, 0.13725490196078433, 0.55947712418300655, 1.0) -(0.79944636678200698, 0.13098039215686275, 0.55640138408304496, 1.0) -(0.79366397539407929, 0.12470588235294117, 0.55332564398308348, 1.0) -(0.78788158400615149, 0.1184313725490196, 0.55024990388312189, 1.0) -(0.7820991926182238, 0.11215686274509803, 0.54717416378316031, 1.0) -(0.77631680123029612, 0.10588235294117647, 0.54409842368319883, 1.0) -(0.77053440984236832, 0.099607843137254889, 0.54102268358323724, 1.0) -(0.76475201845444063, 0.093333333333333324, 0.53794694348327565, 1.0) -(0.75896962706651294, 0.087058823529411744, 0.53487120338331406, 1.0) -(0.75318723567858514, 0.080784313725490178, 0.53179546328335259, 1.0) -(0.74740484429065757, 0.074509803921568779, 0.52871972318339111, 1.0) -(0.74162245290272977, 0.068235294117647033, 0.52564398308342941, 1.0) -(0.73584006151480197, 0.061960784313725481, 0.52256824298346793, 1.0) -(0.73005767012687428, 0.055686274509803901, 0.51949250288350635, 1.0) -(0.72427527873894659, 0.049411764705882322, 0.51641676278354476, 1.0) -(0.71849288735101879, 0.04313725490196077, 0.51334102268358328, 1.0) -(0.71271049596309111, 0.03686274509803919, 0.51026528258362169, 1.0) -(0.70692810457516342, 0.030588235294117638, 0.50718954248366011, 1.0) -(0.70114571318723573, 0.024313725490196059, 0.50411380238369863, 1.0) -(0.69536332179930793, 0.018039215686274479, 0.50103806228373704, 1.0) -(0.68958093041138024, 0.011764705882352927, 0.49796232218377551, 1.0) -(0.68379853902345256, 0.0054901960784313475, 0.49488658208381392, 1.0) -(0.67755478662053059, 0.0039215686274509803, 0.49347174163783164, 1.0) -(0.67115724721261061, 0.0039215686274509803, 0.49261053440984237, 1.0) -(0.66475970780469051, 0.0039215686274509803, 0.49174932718185316, 1.0) -(0.65836216839677053, 0.0039215686274509803, 0.49088811995386394, 1.0) -(0.65196462898885066, 0.0039215686274509803, 0.49002691272587473, 1.0) -(0.64556708958093045, 0.0039215686274509803, 0.48916570549788546, 1.0) -(0.63916955017301036, 0.0039215686274509803, 0.48830449826989619, 1.0) -(0.63277201076509038, 0.0039215686274509803, 0.48744329104190698, 1.0) -(0.62637447135717028, 0.0039215686274509803, 0.48658208381391777, 1.0) -(0.6199769319492503, 0.0039215686274509803, 0.4857208765859285, 1.0) -(0.61357939254133032, 0.0039215686274509803, 0.48485966935793928, 1.0) -(0.60718185313341022, 0.0039215686274509803, 0.48399846212995001, 1.0) -(0.60078431372549024, 0.0039215686274509803, 0.4831372549019608, 1.0) -(0.59438677431757014, 0.0039215686274509803, 0.48227604767397159, 1.0) -(0.58798923490965016, 0.0039215686274509803, 0.48141484044598232, 1.0) -(0.58159169550173018, 0.0039215686274509803, 0.4805536332179931, 1.0) -(0.57519415609381008, 0.0039215686274509803, 0.47969242599000383, 1.0) -(0.5687966166858901, 0.0039215686274509803, 0.47883121876201462, 1.0) -(0.56239907727797001, 0.0039215686274509803, 0.47797001153402541, 1.0) -(0.55600153787005002, 0.0039215686274509803, 0.47710880430603614, 1.0) -(0.54960399846213015, 0.0039215686274509803, 0.47624759707804692, 1.0) -(0.54320645905420994, 0.0039215686274509803, 0.47538638985005766, 1.0) -(0.53680891964628996, 0.0039215686274509803, 0.47452518262206844, 1.0) -(0.53041138023836987, 0.0039215686274509803, 0.47366397539407923, 1.0) -(0.52401384083044988, 0.0039215686274509803, 0.47280276816608996, 1.0) -(0.51761630142252979, 0.0039215686274509803, 0.47194156093810075, 1.0) -(0.51121876201460981, 0.0039215686274509803, 0.47108035371011148, 1.0) -(0.50482122260668971, 0.0039215686274509803, 0.47021914648212226, 1.0) -(0.49842368319876973, 0.0039215686274509803, 0.46935793925413305, 1.0) -(0.49202614379084969, 0.0039215686274509803, 0.46849673202614378, 1.0) -(0.48562860438292965, 0.0039215686274509803, 0.46763552479815457, 1.0) -(0.47923106497500967, 0.0039215686274509803, 0.46677431757016535, 1.0) -(0.47315647827758556, 0.003813917723952326, 0.46526720492118417, 1.0) -(0.4671280276816609, 0.0036908881199538639, 0.46366782006920415, 1.0) -(0.46109957708573629, 0.0035678585159554018, 0.46206843521722413, 1.0) -(0.45507112648981163, 0.0034448289119569397, 0.46046905036524416, 1.0) -(0.44904267589388713, 0.003321799307958481, 0.45886966551326419, 1.0) -(0.44301422529796231, 0.003198769703960015, 0.45727028066128411, 1.0) -(0.4369857747020377, 0.0030757400999615533, 0.45567089580930414, 1.0) -(0.43095732410611304, 0.0029527104959630908, 0.45407151095732412, 1.0) -(0.42492887351018838, 0.0028296808919646291, 0.4524721261053441, 1.0) -(0.41890042291426377, 0.0027066512879661666, 0.45087274125336407, 1.0) -(0.41287197231833911, 0.0025836216839677049, 0.44927335640138411, 1.0) -(0.40684352172241445, 0.0024605920799692423, 0.44767397154940408, 1.0) -(0.40081507112648984, 0.0023375624759707806, 0.44607458669742406, 1.0) -(0.39478662053056518, 0.0022145328719723181, 0.44447520184544409, 1.0) -(0.38875816993464052, 0.0020915032679738564, 0.44287581699346407, 1.0) -(0.38272971933871591, 0.0019684736639753939, 0.44127643214148404, 1.0) -(0.37670126874279125, 0.0018454440599769317, 0.43967704728950407, 1.0) -(0.37067281814686659, 0.0017224144559784696, 0.43807766243752405, 1.0) -(0.36464436755094193, 0.0015993848519800075, 0.43647827758554403, 1.0) -(0.35861591695501727, 0.0014763552479815454, 0.43487889273356406, 1.0) -(0.35258746635909283, 0.0013533256439830867, 0.43327950788158409, 1.0) -(0.346559015763168, 0.0012302960399846212, 0.43168012302960401, 1.0) -(0.34053056516724334, 0.001107266435986159, 0.43008073817762399, 1.0) -(0.33450211457131873, 0.00098423683198769693, 0.42848135332564402, 1.0) -(0.32847366397539407, 0.00086120722798923481, 0.426881968473664, 1.0) -(0.32244521337946941, 0.0007381776239907727, 0.42528258362168397, 1.0) -(0.3164167627835448, 0.00061514801999231058, 0.42368319876970395, 1.0) -(0.31038831218762014, 0.00049211841599384847, 0.42208381391772398, 1.0) -(0.30435986159169548, 0.00036908881199538635, 0.42048442906574396, 1.0) -(0.29833141099577087, 0.00024605920799692423, 0.41888504421376394, 1.0) -(0.29230296039984616, 0.00012302960399846212, 0.41728565936178397, 1.0) -(0.28627450980392155, 0.0, 0.41568627450980394, 1.0) diff --git a/extern/tfn/colormaps/sequential/Reds.cpp b/extern/tfn/colormaps/sequential/Reds.cpp deleted file mode 100644 index 37834f7..0000000 --- a/extern/tfn/colormaps/sequential/Reds.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential_Reds; -} -const std::vector colormap::data_sequential_Reds = /* NOLINT(cert-err58-cpp) */ -{ -{1.0f, 0.96078431372549022f, 0.94117647058823528f, 1.0f}, -{0.99987697039600154f, 0.95820069204152247f, 0.9374855824682814f, 1.0f}, -{0.99975394079200308f, 0.95561707035755483f, 0.93379469434832751f, 1.0f}, -{0.99963091118800462f, 0.95303344867358708f, 0.93010380622837374f, 1.0f}, -{0.99950788158400616f, 0.95044982698961944f, 0.92641291810841986f, 1.0f}, -{0.9993848519800077f, 0.94786620530565169f, 0.92272202998846597f, 1.0f}, -{0.99926182237600925f, 0.94528258362168394f, 0.91903114186851209f, 1.0f}, -{0.99913879277201079f, 0.9426989619377163f, 0.91534025374855821f, 1.0f}, -{0.99901576316801233f, 0.94011534025374854f, 0.91164936562860432f, 1.0f}, -{0.99889273356401387f, 0.9375317185697809f, 0.90795847750865044f, 1.0f}, -{0.99876970396001541f, 0.93494809688581315f, 0.90426758938869667f, 1.0f}, -{0.99864667435601695f, 0.93236447520184551f, 0.90057670126874279f, 1.0f}, -{0.99852364475201849f, 0.92978085351787776f, 0.8968858131487889f, 1.0f}, -{0.99840061514802003f, 0.92719723183391001f, 0.89319492502883502f, 1.0f}, -{0.99827758554402157f, 0.92461361014994237f, 0.88950403690888113f, 1.0f}, -{0.99815455594002311f, 0.92202998846597461f, 0.88581314878892736f, 1.0f}, -{0.99803152633602465f, 0.91944636678200697f, 0.88212226066897348f, 1.0f}, -{0.9979084967320262f, 0.91686274509803922f, 0.8784313725490196f, 1.0f}, -{0.99778546712802774f, 0.91427912341407147f, 0.87474048442906571f, 1.0f}, -{0.99766243752402928f, 0.91169550173010383f, 0.87104959630911183f, 1.0f}, -{0.99753940792003082f, 0.90911188004613608f, 0.86735870818915795f, 1.0f}, -{0.99741637831603236f, 0.90652825836216844f, 0.86366782006920406f, 1.0f}, -{0.99729334871203379f, 0.90394463667820069f, 0.85997693194925029f, 1.0f}, -{0.99717031910803533f, 0.90136101499423305f, 0.85628604382929641f, 1.0f}, -{0.99704728950403687f, 0.89877739331026529f, 0.85259515570934252f, 1.0f}, -{0.99692425990003841f, 0.89619377162629754f, 0.84890426758938864f, 1.0f}, -{0.99680123029603995f, 0.8936101499423299f, 0.84521337946943476f, 1.0f}, -{0.99667820069204149f, 0.89102652825836215f, 0.84152249134948098f, 1.0f}, -{0.99655517108804303f, 0.8884429065743944f, 0.8378316032295271f, 1.0f}, -{0.99643214148404458f, 0.88585928489042676f, 0.83414071510957322f, 1.0f}, -{0.99630911188004612f, 0.88327566320645901f, 0.83044982698961933f, 1.0f}, -{0.99618608227604766f, 0.88069204152249136f, 0.82675893886966545f, 1.0f}, -{0.99604767397154936f, 0.87786236063052669f, 0.82277585544021525f, 1.0f}, -{0.99580161476355245f, 0.8733102652825836f, 0.81674740484429065f, 1.0f}, -{0.99555555555555553f, 0.8687581699346405f, 0.81071895424836593f, 1.0f}, -{0.99530949634755861f, 0.8642060745866974f, 0.80469050365244132f, 1.0f}, -{0.99506343713956169f, 0.85965397923875431f, 0.79866205305651672f, 1.0f}, -{0.99481737793156477f, 0.85510188389081121f, 0.79263360246059211f, 1.0f}, -{0.99457131872356785f, 0.85054978854286811f, 0.7866051518646674f, 1.0f}, -{0.99432525951557094f, 0.84599769319492502f, 0.78057670126874279f, 1.0f}, -{0.99407920030757402f, 0.84144559784698192f, 0.77454825067281807f, 1.0f}, -{0.9938331410995771f, 0.83689350249903882f, 0.76851980007689347f, 1.0f}, -{0.99358708189158018f, 0.83234140715109572f, 0.76249134948096886f, 1.0f}, -{0.99334102268358326f, 0.82778931180315263f, 0.75646289888504414f, 1.0f}, -{0.99309496347558635f, 0.82323721645520953f, 0.75043444828911954f, 1.0f}, -{0.99284890426758943f, 0.81868512110726643f, 0.74440599769319493f, 1.0f}, -{0.99260284505959251f, 0.81413302575932334f, 0.73837754709727021f, 1.0f}, -{0.99235678585159559f, 0.80958093041138024f, 0.73234909650134561f, 1.0f}, -{0.99211072664359867f, 0.80502883506343714f, 0.726320645905421f, 1.0f}, -{0.99186466743560175f, 0.80047673971549405f, 0.7202921953094964f, 1.0f}, -{0.99161860822760484f, 0.79592464436755095f, 0.71426374471357168f, 1.0f}, -{0.99137254901960792f, 0.79137254901960785f, 0.70823529411764707f, 1.0f}, -{0.991126489811611f, 0.78682045367166475f, 0.70220684352172236f, 1.0f}, -{0.99088043060361408f, 0.78226835832372166f, 0.69617839292579775f, 1.0f}, -{0.99063437139561705f, 0.77771626297577856f, 0.69014994232987315f, 1.0f}, -{0.99038831218762013f, 0.77316416762783535f, 0.68412149173394843f, 1.0f}, -{0.99014225297962322f, 0.76861207227989237f, 0.67809304113802382f, 1.0f}, -{0.9898961937716263f, 0.76405997693194927f, 0.67206459054209922f, 1.0f}, -{0.98965013456362938f, 0.75950788158400617f, 0.6660361399461745f, 1.0f}, -{0.98940407535563246f, 0.75495578623606296f, 0.66000768935024989f, 1.0f}, -{0.98915801614763554f, 0.75040369088811998f, 0.65397923875432529f, 1.0f}, -{0.98891195693963863f, 0.74585159554017688f, 0.64795078815840057f, 1.0f}, -{0.98866589773164171f, 0.74129950019223367f, 0.64192233756247596f, 1.0f}, -{0.98841983852364479f, 0.73674740484429058f, 0.63589388696655136f, 1.0f}, -{0.9882352941176471f, 0.73207227989234902f, 0.62992695117262587f, 1.0f}, -{0.9882352941176471f, 0.72702806612841209f, 0.62414455978469818f, 1.0f}, -{0.9882352941176471f, 0.72198385236447526f, 0.6183621683967705f, 1.0f}, -{0.9882352941176471f, 0.71693963860053822f, 0.6125797770088427f, 1.0f}, -{0.9882352941176471f, 0.71189542483660129f, 0.60679738562091501f, 1.0f}, -{0.9882352941176471f, 0.70685121107266435f, 0.60101499423298732f, 1.0f}, -{0.9882352941176471f, 0.70180699730872731f, 0.59523260284505963f, 1.0f}, -{0.9882352941176471f, 0.69676278354479038f, 0.58945021145713183f, 1.0f}, -{0.9882352941176471f, 0.69171856978085344f, 0.58366782006920415f, 1.0f}, -{0.9882352941176471f, 0.68667435601691651f, 0.57788542868127646f, 1.0f}, -{0.9882352941176471f, 0.68163014225297969f, 0.57210303729334877f, 1.0f}, -{0.9882352941176471f, 0.67658592848904264f, 0.56632064590542097f, 1.0f}, -{0.9882352941176471f, 0.67154171472510571f, 0.56053825451749328f, 1.0f}, -{0.9882352941176471f, 0.66649750096116878f, 0.55475586312956549f, 1.0f}, -{0.9882352941176471f, 0.66145328719723184f, 0.5489734717416378f, 1.0f}, -{0.9882352941176471f, 0.6564090734332948f, 0.54319108035371011f, 1.0f}, -{0.9882352941176471f, 0.65136485966935787f, 0.53740868896578242f, 1.0f}, -{0.9882352941176471f, 0.64632064590542093f, 0.53162629757785473f, 1.0f}, -{0.9882352941176471f, 0.64127643214148411f, 0.52584390618992705f, 1.0f}, -{0.9882352941176471f, 0.63623221837754707f, 0.52006151480199925f, 1.0f}, -{0.9882352941176471f, 0.63118800461361013f, 0.51427912341407156f, 1.0f}, -{0.9882352941176471f, 0.6261437908496732f, 0.50849673202614376f, 1.0f}, -{0.9882352941176471f, 0.62109957708573627f, 0.50271434063821607f, 1.0f}, -{0.9882352941176471f, 0.61605536332179933f, 0.49693194925028839f, 1.0f}, -{0.9882352941176471f, 0.61101114955786229f, 0.49114955786236064f, 1.0f}, -{0.9882352941176471f, 0.60596693579392535f, 0.4853671664744329f, 1.0f}, -{0.9882352941176471f, 0.60092272202998853f, 0.47958477508650532f, 1.0f}, -{0.9882352941176471f, 0.59587850826605149f, 0.47380238369857752f, 1.0f}, -{0.9882352941176471f, 0.59083429450211455f, 0.46801999231064978f, 1.0f}, -{0.9882352941176471f, 0.58579008073817762f, 0.46223760092272204f, 1.0f}, -{0.9882352941176471f, 0.58074586697424069f, 0.45645520953479435f, 1.0f}, -{0.9882352941176471f, 0.57570165321030364f, 0.45067281814686661f, 1.0f}, -{0.98818915801614771f, 0.57070357554786622f, 0.44521337946943484f, 1.0f}, -{0.98806612841214925f, 0.56578239138792774f, 0.44029219530949637f, 1.0f}, -{0.98794309880815079f, 0.56086120722798927f, 0.43537101114955795f, 1.0f}, -{0.98782006920415233f, 0.55594002306805068f, 0.43044982698961942f, 1.0f}, -{0.98769703960015387f, 0.55101883890811221f, 0.42552864282968089f, 1.0f}, -{0.9875740099961553f, 0.54609765474817373f, 0.42060745866974242f, 1.0f}, -{0.98745098039215684f, 0.54117647058823526f, 0.41568627450980394f, 1.0f}, -{0.98732795078815838f, 0.53625528642829678f, 0.41076509034986547f, 1.0f}, -{0.98720492118415992f, 0.53133410226835831f, 0.405843906189927f, 1.0f}, -{0.98708189158016146f, 0.52641291810841984f, 0.40092272202998847f, 1.0f}, -{0.986958861976163f, 0.52149173394848136f, 0.3960015378700501f, 1.0f}, -{0.98683583237216455f, 0.51657054978854289f, 0.39108035371011152f, 1.0f}, -{0.98671280276816609f, 0.51164936562860441f, 0.38615916955017304f, 1.0f}, -{0.98658977316416763f, 0.50672818146866594f, 0.38123798539023457f, 1.0f}, -{0.98646674356016917f, 0.50180699730872735f, 0.37631680123029609f, 1.0f}, -{0.98634371395617071f, 0.49688581314878894f, 0.37139561707035756f, 1.0f}, -{0.98622068435217225f, 0.49196462898885046f, 0.36647443291041909f, 1.0f}, -{0.98609765474817379f, 0.48704344482891193f, 0.36155324875048062f, 1.0f}, -{0.98597462514417533f, 0.48212226066897357f, 0.3566320645905422f, 1.0f}, -{0.98585159554017687f, 0.47720107650903498f, 0.35171088043060361f, 1.0f}, -{0.98572856593617841f, 0.47227989234909651f, 0.34678969627066514f, 1.0f}, -{0.98560553633217995f, 0.46735870818915803f, 0.34186851211072666f, 1.0f}, -{0.9854825067281815f, 0.46243752402921956f, 0.33694732795078819f, 1.0f}, -{0.98535947712418293f, 0.45751633986928109f, 0.33202614379084971f, 1.0f}, -{0.98523644752018447f, 0.45259515570934261f, 0.32710495963091124f, 1.0f}, -{0.98511341791618601f, 0.44767397154940408f, 0.32218377547097277f, 1.0f}, -{0.98499038831218755f, 0.44275278738946566f, 0.31726259131103429f, 1.0f}, -{0.98486735870818909f, 0.43783160322952713f, 0.31234140715109576f, 1.0f}, -{0.98474432910419063f, 0.4329104190695886f, 0.30742022299115729f, 1.0f}, -{0.98462129950019217f, 0.42798923490965013f, 0.30249903883121876f, 1.0f}, -{0.98449826989619371f, 0.42306805074971165f, 0.29757785467128028f, 1.0f}, -{0.98437524029219525f, 0.41814686658977318f, 0.29265667051134181f, 1.0f}, -{0.98357554786620527f, 0.4127950788158401f, 0.28835063437139563f, 1.0f}, -{0.98209919261822376f, 0.40701268742791236f, 0.28465974625144175f, 1.0f}, -{0.98062283737024214f, 0.40123029603998467f, 0.28096885813148792f, 1.0f}, -{0.97914648212226063f, 0.39544790465205693f, 0.27727797001153404f, 1.0f}, -{0.97767012687427912f, 0.38966551326412935f, 0.27358708189158026f, 1.0f}, -{0.9761937716262975f, 0.38388312187620149f, 0.26989619377162632f, 1.0f}, -{0.97471741637831599f, 0.37810073048827375f, 0.26620530565167244f, 1.0f}, -{0.97324106113033448f, 0.37231833910034606f, 0.26251441753171861f, 1.0f}, -{0.97176470588235286f, 0.36653594771241832f, 0.25882352941176473f, 1.0f}, -{0.97028835063437135f, 0.36075355632449058f, 0.25513264129181085f, 1.0f}, -{0.96881199538638985f, 0.35497116493656289f, 0.25144175317185702f, 1.0f}, -{0.96733564013840823f, 0.34918877354863515f, 0.24775086505190314f, 1.0f}, -{0.96585928489042672f, 0.34340638216070746f, 0.24405997693194925f, 1.0f}, -{0.96438292964244521f, 0.33762399077277971f, 0.2403690888119954f, 1.0f}, -{0.96290657439446359f, 0.33184159938485203f, 0.23667820069204154f, 1.0f}, -{0.96143021914648208f, 0.32605920799692428f, 0.23298731257208766f, 1.0f}, -{0.95995386389850057f, 0.32027681660899654f, 0.2292964244521338f, 1.0f}, -{0.95847750865051906f, 0.31449442522106885f, 0.22560553633217995f, 1.0f}, -{0.95700115340253744f, 0.30871203383314111f, 0.22191464821222606f, 1.0f}, -{0.95552479815455593f, 0.30292964244521337f, 0.21822376009227221f, 1.0f}, -{0.95404844290657442f, 0.29714725105728584f, 0.21453287197231846f, 1.0f}, -{0.9525720876585928f, 0.29136485966935793f, 0.21084198385236447f, 1.0f}, -{0.95109573241061129f, 0.28558246828143019f, 0.20715109573241061f, 1.0f}, -{0.94961937716262979f, 0.2798000768935025f, 0.20346020761245676f, 1.0f}, -{0.94814302191464817f, 0.27401768550557482f, 0.19976931949250287f, 1.0f}, -{0.94666666666666666f, 0.26823529411764707f, 0.19607843137254902f, 1.0f}, -{0.94519031141868515f, 0.26245290272971933f, 0.19238754325259516f, 1.0f}, -{0.94371395617070353f, 0.25667051134179164f, 0.18869665513264128f, 1.0f}, -{0.94223760092272202f, 0.2508881199538639f, 0.18500576701268742f, 1.0f}, -{0.94076124567474051f, 0.24510572856593618f, 0.18131487889273357f, 1.0f}, -{0.93928489042675889f, 0.23932333717800847f, 0.17762399077277968f, 1.0f}, -{0.93780853517877738f, 0.23354094579008075f, 0.17393310265282583f, 1.0f}, -{0.93448673587081887f, 0.22868127643214151f, 0.17139561707035755f, 1.0f}, -{0.93005767012687424f, 0.22437524029219533f, 0.16955017301038061f, 1.0f}, -{0.9256286043829296f, 0.22006920415224915f, 0.1677047289504037f, 1.0f}, -{0.92119953863898496f, 0.21576316801230297f, 0.16585928489042676f, 1.0f}, -{0.91677047289504054f, 0.21145713187235693f, 0.16401384083044987f, 1.0f}, -{0.91234140715109568f, 0.20715109573241061f, 0.1621683967704729f, 1.0f}, -{0.90791234140715105f, 0.20284505959246443f, 0.16032295271049596f, 1.0f}, -{0.90348327566320641f, 0.19853902345251828f, 0.15847750865051902f, 1.0f}, -{0.89905420991926177f, 0.1942329873125721f, 0.1566320645905421f, 1.0f}, -{0.89462514417531713f, 0.18992695117262592f, 0.15478662053056516f, 1.0f}, -{0.8901960784313725f, 0.18562091503267975f, 0.15294117647058825f, 1.0f}, -{0.88576701268742786f, 0.18131487889273357f, 0.15109573241061131f, 1.0f}, -{0.88133794694348322f, 0.17700884275278739f, 0.14925028835063436f, 1.0f}, -{0.87690888119953858f, 0.17270280661284121f, 0.14740484429065745f, 1.0f}, -{0.87247981545559394f, 0.16839677047289503f, 0.14555940023068051f, 1.0f}, -{0.86805074971164931f, 0.16409073433294888f, 0.14371395617070357f, 1.0f}, -{0.86362168396770467f, 0.15978469819300267f, 0.14186851211072665f, 1.0f}, -{0.85919261822376003f, 0.15547866205305652f, 0.14002306805074971f, 1.0f}, -{0.85476355247981539f, 0.15117262591311034f, 0.13817762399077277f, 1.0f}, -{0.85033448673587075f, 0.14686658977316416f, 0.13633217993079583f, 1.0f}, -{0.84590542099192623f, 0.14256055363321812f, 0.13448673587081897f, 1.0f}, -{0.84147635524798148f, 0.13825451749327183f, 0.13264129181084197f, 1.0f}, -{0.83704728950403684f, 0.13394848135332565f, 0.13079584775086506f, 1.0f}, -{0.8326182237600922f, 0.12964244521337948f, 0.12895040369088812f, 1.0f}, -{0.82818915801614756f, 0.1253364090734333f, 0.12710495963091117f, 1.0f}, -{0.82376009227220293f, 0.12103037293348712f, 0.12525951557093426f, 1.0f}, -{0.81933102652825829f, 0.11672433679354094f, 0.12341407151095732f, 1.0f}, -{0.81490196078431365f, 0.11241830065359477f, 0.12156862745098039f, 1.0f}, -{0.81047289504036901f, 0.1081122645136486f, 0.11972318339100346f, 1.0f}, -{0.80604382929642437f, 0.10380622837370243f, 0.11787773933102652f, 1.0f}, -{0.80161476355247974f, 0.099500192233756252f, 0.11603229527104959f, 1.0f}, -{0.7971856978085351f, 0.095194156093810073f, 0.11418685121107267f, 1.0f}, -{0.79257208765859277f, 0.093287197231833915f, 0.11298731257208766f, 1.0f}, -{0.78789696270665122f, 0.092179930795847756f, 0.11200307574009996f, 1.0f}, -{0.78322183775470966f, 0.091072664359861596f, 0.11101883890811226f, 1.0f}, -{0.7785467128027681f, 0.089965397923875437f, 0.11003460207612456f, 1.0f}, -{0.77387158785082666f, 0.088858131487889305f, 0.10905036524413689f, 1.0f}, -{0.76919646289888499f, 0.087750865051903118f, 0.10806612841214917f, 1.0f}, -{0.76452133794694344f, 0.086643598615916959f, 0.10708189158016147f, 1.0f}, -{0.75984621299500188f, 0.085536332179930799f, 0.10609765474817377f, 1.0f}, -{0.75517108804306032f, 0.08442906574394464f, 0.10511341791618607f, 1.0f}, -{0.75049596309111877f, 0.08332179930795848f, 0.10412918108419839f, 1.0f}, -{0.74582083813917721f, 0.082214532871972321f, 0.10314494425221069f, 1.0f}, -{0.74114571318723566f, 0.081107266435986161f, 0.10216070742022298f, 1.0f}, -{0.7364705882352941f, 0.080000000000000002f, 0.10117647058823528f, 1.0f}, -{0.73179546328335254f, 0.078892733564013842f, 0.10019223375624758f, 1.0f}, -{0.72712033833141099f, 0.077785467128027683f, 0.099207996924259897f, 1.0f}, -{0.72244521337946943f, 0.076678200692041523f, 0.098223760092272197f, 1.0f}, -{0.71777008842752787f, 0.075570934256055364f, 0.097239523260284497f, 1.0f}, -{0.71309496347558632f, 0.074463667820069204f, 0.096255286428296796f, 1.0f}, -{0.70841983852364476f, 0.073356401384083045f, 0.09527104959630911f, 1.0f}, -{0.70374471357170321f, 0.072249134948096885f, 0.094286812764321409f, 1.0f}, -{0.69906958861976176f, 0.071141868512110754f, 0.093302575932333737f, 1.0f}, -{0.69439446366782009f, 0.070034602076124566f, 0.092318339100346009f, 1.0f}, -{0.68971933871587854f, 0.068927335640138407f, 0.091334102268358308f, 1.0f}, -{0.68504421376393698f, 0.067820069204152247f, 0.090349865436370608f, 1.0f}, -{0.68036908881199543f, 0.066712802768166088f, 0.089365628604382921f, 1.0f}, -{0.67569396386005387f, 0.065605536332179928f, 0.088381391772395221f, 1.0f}, -{0.67101883890811231f, 0.064498269896193769f, 0.08739715494040752f, 1.0f}, -{0.66634371395617076f, 0.063391003460207609f, 0.08641291810841982f, 1.0f}, -{0.6616685890042292f, 0.06228373702422145f, 0.085428681276432133f, 1.0f}, -{0.65699346405228765f, 0.06117647058823529f, 0.084444444444444433f, 1.0f}, -{0.65231833910034609f, 0.060069204152249131f, 0.083460207612456733f, 1.0f}, -{0.64764321414840453f, 0.058961937716262972f, 0.082475970780469032f, 1.0f}, -{0.64038446751249523f, 0.057208765859284888f, 0.081491733948481332f, 1.0f}, -{0.63275663206459054f, 0.05536332179930796f, 0.080507497116493645f, 1.0f}, -{0.62512879661668597f, 0.053517877739331025f, 0.079523260284505945f, 1.0f}, -{0.61750096116878128f, 0.051672433679354091f, 0.078539023452518245f, 1.0f}, -{0.60987312572087682f, 0.049826989619377218f, 0.077554786620530586f, 1.0f}, -{0.60224529027297191f, 0.047981545559400228f, 0.076570549788542858f, 1.0f}, -{0.59461745482506734f, 0.046136101499423293f, 0.075586312956555157f, 1.0f}, -{0.58698961937716265f, 0.044290657439446365f, 0.074602076124567457f, 1.0f}, -{0.57936178392925797f, 0.042445213379469438f, 0.073617839292579756f, 1.0f}, -{0.57173394848135339f, 0.040599769319492503f, 0.07263360246059207f, 1.0f}, -{0.56410611303344871f, 0.038754325259515568f, 0.07164936562860437f, 1.0f}, -{0.55647827758554402f, 0.03690888119953864f, 0.070665128796616669f, 1.0f}, -{0.54885044213763945f, 0.035063437139561705f, 0.069680891964628983f, 1.0f}, -{0.54122260668973476f, 0.033217993079584771f, 0.068696655132641282f, 1.0f}, -{0.53359477124183008f, 0.031372549019607843f, 0.067712418300653582f, 1.0f}, -{0.52596693579392539f, 0.029527104959630911f, 0.066728181468665881f, 1.0f}, -{0.51833910034602082f, 0.02768166089965398f, 0.065743944636678181f, 1.0f}, -{0.51071126489811614f, 0.025836216839677045f, 0.064759707804690494f, 1.0f}, -{0.50308342945021145f, 0.023990772779700117f, 0.063775470972702794f, 1.0f}, -{0.49545559400230682f, 0.022145328719723183f, 0.062791234140715108f, 1.0f}, -{0.48782775855440241f, 0.020299884659746303f, 0.061806997308727435f, 1.0f}, -{0.48019992310649751f, 0.01845444059976932f, 0.060822760476739707f, 1.0f}, -{0.47257208765859288f, 0.016608996539792385f, 0.059838523644752006f, 1.0f}, -{0.46494425221068825f, 0.014763552479815457f, 0.058854286812764313f, 1.0f}, -{0.45731641676278356f, 0.012918108419838523f, 0.057870049980776619f, 1.0f}, -{0.44968858131487888f, 0.011072664359861595f, 0.056885813148788919f, 1.0f}, -{0.44206074586697425f, 0.00922722029988466f, 0.055901576316801219f, 1.0f}, -{0.43443291041906962f, 0.0073817762399077252f, 0.054917339484813525f, 1.0f}, -{0.42680507497116493f, 0.0055363321799307974f, 0.053933102652825832f, 1.0f}, -{0.4191772395232603f, 0.0036908881199538626f, 0.052948865820838131f, 1.0f}, -{0.41154940407535567f, 0.0018454440599769348f, 0.051964628988850431f, 1.0f}, -{0.40392156862745099f, 0.0f, 0.050980392156862737f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential/Reds.txt b/extern/tfn/colormaps/sequential/Reds.txt deleted file mode 100644 index 04a32c0..0000000 --- a/extern/tfn/colormaps/sequential/Reds.txt +++ /dev/null @@ -1,256 +0,0 @@ -(1.0, 0.96078431372549022, 0.94117647058823528, 1.0) -(0.99987697039600154, 0.95820069204152247, 0.9374855824682814, 1.0) -(0.99975394079200308, 0.95561707035755483, 0.93379469434832751, 1.0) -(0.99963091118800462, 0.95303344867358708, 0.93010380622837374, 1.0) -(0.99950788158400616, 0.95044982698961944, 0.92641291810841986, 1.0) -(0.9993848519800077, 0.94786620530565169, 0.92272202998846597, 1.0) -(0.99926182237600925, 0.94528258362168394, 0.91903114186851209, 1.0) -(0.99913879277201079, 0.9426989619377163, 0.91534025374855821, 1.0) -(0.99901576316801233, 0.94011534025374854, 0.91164936562860432, 1.0) -(0.99889273356401387, 0.9375317185697809, 0.90795847750865044, 1.0) -(0.99876970396001541, 0.93494809688581315, 0.90426758938869667, 1.0) -(0.99864667435601695, 0.93236447520184551, 0.90057670126874279, 1.0) -(0.99852364475201849, 0.92978085351787776, 0.8968858131487889, 1.0) -(0.99840061514802003, 0.92719723183391001, 0.89319492502883502, 1.0) -(0.99827758554402157, 0.92461361014994237, 0.88950403690888113, 1.0) -(0.99815455594002311, 0.92202998846597461, 0.88581314878892736, 1.0) -(0.99803152633602465, 0.91944636678200697, 0.88212226066897348, 1.0) -(0.9979084967320262, 0.91686274509803922, 0.8784313725490196, 1.0) -(0.99778546712802774, 0.91427912341407147, 0.87474048442906571, 1.0) -(0.99766243752402928, 0.91169550173010383, 0.87104959630911183, 1.0) -(0.99753940792003082, 0.90911188004613608, 0.86735870818915795, 1.0) -(0.99741637831603236, 0.90652825836216844, 0.86366782006920406, 1.0) -(0.99729334871203379, 0.90394463667820069, 0.85997693194925029, 1.0) -(0.99717031910803533, 0.90136101499423305, 0.85628604382929641, 1.0) -(0.99704728950403687, 0.89877739331026529, 0.85259515570934252, 1.0) -(0.99692425990003841, 0.89619377162629754, 0.84890426758938864, 1.0) -(0.99680123029603995, 0.8936101499423299, 0.84521337946943476, 1.0) -(0.99667820069204149, 0.89102652825836215, 0.84152249134948098, 1.0) -(0.99655517108804303, 0.8884429065743944, 0.8378316032295271, 1.0) -(0.99643214148404458, 0.88585928489042676, 0.83414071510957322, 1.0) -(0.99630911188004612, 0.88327566320645901, 0.83044982698961933, 1.0) -(0.99618608227604766, 0.88069204152249136, 0.82675893886966545, 1.0) -(0.99604767397154936, 0.87786236063052669, 0.82277585544021525, 1.0) -(0.99580161476355245, 0.8733102652825836, 0.81674740484429065, 1.0) -(0.99555555555555553, 0.8687581699346405, 0.81071895424836593, 1.0) -(0.99530949634755861, 0.8642060745866974, 0.80469050365244132, 1.0) -(0.99506343713956169, 0.85965397923875431, 0.79866205305651672, 1.0) -(0.99481737793156477, 0.85510188389081121, 0.79263360246059211, 1.0) -(0.99457131872356785, 0.85054978854286811, 0.7866051518646674, 1.0) -(0.99432525951557094, 0.84599769319492502, 0.78057670126874279, 1.0) -(0.99407920030757402, 0.84144559784698192, 0.77454825067281807, 1.0) -(0.9938331410995771, 0.83689350249903882, 0.76851980007689347, 1.0) -(0.99358708189158018, 0.83234140715109572, 0.76249134948096886, 1.0) -(0.99334102268358326, 0.82778931180315263, 0.75646289888504414, 1.0) -(0.99309496347558635, 0.82323721645520953, 0.75043444828911954, 1.0) -(0.99284890426758943, 0.81868512110726643, 0.74440599769319493, 1.0) -(0.99260284505959251, 0.81413302575932334, 0.73837754709727021, 1.0) -(0.99235678585159559, 0.80958093041138024, 0.73234909650134561, 1.0) -(0.99211072664359867, 0.80502883506343714, 0.726320645905421, 1.0) -(0.99186466743560175, 0.80047673971549405, 0.7202921953094964, 1.0) -(0.99161860822760484, 0.79592464436755095, 0.71426374471357168, 1.0) -(0.99137254901960792, 0.79137254901960785, 0.70823529411764707, 1.0) -(0.991126489811611, 0.78682045367166475, 0.70220684352172236, 1.0) -(0.99088043060361408, 0.78226835832372166, 0.69617839292579775, 1.0) -(0.99063437139561705, 0.77771626297577856, 0.69014994232987315, 1.0) -(0.99038831218762013, 0.77316416762783535, 0.68412149173394843, 1.0) -(0.99014225297962322, 0.76861207227989237, 0.67809304113802382, 1.0) -(0.9898961937716263, 0.76405997693194927, 0.67206459054209922, 1.0) -(0.98965013456362938, 0.75950788158400617, 0.6660361399461745, 1.0) -(0.98940407535563246, 0.75495578623606296, 0.66000768935024989, 1.0) -(0.98915801614763554, 0.75040369088811998, 0.65397923875432529, 1.0) -(0.98891195693963863, 0.74585159554017688, 0.64795078815840057, 1.0) -(0.98866589773164171, 0.74129950019223367, 0.64192233756247596, 1.0) -(0.98841983852364479, 0.73674740484429058, 0.63589388696655136, 1.0) -(0.9882352941176471, 0.73207227989234902, 0.62992695117262587, 1.0) -(0.9882352941176471, 0.72702806612841209, 0.62414455978469818, 1.0) -(0.9882352941176471, 0.72198385236447526, 0.6183621683967705, 1.0) -(0.9882352941176471, 0.71693963860053822, 0.6125797770088427, 1.0) -(0.9882352941176471, 0.71189542483660129, 0.60679738562091501, 1.0) -(0.9882352941176471, 0.70685121107266435, 0.60101499423298732, 1.0) -(0.9882352941176471, 0.70180699730872731, 0.59523260284505963, 1.0) -(0.9882352941176471, 0.69676278354479038, 0.58945021145713183, 1.0) -(0.9882352941176471, 0.69171856978085344, 0.58366782006920415, 1.0) -(0.9882352941176471, 0.68667435601691651, 0.57788542868127646, 1.0) -(0.9882352941176471, 0.68163014225297969, 0.57210303729334877, 1.0) -(0.9882352941176471, 0.67658592848904264, 0.56632064590542097, 1.0) -(0.9882352941176471, 0.67154171472510571, 0.56053825451749328, 1.0) -(0.9882352941176471, 0.66649750096116878, 0.55475586312956549, 1.0) -(0.9882352941176471, 0.66145328719723184, 0.5489734717416378, 1.0) -(0.9882352941176471, 0.6564090734332948, 0.54319108035371011, 1.0) -(0.9882352941176471, 0.65136485966935787, 0.53740868896578242, 1.0) -(0.9882352941176471, 0.64632064590542093, 0.53162629757785473, 1.0) -(0.9882352941176471, 0.64127643214148411, 0.52584390618992705, 1.0) -(0.9882352941176471, 0.63623221837754707, 0.52006151480199925, 1.0) -(0.9882352941176471, 0.63118800461361013, 0.51427912341407156, 1.0) -(0.9882352941176471, 0.6261437908496732, 0.50849673202614376, 1.0) -(0.9882352941176471, 0.62109957708573627, 0.50271434063821607, 1.0) -(0.9882352941176471, 0.61605536332179933, 0.49693194925028839, 1.0) -(0.9882352941176471, 0.61101114955786229, 0.49114955786236064, 1.0) -(0.9882352941176471, 0.60596693579392535, 0.4853671664744329, 1.0) -(0.9882352941176471, 0.60092272202998853, 0.47958477508650532, 1.0) -(0.9882352941176471, 0.59587850826605149, 0.47380238369857752, 1.0) -(0.9882352941176471, 0.59083429450211455, 0.46801999231064978, 1.0) -(0.9882352941176471, 0.58579008073817762, 0.46223760092272204, 1.0) -(0.9882352941176471, 0.58074586697424069, 0.45645520953479435, 1.0) -(0.9882352941176471, 0.57570165321030364, 0.45067281814686661, 1.0) -(0.98818915801614771, 0.57070357554786622, 0.44521337946943484, 1.0) -(0.98806612841214925, 0.56578239138792774, 0.44029219530949637, 1.0) -(0.98794309880815079, 0.56086120722798927, 0.43537101114955795, 1.0) -(0.98782006920415233, 0.55594002306805068, 0.43044982698961942, 1.0) -(0.98769703960015387, 0.55101883890811221, 0.42552864282968089, 1.0) -(0.9875740099961553, 0.54609765474817373, 0.42060745866974242, 1.0) -(0.98745098039215684, 0.54117647058823526, 0.41568627450980394, 1.0) -(0.98732795078815838, 0.53625528642829678, 0.41076509034986547, 1.0) -(0.98720492118415992, 0.53133410226835831, 0.405843906189927, 1.0) -(0.98708189158016146, 0.52641291810841984, 0.40092272202998847, 1.0) -(0.986958861976163, 0.52149173394848136, 0.3960015378700501, 1.0) -(0.98683583237216455, 0.51657054978854289, 0.39108035371011152, 1.0) -(0.98671280276816609, 0.51164936562860441, 0.38615916955017304, 1.0) -(0.98658977316416763, 0.50672818146866594, 0.38123798539023457, 1.0) -(0.98646674356016917, 0.50180699730872735, 0.37631680123029609, 1.0) -(0.98634371395617071, 0.49688581314878894, 0.37139561707035756, 1.0) -(0.98622068435217225, 0.49196462898885046, 0.36647443291041909, 1.0) -(0.98609765474817379, 0.48704344482891193, 0.36155324875048062, 1.0) -(0.98597462514417533, 0.48212226066897357, 0.3566320645905422, 1.0) -(0.98585159554017687, 0.47720107650903498, 0.35171088043060361, 1.0) -(0.98572856593617841, 0.47227989234909651, 0.34678969627066514, 1.0) -(0.98560553633217995, 0.46735870818915803, 0.34186851211072666, 1.0) -(0.9854825067281815, 0.46243752402921956, 0.33694732795078819, 1.0) -(0.98535947712418293, 0.45751633986928109, 0.33202614379084971, 1.0) -(0.98523644752018447, 0.45259515570934261, 0.32710495963091124, 1.0) -(0.98511341791618601, 0.44767397154940408, 0.32218377547097277, 1.0) -(0.98499038831218755, 0.44275278738946566, 0.31726259131103429, 1.0) -(0.98486735870818909, 0.43783160322952713, 0.31234140715109576, 1.0) -(0.98474432910419063, 0.4329104190695886, 0.30742022299115729, 1.0) -(0.98462129950019217, 0.42798923490965013, 0.30249903883121876, 1.0) -(0.98449826989619371, 0.42306805074971165, 0.29757785467128028, 1.0) -(0.98437524029219525, 0.41814686658977318, 0.29265667051134181, 1.0) -(0.98357554786620527, 0.4127950788158401, 0.28835063437139563, 1.0) -(0.98209919261822376, 0.40701268742791236, 0.28465974625144175, 1.0) -(0.98062283737024214, 0.40123029603998467, 0.28096885813148792, 1.0) -(0.97914648212226063, 0.39544790465205693, 0.27727797001153404, 1.0) -(0.97767012687427912, 0.38966551326412935, 0.27358708189158026, 1.0) -(0.9761937716262975, 0.38388312187620149, 0.26989619377162632, 1.0) -(0.97471741637831599, 0.37810073048827375, 0.26620530565167244, 1.0) -(0.97324106113033448, 0.37231833910034606, 0.26251441753171861, 1.0) -(0.97176470588235286, 0.36653594771241832, 0.25882352941176473, 1.0) -(0.97028835063437135, 0.36075355632449058, 0.25513264129181085, 1.0) -(0.96881199538638985, 0.35497116493656289, 0.25144175317185702, 1.0) -(0.96733564013840823, 0.34918877354863515, 0.24775086505190314, 1.0) -(0.96585928489042672, 0.34340638216070746, 0.24405997693194925, 1.0) -(0.96438292964244521, 0.33762399077277971, 0.2403690888119954, 1.0) -(0.96290657439446359, 0.33184159938485203, 0.23667820069204154, 1.0) -(0.96143021914648208, 0.32605920799692428, 0.23298731257208766, 1.0) -(0.95995386389850057, 0.32027681660899654, 0.2292964244521338, 1.0) -(0.95847750865051906, 0.31449442522106885, 0.22560553633217995, 1.0) -(0.95700115340253744, 0.30871203383314111, 0.22191464821222606, 1.0) -(0.95552479815455593, 0.30292964244521337, 0.21822376009227221, 1.0) -(0.95404844290657442, 0.29714725105728584, 0.21453287197231846, 1.0) -(0.9525720876585928, 0.29136485966935793, 0.21084198385236447, 1.0) -(0.95109573241061129, 0.28558246828143019, 0.20715109573241061, 1.0) -(0.94961937716262979, 0.2798000768935025, 0.20346020761245676, 1.0) -(0.94814302191464817, 0.27401768550557482, 0.19976931949250287, 1.0) -(0.94666666666666666, 0.26823529411764707, 0.19607843137254902, 1.0) -(0.94519031141868515, 0.26245290272971933, 0.19238754325259516, 1.0) -(0.94371395617070353, 0.25667051134179164, 0.18869665513264128, 1.0) -(0.94223760092272202, 0.2508881199538639, 0.18500576701268742, 1.0) -(0.94076124567474051, 0.24510572856593618, 0.18131487889273357, 1.0) -(0.93928489042675889, 0.23932333717800847, 0.17762399077277968, 1.0) -(0.93780853517877738, 0.23354094579008075, 0.17393310265282583, 1.0) -(0.93448673587081887, 0.22868127643214151, 0.17139561707035755, 1.0) -(0.93005767012687424, 0.22437524029219533, 0.16955017301038061, 1.0) -(0.9256286043829296, 0.22006920415224915, 0.1677047289504037, 1.0) -(0.92119953863898496, 0.21576316801230297, 0.16585928489042676, 1.0) -(0.91677047289504054, 0.21145713187235693, 0.16401384083044987, 1.0) -(0.91234140715109568, 0.20715109573241061, 0.1621683967704729, 1.0) -(0.90791234140715105, 0.20284505959246443, 0.16032295271049596, 1.0) -(0.90348327566320641, 0.19853902345251828, 0.15847750865051902, 1.0) -(0.89905420991926177, 0.1942329873125721, 0.1566320645905421, 1.0) -(0.89462514417531713, 0.18992695117262592, 0.15478662053056516, 1.0) -(0.8901960784313725, 0.18562091503267975, 0.15294117647058825, 1.0) -(0.88576701268742786, 0.18131487889273357, 0.15109573241061131, 1.0) -(0.88133794694348322, 0.17700884275278739, 0.14925028835063436, 1.0) -(0.87690888119953858, 0.17270280661284121, 0.14740484429065745, 1.0) -(0.87247981545559394, 0.16839677047289503, 0.14555940023068051, 1.0) -(0.86805074971164931, 0.16409073433294888, 0.14371395617070357, 1.0) -(0.86362168396770467, 0.15978469819300267, 0.14186851211072665, 1.0) -(0.85919261822376003, 0.15547866205305652, 0.14002306805074971, 1.0) -(0.85476355247981539, 0.15117262591311034, 0.13817762399077277, 1.0) -(0.85033448673587075, 0.14686658977316416, 0.13633217993079583, 1.0) -(0.84590542099192623, 0.14256055363321812, 0.13448673587081897, 1.0) -(0.84147635524798148, 0.13825451749327183, 0.13264129181084197, 1.0) -(0.83704728950403684, 0.13394848135332565, 0.13079584775086506, 1.0) -(0.8326182237600922, 0.12964244521337948, 0.12895040369088812, 1.0) -(0.82818915801614756, 0.1253364090734333, 0.12710495963091117, 1.0) -(0.82376009227220293, 0.12103037293348712, 0.12525951557093426, 1.0) -(0.81933102652825829, 0.11672433679354094, 0.12341407151095732, 1.0) -(0.81490196078431365, 0.11241830065359477, 0.12156862745098039, 1.0) -(0.81047289504036901, 0.1081122645136486, 0.11972318339100346, 1.0) -(0.80604382929642437, 0.10380622837370243, 0.11787773933102652, 1.0) -(0.80161476355247974, 0.099500192233756252, 0.11603229527104959, 1.0) -(0.7971856978085351, 0.095194156093810073, 0.11418685121107267, 1.0) -(0.79257208765859277, 0.093287197231833915, 0.11298731257208766, 1.0) -(0.78789696270665122, 0.092179930795847756, 0.11200307574009996, 1.0) -(0.78322183775470966, 0.091072664359861596, 0.11101883890811226, 1.0) -(0.7785467128027681, 0.089965397923875437, 0.11003460207612456, 1.0) -(0.77387158785082666, 0.088858131487889305, 0.10905036524413689, 1.0) -(0.76919646289888499, 0.087750865051903118, 0.10806612841214917, 1.0) -(0.76452133794694344, 0.086643598615916959, 0.10708189158016147, 1.0) -(0.75984621299500188, 0.085536332179930799, 0.10609765474817377, 1.0) -(0.75517108804306032, 0.08442906574394464, 0.10511341791618607, 1.0) -(0.75049596309111877, 0.08332179930795848, 0.10412918108419839, 1.0) -(0.74582083813917721, 0.082214532871972321, 0.10314494425221069, 1.0) -(0.74114571318723566, 0.081107266435986161, 0.10216070742022298, 1.0) -(0.7364705882352941, 0.080000000000000002, 0.10117647058823528, 1.0) -(0.73179546328335254, 0.078892733564013842, 0.10019223375624758, 1.0) -(0.72712033833141099, 0.077785467128027683, 0.099207996924259897, 1.0) -(0.72244521337946943, 0.076678200692041523, 0.098223760092272197, 1.0) -(0.71777008842752787, 0.075570934256055364, 0.097239523260284497, 1.0) -(0.71309496347558632, 0.074463667820069204, 0.096255286428296796, 1.0) -(0.70841983852364476, 0.073356401384083045, 0.09527104959630911, 1.0) -(0.70374471357170321, 0.072249134948096885, 0.094286812764321409, 1.0) -(0.69906958861976176, 0.071141868512110754, 0.093302575932333737, 1.0) -(0.69439446366782009, 0.070034602076124566, 0.092318339100346009, 1.0) -(0.68971933871587854, 0.068927335640138407, 0.091334102268358308, 1.0) -(0.68504421376393698, 0.067820069204152247, 0.090349865436370608, 1.0) -(0.68036908881199543, 0.066712802768166088, 0.089365628604382921, 1.0) -(0.67569396386005387, 0.065605536332179928, 0.088381391772395221, 1.0) -(0.67101883890811231, 0.064498269896193769, 0.08739715494040752, 1.0) -(0.66634371395617076, 0.063391003460207609, 0.08641291810841982, 1.0) -(0.6616685890042292, 0.06228373702422145, 0.085428681276432133, 1.0) -(0.65699346405228765, 0.06117647058823529, 0.084444444444444433, 1.0) -(0.65231833910034609, 0.060069204152249131, 0.083460207612456733, 1.0) -(0.64764321414840453, 0.058961937716262972, 0.082475970780469032, 1.0) -(0.64038446751249523, 0.057208765859284888, 0.081491733948481332, 1.0) -(0.63275663206459054, 0.05536332179930796, 0.080507497116493645, 1.0) -(0.62512879661668597, 0.053517877739331025, 0.079523260284505945, 1.0) -(0.61750096116878128, 0.051672433679354091, 0.078539023452518245, 1.0) -(0.60987312572087682, 0.049826989619377218, 0.077554786620530586, 1.0) -(0.60224529027297191, 0.047981545559400228, 0.076570549788542858, 1.0) -(0.59461745482506734, 0.046136101499423293, 0.075586312956555157, 1.0) -(0.58698961937716265, 0.044290657439446365, 0.074602076124567457, 1.0) -(0.57936178392925797, 0.042445213379469438, 0.073617839292579756, 1.0) -(0.57173394848135339, 0.040599769319492503, 0.07263360246059207, 1.0) -(0.56410611303344871, 0.038754325259515568, 0.07164936562860437, 1.0) -(0.55647827758554402, 0.03690888119953864, 0.070665128796616669, 1.0) -(0.54885044213763945, 0.035063437139561705, 0.069680891964628983, 1.0) -(0.54122260668973476, 0.033217993079584771, 0.068696655132641282, 1.0) -(0.53359477124183008, 0.031372549019607843, 0.067712418300653582, 1.0) -(0.52596693579392539, 0.029527104959630911, 0.066728181468665881, 1.0) -(0.51833910034602082, 0.02768166089965398, 0.065743944636678181, 1.0) -(0.51071126489811614, 0.025836216839677045, 0.064759707804690494, 1.0) -(0.50308342945021145, 0.023990772779700117, 0.063775470972702794, 1.0) -(0.49545559400230682, 0.022145328719723183, 0.062791234140715108, 1.0) -(0.48782775855440241, 0.020299884659746303, 0.061806997308727435, 1.0) -(0.48019992310649751, 0.01845444059976932, 0.060822760476739707, 1.0) -(0.47257208765859288, 0.016608996539792385, 0.059838523644752006, 1.0) -(0.46494425221068825, 0.014763552479815457, 0.058854286812764313, 1.0) -(0.45731641676278356, 0.012918108419838523, 0.057870049980776619, 1.0) -(0.44968858131487888, 0.011072664359861595, 0.056885813148788919, 1.0) -(0.44206074586697425, 0.00922722029988466, 0.055901576316801219, 1.0) -(0.43443291041906962, 0.0073817762399077252, 0.054917339484813525, 1.0) -(0.42680507497116493, 0.0055363321799307974, 0.053933102652825832, 1.0) -(0.4191772395232603, 0.0036908881199538626, 0.052948865820838131, 1.0) -(0.41154940407535567, 0.0018454440599769348, 0.051964628988850431, 1.0) -(0.40392156862745099, 0.0, 0.050980392156862737, 1.0) diff --git a/extern/tfn/colormaps/sequential/YlGn.cpp b/extern/tfn/colormaps/sequential/YlGn.cpp deleted file mode 100644 index f2ea924..0000000 --- a/extern/tfn/colormaps/sequential/YlGn.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential_YlGn; -} -const std::vector colormap::data_sequential_YlGn = /* NOLINT(cert-err58-cpp) */ -{ -{1.0f, 1.0f, 0.89803921568627454f, 1.0f}, -{0.99901576316801233f, 0.99963091118800462f, 0.89262591311034223f, 1.0f}, -{0.99803152633602465f, 0.99926182237600925f, 0.88721261053440992f, 1.0f}, -{0.99704728950403687f, 0.99889273356401387f, 0.8817993079584775f, 1.0f}, -{0.9960630526720492f, 0.99852364475201849f, 0.87638600538254519f, 1.0f}, -{0.99507881584006153f, 0.99815455594002311f, 0.87097270280661288f, 1.0f}, -{0.99409457900807385f, 0.99778546712802774f, 0.86555940023068056f, 1.0f}, -{0.99311034217608607f, 0.99741637831603236f, 0.86014609765474814f, 1.0f}, -{0.9921261053440984f, 0.99704728950403687f, 0.85473279507881583f, 1.0f}, -{0.99114186851211072f, 0.99667820069204149f, 0.84931949250288352f, 1.0f}, -{0.99015763168012305f, 0.99630911188004612f, 0.84390618992695121f, 1.0f}, -{0.98917339484813538f, 0.99594002306805074f, 0.8384928873510189f, 1.0f}, -{0.9881891580161476f, 0.99557093425605536f, 0.83307958477508648f, 1.0f}, -{0.98720492118415992f, 0.99520184544405998f, 0.82766628219915417f, 1.0f}, -{0.98622068435217225f, 0.99483275663206461f, 0.82225297962322186f, 1.0f}, -{0.98523644752018458f, 0.99446366782006923f, 0.81683967704728955f, 1.0f}, -{0.98425221068819679f, 0.99409457900807385f, 0.81142637447135713f, 1.0f}, -{0.98326797385620912f, 0.99372549019607848f, 0.80601307189542482f, 1.0f}, -{0.98228373702422145f, 0.9933564013840831f, 0.8005997693194925f, 1.0f}, -{0.98129950019223378f, 0.99298731257208772f, 0.79518646674356019f, 1.0f}, -{0.9803152633602461f, 0.99261822376009234f, 0.78977316416762777f, 1.0f}, -{0.97933102652825832f, 0.99224913494809697f, 0.78435986159169546f, 1.0f}, -{0.97834678969627065f, 0.99188004613610148f, 0.77894655901576315f, 1.0f}, -{0.97736255286428297f, 0.9915109573241061f, 0.77353325643983084f, 1.0f}, -{0.9763783160322953f, 0.99114186851211072f, 0.76811995386389853f, 1.0f}, -{0.97539407920030752f, 0.99077277970011535f, 0.76270665128796611f, 1.0f}, -{0.97440984236831985f, 0.99040369088811997f, 0.7572933487120338f, 1.0f}, -{0.97342560553633217f, 0.99003460207612459f, 0.75188004613610149f, 1.0f}, -{0.9724413687043445f, 0.98966551326412922f, 0.74646674356016918f, 1.0f}, -{0.97145713187235683f, 0.98929642445213384f, 0.74105344098423687f, 1.0f}, -{0.97047289504036904f, 0.98892733564013846f, 0.73564013840830444f, 1.0f}, -{0.96948865820838137f, 0.98855824682814308f, 0.73022683583237213f, 1.0f}, -{0.96816608996539788f, 0.98805074971164941f, 0.72515186466743553f, 1.0f}, -{0.96447520184544411f, 0.9865743944636679f, 0.72244521337946943f, 1.0f}, -{0.96078431372549022f, 0.98509803921568628f, 0.71973856209150322f, 1.0f}, -{0.95709342560553634f, 0.98362168396770477f, 0.71703191080353712f, 1.0f}, -{0.95340253748558246f, 0.98214532871972327f, 0.71432525951557091f, 1.0f}, -{0.94971164936562857f, 0.98066897347174165f, 0.71161860822760481f, 1.0f}, -{0.94602076124567469f, 0.97919261822376014f, 0.7089119569396386f, 1.0f}, -{0.94232987312572092f, 0.97771626297577863f, 0.70620530565167239f, 1.0f}, -{0.93863898500576703f, 0.97623990772779701f, 0.70349865436370629f, 1.0f}, -{0.93494809688581315f, 0.9747635524798155f, 0.70079200307574008f, 1.0f}, -{0.93125720876585927f, 0.97328719723183399f, 0.69808535178777387f, 1.0f}, -{0.92756632064590538f, 0.97181084198385237f, 0.69537870049980777f, 1.0f}, -{0.9238754325259515f, 0.97033448673587086f, 0.69267204921184156f, 1.0f}, -{0.92018454440599773f, 0.96885813148788935f, 0.68996539792387546f, 1.0f}, -{0.91649365628604385f, 0.96738177623990773f, 0.68725874663590925f, 1.0f}, -{0.91280276816608996f, 0.96590542099192622f, 0.68455209534794303f, 1.0f}, -{0.90911188004613608f, 0.9644290657439446f, 0.68184544405997694f, 1.0f}, -{0.90542099192618219f, 0.96295271049596309f, 0.67913879277201072f, 1.0f}, -{0.90173010380622842f, 0.96147635524798158f, 0.67643214148404451f, 1.0f}, -{0.89803921568627454f, 0.95999999999999996f, 0.67372549019607841f, 1.0f}, -{0.89434832756632066f, 0.95852364475201846f, 0.6710188389081122f, 1.0f}, -{0.89065743944636677f, 0.95704728950403695f, 0.6683121876201461f, 1.0f}, -{0.88696655132641289f, 0.95557093425605533f, 0.66560553633217989f, 1.0f}, -{0.88327566320645901f, 0.95409457900807382f, 0.66289888504421368f, 1.0f}, -{0.87958477508650512f, 0.95261822376009231f, 0.66019223375624758f, 1.0f}, -{0.87589388696655135f, 0.95114186851211069f, 0.65748558246828137f, 1.0f}, -{0.87220299884659747f, 0.94966551326412918f, 0.65477893118031516f, 1.0f}, -{0.86851211072664358f, 0.94818915801614767f, 0.65207227989234906f, 1.0f}, -{0.8648212226066897f, 0.94671280276816605f, 0.64936562860438285f, 1.0f}, -{0.86113033448673582f, 0.94523644752018454f, 0.64665897731641675f, 1.0f}, -{0.85743944636678204f, 0.94376009227220303f, 0.64395232602845054f, 1.0f}, -{0.85374855824682816f, 0.94228373702422141f, 0.64124567474048444f, 1.0f}, -{0.84962706651287967f, 0.94059207996924254f, 0.63856978085351779f, 1.0f}, -{0.84421376393694736f, 0.93825451749327182f, 0.63598615916955015f, 1.0f}, -{0.83880046136101505f, 0.9359169550173011f, 0.63340253748558251f, 1.0f}, -{0.83338715878508263f, 0.93357939254133027f, 0.63081891580161475f, 1.0f}, -{0.82797385620915032f, 0.93124183006535943f, 0.628235294117647f, 1.0f}, -{0.82256055363321801f, 0.92890426758938871f, 0.62565167243367936f, 1.0f}, -{0.8171472510572857f, 0.92656670511341788f, 0.62306805074971161f, 1.0f}, -{0.81173394848135327f, 0.92422914263744715f, 0.62048442906574386f, 1.0f}, -{0.80632064590542096f, 0.92189158016147632f, 0.61790080738177622f, 1.0f}, -{0.80090734332948865f, 0.9195540176855056f, 0.61531718569780847f, 1.0f}, -{0.79549404075355634f, 0.91721645520953488f, 0.61273356401384083f, 1.0f}, -{0.79008073817762403f, 0.91487889273356404f, 0.61014994232987307f, 1.0f}, -{0.78466743560169161f, 0.91254133025759321f, 0.60756632064590543f, 1.0f}, -{0.7792541330257593f, 0.91020376778162249f, 0.60498269896193768f, 1.0f}, -{0.77384083044982699f, 0.90786620530565165f, 0.60239907727797004f, 1.0f}, -{0.76842752787389468f, 0.90552864282968093f, 0.59981545559400229f, 1.0f}, -{0.76301422529796237f, 0.9031910803537101f, 0.59723183391003465f, 1.0f}, -{0.75760092272202995f, 0.90085351787773937f, 0.5946482122260669f, 1.0f}, -{0.75218762014609775f, 0.89851595540176854f, 0.59206459054209926f, 1.0f}, -{0.74677431757016532f, 0.89617839292579782f, 0.5894809688581315f, 1.0f}, -{0.74136101499423301f, 0.89384083044982698f, 0.58689734717416375f, 1.0f}, -{0.7359477124183007f, 0.89150326797385626f, 0.58431372549019611f, 1.0f}, -{0.73053440984236828f, 0.88916570549788543f, 0.58173010380622836f, 1.0f}, -{0.72512110726643597f, 0.88682814302191471f, 0.57914648212226072f, 1.0f}, -{0.71970780469050366f, 0.88449058054594387f, 0.57656286043829297f, 1.0f}, -{0.71429450211457135f, 0.88215301806997315f, 0.57397923875432522f, 1.0f}, -{0.70888119953863904f, 0.87981545559400232f, 0.57139561707035758f, 1.0f}, -{0.70346789696270662f, 0.87747789311803159f, 0.56881199538638982f, 1.0f}, -{0.69805459438677442f, 0.87514033064206076f, 0.56622837370242218f, 1.0f}, -{0.692641291810842f, 0.87280276816609004f, 0.56364475201845443f, 1.0f}, -{0.68722798923490969f, 0.8704652056901192f, 0.56106113033448679f, 1.0f}, -{0.68181468665897738f, 0.86812764321414848f, 0.55847750865051904f, 1.0f}, -{0.67598615916955018f, 0.86560553633217996f, 0.5558938869665514f, 1.0f}, -{0.66946559015763174f, 0.86277585544021529f, 0.55331026528258365f, 1.0f}, -{0.6629450211457133f, 0.85994617454825073f, 0.55072664359861601f, 1.0f}, -{0.65642445213379474f, 0.85711649365628606f, 0.54814302191464825f, 1.0f}, -{0.64990388312187619f, 0.85428681276432139f, 0.5455594002306805f, 1.0f}, -{0.64338331410995775f, 0.85145713187235683f, 0.54297577854671286f, 1.0f}, -{0.6368627450980392f, 0.84862745098039216f, 0.54039215686274511f, 1.0f}, -{0.63034217608612075f, 0.8457977700884276f, 0.53780853517877736f, 1.0f}, -{0.6238216070742022f, 0.84296808919646293f, 0.53522491349480972f, 1.0f}, -{0.61730103806228376f, 0.84013840830449826f, 0.53264129181084197f, 1.0f}, -{0.61078046905036532f, 0.8373087274125337f, 0.53005767012687433f, 1.0f}, -{0.60425990003844676f, 0.83447904652056903f, 0.52747404844290657f, 1.0f}, -{0.59773933102652832f, 0.83164936562860436f, 0.52489042675893882f, 1.0f}, -{0.59121876201460977f, 0.82881968473663981f, 0.52230680507497118f, 1.0f}, -{0.58469819300269132f, 0.82599000384467514f, 0.51972318339100343f, 1.0f}, -{0.57817762399077277f, 0.82316032295271047f, 0.51713956170703579f, 1.0f}, -{0.57165705497885433f, 0.82033064206074591f, 0.51455594002306804f, 1.0f}, -{0.56513648596693578f, 0.81750096116878124f, 0.5119723183391004f, 1.0f}, -{0.55861591695501744f, 0.81467128027681668f, 0.50938869665513264f, 1.0f}, -{0.55209534794309878f, 0.81184159938485201f, 0.50680507497116489f, 1.0f}, -{0.54557477893118034f, 0.80901191849288734f, 0.50422145328719725f, 1.0f}, -{0.5390542099192619f, 0.80618223760092278f, 0.5016378316032295f, 1.0f}, -{0.53253364090734334f, 0.80335255670895811f, 0.4990542099192618f, 1.0f}, -{0.52601307189542479f, 0.80052287581699355f, 0.49647058823529411f, 1.0f}, -{0.51949250288350635f, 0.79769319492502888f, 0.49388696655132641f, 1.0f}, -{0.5129719338715879f, 0.79486351403306421f, 0.49130334486735872f, 1.0f}, -{0.50645136485966946f, 0.79203383314109965f, 0.48871972318339102f, 1.0f}, -{0.49993079584775091f, 0.78920415224913498f, 0.48613610149942327f, 1.0f}, -{0.49341022683583236f, 0.78637447135717031f, 0.48355247981545557f, 1.0f}, -{0.48688965782391391f, 0.78354479046520575f, 0.48096885813148788f, 1.0f}, -{0.48036908881199536f, 0.78071510957324108f, 0.47838523644752018f, 1.0f}, -{0.47384851980007692f, 0.77788542868127641f, 0.47580161476355248f, 1.0f}, -{0.4672049211841599f, 0.77480968858131494f, 0.47278738946559012f, 1.0f}, -{0.46043829296424449f, 0.77148788927335643f, 0.46934256055363321f, 1.0f}, -{0.45367166474432907f, 0.76816608996539792f, 0.46589773164167625f, 1.0f}, -{0.44690503652441366f, 0.76484429065743942f, 0.46245290272971934f, 1.0f}, -{0.44013840830449846f, 0.76152249134948102f, 0.45900807381776249f, 1.0f}, -{0.43337178008458282f, 0.75820069204152252f, 0.45556324490580546f, 1.0f}, -{0.42660515186466741f, 0.75487889273356401f, 0.4521184159938485f, 1.0f}, -{0.41983852364475199f, 0.7515570934256055f, 0.44867358708189153f, 1.0f}, -{0.41307189542483658f, 0.74823529411764711f, 0.44522875816993462f, 1.0f}, -{0.40630526720492116f, 0.7449134948096886f, 0.44178392925797766f, 1.0f}, -{0.39953863898500575f, 0.7415916955017301f, 0.43833910034602075f, 1.0f}, -{0.39277201076509033f, 0.73826989619377159f, 0.43489427143406378f, 1.0f}, -{0.38600538254517491f, 0.73494809688581308f, 0.43144944252210687f, 1.0f}, -{0.3792387543252595f, 0.73162629757785469f, 0.42800461361014991f, 1.0f}, -{0.37247212610534408f, 0.72830449826989618f, 0.424559784698193f, 1.0f}, -{0.36570549788542867f, 0.72498269896193768f, 0.42111495578623603f, 1.0f}, -{0.35893886966551325f, 0.72166089965397917f, 0.41767012687427907f, 1.0f}, -{0.35217224144559783f, 0.71833910034602078f, 0.41422529796232216f, 1.0f}, -{0.34540561322568242f, 0.71501730103806227f, 0.41078046905036525f, 1.0f}, -{0.338638985005767f, 0.71169550173010376f, 0.40733564013840828f, 1.0f}, -{0.33187235678585175f, 0.70837370242214537f, 0.40389081122645143f, 1.0f}, -{0.32510572856593611f, 0.70505190311418686f, 0.40044598231449441f, 1.0f}, -{0.31833910034602075f, 0.70173010380622836f, 0.39700115340253744f, 1.0f}, -{0.31157247212610528f, 0.69840830449826985f, 0.39355632449058053f, 1.0f}, -{0.30480584390618992f, 0.69508650519031134f, 0.39011149557862357f, 1.0f}, -{0.29803921568627445f, 0.69176470588235284f, 0.38666666666666666f, 1.0f}, -{0.29127258746635909f, 0.68844290657439444f, 0.38322183775470969f, 1.0f}, -{0.28450595924644362f, 0.68512110726643594f, 0.37977700884275278f, 1.0f}, -{0.27773933102652826f, 0.68179930795847743f, 0.37633217993079582f, 1.0f}, -{0.27097270280661279f, 0.67847750865051903f, 0.37288735101883885f, 1.0f}, -{0.26420607458669743f, 0.67515570934256053f, 0.36944252210688194f, 1.0f}, -{0.25743944636678195f, 0.67183391003460202f, 0.36599769319492503f, 1.0f}, -{0.25259515570934254f, 0.66758938869665507f, 0.36270665128796614f, 1.0f}, -{0.24890426758938869f, 0.66279123414071506f, 0.35950788158400615f, 1.0f}, -{0.24521337946943481f, 0.65799307958477504f, 0.3563091118800461f, 1.0f}, -{0.24152249134948095f, 0.65319492502883503f, 0.35311034217608611f, 1.0f}, -{0.23783160322952721f, 0.64839677047289512f, 0.34991157247212618f, 1.0f}, -{0.23414071510957324f, 0.643598615916955f, 0.34671280276816607f, 1.0f}, -{0.23044982698961936f, 0.63880046136101498f, 0.34351403306420608f, 1.0f}, -{0.2267589388696655f, 0.63400230680507497f, 0.34031526336024603f, 1.0f}, -{0.22306805074971164f, 0.62920415224913495f, 0.33711649365628604f, 1.0f}, -{0.21937716262975779f, 0.62440599769319494f, 0.333917723952326f, 1.0f}, -{0.21568627450980393f, 0.61960784313725492f, 0.330718954248366f, 1.0f}, -{0.21199538638985005f, 0.61480968858131491f, 0.32752018454440601f, 1.0f}, -{0.20830449826989619f, 0.61001153402537489f, 0.32432141484044597f, 1.0f}, -{0.20461361014994234f, 0.60521337946943488f, 0.32112264513648597f, 1.0f}, -{0.20092272202998845f, 0.60041522491349486f, 0.31792387543252593f, 1.0f}, -{0.1972318339100346f, 0.59561707035755473f, 0.31472510572856593f, 1.0f}, -{0.19354094579008074f, 0.59081891580161472f, 0.31152633602460589f, 1.0f}, -{0.18985005767012686f, 0.5860207612456747f, 0.3083275663206459f, 1.0f}, -{0.186159169550173f, 0.58122260668973469f, 0.3051287966166859f, 1.0f}, -{0.18246828143021915f, 0.57642445213379467f, 0.30193002691272586f, 1.0f}, -{0.17877739331026538f, 0.57162629757785477f, 0.29873125720876592f, 1.0f}, -{0.17508650519031144f, 0.56682814302191464f, 0.29553248750480587f, 1.0f}, -{0.17139561707035755f, 0.56202998846597463f, 0.29233371780084583f, 1.0f}, -{0.1677047289504037f, 0.55723183391003461f, 0.28913494809688578f, 1.0f}, -{0.16401384083044984f, 0.5524336793540946f, 0.28593617839292579f, 1.0f}, -{0.16032295271049596f, 0.54763552479815458f, 0.2827374086889658f, 1.0f}, -{0.1566320645905421f, 0.54283737024221457f, 0.27953863898500575f, 1.0f}, -{0.15294117647058825f, 0.53803921568627455f, 0.27633986928104576f, 1.0f}, -{0.14925028835063436f, 0.53324106113033454f, 0.27314109957708577f, 1.0f}, -{0.14555940023068051f, 0.52844290657439452f, 0.26994232987312572f, 1.0f}, -{0.14186851211072665f, 0.52364475201845451f, 0.26674356016916573f, 1.0f}, -{0.13817762399077277f, 0.51884659746251449f, 0.26354479046520568f, 1.0f}, -{0.13402537485582469f, 0.51506343713956171f, 0.26163783160322956f, 1.0f}, -{0.12971933871587851f, 0.51161860822760485f, 0.260161476355248f, 1.0f}, -{0.12541330257593233f, 0.50817377931564789f, 0.25868512110726644f, 1.0f}, -{0.12110726643598617f, 0.50472895040369092f, 0.25720876585928493f, 1.0f}, -{0.11680123029604011f, 0.50128412149173407f, 0.25573241061130342f, 1.0f}, -{0.11249519415609383f, 0.49783929257977705f, 0.2542560553633218f, 1.0f}, -{0.10818915801614765f, 0.49439446366782008f, 0.25277970011534029f, 1.0f}, -{0.10388312187620147f, 0.49094963475586317f, 0.25130334486735872f, 1.0f}, -{0.099577085736255289f, 0.48750480584390621f, 0.24982698961937716f, 1.0f}, -{0.09527104959630911f, 0.4840599769319493f, 0.24835063437139562f, 1.0f}, -{0.090965013456362945f, 0.48061514801999233f, 0.24687427912341409f, 1.0f}, -{0.086658977316416766f, 0.47717031910803542f, 0.24539792387543252f, 1.0f}, -{0.082352941176470601f, 0.47372549019607846f, 0.24392156862745099f, 1.0f}, -{0.078046905036524422f, 0.47028066128412149f, 0.24244521337946945f, 1.0f}, -{0.073740868896578243f, 0.46683583237216458f, 0.24096885813148788f, 1.0f}, -{0.069434832756632064f, 0.46339100346020762f, 0.23949250288350635f, 1.0f}, -{0.065128796616685899f, 0.45994617454825071f, 0.23801614763552481f, 1.0f}, -{0.060822760476739721f, 0.45650134563629374f, 0.23653979238754327f, 1.0f}, -{0.056516724336793542f, 0.45305651672433678f, 0.23506343713956171f, 1.0f}, -{0.052210688196847363f, 0.44961168781237987f, 0.23358708189158017f, 1.0f}, -{0.047904652056901309f, 0.44616685890042301f, 0.23211072664359866f, 1.0f}, -{0.043598615916955019f, 0.44272202998846599f, 0.23063437139561707f, 1.0f}, -{0.03929257977700884f, 0.43927720107650903f, 0.22915801614763553f, 1.0f}, -{0.034986543637062675f, 0.43583237216455212f, 0.227681660899654f, 1.0f}, -{0.030680507497116496f, 0.43238754325259515f, 0.22620530565167243f, 1.0f}, -{0.026374471357170318f, 0.42894271434063824f, 0.2247289504036909f, 1.0f}, -{0.022068435217224139f, 0.42549788542868128f, 0.22325259515570936f, 1.0f}, -{0.017762399077277974f, 0.42205305651672431f, 0.22177623990772782f, 1.0f}, -{0.013456362937331795f, 0.4186082276047674f, 0.22029988465974626f, 1.0f}, -{0.0091503267973856162f, 0.41516339869281044f, 0.21882352941176472f, 1.0f}, -{0.0048442906574394373f, 0.41171856978085353f, 0.21734717416378319f, 1.0f}, -{0.00053825451749325848f, 0.40827374086889656f, 0.21587081891580162f, 1.0f}, -{0.0f, 0.40407535563244906f, 0.21417916186082278f, 1.0f}, -{0.0f, 0.39976931949250288f, 0.2124567474048443f, 1.0f}, -{0.0f, 0.3954632833525567f, 0.21073433294886584f, 1.0f}, -{0.0f, 0.39115724721261053f, 0.20901191849288736f, 1.0f}, -{0.0f, 0.38685121107266446f, 0.20728950403690893f, 1.0f}, -{0.0f, 0.38254517493271817f, 0.20556708958093042f, 1.0f}, -{0.0f, 0.37823913879277199f, 0.20384467512495194f, 1.0f}, -{0.0f, 0.37393310265282581f, 0.20212226066897349f, 1.0f}, -{0.0f, 0.36962706651287963f, 0.200399846212995f, 1.0f}, -{0.0f, 0.36532103037293345f, 0.19867743175701655f, 1.0f}, -{0.0f, 0.36101499423298733f, 0.19695501730103807f, 1.0f}, -{0.0f, 0.35670895809304115f, 0.19523260284505961f, 1.0f}, -{0.0f, 0.35240292195309497f, 0.19351018838908113f, 1.0f}, -{0.0f, 0.34809688581314879f, 0.19178777393310267f, 1.0f}, -{0.0f, 0.34379084967320261f, 0.19006535947712419f, 1.0f}, -{0.0f, 0.33948481353325644f, 0.18834294502114574f, 1.0f}, -{0.0f, 0.33517877739331026f, 0.18662053056516725f, 1.0f}, -{0.0f, 0.33087274125336408f, 0.18489811610918877f, 1.0f}, -{0.0f, 0.3265667051134179f, 0.18317570165321032f, 1.0f}, -{0.0f, 0.32226066897347172f, 0.18145328719723186f, 1.0f}, -{0.0f, 0.31795463283352565f, 0.17973087274125343f, 1.0f}, -{0.0f, 0.31364859669357936f, 0.1780084582852749f, 1.0f}, -{0.0f, 0.30934256055363318f, 0.17628604382929644f, 1.0f}, -{0.0f, 0.305036524413687f, 0.17456362937331796f, 1.0f}, -{0.0f, 0.30073048827374083f, 0.1728412149173395f, 1.0f}, -{0.0f, 0.29642445213379465f, 0.17111880046136102f, 1.0f}, -{0.0f, 0.29211841599384852f, 0.16939638600538257f, 1.0f}, -{0.0f, 0.28781237985390234f, 0.16767397154940408f, 1.0f}, -{0.0f, 0.28350634371395617f, 0.16595155709342563f, 1.0f}, -{0.0f, 0.27920030757400999f, 0.16422914263744715f, 1.0f}, -{0.0f, 0.27489427143406381f, 0.16250672818146866f, 1.0f}, -{0.0f, 0.27058823529411763f, 0.16078431372549021f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential/YlGn.txt b/extern/tfn/colormaps/sequential/YlGn.txt deleted file mode 100644 index c0a12b4..0000000 --- a/extern/tfn/colormaps/sequential/YlGn.txt +++ /dev/null @@ -1,256 +0,0 @@ -(1.0, 1.0, 0.89803921568627454, 1.0) -(0.99901576316801233, 0.99963091118800462, 0.89262591311034223, 1.0) -(0.99803152633602465, 0.99926182237600925, 0.88721261053440992, 1.0) -(0.99704728950403687, 0.99889273356401387, 0.8817993079584775, 1.0) -(0.9960630526720492, 0.99852364475201849, 0.87638600538254519, 1.0) -(0.99507881584006153, 0.99815455594002311, 0.87097270280661288, 1.0) -(0.99409457900807385, 0.99778546712802774, 0.86555940023068056, 1.0) -(0.99311034217608607, 0.99741637831603236, 0.86014609765474814, 1.0) -(0.9921261053440984, 0.99704728950403687, 0.85473279507881583, 1.0) -(0.99114186851211072, 0.99667820069204149, 0.84931949250288352, 1.0) -(0.99015763168012305, 0.99630911188004612, 0.84390618992695121, 1.0) -(0.98917339484813538, 0.99594002306805074, 0.8384928873510189, 1.0) -(0.9881891580161476, 0.99557093425605536, 0.83307958477508648, 1.0) -(0.98720492118415992, 0.99520184544405998, 0.82766628219915417, 1.0) -(0.98622068435217225, 0.99483275663206461, 0.82225297962322186, 1.0) -(0.98523644752018458, 0.99446366782006923, 0.81683967704728955, 1.0) -(0.98425221068819679, 0.99409457900807385, 0.81142637447135713, 1.0) -(0.98326797385620912, 0.99372549019607848, 0.80601307189542482, 1.0) -(0.98228373702422145, 0.9933564013840831, 0.8005997693194925, 1.0) -(0.98129950019223378, 0.99298731257208772, 0.79518646674356019, 1.0) -(0.9803152633602461, 0.99261822376009234, 0.78977316416762777, 1.0) -(0.97933102652825832, 0.99224913494809697, 0.78435986159169546, 1.0) -(0.97834678969627065, 0.99188004613610148, 0.77894655901576315, 1.0) -(0.97736255286428297, 0.9915109573241061, 0.77353325643983084, 1.0) -(0.9763783160322953, 0.99114186851211072, 0.76811995386389853, 1.0) -(0.97539407920030752, 0.99077277970011535, 0.76270665128796611, 1.0) -(0.97440984236831985, 0.99040369088811997, 0.7572933487120338, 1.0) -(0.97342560553633217, 0.99003460207612459, 0.75188004613610149, 1.0) -(0.9724413687043445, 0.98966551326412922, 0.74646674356016918, 1.0) -(0.97145713187235683, 0.98929642445213384, 0.74105344098423687, 1.0) -(0.97047289504036904, 0.98892733564013846, 0.73564013840830444, 1.0) -(0.96948865820838137, 0.98855824682814308, 0.73022683583237213, 1.0) -(0.96816608996539788, 0.98805074971164941, 0.72515186466743553, 1.0) -(0.96447520184544411, 0.9865743944636679, 0.72244521337946943, 1.0) -(0.96078431372549022, 0.98509803921568628, 0.71973856209150322, 1.0) -(0.95709342560553634, 0.98362168396770477, 0.71703191080353712, 1.0) -(0.95340253748558246, 0.98214532871972327, 0.71432525951557091, 1.0) -(0.94971164936562857, 0.98066897347174165, 0.71161860822760481, 1.0) -(0.94602076124567469, 0.97919261822376014, 0.7089119569396386, 1.0) -(0.94232987312572092, 0.97771626297577863, 0.70620530565167239, 1.0) -(0.93863898500576703, 0.97623990772779701, 0.70349865436370629, 1.0) -(0.93494809688581315, 0.9747635524798155, 0.70079200307574008, 1.0) -(0.93125720876585927, 0.97328719723183399, 0.69808535178777387, 1.0) -(0.92756632064590538, 0.97181084198385237, 0.69537870049980777, 1.0) -(0.9238754325259515, 0.97033448673587086, 0.69267204921184156, 1.0) -(0.92018454440599773, 0.96885813148788935, 0.68996539792387546, 1.0) -(0.91649365628604385, 0.96738177623990773, 0.68725874663590925, 1.0) -(0.91280276816608996, 0.96590542099192622, 0.68455209534794303, 1.0) -(0.90911188004613608, 0.9644290657439446, 0.68184544405997694, 1.0) -(0.90542099192618219, 0.96295271049596309, 0.67913879277201072, 1.0) -(0.90173010380622842, 0.96147635524798158, 0.67643214148404451, 1.0) -(0.89803921568627454, 0.95999999999999996, 0.67372549019607841, 1.0) -(0.89434832756632066, 0.95852364475201846, 0.6710188389081122, 1.0) -(0.89065743944636677, 0.95704728950403695, 0.6683121876201461, 1.0) -(0.88696655132641289, 0.95557093425605533, 0.66560553633217989, 1.0) -(0.88327566320645901, 0.95409457900807382, 0.66289888504421368, 1.0) -(0.87958477508650512, 0.95261822376009231, 0.66019223375624758, 1.0) -(0.87589388696655135, 0.95114186851211069, 0.65748558246828137, 1.0) -(0.87220299884659747, 0.94966551326412918, 0.65477893118031516, 1.0) -(0.86851211072664358, 0.94818915801614767, 0.65207227989234906, 1.0) -(0.8648212226066897, 0.94671280276816605, 0.64936562860438285, 1.0) -(0.86113033448673582, 0.94523644752018454, 0.64665897731641675, 1.0) -(0.85743944636678204, 0.94376009227220303, 0.64395232602845054, 1.0) -(0.85374855824682816, 0.94228373702422141, 0.64124567474048444, 1.0) -(0.84962706651287967, 0.94059207996924254, 0.63856978085351779, 1.0) -(0.84421376393694736, 0.93825451749327182, 0.63598615916955015, 1.0) -(0.83880046136101505, 0.9359169550173011, 0.63340253748558251, 1.0) -(0.83338715878508263, 0.93357939254133027, 0.63081891580161475, 1.0) -(0.82797385620915032, 0.93124183006535943, 0.628235294117647, 1.0) -(0.82256055363321801, 0.92890426758938871, 0.62565167243367936, 1.0) -(0.8171472510572857, 0.92656670511341788, 0.62306805074971161, 1.0) -(0.81173394848135327, 0.92422914263744715, 0.62048442906574386, 1.0) -(0.80632064590542096, 0.92189158016147632, 0.61790080738177622, 1.0) -(0.80090734332948865, 0.9195540176855056, 0.61531718569780847, 1.0) -(0.79549404075355634, 0.91721645520953488, 0.61273356401384083, 1.0) -(0.79008073817762403, 0.91487889273356404, 0.61014994232987307, 1.0) -(0.78466743560169161, 0.91254133025759321, 0.60756632064590543, 1.0) -(0.7792541330257593, 0.91020376778162249, 0.60498269896193768, 1.0) -(0.77384083044982699, 0.90786620530565165, 0.60239907727797004, 1.0) -(0.76842752787389468, 0.90552864282968093, 0.59981545559400229, 1.0) -(0.76301422529796237, 0.9031910803537101, 0.59723183391003465, 1.0) -(0.75760092272202995, 0.90085351787773937, 0.5946482122260669, 1.0) -(0.75218762014609775, 0.89851595540176854, 0.59206459054209926, 1.0) -(0.74677431757016532, 0.89617839292579782, 0.5894809688581315, 1.0) -(0.74136101499423301, 0.89384083044982698, 0.58689734717416375, 1.0) -(0.7359477124183007, 0.89150326797385626, 0.58431372549019611, 1.0) -(0.73053440984236828, 0.88916570549788543, 0.58173010380622836, 1.0) -(0.72512110726643597, 0.88682814302191471, 0.57914648212226072, 1.0) -(0.71970780469050366, 0.88449058054594387, 0.57656286043829297, 1.0) -(0.71429450211457135, 0.88215301806997315, 0.57397923875432522, 1.0) -(0.70888119953863904, 0.87981545559400232, 0.57139561707035758, 1.0) -(0.70346789696270662, 0.87747789311803159, 0.56881199538638982, 1.0) -(0.69805459438677442, 0.87514033064206076, 0.56622837370242218, 1.0) -(0.692641291810842, 0.87280276816609004, 0.56364475201845443, 1.0) -(0.68722798923490969, 0.8704652056901192, 0.56106113033448679, 1.0) -(0.68181468665897738, 0.86812764321414848, 0.55847750865051904, 1.0) -(0.67598615916955018, 0.86560553633217996, 0.5558938869665514, 1.0) -(0.66946559015763174, 0.86277585544021529, 0.55331026528258365, 1.0) -(0.6629450211457133, 0.85994617454825073, 0.55072664359861601, 1.0) -(0.65642445213379474, 0.85711649365628606, 0.54814302191464825, 1.0) -(0.64990388312187619, 0.85428681276432139, 0.5455594002306805, 1.0) -(0.64338331410995775, 0.85145713187235683, 0.54297577854671286, 1.0) -(0.6368627450980392, 0.84862745098039216, 0.54039215686274511, 1.0) -(0.63034217608612075, 0.8457977700884276, 0.53780853517877736, 1.0) -(0.6238216070742022, 0.84296808919646293, 0.53522491349480972, 1.0) -(0.61730103806228376, 0.84013840830449826, 0.53264129181084197, 1.0) -(0.61078046905036532, 0.8373087274125337, 0.53005767012687433, 1.0) -(0.60425990003844676, 0.83447904652056903, 0.52747404844290657, 1.0) -(0.59773933102652832, 0.83164936562860436, 0.52489042675893882, 1.0) -(0.59121876201460977, 0.82881968473663981, 0.52230680507497118, 1.0) -(0.58469819300269132, 0.82599000384467514, 0.51972318339100343, 1.0) -(0.57817762399077277, 0.82316032295271047, 0.51713956170703579, 1.0) -(0.57165705497885433, 0.82033064206074591, 0.51455594002306804, 1.0) -(0.56513648596693578, 0.81750096116878124, 0.5119723183391004, 1.0) -(0.55861591695501744, 0.81467128027681668, 0.50938869665513264, 1.0) -(0.55209534794309878, 0.81184159938485201, 0.50680507497116489, 1.0) -(0.54557477893118034, 0.80901191849288734, 0.50422145328719725, 1.0) -(0.5390542099192619, 0.80618223760092278, 0.5016378316032295, 1.0) -(0.53253364090734334, 0.80335255670895811, 0.4990542099192618, 1.0) -(0.52601307189542479, 0.80052287581699355, 0.49647058823529411, 1.0) -(0.51949250288350635, 0.79769319492502888, 0.49388696655132641, 1.0) -(0.5129719338715879, 0.79486351403306421, 0.49130334486735872, 1.0) -(0.50645136485966946, 0.79203383314109965, 0.48871972318339102, 1.0) -(0.49993079584775091, 0.78920415224913498, 0.48613610149942327, 1.0) -(0.49341022683583236, 0.78637447135717031, 0.48355247981545557, 1.0) -(0.48688965782391391, 0.78354479046520575, 0.48096885813148788, 1.0) -(0.48036908881199536, 0.78071510957324108, 0.47838523644752018, 1.0) -(0.47384851980007692, 0.77788542868127641, 0.47580161476355248, 1.0) -(0.4672049211841599, 0.77480968858131494, 0.47278738946559012, 1.0) -(0.46043829296424449, 0.77148788927335643, 0.46934256055363321, 1.0) -(0.45367166474432907, 0.76816608996539792, 0.46589773164167625, 1.0) -(0.44690503652441366, 0.76484429065743942, 0.46245290272971934, 1.0) -(0.44013840830449846, 0.76152249134948102, 0.45900807381776249, 1.0) -(0.43337178008458282, 0.75820069204152252, 0.45556324490580546, 1.0) -(0.42660515186466741, 0.75487889273356401, 0.4521184159938485, 1.0) -(0.41983852364475199, 0.7515570934256055, 0.44867358708189153, 1.0) -(0.41307189542483658, 0.74823529411764711, 0.44522875816993462, 1.0) -(0.40630526720492116, 0.7449134948096886, 0.44178392925797766, 1.0) -(0.39953863898500575, 0.7415916955017301, 0.43833910034602075, 1.0) -(0.39277201076509033, 0.73826989619377159, 0.43489427143406378, 1.0) -(0.38600538254517491, 0.73494809688581308, 0.43144944252210687, 1.0) -(0.3792387543252595, 0.73162629757785469, 0.42800461361014991, 1.0) -(0.37247212610534408, 0.72830449826989618, 0.424559784698193, 1.0) -(0.36570549788542867, 0.72498269896193768, 0.42111495578623603, 1.0) -(0.35893886966551325, 0.72166089965397917, 0.41767012687427907, 1.0) -(0.35217224144559783, 0.71833910034602078, 0.41422529796232216, 1.0) -(0.34540561322568242, 0.71501730103806227, 0.41078046905036525, 1.0) -(0.338638985005767, 0.71169550173010376, 0.40733564013840828, 1.0) -(0.33187235678585175, 0.70837370242214537, 0.40389081122645143, 1.0) -(0.32510572856593611, 0.70505190311418686, 0.40044598231449441, 1.0) -(0.31833910034602075, 0.70173010380622836, 0.39700115340253744, 1.0) -(0.31157247212610528, 0.69840830449826985, 0.39355632449058053, 1.0) -(0.30480584390618992, 0.69508650519031134, 0.39011149557862357, 1.0) -(0.29803921568627445, 0.69176470588235284, 0.38666666666666666, 1.0) -(0.29127258746635909, 0.68844290657439444, 0.38322183775470969, 1.0) -(0.28450595924644362, 0.68512110726643594, 0.37977700884275278, 1.0) -(0.27773933102652826, 0.68179930795847743, 0.37633217993079582, 1.0) -(0.27097270280661279, 0.67847750865051903, 0.37288735101883885, 1.0) -(0.26420607458669743, 0.67515570934256053, 0.36944252210688194, 1.0) -(0.25743944636678195, 0.67183391003460202, 0.36599769319492503, 1.0) -(0.25259515570934254, 0.66758938869665507, 0.36270665128796614, 1.0) -(0.24890426758938869, 0.66279123414071506, 0.35950788158400615, 1.0) -(0.24521337946943481, 0.65799307958477504, 0.3563091118800461, 1.0) -(0.24152249134948095, 0.65319492502883503, 0.35311034217608611, 1.0) -(0.23783160322952721, 0.64839677047289512, 0.34991157247212618, 1.0) -(0.23414071510957324, 0.643598615916955, 0.34671280276816607, 1.0) -(0.23044982698961936, 0.63880046136101498, 0.34351403306420608, 1.0) -(0.2267589388696655, 0.63400230680507497, 0.34031526336024603, 1.0) -(0.22306805074971164, 0.62920415224913495, 0.33711649365628604, 1.0) -(0.21937716262975779, 0.62440599769319494, 0.333917723952326, 1.0) -(0.21568627450980393, 0.61960784313725492, 0.330718954248366, 1.0) -(0.21199538638985005, 0.61480968858131491, 0.32752018454440601, 1.0) -(0.20830449826989619, 0.61001153402537489, 0.32432141484044597, 1.0) -(0.20461361014994234, 0.60521337946943488, 0.32112264513648597, 1.0) -(0.20092272202998845, 0.60041522491349486, 0.31792387543252593, 1.0) -(0.1972318339100346, 0.59561707035755473, 0.31472510572856593, 1.0) -(0.19354094579008074, 0.59081891580161472, 0.31152633602460589, 1.0) -(0.18985005767012686, 0.5860207612456747, 0.3083275663206459, 1.0) -(0.186159169550173, 0.58122260668973469, 0.3051287966166859, 1.0) -(0.18246828143021915, 0.57642445213379467, 0.30193002691272586, 1.0) -(0.17877739331026538, 0.57162629757785477, 0.29873125720876592, 1.0) -(0.17508650519031144, 0.56682814302191464, 0.29553248750480587, 1.0) -(0.17139561707035755, 0.56202998846597463, 0.29233371780084583, 1.0) -(0.1677047289504037, 0.55723183391003461, 0.28913494809688578, 1.0) -(0.16401384083044984, 0.5524336793540946, 0.28593617839292579, 1.0) -(0.16032295271049596, 0.54763552479815458, 0.2827374086889658, 1.0) -(0.1566320645905421, 0.54283737024221457, 0.27953863898500575, 1.0) -(0.15294117647058825, 0.53803921568627455, 0.27633986928104576, 1.0) -(0.14925028835063436, 0.53324106113033454, 0.27314109957708577, 1.0) -(0.14555940023068051, 0.52844290657439452, 0.26994232987312572, 1.0) -(0.14186851211072665, 0.52364475201845451, 0.26674356016916573, 1.0) -(0.13817762399077277, 0.51884659746251449, 0.26354479046520568, 1.0) -(0.13402537485582469, 0.51506343713956171, 0.26163783160322956, 1.0) -(0.12971933871587851, 0.51161860822760485, 0.260161476355248, 1.0) -(0.12541330257593233, 0.50817377931564789, 0.25868512110726644, 1.0) -(0.12110726643598617, 0.50472895040369092, 0.25720876585928493, 1.0) -(0.11680123029604011, 0.50128412149173407, 0.25573241061130342, 1.0) -(0.11249519415609383, 0.49783929257977705, 0.2542560553633218, 1.0) -(0.10818915801614765, 0.49439446366782008, 0.25277970011534029, 1.0) -(0.10388312187620147, 0.49094963475586317, 0.25130334486735872, 1.0) -(0.099577085736255289, 0.48750480584390621, 0.24982698961937716, 1.0) -(0.09527104959630911, 0.4840599769319493, 0.24835063437139562, 1.0) -(0.090965013456362945, 0.48061514801999233, 0.24687427912341409, 1.0) -(0.086658977316416766, 0.47717031910803542, 0.24539792387543252, 1.0) -(0.082352941176470601, 0.47372549019607846, 0.24392156862745099, 1.0) -(0.078046905036524422, 0.47028066128412149, 0.24244521337946945, 1.0) -(0.073740868896578243, 0.46683583237216458, 0.24096885813148788, 1.0) -(0.069434832756632064, 0.46339100346020762, 0.23949250288350635, 1.0) -(0.065128796616685899, 0.45994617454825071, 0.23801614763552481, 1.0) -(0.060822760476739721, 0.45650134563629374, 0.23653979238754327, 1.0) -(0.056516724336793542, 0.45305651672433678, 0.23506343713956171, 1.0) -(0.052210688196847363, 0.44961168781237987, 0.23358708189158017, 1.0) -(0.047904652056901309, 0.44616685890042301, 0.23211072664359866, 1.0) -(0.043598615916955019, 0.44272202998846599, 0.23063437139561707, 1.0) -(0.03929257977700884, 0.43927720107650903, 0.22915801614763553, 1.0) -(0.034986543637062675, 0.43583237216455212, 0.227681660899654, 1.0) -(0.030680507497116496, 0.43238754325259515, 0.22620530565167243, 1.0) -(0.026374471357170318, 0.42894271434063824, 0.2247289504036909, 1.0) -(0.022068435217224139, 0.42549788542868128, 0.22325259515570936, 1.0) -(0.017762399077277974, 0.42205305651672431, 0.22177623990772782, 1.0) -(0.013456362937331795, 0.4186082276047674, 0.22029988465974626, 1.0) -(0.0091503267973856162, 0.41516339869281044, 0.21882352941176472, 1.0) -(0.0048442906574394373, 0.41171856978085353, 0.21734717416378319, 1.0) -(0.00053825451749325848, 0.40827374086889656, 0.21587081891580162, 1.0) -(0.0, 0.40407535563244906, 0.21417916186082278, 1.0) -(0.0, 0.39976931949250288, 0.2124567474048443, 1.0) -(0.0, 0.3954632833525567, 0.21073433294886584, 1.0) -(0.0, 0.39115724721261053, 0.20901191849288736, 1.0) -(0.0, 0.38685121107266446, 0.20728950403690893, 1.0) -(0.0, 0.38254517493271817, 0.20556708958093042, 1.0) -(0.0, 0.37823913879277199, 0.20384467512495194, 1.0) -(0.0, 0.37393310265282581, 0.20212226066897349, 1.0) -(0.0, 0.36962706651287963, 0.200399846212995, 1.0) -(0.0, 0.36532103037293345, 0.19867743175701655, 1.0) -(0.0, 0.36101499423298733, 0.19695501730103807, 1.0) -(0.0, 0.35670895809304115, 0.19523260284505961, 1.0) -(0.0, 0.35240292195309497, 0.19351018838908113, 1.0) -(0.0, 0.34809688581314879, 0.19178777393310267, 1.0) -(0.0, 0.34379084967320261, 0.19006535947712419, 1.0) -(0.0, 0.33948481353325644, 0.18834294502114574, 1.0) -(0.0, 0.33517877739331026, 0.18662053056516725, 1.0) -(0.0, 0.33087274125336408, 0.18489811610918877, 1.0) -(0.0, 0.3265667051134179, 0.18317570165321032, 1.0) -(0.0, 0.32226066897347172, 0.18145328719723186, 1.0) -(0.0, 0.31795463283352565, 0.17973087274125343, 1.0) -(0.0, 0.31364859669357936, 0.1780084582852749, 1.0) -(0.0, 0.30934256055363318, 0.17628604382929644, 1.0) -(0.0, 0.305036524413687, 0.17456362937331796, 1.0) -(0.0, 0.30073048827374083, 0.1728412149173395, 1.0) -(0.0, 0.29642445213379465, 0.17111880046136102, 1.0) -(0.0, 0.29211841599384852, 0.16939638600538257, 1.0) -(0.0, 0.28781237985390234, 0.16767397154940408, 1.0) -(0.0, 0.28350634371395617, 0.16595155709342563, 1.0) -(0.0, 0.27920030757400999, 0.16422914263744715, 1.0) -(0.0, 0.27489427143406381, 0.16250672818146866, 1.0) -(0.0, 0.27058823529411763, 0.16078431372549021, 1.0) diff --git a/extern/tfn/colormaps/sequential/YlGnBu.cpp b/extern/tfn/colormaps/sequential/YlGnBu.cpp deleted file mode 100644 index fb9bc7e..0000000 --- a/extern/tfn/colormaps/sequential/YlGnBu.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential_YlGnBu; -} -const std::vector colormap::data_sequential_YlGnBu = /* NOLINT(cert-err58-cpp) */ -{ -{1.0f, 1.0f, 0.85098039215686272f, 1.0f}, -{0.99778546712802774f, 0.99913879277201079f, 0.84605920799692425f, 1.0f}, -{0.99557093425605536f, 0.99827758554402157f, 0.84113802383698577f, 1.0f}, -{0.9933564013840831f, 0.99741637831603225f, 0.8362168396770473f, 1.0f}, -{0.99114186851211072f, 0.99655517108804303f, 0.83129565551710882f, 1.0f}, -{0.98892733564013846f, 0.99569396386005382f, 0.82637447135717035f, 1.0f}, -{0.98671280276816609f, 0.99483275663206461f, 0.82145328719723176f, 1.0f}, -{0.98449826989619382f, 0.99397154940407539f, 0.81653210303729329f, 1.0f}, -{0.98228373702422145f, 0.99311034217608607f, 0.81161091887735481f, 1.0f}, -{0.98006920415224918f, 0.99224913494809686f, 0.80668973471741634f, 1.0f}, -{0.97785467128027681f, 0.99138792772010764f, 0.80176855055747787f, 1.0f}, -{0.97564013840830455f, 0.99052672049211843f, 0.79684736639753939f, 1.0f}, -{0.97342560553633217f, 0.98966551326412922f, 0.79192618223760092f, 1.0f}, -{0.97121107266435991f, 0.98880430603613989f, 0.78700499807766244f, 1.0f}, -{0.96899653979238753f, 0.98794309880815068f, 0.78208381391772397f, 1.0f}, -{0.96678200692041527f, 0.98708189158016146f, 0.77716262975778538f, 1.0f}, -{0.9645674740484429f, 0.98622068435217225f, 0.77224144559784702f, 1.0f}, -{0.96235294117647063f, 0.98535947712418304f, 0.76732026143790844f, 1.0f}, -{0.96013840830449826f, 0.98449826989619371f, 0.76239907727796996f, 1.0f}, -{0.957923875432526f, 0.9836370626682045f, 0.75747789311803149f, 1.0f}, -{0.95570934256055362f, 0.98277585544021528f, 0.75255670895809301f, 1.0f}, -{0.95349480968858136f, 0.98191464821222607f, 0.74763552479815454f, 1.0f}, -{0.95128027681660898f, 0.98105344098423686f, 0.74271434063821606f, 1.0f}, -{0.94906574394463672f, 0.98019223375624764f, 0.73779315647827759f, 1.0f}, -{0.94685121107266434f, 0.97933102652825832f, 0.73287197231833912f, 1.0f}, -{0.94463667820069208f, 0.97846981930026911f, 0.72795078815840064f, 1.0f}, -{0.94242214532871971f, 0.97760861207227989f, 0.72302960399846206f, 1.0f}, -{0.94020761245674744f, 0.97674740484429068f, 0.71810841983852358f, 1.0f}, -{0.93799307958477507f, 0.97588619761630135f, 0.71318723567858511f, 1.0f}, -{0.93577854671280281f, 0.97502499038831214f, 0.70826605151864663f, 1.0f}, -{0.93356401384083043f, 0.97416378316032293f, 0.70334486735870816f, 1.0f}, -{0.93134948096885817f, 0.97330257593233371f, 0.69842368319876968f, 1.0f}, -{0.92882737408688965f, 0.97231833910034604f, 0.6941637831603229f, 1.0f}, -{0.9241522491349482f, 0.97047289504036904f, 0.69453287197231828f, 1.0f}, -{0.91947712418300653f, 0.96862745098039216f, 0.69490196078431365f, 1.0f}, -{0.91480199923106498f, 0.96678200692041516f, 0.69527104959630914f, 1.0f}, -{0.91012687427912342f, 0.96493656286043827f, 0.69564013840830452f, 1.0f}, -{0.90545174932718187f, 0.96309111880046139f, 0.6960092272202999f, 1.0f}, -{0.90077662437524031f, 0.96124567474048439f, 0.69637831603229527f, 1.0f}, -{0.89610149942329875f, 0.9594002306805075f, 0.69674740484429065f, 1.0f}, -{0.8914263744713572f, 0.95755478662053051f, 0.69711649365628603f, 1.0f}, -{0.88675124951941564f, 0.95570934256055362f, 0.69748558246828141f, 1.0f}, -{0.88207612456747408f, 0.95386389850057673f, 0.69785467128027678f, 1.0f}, -{0.87740099961553253f, 0.95201845444059974f, 0.69822376009227216f, 1.0f}, -{0.87272587466359097f, 0.95017301038062285f, 0.69859284890426754f, 1.0f}, -{0.86805074971164942f, 0.94832756632064585f, 0.69896193771626303f, 1.0f}, -{0.86337562475970786f, 0.94648212226066897f, 0.6993310265282584f, 1.0f}, -{0.8587004998077663f, 0.94463667820069197f, 0.69970011534025378f, 1.0f}, -{0.85402537485582475f, 0.94279123414071508f, 0.70006920415224916f, 1.0f}, -{0.84935024990388319f, 0.9409457900807382f, 0.70043829296424454f, 1.0f}, -{0.84467512495194152f, 0.9391003460207612f, 0.70080738177623991f, 1.0f}, -{0.83999999999999997f, 0.93725490196078431f, 0.70117647058823529f, 1.0f}, -{0.83532487504805841f, 0.93540945790080732f, 0.70154555940023067f, 1.0f}, -{0.83064975009611697f, 0.93356401384083043f, 0.70191464821222604f, 1.0f}, -{0.8259746251441753f, 0.93171856978085354f, 0.70228373702422142f, 1.0f}, -{0.82129950019223374f, 0.92987312572087655f, 0.70265282583621691f, 1.0f}, -{0.81662437524029219f, 0.92802768166089966f, 0.70302191464821229f, 1.0f}, -{0.81194925028835063f, 0.92618223760092266f, 0.70339100346020766f, 1.0f}, -{0.80727412533640908f, 0.92433679354094578f, 0.70376009227220304f, 1.0f}, -{0.80259900038446752f, 0.92249134948096878f, 0.70412918108419842f, 1.0f}, -{0.79792387543252596f, 0.92064590542099189f, 0.7044982698961938f, 1.0f}, -{0.79324875048058441f, 0.91880046136101501f, 0.70486735870818917f, 1.0f}, -{0.78857362552864285f, 0.91695501730103801f, 0.70523644752018455f, 1.0f}, -{0.7838985005767013f, 0.91510957324106112f, 0.70560553633217993f, 1.0f}, -{0.77817762399077284f, 0.91286428296808919f, 0.70609765474817388f, 1.0f}, -{0.76931949250288356f, 0.90941945405613223f, 0.70695886197616309f, 1.0f}, -{0.7604613610149944f, 0.90597462514417537f, 0.7078200692041523f, 1.0f}, -{0.75160322952710501f, 0.90252979623221841f, 0.70868127643214152f, 1.0f}, -{0.74274509803921573f, 0.89908496732026144f, 0.70954248366013073f, 1.0f}, -{0.73388696655132646f, 0.89564013840830448f, 0.71040369088811994f, 1.0f}, -{0.72502883506343718f, 0.89219530949634751f, 0.71126489811610927f, 1.0f}, -{0.71617070357554791f, 0.88875048058439066f, 0.71212610534409848f, 1.0f}, -{0.70731257208765863f, 0.88530565167243369f, 0.71298731257208769f, 1.0f}, -{0.69845444059976936f, 0.88186082276047673f, 0.71384851980007691f, 1.0f}, -{0.68959630911188019f, 0.87841599384851987f, 0.71470972702806612f, 1.0f}, -{0.6807381776239908f, 0.8749711649365628f, 0.71557093425605534f, 1.0f}, -{0.67188004613610153f, 0.87152633602460594f, 0.71643214148404466f, 1.0f}, -{0.66302191464821225f, 0.86808150711264898f, 0.71729334871203387f, 1.0f}, -{0.65416378316032298f, 0.86463667820069201f, 0.71815455594002309f, 1.0f}, -{0.6453056516724337f, 0.86119184928873516f, 0.7190157631680123f, 1.0f}, -{0.63644752018454442f, 0.85774702037677819f, 0.71987697039600151f, 1.0f}, -{0.62758938869665515f, 0.85430219146482123f, 0.72073817762399073f, 1.0f}, -{0.61873125720876598f, 0.85085736255286437f, 0.72159938485197994f, 1.0f}, -{0.6098731257208766f, 0.8474125336409073f, 0.72246059207996927f, 1.0f}, -{0.60101499423298732f, 0.84396770472895044f, 0.72332179930795848f, 1.0f}, -{0.59215686274509804f, 0.84052287581699348f, 0.72418300653594769f, 1.0f}, -{0.58329873125720877f, 0.83707804690503651f, 0.72504421376393691f, 1.0f}, -{0.57444059976931949f, 0.83363321799307966f, 0.72590542099192612f, 1.0f}, -{0.56558246828143022f, 0.83018838908112269f, 0.72676662821991544f, 1.0f}, -{0.55672433679354094f, 0.82674356016916573f, 0.72762783544790466f, 1.0f}, -{0.54786620530565178f, 0.82329873125720887f, 0.72848904267589387f, 1.0f}, -{0.53900807381776239f, 0.81985390234525179f, 0.72935024990388309f, 1.0f}, -{0.53014994232987322f, 0.81640907343329494f, 0.7302114571318723f, 1.0f}, -{0.52129181084198395f, 0.81296424452133798f, 0.73107266435986151f, 1.0f}, -{0.51243367935409467f, 0.80951941560938101f, 0.73193387158785073f, 1.0f}, -{0.5035755478662054f, 0.80607458669742416f, 0.73279507881584005f, 1.0f}, -{0.49517877739331029f, 0.80286043829296427f, 0.73374855824682805f, 1.0f}, -{0.4875509419454056f, 0.8000307574009996f, 0.7348558246828143f, 1.0f}, -{0.47992310649750108f, 0.79720107650903504f, 0.73596309111880043f, 1.0f}, -{0.47229527104959629f, 0.79437139561707037f, 0.73707035755478656f, 1.0f}, -{0.46466743560169166f, 0.79154171472510571f, 0.73817762399077269f, 1.0f}, -{0.45703960015378703f, 0.78871203383314115f, 0.73928489042675893f, 1.0f}, -{0.44941176470588234f, 0.78588235294117648f, 0.74039215686274507f, 1.0f}, -{0.44178392925797771f, 0.78305267204921192f, 0.7414994232987312f, 1.0f}, -{0.43415609381007303f, 0.78022299115724725f, 0.74260668973471744f, 1.0f}, -{0.4265282583621684f, 0.77739331026528258f, 0.74371395617070357f, 1.0f}, -{0.41890042291426388f, 0.77456362937331802f, 0.7448212226066897f, 1.0f}, -{0.41127258746635909f, 0.77173394848135335f, 0.74592848904267584f, 1.0f}, -{0.40364475201845446f, 0.76890426758938868f, 0.74703575547866208f, 1.0f}, -{0.39601691657054977f, 0.76607458669742412f, 0.74814302191464821f, 1.0f}, -{0.38838908112264514f, 0.76324490580545945f, 0.74925028835063434f, 1.0f}, -{0.38076124567474046f, 0.76041522491349478f, 0.75035755478662047f, 1.0f}, -{0.37313341022683583f, 0.75758554402153022f, 0.75146482122260672f, 1.0f}, -{0.3655055747789312f, 0.75475586312956555f, 0.75257208765859285f, 1.0f}, -{0.35787773933102662f, 0.75192618223760099f, 0.75367935409457898f, 1.0f}, -{0.35024990388312188f, 0.74909650134563632f, 0.75478662053056522f, 1.0f}, -{0.34262206843521725f, 0.74626682045367165f, 0.75589388696655135f, 1.0f}, -{0.33499423298731257f, 0.74343713956170709f, 0.75700115340253749f, 1.0f}, -{0.32736639753940788f, 0.74060745866974242f, 0.75810841983852362f, 1.0f}, -{0.31973856209150331f, 0.73777777777777787f, 0.75921568627450986f, 1.0f}, -{0.31211072664359862f, 0.7349480968858132f, 0.76032295271049599f, 1.0f}, -{0.30448289119569394f, 0.73211841599384853f, 0.76143021914648212f, 1.0f}, -{0.29685505574778942f, 0.72928873510188397f, 0.76253748558246826f, 1.0f}, -{0.28922722029988468f, 0.7264590542099193f, 0.7636447520184545f, 1.0f}, -{0.28159938485197999f, 0.72362937331795463f, 0.76475201845444063f, 1.0f}, -{0.27397154940407537f, 0.72079969242599007f, 0.76585928489042676f, 1.0f}, -{0.26634371395617074f, 0.7179700115340254f, 0.766966551326413f, 1.0f}, -{0.25871587850826605f, 0.71514033064206073f, 0.76807381776239914f, 1.0f}, -{0.25268742791234139f, 0.71144944252210685f, 0.76838139177239528f, 1.0f}, -{0.24825836216839675f, 0.70689734717416375f, 0.76788927335640145f, 1.0f}, -{0.24382929642445211f, 0.70234525182622065f, 0.76739715494040761f, 1.0f}, -{0.23940023068050748f, 0.69779315647827755f, 0.76690503652441377f, 1.0f}, -{0.23497116493656298f, 0.69324106113033468f, 0.76641291810841994f, 1.0f}, -{0.2305420991926182f, 0.68868896578239136f, 0.76592079969242599f, 1.0f}, -{0.22611303344867356f, 0.68413687043444826f, 0.76542868127643215f, 1.0f}, -{0.22168396770472892f, 0.67958477508650517f, 0.76493656286043832f, 1.0f}, -{0.21725490196078429f, 0.67503267973856207f, 0.76444444444444448f, 1.0f}, -{0.21282583621683965f, 0.67048058439061897f, 0.76395232602845065f, 1.0f}, -{0.20839677047289501f, 0.66592848904267588f, 0.76346020761245681f, 1.0f}, -{0.20396770472895037f, 0.66137639369473278f, 0.76296808919646297f, 1.0f}, -{0.19953863898500573f, 0.65682429834678968f, 0.76247597078046903f, 1.0f}, -{0.19510957324106112f, 0.65227220299884658f, 0.76198385236447519f, 1.0f}, -{0.19068050749711646f, 0.64772010765090349f, 0.76149173394848135f, 1.0f}, -{0.18625144175317185f, 0.64316801230296039f, 0.76099961553248752f, 1.0f}, -{0.18182237600922718f, 0.63861591695501729f, 0.76050749711649368f, 1.0f}, -{0.17739331026528254f, 0.6340638216070742f, 0.76001537870049984f, 1.0f}, -{0.17296424452133791f, 0.6295117262591311f, 0.75952326028450601f, 1.0f}, -{0.16853517877739327f, 0.624959630911188f, 0.75903114186851217f, 1.0f}, -{0.16410611303344877f, 0.62040753556324502f, 0.75853902345251834f, 1.0f}, -{0.15967704728950402f, 0.61585544021530181f, 0.75804690503652439f, 1.0f}, -{0.15524798154555938f, 0.61130334486735871f, 0.75755478662053055f, 1.0f}, -{0.15081891580161474f, 0.60675124951941561f, 0.75706266820453672f, 1.0f}, -{0.14638985005767011f, 0.60219915417147252f, 0.75657054978854288f, 1.0f}, -{0.14196078431372547f, 0.59764705882352942f, 0.75607843137254904f, 1.0f}, -{0.13753171856978083f, 0.59309496347558632f, 0.75558631295655521f, 1.0f}, -{0.13310265282583619f, 0.58854286812764323f, 0.75509419454056137f, 1.0f}, -{0.12867358708189156f, 0.58399077277970013f, 0.75460207612456742f, 1.0f}, -{0.12424452133794692f, 0.57943867743175703f, 0.75410995770857359f, 1.0f}, -{0.11981545559400228f, 0.57488658208381382f, 0.75361783929257975f, 1.0f}, -{0.11538638985005764f, 0.57033448673587084f, 0.75312572087658591f, 1.0f}, -{0.11410995770857363f, 0.56470588235294117f, 0.75109573241061134f, 1.0f}, -{0.11472510572856594f, 0.55843137254901953f, 0.74814302191464821f, 1.0f}, -{0.11534025374855825f, 0.55215686274509801f, 0.74519031141868508f, 1.0f}, -{0.11595540176855056f, 0.54588235294117649f, 0.74223760092272206f, 1.0f}, -{0.11657054978854285f, 0.53960784313725507f, 0.73928489042675904f, 1.0f}, -{0.11718569780853517f, 0.53333333333333333f, 0.7363321799307958f, 1.0f}, -{0.11780084582852748f, 0.5270588235294118f, 0.73337946943483279f, 1.0f}, -{0.11841599384851979f, 0.52078431372549017f, 0.73042675893886966f, 1.0f}, -{0.1190311418685121f, 0.51450980392156864f, 0.72747404844290653f, 1.0f}, -{0.11964628988850443f, 0.50823529411764701f, 0.72452133794694351f, 1.0f}, -{0.12026143790849673f, 0.50196078431372548f, 0.72156862745098038f, 1.0f}, -{0.12087658592848904f, 0.4956862745098039f, 0.71861591695501725f, 1.0f}, -{0.12149173394848135f, 0.48941176470588232f, 0.71566320645905424f, 1.0f}, -{0.12210688196847366f, 0.4831372549019608f, 0.71271049596309111f, 1.0f}, -{0.12272202998846597f, 0.47686274509803922f, 0.70975778546712798f, 1.0f}, -{0.12333717800845828f, 0.47058823529411764f, 0.70680507497116496f, 1.0f}, -{0.12395232602845059f, 0.46431372549019606f, 0.70385236447520183f, 1.0f}, -{0.1245674740484429f, 0.45803921568627448f, 0.7008996539792387f, 1.0f}, -{0.12518262206843522f, 0.45176470588235296f, 0.69794694348327568f, 1.0f}, -{0.12579777008842752f, 0.44549019607843138f, 0.69499423298731255f, 1.0f}, -{0.12641291810841981f, 0.43921568627451002f, 0.69204152249134954f, 1.0f}, -{0.12702806612841214f, 0.43294117647058827f, 0.68908881199538641f, 1.0f}, -{0.12764321414840446f, 0.42666666666666664f, 0.68613610149942328f, 1.0f}, -{0.12825836216839676f, 0.42039215686274511f, 0.68318339100346015f, 1.0f}, -{0.12887351018838908f, 0.41411764705882353f, 0.68023068050749713f, 1.0f}, -{0.1294886582083814f, 0.40784313725490196f, 0.677277970011534f, 1.0f}, -{0.1301038062283737f, 0.40156862745098043f, 0.67432525951557087f, 1.0f}, -{0.13071895424836602f, 0.3952941176470588f, 0.67137254901960786f, 1.0f}, -{0.13133410226835832f, 0.38901960784313727f, 0.66841983852364473f, 1.0f}, -{0.13194925028835064f, 0.38274509803921569f, 0.6654671280276816f, 1.0f}, -{0.13256439830834293f, 0.37647058823529411f, 0.66251441753171858f, 1.0f}, -{0.13317954632833526f, 0.37019607843137259f, 0.65956170703575545f, 1.0f}, -{0.13361014994232986f, 0.36475201845444061f, 0.65697808535178781f, 1.0f}, -{0.13397923875432527f, 0.35958477508650522f, 0.65451749327181852f, 1.0f}, -{0.13434832756632065f, 0.35441753171856982f, 0.65205690119184934f, 1.0f}, -{0.13471741637831602f, 0.34925028835063437f, 0.64959630911188004f, 1.0f}, -{0.1350865051903114f, 0.34408304498269915f, 0.64713571703191086f, 1.0f}, -{0.13545559400230681f, 0.33891580161476359f, 0.64467512495194157f, 1.0f}, -{0.13582468281430218f, 0.33374855824682814f, 0.64221453287197228f, 1.0f}, -{0.13619377162629759f, 0.32858131487889275f, 0.6397539407920031f, 1.0f}, -{0.13656286043829297f, 0.32341407151095736f, 0.6372933487120338f, 1.0f}, -{0.13693194925028834f, 0.31824682814302191f, 0.63483275663206462f, 1.0f}, -{0.13730103806228375f, 0.31307958477508652f, 0.63237216455209533f, 1.0f}, -{0.13767012687427913f, 0.30791234140715112f, 0.62991157247212615f, 1.0f}, -{0.1380392156862745f, 0.30274509803921568f, 0.62745098039215685f, 1.0f}, -{0.13840830449826991f, 0.29757785467128028f, 0.62499038831218767f, 1.0f}, -{0.13877739331026528f, 0.29241061130334489f, 0.62252979623221838f, 1.0f}, -{0.13914648212226066f, 0.28724336793540944f, 0.6200692041522492f, 1.0f}, -{0.13951557093425607f, 0.28207612456747405f, 0.61760861207227991f, 1.0f}, -{0.13988465974625144f, 0.27690888119953866f, 0.61514801999231072f, 1.0f}, -{0.14025374855824682f, 0.27174163783160321f, 0.61268742791234143f, 1.0f}, -{0.14062283737024223f, 0.26657439446366782f, 0.61022683583237214f, 1.0f}, -{0.1409919261822376f, 0.26140715109573254f, 0.60776624375240307f, 1.0f}, -{0.14136101499423298f, 0.25623990772779703f, 0.60530565167243366f, 1.0f}, -{0.14173010380622839f, 0.25107266435986159f, 0.60284505959246448f, 1.0f}, -{0.14209919261822376f, 0.24590542099192619f, 0.60038446751249519f, 1.0f}, -{0.14246828143021917f, 0.24073817762399077f, 0.59792387543252601f, 1.0f}, -{0.14283737024221455f, 0.23557093425605535f, 0.59546328335255672f, 1.0f}, -{0.14320645905420992f, 0.23040369088811996f, 0.59300269127258753f, 1.0f}, -{0.14357554786620533f, 0.22523644752018454f, 0.59054209919261824f, 1.0f}, -{0.1439446366782007f, 0.22006920415224912f, 0.58808150711264906f, 1.0f}, -{0.14431372549019608f, 0.21490196078431373f, 0.58562091503267977f, 1.0f}, -{0.14468281430219149f, 0.20973471741637831f, 0.58316032295271059f, 1.0f}, -{0.14505190311418686f, 0.20456747404844289f, 0.58069973087274129f, 1.0f}, -{0.1419761630142253f, 0.20144559784698193f, 0.57393310265282593f, 1.0f}, -{0.13840830449826991f, 0.19861591695501729f, 0.56655132641291817f, 1.0f}, -{0.13484044598231451f, 0.19578623606305268f, 0.5591695501730104f, 1.0f}, -{0.13127258746635911f, 0.19295655517108803f, 0.55178777393310274f, 1.0f}, -{0.1277047289504038f, 0.1901268742791235f, 0.5444059976931952f, 1.0f}, -{0.12413687043444829f, 0.18729719338715878f, 0.53702422145328721f, 1.0f}, -{0.1205690119184929f, 0.18446751249519416f, 0.52964244521337955f, 1.0f}, -{0.1170011534025375f, 0.18163783160322952f, 0.52226066897347179f, 1.0f}, -{0.11343329488658209f, 0.17880815071126488f, 0.51487889273356402f, 1.0f}, -{0.10986543637062668f, 0.17597846981930026f, 0.50749711649365636f, 1.0f}, -{0.10629757785467128f, 0.17314878892733565f, 0.5001153402537486f, 1.0f}, -{0.10272971933871589f, 0.17031910803537101f, 0.49273356401384083f, 1.0f}, -{0.099161860822760489f, 0.16748942714340637f, 0.48535178777393312f, 1.0f}, -{0.095594002306805079f, 0.16465974625144175f, 0.47797001153402541f, 1.0f}, -{0.092026143790849668f, 0.16183006535947714f, 0.47058823529411764f, 1.0f}, -{0.088458285274894272f, 0.1590003844675125f, 0.46320645905420993f, 1.0f}, -{0.084890426758938875f, 0.15617070357554785f, 0.45582468281430222f, 1.0f}, -{0.081322568242983478f, 0.15334102268358324f, 0.44844290657439445f, 1.0f}, -{0.077754709727028068f, 0.1505113417916186f, 0.44106113033448674f, 1.0f}, -{0.074186851211072671f, 0.14768166089965398f, 0.43367935409457903f, 1.0f}, -{0.070618992695117372f, 0.14485198000768942f, 0.42629757785467148f, 1.0f}, -{0.067051134179161864f, 0.14202229911572473f, 0.41891580161476355f, 1.0f}, -{0.063483275663206468f, 0.13919261822376008f, 0.41153402537485584f, 1.0f}, -{0.059915417147251057f, 0.13636293733179544f, 0.40415224913494807f, 1.0f}, -{0.056347558631295661f, 0.13353325643983083f, 0.39677047289504042f, 1.0f}, -{0.05277970011534025f, 0.13070357554786621f, 0.38938869665513265f, 1.0f}, -{0.049211841599384853f, 0.12787389465590157f, 0.38200692041522488f, 1.0f}, -{0.045643983083429457f, 0.12504421376393693f, 0.37462514417531723f, 1.0f}, -{0.042076124567474046f, 0.12221453287197231f, 0.36724336793540946f, 1.0f}, -{0.03850826605151865f, 0.11938485198000769f, 0.35986159169550169f, 1.0f}, -{0.034940407535563239f, 0.11655517108804306f, 0.35247981545559404f, 1.0f}, -{0.031372549019607843f, 0.11372549019607843f, 0.34509803921568627f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential/YlGnBu.txt b/extern/tfn/colormaps/sequential/YlGnBu.txt deleted file mode 100644 index ebae9ed..0000000 --- a/extern/tfn/colormaps/sequential/YlGnBu.txt +++ /dev/null @@ -1,256 +0,0 @@ -(1.0, 1.0, 0.85098039215686272, 1.0) -(0.99778546712802774, 0.99913879277201079, 0.84605920799692425, 1.0) -(0.99557093425605536, 0.99827758554402157, 0.84113802383698577, 1.0) -(0.9933564013840831, 0.99741637831603225, 0.8362168396770473, 1.0) -(0.99114186851211072, 0.99655517108804303, 0.83129565551710882, 1.0) -(0.98892733564013846, 0.99569396386005382, 0.82637447135717035, 1.0) -(0.98671280276816609, 0.99483275663206461, 0.82145328719723176, 1.0) -(0.98449826989619382, 0.99397154940407539, 0.81653210303729329, 1.0) -(0.98228373702422145, 0.99311034217608607, 0.81161091887735481, 1.0) -(0.98006920415224918, 0.99224913494809686, 0.80668973471741634, 1.0) -(0.97785467128027681, 0.99138792772010764, 0.80176855055747787, 1.0) -(0.97564013840830455, 0.99052672049211843, 0.79684736639753939, 1.0) -(0.97342560553633217, 0.98966551326412922, 0.79192618223760092, 1.0) -(0.97121107266435991, 0.98880430603613989, 0.78700499807766244, 1.0) -(0.96899653979238753, 0.98794309880815068, 0.78208381391772397, 1.0) -(0.96678200692041527, 0.98708189158016146, 0.77716262975778538, 1.0) -(0.9645674740484429, 0.98622068435217225, 0.77224144559784702, 1.0) -(0.96235294117647063, 0.98535947712418304, 0.76732026143790844, 1.0) -(0.96013840830449826, 0.98449826989619371, 0.76239907727796996, 1.0) -(0.957923875432526, 0.9836370626682045, 0.75747789311803149, 1.0) -(0.95570934256055362, 0.98277585544021528, 0.75255670895809301, 1.0) -(0.95349480968858136, 0.98191464821222607, 0.74763552479815454, 1.0) -(0.95128027681660898, 0.98105344098423686, 0.74271434063821606, 1.0) -(0.94906574394463672, 0.98019223375624764, 0.73779315647827759, 1.0) -(0.94685121107266434, 0.97933102652825832, 0.73287197231833912, 1.0) -(0.94463667820069208, 0.97846981930026911, 0.72795078815840064, 1.0) -(0.94242214532871971, 0.97760861207227989, 0.72302960399846206, 1.0) -(0.94020761245674744, 0.97674740484429068, 0.71810841983852358, 1.0) -(0.93799307958477507, 0.97588619761630135, 0.71318723567858511, 1.0) -(0.93577854671280281, 0.97502499038831214, 0.70826605151864663, 1.0) -(0.93356401384083043, 0.97416378316032293, 0.70334486735870816, 1.0) -(0.93134948096885817, 0.97330257593233371, 0.69842368319876968, 1.0) -(0.92882737408688965, 0.97231833910034604, 0.6941637831603229, 1.0) -(0.9241522491349482, 0.97047289504036904, 0.69453287197231828, 1.0) -(0.91947712418300653, 0.96862745098039216, 0.69490196078431365, 1.0) -(0.91480199923106498, 0.96678200692041516, 0.69527104959630914, 1.0) -(0.91012687427912342, 0.96493656286043827, 0.69564013840830452, 1.0) -(0.90545174932718187, 0.96309111880046139, 0.6960092272202999, 1.0) -(0.90077662437524031, 0.96124567474048439, 0.69637831603229527, 1.0) -(0.89610149942329875, 0.9594002306805075, 0.69674740484429065, 1.0) -(0.8914263744713572, 0.95755478662053051, 0.69711649365628603, 1.0) -(0.88675124951941564, 0.95570934256055362, 0.69748558246828141, 1.0) -(0.88207612456747408, 0.95386389850057673, 0.69785467128027678, 1.0) -(0.87740099961553253, 0.95201845444059974, 0.69822376009227216, 1.0) -(0.87272587466359097, 0.95017301038062285, 0.69859284890426754, 1.0) -(0.86805074971164942, 0.94832756632064585, 0.69896193771626303, 1.0) -(0.86337562475970786, 0.94648212226066897, 0.6993310265282584, 1.0) -(0.8587004998077663, 0.94463667820069197, 0.69970011534025378, 1.0) -(0.85402537485582475, 0.94279123414071508, 0.70006920415224916, 1.0) -(0.84935024990388319, 0.9409457900807382, 0.70043829296424454, 1.0) -(0.84467512495194152, 0.9391003460207612, 0.70080738177623991, 1.0) -(0.83999999999999997, 0.93725490196078431, 0.70117647058823529, 1.0) -(0.83532487504805841, 0.93540945790080732, 0.70154555940023067, 1.0) -(0.83064975009611697, 0.93356401384083043, 0.70191464821222604, 1.0) -(0.8259746251441753, 0.93171856978085354, 0.70228373702422142, 1.0) -(0.82129950019223374, 0.92987312572087655, 0.70265282583621691, 1.0) -(0.81662437524029219, 0.92802768166089966, 0.70302191464821229, 1.0) -(0.81194925028835063, 0.92618223760092266, 0.70339100346020766, 1.0) -(0.80727412533640908, 0.92433679354094578, 0.70376009227220304, 1.0) -(0.80259900038446752, 0.92249134948096878, 0.70412918108419842, 1.0) -(0.79792387543252596, 0.92064590542099189, 0.7044982698961938, 1.0) -(0.79324875048058441, 0.91880046136101501, 0.70486735870818917, 1.0) -(0.78857362552864285, 0.91695501730103801, 0.70523644752018455, 1.0) -(0.7838985005767013, 0.91510957324106112, 0.70560553633217993, 1.0) -(0.77817762399077284, 0.91286428296808919, 0.70609765474817388, 1.0) -(0.76931949250288356, 0.90941945405613223, 0.70695886197616309, 1.0) -(0.7604613610149944, 0.90597462514417537, 0.7078200692041523, 1.0) -(0.75160322952710501, 0.90252979623221841, 0.70868127643214152, 1.0) -(0.74274509803921573, 0.89908496732026144, 0.70954248366013073, 1.0) -(0.73388696655132646, 0.89564013840830448, 0.71040369088811994, 1.0) -(0.72502883506343718, 0.89219530949634751, 0.71126489811610927, 1.0) -(0.71617070357554791, 0.88875048058439066, 0.71212610534409848, 1.0) -(0.70731257208765863, 0.88530565167243369, 0.71298731257208769, 1.0) -(0.69845444059976936, 0.88186082276047673, 0.71384851980007691, 1.0) -(0.68959630911188019, 0.87841599384851987, 0.71470972702806612, 1.0) -(0.6807381776239908, 0.8749711649365628, 0.71557093425605534, 1.0) -(0.67188004613610153, 0.87152633602460594, 0.71643214148404466, 1.0) -(0.66302191464821225, 0.86808150711264898, 0.71729334871203387, 1.0) -(0.65416378316032298, 0.86463667820069201, 0.71815455594002309, 1.0) -(0.6453056516724337, 0.86119184928873516, 0.7190157631680123, 1.0) -(0.63644752018454442, 0.85774702037677819, 0.71987697039600151, 1.0) -(0.62758938869665515, 0.85430219146482123, 0.72073817762399073, 1.0) -(0.61873125720876598, 0.85085736255286437, 0.72159938485197994, 1.0) -(0.6098731257208766, 0.8474125336409073, 0.72246059207996927, 1.0) -(0.60101499423298732, 0.84396770472895044, 0.72332179930795848, 1.0) -(0.59215686274509804, 0.84052287581699348, 0.72418300653594769, 1.0) -(0.58329873125720877, 0.83707804690503651, 0.72504421376393691, 1.0) -(0.57444059976931949, 0.83363321799307966, 0.72590542099192612, 1.0) -(0.56558246828143022, 0.83018838908112269, 0.72676662821991544, 1.0) -(0.55672433679354094, 0.82674356016916573, 0.72762783544790466, 1.0) -(0.54786620530565178, 0.82329873125720887, 0.72848904267589387, 1.0) -(0.53900807381776239, 0.81985390234525179, 0.72935024990388309, 1.0) -(0.53014994232987322, 0.81640907343329494, 0.7302114571318723, 1.0) -(0.52129181084198395, 0.81296424452133798, 0.73107266435986151, 1.0) -(0.51243367935409467, 0.80951941560938101, 0.73193387158785073, 1.0) -(0.5035755478662054, 0.80607458669742416, 0.73279507881584005, 1.0) -(0.49517877739331029, 0.80286043829296427, 0.73374855824682805, 1.0) -(0.4875509419454056, 0.8000307574009996, 0.7348558246828143, 1.0) -(0.47992310649750108, 0.79720107650903504, 0.73596309111880043, 1.0) -(0.47229527104959629, 0.79437139561707037, 0.73707035755478656, 1.0) -(0.46466743560169166, 0.79154171472510571, 0.73817762399077269, 1.0) -(0.45703960015378703, 0.78871203383314115, 0.73928489042675893, 1.0) -(0.44941176470588234, 0.78588235294117648, 0.74039215686274507, 1.0) -(0.44178392925797771, 0.78305267204921192, 0.7414994232987312, 1.0) -(0.43415609381007303, 0.78022299115724725, 0.74260668973471744, 1.0) -(0.4265282583621684, 0.77739331026528258, 0.74371395617070357, 1.0) -(0.41890042291426388, 0.77456362937331802, 0.7448212226066897, 1.0) -(0.41127258746635909, 0.77173394848135335, 0.74592848904267584, 1.0) -(0.40364475201845446, 0.76890426758938868, 0.74703575547866208, 1.0) -(0.39601691657054977, 0.76607458669742412, 0.74814302191464821, 1.0) -(0.38838908112264514, 0.76324490580545945, 0.74925028835063434, 1.0) -(0.38076124567474046, 0.76041522491349478, 0.75035755478662047, 1.0) -(0.37313341022683583, 0.75758554402153022, 0.75146482122260672, 1.0) -(0.3655055747789312, 0.75475586312956555, 0.75257208765859285, 1.0) -(0.35787773933102662, 0.75192618223760099, 0.75367935409457898, 1.0) -(0.35024990388312188, 0.74909650134563632, 0.75478662053056522, 1.0) -(0.34262206843521725, 0.74626682045367165, 0.75589388696655135, 1.0) -(0.33499423298731257, 0.74343713956170709, 0.75700115340253749, 1.0) -(0.32736639753940788, 0.74060745866974242, 0.75810841983852362, 1.0) -(0.31973856209150331, 0.73777777777777787, 0.75921568627450986, 1.0) -(0.31211072664359862, 0.7349480968858132, 0.76032295271049599, 1.0) -(0.30448289119569394, 0.73211841599384853, 0.76143021914648212, 1.0) -(0.29685505574778942, 0.72928873510188397, 0.76253748558246826, 1.0) -(0.28922722029988468, 0.7264590542099193, 0.7636447520184545, 1.0) -(0.28159938485197999, 0.72362937331795463, 0.76475201845444063, 1.0) -(0.27397154940407537, 0.72079969242599007, 0.76585928489042676, 1.0) -(0.26634371395617074, 0.7179700115340254, 0.766966551326413, 1.0) -(0.25871587850826605, 0.71514033064206073, 0.76807381776239914, 1.0) -(0.25268742791234139, 0.71144944252210685, 0.76838139177239528, 1.0) -(0.24825836216839675, 0.70689734717416375, 0.76788927335640145, 1.0) -(0.24382929642445211, 0.70234525182622065, 0.76739715494040761, 1.0) -(0.23940023068050748, 0.69779315647827755, 0.76690503652441377, 1.0) -(0.23497116493656298, 0.69324106113033468, 0.76641291810841994, 1.0) -(0.2305420991926182, 0.68868896578239136, 0.76592079969242599, 1.0) -(0.22611303344867356, 0.68413687043444826, 0.76542868127643215, 1.0) -(0.22168396770472892, 0.67958477508650517, 0.76493656286043832, 1.0) -(0.21725490196078429, 0.67503267973856207, 0.76444444444444448, 1.0) -(0.21282583621683965, 0.67048058439061897, 0.76395232602845065, 1.0) -(0.20839677047289501, 0.66592848904267588, 0.76346020761245681, 1.0) -(0.20396770472895037, 0.66137639369473278, 0.76296808919646297, 1.0) -(0.19953863898500573, 0.65682429834678968, 0.76247597078046903, 1.0) -(0.19510957324106112, 0.65227220299884658, 0.76198385236447519, 1.0) -(0.19068050749711646, 0.64772010765090349, 0.76149173394848135, 1.0) -(0.18625144175317185, 0.64316801230296039, 0.76099961553248752, 1.0) -(0.18182237600922718, 0.63861591695501729, 0.76050749711649368, 1.0) -(0.17739331026528254, 0.6340638216070742, 0.76001537870049984, 1.0) -(0.17296424452133791, 0.6295117262591311, 0.75952326028450601, 1.0) -(0.16853517877739327, 0.624959630911188, 0.75903114186851217, 1.0) -(0.16410611303344877, 0.62040753556324502, 0.75853902345251834, 1.0) -(0.15967704728950402, 0.61585544021530181, 0.75804690503652439, 1.0) -(0.15524798154555938, 0.61130334486735871, 0.75755478662053055, 1.0) -(0.15081891580161474, 0.60675124951941561, 0.75706266820453672, 1.0) -(0.14638985005767011, 0.60219915417147252, 0.75657054978854288, 1.0) -(0.14196078431372547, 0.59764705882352942, 0.75607843137254904, 1.0) -(0.13753171856978083, 0.59309496347558632, 0.75558631295655521, 1.0) -(0.13310265282583619, 0.58854286812764323, 0.75509419454056137, 1.0) -(0.12867358708189156, 0.58399077277970013, 0.75460207612456742, 1.0) -(0.12424452133794692, 0.57943867743175703, 0.75410995770857359, 1.0) -(0.11981545559400228, 0.57488658208381382, 0.75361783929257975, 1.0) -(0.11538638985005764, 0.57033448673587084, 0.75312572087658591, 1.0) -(0.11410995770857363, 0.56470588235294117, 0.75109573241061134, 1.0) -(0.11472510572856594, 0.55843137254901953, 0.74814302191464821, 1.0) -(0.11534025374855825, 0.55215686274509801, 0.74519031141868508, 1.0) -(0.11595540176855056, 0.54588235294117649, 0.74223760092272206, 1.0) -(0.11657054978854285, 0.53960784313725507, 0.73928489042675904, 1.0) -(0.11718569780853517, 0.53333333333333333, 0.7363321799307958, 1.0) -(0.11780084582852748, 0.5270588235294118, 0.73337946943483279, 1.0) -(0.11841599384851979, 0.52078431372549017, 0.73042675893886966, 1.0) -(0.1190311418685121, 0.51450980392156864, 0.72747404844290653, 1.0) -(0.11964628988850443, 0.50823529411764701, 0.72452133794694351, 1.0) -(0.12026143790849673, 0.50196078431372548, 0.72156862745098038, 1.0) -(0.12087658592848904, 0.4956862745098039, 0.71861591695501725, 1.0) -(0.12149173394848135, 0.48941176470588232, 0.71566320645905424, 1.0) -(0.12210688196847366, 0.4831372549019608, 0.71271049596309111, 1.0) -(0.12272202998846597, 0.47686274509803922, 0.70975778546712798, 1.0) -(0.12333717800845828, 0.47058823529411764, 0.70680507497116496, 1.0) -(0.12395232602845059, 0.46431372549019606, 0.70385236447520183, 1.0) -(0.1245674740484429, 0.45803921568627448, 0.7008996539792387, 1.0) -(0.12518262206843522, 0.45176470588235296, 0.69794694348327568, 1.0) -(0.12579777008842752, 0.44549019607843138, 0.69499423298731255, 1.0) -(0.12641291810841981, 0.43921568627451002, 0.69204152249134954, 1.0) -(0.12702806612841214, 0.43294117647058827, 0.68908881199538641, 1.0) -(0.12764321414840446, 0.42666666666666664, 0.68613610149942328, 1.0) -(0.12825836216839676, 0.42039215686274511, 0.68318339100346015, 1.0) -(0.12887351018838908, 0.41411764705882353, 0.68023068050749713, 1.0) -(0.1294886582083814, 0.40784313725490196, 0.677277970011534, 1.0) -(0.1301038062283737, 0.40156862745098043, 0.67432525951557087, 1.0) -(0.13071895424836602, 0.3952941176470588, 0.67137254901960786, 1.0) -(0.13133410226835832, 0.38901960784313727, 0.66841983852364473, 1.0) -(0.13194925028835064, 0.38274509803921569, 0.6654671280276816, 1.0) -(0.13256439830834293, 0.37647058823529411, 0.66251441753171858, 1.0) -(0.13317954632833526, 0.37019607843137259, 0.65956170703575545, 1.0) -(0.13361014994232986, 0.36475201845444061, 0.65697808535178781, 1.0) -(0.13397923875432527, 0.35958477508650522, 0.65451749327181852, 1.0) -(0.13434832756632065, 0.35441753171856982, 0.65205690119184934, 1.0) -(0.13471741637831602, 0.34925028835063437, 0.64959630911188004, 1.0) -(0.1350865051903114, 0.34408304498269915, 0.64713571703191086, 1.0) -(0.13545559400230681, 0.33891580161476359, 0.64467512495194157, 1.0) -(0.13582468281430218, 0.33374855824682814, 0.64221453287197228, 1.0) -(0.13619377162629759, 0.32858131487889275, 0.6397539407920031, 1.0) -(0.13656286043829297, 0.32341407151095736, 0.6372933487120338, 1.0) -(0.13693194925028834, 0.31824682814302191, 0.63483275663206462, 1.0) -(0.13730103806228375, 0.31307958477508652, 0.63237216455209533, 1.0) -(0.13767012687427913, 0.30791234140715112, 0.62991157247212615, 1.0) -(0.1380392156862745, 0.30274509803921568, 0.62745098039215685, 1.0) -(0.13840830449826991, 0.29757785467128028, 0.62499038831218767, 1.0) -(0.13877739331026528, 0.29241061130334489, 0.62252979623221838, 1.0) -(0.13914648212226066, 0.28724336793540944, 0.6200692041522492, 1.0) -(0.13951557093425607, 0.28207612456747405, 0.61760861207227991, 1.0) -(0.13988465974625144, 0.27690888119953866, 0.61514801999231072, 1.0) -(0.14025374855824682, 0.27174163783160321, 0.61268742791234143, 1.0) -(0.14062283737024223, 0.26657439446366782, 0.61022683583237214, 1.0) -(0.1409919261822376, 0.26140715109573254, 0.60776624375240307, 1.0) -(0.14136101499423298, 0.25623990772779703, 0.60530565167243366, 1.0) -(0.14173010380622839, 0.25107266435986159, 0.60284505959246448, 1.0) -(0.14209919261822376, 0.24590542099192619, 0.60038446751249519, 1.0) -(0.14246828143021917, 0.24073817762399077, 0.59792387543252601, 1.0) -(0.14283737024221455, 0.23557093425605535, 0.59546328335255672, 1.0) -(0.14320645905420992, 0.23040369088811996, 0.59300269127258753, 1.0) -(0.14357554786620533, 0.22523644752018454, 0.59054209919261824, 1.0) -(0.1439446366782007, 0.22006920415224912, 0.58808150711264906, 1.0) -(0.14431372549019608, 0.21490196078431373, 0.58562091503267977, 1.0) -(0.14468281430219149, 0.20973471741637831, 0.58316032295271059, 1.0) -(0.14505190311418686, 0.20456747404844289, 0.58069973087274129, 1.0) -(0.1419761630142253, 0.20144559784698193, 0.57393310265282593, 1.0) -(0.13840830449826991, 0.19861591695501729, 0.56655132641291817, 1.0) -(0.13484044598231451, 0.19578623606305268, 0.5591695501730104, 1.0) -(0.13127258746635911, 0.19295655517108803, 0.55178777393310274, 1.0) -(0.1277047289504038, 0.1901268742791235, 0.5444059976931952, 1.0) -(0.12413687043444829, 0.18729719338715878, 0.53702422145328721, 1.0) -(0.1205690119184929, 0.18446751249519416, 0.52964244521337955, 1.0) -(0.1170011534025375, 0.18163783160322952, 0.52226066897347179, 1.0) -(0.11343329488658209, 0.17880815071126488, 0.51487889273356402, 1.0) -(0.10986543637062668, 0.17597846981930026, 0.50749711649365636, 1.0) -(0.10629757785467128, 0.17314878892733565, 0.5001153402537486, 1.0) -(0.10272971933871589, 0.17031910803537101, 0.49273356401384083, 1.0) -(0.099161860822760489, 0.16748942714340637, 0.48535178777393312, 1.0) -(0.095594002306805079, 0.16465974625144175, 0.47797001153402541, 1.0) -(0.092026143790849668, 0.16183006535947714, 0.47058823529411764, 1.0) -(0.088458285274894272, 0.1590003844675125, 0.46320645905420993, 1.0) -(0.084890426758938875, 0.15617070357554785, 0.45582468281430222, 1.0) -(0.081322568242983478, 0.15334102268358324, 0.44844290657439445, 1.0) -(0.077754709727028068, 0.1505113417916186, 0.44106113033448674, 1.0) -(0.074186851211072671, 0.14768166089965398, 0.43367935409457903, 1.0) -(0.070618992695117372, 0.14485198000768942, 0.42629757785467148, 1.0) -(0.067051134179161864, 0.14202229911572473, 0.41891580161476355, 1.0) -(0.063483275663206468, 0.13919261822376008, 0.41153402537485584, 1.0) -(0.059915417147251057, 0.13636293733179544, 0.40415224913494807, 1.0) -(0.056347558631295661, 0.13353325643983083, 0.39677047289504042, 1.0) -(0.05277970011534025, 0.13070357554786621, 0.38938869665513265, 1.0) -(0.049211841599384853, 0.12787389465590157, 0.38200692041522488, 1.0) -(0.045643983083429457, 0.12504421376393693, 0.37462514417531723, 1.0) -(0.042076124567474046, 0.12221453287197231, 0.36724336793540946, 1.0) -(0.03850826605151865, 0.11938485198000769, 0.35986159169550169, 1.0) -(0.034940407535563239, 0.11655517108804306, 0.35247981545559404, 1.0) -(0.031372549019607843, 0.11372549019607843, 0.34509803921568627, 1.0) diff --git a/extern/tfn/colormaps/sequential/YlOrBr.cpp b/extern/tfn/colormaps/sequential/YlOrBr.cpp deleted file mode 100644 index 422722c..0000000 --- a/extern/tfn/colormaps/sequential/YlOrBr.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential_YlOrBr; -} -const std::vector colormap::data_sequential_YlOrBr = /* NOLINT(cert-err58-cpp) */ -{ -{1.0f, 1.0f, 0.89803921568627454f, 1.0f}, -{1.0f, 0.99901576316801233f, 0.89299500192233761f, 1.0f}, -{1.0f, 0.99803152633602465f, 0.88795078815840067f, 1.0f}, -{1.0f, 0.99704728950403687f, 0.88290657439446374f, 1.0f}, -{1.0f, 0.9960630526720492f, 0.87786236063052681f, 1.0f}, -{1.0f, 0.99507881584006153f, 0.87281814686658976f, 1.0f}, -{1.0f, 0.99409457900807385f, 0.86777393310265283f, 1.0f}, -{1.0f, 0.99311034217608607f, 0.86272971933871589f, 1.0f}, -{1.0f, 0.9921261053440984f, 0.85768550557477896f, 1.0f}, -{1.0f, 0.99114186851211072f, 0.85264129181084203f, 1.0f}, -{1.0f, 0.99015763168012305f, 0.84759707804690509f, 1.0f}, -{1.0f, 0.98917339484813538f, 0.84255286428296816f, 1.0f}, -{1.0f, 0.9881891580161476f, 0.83750865051903123f, 1.0f}, -{1.0f, 0.98720492118415992f, 0.83246443675509418f, 1.0f}, -{1.0f, 0.98622068435217225f, 0.82742022299115725f, 1.0f}, -{1.0f, 0.98523644752018458f, 0.82237600922722032f, 1.0f}, -{1.0f, 0.98425221068819679f, 0.81733179546328338f, 1.0f}, -{1.0f, 0.98326797385620912f, 0.81228758169934645f, 1.0f}, -{1.0f, 0.98228373702422145f, 0.80724336793540952f, 1.0f}, -{1.0f, 0.98129950019223378f, 0.80219915417147258f, 1.0f}, -{1.0f, 0.9803152633602461f, 0.79715494040753565f, 1.0f}, -{1.0f, 0.97933102652825832f, 0.79211072664359872f, 1.0f}, -{1.0f, 0.97834678969627065f, 0.78706651287966167f, 1.0f}, -{1.0f, 0.97736255286428297f, 0.78202229911572474f, 1.0f}, -{1.0f, 0.9763783160322953f, 0.77697808535178781f, 1.0f}, -{1.0f, 0.97539407920030752f, 0.77193387158785087f, 1.0f}, -{1.0f, 0.97440984236831985f, 0.76688965782391394f, 1.0f}, -{1.0f, 0.97342560553633217f, 0.76184544405997701f, 1.0f}, -{1.0f, 0.9724413687043445f, 0.75680123029604007f, 1.0f}, -{1.0f, 0.97145713187235683f, 0.75175701653210303f, 1.0f}, -{1.0f, 0.97047289504036904f, 0.7467128027681661f, 1.0f}, -{1.0f, 0.96948865820838137f, 0.74166858900422916f, 1.0f}, -{0.99998462129950016f, 0.96831987697039601f, 0.73659361783929267f, 1.0f}, -{0.99986159169550171f, 0.96585928489042683f, 0.73130334486735882f, 1.0f}, -{0.99973856209150325f, 0.96339869281045754f, 0.72601307189542486f, 1.0f}, -{0.99961553248750479f, 0.96093810073048824f, 0.720722798923491f, 1.0f}, -{0.99949250288350633f, 0.95847750865051906f, 0.71543252595155715f, 1.0f}, -{0.99936947327950787f, 0.95601691657054977f, 0.7101422529796233f, 1.0f}, -{0.99924644367550941f, 0.95355632449058059f, 0.70485198000768934f, 1.0f}, -{0.99912341407151095f, 0.95109573241061129f, 0.69956170703575549f, 1.0f}, -{0.99900038446751249f, 0.948635140330642f, 0.69427143406382164f, 1.0f}, -{0.99887735486351403f, 0.94617454825067282f, 0.68898116109188778f, 1.0f}, -{0.99875432525951557f, 0.94371395617070353f, 0.68369088811995393f, 1.0f}, -{0.99863129565551711f, 0.94125336409073435f, 0.67840061514801997f, 1.0f}, -{0.99850826605151866f, 0.93879277201076505f, 0.67311034217608612f, 1.0f}, -{0.9983852364475202f, 0.93633217993079587f, 0.66782006920415227f, 1.0f}, -{0.99826220684352174f, 0.93387158785082658f, 0.66252979623221842f, 1.0f}, -{0.99813917723952328f, 0.9314109957708574f, 0.65723952326028456f, 1.0f}, -{0.99801614763552482f, 0.9289504036908881f, 0.6519492502883506f, 1.0f}, -{0.99789311803152636f, 0.92648981161091881f, 0.64665897731641686f, 1.0f}, -{0.9977700884275279f, 0.92402921953094963f, 0.6413687043444829f, 1.0f}, -{0.99764705882352944f, 0.92156862745098034f, 0.63607843137254905f, 1.0f}, -{0.99752402921953098f, 0.91910803537101116f, 0.6307881584006152f, 1.0f}, -{0.99740099961553252f, 0.91664744329104186f, 0.62549788542868134f, 1.0f}, -{0.99727797001153407f, 0.91418685121107268f, 0.62020761245674738f, 1.0f}, -{0.99715494040753561f, 0.91172625913110339f, 0.61491733948481353f, 1.0f}, -{0.99703191080353715f, 0.9092656670511341f, 0.60962706651287968f, 1.0f}, -{0.99690888119953869f, 0.90680507497116491f, 0.60433679354094583f, 1.0f}, -{0.99678585159554023f, 0.90434448289119562f, 0.59904652056901186f, 1.0f}, -{0.99666282199154177f, 0.90188389081122644f, 0.59375624759707801f, 1.0f}, -{0.99653979238754331f, 0.89942329873125715f, 0.58846597462514416f, 1.0f}, -{0.99641676278354485f, 0.89696270665128797f, 0.58317570165321031f, 1.0f}, -{0.99629373317954639f, 0.89450211457131867f, 0.57788542868127646f, 1.0f}, -{0.99617070357554793f, 0.89204152249134938f, 0.5725951557093425f, 1.0f}, -{0.99607843137254903f, 0.88924259900038438f, 0.56659746251441756f, 1.0f}, -{0.99607843137254903f, 0.88542868127643204f, 0.55847750865051904f, 1.0f}, -{0.99607843137254903f, 0.88161476355247981f, 0.55035755478662063f, 1.0f}, -{0.99607843137254903f, 0.87780084582852747f, 0.542237600922722f, 1.0f}, -{0.99607843137254903f, 0.87398692810457512f, 0.53411764705882347f, 1.0f}, -{0.99607843137254903f, 0.87017301038062278f, 0.52599769319492506f, 1.0f}, -{0.99607843137254903f, 0.86635909265667044f, 0.51787773933102654f, 1.0f}, -{0.99607843137254903f, 0.86254517493271821f, 0.50975778546712802f, 1.0f}, -{0.99607843137254903f, 0.85873125720876586f, 0.5016378316032295f, 1.0f}, -{0.99607843137254903f, 0.85491733948481352f, 0.49351787773933098f, 1.0f}, -{0.99607843137254903f, 0.85110342176086129f, 0.48539792387543262f, 1.0f}, -{0.99607843137254903f, 0.84728950403690884f, 0.47727797001153399f, 1.0f}, -{0.99607843137254903f, 0.84347558631295649f, 0.46915801614763553f, 1.0f}, -{0.99607843137254903f, 0.83966166858900426f, 0.461038062283737f, 1.0f}, -{0.99607843137254903f, 0.83584775086505192f, 0.45291810841983848f, 1.0f}, -{0.99607843137254903f, 0.83203383314109958f, 0.44479815455594002f, 1.0f}, -{0.99607843137254903f, 0.82821991541714723f, 0.43667820069204155f, 1.0f}, -{0.99607843137254903f, 0.82440599769319489f, 0.42855824682814303f, 1.0f}, -{0.99607843137254903f, 0.82059207996924266f, 0.42043829296424462f, 1.0f}, -{0.99607843137254903f, 0.81677816224529032f, 0.41231833910034599f, 1.0f}, -{0.99607843137254903f, 0.81296424452133798f, 0.40419838523644752f, 1.0f}, -{0.99607843137254903f, 0.80915032679738563f, 0.39607843137254906f, 1.0f}, -{0.99607843137254903f, 0.80533640907343329f, 0.38795847750865053f, 1.0f}, -{0.99607843137254903f, 0.80152249134948095f, 0.37983852364475201f, 1.0f}, -{0.99607843137254903f, 0.79770857362552872f, 0.37171856978085349f, 1.0f}, -{0.99607843137254903f, 0.79389465590157637f, 0.36359861591695503f, 1.0f}, -{0.99607843137254903f, 0.79008073817762403f, 0.35547866205305667f, 1.0f}, -{0.99607843137254903f, 0.78626682045367169f, 0.34735870818915804f, 1.0f}, -{0.99607843137254903f, 0.78245290272971935f, 0.33923875432525952f, 1.0f}, -{0.99607843137254903f, 0.77863898500576711f, 0.331118800461361f, 1.0f}, -{0.99607843137254903f, 0.77482506728181477f, 0.32299884659746253f, 1.0f}, -{0.99607843137254903f, 0.77101114955786243f, 0.31487889273356401f, 1.0f}, -{0.99607843137254903f, 0.76664359861591702f, 0.30805074971164936f, 1.0f}, -{0.99607843137254903f, 0.76135332564398317f, 0.30337562475970781f, 1.0f}, -{0.99607843137254903f, 0.75606305267204932f, 0.29870049980776631f, 1.0f}, -{0.99607843137254903f, 0.75077277970011536f, 0.29402537485582469f, 1.0f}, -{0.99607843137254903f, 0.7454825067281815f, 0.28935024990388314f, 1.0f}, -{0.99607843137254903f, 0.74019223375624765f, 0.28467512495194158f, 1.0f}, -{0.99607843137254903f, 0.7349019607843138f, 0.28000000000000003f, 1.0f}, -{0.99607843137254903f, 0.72961168781237984f, 0.27532487504805847f, 1.0f}, -{0.99607843137254903f, 0.72432141484044599f, 0.27064975009611691f, 1.0f}, -{0.99607843137254903f, 0.71903114186851214f, 0.2659746251441753f, 1.0f}, -{0.99607843137254903f, 0.71374086889657828f, 0.2612995001922338f, 1.0f}, -{0.99607843137254903f, 0.70845059592464443f, 0.25662437524029219f, 1.0f}, -{0.99607843137254903f, 0.70316032295271047f, 0.25194925028835063f, 1.0f}, -{0.99607843137254903f, 0.69787004998077662f, 0.24727412533640908f, 1.0f}, -{0.99607843137254903f, 0.69257977700884277f, 0.24259900038446752f, 1.0f}, -{0.99607843137254903f, 0.68728950403690892f, 0.23792387543252597f, 1.0f}, -{0.99607843137254903f, 0.68199923106497506f, 0.23324875048058441f, 1.0f}, -{0.99607843137254903f, 0.67670895809304121f, 0.22857362552864285f, 1.0f}, -{0.99607843137254903f, 0.67141868512110736f, 0.22389850057670135f, 1.0f}, -{0.99607843137254903f, 0.6661284121491734f, 0.21922337562475974f, 1.0f}, -{0.99607843137254903f, 0.66083813917723955f, 0.21454825067281819f, 1.0f}, -{0.99607843137254903f, 0.6555478662053057f, 0.2098731257208766f, 1.0f}, -{0.99607843137254903f, 0.65025759323337184f, 0.20519800076893505f, 1.0f}, -{0.99607843137254903f, 0.64496732026143788f, 0.20052287581699346f, 1.0f}, -{0.99607843137254903f, 0.63967704728950403f, 0.19584775086505191f, 1.0f}, -{0.99607843137254903f, 0.63438677431757018f, 0.19117262591311035f, 1.0f}, -{0.99607843137254903f, 0.62909650134563633f, 0.18649750096116885f, 1.0f}, -{0.99607843137254903f, 0.62380622837370248f, 0.18182237600922724f, 1.0f}, -{0.99607843137254903f, 0.61851595540176851f, 0.17714725105728568f, 1.0f}, -{0.99607843137254903f, 0.61322568242983466f, 0.17247212610534413f, 1.0f}, -{0.99607843137254903f, 0.60793540945790081f, 0.16779700115340257f, 1.0f}, -{0.99607843137254903f, 0.60264513648596696f, 0.16312187620146099f, 1.0f}, -{0.9949711649365629f, 0.59747789311803146f, 0.15949250288350636f, 1.0f}, -{0.99275663206459053f, 0.59243367935409452f, 0.15690888119953866f, 1.0f}, -{0.99054209919261826f, 0.58738946559015759f, 0.15432525951557094f, 1.0f}, -{0.98832756632064589f, 0.58234525182622066f, 0.15174163783160324f, 1.0f}, -{0.98611303344867363f, 0.57730103806228383f, 0.1491580161476356f, 1.0f}, -{0.98389850057670125f, 0.57225682429834679f, 0.14657439446366782f, 1.0f}, -{0.98168396770472899f, 0.56721261053440986f, 0.14399077277970013f, 1.0f}, -{0.97946943483275661f, 0.56216839677047292f, 0.14140715109573243f, 1.0f}, -{0.97725490196078435f, 0.55712418300653588f, 0.13882352941176471f, 1.0f}, -{0.97504036908881198f, 0.55207996924259894f, 0.13623990772779701f, 1.0f}, -{0.97282583621683971f, 0.54703575547866201f, 0.13365628604382931f, 1.0f}, -{0.97061130334486734f, 0.54199154171472508f, 0.13107266435986159f, 1.0f}, -{0.96839677047289507f, 0.53694732795078814f, 0.12848904267589389f, 1.0f}, -{0.9661822376009227f, 0.53190311418685121f, 0.1259054209919262f, 1.0f}, -{0.96396770472895044f, 0.52685890042291428f, 0.12332179930795847f, 1.0f}, -{0.96175317185697806f, 0.52181468665897734f, 0.12073817762399078f, 1.0f}, -{0.9595386389850058f, 0.5167704728950403f, 0.11815455594002307f, 1.0f}, -{0.95732410611303342f, 0.51172625913110337f, 0.11557093425605536f, 1.0f}, -{0.95510957324106116f, 0.50668204536716643f, 0.11298731257208766f, 1.0f}, -{0.95289504036908879f, 0.5016378316032295f, 0.11040369088811995f, 1.0f}, -{0.95068050749711663f, 0.49659361783929268f, 0.10782006920415232f, 1.0f}, -{0.94846597462514426f, 0.49154940407535563f, 0.10523644752018455f, 1.0f}, -{0.94625144175317188f, 0.4865051903114187f, 0.10265282583621685f, 1.0f}, -{0.94403690888119962f, 0.48146097654748171f, 0.10006920415224912f, 1.0f}, -{0.94182237600922725f, 0.47641676278354478f, 0.097485582468281429f, 1.0f}, -{0.93960784313725498f, 0.47137254901960779f, 0.094901960784313719f, 1.0f}, -{0.93739331026528261f, 0.46632833525567086f, 0.092318339100346022f, 1.0f}, -{0.93517877739331035f, 0.46128412149173392f, 0.089734717416378312f, 1.0f}, -{0.93296424452133797f, 0.45623990772779699f, 0.087151095732410602f, 1.0f}, -{0.93074971164936571f, 0.45119569396386006f, 0.084567474048442906f, 1.0f}, -{0.92853517877739333f, 0.44615148019992312f, 0.081983852364475196f, 1.0f}, -{0.92632064590542107f, 0.44110726643598613f, 0.079400230680507486f, 1.0f}, -{0.92302960399846212f, 0.43644752018454441f, 0.077047289504036914f, 1.0f}, -{0.91909265667051143f, 0.43201845444059978f, 0.074832756632064595f, 1.0f}, -{0.91515570934256063f, 0.42758938869665514f, 0.072618223760092276f, 1.0f}, -{0.91121876201460983f, 0.4231603229527105f, 0.070403690888119957f, 1.0f}, -{0.90728181468665914f, 0.41873125720876597f, 0.068189158016147694f, 1.0f}, -{0.90334486735870823f, 0.41430219146482122f, 0.06597462514417532f, 1.0f}, -{0.89940792003075742f, 0.40987312572087659f, 0.063760092272203001f, 1.0f}, -{0.89547097270280662f, 0.40544405997693195f, 0.061545559400230682f, 1.0f}, -{0.89153402537485582f, 0.40101499423298731f, 0.059331026528258363f, 1.0f}, -{0.88759707804690513f, 0.39658592848904267f, 0.057116493656286044f, 1.0f}, -{0.88366013071895433f, 0.39215686274509803f, 0.054901960784313725f, 1.0f}, -{0.87972318339100353f, 0.3877277970011534f, 0.052687427912341406f, 1.0f}, -{0.87578623606305273f, 0.38329873125720876f, 0.050472895040369087f, 1.0f}, -{0.87184928873510192f, 0.37886966551326412f, 0.048258362168396768f, 1.0f}, -{0.86791234140715112f, 0.37444059976931948f, 0.046043829296424456f, 1.0f}, -{0.86397539407920032f, 0.37001153402537484f, 0.043829296424452137f, 1.0f}, -{0.86003844675124952f, 0.36558246828143021f, 0.041614763552479811f, 1.0f}, -{0.85610149942329872f, 0.36115340253748557f, 0.039400230680507492f, 1.0f}, -{0.85216455209534803f, 0.35672433679354093f, 0.037185697808535173f, 1.0f}, -{0.84822760476739723f, 0.35229527104959629f, 0.034971164936562861f, 1.0f}, -{0.84429065743944653f, 0.34786620530565182f, 0.032756632064590605f, 1.0f}, -{0.84035371011149562f, 0.34343713956170702f, 0.030542099192618223f, 1.0f}, -{0.83641676278354482f, 0.33900807381776238f, 0.028327566320645904f, 1.0f}, -{0.83247981545559402f, 0.33457900807381774f, 0.026113033448673585f, 1.0f}, -{0.82854286812764322f, 0.3301499423298731f, 0.023898500576701266f, 1.0f}, -{0.82460592079969253f, 0.32572087658592846f, 0.021683967704728947f, 1.0f}, -{0.82066897347174173f, 0.32129181084198383f, 0.019469434832756628f, 1.0f}, -{0.81673202614379092f, 0.31686274509803919f, 0.017254901960784309f, 1.0f}, -{0.81279507881584012f, 0.31243367935409461f, 0.015040369088811997f, 1.0f}, -{0.80885813148788932f, 0.30800461361014997f, 0.012825836216839678f, 1.0f}, -{0.80492118415993852f, 0.30357554786620533f, 0.010611303344867359f, 1.0f}, -{0.80098423683198772f, 0.29914648212226069f, 0.0083967704728950404f, 1.0f}, -{0.79529411764705882f, 0.29582468281430219f, 0.0080276816608996545f, 1.0f}, -{0.78901960784313729f, 0.29287197231833911f, 0.0082737408688965779f, 1.0f}, -{0.78274509803921577f, 0.28991926182237598f, 0.008519800076893503f, 1.0f}, -{0.77647058823529413f, 0.28696655132641291f, 0.0087658592848904263f, 1.0f}, -{0.77019607843137272f, 0.28401384083044989f, 0.0090119184928873445f, 1.0f}, -{0.76392156862745098f, 0.28106113033448671f, 0.0092579777008842748f, 1.0f}, -{0.75764705882352945f, 0.27810841983852364f, 0.0095040369088811999f, 1.0f}, -{0.75137254901960793f, 0.27515570934256056f, 0.0097500961168781233f, 1.0f}, -{0.74509803921568629f, 0.27220299884659743f, 0.0099961553248750484f, 1.0f}, -{0.73882352941176477f, 0.26925028835063436f, 0.010242214532871972f, 1.0f}, -{0.73254901960784313f, 0.26629757785467129f, 0.010488273740868897f, 1.0f}, -{0.72627450980392161f, 0.26334486735870821f, 0.010734332948865822f, 1.0f}, -{0.71999999999999997f, 0.26039215686274508f, 0.010980392156862745f, 1.0f}, -{0.71372549019607845f, 0.25743944636678201f, 0.011226451364859669f, 1.0f}, -{0.70745098039215693f, 0.25448673587081894f, 0.011472510572856594f, 1.0f}, -{0.70117647058823529f, 0.25153402537485581f, 0.011718569780853519f, 1.0f}, -{0.69490196078431377f, 0.24858131487889273f, 0.011964628988850442f, 1.0f}, -{0.68862745098039213f, 0.24562860438292963f, 0.012210688196847366f, 1.0f}, -{0.68235294117647061f, 0.24267589388696653f, 0.012456747404844291f, 1.0f}, -{0.67607843137254897f, 0.23972318339100346f, 0.012702806612841216f, 1.0f}, -{0.66980392156862756f, 0.23677047289504044f, 0.012948865820838132f, 1.0f}, -{0.66352941176470592f, 0.23381776239907726f, 0.013194925028835063f, 1.0f}, -{0.65725490196078429f, 0.23086505190311418f, 0.013440984236831988f, 1.0f}, -{0.65098039215686276f, 0.22791234140715111f, 0.013687043444828913f, 1.0f}, -{0.64470588235294113f, 0.22495963091118798f, 0.013933102652825836f, 1.0f}, -{0.6384313725490196f, 0.22200692041522491f, 0.014179161860822759f, 1.0f}, -{0.63215686274509797f, 0.21905420991926183f, 0.014425221068819685f, 1.0f}, -{0.62588235294117645f, 0.21610149942329873f, 0.01467128027681661f, 1.0f}, -{0.61960784313725492f, 0.21314878892733563f, 0.014917339484813533f, 1.0f}, -{0.61333333333333329f, 0.21019607843137256f, 0.015163398692810456f, 1.0f}, -{0.60705882352941176f, 0.20724336793540946f, 0.015409457900807381f, 1.0f}, -{0.60078431372549024f, 0.20429065743944635f, 0.015655517108804307f, 1.0f}, -{0.5945098039215686f, 0.20230680507497117f, 0.015901576316801232f, 1.0f}, -{0.58823529411764708f, 0.20046136101499423f, 0.016147635524798153f, 1.0f}, -{0.58196078431372544f, 0.19861591695501729f, 0.016393694732795078f, 1.0f}, -{0.57568627450980392f, 0.19677047289504038f, 0.016639753940792004f, 1.0f}, -{0.56941176470588251f, 0.19492502883506349f, 0.016885813148788918f, 1.0f}, -{0.56313725490196076f, 0.19307958477508649f, 0.01713187235678585f, 1.0f}, -{0.55686274509803924f, 0.19123414071510958f, 0.017377931564782775f, 1.0f}, -{0.5505882352941176f, 0.18938869665513264f, 0.0176239907727797f, 1.0f}, -{0.54431372549019608f, 0.1875432525951557f, 0.017870049980776622f, 1.0f}, -{0.53803921568627455f, 0.18569780853517878f, 0.018116109188773547f, 1.0f}, -{0.53176470588235292f, 0.18385236447520184f, 0.018362168396770472f, 1.0f}, -{0.52549019607843139f, 0.18200692041522493f, 0.018608227604767394f, 1.0f}, -{0.51921568627450976f, 0.18016147635524798f, 0.018854286812764319f, 1.0f}, -{0.51294117647058823f, 0.17831603229527104f, 0.019100346020761244f, 1.0f}, -{0.50666666666666671f, 0.17647058823529413f, 0.019346405228758169f, 1.0f}, -{0.50039215686274507f, 0.17462514417531719f, 0.019592464436755091f, 1.0f}, -{0.49411764705882355f, 0.17277970011534027f, 0.019838523644752016f, 1.0f}, -{0.48784313725490197f, 0.17093425605536333f, 0.020084582852748941f, 1.0f}, -{0.48156862745098039f, 0.16908881199538639f, 0.020330642060745863f, 1.0f}, -{0.47529411764705881f, 0.16724336793540945f, 0.020576701268742788f, 1.0f}, -{0.46901960784313745f, 0.16539792387543259f, 0.020822760476739706f, 1.0f}, -{0.46274509803921571f, 0.16355247981545559f, 0.021068819684736638f, 1.0f}, -{0.45647058823529413f, 0.16170703575547868f, 0.021314878892733563f, 1.0f}, -{0.45019607843137255f, 0.15986159169550174f, 0.021560938100730485f, 1.0f}, -{0.44392156862745102f, 0.1580161476355248f, 0.02180699730872741f, 1.0f}, -{0.43764705882352939f, 0.15617070357554788f, 0.022053056516724335f, 1.0f}, -{0.43137254901960786f, 0.15432525951557094f, 0.022299115724721257f, 1.0f}, -{0.42509803921568629f, 0.15247981545559403f, 0.022545174932718182f, 1.0f}, -{0.41882352941176471f, 0.15063437139561708f, 0.022791234140715107f, 1.0f}, -{0.41254901960784318f, 0.14878892733564014f, 0.023037293348712032f, 1.0f}, -{0.4062745098039216f, 0.14694348327566323f, 0.023283352556708953f, 1.0f}, -{0.40000000000000002f, 0.14509803921568629f, 0.023529411764705879f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential/YlOrBr.txt b/extern/tfn/colormaps/sequential/YlOrBr.txt deleted file mode 100644 index 5b500db..0000000 --- a/extern/tfn/colormaps/sequential/YlOrBr.txt +++ /dev/null @@ -1,256 +0,0 @@ -(1.0, 1.0, 0.89803921568627454, 1.0) -(1.0, 0.99901576316801233, 0.89299500192233761, 1.0) -(1.0, 0.99803152633602465, 0.88795078815840067, 1.0) -(1.0, 0.99704728950403687, 0.88290657439446374, 1.0) -(1.0, 0.9960630526720492, 0.87786236063052681, 1.0) -(1.0, 0.99507881584006153, 0.87281814686658976, 1.0) -(1.0, 0.99409457900807385, 0.86777393310265283, 1.0) -(1.0, 0.99311034217608607, 0.86272971933871589, 1.0) -(1.0, 0.9921261053440984, 0.85768550557477896, 1.0) -(1.0, 0.99114186851211072, 0.85264129181084203, 1.0) -(1.0, 0.99015763168012305, 0.84759707804690509, 1.0) -(1.0, 0.98917339484813538, 0.84255286428296816, 1.0) -(1.0, 0.9881891580161476, 0.83750865051903123, 1.0) -(1.0, 0.98720492118415992, 0.83246443675509418, 1.0) -(1.0, 0.98622068435217225, 0.82742022299115725, 1.0) -(1.0, 0.98523644752018458, 0.82237600922722032, 1.0) -(1.0, 0.98425221068819679, 0.81733179546328338, 1.0) -(1.0, 0.98326797385620912, 0.81228758169934645, 1.0) -(1.0, 0.98228373702422145, 0.80724336793540952, 1.0) -(1.0, 0.98129950019223378, 0.80219915417147258, 1.0) -(1.0, 0.9803152633602461, 0.79715494040753565, 1.0) -(1.0, 0.97933102652825832, 0.79211072664359872, 1.0) -(1.0, 0.97834678969627065, 0.78706651287966167, 1.0) -(1.0, 0.97736255286428297, 0.78202229911572474, 1.0) -(1.0, 0.9763783160322953, 0.77697808535178781, 1.0) -(1.0, 0.97539407920030752, 0.77193387158785087, 1.0) -(1.0, 0.97440984236831985, 0.76688965782391394, 1.0) -(1.0, 0.97342560553633217, 0.76184544405997701, 1.0) -(1.0, 0.9724413687043445, 0.75680123029604007, 1.0) -(1.0, 0.97145713187235683, 0.75175701653210303, 1.0) -(1.0, 0.97047289504036904, 0.7467128027681661, 1.0) -(1.0, 0.96948865820838137, 0.74166858900422916, 1.0) -(0.99998462129950016, 0.96831987697039601, 0.73659361783929267, 1.0) -(0.99986159169550171, 0.96585928489042683, 0.73130334486735882, 1.0) -(0.99973856209150325, 0.96339869281045754, 0.72601307189542486, 1.0) -(0.99961553248750479, 0.96093810073048824, 0.720722798923491, 1.0) -(0.99949250288350633, 0.95847750865051906, 0.71543252595155715, 1.0) -(0.99936947327950787, 0.95601691657054977, 0.7101422529796233, 1.0) -(0.99924644367550941, 0.95355632449058059, 0.70485198000768934, 1.0) -(0.99912341407151095, 0.95109573241061129, 0.69956170703575549, 1.0) -(0.99900038446751249, 0.948635140330642, 0.69427143406382164, 1.0) -(0.99887735486351403, 0.94617454825067282, 0.68898116109188778, 1.0) -(0.99875432525951557, 0.94371395617070353, 0.68369088811995393, 1.0) -(0.99863129565551711, 0.94125336409073435, 0.67840061514801997, 1.0) -(0.99850826605151866, 0.93879277201076505, 0.67311034217608612, 1.0) -(0.9983852364475202, 0.93633217993079587, 0.66782006920415227, 1.0) -(0.99826220684352174, 0.93387158785082658, 0.66252979623221842, 1.0) -(0.99813917723952328, 0.9314109957708574, 0.65723952326028456, 1.0) -(0.99801614763552482, 0.9289504036908881, 0.6519492502883506, 1.0) -(0.99789311803152636, 0.92648981161091881, 0.64665897731641686, 1.0) -(0.9977700884275279, 0.92402921953094963, 0.6413687043444829, 1.0) -(0.99764705882352944, 0.92156862745098034, 0.63607843137254905, 1.0) -(0.99752402921953098, 0.91910803537101116, 0.6307881584006152, 1.0) -(0.99740099961553252, 0.91664744329104186, 0.62549788542868134, 1.0) -(0.99727797001153407, 0.91418685121107268, 0.62020761245674738, 1.0) -(0.99715494040753561, 0.91172625913110339, 0.61491733948481353, 1.0) -(0.99703191080353715, 0.9092656670511341, 0.60962706651287968, 1.0) -(0.99690888119953869, 0.90680507497116491, 0.60433679354094583, 1.0) -(0.99678585159554023, 0.90434448289119562, 0.59904652056901186, 1.0) -(0.99666282199154177, 0.90188389081122644, 0.59375624759707801, 1.0) -(0.99653979238754331, 0.89942329873125715, 0.58846597462514416, 1.0) -(0.99641676278354485, 0.89696270665128797, 0.58317570165321031, 1.0) -(0.99629373317954639, 0.89450211457131867, 0.57788542868127646, 1.0) -(0.99617070357554793, 0.89204152249134938, 0.5725951557093425, 1.0) -(0.99607843137254903, 0.88924259900038438, 0.56659746251441756, 1.0) -(0.99607843137254903, 0.88542868127643204, 0.55847750865051904, 1.0) -(0.99607843137254903, 0.88161476355247981, 0.55035755478662063, 1.0) -(0.99607843137254903, 0.87780084582852747, 0.542237600922722, 1.0) -(0.99607843137254903, 0.87398692810457512, 0.53411764705882347, 1.0) -(0.99607843137254903, 0.87017301038062278, 0.52599769319492506, 1.0) -(0.99607843137254903, 0.86635909265667044, 0.51787773933102654, 1.0) -(0.99607843137254903, 0.86254517493271821, 0.50975778546712802, 1.0) -(0.99607843137254903, 0.85873125720876586, 0.5016378316032295, 1.0) -(0.99607843137254903, 0.85491733948481352, 0.49351787773933098, 1.0) -(0.99607843137254903, 0.85110342176086129, 0.48539792387543262, 1.0) -(0.99607843137254903, 0.84728950403690884, 0.47727797001153399, 1.0) -(0.99607843137254903, 0.84347558631295649, 0.46915801614763553, 1.0) -(0.99607843137254903, 0.83966166858900426, 0.461038062283737, 1.0) -(0.99607843137254903, 0.83584775086505192, 0.45291810841983848, 1.0) -(0.99607843137254903, 0.83203383314109958, 0.44479815455594002, 1.0) -(0.99607843137254903, 0.82821991541714723, 0.43667820069204155, 1.0) -(0.99607843137254903, 0.82440599769319489, 0.42855824682814303, 1.0) -(0.99607843137254903, 0.82059207996924266, 0.42043829296424462, 1.0) -(0.99607843137254903, 0.81677816224529032, 0.41231833910034599, 1.0) -(0.99607843137254903, 0.81296424452133798, 0.40419838523644752, 1.0) -(0.99607843137254903, 0.80915032679738563, 0.39607843137254906, 1.0) -(0.99607843137254903, 0.80533640907343329, 0.38795847750865053, 1.0) -(0.99607843137254903, 0.80152249134948095, 0.37983852364475201, 1.0) -(0.99607843137254903, 0.79770857362552872, 0.37171856978085349, 1.0) -(0.99607843137254903, 0.79389465590157637, 0.36359861591695503, 1.0) -(0.99607843137254903, 0.79008073817762403, 0.35547866205305667, 1.0) -(0.99607843137254903, 0.78626682045367169, 0.34735870818915804, 1.0) -(0.99607843137254903, 0.78245290272971935, 0.33923875432525952, 1.0) -(0.99607843137254903, 0.77863898500576711, 0.331118800461361, 1.0) -(0.99607843137254903, 0.77482506728181477, 0.32299884659746253, 1.0) -(0.99607843137254903, 0.77101114955786243, 0.31487889273356401, 1.0) -(0.99607843137254903, 0.76664359861591702, 0.30805074971164936, 1.0) -(0.99607843137254903, 0.76135332564398317, 0.30337562475970781, 1.0) -(0.99607843137254903, 0.75606305267204932, 0.29870049980776631, 1.0) -(0.99607843137254903, 0.75077277970011536, 0.29402537485582469, 1.0) -(0.99607843137254903, 0.7454825067281815, 0.28935024990388314, 1.0) -(0.99607843137254903, 0.74019223375624765, 0.28467512495194158, 1.0) -(0.99607843137254903, 0.7349019607843138, 0.28000000000000003, 1.0) -(0.99607843137254903, 0.72961168781237984, 0.27532487504805847, 1.0) -(0.99607843137254903, 0.72432141484044599, 0.27064975009611691, 1.0) -(0.99607843137254903, 0.71903114186851214, 0.2659746251441753, 1.0) -(0.99607843137254903, 0.71374086889657828, 0.2612995001922338, 1.0) -(0.99607843137254903, 0.70845059592464443, 0.25662437524029219, 1.0) -(0.99607843137254903, 0.70316032295271047, 0.25194925028835063, 1.0) -(0.99607843137254903, 0.69787004998077662, 0.24727412533640908, 1.0) -(0.99607843137254903, 0.69257977700884277, 0.24259900038446752, 1.0) -(0.99607843137254903, 0.68728950403690892, 0.23792387543252597, 1.0) -(0.99607843137254903, 0.68199923106497506, 0.23324875048058441, 1.0) -(0.99607843137254903, 0.67670895809304121, 0.22857362552864285, 1.0) -(0.99607843137254903, 0.67141868512110736, 0.22389850057670135, 1.0) -(0.99607843137254903, 0.6661284121491734, 0.21922337562475974, 1.0) -(0.99607843137254903, 0.66083813917723955, 0.21454825067281819, 1.0) -(0.99607843137254903, 0.6555478662053057, 0.2098731257208766, 1.0) -(0.99607843137254903, 0.65025759323337184, 0.20519800076893505, 1.0) -(0.99607843137254903, 0.64496732026143788, 0.20052287581699346, 1.0) -(0.99607843137254903, 0.63967704728950403, 0.19584775086505191, 1.0) -(0.99607843137254903, 0.63438677431757018, 0.19117262591311035, 1.0) -(0.99607843137254903, 0.62909650134563633, 0.18649750096116885, 1.0) -(0.99607843137254903, 0.62380622837370248, 0.18182237600922724, 1.0) -(0.99607843137254903, 0.61851595540176851, 0.17714725105728568, 1.0) -(0.99607843137254903, 0.61322568242983466, 0.17247212610534413, 1.0) -(0.99607843137254903, 0.60793540945790081, 0.16779700115340257, 1.0) -(0.99607843137254903, 0.60264513648596696, 0.16312187620146099, 1.0) -(0.9949711649365629, 0.59747789311803146, 0.15949250288350636, 1.0) -(0.99275663206459053, 0.59243367935409452, 0.15690888119953866, 1.0) -(0.99054209919261826, 0.58738946559015759, 0.15432525951557094, 1.0) -(0.98832756632064589, 0.58234525182622066, 0.15174163783160324, 1.0) -(0.98611303344867363, 0.57730103806228383, 0.1491580161476356, 1.0) -(0.98389850057670125, 0.57225682429834679, 0.14657439446366782, 1.0) -(0.98168396770472899, 0.56721261053440986, 0.14399077277970013, 1.0) -(0.97946943483275661, 0.56216839677047292, 0.14140715109573243, 1.0) -(0.97725490196078435, 0.55712418300653588, 0.13882352941176471, 1.0) -(0.97504036908881198, 0.55207996924259894, 0.13623990772779701, 1.0) -(0.97282583621683971, 0.54703575547866201, 0.13365628604382931, 1.0) -(0.97061130334486734, 0.54199154171472508, 0.13107266435986159, 1.0) -(0.96839677047289507, 0.53694732795078814, 0.12848904267589389, 1.0) -(0.9661822376009227, 0.53190311418685121, 0.1259054209919262, 1.0) -(0.96396770472895044, 0.52685890042291428, 0.12332179930795847, 1.0) -(0.96175317185697806, 0.52181468665897734, 0.12073817762399078, 1.0) -(0.9595386389850058, 0.5167704728950403, 0.11815455594002307, 1.0) -(0.95732410611303342, 0.51172625913110337, 0.11557093425605536, 1.0) -(0.95510957324106116, 0.50668204536716643, 0.11298731257208766, 1.0) -(0.95289504036908879, 0.5016378316032295, 0.11040369088811995, 1.0) -(0.95068050749711663, 0.49659361783929268, 0.10782006920415232, 1.0) -(0.94846597462514426, 0.49154940407535563, 0.10523644752018455, 1.0) -(0.94625144175317188, 0.4865051903114187, 0.10265282583621685, 1.0) -(0.94403690888119962, 0.48146097654748171, 0.10006920415224912, 1.0) -(0.94182237600922725, 0.47641676278354478, 0.097485582468281429, 1.0) -(0.93960784313725498, 0.47137254901960779, 0.094901960784313719, 1.0) -(0.93739331026528261, 0.46632833525567086, 0.092318339100346022, 1.0) -(0.93517877739331035, 0.46128412149173392, 0.089734717416378312, 1.0) -(0.93296424452133797, 0.45623990772779699, 0.087151095732410602, 1.0) -(0.93074971164936571, 0.45119569396386006, 0.084567474048442906, 1.0) -(0.92853517877739333, 0.44615148019992312, 0.081983852364475196, 1.0) -(0.92632064590542107, 0.44110726643598613, 0.079400230680507486, 1.0) -(0.92302960399846212, 0.43644752018454441, 0.077047289504036914, 1.0) -(0.91909265667051143, 0.43201845444059978, 0.074832756632064595, 1.0) -(0.91515570934256063, 0.42758938869665514, 0.072618223760092276, 1.0) -(0.91121876201460983, 0.4231603229527105, 0.070403690888119957, 1.0) -(0.90728181468665914, 0.41873125720876597, 0.068189158016147694, 1.0) -(0.90334486735870823, 0.41430219146482122, 0.06597462514417532, 1.0) -(0.89940792003075742, 0.40987312572087659, 0.063760092272203001, 1.0) -(0.89547097270280662, 0.40544405997693195, 0.061545559400230682, 1.0) -(0.89153402537485582, 0.40101499423298731, 0.059331026528258363, 1.0) -(0.88759707804690513, 0.39658592848904267, 0.057116493656286044, 1.0) -(0.88366013071895433, 0.39215686274509803, 0.054901960784313725, 1.0) -(0.87972318339100353, 0.3877277970011534, 0.052687427912341406, 1.0) -(0.87578623606305273, 0.38329873125720876, 0.050472895040369087, 1.0) -(0.87184928873510192, 0.37886966551326412, 0.048258362168396768, 1.0) -(0.86791234140715112, 0.37444059976931948, 0.046043829296424456, 1.0) -(0.86397539407920032, 0.37001153402537484, 0.043829296424452137, 1.0) -(0.86003844675124952, 0.36558246828143021, 0.041614763552479811, 1.0) -(0.85610149942329872, 0.36115340253748557, 0.039400230680507492, 1.0) -(0.85216455209534803, 0.35672433679354093, 0.037185697808535173, 1.0) -(0.84822760476739723, 0.35229527104959629, 0.034971164936562861, 1.0) -(0.84429065743944653, 0.34786620530565182, 0.032756632064590605, 1.0) -(0.84035371011149562, 0.34343713956170702, 0.030542099192618223, 1.0) -(0.83641676278354482, 0.33900807381776238, 0.028327566320645904, 1.0) -(0.83247981545559402, 0.33457900807381774, 0.026113033448673585, 1.0) -(0.82854286812764322, 0.3301499423298731, 0.023898500576701266, 1.0) -(0.82460592079969253, 0.32572087658592846, 0.021683967704728947, 1.0) -(0.82066897347174173, 0.32129181084198383, 0.019469434832756628, 1.0) -(0.81673202614379092, 0.31686274509803919, 0.017254901960784309, 1.0) -(0.81279507881584012, 0.31243367935409461, 0.015040369088811997, 1.0) -(0.80885813148788932, 0.30800461361014997, 0.012825836216839678, 1.0) -(0.80492118415993852, 0.30357554786620533, 0.010611303344867359, 1.0) -(0.80098423683198772, 0.29914648212226069, 0.0083967704728950404, 1.0) -(0.79529411764705882, 0.29582468281430219, 0.0080276816608996545, 1.0) -(0.78901960784313729, 0.29287197231833911, 0.0082737408688965779, 1.0) -(0.78274509803921577, 0.28991926182237598, 0.008519800076893503, 1.0) -(0.77647058823529413, 0.28696655132641291, 0.0087658592848904263, 1.0) -(0.77019607843137272, 0.28401384083044989, 0.0090119184928873445, 1.0) -(0.76392156862745098, 0.28106113033448671, 0.0092579777008842748, 1.0) -(0.75764705882352945, 0.27810841983852364, 0.0095040369088811999, 1.0) -(0.75137254901960793, 0.27515570934256056, 0.0097500961168781233, 1.0) -(0.74509803921568629, 0.27220299884659743, 0.0099961553248750484, 1.0) -(0.73882352941176477, 0.26925028835063436, 0.010242214532871972, 1.0) -(0.73254901960784313, 0.26629757785467129, 0.010488273740868897, 1.0) -(0.72627450980392161, 0.26334486735870821, 0.010734332948865822, 1.0) -(0.71999999999999997, 0.26039215686274508, 0.010980392156862745, 1.0) -(0.71372549019607845, 0.25743944636678201, 0.011226451364859669, 1.0) -(0.70745098039215693, 0.25448673587081894, 0.011472510572856594, 1.0) -(0.70117647058823529, 0.25153402537485581, 0.011718569780853519, 1.0) -(0.69490196078431377, 0.24858131487889273, 0.011964628988850442, 1.0) -(0.68862745098039213, 0.24562860438292963, 0.012210688196847366, 1.0) -(0.68235294117647061, 0.24267589388696653, 0.012456747404844291, 1.0) -(0.67607843137254897, 0.23972318339100346, 0.012702806612841216, 1.0) -(0.66980392156862756, 0.23677047289504044, 0.012948865820838132, 1.0) -(0.66352941176470592, 0.23381776239907726, 0.013194925028835063, 1.0) -(0.65725490196078429, 0.23086505190311418, 0.013440984236831988, 1.0) -(0.65098039215686276, 0.22791234140715111, 0.013687043444828913, 1.0) -(0.64470588235294113, 0.22495963091118798, 0.013933102652825836, 1.0) -(0.6384313725490196, 0.22200692041522491, 0.014179161860822759, 1.0) -(0.63215686274509797, 0.21905420991926183, 0.014425221068819685, 1.0) -(0.62588235294117645, 0.21610149942329873, 0.01467128027681661, 1.0) -(0.61960784313725492, 0.21314878892733563, 0.014917339484813533, 1.0) -(0.61333333333333329, 0.21019607843137256, 0.015163398692810456, 1.0) -(0.60705882352941176, 0.20724336793540946, 0.015409457900807381, 1.0) -(0.60078431372549024, 0.20429065743944635, 0.015655517108804307, 1.0) -(0.5945098039215686, 0.20230680507497117, 0.015901576316801232, 1.0) -(0.58823529411764708, 0.20046136101499423, 0.016147635524798153, 1.0) -(0.58196078431372544, 0.19861591695501729, 0.016393694732795078, 1.0) -(0.57568627450980392, 0.19677047289504038, 0.016639753940792004, 1.0) -(0.56941176470588251, 0.19492502883506349, 0.016885813148788918, 1.0) -(0.56313725490196076, 0.19307958477508649, 0.01713187235678585, 1.0) -(0.55686274509803924, 0.19123414071510958, 0.017377931564782775, 1.0) -(0.5505882352941176, 0.18938869665513264, 0.0176239907727797, 1.0) -(0.54431372549019608, 0.1875432525951557, 0.017870049980776622, 1.0) -(0.53803921568627455, 0.18569780853517878, 0.018116109188773547, 1.0) -(0.53176470588235292, 0.18385236447520184, 0.018362168396770472, 1.0) -(0.52549019607843139, 0.18200692041522493, 0.018608227604767394, 1.0) -(0.51921568627450976, 0.18016147635524798, 0.018854286812764319, 1.0) -(0.51294117647058823, 0.17831603229527104, 0.019100346020761244, 1.0) -(0.50666666666666671, 0.17647058823529413, 0.019346405228758169, 1.0) -(0.50039215686274507, 0.17462514417531719, 0.019592464436755091, 1.0) -(0.49411764705882355, 0.17277970011534027, 0.019838523644752016, 1.0) -(0.48784313725490197, 0.17093425605536333, 0.020084582852748941, 1.0) -(0.48156862745098039, 0.16908881199538639, 0.020330642060745863, 1.0) -(0.47529411764705881, 0.16724336793540945, 0.020576701268742788, 1.0) -(0.46901960784313745, 0.16539792387543259, 0.020822760476739706, 1.0) -(0.46274509803921571, 0.16355247981545559, 0.021068819684736638, 1.0) -(0.45647058823529413, 0.16170703575547868, 0.021314878892733563, 1.0) -(0.45019607843137255, 0.15986159169550174, 0.021560938100730485, 1.0) -(0.44392156862745102, 0.1580161476355248, 0.02180699730872741, 1.0) -(0.43764705882352939, 0.15617070357554788, 0.022053056516724335, 1.0) -(0.43137254901960786, 0.15432525951557094, 0.022299115724721257, 1.0) -(0.42509803921568629, 0.15247981545559403, 0.022545174932718182, 1.0) -(0.41882352941176471, 0.15063437139561708, 0.022791234140715107, 1.0) -(0.41254901960784318, 0.14878892733564014, 0.023037293348712032, 1.0) -(0.4062745098039216, 0.14694348327566323, 0.023283352556708953, 1.0) -(0.40000000000000002, 0.14509803921568629, 0.023529411764705879, 1.0) diff --git a/extern/tfn/colormaps/sequential/YlOrRd.cpp b/extern/tfn/colormaps/sequential/YlOrRd.cpp deleted file mode 100644 index 5cea4de..0000000 --- a/extern/tfn/colormaps/sequential/YlOrRd.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential_YlOrRd; -} -const std::vector colormap::data_sequential_YlOrRd = /* NOLINT(cert-err58-cpp) */ -{ -{1.0f, 1.0f, 0.80000000000000004f, 1.0f}, -{1.0f, 0.99778546712802774f, 0.79458669742406773f, 1.0f}, -{1.0f, 0.99557093425605536f, 0.78917339484813542f, 1.0f}, -{1.0f, 0.9933564013840831f, 0.783760092272203f, 1.0f}, -{1.0f, 0.99114186851211072f, 0.77834678969627069f, 1.0f}, -{1.0f, 0.98892733564013846f, 0.77293348712033838f, 1.0f}, -{1.0f, 0.98671280276816609f, 0.76752018454440607f, 1.0f}, -{1.0f, 0.98449826989619382f, 0.76210688196847365f, 1.0f}, -{1.0f, 0.98228373702422145f, 0.75669357939254134f, 1.0f}, -{1.0f, 0.98006920415224918f, 0.75128027681660903f, 1.0f}, -{1.0f, 0.97785467128027681f, 0.74586697424067672f, 1.0f}, -{1.0f, 0.97564013840830455f, 0.74045367166474441f, 1.0f}, -{1.0f, 0.97342560553633217f, 0.73504036908881198f, 1.0f}, -{1.0f, 0.97121107266435991f, 0.72962706651287967f, 1.0f}, -{1.0f, 0.96899653979238753f, 0.72421376393694736f, 1.0f}, -{1.0f, 0.96678200692041527f, 0.71880046136101505f, 1.0f}, -{1.0f, 0.9645674740484429f, 0.71338715878508263f, 1.0f}, -{1.0f, 0.96235294117647063f, 0.70797385620915032f, 1.0f}, -{1.0f, 0.96013840830449826f, 0.70256055363321801f, 1.0f}, -{1.0f, 0.957923875432526f, 0.6971472510572857f, 1.0f}, -{1.0f, 0.95570934256055362f, 0.69173394848135339f, 1.0f}, -{1.0f, 0.95349480968858136f, 0.68632064590542097f, 1.0f}, -{1.0f, 0.95128027681660898f, 0.68090734332948866f, 1.0f}, -{1.0f, 0.94906574394463672f, 0.67549404075355635f, 1.0f}, -{1.0f, 0.94685121107266434f, 0.67008073817762404f, 1.0f}, -{1.0f, 0.94463667820069208f, 0.66466743560169173f, 1.0f}, -{1.0f, 0.94242214532871971f, 0.6592541330257593f, 1.0f}, -{1.0f, 0.94020761245674744f, 0.65384083044982699f, 1.0f}, -{1.0f, 0.93799307958477507f, 0.64842752787389468f, 1.0f}, -{1.0f, 0.93577854671280281f, 0.64301422529796226f, 1.0f}, -{1.0f, 0.93356401384083043f, 0.63760092272202995f, 1.0f}, -{1.0f, 0.93134948096885817f, 0.63218762014609764f, 1.0f}, -{0.99998462129950016f, 0.92910419069588623f, 0.62680507497116489f, 1.0f}, -{0.99986159169550171f, 0.92664359861591705f, 0.62163783160322961f, 1.0f}, -{0.99973856209150325f, 0.92418300653594776f, 0.6164705882352941f, 1.0f}, -{0.99961553248750479f, 0.92172241445597847f, 0.61130334486735871f, 1.0f}, -{0.99949250288350633f, 0.91926182237600929f, 0.60613610149942332f, 1.0f}, -{0.99936947327950787f, 0.91680123029603999f, 0.60096885813148793f, 1.0f}, -{0.99924644367550941f, 0.91434063821607081f, 0.59580161476355253f, 1.0f}, -{0.99912341407151095f, 0.91188004613610152f, 0.59063437139561703f, 1.0f}, -{0.99900038446751249f, 0.90941945405613223f, 0.58546712802768164f, 1.0f}, -{0.99887735486351403f, 0.90695886197616304f, 0.58029988465974625f, 1.0f}, -{0.99875432525951557f, 0.90449826989619375f, 0.57513264129181085f, 1.0f}, -{0.99863129565551711f, 0.90203767781622457f, 0.56996539792387546f, 1.0f}, -{0.99850826605151866f, 0.89957708573625528f, 0.56479815455594007f, 1.0f}, -{0.9983852364475202f, 0.8971164936562861f, 0.55963091118800468f, 1.0f}, -{0.99826220684352174f, 0.8946559015763168f, 0.55446366782006917f, 1.0f}, -{0.99813917723952328f, 0.89219530949634751f, 0.54929642445213378f, 1.0f}, -{0.99801614763552482f, 0.88973471741637833f, 0.54412918108419839f, 1.0f}, -{0.99789311803152636f, 0.88727412533640915f, 0.538961937716263f, 1.0f}, -{0.9977700884275279f, 0.88481353325643985f, 0.5337946943483276f, 1.0f}, -{0.99764705882352944f, 0.88235294117647056f, 0.52862745098039221f, 1.0f}, -{0.99752402921953098f, 0.87989234909650138f, 0.52346020761245682f, 1.0f}, -{0.99740099961553252f, 0.87743175701653209f, 0.51829296424452143f, 1.0f}, -{0.99727797001153407f, 0.8749711649365628f, 0.51312572087658592f, 1.0f}, -{0.99715494040753561f, 0.87251057285659361f, 0.50795847750865053f, 1.0f}, -{0.99703191080353715f, 0.87004998077662432f, 0.50279123414071514f, 1.0f}, -{0.99690888119953869f, 0.86758938869665514f, 0.49762399077277975f, 1.0f}, -{0.99678585159554023f, 0.86512879661668585f, 0.4924567474048443f, 1.0f}, -{0.99666282199154177f, 0.86266820453671667f, 0.4872895040369089f, 1.0f}, -{0.99653979238754331f, 0.86020761245674737f, 0.48212226066897346f, 1.0f}, -{0.99641676278354485f, 0.85774702037677819f, 0.47695501730103812f, 1.0f}, -{0.99629373317954639f, 0.8552864282968089f, 0.47178777393310267f, 1.0f}, -{0.99617070357554793f, 0.85282583621683972f, 0.46662053056516728f, 1.0f}, -{0.99607843137254903f, 0.84978085351787769f, 0.46145328719723183f, 1.0f}, -{0.99607843137254903f, 0.84498269896193767f, 0.45628604382929644f, 1.0f}, -{0.99607843137254903f, 0.84018454440599777f, 0.4511188004613611f, 1.0f}, -{0.99607843137254903f, 0.83538638985005764f, 0.4459515570934256f, 1.0f}, -{0.99607843137254903f, 0.83058823529411763f, 0.44078431372549021f, 1.0f}, -{0.99607843137254903f, 0.82579008073817761f, 0.43561707035755481f, 1.0f}, -{0.99607843137254903f, 0.8209919261822376f, 0.43044982698961942f, 1.0f}, -{0.99607843137254903f, 0.81619377162629758f, 0.42528258362168397f, 1.0f}, -{0.99607843137254903f, 0.81139561707035757f, 0.42011534025374858f, 1.0f}, -{0.99607843137254903f, 0.80659746251441744f, 0.41494809688581313f, 1.0f}, -{0.99607843137254903f, 0.80179930795847754f, 0.40978085351787785f, 1.0f}, -{0.99607843137254903f, 0.79700115340253741f, 0.40461361014994235f, 1.0f}, -{0.99607843137254903f, 0.79220299884659739f, 0.39944636678200696f, 1.0f}, -{0.99607843137254903f, 0.78740484429065738f, 0.39427912341407151f, 1.0f}, -{0.99607843137254903f, 0.78260668973471736f, 0.38911188004613612f, 1.0f}, -{0.99607843137254903f, 0.77780853517877735f, 0.38394463667820067f, 1.0f}, -{0.99607843137254903f, 0.77301038062283733f, 0.37877739331026528f, 1.0f}, -{0.99607843137254903f, 0.76821222606689732f, 0.37361014994232988f, 1.0f}, -{0.99607843137254903f, 0.76341407151095741f, 0.36844290657439455f, 1.0f}, -{0.99607843137254903f, 0.75861591695501729f, 0.3632756632064591f, 1.0f}, -{0.99607843137254903f, 0.75381776239907727f, 0.35810841983852365f, 1.0f}, -{0.99607843137254903f, 0.74901960784313726f, 0.35294117647058826f, 1.0f}, -{0.99607843137254903f, 0.74422145328719724f, 0.34777393310265281f, 1.0f}, -{0.99607843137254903f, 0.73942329873125723f, 0.34260668973471742f, 1.0f}, -{0.99607843137254903f, 0.7346251441753171f, 0.33743944636678203f, 1.0f}, -{0.99607843137254903f, 0.72982698961937709f, 0.33227220299884663f, 1.0f}, -{0.99607843137254903f, 0.72502883506343718f, 0.32710495963091124f, 1.0f}, -{0.99607843137254903f, 0.72023068050749706f, 0.32193771626297579f, 1.0f}, -{0.99607843137254903f, 0.71543252595155704f, 0.31677047289504034f, 1.0f}, -{0.99607843137254903f, 0.71063437139561703f, 0.31160322952710495f, 1.0f}, -{0.99607843137254903f, 0.70583621683967701f, 0.30643598615916956f, 1.0f}, -{0.99607843137254903f, 0.701038062283737f, 0.30126874279123417f, 1.0f}, -{0.99603229527104964f, 0.69633217993079577f, 0.29730103806228375f, 1.0f}, -{0.99590926566705118f, 0.69178008458285267f, 0.29533256439830835f, 1.0f}, -{0.99578623606305272f, 0.68722798923490969f, 0.29336409073433295f, 1.0f}, -{0.99566320645905426f, 0.68267589388696648f, 0.29139561707035755f, 1.0f}, -{0.9955401768550558f, 0.67812379853902338f, 0.28942714340638215f, 1.0f}, -{0.99541714725105734f, 0.67357170319108028f, 0.28745866974240675f, 1.0f}, -{0.99529411764705888f, 0.66901960784313719f, 0.28549019607843135f, 1.0f}, -{0.99517108804306043f, 0.66446751249519409f, 0.28352172241445595f, 1.0f}, -{0.99504805843906197f, 0.65991541714725099f, 0.2815532487504806f, 1.0f}, -{0.99492502883506351f, 0.6553633217993079f, 0.2795847750865052f, 1.0f}, -{0.99480199923106505f, 0.65081122645136491f, 0.2776163014225298f, 1.0f}, -{0.99467896962706648f, 0.6462591311034217f, 0.2756478277585544f, 1.0f}, -{0.99455594002306802f, 0.64170703575547861f, 0.273679354094579f, 1.0f}, -{0.99443291041906956f, 0.63715494040753551f, 0.2717108804306036f, 1.0f}, -{0.9943098808150711f, 0.63260284505959241f, 0.2697424067666282f, 1.0f}, -{0.99418685121107264f, 0.62805074971164931f, 0.26777393310265285f, 1.0f}, -{0.99406382160707418f, 0.62349865436370622f, 0.26580545943867745f, 1.0f}, -{0.99394079200307572f, 0.61894655901576323f, 0.26383698577470205f, 1.0f}, -{0.99381776239907726f, 0.61439446366782013f, 0.26186851211072665f, 1.0f}, -{0.99369473279507881f, 0.60984236831987704f, 0.25990003844675125f, 1.0f}, -{0.99357170319108035f, 0.60529027297193383f, 0.25793156478277585f, 1.0f}, -{0.99344867358708189f, 0.60073817762399084f, 0.25596309111880045f, 1.0f}, -{0.99332564398308343f, 0.59618608227604764f, 0.25399461745482504f, 1.0f}, -{0.99320261437908497f, 0.59163398692810465f, 0.25202614379084964f, 1.0f}, -{0.99307958477508651f, 0.58708189158016144f, 0.2500576701268743f, 1.0f}, -{0.99295655517108805f, 0.58252979623221846f, 0.2480891964628989f, 1.0f}, -{0.99283352556708959f, 0.57797770088427536f, 0.24612072279892352f, 1.0f}, -{0.99271049596309113f, 0.57342560553633226f, 0.2441522491349481f, 1.0f}, -{0.99258746635909267f, 0.56887351018838905f, 0.2421837754709727f, 1.0f}, -{0.99246443675509421f, 0.56432141484044607f, 0.24021530180699729f, 1.0f}, -{0.99234140715109576f, 0.55976931949250286f, 0.23824682814302192f, 1.0f}, -{0.9922183775470973f, 0.55521722414455987f, 0.23627835447904652f, 1.0f}, -{0.99209534794309884f, 0.5490657439446367f, 0.23418685121107266f, 1.0f}, -{0.99197231833910038f, 0.54131487889273355f, 0.23197231833910034f, 1.0f}, -{0.99184928873510192f, 0.53356401384083052f, 0.22975778546712802f, 1.0f}, -{0.99172625913110346f, 0.52581314878892738f, 0.2275432525951557f, 1.0f}, -{0.991603229527105f, 0.51806228373702445f, 0.22532871972318344f, 1.0f}, -{0.99148019992310654f, 0.5103114186851212f, 0.22311418685121107f, 1.0f}, -{0.99135717031910808f, 0.50256055363321805f, 0.22089965397923875f, 1.0f}, -{0.99123414071510962f, 0.49480968858131491f, 0.21868512110726643f, 1.0f}, -{0.99111111111111116f, 0.48705882352941177f, 0.21647058823529411f, 1.0f}, -{0.99098808150711271f, 0.47930795847750868f, 0.21425605536332179f, 1.0f}, -{0.99086505190311425f, 0.47155709342560559f, 0.21204152249134947f, 1.0f}, -{0.99074202229911579f, 0.46380622837370244f, 0.20982698961937715f, 1.0f}, -{0.99061899269511733f, 0.45605536332179936f, 0.20761245674740483f, 1.0f}, -{0.99049596309111887f, 0.44830449826989621f, 0.20539792387543251f, 1.0f}, -{0.99037293348712041f, 0.44055363321799312f, 0.2031833910034602f, 1.0f}, -{0.99024990388312195f, 0.43280276816608998f, 0.2009688581314879f, 1.0f}, -{0.99012687427912349f, 0.42505190311418684f, 0.19875432525951556f, 1.0f}, -{0.99000384467512503f, 0.41730103806228375f, 0.19653979238754324f, 1.0f}, -{0.98988081507112657f, 0.40955017301038066f, 0.19432525951557092f, 1.0f}, -{0.98975778546712812f, 0.40179930795847751f, 0.1921107266435986f, 1.0f}, -{0.98963475586312966f, 0.39404844290657459f, 0.18989619377162636f, 1.0f}, -{0.98951172625913109f, 0.38629757785467134f, 0.18768166089965399f, 1.0f}, -{0.98938869665513263f, 0.37854671280276819f, 0.18546712802768167f, 1.0f}, -{0.98926566705113417f, 0.37079584775086505f, 0.18325259515570935f, 1.0f}, -{0.98914263744713571f, 0.36304498269896196f, 0.18103806228373703f, 1.0f}, -{0.98901960784313725f, 0.35529411764705887f, 0.17882352941176471f, 1.0f}, -{0.98889657823913879f, 0.34754325259515573f, 0.1766089965397924f, 1.0f}, -{0.98877354863514033f, 0.33979238754325258f, 0.17439446366782008f, 1.0f}, -{0.98865051903114187f, 0.33204152249134949f, 0.17217993079584776f, 1.0f}, -{0.98852748942714341f, 0.32429065743944641f, 0.16996539792387544f, 1.0f}, -{0.98840445982314495f, 0.31653979238754326f, 0.16775086505190312f, 1.0f}, -{0.9882814302191465f, 0.30878892733564012f, 0.1655363321799308f, 1.0f}, -{0.98631295655517115f, 0.30188389081122646f, 0.16362937331795463f, 1.0f}, -{0.98323721645520956f, 0.29548635140330642f, 0.16190695886197615f, 1.0f}, -{0.98016147635524797f, 0.28908881199538639f, 0.16018454440599769f, 1.0f}, -{0.9770857362552865f, 0.2826912725874664f, 0.15846212995001921f, 1.0f}, -{0.97400999615532502f, 0.27629373317954653f, 0.15673971549404081f, 1.0f}, -{0.97093425605536332f, 0.26989619377162632f, 0.15501730103806227f, 1.0f}, -{0.96785851595540184f, 0.26349865436370629f, 0.15329488658208382f, 1.0f}, -{0.96478277585544026f, 0.25710111495578625f, 0.15157247212610533f, 1.0f}, -{0.96170703575547867f, 0.25070357554786621f, 0.14985005767012688f, 1.0f}, -{0.95863129565551708f, 0.2443060361399462f, 0.1481276432141484f, 1.0f}, -{0.9555555555555556f, 0.23790849673202616f, 0.14640522875816994f, 1.0f}, -{0.95247981545559401f, 0.23151095732410615f, 0.14468281430219146f, 1.0f}, -{0.94940407535563243f, 0.22511341791618611f, 0.142960399846213f, 1.0f}, -{0.94632833525567095f, 0.21871587850826607f, 0.14123798539023452f, 1.0f}, -{0.94325259515570936f, 0.21231833910034603f, 0.13951557093425604f, 1.0f}, -{0.94017685505574777f, 0.20592079969242599f, 0.13779315647827758f, 1.0f}, -{0.93710111495578619f, 0.19952326028450595f, 0.1360707420222991f, 1.0f}, -{0.93402537485582471f, 0.19312572087658592f, 0.13434832756632065f, 1.0f}, -{0.93094963475586312f, 0.1867281814686659f, 0.13262591311034216f, 1.0f}, -{0.92787389465590153f, 0.18033064206074587f, 0.13090349865436371f, 1.0f}, -{0.92479815455594006f, 0.17393310265282602f, 0.12918108419838528f, 1.0f}, -{0.92172241445597847f, 0.16753556324490582f, 0.12745866974240677f, 1.0f}, -{0.91864667435601688f, 0.16113802383698578f, 0.12573625528642829f, 1.0f}, -{0.91557093425605529f, 0.15474048442906574f, 0.12401384083044982f, 1.0f}, -{0.91249519415609381f, 0.1483429450211457f, 0.12229142637447135f, 1.0f}, -{0.90941945405613223f, 0.14194540561322569f, 0.12056901191849288f, 1.0f}, -{0.90634371395617064f, 0.13554786620530565f, 0.11884659746251441f, 1.0f}, -{0.90326797385620905f, 0.12915032679738561f, 0.11712418300653595f, 1.0f}, -{0.90019223375624757f, 0.12275278738946557f, 0.11540176855055748f, 1.0f}, -{0.89711649365628598f, 0.11635524798154556f, 0.11367935409457901f, 1.0f}, -{0.8940407535563244f, 0.10995770857362552f, 0.11195693963860054f, 1.0f}, -{0.89096501345636292f, 0.10356016916570548f, 0.11023452518262206f, 1.0f}, -{0.8866897347174163f, 0.099561707035755481f, 0.11072664359861592f, 1.0f}, -{0.88201460976547474f, 0.096362937331795462f, 0.11195693963860054f, 1.0f}, -{0.87733948481353319f, 0.093164167627835442f, 0.11318723567858516f, 1.0f}, -{0.87266435986159163f, 0.089965397923875437f, 0.11441753171856978f, 1.0f}, -{0.86798923490965019f, 0.086766628219915501f, 0.11564782775855437f, 1.0f}, -{0.86331410995770852f, 0.083567858515955398f, 0.11687812379853903f, 1.0f}, -{0.85863898500576696f, 0.080369088811995393f, 0.11810841983852365f, 1.0f}, -{0.85396386005382541f, 0.077170319108035373f, 0.11933871587850826f, 1.0f}, -{0.84928873510188385f, 0.073971549404075354f, 0.12056901191849288f, 1.0f}, -{0.8446136101499423f, 0.070772779700115335f, 0.12179930795847752f, 1.0f}, -{0.83993848519800074f, 0.067574009996155315f, 0.12302960399846213f, 1.0f}, -{0.83526336024605918f, 0.064375240292195296f, 0.12425990003844675f, 1.0f}, -{0.83058823529411763f, 0.06117647058823529f, 0.12549019607843137f, 1.0f}, -{0.82591311034217607f, 0.057977700884275278f, 0.12672049211841599f, 1.0f}, -{0.82123798539023452f, 0.054778931180315259f, 0.12795078815840061f, 1.0f}, -{0.81656286043829296f, 0.051580161476355246f, 0.12918108419838523f, 1.0f}, -{0.8118877354863514f, 0.048381391772395227f, 0.13041138023836985f, 1.0f}, -{0.80721261053440985f, 0.045182622068435215f, 0.13164167627835449f, 1.0f}, -{0.80253748558246829f, 0.041983852364475202f, 0.13287197231833911f, 1.0f}, -{0.79786236063052673f, 0.038785082660515183f, 0.13410226835832373f, 1.0f}, -{0.79318723567858529f, 0.035586312956555261f, 0.13533256439830832f, 1.0f}, -{0.78851211072664362f, 0.032387543252595158f, 0.13656286043829297f, 1.0f}, -{0.78383698577470207f, 0.029188773548635139f, 0.13779315647827758f, 1.0f}, -{0.77916186082276051f, 0.025990003844675119f, 0.1390234525182622f, 1.0f}, -{0.77448673587081895f, 0.022791234140715114f, 0.14025374855824682f, 1.0f}, -{0.7698116109188774f, 0.019592464436755094f, 0.14148404459823144f, 1.0f}, -{0.76513648596693584f, 0.016393694732795075f, 0.14271434063821609f, 1.0f}, -{0.76046136101499429f, 0.013194925028835056f, 0.14394463667820068f, 1.0f}, -{0.75578623606305273f, 0.0099961553248750501f, 0.14517493271818532f, 1.0f}, -{0.75111111111111117f, 0.0067973856209150307f, 0.14640522875816994f, 1.0f}, -{0.74643598615916962f, 0.0035986159169550114f, 0.14763552479815456f, 1.0f}, -{0.74176086120722795f, 0.00039984621299500589f, 0.14886582083813918f, 1.0f}, -{0.73460976547481738f, 0.0f, 0.14901960784313725f, 1.0f}, -{0.72710495963091126f, 0.0f, 0.14901960784313725f, 1.0f}, -{0.71960015378700504f, 0.0f, 0.14901960784313725f, 1.0f}, -{0.71209534794309881f, 0.0f, 0.14901960784313725f, 1.0f}, -{0.70459054209919292f, 0.0f, 0.14901960784313725f, 1.0f}, -{0.69708573625528647f, 0.0f, 0.14901960784313725f, 1.0f}, -{0.68958093041138024f, 0.0f, 0.14901960784313725f, 1.0f}, -{0.68207612456747402f, 0.0f, 0.14901960784313725f, 1.0f}, -{0.6745713187235679f, 0.0f, 0.14901960784313725f, 1.0f}, -{0.66706651287966168f, 0.0f, 0.14901960784313725f, 1.0f}, -{0.65956170703575545f, 0.0f, 0.14901960784313725f, 1.0f}, -{0.65205690119184934f, 0.0f, 0.14901960784313725f, 1.0f}, -{0.64455209534794311f, 0.0f, 0.14901960784313725f, 1.0f}, -{0.63704728950403688f, 0.0f, 0.14901960784313725f, 1.0f}, -{0.62954248366013077f, 0.0f, 0.14901960784313725f, 1.0f}, -{0.62203767781622454f, 0.0f, 0.14901960784313725f, 1.0f}, -{0.61453287197231832f, 0.0f, 0.14901960784313725f, 1.0f}, -{0.6070280661284122f, 0.0f, 0.14901960784313725f, 1.0f}, -{0.59952326028450598f, 0.0f, 0.14901960784313725f, 1.0f}, -{0.59201845444059975f, 0.0f, 0.14901960784313725f, 1.0f}, -{0.58451364859669375f, 0.0f, 0.14901960784313725f, 1.0f}, -{0.57700884275278741f, 0.0f, 0.14901960784313725f, 1.0f}, -{0.56950403690888118f, 0.0f, 0.14901960784313725f, 1.0f}, -{0.56199923106497507f, 0.0f, 0.14901960784313725f, 1.0f}, -{0.55449442522106884f, 0.0f, 0.14901960784313725f, 1.0f}, -{0.54698961937716262f, 0.0f, 0.14901960784313725f, 1.0f}, -{0.53948481353325639f, 0.0f, 0.14901960784313725f, 1.0f}, -{0.53198000768935028f, 0.0f, 0.14901960784313725f, 1.0f}, -{0.52447520184544405f, 0.0f, 0.14901960784313725f, 1.0f}, -{0.51697039600153782f, 0.0f, 0.14901960784313725f, 1.0f}, -{0.50946559015763171f, 0.0f, 0.14901960784313725f, 1.0f}, -{0.50196078431372548f, 0.0f, 0.14901960784313725f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential/YlOrRd.txt b/extern/tfn/colormaps/sequential/YlOrRd.txt deleted file mode 100644 index 903129f..0000000 --- a/extern/tfn/colormaps/sequential/YlOrRd.txt +++ /dev/null @@ -1,256 +0,0 @@ -(1.0, 1.0, 0.80000000000000004, 1.0) -(1.0, 0.99778546712802774, 0.79458669742406773, 1.0) -(1.0, 0.99557093425605536, 0.78917339484813542, 1.0) -(1.0, 0.9933564013840831, 0.783760092272203, 1.0) -(1.0, 0.99114186851211072, 0.77834678969627069, 1.0) -(1.0, 0.98892733564013846, 0.77293348712033838, 1.0) -(1.0, 0.98671280276816609, 0.76752018454440607, 1.0) -(1.0, 0.98449826989619382, 0.76210688196847365, 1.0) -(1.0, 0.98228373702422145, 0.75669357939254134, 1.0) -(1.0, 0.98006920415224918, 0.75128027681660903, 1.0) -(1.0, 0.97785467128027681, 0.74586697424067672, 1.0) -(1.0, 0.97564013840830455, 0.74045367166474441, 1.0) -(1.0, 0.97342560553633217, 0.73504036908881198, 1.0) -(1.0, 0.97121107266435991, 0.72962706651287967, 1.0) -(1.0, 0.96899653979238753, 0.72421376393694736, 1.0) -(1.0, 0.96678200692041527, 0.71880046136101505, 1.0) -(1.0, 0.9645674740484429, 0.71338715878508263, 1.0) -(1.0, 0.96235294117647063, 0.70797385620915032, 1.0) -(1.0, 0.96013840830449826, 0.70256055363321801, 1.0) -(1.0, 0.957923875432526, 0.6971472510572857, 1.0) -(1.0, 0.95570934256055362, 0.69173394848135339, 1.0) -(1.0, 0.95349480968858136, 0.68632064590542097, 1.0) -(1.0, 0.95128027681660898, 0.68090734332948866, 1.0) -(1.0, 0.94906574394463672, 0.67549404075355635, 1.0) -(1.0, 0.94685121107266434, 0.67008073817762404, 1.0) -(1.0, 0.94463667820069208, 0.66466743560169173, 1.0) -(1.0, 0.94242214532871971, 0.6592541330257593, 1.0) -(1.0, 0.94020761245674744, 0.65384083044982699, 1.0) -(1.0, 0.93799307958477507, 0.64842752787389468, 1.0) -(1.0, 0.93577854671280281, 0.64301422529796226, 1.0) -(1.0, 0.93356401384083043, 0.63760092272202995, 1.0) -(1.0, 0.93134948096885817, 0.63218762014609764, 1.0) -(0.99998462129950016, 0.92910419069588623, 0.62680507497116489, 1.0) -(0.99986159169550171, 0.92664359861591705, 0.62163783160322961, 1.0) -(0.99973856209150325, 0.92418300653594776, 0.6164705882352941, 1.0) -(0.99961553248750479, 0.92172241445597847, 0.61130334486735871, 1.0) -(0.99949250288350633, 0.91926182237600929, 0.60613610149942332, 1.0) -(0.99936947327950787, 0.91680123029603999, 0.60096885813148793, 1.0) -(0.99924644367550941, 0.91434063821607081, 0.59580161476355253, 1.0) -(0.99912341407151095, 0.91188004613610152, 0.59063437139561703, 1.0) -(0.99900038446751249, 0.90941945405613223, 0.58546712802768164, 1.0) -(0.99887735486351403, 0.90695886197616304, 0.58029988465974625, 1.0) -(0.99875432525951557, 0.90449826989619375, 0.57513264129181085, 1.0) -(0.99863129565551711, 0.90203767781622457, 0.56996539792387546, 1.0) -(0.99850826605151866, 0.89957708573625528, 0.56479815455594007, 1.0) -(0.9983852364475202, 0.8971164936562861, 0.55963091118800468, 1.0) -(0.99826220684352174, 0.8946559015763168, 0.55446366782006917, 1.0) -(0.99813917723952328, 0.89219530949634751, 0.54929642445213378, 1.0) -(0.99801614763552482, 0.88973471741637833, 0.54412918108419839, 1.0) -(0.99789311803152636, 0.88727412533640915, 0.538961937716263, 1.0) -(0.9977700884275279, 0.88481353325643985, 0.5337946943483276, 1.0) -(0.99764705882352944, 0.88235294117647056, 0.52862745098039221, 1.0) -(0.99752402921953098, 0.87989234909650138, 0.52346020761245682, 1.0) -(0.99740099961553252, 0.87743175701653209, 0.51829296424452143, 1.0) -(0.99727797001153407, 0.8749711649365628, 0.51312572087658592, 1.0) -(0.99715494040753561, 0.87251057285659361, 0.50795847750865053, 1.0) -(0.99703191080353715, 0.87004998077662432, 0.50279123414071514, 1.0) -(0.99690888119953869, 0.86758938869665514, 0.49762399077277975, 1.0) -(0.99678585159554023, 0.86512879661668585, 0.4924567474048443, 1.0) -(0.99666282199154177, 0.86266820453671667, 0.4872895040369089, 1.0) -(0.99653979238754331, 0.86020761245674737, 0.48212226066897346, 1.0) -(0.99641676278354485, 0.85774702037677819, 0.47695501730103812, 1.0) -(0.99629373317954639, 0.8552864282968089, 0.47178777393310267, 1.0) -(0.99617070357554793, 0.85282583621683972, 0.46662053056516728, 1.0) -(0.99607843137254903, 0.84978085351787769, 0.46145328719723183, 1.0) -(0.99607843137254903, 0.84498269896193767, 0.45628604382929644, 1.0) -(0.99607843137254903, 0.84018454440599777, 0.4511188004613611, 1.0) -(0.99607843137254903, 0.83538638985005764, 0.4459515570934256, 1.0) -(0.99607843137254903, 0.83058823529411763, 0.44078431372549021, 1.0) -(0.99607843137254903, 0.82579008073817761, 0.43561707035755481, 1.0) -(0.99607843137254903, 0.8209919261822376, 0.43044982698961942, 1.0) -(0.99607843137254903, 0.81619377162629758, 0.42528258362168397, 1.0) -(0.99607843137254903, 0.81139561707035757, 0.42011534025374858, 1.0) -(0.99607843137254903, 0.80659746251441744, 0.41494809688581313, 1.0) -(0.99607843137254903, 0.80179930795847754, 0.40978085351787785, 1.0) -(0.99607843137254903, 0.79700115340253741, 0.40461361014994235, 1.0) -(0.99607843137254903, 0.79220299884659739, 0.39944636678200696, 1.0) -(0.99607843137254903, 0.78740484429065738, 0.39427912341407151, 1.0) -(0.99607843137254903, 0.78260668973471736, 0.38911188004613612, 1.0) -(0.99607843137254903, 0.77780853517877735, 0.38394463667820067, 1.0) -(0.99607843137254903, 0.77301038062283733, 0.37877739331026528, 1.0) -(0.99607843137254903, 0.76821222606689732, 0.37361014994232988, 1.0) -(0.99607843137254903, 0.76341407151095741, 0.36844290657439455, 1.0) -(0.99607843137254903, 0.75861591695501729, 0.3632756632064591, 1.0) -(0.99607843137254903, 0.75381776239907727, 0.35810841983852365, 1.0) -(0.99607843137254903, 0.74901960784313726, 0.35294117647058826, 1.0) -(0.99607843137254903, 0.74422145328719724, 0.34777393310265281, 1.0) -(0.99607843137254903, 0.73942329873125723, 0.34260668973471742, 1.0) -(0.99607843137254903, 0.7346251441753171, 0.33743944636678203, 1.0) -(0.99607843137254903, 0.72982698961937709, 0.33227220299884663, 1.0) -(0.99607843137254903, 0.72502883506343718, 0.32710495963091124, 1.0) -(0.99607843137254903, 0.72023068050749706, 0.32193771626297579, 1.0) -(0.99607843137254903, 0.71543252595155704, 0.31677047289504034, 1.0) -(0.99607843137254903, 0.71063437139561703, 0.31160322952710495, 1.0) -(0.99607843137254903, 0.70583621683967701, 0.30643598615916956, 1.0) -(0.99607843137254903, 0.701038062283737, 0.30126874279123417, 1.0) -(0.99603229527104964, 0.69633217993079577, 0.29730103806228375, 1.0) -(0.99590926566705118, 0.69178008458285267, 0.29533256439830835, 1.0) -(0.99578623606305272, 0.68722798923490969, 0.29336409073433295, 1.0) -(0.99566320645905426, 0.68267589388696648, 0.29139561707035755, 1.0) -(0.9955401768550558, 0.67812379853902338, 0.28942714340638215, 1.0) -(0.99541714725105734, 0.67357170319108028, 0.28745866974240675, 1.0) -(0.99529411764705888, 0.66901960784313719, 0.28549019607843135, 1.0) -(0.99517108804306043, 0.66446751249519409, 0.28352172241445595, 1.0) -(0.99504805843906197, 0.65991541714725099, 0.2815532487504806, 1.0) -(0.99492502883506351, 0.6553633217993079, 0.2795847750865052, 1.0) -(0.99480199923106505, 0.65081122645136491, 0.2776163014225298, 1.0) -(0.99467896962706648, 0.6462591311034217, 0.2756478277585544, 1.0) -(0.99455594002306802, 0.64170703575547861, 0.273679354094579, 1.0) -(0.99443291041906956, 0.63715494040753551, 0.2717108804306036, 1.0) -(0.9943098808150711, 0.63260284505959241, 0.2697424067666282, 1.0) -(0.99418685121107264, 0.62805074971164931, 0.26777393310265285, 1.0) -(0.99406382160707418, 0.62349865436370622, 0.26580545943867745, 1.0) -(0.99394079200307572, 0.61894655901576323, 0.26383698577470205, 1.0) -(0.99381776239907726, 0.61439446366782013, 0.26186851211072665, 1.0) -(0.99369473279507881, 0.60984236831987704, 0.25990003844675125, 1.0) -(0.99357170319108035, 0.60529027297193383, 0.25793156478277585, 1.0) -(0.99344867358708189, 0.60073817762399084, 0.25596309111880045, 1.0) -(0.99332564398308343, 0.59618608227604764, 0.25399461745482504, 1.0) -(0.99320261437908497, 0.59163398692810465, 0.25202614379084964, 1.0) -(0.99307958477508651, 0.58708189158016144, 0.2500576701268743, 1.0) -(0.99295655517108805, 0.58252979623221846, 0.2480891964628989, 1.0) -(0.99283352556708959, 0.57797770088427536, 0.24612072279892352, 1.0) -(0.99271049596309113, 0.57342560553633226, 0.2441522491349481, 1.0) -(0.99258746635909267, 0.56887351018838905, 0.2421837754709727, 1.0) -(0.99246443675509421, 0.56432141484044607, 0.24021530180699729, 1.0) -(0.99234140715109576, 0.55976931949250286, 0.23824682814302192, 1.0) -(0.9922183775470973, 0.55521722414455987, 0.23627835447904652, 1.0) -(0.99209534794309884, 0.5490657439446367, 0.23418685121107266, 1.0) -(0.99197231833910038, 0.54131487889273355, 0.23197231833910034, 1.0) -(0.99184928873510192, 0.53356401384083052, 0.22975778546712802, 1.0) -(0.99172625913110346, 0.52581314878892738, 0.2275432525951557, 1.0) -(0.991603229527105, 0.51806228373702445, 0.22532871972318344, 1.0) -(0.99148019992310654, 0.5103114186851212, 0.22311418685121107, 1.0) -(0.99135717031910808, 0.50256055363321805, 0.22089965397923875, 1.0) -(0.99123414071510962, 0.49480968858131491, 0.21868512110726643, 1.0) -(0.99111111111111116, 0.48705882352941177, 0.21647058823529411, 1.0) -(0.99098808150711271, 0.47930795847750868, 0.21425605536332179, 1.0) -(0.99086505190311425, 0.47155709342560559, 0.21204152249134947, 1.0) -(0.99074202229911579, 0.46380622837370244, 0.20982698961937715, 1.0) -(0.99061899269511733, 0.45605536332179936, 0.20761245674740483, 1.0) -(0.99049596309111887, 0.44830449826989621, 0.20539792387543251, 1.0) -(0.99037293348712041, 0.44055363321799312, 0.2031833910034602, 1.0) -(0.99024990388312195, 0.43280276816608998, 0.2009688581314879, 1.0) -(0.99012687427912349, 0.42505190311418684, 0.19875432525951556, 1.0) -(0.99000384467512503, 0.41730103806228375, 0.19653979238754324, 1.0) -(0.98988081507112657, 0.40955017301038066, 0.19432525951557092, 1.0) -(0.98975778546712812, 0.40179930795847751, 0.1921107266435986, 1.0) -(0.98963475586312966, 0.39404844290657459, 0.18989619377162636, 1.0) -(0.98951172625913109, 0.38629757785467134, 0.18768166089965399, 1.0) -(0.98938869665513263, 0.37854671280276819, 0.18546712802768167, 1.0) -(0.98926566705113417, 0.37079584775086505, 0.18325259515570935, 1.0) -(0.98914263744713571, 0.36304498269896196, 0.18103806228373703, 1.0) -(0.98901960784313725, 0.35529411764705887, 0.17882352941176471, 1.0) -(0.98889657823913879, 0.34754325259515573, 0.1766089965397924, 1.0) -(0.98877354863514033, 0.33979238754325258, 0.17439446366782008, 1.0) -(0.98865051903114187, 0.33204152249134949, 0.17217993079584776, 1.0) -(0.98852748942714341, 0.32429065743944641, 0.16996539792387544, 1.0) -(0.98840445982314495, 0.31653979238754326, 0.16775086505190312, 1.0) -(0.9882814302191465, 0.30878892733564012, 0.1655363321799308, 1.0) -(0.98631295655517115, 0.30188389081122646, 0.16362937331795463, 1.0) -(0.98323721645520956, 0.29548635140330642, 0.16190695886197615, 1.0) -(0.98016147635524797, 0.28908881199538639, 0.16018454440599769, 1.0) -(0.9770857362552865, 0.2826912725874664, 0.15846212995001921, 1.0) -(0.97400999615532502, 0.27629373317954653, 0.15673971549404081, 1.0) -(0.97093425605536332, 0.26989619377162632, 0.15501730103806227, 1.0) -(0.96785851595540184, 0.26349865436370629, 0.15329488658208382, 1.0) -(0.96478277585544026, 0.25710111495578625, 0.15157247212610533, 1.0) -(0.96170703575547867, 0.25070357554786621, 0.14985005767012688, 1.0) -(0.95863129565551708, 0.2443060361399462, 0.1481276432141484, 1.0) -(0.9555555555555556, 0.23790849673202616, 0.14640522875816994, 1.0) -(0.95247981545559401, 0.23151095732410615, 0.14468281430219146, 1.0) -(0.94940407535563243, 0.22511341791618611, 0.142960399846213, 1.0) -(0.94632833525567095, 0.21871587850826607, 0.14123798539023452, 1.0) -(0.94325259515570936, 0.21231833910034603, 0.13951557093425604, 1.0) -(0.94017685505574777, 0.20592079969242599, 0.13779315647827758, 1.0) -(0.93710111495578619, 0.19952326028450595, 0.1360707420222991, 1.0) -(0.93402537485582471, 0.19312572087658592, 0.13434832756632065, 1.0) -(0.93094963475586312, 0.1867281814686659, 0.13262591311034216, 1.0) -(0.92787389465590153, 0.18033064206074587, 0.13090349865436371, 1.0) -(0.92479815455594006, 0.17393310265282602, 0.12918108419838528, 1.0) -(0.92172241445597847, 0.16753556324490582, 0.12745866974240677, 1.0) -(0.91864667435601688, 0.16113802383698578, 0.12573625528642829, 1.0) -(0.91557093425605529, 0.15474048442906574, 0.12401384083044982, 1.0) -(0.91249519415609381, 0.1483429450211457, 0.12229142637447135, 1.0) -(0.90941945405613223, 0.14194540561322569, 0.12056901191849288, 1.0) -(0.90634371395617064, 0.13554786620530565, 0.11884659746251441, 1.0) -(0.90326797385620905, 0.12915032679738561, 0.11712418300653595, 1.0) -(0.90019223375624757, 0.12275278738946557, 0.11540176855055748, 1.0) -(0.89711649365628598, 0.11635524798154556, 0.11367935409457901, 1.0) -(0.8940407535563244, 0.10995770857362552, 0.11195693963860054, 1.0) -(0.89096501345636292, 0.10356016916570548, 0.11023452518262206, 1.0) -(0.8866897347174163, 0.099561707035755481, 0.11072664359861592, 1.0) -(0.88201460976547474, 0.096362937331795462, 0.11195693963860054, 1.0) -(0.87733948481353319, 0.093164167627835442, 0.11318723567858516, 1.0) -(0.87266435986159163, 0.089965397923875437, 0.11441753171856978, 1.0) -(0.86798923490965019, 0.086766628219915501, 0.11564782775855437, 1.0) -(0.86331410995770852, 0.083567858515955398, 0.11687812379853903, 1.0) -(0.85863898500576696, 0.080369088811995393, 0.11810841983852365, 1.0) -(0.85396386005382541, 0.077170319108035373, 0.11933871587850826, 1.0) -(0.84928873510188385, 0.073971549404075354, 0.12056901191849288, 1.0) -(0.8446136101499423, 0.070772779700115335, 0.12179930795847752, 1.0) -(0.83993848519800074, 0.067574009996155315, 0.12302960399846213, 1.0) -(0.83526336024605918, 0.064375240292195296, 0.12425990003844675, 1.0) -(0.83058823529411763, 0.06117647058823529, 0.12549019607843137, 1.0) -(0.82591311034217607, 0.057977700884275278, 0.12672049211841599, 1.0) -(0.82123798539023452, 0.054778931180315259, 0.12795078815840061, 1.0) -(0.81656286043829296, 0.051580161476355246, 0.12918108419838523, 1.0) -(0.8118877354863514, 0.048381391772395227, 0.13041138023836985, 1.0) -(0.80721261053440985, 0.045182622068435215, 0.13164167627835449, 1.0) -(0.80253748558246829, 0.041983852364475202, 0.13287197231833911, 1.0) -(0.79786236063052673, 0.038785082660515183, 0.13410226835832373, 1.0) -(0.79318723567858529, 0.035586312956555261, 0.13533256439830832, 1.0) -(0.78851211072664362, 0.032387543252595158, 0.13656286043829297, 1.0) -(0.78383698577470207, 0.029188773548635139, 0.13779315647827758, 1.0) -(0.77916186082276051, 0.025990003844675119, 0.1390234525182622, 1.0) -(0.77448673587081895, 0.022791234140715114, 0.14025374855824682, 1.0) -(0.7698116109188774, 0.019592464436755094, 0.14148404459823144, 1.0) -(0.76513648596693584, 0.016393694732795075, 0.14271434063821609, 1.0) -(0.76046136101499429, 0.013194925028835056, 0.14394463667820068, 1.0) -(0.75578623606305273, 0.0099961553248750501, 0.14517493271818532, 1.0) -(0.75111111111111117, 0.0067973856209150307, 0.14640522875816994, 1.0) -(0.74643598615916962, 0.0035986159169550114, 0.14763552479815456, 1.0) -(0.74176086120722795, 0.00039984621299500589, 0.14886582083813918, 1.0) -(0.73460976547481738, 0.0, 0.14901960784313725, 1.0) -(0.72710495963091126, 0.0, 0.14901960784313725, 1.0) -(0.71960015378700504, 0.0, 0.14901960784313725, 1.0) -(0.71209534794309881, 0.0, 0.14901960784313725, 1.0) -(0.70459054209919292, 0.0, 0.14901960784313725, 1.0) -(0.69708573625528647, 0.0, 0.14901960784313725, 1.0) -(0.68958093041138024, 0.0, 0.14901960784313725, 1.0) -(0.68207612456747402, 0.0, 0.14901960784313725, 1.0) -(0.6745713187235679, 0.0, 0.14901960784313725, 1.0) -(0.66706651287966168, 0.0, 0.14901960784313725, 1.0) -(0.65956170703575545, 0.0, 0.14901960784313725, 1.0) -(0.65205690119184934, 0.0, 0.14901960784313725, 1.0) -(0.64455209534794311, 0.0, 0.14901960784313725, 1.0) -(0.63704728950403688, 0.0, 0.14901960784313725, 1.0) -(0.62954248366013077, 0.0, 0.14901960784313725, 1.0) -(0.62203767781622454, 0.0, 0.14901960784313725, 1.0) -(0.61453287197231832, 0.0, 0.14901960784313725, 1.0) -(0.6070280661284122, 0.0, 0.14901960784313725, 1.0) -(0.59952326028450598, 0.0, 0.14901960784313725, 1.0) -(0.59201845444059975, 0.0, 0.14901960784313725, 1.0) -(0.58451364859669375, 0.0, 0.14901960784313725, 1.0) -(0.57700884275278741, 0.0, 0.14901960784313725, 1.0) -(0.56950403690888118, 0.0, 0.14901960784313725, 1.0) -(0.56199923106497507, 0.0, 0.14901960784313725, 1.0) -(0.55449442522106884, 0.0, 0.14901960784313725, 1.0) -(0.54698961937716262, 0.0, 0.14901960784313725, 1.0) -(0.53948481353325639, 0.0, 0.14901960784313725, 1.0) -(0.53198000768935028, 0.0, 0.14901960784313725, 1.0) -(0.52447520184544405, 0.0, 0.14901960784313725, 1.0) -(0.51697039600153782, 0.0, 0.14901960784313725, 1.0) -(0.50946559015763171, 0.0, 0.14901960784313725, 1.0) -(0.50196078431372548, 0.0, 0.14901960784313725, 1.0) diff --git a/extern/tfn/colormaps/sequential2/Wistia.cpp b/extern/tfn/colormaps/sequential2/Wistia.cpp deleted file mode 100644 index 5d02b74..0000000 --- a/extern/tfn/colormaps/sequential2/Wistia.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential2_Wistia; -} -const std::vector colormap::data_sequential2_Wistia = /* NOLINT(cert-err58-cpp) */ -{ -{0.89411764705882357f, 1.0f, 0.47843137254901963f, 1.0f}, -{0.89577854671280277f, 0.99858515955401772f, 0.47252595155709343f, 1.0f}, -{0.89743944636678208f, 0.99717031910803533f, 0.46662053056516728f, 1.0f}, -{0.89910034602076128f, 0.99575547866205305f, 0.46071510957324108f, 1.0f}, -{0.90076124567474047f, 0.99434063821607077f, 0.45480968858131487f, 1.0f}, -{0.90242214532871978f, 0.99292579777008838f, 0.44890426758938873f, 1.0f}, -{0.90408304498269898f, 0.9915109573241061f, 0.44299884659746253f, 1.0f}, -{0.90574394463667829f, 0.99009611687812382f, 0.43709342560553638f, 1.0f}, -{0.90740484429065749f, 0.98868127643214143f, 0.43118800461361018f, 1.0f}, -{0.90906574394463668f, 0.98726643598615915f, 0.42528258362168397f, 1.0f}, -{0.91072664359861599f, 0.98585159554017687f, 0.41937716262975783f, 1.0f}, -{0.91238754325259519f, 0.98443675509419459f, 0.41347174163783162f, 1.0f}, -{0.91404844290657439f, 0.9830219146482122f, 0.40756632064590548f, 1.0f}, -{0.9157093425605537f, 0.98160707420222992f, 0.40166089965397928f, 1.0f}, -{0.91737024221453289f, 0.98019223375624764f, 0.39575547866205307f, 1.0f}, -{0.91903114186851209f, 0.97877739331026525f, 0.38985005767012693f, 1.0f}, -{0.9206920415224914f, 0.97736255286428297f, 0.38394463667820072f, 1.0f}, -{0.9223529411764706f, 0.97594771241830069f, 0.37803921568627452f, 1.0f}, -{0.92401384083044991f, 0.9745328719723183f, 0.37213379469434837f, 1.0f}, -{0.9256747404844291f, 0.97311803152633602f, 0.36622837370242217f, 1.0f}, -{0.9273356401384083f, 0.97170319108035375f, 0.36032295271049597f, 1.0f}, -{0.92899653979238761f, 0.97028835063437135f, 0.35441753171856982f, 1.0f}, -{0.93065743944636681f, 0.96887351018838908f, 0.34851211072664362f, 1.0f}, -{0.93231833910034601f, 0.9674586697424068f, 0.34260668973471742f, 1.0f}, -{0.93397923875432531f, 0.96604382929642441f, 0.33670126874279127f, 1.0f}, -{0.93564013840830451f, 0.96462898885044213f, 0.33079584775086507f, 1.0f}, -{0.93730103806228371f, 0.96321414840445985f, 0.32489042675893887f, 1.0f}, -{0.93896193771626302f, 0.96179930795847746f, 0.31898500576701272f, 1.0f}, -{0.94062283737024222f, 0.96038446751249518f, 0.31307958477508657f, 1.0f}, -{0.94228373702422152f, 0.9589696270665129f, 0.30717416378316031f, 1.0f}, -{0.94394463667820072f, 0.95755478662053051f, 0.30126874279123417f, 1.0f}, -{0.94560553633217992f, 0.95613994617454823f, 0.29536332179930802f, 1.0f}, -{0.94726643598615923f, 0.95472510572856595f, 0.28945790080738176f, 1.0f}, -{0.94892733564013843f, 0.95331026528258367f, 0.28355247981545562f, 1.0f}, -{0.95058823529411762f, 0.95189542483660128f, 0.27764705882352947f, 1.0f}, -{0.95224913494809693f, 0.950480584390619f, 0.27174163783160321f, 1.0f}, -{0.95391003460207613f, 0.94906574394463672f, 0.26583621683967706f, 1.0f}, -{0.95557093425605533f, 0.94765090349865433f, 0.25993079584775092f, 1.0f}, -{0.95723183391003464f, 0.94623606305267205f, 0.25402537485582471f, 1.0f}, -{0.95889273356401383f, 0.94482122260668977f, 0.24811995386389851f, 1.0f}, -{0.96055363321799314f, 0.94340638216070738f, 0.24221453287197234f, 1.0f}, -{0.96221453287197234f, 0.9419915417147251f, 0.23630911188004619f, 1.0f}, -{0.96387543252595154f, 0.94057670126874282f, 0.23040369088811999f, 1.0f}, -{0.96553633217993085f, 0.93916186082276043f, 0.22449826989619376f, 1.0f}, -{0.96719723183391004f, 0.93774702037677815f, 0.21859284890426761f, 1.0f}, -{0.96885813148788924f, 0.93633217993079587f, 0.21268742791234146f, 1.0f}, -{0.97051903114186855f, 0.93491733948481348f, 0.20678200692041526f, 1.0f}, -{0.97217993079584775f, 0.9335024990388312f, 0.20087658592848906f, 1.0f}, -{0.97384083044982694f, 0.93208765859284892f, 0.19497116493656291f, 1.0f}, -{0.97550173010380625f, 0.93067281814686664f, 0.18906574394463671f, 1.0f}, -{0.97716262975778545f, 0.92925797770088425f, 0.18316032295271051f, 1.0f}, -{0.97882352941176476f, 0.92784313725490197f, 0.17725490196078431f, 1.0f}, -{0.98048442906574396f, 0.92642829680891969f, 0.17134948096885816f, 1.0f}, -{0.98214532871972315f, 0.9250134563629373f, 0.16544405997693201f, 1.0f}, -{0.98380622837370246f, 0.92359861591695502f, 0.15953863898500581f, 1.0f}, -{0.98546712802768166f, 0.92218377547097274f, 0.15363321799307961f, 1.0f}, -{0.98712802768166086f, 0.92076893502499035f, 0.14772779700115346f, 1.0f}, -{0.98878892733564017f, 0.91935409457900807f, 0.14182237600922726f, 1.0f}, -{0.99044982698961936f, 0.91793925413302579f, 0.13591695501730106f, 1.0f}, -{0.99211072664359867f, 0.9165244136870434f, 0.13001153402537485f, 1.0f}, -{0.99377162629757787f, 0.91510957324106112f, 0.12410611303344871f, 1.0f}, -{0.99543252595155707f, 0.91369473279507885f, 0.11820069204152256f, 1.0f}, -{0.99709342560553638f, 0.91227989234909646f, 0.11229527104959636f, 1.0f}, -{0.99875432525951557f, 0.91086505190311418f, 0.10638985005767015f, 1.0f}, -{1.0f, 0.90914263744713575f, 0.10156093810073048f, 1.0f}, -{1.0f, 0.90649750096116877f, 0.099961553248750473f, 1.0f}, -{1.0f, 0.9038523644752019f, 0.098362168396770491f, 1.0f}, -{1.0f, 0.90120722798923492f, 0.096762783544790468f, 1.0f}, -{1.0f, 0.89856209150326793f, 0.095163398692810458f, 1.0f}, -{1.0f, 0.89591695501730106f, 0.093564013840830448f, 1.0f}, -{1.0f, 0.89327181853133408f, 0.091964628988850439f, 1.0f}, -{1.0f, 0.89062668204536721f, 0.090365244136870429f, 1.0f}, -{1.0f, 0.88798154555940023f, 0.088765859284890419f, 1.0f}, -{1.0f, 0.88533640907343325f, 0.087166474432910424f, 1.0f}, -{1.0f, 0.88269127258746638f, 0.085567089580930428f, 1.0f}, -{1.0f, 0.8800461361014994f, 0.083967704728950404f, 1.0f}, -{1.0f, 0.87740099961553253f, 0.082368319876970394f, 1.0f}, -{1.0f, 0.87475586312956555f, 0.080768935024990385f, 1.0f}, -{1.0f, 0.87211072664359857f, 0.079169550173010375f, 1.0f}, -{1.0f, 0.8694655901576317f, 0.077570165321030365f, 1.0f}, -{1.0f, 0.86682045367166471f, 0.07597078046905037f, 1.0f}, -{1.0f, 0.86417531718569784f, 0.07437139561707036f, 1.0f}, -{1.0f, 0.86153018069973086f, 0.072772010765090378f, 1.0f}, -{1.0f, 0.85888504421376388f, 0.071172625913110341f, 1.0f}, -{1.0f, 0.85623990772779701f, 0.069573241061130331f, 1.0f}, -{1.0f, 0.85359477124183003f, 0.067973856209150335f, 1.0f}, -{1.0f, 0.85094963475586316f, 0.066374471357170312f, 1.0f}, -{1.0f, 0.84830449826989618f, 0.064775086505190316f, 1.0f}, -{1.0f, 0.84565936178392931f, 0.063175701653210306f, 1.0f}, -{1.0f, 0.84301422529796233f, 0.061576316801230296f, 1.0f}, -{1.0f, 0.84036908881199546f, 0.059976931949250314f, 1.0f}, -{1.0f, 0.83772395232602848f, 0.058377547097270284f, 1.0f}, -{1.0f, 0.83507881584006149f, 0.056778162245290274f, 1.0f}, -{1.0f, 0.83243367935409462f, 0.055178777393310265f, 1.0f}, -{1.0f, 0.82978854286812764f, 0.053579392541330262f, 1.0f}, -{1.0f, 0.82714340638216077f, 0.051980007689350252f, 1.0f}, -{1.0f, 0.82449826989619379f, 0.050380622837370242f, 1.0f}, -{1.0f, 0.82185313341022681f, 0.048781237985390233f, 1.0f}, -{1.0f, 0.81920799692425994f, 0.047181853133410251f, 1.0f}, -{1.0f, 0.81656286043829296f, 0.045582468281430213f, 1.0f}, -{1.0f, 0.81391772395232609f, 0.043983083429450211f, 1.0f}, -{1.0f, 0.81127258746635911f, 0.042383698577470201f, 1.0f}, -{1.0f, 0.80862745098039213f, 0.040784313725490198f, 1.0f}, -{1.0f, 0.80598231449442526f, 0.039184928873510189f, 1.0f}, -{1.0f, 0.80333717800845827f, 0.037585544021530179f, 1.0f}, -{1.0f, 0.8006920415224914f, 0.035986159169550169f, 1.0f}, -{1.0f, 0.79804690503652442f, 0.034386774317570187f, 1.0f}, -{1.0f, 0.79540176855055744f, 0.03278738946559015f, 1.0f}, -{1.0f, 0.79275663206459057f, 0.031188004613610154f, 1.0f}, -{1.0f, 0.79011149557862359f, 0.029588619761630144f, 1.0f}, -{1.0f, 0.78746635909265672f, 0.027989234909650135f, 1.0f}, -{1.0f, 0.78482122260668974f, 0.026389850057670125f, 1.0f}, -{1.0f, 0.78217608612072276f, 0.024790465205690115f, 1.0f}, -{1.0f, 0.77953094963475589f, 0.023191080353710106f, 1.0f}, -{1.0f, 0.77688581314878902f, 0.021591695501730124f, 1.0f}, -{1.0f, 0.77424067666282204f, 0.019992310649750086f, 1.0f}, -{1.0f, 0.77159554017685505f, 0.018392925797770091f, 1.0f}, -{1.0f, 0.76895040369088807f, 0.016793540945790081f, 1.0f}, -{1.0f, 0.7663052672049212f, 0.015194156093810071f, 1.0f}, -{1.0f, 0.76366013071895433f, 0.013594771241830061f, 1.0f}, -{1.0f, 0.76101499423298735f, 0.011995386389850066f, 1.0f}, -{1.0f, 0.75836985774702037f, 0.010396001537870042f, 1.0f}, -{1.0f, 0.7557247212610535f, 0.0087966166858900741f, 1.0f}, -{1.0f, 0.75307958477508652f, 0.0071972318339100366f, 1.0f}, -{1.0f, 0.75043444828911965f, 0.0055978469819300269f, 1.0f}, -{1.0f, 0.74778931180315267f, 0.0039984621299500173f, 1.0f}, -{1.0f, 0.74514417531718569f, 0.0023990772779700076f, 1.0f}, -{1.0f, 0.74249903883121882f, 0.0007996924259899979f, 1.0f}, -{1.0f, 0.74028450595924644f, 0.0f, 1.0f}, -{1.0f, 0.73850057670126878f, 0.0f, 1.0f}, -{1.0f, 0.73671664744329102f, 0.0f, 1.0f}, -{1.0f, 0.73493271818531336f, 0.0f, 1.0f}, -{1.0f, 0.7331487889273357f, 0.0f, 1.0f}, -{1.0f, 0.73136485966935794f, 0.0f, 1.0f}, -{1.0f, 0.72958093041138028f, 0.0f, 1.0f}, -{1.0f, 0.72779700115340251f, 0.0f, 1.0f}, -{1.0f, 0.72601307189542486f, 0.0f, 1.0f}, -{1.0f, 0.7242291426374472f, 0.0f, 1.0f}, -{1.0f, 0.72244521337946943f, 0.0f, 1.0f}, -{1.0f, 0.72066128412149177f, 0.0f, 1.0f}, -{1.0f, 0.71887735486351401f, 0.0f, 1.0f}, -{1.0f, 0.71709342560553635f, 0.0f, 1.0f}, -{1.0f, 0.71530949634755869f, 0.0f, 1.0f}, -{1.0f, 0.71352556708958093f, 0.0f, 1.0f}, -{1.0f, 0.71174163783160327f, 0.0f, 1.0f}, -{1.0f, 0.7099577085736255f, 0.0f, 1.0f}, -{1.0f, 0.70817377931564784f, 0.0f, 1.0f}, -{1.0f, 0.70638985005767019f, 0.0f, 1.0f}, -{1.0f, 0.70460592079969253f, 0.0f, 1.0f}, -{1.0f, 0.70282199154171476f, 0.0f, 1.0f}, -{1.0f, 0.701038062283737f, 0.0f, 1.0f}, -{1.0f, 0.69925413302575934f, 0.0f, 1.0f}, -{1.0f, 0.69747020376778168f, 0.0f, 1.0f}, -{1.0f, 0.69568627450980391f, 0.0f, 1.0f}, -{1.0f, 0.69390234525182626f, 0.0f, 1.0f}, -{1.0f, 0.69211841599384849f, 0.0f, 1.0f}, -{1.0f, 0.69033448673587083f, 0.0f, 1.0f}, -{1.0f, 0.68855055747789318f, 0.0f, 1.0f}, -{1.0f, 0.68676662821991541f, 0.0f, 1.0f}, -{1.0f, 0.68498269896193775f, 0.0f, 1.0f}, -{1.0f, 0.68319876970395998f, 0.0f, 1.0f}, -{1.0f, 0.68141484044598233f, 0.0f, 1.0f}, -{1.0f, 0.67963091118800467f, 0.0f, 1.0f}, -{1.0f, 0.6778469819300269f, 0.0f, 1.0f}, -{1.0f, 0.67606305267204925f, 0.0f, 1.0f}, -{1.0f, 0.67427912341407148f, 0.0f, 1.0f}, -{1.0f, 0.67249519415609382f, 0.0f, 1.0f}, -{1.0f, 0.67071126489811617f, 0.0f, 1.0f}, -{1.0f, 0.6689273356401384f, 0.0f, 1.0f}, -{1.0f, 0.66714340638216074f, 0.0f, 1.0f}, -{1.0f, 0.66535947712418297f, 0.0f, 1.0f}, -{1.0f, 0.66357554786620532f, 0.0f, 1.0f}, -{1.0f, 0.66179161860822766f, 0.0f, 1.0f}, -{1.0f, 0.66000768935024989f, 0.0f, 1.0f}, -{1.0f, 0.65822376009227224f, 0.0f, 1.0f}, -{1.0f, 0.65643983083429447f, 0.0f, 1.0f}, -{1.0f, 0.65465590157631681f, 0.0f, 1.0f}, -{1.0f, 0.65287197231833916f, 0.0f, 1.0f}, -{1.0f, 0.65108804306036139f, 0.0f, 1.0f}, -{1.0f, 0.64930411380238373f, 0.0f, 1.0f}, -{1.0f, 0.64752018454440607f, 0.0f, 1.0f}, -{1.0f, 0.64573625528642831f, 0.0f, 1.0f}, -{1.0f, 0.64395232602845054f, 0.0f, 1.0f}, -{1.0f, 0.64216839677047288f, 0.0f, 1.0f}, -{1.0f, 0.64038446751249523f, 0.0f, 1.0f}, -{1.0f, 0.63860053825451746f, 0.0f, 1.0f}, -{1.0f, 0.6368166089965398f, 0.0f, 1.0f}, -{1.0f, 0.63503267973856214f, 0.0f, 1.0f}, -{1.0f, 0.63324875048058438f, 0.0f, 1.0f}, -{1.0f, 0.63146482122260672f, 0.0f, 1.0f}, -{1.0f, 0.62968089196462895f, 0.0f, 1.0f}, -{1.0f, 0.6278969627066513f, 0.0f, 1.0f}, -{0.99986159169550171f, 0.62592848904267584f, 0.0f, 1.0f}, -{0.99967704728950402f, 0.62389850057670126f, 0.0f, 1.0f}, -{0.99949250288350633f, 0.62186851211072669f, 0.0f, 1.0f}, -{0.99930795847750864f, 0.619838523644752f, 0.0f, 1.0f}, -{0.99912341407151095f, 0.61780853517877743f, 0.0f, 1.0f}, -{0.99893886966551326f, 0.61577854671280274f, 0.0f, 1.0f}, -{0.99875432525951557f, 0.61374855824682817f, 0.0f, 1.0f}, -{0.99856978085351789f, 0.61171856978085348f, 0.0f, 1.0f}, -{0.9983852364475202f, 0.60968858131487891f, 0.0f, 1.0f}, -{0.99820069204152251f, 0.60765859284890422f, 0.0f, 1.0f}, -{0.99801614763552482f, 0.60562860438292965f, 0.0f, 1.0f}, -{0.99783160322952713f, 0.60359861591695496f, 0.0f, 1.0f}, -{0.99764705882352944f, 0.60156862745098039f, 0.0f, 1.0f}, -{0.99746251441753175f, 0.59953863898500581f, 0.0f, 1.0f}, -{0.99727797001153407f, 0.59750865051903113f, 0.0f, 1.0f}, -{0.99709342560553638f, 0.59547866205305655f, 0.0f, 1.0f}, -{0.99690888119953869f, 0.59344867358708187f, 0.0f, 1.0f}, -{0.996724336793541f, 0.59141868512110729f, 0.0f, 1.0f}, -{0.99653979238754331f, 0.5893886966551326f, 0.0f, 1.0f}, -{0.99635524798154562f, 0.58735870818915803f, 0.0f, 1.0f}, -{0.99617070357554793f, 0.58532871972318345f, 0.0f, 1.0f}, -{0.99598615916955013f, 0.58329873125720877f, 0.0f, 1.0f}, -{0.99580161476355245f, 0.58126874279123419f, 0.0f, 1.0f}, -{0.99561707035755476f, 0.57923875432525951f, 0.0f, 1.0f}, -{0.99543252595155707f, 0.57720876585928493f, 0.0f, 1.0f}, -{0.99524798154555938f, 0.57517877739331025f, 0.0f, 1.0f}, -{0.99506343713956169f, 0.57314878892733567f, 0.0f, 1.0f}, -{0.994878892733564f, 0.57111880046136099f, 0.0f, 1.0f}, -{0.99469434832756631f, 0.56908881199538641f, 0.0f, 1.0f}, -{0.99450980392156862f, 0.56705882352941173f, 0.0f, 1.0f}, -{0.99432525951557094f, 0.56502883506343715f, 0.0f, 1.0f}, -{0.99414071510957325f, 0.56299884659746247f, 0.0f, 1.0f}, -{0.99395617070357556f, 0.56096885813148789f, 0.0f, 1.0f}, -{0.99377162629757787f, 0.55893886966551332f, 0.0f, 1.0f}, -{0.99358708189158018f, 0.55690888119953863f, 0.0f, 1.0f}, -{0.99340253748558249f, 0.55487889273356406f, 0.0f, 1.0f}, -{0.9932179930795848f, 0.55284890426758948f, 0.0f, 1.0f}, -{0.99303344867358712f, 0.55081891580161479f, 0.0f, 1.0f}, -{0.99284890426758943f, 0.54878892733564011f, 0.0f, 1.0f}, -{0.99266435986159174f, 0.54675893886966553f, 0.0f, 1.0f}, -{0.99247981545559405f, 0.54472895040369085f, 0.0f, 1.0f}, -{0.99229527104959636f, 0.54269896193771627f, 0.0f, 1.0f}, -{0.99211072664359867f, 0.54066897347174159f, 0.0f, 1.0f}, -{0.99192618223760098f, 0.53863898500576701f, 0.0f, 1.0f}, -{0.9917416378316033f, 0.53660899653979244f, 0.0f, 1.0f}, -{0.99155709342560561f, 0.53457900807381775f, 0.0f, 1.0f}, -{0.99137254901960792f, 0.53254901960784318f, 0.0f, 1.0f}, -{0.99118800461361023f, 0.53051903114186849f, 0.0f, 1.0f}, -{0.99100346020761254f, 0.52848904267589392f, 0.0f, 1.0f}, -{0.99081891580161474f, 0.52645905420991923f, 0.0f, 1.0f}, -{0.99063437139561705f, 0.52442906574394466f, 0.0f, 1.0f}, -{0.99044982698961936f, 0.52239907727796997f, 0.0f, 1.0f}, -{0.99026528258362168f, 0.5203690888119954f, 0.0f, 1.0f}, -{0.99008073817762399f, 0.51833910034602071f, 0.0f, 1.0f}, -{0.9898961937716263f, 0.51630911188004613f, 0.0f, 1.0f}, -{0.98971164936562861f, 0.51427912341407156f, 0.0f, 1.0f}, -{0.98952710495963092f, 0.51224913494809687f, 0.0f, 1.0f}, -{0.98934256055363323f, 0.5102191464821223f, 0.0f, 1.0f}, -{0.98915801614763554f, 0.50818915801614761f, 0.0f, 1.0f}, -{0.98897347174163786f, 0.50615916955017304f, 0.0f, 1.0f}, -{0.98878892733564017f, 0.50412918108419835f, 0.0f, 1.0f}, -{0.98860438292964248f, 0.50209919261822378f, 0.0f, 1.0f}, -{0.98841983852364479f, 0.5000692041522492f, 0.0f, 1.0f}, -{0.9882352941176471f, 0.49803921568627452f, 0.0f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential2/Wistia.txt b/extern/tfn/colormaps/sequential2/Wistia.txt deleted file mode 100644 index f7f6daf..0000000 --- a/extern/tfn/colormaps/sequential2/Wistia.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.89411764705882357, 1.0, 0.47843137254901963, 1.0) -(0.89577854671280277, 0.99858515955401772, 0.47252595155709343, 1.0) -(0.89743944636678208, 0.99717031910803533, 0.46662053056516728, 1.0) -(0.89910034602076128, 0.99575547866205305, 0.46071510957324108, 1.0) -(0.90076124567474047, 0.99434063821607077, 0.45480968858131487, 1.0) -(0.90242214532871978, 0.99292579777008838, 0.44890426758938873, 1.0) -(0.90408304498269898, 0.9915109573241061, 0.44299884659746253, 1.0) -(0.90574394463667829, 0.99009611687812382, 0.43709342560553638, 1.0) -(0.90740484429065749, 0.98868127643214143, 0.43118800461361018, 1.0) -(0.90906574394463668, 0.98726643598615915, 0.42528258362168397, 1.0) -(0.91072664359861599, 0.98585159554017687, 0.41937716262975783, 1.0) -(0.91238754325259519, 0.98443675509419459, 0.41347174163783162, 1.0) -(0.91404844290657439, 0.9830219146482122, 0.40756632064590548, 1.0) -(0.9157093425605537, 0.98160707420222992, 0.40166089965397928, 1.0) -(0.91737024221453289, 0.98019223375624764, 0.39575547866205307, 1.0) -(0.91903114186851209, 0.97877739331026525, 0.38985005767012693, 1.0) -(0.9206920415224914, 0.97736255286428297, 0.38394463667820072, 1.0) -(0.9223529411764706, 0.97594771241830069, 0.37803921568627452, 1.0) -(0.92401384083044991, 0.9745328719723183, 0.37213379469434837, 1.0) -(0.9256747404844291, 0.97311803152633602, 0.36622837370242217, 1.0) -(0.9273356401384083, 0.97170319108035375, 0.36032295271049597, 1.0) -(0.92899653979238761, 0.97028835063437135, 0.35441753171856982, 1.0) -(0.93065743944636681, 0.96887351018838908, 0.34851211072664362, 1.0) -(0.93231833910034601, 0.9674586697424068, 0.34260668973471742, 1.0) -(0.93397923875432531, 0.96604382929642441, 0.33670126874279127, 1.0) -(0.93564013840830451, 0.96462898885044213, 0.33079584775086507, 1.0) -(0.93730103806228371, 0.96321414840445985, 0.32489042675893887, 1.0) -(0.93896193771626302, 0.96179930795847746, 0.31898500576701272, 1.0) -(0.94062283737024222, 0.96038446751249518, 0.31307958477508657, 1.0) -(0.94228373702422152, 0.9589696270665129, 0.30717416378316031, 1.0) -(0.94394463667820072, 0.95755478662053051, 0.30126874279123417, 1.0) -(0.94560553633217992, 0.95613994617454823, 0.29536332179930802, 1.0) -(0.94726643598615923, 0.95472510572856595, 0.28945790080738176, 1.0) -(0.94892733564013843, 0.95331026528258367, 0.28355247981545562, 1.0) -(0.95058823529411762, 0.95189542483660128, 0.27764705882352947, 1.0) -(0.95224913494809693, 0.950480584390619, 0.27174163783160321, 1.0) -(0.95391003460207613, 0.94906574394463672, 0.26583621683967706, 1.0) -(0.95557093425605533, 0.94765090349865433, 0.25993079584775092, 1.0) -(0.95723183391003464, 0.94623606305267205, 0.25402537485582471, 1.0) -(0.95889273356401383, 0.94482122260668977, 0.24811995386389851, 1.0) -(0.96055363321799314, 0.94340638216070738, 0.24221453287197234, 1.0) -(0.96221453287197234, 0.9419915417147251, 0.23630911188004619, 1.0) -(0.96387543252595154, 0.94057670126874282, 0.23040369088811999, 1.0) -(0.96553633217993085, 0.93916186082276043, 0.22449826989619376, 1.0) -(0.96719723183391004, 0.93774702037677815, 0.21859284890426761, 1.0) -(0.96885813148788924, 0.93633217993079587, 0.21268742791234146, 1.0) -(0.97051903114186855, 0.93491733948481348, 0.20678200692041526, 1.0) -(0.97217993079584775, 0.9335024990388312, 0.20087658592848906, 1.0) -(0.97384083044982694, 0.93208765859284892, 0.19497116493656291, 1.0) -(0.97550173010380625, 0.93067281814686664, 0.18906574394463671, 1.0) -(0.97716262975778545, 0.92925797770088425, 0.18316032295271051, 1.0) -(0.97882352941176476, 0.92784313725490197, 0.17725490196078431, 1.0) -(0.98048442906574396, 0.92642829680891969, 0.17134948096885816, 1.0) -(0.98214532871972315, 0.9250134563629373, 0.16544405997693201, 1.0) -(0.98380622837370246, 0.92359861591695502, 0.15953863898500581, 1.0) -(0.98546712802768166, 0.92218377547097274, 0.15363321799307961, 1.0) -(0.98712802768166086, 0.92076893502499035, 0.14772779700115346, 1.0) -(0.98878892733564017, 0.91935409457900807, 0.14182237600922726, 1.0) -(0.99044982698961936, 0.91793925413302579, 0.13591695501730106, 1.0) -(0.99211072664359867, 0.9165244136870434, 0.13001153402537485, 1.0) -(0.99377162629757787, 0.91510957324106112, 0.12410611303344871, 1.0) -(0.99543252595155707, 0.91369473279507885, 0.11820069204152256, 1.0) -(0.99709342560553638, 0.91227989234909646, 0.11229527104959636, 1.0) -(0.99875432525951557, 0.91086505190311418, 0.10638985005767015, 1.0) -(1.0, 0.90914263744713575, 0.10156093810073048, 1.0) -(1.0, 0.90649750096116877, 0.099961553248750473, 1.0) -(1.0, 0.9038523644752019, 0.098362168396770491, 1.0) -(1.0, 0.90120722798923492, 0.096762783544790468, 1.0) -(1.0, 0.89856209150326793, 0.095163398692810458, 1.0) -(1.0, 0.89591695501730106, 0.093564013840830448, 1.0) -(1.0, 0.89327181853133408, 0.091964628988850439, 1.0) -(1.0, 0.89062668204536721, 0.090365244136870429, 1.0) -(1.0, 0.88798154555940023, 0.088765859284890419, 1.0) -(1.0, 0.88533640907343325, 0.087166474432910424, 1.0) -(1.0, 0.88269127258746638, 0.085567089580930428, 1.0) -(1.0, 0.8800461361014994, 0.083967704728950404, 1.0) -(1.0, 0.87740099961553253, 0.082368319876970394, 1.0) -(1.0, 0.87475586312956555, 0.080768935024990385, 1.0) -(1.0, 0.87211072664359857, 0.079169550173010375, 1.0) -(1.0, 0.8694655901576317, 0.077570165321030365, 1.0) -(1.0, 0.86682045367166471, 0.07597078046905037, 1.0) -(1.0, 0.86417531718569784, 0.07437139561707036, 1.0) -(1.0, 0.86153018069973086, 0.072772010765090378, 1.0) -(1.0, 0.85888504421376388, 0.071172625913110341, 1.0) -(1.0, 0.85623990772779701, 0.069573241061130331, 1.0) -(1.0, 0.85359477124183003, 0.067973856209150335, 1.0) -(1.0, 0.85094963475586316, 0.066374471357170312, 1.0) -(1.0, 0.84830449826989618, 0.064775086505190316, 1.0) -(1.0, 0.84565936178392931, 0.063175701653210306, 1.0) -(1.0, 0.84301422529796233, 0.061576316801230296, 1.0) -(1.0, 0.84036908881199546, 0.059976931949250314, 1.0) -(1.0, 0.83772395232602848, 0.058377547097270284, 1.0) -(1.0, 0.83507881584006149, 0.056778162245290274, 1.0) -(1.0, 0.83243367935409462, 0.055178777393310265, 1.0) -(1.0, 0.82978854286812764, 0.053579392541330262, 1.0) -(1.0, 0.82714340638216077, 0.051980007689350252, 1.0) -(1.0, 0.82449826989619379, 0.050380622837370242, 1.0) -(1.0, 0.82185313341022681, 0.048781237985390233, 1.0) -(1.0, 0.81920799692425994, 0.047181853133410251, 1.0) -(1.0, 0.81656286043829296, 0.045582468281430213, 1.0) -(1.0, 0.81391772395232609, 0.043983083429450211, 1.0) -(1.0, 0.81127258746635911, 0.042383698577470201, 1.0) -(1.0, 0.80862745098039213, 0.040784313725490198, 1.0) -(1.0, 0.80598231449442526, 0.039184928873510189, 1.0) -(1.0, 0.80333717800845827, 0.037585544021530179, 1.0) -(1.0, 0.8006920415224914, 0.035986159169550169, 1.0) -(1.0, 0.79804690503652442, 0.034386774317570187, 1.0) -(1.0, 0.79540176855055744, 0.03278738946559015, 1.0) -(1.0, 0.79275663206459057, 0.031188004613610154, 1.0) -(1.0, 0.79011149557862359, 0.029588619761630144, 1.0) -(1.0, 0.78746635909265672, 0.027989234909650135, 1.0) -(1.0, 0.78482122260668974, 0.026389850057670125, 1.0) -(1.0, 0.78217608612072276, 0.024790465205690115, 1.0) -(1.0, 0.77953094963475589, 0.023191080353710106, 1.0) -(1.0, 0.77688581314878902, 0.021591695501730124, 1.0) -(1.0, 0.77424067666282204, 0.019992310649750086, 1.0) -(1.0, 0.77159554017685505, 0.018392925797770091, 1.0) -(1.0, 0.76895040369088807, 0.016793540945790081, 1.0) -(1.0, 0.7663052672049212, 0.015194156093810071, 1.0) -(1.0, 0.76366013071895433, 0.013594771241830061, 1.0) -(1.0, 0.76101499423298735, 0.011995386389850066, 1.0) -(1.0, 0.75836985774702037, 0.010396001537870042, 1.0) -(1.0, 0.7557247212610535, 0.0087966166858900741, 1.0) -(1.0, 0.75307958477508652, 0.0071972318339100366, 1.0) -(1.0, 0.75043444828911965, 0.0055978469819300269, 1.0) -(1.0, 0.74778931180315267, 0.0039984621299500173, 1.0) -(1.0, 0.74514417531718569, 0.0023990772779700076, 1.0) -(1.0, 0.74249903883121882, 0.0007996924259899979, 1.0) -(1.0, 0.74028450595924644, 0.0, 1.0) -(1.0, 0.73850057670126878, 0.0, 1.0) -(1.0, 0.73671664744329102, 0.0, 1.0) -(1.0, 0.73493271818531336, 0.0, 1.0) -(1.0, 0.7331487889273357, 0.0, 1.0) -(1.0, 0.73136485966935794, 0.0, 1.0) -(1.0, 0.72958093041138028, 0.0, 1.0) -(1.0, 0.72779700115340251, 0.0, 1.0) -(1.0, 0.72601307189542486, 0.0, 1.0) -(1.0, 0.7242291426374472, 0.0, 1.0) -(1.0, 0.72244521337946943, 0.0, 1.0) -(1.0, 0.72066128412149177, 0.0, 1.0) -(1.0, 0.71887735486351401, 0.0, 1.0) -(1.0, 0.71709342560553635, 0.0, 1.0) -(1.0, 0.71530949634755869, 0.0, 1.0) -(1.0, 0.71352556708958093, 0.0, 1.0) -(1.0, 0.71174163783160327, 0.0, 1.0) -(1.0, 0.7099577085736255, 0.0, 1.0) -(1.0, 0.70817377931564784, 0.0, 1.0) -(1.0, 0.70638985005767019, 0.0, 1.0) -(1.0, 0.70460592079969253, 0.0, 1.0) -(1.0, 0.70282199154171476, 0.0, 1.0) -(1.0, 0.701038062283737, 0.0, 1.0) -(1.0, 0.69925413302575934, 0.0, 1.0) -(1.0, 0.69747020376778168, 0.0, 1.0) -(1.0, 0.69568627450980391, 0.0, 1.0) -(1.0, 0.69390234525182626, 0.0, 1.0) -(1.0, 0.69211841599384849, 0.0, 1.0) -(1.0, 0.69033448673587083, 0.0, 1.0) -(1.0, 0.68855055747789318, 0.0, 1.0) -(1.0, 0.68676662821991541, 0.0, 1.0) -(1.0, 0.68498269896193775, 0.0, 1.0) -(1.0, 0.68319876970395998, 0.0, 1.0) -(1.0, 0.68141484044598233, 0.0, 1.0) -(1.0, 0.67963091118800467, 0.0, 1.0) -(1.0, 0.6778469819300269, 0.0, 1.0) -(1.0, 0.67606305267204925, 0.0, 1.0) -(1.0, 0.67427912341407148, 0.0, 1.0) -(1.0, 0.67249519415609382, 0.0, 1.0) -(1.0, 0.67071126489811617, 0.0, 1.0) -(1.0, 0.6689273356401384, 0.0, 1.0) -(1.0, 0.66714340638216074, 0.0, 1.0) -(1.0, 0.66535947712418297, 0.0, 1.0) -(1.0, 0.66357554786620532, 0.0, 1.0) -(1.0, 0.66179161860822766, 0.0, 1.0) -(1.0, 0.66000768935024989, 0.0, 1.0) -(1.0, 0.65822376009227224, 0.0, 1.0) -(1.0, 0.65643983083429447, 0.0, 1.0) -(1.0, 0.65465590157631681, 0.0, 1.0) -(1.0, 0.65287197231833916, 0.0, 1.0) -(1.0, 0.65108804306036139, 0.0, 1.0) -(1.0, 0.64930411380238373, 0.0, 1.0) -(1.0, 0.64752018454440607, 0.0, 1.0) -(1.0, 0.64573625528642831, 0.0, 1.0) -(1.0, 0.64395232602845054, 0.0, 1.0) -(1.0, 0.64216839677047288, 0.0, 1.0) -(1.0, 0.64038446751249523, 0.0, 1.0) -(1.0, 0.63860053825451746, 0.0, 1.0) -(1.0, 0.6368166089965398, 0.0, 1.0) -(1.0, 0.63503267973856214, 0.0, 1.0) -(1.0, 0.63324875048058438, 0.0, 1.0) -(1.0, 0.63146482122260672, 0.0, 1.0) -(1.0, 0.62968089196462895, 0.0, 1.0) -(1.0, 0.6278969627066513, 0.0, 1.0) -(0.99986159169550171, 0.62592848904267584, 0.0, 1.0) -(0.99967704728950402, 0.62389850057670126, 0.0, 1.0) -(0.99949250288350633, 0.62186851211072669, 0.0, 1.0) -(0.99930795847750864, 0.619838523644752, 0.0, 1.0) -(0.99912341407151095, 0.61780853517877743, 0.0, 1.0) -(0.99893886966551326, 0.61577854671280274, 0.0, 1.0) -(0.99875432525951557, 0.61374855824682817, 0.0, 1.0) -(0.99856978085351789, 0.61171856978085348, 0.0, 1.0) -(0.9983852364475202, 0.60968858131487891, 0.0, 1.0) -(0.99820069204152251, 0.60765859284890422, 0.0, 1.0) -(0.99801614763552482, 0.60562860438292965, 0.0, 1.0) -(0.99783160322952713, 0.60359861591695496, 0.0, 1.0) -(0.99764705882352944, 0.60156862745098039, 0.0, 1.0) -(0.99746251441753175, 0.59953863898500581, 0.0, 1.0) -(0.99727797001153407, 0.59750865051903113, 0.0, 1.0) -(0.99709342560553638, 0.59547866205305655, 0.0, 1.0) -(0.99690888119953869, 0.59344867358708187, 0.0, 1.0) -(0.996724336793541, 0.59141868512110729, 0.0, 1.0) -(0.99653979238754331, 0.5893886966551326, 0.0, 1.0) -(0.99635524798154562, 0.58735870818915803, 0.0, 1.0) -(0.99617070357554793, 0.58532871972318345, 0.0, 1.0) -(0.99598615916955013, 0.58329873125720877, 0.0, 1.0) -(0.99580161476355245, 0.58126874279123419, 0.0, 1.0) -(0.99561707035755476, 0.57923875432525951, 0.0, 1.0) -(0.99543252595155707, 0.57720876585928493, 0.0, 1.0) -(0.99524798154555938, 0.57517877739331025, 0.0, 1.0) -(0.99506343713956169, 0.57314878892733567, 0.0, 1.0) -(0.994878892733564, 0.57111880046136099, 0.0, 1.0) -(0.99469434832756631, 0.56908881199538641, 0.0, 1.0) -(0.99450980392156862, 0.56705882352941173, 0.0, 1.0) -(0.99432525951557094, 0.56502883506343715, 0.0, 1.0) -(0.99414071510957325, 0.56299884659746247, 0.0, 1.0) -(0.99395617070357556, 0.56096885813148789, 0.0, 1.0) -(0.99377162629757787, 0.55893886966551332, 0.0, 1.0) -(0.99358708189158018, 0.55690888119953863, 0.0, 1.0) -(0.99340253748558249, 0.55487889273356406, 0.0, 1.0) -(0.9932179930795848, 0.55284890426758948, 0.0, 1.0) -(0.99303344867358712, 0.55081891580161479, 0.0, 1.0) -(0.99284890426758943, 0.54878892733564011, 0.0, 1.0) -(0.99266435986159174, 0.54675893886966553, 0.0, 1.0) -(0.99247981545559405, 0.54472895040369085, 0.0, 1.0) -(0.99229527104959636, 0.54269896193771627, 0.0, 1.0) -(0.99211072664359867, 0.54066897347174159, 0.0, 1.0) -(0.99192618223760098, 0.53863898500576701, 0.0, 1.0) -(0.9917416378316033, 0.53660899653979244, 0.0, 1.0) -(0.99155709342560561, 0.53457900807381775, 0.0, 1.0) -(0.99137254901960792, 0.53254901960784318, 0.0, 1.0) -(0.99118800461361023, 0.53051903114186849, 0.0, 1.0) -(0.99100346020761254, 0.52848904267589392, 0.0, 1.0) -(0.99081891580161474, 0.52645905420991923, 0.0, 1.0) -(0.99063437139561705, 0.52442906574394466, 0.0, 1.0) -(0.99044982698961936, 0.52239907727796997, 0.0, 1.0) -(0.99026528258362168, 0.5203690888119954, 0.0, 1.0) -(0.99008073817762399, 0.51833910034602071, 0.0, 1.0) -(0.9898961937716263, 0.51630911188004613, 0.0, 1.0) -(0.98971164936562861, 0.51427912341407156, 0.0, 1.0) -(0.98952710495963092, 0.51224913494809687, 0.0, 1.0) -(0.98934256055363323, 0.5102191464821223, 0.0, 1.0) -(0.98915801614763554, 0.50818915801614761, 0.0, 1.0) -(0.98897347174163786, 0.50615916955017304, 0.0, 1.0) -(0.98878892733564017, 0.50412918108419835, 0.0, 1.0) -(0.98860438292964248, 0.50209919261822378, 0.0, 1.0) -(0.98841983852364479, 0.5000692041522492, 0.0, 1.0) -(0.9882352941176471, 0.49803921568627452, 0.0, 1.0) diff --git a/extern/tfn/colormaps/sequential2/afmhot.cpp b/extern/tfn/colormaps/sequential2/afmhot.cpp deleted file mode 100644 index f79c084..0000000 --- a/extern/tfn/colormaps/sequential2/afmhot.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential2_afmhot; -} -const std::vector colormap::data_sequential2_afmhot = /* NOLINT(cert-err58-cpp) */ -{ -{0.0f, 0.0f, 0.0f, 1.0f}, -{0.0078431372549019607f, 0.0f, 0.0f, 1.0f}, -{0.015686274509803921f, 0.0f, 0.0f, 1.0f}, -{0.023529411764705882f, 0.0f, 0.0f, 1.0f}, -{0.031372549019607843f, 0.0f, 0.0f, 1.0f}, -{0.039215686274509803f, 0.0f, 0.0f, 1.0f}, -{0.047058823529411764f, 0.0f, 0.0f, 1.0f}, -{0.054901960784313725f, 0.0f, 0.0f, 1.0f}, -{0.062745098039215685f, 0.0f, 0.0f, 1.0f}, -{0.070588235294117646f, 0.0f, 0.0f, 1.0f}, -{0.078431372549019607f, 0.0f, 0.0f, 1.0f}, -{0.086274509803921567f, 0.0f, 0.0f, 1.0f}, -{0.094117647058823528f, 0.0f, 0.0f, 1.0f}, -{0.10196078431372549f, 0.0f, 0.0f, 1.0f}, -{0.10980392156862745f, 0.0f, 0.0f, 1.0f}, -{0.11764705882352941f, 0.0f, 0.0f, 1.0f}, -{0.12549019607843137f, 0.0f, 0.0f, 1.0f}, -{0.13333333333333333f, 0.0f, 0.0f, 1.0f}, -{0.14117647058823529f, 0.0f, 0.0f, 1.0f}, -{0.14901960784313725f, 0.0f, 0.0f, 1.0f}, -{0.15686274509803921f, 0.0f, 0.0f, 1.0f}, -{0.16470588235294117f, 0.0f, 0.0f, 1.0f}, -{0.17254901960784313f, 0.0f, 0.0f, 1.0f}, -{0.1803921568627451f, 0.0f, 0.0f, 1.0f}, -{0.18823529411764706f, 0.0f, 0.0f, 1.0f}, -{0.19607843137254902f, 0.0f, 0.0f, 1.0f}, -{0.20392156862745098f, 0.0f, 0.0f, 1.0f}, -{0.21176470588235294f, 0.0f, 0.0f, 1.0f}, -{0.2196078431372549f, 0.0f, 0.0f, 1.0f}, -{0.22745098039215686f, 0.0f, 0.0f, 1.0f}, -{0.23529411764705882f, 0.0f, 0.0f, 1.0f}, -{0.24313725490196078f, 0.0f, 0.0f, 1.0f}, -{0.25098039215686274f, 0.0f, 0.0f, 1.0f}, -{0.25882352941176467f, 0.0f, 0.0f, 1.0f}, -{0.26666666666666666f, 0.0f, 0.0f, 1.0f}, -{0.27450980392156865f, 0.0f, 0.0f, 1.0f}, -{0.28235294117647058f, 0.0f, 0.0f, 1.0f}, -{0.29019607843137252f, 0.0f, 0.0f, 1.0f}, -{0.29803921568627451f, 0.0f, 0.0f, 1.0f}, -{0.30588235294117649f, 0.0f, 0.0f, 1.0f}, -{0.31372549019607843f, 0.0f, 0.0f, 1.0f}, -{0.32156862745098036f, 0.0f, 0.0f, 1.0f}, -{0.32941176470588235f, 0.0f, 0.0f, 1.0f}, -{0.33725490196078434f, 0.0f, 0.0f, 1.0f}, -{0.34509803921568627f, 0.0f, 0.0f, 1.0f}, -{0.3529411764705882f, 0.0f, 0.0f, 1.0f}, -{0.36078431372549019f, 0.0f, 0.0f, 1.0f}, -{0.36862745098039218f, 0.0f, 0.0f, 1.0f}, -{0.37647058823529411f, 0.0f, 0.0f, 1.0f}, -{0.38431372549019605f, 0.0f, 0.0f, 1.0f}, -{0.39215686274509803f, 0.0f, 0.0f, 1.0f}, -{0.40000000000000002f, 0.0f, 0.0f, 1.0f}, -{0.40784313725490196f, 0.0f, 0.0f, 1.0f}, -{0.41568627450980389f, 0.0f, 0.0f, 1.0f}, -{0.42352941176470588f, 0.0f, 0.0f, 1.0f}, -{0.43137254901960786f, 0.0f, 0.0f, 1.0f}, -{0.4392156862745098f, 0.0f, 0.0f, 1.0f}, -{0.44705882352941173f, 0.0f, 0.0f, 1.0f}, -{0.45490196078431372f, 0.0f, 0.0f, 1.0f}, -{0.46274509803921571f, 0.0f, 0.0f, 1.0f}, -{0.47058823529411764f, 0.0f, 0.0f, 1.0f}, -{0.47843137254901957f, 0.0f, 0.0f, 1.0f}, -{0.48627450980392156f, 0.0f, 0.0f, 1.0f}, -{0.49411764705882355f, 0.0f, 0.0f, 1.0f}, -{0.50196078431372548f, 0.0019607843137254832f, 0.0f, 1.0f}, -{0.50980392156862742f, 0.0098039215686274161f, 0.0f, 1.0f}, -{0.51764705882352935f, 0.017647058823529349f, 0.0f, 1.0f}, -{0.52549019607843139f, 0.025490196078431393f, 0.0f, 1.0f}, -{0.53333333333333333f, 0.033333333333333326f, 0.0f, 1.0f}, -{0.54117647058823526f, 0.041176470588235259f, 0.0f, 1.0f}, -{0.5490196078431373f, 0.049019607843137303f, 0.0f, 1.0f}, -{0.55686274509803924f, 0.056862745098039236f, 0.0f, 1.0f}, -{0.56470588235294117f, 0.064705882352941169f, 0.0f, 1.0f}, -{0.5725490196078431f, 0.072549019607843102f, 0.0f, 1.0f}, -{0.58039215686274503f, 0.080392156862745034f, 0.0f, 1.0f}, -{0.58823529411764708f, 0.088235294117647078f, 0.0f, 1.0f}, -{0.59607843137254901f, 0.096078431372549011f, 0.0f, 1.0f}, -{0.60392156862745094f, 0.10392156862745094f, 0.0f, 1.0f}, -{0.61176470588235299f, 0.11176470588235299f, 0.0f, 1.0f}, -{0.61960784313725492f, 0.11960784313725492f, 0.0f, 1.0f}, -{0.62745098039215685f, 0.12745098039215685f, 0.0f, 1.0f}, -{0.63529411764705879f, 0.13529411764705879f, 0.0f, 1.0f}, -{0.64313725490196072f, 0.14313725490196072f, 0.0f, 1.0f}, -{0.65098039215686276f, 0.15098039215686276f, 0.0f, 1.0f}, -{0.6588235294117647f, 0.1588235294117647f, 0.0f, 1.0f}, -{0.66666666666666663f, 0.16666666666666663f, 0.0f, 1.0f}, -{0.67450980392156867f, 0.17450980392156867f, 0.0f, 1.0f}, -{0.68235294117647061f, 0.18235294117647061f, 0.0f, 1.0f}, -{0.69019607843137254f, 0.19019607843137254f, 0.0f, 1.0f}, -{0.69803921568627447f, 0.19803921568627447f, 0.0f, 1.0f}, -{0.70588235294117641f, 0.20588235294117641f, 0.0f, 1.0f}, -{0.71372549019607845f, 0.21372549019607845f, 0.0f, 1.0f}, -{0.72156862745098038f, 0.22156862745098038f, 0.0f, 1.0f}, -{0.72941176470588232f, 0.22941176470588232f, 0.0f, 1.0f}, -{0.73725490196078436f, 0.23725490196078436f, 0.0f, 1.0f}, -{0.74509803921568629f, 0.24509803921568629f, 0.0f, 1.0f}, -{0.75294117647058822f, 0.25294117647058822f, 0.0f, 1.0f}, -{0.76078431372549016f, 0.26078431372549016f, 0.0f, 1.0f}, -{0.76862745098039209f, 0.26862745098039209f, 0.0f, 1.0f}, -{0.77647058823529413f, 0.27647058823529413f, 0.0f, 1.0f}, -{0.78431372549019607f, 0.28431372549019607f, 0.0f, 1.0f}, -{0.792156862745098f, 0.292156862745098f, 0.0f, 1.0f}, -{0.80000000000000004f, 0.30000000000000004f, 0.0f, 1.0f}, -{0.80784313725490198f, 0.30784313725490198f, 0.0f, 1.0f}, -{0.81568627450980391f, 0.31568627450980391f, 0.0f, 1.0f}, -{0.82352941176470584f, 0.32352941176470584f, 0.0f, 1.0f}, -{0.83137254901960778f, 0.33137254901960778f, 0.0f, 1.0f}, -{0.83921568627450982f, 0.33921568627450982f, 0.0f, 1.0f}, -{0.84705882352941175f, 0.34705882352941175f, 0.0f, 1.0f}, -{0.85490196078431369f, 0.35490196078431369f, 0.0f, 1.0f}, -{0.86274509803921573f, 0.36274509803921573f, 0.0f, 1.0f}, -{0.87058823529411766f, 0.37058823529411766f, 0.0f, 1.0f}, -{0.8784313725490196f, 0.3784313725490196f, 0.0f, 1.0f}, -{0.88627450980392153f, 0.38627450980392153f, 0.0f, 1.0f}, -{0.89411764705882346f, 0.39411764705882346f, 0.0f, 1.0f}, -{0.90196078431372551f, 0.40196078431372551f, 0.0f, 1.0f}, -{0.90980392156862744f, 0.40980392156862744f, 0.0f, 1.0f}, -{0.91764705882352937f, 0.41764705882352937f, 0.0f, 1.0f}, -{0.92549019607843142f, 0.42549019607843142f, 0.0f, 1.0f}, -{0.93333333333333335f, 0.43333333333333335f, 0.0f, 1.0f}, -{0.94117647058823528f, 0.44117647058823528f, 0.0f, 1.0f}, -{0.94901960784313721f, 0.44901960784313721f, 0.0f, 1.0f}, -{0.95686274509803915f, 0.45686274509803915f, 0.0f, 1.0f}, -{0.96470588235294119f, 0.46470588235294119f, 0.0f, 1.0f}, -{0.97254901960784312f, 0.47254901960784312f, 0.0f, 1.0f}, -{0.98039215686274506f, 0.48039215686274506f, 0.0f, 1.0f}, -{0.9882352941176471f, 0.4882352941176471f, 0.0f, 1.0f}, -{0.99607843137254903f, 0.49607843137254903f, 0.0f, 1.0f}, -{1.0f, 0.50392156862745097f, 0.0039215686274509665f, 1.0f}, -{1.0f, 0.5117647058823529f, 0.011764705882352899f, 1.0f}, -{1.0f, 0.51960784313725483f, 0.019607843137254832f, 1.0f}, -{1.0f, 0.52745098039215677f, 0.027450980392156765f, 1.0f}, -{1.0f, 0.5352941176470587f, 0.035294117647058698f, 1.0f}, -{1.0f, 0.54313725490196085f, 0.043137254901960853f, 1.0f}, -{1.0f, 0.55098039215686279f, 0.050980392156862786f, 1.0f}, -{1.0f, 0.55882352941176472f, 0.058823529411764719f, 1.0f}, -{1.0f, 0.56666666666666665f, 0.066666666666666652f, 1.0f}, -{1.0f, 0.57450980392156858f, 0.074509803921568585f, 1.0f}, -{1.0f, 0.58235294117647052f, 0.082352941176470518f, 1.0f}, -{1.0f, 0.59019607843137245f, 0.090196078431372451f, 1.0f}, -{1.0f, 0.59803921568627461f, 0.098039215686274606f, 1.0f}, -{1.0f, 0.60588235294117654f, 0.10588235294117654f, 1.0f}, -{1.0f, 0.61372549019607847f, 0.11372549019607847f, 1.0f}, -{1.0f, 0.6215686274509804f, 0.1215686274509804f, 1.0f}, -{1.0f, 0.62941176470588234f, 0.12941176470588234f, 1.0f}, -{1.0f, 0.63725490196078427f, 0.13725490196078427f, 1.0f}, -{1.0f, 0.6450980392156862f, 0.1450980392156862f, 1.0f}, -{1.0f, 0.65294117647058814f, 0.15294117647058814f, 1.0f}, -{1.0f, 0.66078431372549007f, 0.16078431372549007f, 1.0f}, -{1.0f, 0.66862745098039222f, 0.16862745098039222f, 1.0f}, -{1.0f, 0.67647058823529416f, 0.17647058823529416f, 1.0f}, -{1.0f, 0.68431372549019609f, 0.18431372549019609f, 1.0f}, -{1.0f, 0.69215686274509802f, 0.19215686274509802f, 1.0f}, -{1.0f, 0.69999999999999996f, 0.19999999999999996f, 1.0f}, -{1.0f, 0.70784313725490189f, 0.20784313725490189f, 1.0f}, -{1.0f, 0.71568627450980382f, 0.21568627450980382f, 1.0f}, -{1.0f, 0.72352941176470598f, 0.22352941176470598f, 1.0f}, -{1.0f, 0.73137254901960791f, 0.23137254901960791f, 1.0f}, -{1.0f, 0.73921568627450984f, 0.23921568627450984f, 1.0f}, -{1.0f, 0.74705882352941178f, 0.24705882352941178f, 1.0f}, -{1.0f, 0.75490196078431371f, 0.25490196078431371f, 1.0f}, -{1.0f, 0.76274509803921564f, 0.26274509803921564f, 1.0f}, -{1.0f, 0.77058823529411757f, 0.27058823529411757f, 1.0f}, -{1.0f, 0.77843137254901951f, 0.27843137254901951f, 1.0f}, -{1.0f, 0.78627450980392144f, 0.28627450980392144f, 1.0f}, -{1.0f, 0.79411764705882359f, 0.29411764705882359f, 1.0f}, -{1.0f, 0.80196078431372553f, 0.30196078431372553f, 1.0f}, -{1.0f, 0.80980392156862746f, 0.30980392156862746f, 1.0f}, -{1.0f, 0.81764705882352939f, 0.31764705882352939f, 1.0f}, -{1.0f, 0.82549019607843133f, 0.32549019607843133f, 1.0f}, -{1.0f, 0.83333333333333326f, 0.33333333333333326f, 1.0f}, -{1.0f, 0.84117647058823519f, 0.34117647058823519f, 1.0f}, -{1.0f, 0.84901960784313735f, 0.34901960784313735f, 1.0f}, -{1.0f, 0.85686274509803928f, 0.35686274509803928f, 1.0f}, -{1.0f, 0.86470588235294121f, 0.36470588235294121f, 1.0f}, -{1.0f, 0.87254901960784315f, 0.37254901960784315f, 1.0f}, -{1.0f, 0.88039215686274508f, 0.38039215686274508f, 1.0f}, -{1.0f, 0.88823529411764701f, 0.38823529411764701f, 1.0f}, -{1.0f, 0.89607843137254894f, 0.39607843137254894f, 1.0f}, -{1.0f, 0.90392156862745088f, 0.40392156862745088f, 1.0f}, -{1.0f, 0.91176470588235281f, 0.41176470588235281f, 1.0f}, -{1.0f, 0.91960784313725497f, 0.41960784313725497f, 1.0f}, -{1.0f, 0.9274509803921569f, 0.4274509803921569f, 1.0f}, -{1.0f, 0.93529411764705883f, 0.43529411764705883f, 1.0f}, -{1.0f, 0.94313725490196076f, 0.44313725490196076f, 1.0f}, -{1.0f, 0.9509803921568627f, 0.4509803921568627f, 1.0f}, -{1.0f, 0.95882352941176463f, 0.45882352941176463f, 1.0f}, -{1.0f, 0.96666666666666656f, 0.46666666666666656f, 1.0f}, -{1.0f, 0.97450980392156872f, 0.47450980392156872f, 1.0f}, -{1.0f, 0.98235294117647065f, 0.48235294117647065f, 1.0f}, -{1.0f, 0.99019607843137258f, 0.49019607843137258f, 1.0f}, -{1.0f, 0.99803921568627452f, 0.49803921568627452f, 1.0f}, -{1.0f, 1.0f, 0.50588235294117645f, 1.0f}, -{1.0f, 1.0f, 0.51372549019607838f, 1.0f}, -{1.0f, 1.0f, 0.52156862745098032f, 1.0f}, -{1.0f, 1.0f, 0.52941176470588225f, 1.0f}, -{1.0f, 1.0f, 0.53725490196078418f, 1.0f}, -{1.0f, 1.0f, 0.54509803921568634f, 1.0f}, -{1.0f, 1.0f, 0.55294117647058827f, 1.0f}, -{1.0f, 1.0f, 0.5607843137254902f, 1.0f}, -{1.0f, 1.0f, 0.56862745098039214f, 1.0f}, -{1.0f, 1.0f, 0.57647058823529407f, 1.0f}, -{1.0f, 1.0f, 0.584313725490196f, 1.0f}, -{1.0f, 1.0f, 0.59215686274509793f, 1.0f}, -{1.0f, 1.0f, 0.60000000000000009f, 1.0f}, -{1.0f, 1.0f, 0.60784313725490202f, 1.0f}, -{1.0f, 1.0f, 0.61568627450980395f, 1.0f}, -{1.0f, 1.0f, 0.62352941176470589f, 1.0f}, -{1.0f, 1.0f, 0.63137254901960782f, 1.0f}, -{1.0f, 1.0f, 0.63921568627450975f, 1.0f}, -{1.0f, 1.0f, 0.64705882352941169f, 1.0f}, -{1.0f, 1.0f, 0.65490196078431362f, 1.0f}, -{1.0f, 1.0f, 0.66274509803921555f, 1.0f}, -{1.0f, 1.0f, 0.67058823529411771f, 1.0f}, -{1.0f, 1.0f, 0.67843137254901964f, 1.0f}, -{1.0f, 1.0f, 0.68627450980392157f, 1.0f}, -{1.0f, 1.0f, 0.69411764705882351f, 1.0f}, -{1.0f, 1.0f, 0.70196078431372544f, 1.0f}, -{1.0f, 1.0f, 0.70980392156862737f, 1.0f}, -{1.0f, 1.0f, 0.7176470588235293f, 1.0f}, -{1.0f, 1.0f, 0.72549019607843146f, 1.0f}, -{1.0f, 1.0f, 0.73333333333333339f, 1.0f}, -{1.0f, 1.0f, 0.74117647058823533f, 1.0f}, -{1.0f, 1.0f, 0.74901960784313726f, 1.0f}, -{1.0f, 1.0f, 0.75686274509803919f, 1.0f}, -{1.0f, 1.0f, 0.76470588235294112f, 1.0f}, -{1.0f, 1.0f, 0.77254901960784306f, 1.0f}, -{1.0f, 1.0f, 0.78039215686274499f, 1.0f}, -{1.0f, 1.0f, 0.78823529411764692f, 1.0f}, -{1.0f, 1.0f, 0.79607843137254908f, 1.0f}, -{1.0f, 1.0f, 0.80392156862745101f, 1.0f}, -{1.0f, 1.0f, 0.81176470588235294f, 1.0f}, -{1.0f, 1.0f, 0.81960784313725488f, 1.0f}, -{1.0f, 1.0f, 0.82745098039215681f, 1.0f}, -{1.0f, 1.0f, 0.83529411764705874f, 1.0f}, -{1.0f, 1.0f, 0.84313725490196068f, 1.0f}, -{1.0f, 1.0f, 0.85098039215686283f, 1.0f}, -{1.0f, 1.0f, 0.85882352941176476f, 1.0f}, -{1.0f, 1.0f, 0.8666666666666667f, 1.0f}, -{1.0f, 1.0f, 0.87450980392156863f, 1.0f}, -{1.0f, 1.0f, 0.88235294117647056f, 1.0f}, -{1.0f, 1.0f, 0.8901960784313725f, 1.0f}, -{1.0f, 1.0f, 0.89803921568627443f, 1.0f}, -{1.0f, 1.0f, 0.90588235294117636f, 1.0f}, -{1.0f, 1.0f, 0.91372549019607829f, 1.0f}, -{1.0f, 1.0f, 0.92156862745098045f, 1.0f}, -{1.0f, 1.0f, 0.92941176470588238f, 1.0f}, -{1.0f, 1.0f, 0.93725490196078431f, 1.0f}, -{1.0f, 1.0f, 0.94509803921568625f, 1.0f}, -{1.0f, 1.0f, 0.95294117647058818f, 1.0f}, -{1.0f, 1.0f, 0.96078431372549011f, 1.0f}, -{1.0f, 1.0f, 0.96862745098039205f, 1.0f}, -{1.0f, 1.0f, 0.9764705882352942f, 1.0f}, -{1.0f, 1.0f, 0.98431372549019613f, 1.0f}, -{1.0f, 1.0f, 0.99215686274509807f, 1.0f}, -{1.0f, 1.0f, 1.0f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential2/afmhot.txt b/extern/tfn/colormaps/sequential2/afmhot.txt deleted file mode 100644 index 5ace91e..0000000 --- a/extern/tfn/colormaps/sequential2/afmhot.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.0, 0.0, 0.0, 1.0) -(0.0078431372549019607, 0.0, 0.0, 1.0) -(0.015686274509803921, 0.0, 0.0, 1.0) -(0.023529411764705882, 0.0, 0.0, 1.0) -(0.031372549019607843, 0.0, 0.0, 1.0) -(0.039215686274509803, 0.0, 0.0, 1.0) -(0.047058823529411764, 0.0, 0.0, 1.0) -(0.054901960784313725, 0.0, 0.0, 1.0) -(0.062745098039215685, 0.0, 0.0, 1.0) -(0.070588235294117646, 0.0, 0.0, 1.0) -(0.078431372549019607, 0.0, 0.0, 1.0) -(0.086274509803921567, 0.0, 0.0, 1.0) -(0.094117647058823528, 0.0, 0.0, 1.0) -(0.10196078431372549, 0.0, 0.0, 1.0) -(0.10980392156862745, 0.0, 0.0, 1.0) -(0.11764705882352941, 0.0, 0.0, 1.0) -(0.12549019607843137, 0.0, 0.0, 1.0) -(0.13333333333333333, 0.0, 0.0, 1.0) -(0.14117647058823529, 0.0, 0.0, 1.0) -(0.14901960784313725, 0.0, 0.0, 1.0) -(0.15686274509803921, 0.0, 0.0, 1.0) -(0.16470588235294117, 0.0, 0.0, 1.0) -(0.17254901960784313, 0.0, 0.0, 1.0) -(0.1803921568627451, 0.0, 0.0, 1.0) -(0.18823529411764706, 0.0, 0.0, 1.0) -(0.19607843137254902, 0.0, 0.0, 1.0) -(0.20392156862745098, 0.0, 0.0, 1.0) -(0.21176470588235294, 0.0, 0.0, 1.0) -(0.2196078431372549, 0.0, 0.0, 1.0) -(0.22745098039215686, 0.0, 0.0, 1.0) -(0.23529411764705882, 0.0, 0.0, 1.0) -(0.24313725490196078, 0.0, 0.0, 1.0) -(0.25098039215686274, 0.0, 0.0, 1.0) -(0.25882352941176467, 0.0, 0.0, 1.0) -(0.26666666666666666, 0.0, 0.0, 1.0) -(0.27450980392156865, 0.0, 0.0, 1.0) -(0.28235294117647058, 0.0, 0.0, 1.0) -(0.29019607843137252, 0.0, 0.0, 1.0) -(0.29803921568627451, 0.0, 0.0, 1.0) -(0.30588235294117649, 0.0, 0.0, 1.0) -(0.31372549019607843, 0.0, 0.0, 1.0) -(0.32156862745098036, 0.0, 0.0, 1.0) -(0.32941176470588235, 0.0, 0.0, 1.0) -(0.33725490196078434, 0.0, 0.0, 1.0) -(0.34509803921568627, 0.0, 0.0, 1.0) -(0.3529411764705882, 0.0, 0.0, 1.0) -(0.36078431372549019, 0.0, 0.0, 1.0) -(0.36862745098039218, 0.0, 0.0, 1.0) -(0.37647058823529411, 0.0, 0.0, 1.0) -(0.38431372549019605, 0.0, 0.0, 1.0) -(0.39215686274509803, 0.0, 0.0, 1.0) -(0.40000000000000002, 0.0, 0.0, 1.0) -(0.40784313725490196, 0.0, 0.0, 1.0) -(0.41568627450980389, 0.0, 0.0, 1.0) -(0.42352941176470588, 0.0, 0.0, 1.0) -(0.43137254901960786, 0.0, 0.0, 1.0) -(0.4392156862745098, 0.0, 0.0, 1.0) -(0.44705882352941173, 0.0, 0.0, 1.0) -(0.45490196078431372, 0.0, 0.0, 1.0) -(0.46274509803921571, 0.0, 0.0, 1.0) -(0.47058823529411764, 0.0, 0.0, 1.0) -(0.47843137254901957, 0.0, 0.0, 1.0) -(0.48627450980392156, 0.0, 0.0, 1.0) -(0.49411764705882355, 0.0, 0.0, 1.0) -(0.50196078431372548, 0.0019607843137254832, 0.0, 1.0) -(0.50980392156862742, 0.0098039215686274161, 0.0, 1.0) -(0.51764705882352935, 0.017647058823529349, 0.0, 1.0) -(0.52549019607843139, 0.025490196078431393, 0.0, 1.0) -(0.53333333333333333, 0.033333333333333326, 0.0, 1.0) -(0.54117647058823526, 0.041176470588235259, 0.0, 1.0) -(0.5490196078431373, 0.049019607843137303, 0.0, 1.0) -(0.55686274509803924, 0.056862745098039236, 0.0, 1.0) -(0.56470588235294117, 0.064705882352941169, 0.0, 1.0) -(0.5725490196078431, 0.072549019607843102, 0.0, 1.0) -(0.58039215686274503, 0.080392156862745034, 0.0, 1.0) -(0.58823529411764708, 0.088235294117647078, 0.0, 1.0) -(0.59607843137254901, 0.096078431372549011, 0.0, 1.0) -(0.60392156862745094, 0.10392156862745094, 0.0, 1.0) -(0.61176470588235299, 0.11176470588235299, 0.0, 1.0) -(0.61960784313725492, 0.11960784313725492, 0.0, 1.0) -(0.62745098039215685, 0.12745098039215685, 0.0, 1.0) -(0.63529411764705879, 0.13529411764705879, 0.0, 1.0) -(0.64313725490196072, 0.14313725490196072, 0.0, 1.0) -(0.65098039215686276, 0.15098039215686276, 0.0, 1.0) -(0.6588235294117647, 0.1588235294117647, 0.0, 1.0) -(0.66666666666666663, 0.16666666666666663, 0.0, 1.0) -(0.67450980392156867, 0.17450980392156867, 0.0, 1.0) -(0.68235294117647061, 0.18235294117647061, 0.0, 1.0) -(0.69019607843137254, 0.19019607843137254, 0.0, 1.0) -(0.69803921568627447, 0.19803921568627447, 0.0, 1.0) -(0.70588235294117641, 0.20588235294117641, 0.0, 1.0) -(0.71372549019607845, 0.21372549019607845, 0.0, 1.0) -(0.72156862745098038, 0.22156862745098038, 0.0, 1.0) -(0.72941176470588232, 0.22941176470588232, 0.0, 1.0) -(0.73725490196078436, 0.23725490196078436, 0.0, 1.0) -(0.74509803921568629, 0.24509803921568629, 0.0, 1.0) -(0.75294117647058822, 0.25294117647058822, 0.0, 1.0) -(0.76078431372549016, 0.26078431372549016, 0.0, 1.0) -(0.76862745098039209, 0.26862745098039209, 0.0, 1.0) -(0.77647058823529413, 0.27647058823529413, 0.0, 1.0) -(0.78431372549019607, 0.28431372549019607, 0.0, 1.0) -(0.792156862745098, 0.292156862745098, 0.0, 1.0) -(0.80000000000000004, 0.30000000000000004, 0.0, 1.0) -(0.80784313725490198, 0.30784313725490198, 0.0, 1.0) -(0.81568627450980391, 0.31568627450980391, 0.0, 1.0) -(0.82352941176470584, 0.32352941176470584, 0.0, 1.0) -(0.83137254901960778, 0.33137254901960778, 0.0, 1.0) -(0.83921568627450982, 0.33921568627450982, 0.0, 1.0) -(0.84705882352941175, 0.34705882352941175, 0.0, 1.0) -(0.85490196078431369, 0.35490196078431369, 0.0, 1.0) -(0.86274509803921573, 0.36274509803921573, 0.0, 1.0) -(0.87058823529411766, 0.37058823529411766, 0.0, 1.0) -(0.8784313725490196, 0.3784313725490196, 0.0, 1.0) -(0.88627450980392153, 0.38627450980392153, 0.0, 1.0) -(0.89411764705882346, 0.39411764705882346, 0.0, 1.0) -(0.90196078431372551, 0.40196078431372551, 0.0, 1.0) -(0.90980392156862744, 0.40980392156862744, 0.0, 1.0) -(0.91764705882352937, 0.41764705882352937, 0.0, 1.0) -(0.92549019607843142, 0.42549019607843142, 0.0, 1.0) -(0.93333333333333335, 0.43333333333333335, 0.0, 1.0) -(0.94117647058823528, 0.44117647058823528, 0.0, 1.0) -(0.94901960784313721, 0.44901960784313721, 0.0, 1.0) -(0.95686274509803915, 0.45686274509803915, 0.0, 1.0) -(0.96470588235294119, 0.46470588235294119, 0.0, 1.0) -(0.97254901960784312, 0.47254901960784312, 0.0, 1.0) -(0.98039215686274506, 0.48039215686274506, 0.0, 1.0) -(0.9882352941176471, 0.4882352941176471, 0.0, 1.0) -(0.99607843137254903, 0.49607843137254903, 0.0, 1.0) -(1.0, 0.50392156862745097, 0.0039215686274509665, 1.0) -(1.0, 0.5117647058823529, 0.011764705882352899, 1.0) -(1.0, 0.51960784313725483, 0.019607843137254832, 1.0) -(1.0, 0.52745098039215677, 0.027450980392156765, 1.0) -(1.0, 0.5352941176470587, 0.035294117647058698, 1.0) -(1.0, 0.54313725490196085, 0.043137254901960853, 1.0) -(1.0, 0.55098039215686279, 0.050980392156862786, 1.0) -(1.0, 0.55882352941176472, 0.058823529411764719, 1.0) -(1.0, 0.56666666666666665, 0.066666666666666652, 1.0) -(1.0, 0.57450980392156858, 0.074509803921568585, 1.0) -(1.0, 0.58235294117647052, 0.082352941176470518, 1.0) -(1.0, 0.59019607843137245, 0.090196078431372451, 1.0) -(1.0, 0.59803921568627461, 0.098039215686274606, 1.0) -(1.0, 0.60588235294117654, 0.10588235294117654, 1.0) -(1.0, 0.61372549019607847, 0.11372549019607847, 1.0) -(1.0, 0.6215686274509804, 0.1215686274509804, 1.0) -(1.0, 0.62941176470588234, 0.12941176470588234, 1.0) -(1.0, 0.63725490196078427, 0.13725490196078427, 1.0) -(1.0, 0.6450980392156862, 0.1450980392156862, 1.0) -(1.0, 0.65294117647058814, 0.15294117647058814, 1.0) -(1.0, 0.66078431372549007, 0.16078431372549007, 1.0) -(1.0, 0.66862745098039222, 0.16862745098039222, 1.0) -(1.0, 0.67647058823529416, 0.17647058823529416, 1.0) -(1.0, 0.68431372549019609, 0.18431372549019609, 1.0) -(1.0, 0.69215686274509802, 0.19215686274509802, 1.0) -(1.0, 0.69999999999999996, 0.19999999999999996, 1.0) -(1.0, 0.70784313725490189, 0.20784313725490189, 1.0) -(1.0, 0.71568627450980382, 0.21568627450980382, 1.0) -(1.0, 0.72352941176470598, 0.22352941176470598, 1.0) -(1.0, 0.73137254901960791, 0.23137254901960791, 1.0) -(1.0, 0.73921568627450984, 0.23921568627450984, 1.0) -(1.0, 0.74705882352941178, 0.24705882352941178, 1.0) -(1.0, 0.75490196078431371, 0.25490196078431371, 1.0) -(1.0, 0.76274509803921564, 0.26274509803921564, 1.0) -(1.0, 0.77058823529411757, 0.27058823529411757, 1.0) -(1.0, 0.77843137254901951, 0.27843137254901951, 1.0) -(1.0, 0.78627450980392144, 0.28627450980392144, 1.0) -(1.0, 0.79411764705882359, 0.29411764705882359, 1.0) -(1.0, 0.80196078431372553, 0.30196078431372553, 1.0) -(1.0, 0.80980392156862746, 0.30980392156862746, 1.0) -(1.0, 0.81764705882352939, 0.31764705882352939, 1.0) -(1.0, 0.82549019607843133, 0.32549019607843133, 1.0) -(1.0, 0.83333333333333326, 0.33333333333333326, 1.0) -(1.0, 0.84117647058823519, 0.34117647058823519, 1.0) -(1.0, 0.84901960784313735, 0.34901960784313735, 1.0) -(1.0, 0.85686274509803928, 0.35686274509803928, 1.0) -(1.0, 0.86470588235294121, 0.36470588235294121, 1.0) -(1.0, 0.87254901960784315, 0.37254901960784315, 1.0) -(1.0, 0.88039215686274508, 0.38039215686274508, 1.0) -(1.0, 0.88823529411764701, 0.38823529411764701, 1.0) -(1.0, 0.89607843137254894, 0.39607843137254894, 1.0) -(1.0, 0.90392156862745088, 0.40392156862745088, 1.0) -(1.0, 0.91176470588235281, 0.41176470588235281, 1.0) -(1.0, 0.91960784313725497, 0.41960784313725497, 1.0) -(1.0, 0.9274509803921569, 0.4274509803921569, 1.0) -(1.0, 0.93529411764705883, 0.43529411764705883, 1.0) -(1.0, 0.94313725490196076, 0.44313725490196076, 1.0) -(1.0, 0.9509803921568627, 0.4509803921568627, 1.0) -(1.0, 0.95882352941176463, 0.45882352941176463, 1.0) -(1.0, 0.96666666666666656, 0.46666666666666656, 1.0) -(1.0, 0.97450980392156872, 0.47450980392156872, 1.0) -(1.0, 0.98235294117647065, 0.48235294117647065, 1.0) -(1.0, 0.99019607843137258, 0.49019607843137258, 1.0) -(1.0, 0.99803921568627452, 0.49803921568627452, 1.0) -(1.0, 1.0, 0.50588235294117645, 1.0) -(1.0, 1.0, 0.51372549019607838, 1.0) -(1.0, 1.0, 0.52156862745098032, 1.0) -(1.0, 1.0, 0.52941176470588225, 1.0) -(1.0, 1.0, 0.53725490196078418, 1.0) -(1.0, 1.0, 0.54509803921568634, 1.0) -(1.0, 1.0, 0.55294117647058827, 1.0) -(1.0, 1.0, 0.5607843137254902, 1.0) -(1.0, 1.0, 0.56862745098039214, 1.0) -(1.0, 1.0, 0.57647058823529407, 1.0) -(1.0, 1.0, 0.584313725490196, 1.0) -(1.0, 1.0, 0.59215686274509793, 1.0) -(1.0, 1.0, 0.60000000000000009, 1.0) -(1.0, 1.0, 0.60784313725490202, 1.0) -(1.0, 1.0, 0.61568627450980395, 1.0) -(1.0, 1.0, 0.62352941176470589, 1.0) -(1.0, 1.0, 0.63137254901960782, 1.0) -(1.0, 1.0, 0.63921568627450975, 1.0) -(1.0, 1.0, 0.64705882352941169, 1.0) -(1.0, 1.0, 0.65490196078431362, 1.0) -(1.0, 1.0, 0.66274509803921555, 1.0) -(1.0, 1.0, 0.67058823529411771, 1.0) -(1.0, 1.0, 0.67843137254901964, 1.0) -(1.0, 1.0, 0.68627450980392157, 1.0) -(1.0, 1.0, 0.69411764705882351, 1.0) -(1.0, 1.0, 0.70196078431372544, 1.0) -(1.0, 1.0, 0.70980392156862737, 1.0) -(1.0, 1.0, 0.7176470588235293, 1.0) -(1.0, 1.0, 0.72549019607843146, 1.0) -(1.0, 1.0, 0.73333333333333339, 1.0) -(1.0, 1.0, 0.74117647058823533, 1.0) -(1.0, 1.0, 0.74901960784313726, 1.0) -(1.0, 1.0, 0.75686274509803919, 1.0) -(1.0, 1.0, 0.76470588235294112, 1.0) -(1.0, 1.0, 0.77254901960784306, 1.0) -(1.0, 1.0, 0.78039215686274499, 1.0) -(1.0, 1.0, 0.78823529411764692, 1.0) -(1.0, 1.0, 0.79607843137254908, 1.0) -(1.0, 1.0, 0.80392156862745101, 1.0) -(1.0, 1.0, 0.81176470588235294, 1.0) -(1.0, 1.0, 0.81960784313725488, 1.0) -(1.0, 1.0, 0.82745098039215681, 1.0) -(1.0, 1.0, 0.83529411764705874, 1.0) -(1.0, 1.0, 0.84313725490196068, 1.0) -(1.0, 1.0, 0.85098039215686283, 1.0) -(1.0, 1.0, 0.85882352941176476, 1.0) -(1.0, 1.0, 0.8666666666666667, 1.0) -(1.0, 1.0, 0.87450980392156863, 1.0) -(1.0, 1.0, 0.88235294117647056, 1.0) -(1.0, 1.0, 0.8901960784313725, 1.0) -(1.0, 1.0, 0.89803921568627443, 1.0) -(1.0, 1.0, 0.90588235294117636, 1.0) -(1.0, 1.0, 0.91372549019607829, 1.0) -(1.0, 1.0, 0.92156862745098045, 1.0) -(1.0, 1.0, 0.92941176470588238, 1.0) -(1.0, 1.0, 0.93725490196078431, 1.0) -(1.0, 1.0, 0.94509803921568625, 1.0) -(1.0, 1.0, 0.95294117647058818, 1.0) -(1.0, 1.0, 0.96078431372549011, 1.0) -(1.0, 1.0, 0.96862745098039205, 1.0) -(1.0, 1.0, 0.9764705882352942, 1.0) -(1.0, 1.0, 0.98431372549019613, 1.0) -(1.0, 1.0, 0.99215686274509807, 1.0) -(1.0, 1.0, 1.0, 1.0) diff --git a/extern/tfn/colormaps/sequential2/autumn.cpp b/extern/tfn/colormaps/sequential2/autumn.cpp deleted file mode 100644 index f155af8..0000000 --- a/extern/tfn/colormaps/sequential2/autumn.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential2_autumn; -} -const std::vector colormap::data_sequential2_autumn = /* NOLINT(cert-err58-cpp) */ -{ -{1.0f, 0.0f, 0.0f, 1.0f}, -{1.0f, 0.0039215686274509803f, 0.0f, 1.0f}, -{1.0f, 0.0078431372549019607f, 0.0f, 1.0f}, -{1.0f, 0.011764705882352941f, 0.0f, 1.0f}, -{1.0f, 0.015686274509803921f, 0.0f, 1.0f}, -{1.0f, 0.019607843137254902f, 0.0f, 1.0f}, -{1.0f, 0.023529411764705882f, 0.0f, 1.0f}, -{1.0f, 0.027450980392156862f, 0.0f, 1.0f}, -{1.0f, 0.031372549019607843f, 0.0f, 1.0f}, -{1.0f, 0.035294117647058823f, 0.0f, 1.0f}, -{1.0f, 0.039215686274509803f, 0.0f, 1.0f}, -{1.0f, 0.043137254901960784f, 0.0f, 1.0f}, -{1.0f, 0.047058823529411764f, 0.0f, 1.0f}, -{1.0f, 0.050980392156862744f, 0.0f, 1.0f}, -{1.0f, 0.054901960784313725f, 0.0f, 1.0f}, -{1.0f, 0.058823529411764705f, 0.0f, 1.0f}, -{1.0f, 0.062745098039215685f, 0.0f, 1.0f}, -{1.0f, 0.066666666666666666f, 0.0f, 1.0f}, -{1.0f, 0.070588235294117646f, 0.0f, 1.0f}, -{1.0f, 0.074509803921568626f, 0.0f, 1.0f}, -{1.0f, 0.078431372549019607f, 0.0f, 1.0f}, -{1.0f, 0.082352941176470587f, 0.0f, 1.0f}, -{1.0f, 0.086274509803921567f, 0.0f, 1.0f}, -{1.0f, 0.090196078431372548f, 0.0f, 1.0f}, -{1.0f, 0.094117647058823528f, 0.0f, 1.0f}, -{1.0f, 0.098039215686274508f, 0.0f, 1.0f}, -{1.0f, 0.10196078431372549f, 0.0f, 1.0f}, -{1.0f, 0.10588235294117647f, 0.0f, 1.0f}, -{1.0f, 0.10980392156862745f, 0.0f, 1.0f}, -{1.0f, 0.11372549019607843f, 0.0f, 1.0f}, -{1.0f, 0.11764705882352941f, 0.0f, 1.0f}, -{1.0f, 0.12156862745098039f, 0.0f, 1.0f}, -{1.0f, 0.12549019607843137f, 0.0f, 1.0f}, -{1.0f, 0.12941176470588234f, 0.0f, 1.0f}, -{1.0f, 0.13333333333333333f, 0.0f, 1.0f}, -{1.0f, 0.13725490196078433f, 0.0f, 1.0f}, -{1.0f, 0.14117647058823529f, 0.0f, 1.0f}, -{1.0f, 0.14509803921568626f, 0.0f, 1.0f}, -{1.0f, 0.14901960784313725f, 0.0f, 1.0f}, -{1.0f, 0.15294117647058825f, 0.0f, 1.0f}, -{1.0f, 0.15686274509803921f, 0.0f, 1.0f}, -{1.0f, 0.16078431372549018f, 0.0f, 1.0f}, -{1.0f, 0.16470588235294117f, 0.0f, 1.0f}, -{1.0f, 0.16862745098039217f, 0.0f, 1.0f}, -{1.0f, 0.17254901960784313f, 0.0f, 1.0f}, -{1.0f, 0.1764705882352941f, 0.0f, 1.0f}, -{1.0f, 0.1803921568627451f, 0.0f, 1.0f}, -{1.0f, 0.18431372549019609f, 0.0f, 1.0f}, -{1.0f, 0.18823529411764706f, 0.0f, 1.0f}, -{1.0f, 0.19215686274509802f, 0.0f, 1.0f}, -{1.0f, 0.19607843137254902f, 0.0f, 1.0f}, -{1.0f, 0.20000000000000001f, 0.0f, 1.0f}, -{1.0f, 0.20392156862745098f, 0.0f, 1.0f}, -{1.0f, 0.20784313725490194f, 0.0f, 1.0f}, -{1.0f, 0.21176470588235294f, 0.0f, 1.0f}, -{1.0f, 0.21568627450980393f, 0.0f, 1.0f}, -{1.0f, 0.2196078431372549f, 0.0f, 1.0f}, -{1.0f, 0.22352941176470587f, 0.0f, 1.0f}, -{1.0f, 0.22745098039215686f, 0.0f, 1.0f}, -{1.0f, 0.23137254901960785f, 0.0f, 1.0f}, -{1.0f, 0.23529411764705882f, 0.0f, 1.0f}, -{1.0f, 0.23921568627450979f, 0.0f, 1.0f}, -{1.0f, 0.24313725490196078f, 0.0f, 1.0f}, -{1.0f, 0.24705882352941178f, 0.0f, 1.0f}, -{1.0f, 0.25098039215686274f, 0.0f, 1.0f}, -{1.0f, 0.25490196078431371f, 0.0f, 1.0f}, -{1.0f, 0.25882352941176467f, 0.0f, 1.0f}, -{1.0f, 0.2627450980392157f, 0.0f, 1.0f}, -{1.0f, 0.26666666666666666f, 0.0f, 1.0f}, -{1.0f, 0.27058823529411763f, 0.0f, 1.0f}, -{1.0f, 0.27450980392156865f, 0.0f, 1.0f}, -{1.0f, 0.27843137254901962f, 0.0f, 1.0f}, -{1.0f, 0.28235294117647058f, 0.0f, 1.0f}, -{1.0f, 0.28627450980392155f, 0.0f, 1.0f}, -{1.0f, 0.29019607843137252f, 0.0f, 1.0f}, -{1.0f, 0.29411764705882354f, 0.0f, 1.0f}, -{1.0f, 0.29803921568627451f, 0.0f, 1.0f}, -{1.0f, 0.30196078431372547f, 0.0f, 1.0f}, -{1.0f, 0.30588235294117649f, 0.0f, 1.0f}, -{1.0f, 0.30980392156862746f, 0.0f, 1.0f}, -{1.0f, 0.31372549019607843f, 0.0f, 1.0f}, -{1.0f, 0.31764705882352939f, 0.0f, 1.0f}, -{1.0f, 0.32156862745098036f, 0.0f, 1.0f}, -{1.0f, 0.32549019607843138f, 0.0f, 1.0f}, -{1.0f, 0.32941176470588235f, 0.0f, 1.0f}, -{1.0f, 0.33333333333333331f, 0.0f, 1.0f}, -{1.0f, 0.33725490196078434f, 0.0f, 1.0f}, -{1.0f, 0.3411764705882353f, 0.0f, 1.0f}, -{1.0f, 0.34509803921568627f, 0.0f, 1.0f}, -{1.0f, 0.34901960784313724f, 0.0f, 1.0f}, -{1.0f, 0.3529411764705882f, 0.0f, 1.0f}, -{1.0f, 0.35686274509803922f, 0.0f, 1.0f}, -{1.0f, 0.36078431372549019f, 0.0f, 1.0f}, -{1.0f, 0.36470588235294116f, 0.0f, 1.0f}, -{1.0f, 0.36862745098039218f, 0.0f, 1.0f}, -{1.0f, 0.37254901960784315f, 0.0f, 1.0f}, -{1.0f, 0.37647058823529411f, 0.0f, 1.0f}, -{1.0f, 0.38039215686274508f, 0.0f, 1.0f}, -{1.0f, 0.38431372549019605f, 0.0f, 1.0f}, -{1.0f, 0.38823529411764707f, 0.0f, 1.0f}, -{1.0f, 0.39215686274509803f, 0.0f, 1.0f}, -{1.0f, 0.396078431372549f, 0.0f, 1.0f}, -{1.0f, 0.40000000000000002f, 0.0f, 1.0f}, -{1.0f, 0.40392156862745099f, 0.0f, 1.0f}, -{1.0f, 0.40784313725490196f, 0.0f, 1.0f}, -{1.0f, 0.41176470588235292f, 0.0f, 1.0f}, -{1.0f, 0.41568627450980389f, 0.0f, 1.0f}, -{1.0f, 0.41960784313725491f, 0.0f, 1.0f}, -{1.0f, 0.42352941176470588f, 0.0f, 1.0f}, -{1.0f, 0.42745098039215684f, 0.0f, 1.0f}, -{1.0f, 0.43137254901960786f, 0.0f, 1.0f}, -{1.0f, 0.43529411764705883f, 0.0f, 1.0f}, -{1.0f, 0.4392156862745098f, 0.0f, 1.0f}, -{1.0f, 0.44313725490196076f, 0.0f, 1.0f}, -{1.0f, 0.44705882352941173f, 0.0f, 1.0f}, -{1.0f, 0.45098039215686275f, 0.0f, 1.0f}, -{1.0f, 0.45490196078431372f, 0.0f, 1.0f}, -{1.0f, 0.45882352941176469f, 0.0f, 1.0f}, -{1.0f, 0.46274509803921571f, 0.0f, 1.0f}, -{1.0f, 0.46666666666666667f, 0.0f, 1.0f}, -{1.0f, 0.47058823529411764f, 0.0f, 1.0f}, -{1.0f, 0.47450980392156861f, 0.0f, 1.0f}, -{1.0f, 0.47843137254901957f, 0.0f, 1.0f}, -{1.0f, 0.4823529411764706f, 0.0f, 1.0f}, -{1.0f, 0.48627450980392156f, 0.0f, 1.0f}, -{1.0f, 0.49019607843137253f, 0.0f, 1.0f}, -{1.0f, 0.49411764705882355f, 0.0f, 1.0f}, -{1.0f, 0.49803921568627452f, 0.0f, 1.0f}, -{1.0f, 0.50196078431372548f, 0.0f, 1.0f}, -{1.0f, 0.50588235294117645f, 0.0f, 1.0f}, -{1.0f, 0.50980392156862742f, 0.0f, 1.0f}, -{1.0f, 0.51372549019607838f, 0.0f, 1.0f}, -{1.0f, 0.51764705882352935f, 0.0f, 1.0f}, -{1.0f, 0.52156862745098043f, 0.0f, 1.0f}, -{1.0f, 0.52549019607843139f, 0.0f, 1.0f}, -{1.0f, 0.52941176470588236f, 0.0f, 1.0f}, -{1.0f, 0.53333333333333333f, 0.0f, 1.0f}, -{1.0f, 0.53725490196078429f, 0.0f, 1.0f}, -{1.0f, 0.54117647058823526f, 0.0f, 1.0f}, -{1.0f, 0.54509803921568623f, 0.0f, 1.0f}, -{1.0f, 0.5490196078431373f, 0.0f, 1.0f}, -{1.0f, 0.55294117647058827f, 0.0f, 1.0f}, -{1.0f, 0.55686274509803924f, 0.0f, 1.0f}, -{1.0f, 0.5607843137254902f, 0.0f, 1.0f}, -{1.0f, 0.56470588235294117f, 0.0f, 1.0f}, -{1.0f, 0.56862745098039214f, 0.0f, 1.0f}, -{1.0f, 0.5725490196078431f, 0.0f, 1.0f}, -{1.0f, 0.57647058823529407f, 0.0f, 1.0f}, -{1.0f, 0.58039215686274503f, 0.0f, 1.0f}, -{1.0f, 0.58431372549019611f, 0.0f, 1.0f}, -{1.0f, 0.58823529411764708f, 0.0f, 1.0f}, -{1.0f, 0.59215686274509804f, 0.0f, 1.0f}, -{1.0f, 0.59607843137254901f, 0.0f, 1.0f}, -{1.0f, 0.59999999999999998f, 0.0f, 1.0f}, -{1.0f, 0.60392156862745094f, 0.0f, 1.0f}, -{1.0f, 0.60784313725490191f, 0.0f, 1.0f}, -{1.0f, 0.61176470588235299f, 0.0f, 1.0f}, -{1.0f, 0.61568627450980395f, 0.0f, 1.0f}, -{1.0f, 0.61960784313725492f, 0.0f, 1.0f}, -{1.0f, 0.62352941176470589f, 0.0f, 1.0f}, -{1.0f, 0.62745098039215685f, 0.0f, 1.0f}, -{1.0f, 0.63137254901960782f, 0.0f, 1.0f}, -{1.0f, 0.63529411764705879f, 0.0f, 1.0f}, -{1.0f, 0.63921568627450975f, 0.0f, 1.0f}, -{1.0f, 0.64313725490196072f, 0.0f, 1.0f}, -{1.0f, 0.6470588235294118f, 0.0f, 1.0f}, -{1.0f, 0.65098039215686276f, 0.0f, 1.0f}, -{1.0f, 0.65490196078431373f, 0.0f, 1.0f}, -{1.0f, 0.6588235294117647f, 0.0f, 1.0f}, -{1.0f, 0.66274509803921566f, 0.0f, 1.0f}, -{1.0f, 0.66666666666666663f, 0.0f, 1.0f}, -{1.0f, 0.6705882352941176f, 0.0f, 1.0f}, -{1.0f, 0.67450980392156867f, 0.0f, 1.0f}, -{1.0f, 0.67843137254901964f, 0.0f, 1.0f}, -{1.0f, 0.68235294117647061f, 0.0f, 1.0f}, -{1.0f, 0.68627450980392157f, 0.0f, 1.0f}, -{1.0f, 0.69019607843137254f, 0.0f, 1.0f}, -{1.0f, 0.69411764705882351f, 0.0f, 1.0f}, -{1.0f, 0.69803921568627447f, 0.0f, 1.0f}, -{1.0f, 0.70196078431372544f, 0.0f, 1.0f}, -{1.0f, 0.70588235294117641f, 0.0f, 1.0f}, -{1.0f, 0.70980392156862748f, 0.0f, 1.0f}, -{1.0f, 0.71372549019607845f, 0.0f, 1.0f}, -{1.0f, 0.71764705882352942f, 0.0f, 1.0f}, -{1.0f, 0.72156862745098038f, 0.0f, 1.0f}, -{1.0f, 0.72549019607843135f, 0.0f, 1.0f}, -{1.0f, 0.72941176470588232f, 0.0f, 1.0f}, -{1.0f, 0.73333333333333328f, 0.0f, 1.0f}, -{1.0f, 0.73725490196078436f, 0.0f, 1.0f}, -{1.0f, 0.74117647058823533f, 0.0f, 1.0f}, -{1.0f, 0.74509803921568629f, 0.0f, 1.0f}, -{1.0f, 0.74901960784313726f, 0.0f, 1.0f}, -{1.0f, 0.75294117647058822f, 0.0f, 1.0f}, -{1.0f, 0.75686274509803919f, 0.0f, 1.0f}, -{1.0f, 0.76078431372549016f, 0.0f, 1.0f}, -{1.0f, 0.76470588235294112f, 0.0f, 1.0f}, -{1.0f, 0.76862745098039209f, 0.0f, 1.0f}, -{1.0f, 0.77254901960784317f, 0.0f, 1.0f}, -{1.0f, 0.77647058823529413f, 0.0f, 1.0f}, -{1.0f, 0.7803921568627451f, 0.0f, 1.0f}, -{1.0f, 0.78431372549019607f, 0.0f, 1.0f}, -{1.0f, 0.78823529411764703f, 0.0f, 1.0f}, -{1.0f, 0.792156862745098f, 0.0f, 1.0f}, -{1.0f, 0.79607843137254897f, 0.0f, 1.0f}, -{1.0f, 0.80000000000000004f, 0.0f, 1.0f}, -{1.0f, 0.80392156862745101f, 0.0f, 1.0f}, -{1.0f, 0.80784313725490198f, 0.0f, 1.0f}, -{1.0f, 0.81176470588235294f, 0.0f, 1.0f}, -{1.0f, 0.81568627450980391f, 0.0f, 1.0f}, -{1.0f, 0.81960784313725488f, 0.0f, 1.0f}, -{1.0f, 0.82352941176470584f, 0.0f, 1.0f}, -{1.0f, 0.82745098039215681f, 0.0f, 1.0f}, -{1.0f, 0.83137254901960778f, 0.0f, 1.0f}, -{1.0f, 0.83529411764705885f, 0.0f, 1.0f}, -{1.0f, 0.83921568627450982f, 0.0f, 1.0f}, -{1.0f, 0.84313725490196079f, 0.0f, 1.0f}, -{1.0f, 0.84705882352941175f, 0.0f, 1.0f}, -{1.0f, 0.85098039215686272f, 0.0f, 1.0f}, -{1.0f, 0.85490196078431369f, 0.0f, 1.0f}, -{1.0f, 0.85882352941176465f, 0.0f, 1.0f}, -{1.0f, 0.86274509803921573f, 0.0f, 1.0f}, -{1.0f, 0.8666666666666667f, 0.0f, 1.0f}, -{1.0f, 0.87058823529411766f, 0.0f, 1.0f}, -{1.0f, 0.87450980392156863f, 0.0f, 1.0f}, -{1.0f, 0.8784313725490196f, 0.0f, 1.0f}, -{1.0f, 0.88235294117647056f, 0.0f, 1.0f}, -{1.0f, 0.88627450980392153f, 0.0f, 1.0f}, -{1.0f, 0.8901960784313725f, 0.0f, 1.0f}, -{1.0f, 0.89411764705882346f, 0.0f, 1.0f}, -{1.0f, 0.89803921568627454f, 0.0f, 1.0f}, -{1.0f, 0.90196078431372551f, 0.0f, 1.0f}, -{1.0f, 0.90588235294117647f, 0.0f, 1.0f}, -{1.0f, 0.90980392156862744f, 0.0f, 1.0f}, -{1.0f, 0.9137254901960784f, 0.0f, 1.0f}, -{1.0f, 0.91764705882352937f, 0.0f, 1.0f}, -{1.0f, 0.92156862745098034f, 0.0f, 1.0f}, -{1.0f, 0.92549019607843142f, 0.0f, 1.0f}, -{1.0f, 0.92941176470588238f, 0.0f, 1.0f}, -{1.0f, 0.93333333333333335f, 0.0f, 1.0f}, -{1.0f, 0.93725490196078431f, 0.0f, 1.0f}, -{1.0f, 0.94117647058823528f, 0.0f, 1.0f}, -{1.0f, 0.94509803921568625f, 0.0f, 1.0f}, -{1.0f, 0.94901960784313721f, 0.0f, 1.0f}, -{1.0f, 0.95294117647058818f, 0.0f, 1.0f}, -{1.0f, 0.95686274509803915f, 0.0f, 1.0f}, -{1.0f, 0.96078431372549022f, 0.0f, 1.0f}, -{1.0f, 0.96470588235294119f, 0.0f, 1.0f}, -{1.0f, 0.96862745098039216f, 0.0f, 1.0f}, -{1.0f, 0.97254901960784312f, 0.0f, 1.0f}, -{1.0f, 0.97647058823529409f, 0.0f, 1.0f}, -{1.0f, 0.98039215686274506f, 0.0f, 1.0f}, -{1.0f, 0.98431372549019602f, 0.0f, 1.0f}, -{1.0f, 0.9882352941176471f, 0.0f, 1.0f}, -{1.0f, 0.99215686274509807f, 0.0f, 1.0f}, -{1.0f, 0.99607843137254903f, 0.0f, 1.0f}, -{1.0f, 1.0f, 0.0f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential2/autumn.txt b/extern/tfn/colormaps/sequential2/autumn.txt deleted file mode 100644 index f6f48e3..0000000 --- a/extern/tfn/colormaps/sequential2/autumn.txt +++ /dev/null @@ -1,256 +0,0 @@ -(1.0, 0.0, 0.0, 1.0) -(1.0, 0.0039215686274509803, 0.0, 1.0) -(1.0, 0.0078431372549019607, 0.0, 1.0) -(1.0, 0.011764705882352941, 0.0, 1.0) -(1.0, 0.015686274509803921, 0.0, 1.0) -(1.0, 0.019607843137254902, 0.0, 1.0) -(1.0, 0.023529411764705882, 0.0, 1.0) -(1.0, 0.027450980392156862, 0.0, 1.0) -(1.0, 0.031372549019607843, 0.0, 1.0) -(1.0, 0.035294117647058823, 0.0, 1.0) -(1.0, 0.039215686274509803, 0.0, 1.0) -(1.0, 0.043137254901960784, 0.0, 1.0) -(1.0, 0.047058823529411764, 0.0, 1.0) -(1.0, 0.050980392156862744, 0.0, 1.0) -(1.0, 0.054901960784313725, 0.0, 1.0) -(1.0, 0.058823529411764705, 0.0, 1.0) -(1.0, 0.062745098039215685, 0.0, 1.0) -(1.0, 0.066666666666666666, 0.0, 1.0) -(1.0, 0.070588235294117646, 0.0, 1.0) -(1.0, 0.074509803921568626, 0.0, 1.0) -(1.0, 0.078431372549019607, 0.0, 1.0) -(1.0, 0.082352941176470587, 0.0, 1.0) -(1.0, 0.086274509803921567, 0.0, 1.0) -(1.0, 0.090196078431372548, 0.0, 1.0) -(1.0, 0.094117647058823528, 0.0, 1.0) -(1.0, 0.098039215686274508, 0.0, 1.0) -(1.0, 0.10196078431372549, 0.0, 1.0) -(1.0, 0.10588235294117647, 0.0, 1.0) -(1.0, 0.10980392156862745, 0.0, 1.0) -(1.0, 0.11372549019607843, 0.0, 1.0) -(1.0, 0.11764705882352941, 0.0, 1.0) -(1.0, 0.12156862745098039, 0.0, 1.0) -(1.0, 0.12549019607843137, 0.0, 1.0) -(1.0, 0.12941176470588234, 0.0, 1.0) -(1.0, 0.13333333333333333, 0.0, 1.0) -(1.0, 0.13725490196078433, 0.0, 1.0) -(1.0, 0.14117647058823529, 0.0, 1.0) -(1.0, 0.14509803921568626, 0.0, 1.0) -(1.0, 0.14901960784313725, 0.0, 1.0) -(1.0, 0.15294117647058825, 0.0, 1.0) -(1.0, 0.15686274509803921, 0.0, 1.0) -(1.0, 0.16078431372549018, 0.0, 1.0) -(1.0, 0.16470588235294117, 0.0, 1.0) -(1.0, 0.16862745098039217, 0.0, 1.0) -(1.0, 0.17254901960784313, 0.0, 1.0) -(1.0, 0.1764705882352941, 0.0, 1.0) -(1.0, 0.1803921568627451, 0.0, 1.0) -(1.0, 0.18431372549019609, 0.0, 1.0) -(1.0, 0.18823529411764706, 0.0, 1.0) -(1.0, 0.19215686274509802, 0.0, 1.0) -(1.0, 0.19607843137254902, 0.0, 1.0) -(1.0, 0.20000000000000001, 0.0, 1.0) -(1.0, 0.20392156862745098, 0.0, 1.0) -(1.0, 0.20784313725490194, 0.0, 1.0) -(1.0, 0.21176470588235294, 0.0, 1.0) -(1.0, 0.21568627450980393, 0.0, 1.0) -(1.0, 0.2196078431372549, 0.0, 1.0) -(1.0, 0.22352941176470587, 0.0, 1.0) -(1.0, 0.22745098039215686, 0.0, 1.0) -(1.0, 0.23137254901960785, 0.0, 1.0) -(1.0, 0.23529411764705882, 0.0, 1.0) -(1.0, 0.23921568627450979, 0.0, 1.0) -(1.0, 0.24313725490196078, 0.0, 1.0) -(1.0, 0.24705882352941178, 0.0, 1.0) -(1.0, 0.25098039215686274, 0.0, 1.0) -(1.0, 0.25490196078431371, 0.0, 1.0) -(1.0, 0.25882352941176467, 0.0, 1.0) -(1.0, 0.2627450980392157, 0.0, 1.0) -(1.0, 0.26666666666666666, 0.0, 1.0) -(1.0, 0.27058823529411763, 0.0, 1.0) -(1.0, 0.27450980392156865, 0.0, 1.0) -(1.0, 0.27843137254901962, 0.0, 1.0) -(1.0, 0.28235294117647058, 0.0, 1.0) -(1.0, 0.28627450980392155, 0.0, 1.0) -(1.0, 0.29019607843137252, 0.0, 1.0) -(1.0, 0.29411764705882354, 0.0, 1.0) -(1.0, 0.29803921568627451, 0.0, 1.0) -(1.0, 0.30196078431372547, 0.0, 1.0) -(1.0, 0.30588235294117649, 0.0, 1.0) -(1.0, 0.30980392156862746, 0.0, 1.0) -(1.0, 0.31372549019607843, 0.0, 1.0) -(1.0, 0.31764705882352939, 0.0, 1.0) -(1.0, 0.32156862745098036, 0.0, 1.0) -(1.0, 0.32549019607843138, 0.0, 1.0) -(1.0, 0.32941176470588235, 0.0, 1.0) -(1.0, 0.33333333333333331, 0.0, 1.0) -(1.0, 0.33725490196078434, 0.0, 1.0) -(1.0, 0.3411764705882353, 0.0, 1.0) -(1.0, 0.34509803921568627, 0.0, 1.0) -(1.0, 0.34901960784313724, 0.0, 1.0) -(1.0, 0.3529411764705882, 0.0, 1.0) -(1.0, 0.35686274509803922, 0.0, 1.0) -(1.0, 0.36078431372549019, 0.0, 1.0) -(1.0, 0.36470588235294116, 0.0, 1.0) -(1.0, 0.36862745098039218, 0.0, 1.0) -(1.0, 0.37254901960784315, 0.0, 1.0) -(1.0, 0.37647058823529411, 0.0, 1.0) -(1.0, 0.38039215686274508, 0.0, 1.0) -(1.0, 0.38431372549019605, 0.0, 1.0) -(1.0, 0.38823529411764707, 0.0, 1.0) -(1.0, 0.39215686274509803, 0.0, 1.0) -(1.0, 0.396078431372549, 0.0, 1.0) -(1.0, 0.40000000000000002, 0.0, 1.0) -(1.0, 0.40392156862745099, 0.0, 1.0) -(1.0, 0.40784313725490196, 0.0, 1.0) -(1.0, 0.41176470588235292, 0.0, 1.0) -(1.0, 0.41568627450980389, 0.0, 1.0) -(1.0, 0.41960784313725491, 0.0, 1.0) -(1.0, 0.42352941176470588, 0.0, 1.0) -(1.0, 0.42745098039215684, 0.0, 1.0) -(1.0, 0.43137254901960786, 0.0, 1.0) -(1.0, 0.43529411764705883, 0.0, 1.0) -(1.0, 0.4392156862745098, 0.0, 1.0) -(1.0, 0.44313725490196076, 0.0, 1.0) -(1.0, 0.44705882352941173, 0.0, 1.0) -(1.0, 0.45098039215686275, 0.0, 1.0) -(1.0, 0.45490196078431372, 0.0, 1.0) -(1.0, 0.45882352941176469, 0.0, 1.0) -(1.0, 0.46274509803921571, 0.0, 1.0) -(1.0, 0.46666666666666667, 0.0, 1.0) -(1.0, 0.47058823529411764, 0.0, 1.0) -(1.0, 0.47450980392156861, 0.0, 1.0) -(1.0, 0.47843137254901957, 0.0, 1.0) -(1.0, 0.4823529411764706, 0.0, 1.0) -(1.0, 0.48627450980392156, 0.0, 1.0) -(1.0, 0.49019607843137253, 0.0, 1.0) -(1.0, 0.49411764705882355, 0.0, 1.0) -(1.0, 0.49803921568627452, 0.0, 1.0) -(1.0, 0.50196078431372548, 0.0, 1.0) -(1.0, 0.50588235294117645, 0.0, 1.0) -(1.0, 0.50980392156862742, 0.0, 1.0) -(1.0, 0.51372549019607838, 0.0, 1.0) -(1.0, 0.51764705882352935, 0.0, 1.0) -(1.0, 0.52156862745098043, 0.0, 1.0) -(1.0, 0.52549019607843139, 0.0, 1.0) -(1.0, 0.52941176470588236, 0.0, 1.0) -(1.0, 0.53333333333333333, 0.0, 1.0) -(1.0, 0.53725490196078429, 0.0, 1.0) -(1.0, 0.54117647058823526, 0.0, 1.0) -(1.0, 0.54509803921568623, 0.0, 1.0) -(1.0, 0.5490196078431373, 0.0, 1.0) -(1.0, 0.55294117647058827, 0.0, 1.0) -(1.0, 0.55686274509803924, 0.0, 1.0) -(1.0, 0.5607843137254902, 0.0, 1.0) -(1.0, 0.56470588235294117, 0.0, 1.0) -(1.0, 0.56862745098039214, 0.0, 1.0) -(1.0, 0.5725490196078431, 0.0, 1.0) -(1.0, 0.57647058823529407, 0.0, 1.0) -(1.0, 0.58039215686274503, 0.0, 1.0) -(1.0, 0.58431372549019611, 0.0, 1.0) -(1.0, 0.58823529411764708, 0.0, 1.0) -(1.0, 0.59215686274509804, 0.0, 1.0) -(1.0, 0.59607843137254901, 0.0, 1.0) -(1.0, 0.59999999999999998, 0.0, 1.0) -(1.0, 0.60392156862745094, 0.0, 1.0) -(1.0, 0.60784313725490191, 0.0, 1.0) -(1.0, 0.61176470588235299, 0.0, 1.0) -(1.0, 0.61568627450980395, 0.0, 1.0) -(1.0, 0.61960784313725492, 0.0, 1.0) -(1.0, 0.62352941176470589, 0.0, 1.0) -(1.0, 0.62745098039215685, 0.0, 1.0) -(1.0, 0.63137254901960782, 0.0, 1.0) -(1.0, 0.63529411764705879, 0.0, 1.0) -(1.0, 0.63921568627450975, 0.0, 1.0) -(1.0, 0.64313725490196072, 0.0, 1.0) -(1.0, 0.6470588235294118, 0.0, 1.0) -(1.0, 0.65098039215686276, 0.0, 1.0) -(1.0, 0.65490196078431373, 0.0, 1.0) -(1.0, 0.6588235294117647, 0.0, 1.0) -(1.0, 0.66274509803921566, 0.0, 1.0) -(1.0, 0.66666666666666663, 0.0, 1.0) -(1.0, 0.6705882352941176, 0.0, 1.0) -(1.0, 0.67450980392156867, 0.0, 1.0) -(1.0, 0.67843137254901964, 0.0, 1.0) -(1.0, 0.68235294117647061, 0.0, 1.0) -(1.0, 0.68627450980392157, 0.0, 1.0) -(1.0, 0.69019607843137254, 0.0, 1.0) -(1.0, 0.69411764705882351, 0.0, 1.0) -(1.0, 0.69803921568627447, 0.0, 1.0) -(1.0, 0.70196078431372544, 0.0, 1.0) -(1.0, 0.70588235294117641, 0.0, 1.0) -(1.0, 0.70980392156862748, 0.0, 1.0) -(1.0, 0.71372549019607845, 0.0, 1.0) -(1.0, 0.71764705882352942, 0.0, 1.0) -(1.0, 0.72156862745098038, 0.0, 1.0) -(1.0, 0.72549019607843135, 0.0, 1.0) -(1.0, 0.72941176470588232, 0.0, 1.0) -(1.0, 0.73333333333333328, 0.0, 1.0) -(1.0, 0.73725490196078436, 0.0, 1.0) -(1.0, 0.74117647058823533, 0.0, 1.0) -(1.0, 0.74509803921568629, 0.0, 1.0) -(1.0, 0.74901960784313726, 0.0, 1.0) -(1.0, 0.75294117647058822, 0.0, 1.0) -(1.0, 0.75686274509803919, 0.0, 1.0) -(1.0, 0.76078431372549016, 0.0, 1.0) -(1.0, 0.76470588235294112, 0.0, 1.0) -(1.0, 0.76862745098039209, 0.0, 1.0) -(1.0, 0.77254901960784317, 0.0, 1.0) -(1.0, 0.77647058823529413, 0.0, 1.0) -(1.0, 0.7803921568627451, 0.0, 1.0) -(1.0, 0.78431372549019607, 0.0, 1.0) -(1.0, 0.78823529411764703, 0.0, 1.0) -(1.0, 0.792156862745098, 0.0, 1.0) -(1.0, 0.79607843137254897, 0.0, 1.0) -(1.0, 0.80000000000000004, 0.0, 1.0) -(1.0, 0.80392156862745101, 0.0, 1.0) -(1.0, 0.80784313725490198, 0.0, 1.0) -(1.0, 0.81176470588235294, 0.0, 1.0) -(1.0, 0.81568627450980391, 0.0, 1.0) -(1.0, 0.81960784313725488, 0.0, 1.0) -(1.0, 0.82352941176470584, 0.0, 1.0) -(1.0, 0.82745098039215681, 0.0, 1.0) -(1.0, 0.83137254901960778, 0.0, 1.0) -(1.0, 0.83529411764705885, 0.0, 1.0) -(1.0, 0.83921568627450982, 0.0, 1.0) -(1.0, 0.84313725490196079, 0.0, 1.0) -(1.0, 0.84705882352941175, 0.0, 1.0) -(1.0, 0.85098039215686272, 0.0, 1.0) -(1.0, 0.85490196078431369, 0.0, 1.0) -(1.0, 0.85882352941176465, 0.0, 1.0) -(1.0, 0.86274509803921573, 0.0, 1.0) -(1.0, 0.8666666666666667, 0.0, 1.0) -(1.0, 0.87058823529411766, 0.0, 1.0) -(1.0, 0.87450980392156863, 0.0, 1.0) -(1.0, 0.8784313725490196, 0.0, 1.0) -(1.0, 0.88235294117647056, 0.0, 1.0) -(1.0, 0.88627450980392153, 0.0, 1.0) -(1.0, 0.8901960784313725, 0.0, 1.0) -(1.0, 0.89411764705882346, 0.0, 1.0) -(1.0, 0.89803921568627454, 0.0, 1.0) -(1.0, 0.90196078431372551, 0.0, 1.0) -(1.0, 0.90588235294117647, 0.0, 1.0) -(1.0, 0.90980392156862744, 0.0, 1.0) -(1.0, 0.9137254901960784, 0.0, 1.0) -(1.0, 0.91764705882352937, 0.0, 1.0) -(1.0, 0.92156862745098034, 0.0, 1.0) -(1.0, 0.92549019607843142, 0.0, 1.0) -(1.0, 0.92941176470588238, 0.0, 1.0) -(1.0, 0.93333333333333335, 0.0, 1.0) -(1.0, 0.93725490196078431, 0.0, 1.0) -(1.0, 0.94117647058823528, 0.0, 1.0) -(1.0, 0.94509803921568625, 0.0, 1.0) -(1.0, 0.94901960784313721, 0.0, 1.0) -(1.0, 0.95294117647058818, 0.0, 1.0) -(1.0, 0.95686274509803915, 0.0, 1.0) -(1.0, 0.96078431372549022, 0.0, 1.0) -(1.0, 0.96470588235294119, 0.0, 1.0) -(1.0, 0.96862745098039216, 0.0, 1.0) -(1.0, 0.97254901960784312, 0.0, 1.0) -(1.0, 0.97647058823529409, 0.0, 1.0) -(1.0, 0.98039215686274506, 0.0, 1.0) -(1.0, 0.98431372549019602, 0.0, 1.0) -(1.0, 0.9882352941176471, 0.0, 1.0) -(1.0, 0.99215686274509807, 0.0, 1.0) -(1.0, 0.99607843137254903, 0.0, 1.0) -(1.0, 1.0, 0.0, 1.0) diff --git a/extern/tfn/colormaps/sequential2/binary.cpp b/extern/tfn/colormaps/sequential2/binary.cpp deleted file mode 100644 index 36bf934..0000000 --- a/extern/tfn/colormaps/sequential2/binary.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential2_binary; -} -const std::vector colormap::data_sequential2_binary = /* NOLINT(cert-err58-cpp) */ -{ -{1.0f, 1.0f, 1.0f, 1.0f}, -{0.99607843137254903f, 0.99607843137254903f, 0.99607843137254903f, 1.0f}, -{0.99215686274509807f, 0.99215686274509807f, 0.99215686274509807f, 1.0f}, -{0.9882352941176471f, 0.9882352941176471f, 0.9882352941176471f, 1.0f}, -{0.98431372549019613f, 0.98431372549019613f, 0.98431372549019613f, 1.0f}, -{0.98039215686274506f, 0.98039215686274506f, 0.98039215686274506f, 1.0f}, -{0.97647058823529409f, 0.97647058823529409f, 0.97647058823529409f, 1.0f}, -{0.97254901960784312f, 0.97254901960784312f, 0.97254901960784312f, 1.0f}, -{0.96862745098039216f, 0.96862745098039216f, 0.96862745098039216f, 1.0f}, -{0.96470588235294119f, 0.96470588235294119f, 0.96470588235294119f, 1.0f}, -{0.96078431372549022f, 0.96078431372549022f, 0.96078431372549022f, 1.0f}, -{0.95686274509803926f, 0.95686274509803926f, 0.95686274509803926f, 1.0f}, -{0.95294117647058818f, 0.95294117647058818f, 0.95294117647058818f, 1.0f}, -{0.94901960784313721f, 0.94901960784313721f, 0.94901960784313721f, 1.0f}, -{0.94509803921568625f, 0.94509803921568625f, 0.94509803921568625f, 1.0f}, -{0.94117647058823528f, 0.94117647058823528f, 0.94117647058823528f, 1.0f}, -{0.93725490196078431f, 0.93725490196078431f, 0.93725490196078431f, 1.0f}, -{0.93333333333333335f, 0.93333333333333335f, 0.93333333333333335f, 1.0f}, -{0.92941176470588238f, 0.92941176470588238f, 0.92941176470588238f, 1.0f}, -{0.92549019607843142f, 0.92549019607843142f, 0.92549019607843142f, 1.0f}, -{0.92156862745098045f, 0.92156862745098045f, 0.92156862745098045f, 1.0f}, -{0.91764705882352937f, 0.91764705882352937f, 0.91764705882352937f, 1.0f}, -{0.9137254901960784f, 0.9137254901960784f, 0.9137254901960784f, 1.0f}, -{0.90980392156862744f, 0.90980392156862744f, 0.90980392156862744f, 1.0f}, -{0.90588235294117647f, 0.90588235294117647f, 0.90588235294117647f, 1.0f}, -{0.90196078431372551f, 0.90196078431372551f, 0.90196078431372551f, 1.0f}, -{0.89803921568627454f, 0.89803921568627454f, 0.89803921568627454f, 1.0f}, -{0.89411764705882357f, 0.89411764705882357f, 0.89411764705882357f, 1.0f}, -{0.8901960784313725f, 0.8901960784313725f, 0.8901960784313725f, 1.0f}, -{0.88627450980392153f, 0.88627450980392153f, 0.88627450980392153f, 1.0f}, -{0.88235294117647056f, 0.88235294117647056f, 0.88235294117647056f, 1.0f}, -{0.8784313725490196f, 0.8784313725490196f, 0.8784313725490196f, 1.0f}, -{0.87450980392156863f, 0.87450980392156863f, 0.87450980392156863f, 1.0f}, -{0.87058823529411766f, 0.87058823529411766f, 0.87058823529411766f, 1.0f}, -{0.8666666666666667f, 0.8666666666666667f, 0.8666666666666667f, 1.0f}, -{0.86274509803921573f, 0.86274509803921573f, 0.86274509803921573f, 1.0f}, -{0.85882352941176476f, 0.85882352941176476f, 0.85882352941176476f, 1.0f}, -{0.8549019607843138f, 0.8549019607843138f, 0.8549019607843138f, 1.0f}, -{0.85098039215686272f, 0.85098039215686272f, 0.85098039215686272f, 1.0f}, -{0.84705882352941175f, 0.84705882352941175f, 0.84705882352941175f, 1.0f}, -{0.84313725490196079f, 0.84313725490196079f, 0.84313725490196079f, 1.0f}, -{0.83921568627450982f, 0.83921568627450982f, 0.83921568627450982f, 1.0f}, -{0.83529411764705885f, 0.83529411764705885f, 0.83529411764705885f, 1.0f}, -{0.83137254901960778f, 0.83137254901960778f, 0.83137254901960778f, 1.0f}, -{0.82745098039215681f, 0.82745098039215681f, 0.82745098039215681f, 1.0f}, -{0.82352941176470584f, 0.82352941176470584f, 0.82352941176470584f, 1.0f}, -{0.81960784313725488f, 0.81960784313725488f, 0.81960784313725488f, 1.0f}, -{0.81568627450980391f, 0.81568627450980391f, 0.81568627450980391f, 1.0f}, -{0.81176470588235294f, 0.81176470588235294f, 0.81176470588235294f, 1.0f}, -{0.80784313725490198f, 0.80784313725490198f, 0.80784313725490198f, 1.0f}, -{0.80392156862745101f, 0.80392156862745101f, 0.80392156862745101f, 1.0f}, -{0.80000000000000004f, 0.80000000000000004f, 0.80000000000000004f, 1.0f}, -{0.79607843137254908f, 0.79607843137254908f, 0.79607843137254908f, 1.0f}, -{0.79215686274509811f, 0.79215686274509811f, 0.79215686274509811f, 1.0f}, -{0.78823529411764703f, 0.78823529411764703f, 0.78823529411764703f, 1.0f}, -{0.78431372549019607f, 0.78431372549019607f, 0.78431372549019607f, 1.0f}, -{0.7803921568627451f, 0.7803921568627451f, 0.7803921568627451f, 1.0f}, -{0.77647058823529413f, 0.77647058823529413f, 0.77647058823529413f, 1.0f}, -{0.77254901960784317f, 0.77254901960784317f, 0.77254901960784317f, 1.0f}, -{0.76862745098039209f, 0.76862745098039209f, 0.76862745098039209f, 1.0f}, -{0.76470588235294112f, 0.76470588235294112f, 0.76470588235294112f, 1.0f}, -{0.76078431372549016f, 0.76078431372549016f, 0.76078431372549016f, 1.0f}, -{0.75686274509803919f, 0.75686274509803919f, 0.75686274509803919f, 1.0f}, -{0.75294117647058822f, 0.75294117647058822f, 0.75294117647058822f, 1.0f}, -{0.74901960784313726f, 0.74901960784313726f, 0.74901960784313726f, 1.0f}, -{0.74509803921568629f, 0.74509803921568629f, 0.74509803921568629f, 1.0f}, -{0.74117647058823533f, 0.74117647058823533f, 0.74117647058823533f, 1.0f}, -{0.73725490196078436f, 0.73725490196078436f, 0.73725490196078436f, 1.0f}, -{0.73333333333333339f, 0.73333333333333339f, 0.73333333333333339f, 1.0f}, -{0.72941176470588243f, 0.72941176470588243f, 0.72941176470588243f, 1.0f}, -{0.72549019607843135f, 0.72549019607843135f, 0.72549019607843135f, 1.0f}, -{0.72156862745098038f, 0.72156862745098038f, 0.72156862745098038f, 1.0f}, -{0.71764705882352942f, 0.71764705882352942f, 0.71764705882352942f, 1.0f}, -{0.71372549019607845f, 0.71372549019607845f, 0.71372549019607845f, 1.0f}, -{0.70980392156862748f, 0.70980392156862748f, 0.70980392156862748f, 1.0f}, -{0.70588235294117641f, 0.70588235294117641f, 0.70588235294117641f, 1.0f}, -{0.70196078431372544f, 0.70196078431372544f, 0.70196078431372544f, 1.0f}, -{0.69803921568627447f, 0.69803921568627447f, 0.69803921568627447f, 1.0f}, -{0.69411764705882351f, 0.69411764705882351f, 0.69411764705882351f, 1.0f}, -{0.69019607843137254f, 0.69019607843137254f, 0.69019607843137254f, 1.0f}, -{0.68627450980392157f, 0.68627450980392157f, 0.68627450980392157f, 1.0f}, -{0.68235294117647061f, 0.68235294117647061f, 0.68235294117647061f, 1.0f}, -{0.67843137254901964f, 0.67843137254901964f, 0.67843137254901964f, 1.0f}, -{0.67450980392156867f, 0.67450980392156867f, 0.67450980392156867f, 1.0f}, -{0.67058823529411771f, 0.67058823529411771f, 0.67058823529411771f, 1.0f}, -{0.66666666666666674f, 0.66666666666666674f, 0.66666666666666674f, 1.0f}, -{0.66274509803921566f, 0.66274509803921566f, 0.66274509803921566f, 1.0f}, -{0.6588235294117647f, 0.6588235294117647f, 0.6588235294117647f, 1.0f}, -{0.65490196078431373f, 0.65490196078431373f, 0.65490196078431373f, 1.0f}, -{0.65098039215686276f, 0.65098039215686276f, 0.65098039215686276f, 1.0f}, -{0.6470588235294118f, 0.6470588235294118f, 0.6470588235294118f, 1.0f}, -{0.64313725490196072f, 0.64313725490196072f, 0.64313725490196072f, 1.0f}, -{0.63921568627450975f, 0.63921568627450975f, 0.63921568627450975f, 1.0f}, -{0.63529411764705879f, 0.63529411764705879f, 0.63529411764705879f, 1.0f}, -{0.63137254901960782f, 0.63137254901960782f, 0.63137254901960782f, 1.0f}, -{0.62745098039215685f, 0.62745098039215685f, 0.62745098039215685f, 1.0f}, -{0.62352941176470589f, 0.62352941176470589f, 0.62352941176470589f, 1.0f}, -{0.61960784313725492f, 0.61960784313725492f, 0.61960784313725492f, 1.0f}, -{0.61568627450980395f, 0.61568627450980395f, 0.61568627450980395f, 1.0f}, -{0.61176470588235299f, 0.61176470588235299f, 0.61176470588235299f, 1.0f}, -{0.60784313725490202f, 0.60784313725490202f, 0.60784313725490202f, 1.0f}, -{0.60392156862745106f, 0.60392156862745106f, 0.60392156862745106f, 1.0f}, -{0.59999999999999998f, 0.59999999999999998f, 0.59999999999999998f, 1.0f}, -{0.59607843137254901f, 0.59607843137254901f, 0.59607843137254901f, 1.0f}, -{0.59215686274509804f, 0.59215686274509804f, 0.59215686274509804f, 1.0f}, -{0.58823529411764708f, 0.58823529411764708f, 0.58823529411764708f, 1.0f}, -{0.58431372549019611f, 0.58431372549019611f, 0.58431372549019611f, 1.0f}, -{0.58039215686274503f, 0.58039215686274503f, 0.58039215686274503f, 1.0f}, -{0.57647058823529407f, 0.57647058823529407f, 0.57647058823529407f, 1.0f}, -{0.5725490196078431f, 0.5725490196078431f, 0.5725490196078431f, 1.0f}, -{0.56862745098039214f, 0.56862745098039214f, 0.56862745098039214f, 1.0f}, -{0.56470588235294117f, 0.56470588235294117f, 0.56470588235294117f, 1.0f}, -{0.5607843137254902f, 0.5607843137254902f, 0.5607843137254902f, 1.0f}, -{0.55686274509803924f, 0.55686274509803924f, 0.55686274509803924f, 1.0f}, -{0.55294117647058827f, 0.55294117647058827f, 0.55294117647058827f, 1.0f}, -{0.5490196078431373f, 0.5490196078431373f, 0.5490196078431373f, 1.0f}, -{0.54509803921568634f, 0.54509803921568634f, 0.54509803921568634f, 1.0f}, -{0.54117647058823537f, 0.54117647058823537f, 0.54117647058823537f, 1.0f}, -{0.53725490196078429f, 0.53725490196078429f, 0.53725490196078429f, 1.0f}, -{0.53333333333333333f, 0.53333333333333333f, 0.53333333333333333f, 1.0f}, -{0.52941176470588236f, 0.52941176470588236f, 0.52941176470588236f, 1.0f}, -{0.52549019607843139f, 0.52549019607843139f, 0.52549019607843139f, 1.0f}, -{0.52156862745098043f, 0.52156862745098043f, 0.52156862745098043f, 1.0f}, -{0.51764705882352935f, 0.51764705882352935f, 0.51764705882352935f, 1.0f}, -{0.51372549019607838f, 0.51372549019607838f, 0.51372549019607838f, 1.0f}, -{0.50980392156862742f, 0.50980392156862742f, 0.50980392156862742f, 1.0f}, -{0.50588235294117645f, 0.50588235294117645f, 0.50588235294117645f, 1.0f}, -{0.50196078431372548f, 0.50196078431372548f, 0.50196078431372548f, 1.0f}, -{0.49803921568627452f, 0.49803921568627452f, 0.49803921568627452f, 1.0f}, -{0.49411764705882355f, 0.49411764705882355f, 0.49411764705882355f, 1.0f}, -{0.49019607843137258f, 0.49019607843137258f, 0.49019607843137258f, 1.0f}, -{0.48627450980392162f, 0.48627450980392162f, 0.48627450980392162f, 1.0f}, -{0.48235294117647065f, 0.48235294117647065f, 0.48235294117647065f, 1.0f}, -{0.47843137254901957f, 0.47843137254901957f, 0.47843137254901957f, 1.0f}, -{0.47450980392156861f, 0.47450980392156861f, 0.47450980392156861f, 1.0f}, -{0.47058823529411764f, 0.47058823529411764f, 0.47058823529411764f, 1.0f}, -{0.46666666666666667f, 0.46666666666666667f, 0.46666666666666667f, 1.0f}, -{0.46274509803921571f, 0.46274509803921571f, 0.46274509803921571f, 1.0f}, -{0.45882352941176474f, 0.45882352941176474f, 0.45882352941176474f, 1.0f}, -{0.45490196078431377f, 0.45490196078431377f, 0.45490196078431377f, 1.0f}, -{0.4509803921568627f, 0.4509803921568627f, 0.4509803921568627f, 1.0f}, -{0.44705882352941173f, 0.44705882352941173f, 0.44705882352941173f, 1.0f}, -{0.44313725490196076f, 0.44313725490196076f, 0.44313725490196076f, 1.0f}, -{0.4392156862745098f, 0.4392156862745098f, 0.4392156862745098f, 1.0f}, -{0.43529411764705883f, 0.43529411764705883f, 0.43529411764705883f, 1.0f}, -{0.43137254901960786f, 0.43137254901960786f, 0.43137254901960786f, 1.0f}, -{0.4274509803921569f, 0.4274509803921569f, 0.4274509803921569f, 1.0f}, -{0.42352941176470593f, 0.42352941176470593f, 0.42352941176470593f, 1.0f}, -{0.41960784313725497f, 0.41960784313725497f, 0.41960784313725497f, 1.0f}, -{0.41568627450980389f, 0.41568627450980389f, 0.41568627450980389f, 1.0f}, -{0.41176470588235292f, 0.41176470588235292f, 0.41176470588235292f, 1.0f}, -{0.40784313725490196f, 0.40784313725490196f, 0.40784313725490196f, 1.0f}, -{0.40392156862745099f, 0.40392156862745099f, 0.40392156862745099f, 1.0f}, -{0.40000000000000002f, 0.40000000000000002f, 0.40000000000000002f, 1.0f}, -{0.39607843137254906f, 0.39607843137254906f, 0.39607843137254906f, 1.0f}, -{0.39215686274509809f, 0.39215686274509809f, 0.39215686274509809f, 1.0f}, -{0.38823529411764701f, 0.38823529411764701f, 0.38823529411764701f, 1.0f}, -{0.38431372549019605f, 0.38431372549019605f, 0.38431372549019605f, 1.0f}, -{0.38039215686274508f, 0.38039215686274508f, 0.38039215686274508f, 1.0f}, -{0.37647058823529411f, 0.37647058823529411f, 0.37647058823529411f, 1.0f}, -{0.37254901960784315f, 0.37254901960784315f, 0.37254901960784315f, 1.0f}, -{0.36862745098039218f, 0.36862745098039218f, 0.36862745098039218f, 1.0f}, -{0.36470588235294121f, 0.36470588235294121f, 0.36470588235294121f, 1.0f}, -{0.36078431372549025f, 0.36078431372549025f, 0.36078431372549025f, 1.0f}, -{0.35686274509803928f, 0.35686274509803928f, 0.35686274509803928f, 1.0f}, -{0.3529411764705882f, 0.3529411764705882f, 0.3529411764705882f, 1.0f}, -{0.34901960784313724f, 0.34901960784313724f, 0.34901960784313724f, 1.0f}, -{0.34509803921568627f, 0.34509803921568627f, 0.34509803921568627f, 1.0f}, -{0.3411764705882353f, 0.3411764705882353f, 0.3411764705882353f, 1.0f}, -{0.33725490196078434f, 0.33725490196078434f, 0.33725490196078434f, 1.0f}, -{0.33333333333333337f, 0.33333333333333337f, 0.33333333333333337f, 1.0f}, -{0.3294117647058824f, 0.3294117647058824f, 0.3294117647058824f, 1.0f}, -{0.32549019607843133f, 0.32549019607843133f, 0.32549019607843133f, 1.0f}, -{0.32156862745098036f, 0.32156862745098036f, 0.32156862745098036f, 1.0f}, -{0.31764705882352939f, 0.31764705882352939f, 0.31764705882352939f, 1.0f}, -{0.31372549019607843f, 0.31372549019607843f, 0.31372549019607843f, 1.0f}, -{0.30980392156862746f, 0.30980392156862746f, 0.30980392156862746f, 1.0f}, -{0.30588235294117649f, 0.30588235294117649f, 0.30588235294117649f, 1.0f}, -{0.30196078431372553f, 0.30196078431372553f, 0.30196078431372553f, 1.0f}, -{0.29803921568627456f, 0.29803921568627456f, 0.29803921568627456f, 1.0f}, -{0.29411764705882359f, 0.29411764705882359f, 0.29411764705882359f, 1.0f}, -{0.29019607843137252f, 0.29019607843137252f, 0.29019607843137252f, 1.0f}, -{0.28627450980392155f, 0.28627450980392155f, 0.28627450980392155f, 1.0f}, -{0.28235294117647058f, 0.28235294117647058f, 0.28235294117647058f, 1.0f}, -{0.27843137254901962f, 0.27843137254901962f, 0.27843137254901962f, 1.0f}, -{0.27450980392156865f, 0.27450980392156865f, 0.27450980392156865f, 1.0f}, -{0.27058823529411768f, 0.27058823529411768f, 0.27058823529411768f, 1.0f}, -{0.26666666666666672f, 0.26666666666666672f, 0.26666666666666672f, 1.0f}, -{0.26274509803921564f, 0.26274509803921564f, 0.26274509803921564f, 1.0f}, -{0.25882352941176467f, 0.25882352941176467f, 0.25882352941176467f, 1.0f}, -{0.25490196078431371f, 0.25490196078431371f, 0.25490196078431371f, 1.0f}, -{0.25098039215686274f, 0.25098039215686274f, 0.25098039215686274f, 1.0f}, -{0.24705882352941178f, 0.24705882352941178f, 0.24705882352941178f, 1.0f}, -{0.24313725490196081f, 0.24313725490196081f, 0.24313725490196081f, 1.0f}, -{0.23921568627450984f, 0.23921568627450984f, 0.23921568627450984f, 1.0f}, -{0.23529411764705888f, 0.23529411764705888f, 0.23529411764705888f, 1.0f}, -{0.23137254901960791f, 0.23137254901960791f, 0.23137254901960791f, 1.0f}, -{0.22745098039215683f, 0.22745098039215683f, 0.22745098039215683f, 1.0f}, -{0.22352941176470587f, 0.22352941176470587f, 0.22352941176470587f, 1.0f}, -{0.2196078431372549f, 0.2196078431372549f, 0.2196078431372549f, 1.0f}, -{0.21568627450980393f, 0.21568627450980393f, 0.21568627450980393f, 1.0f}, -{0.21176470588235297f, 0.21176470588235297f, 0.21176470588235297f, 1.0f}, -{0.207843137254902f, 0.207843137254902f, 0.207843137254902f, 1.0f}, -{0.20392156862745103f, 0.20392156862745103f, 0.20392156862745103f, 1.0f}, -{0.19999999999999996f, 0.19999999999999996f, 0.19999999999999996f, 1.0f}, -{0.19607843137254899f, 0.19607843137254899f, 0.19607843137254899f, 1.0f}, -{0.19215686274509802f, 0.19215686274509802f, 0.19215686274509802f, 1.0f}, -{0.18823529411764706f, 0.18823529411764706f, 0.18823529411764706f, 1.0f}, -{0.18431372549019609f, 0.18431372549019609f, 0.18431372549019609f, 1.0f}, -{0.18039215686274512f, 0.18039215686274512f, 0.18039215686274512f, 1.0f}, -{0.17647058823529416f, 0.17647058823529416f, 0.17647058823529416f, 1.0f}, -{0.17254901960784319f, 0.17254901960784319f, 0.17254901960784319f, 1.0f}, -{0.16862745098039222f, 0.16862745098039222f, 0.16862745098039222f, 1.0f}, -{0.16470588235294115f, 0.16470588235294115f, 0.16470588235294115f, 1.0f}, -{0.16078431372549018f, 0.16078431372549018f, 0.16078431372549018f, 1.0f}, -{0.15686274509803921f, 0.15686274509803921f, 0.15686274509803921f, 1.0f}, -{0.15294117647058825f, 0.15294117647058825f, 0.15294117647058825f, 1.0f}, -{0.14901960784313728f, 0.14901960784313728f, 0.14901960784313728f, 1.0f}, -{0.14509803921568631f, 0.14509803921568631f, 0.14509803921568631f, 1.0f}, -{0.14117647058823535f, 0.14117647058823535f, 0.14117647058823535f, 1.0f}, -{0.13725490196078427f, 0.13725490196078427f, 0.13725490196078427f, 1.0f}, -{0.1333333333333333f, 0.1333333333333333f, 0.1333333333333333f, 1.0f}, -{0.12941176470588234f, 0.12941176470588234f, 0.12941176470588234f, 1.0f}, -{0.12549019607843137f, 0.12549019607843137f, 0.12549019607843137f, 1.0f}, -{0.1215686274509804f, 0.1215686274509804f, 0.1215686274509804f, 1.0f}, -{0.11764705882352944f, 0.11764705882352944f, 0.11764705882352944f, 1.0f}, -{0.11372549019607847f, 0.11372549019607847f, 0.11372549019607847f, 1.0f}, -{0.1098039215686275f, 0.1098039215686275f, 0.1098039215686275f, 1.0f}, -{0.10588235294117654f, 0.10588235294117654f, 0.10588235294117654f, 1.0f}, -{0.10196078431372546f, 0.10196078431372546f, 0.10196078431372546f, 1.0f}, -{0.098039215686274495f, 0.098039215686274495f, 0.098039215686274495f, 1.0f}, -{0.094117647058823528f, 0.094117647058823528f, 0.094117647058823528f, 1.0f}, -{0.090196078431372562f, 0.090196078431372562f, 0.090196078431372562f, 1.0f}, -{0.086274509803921595f, 0.086274509803921595f, 0.086274509803921595f, 1.0f}, -{0.082352941176470629f, 0.082352941176470629f, 0.082352941176470629f, 1.0f}, -{0.078431372549019662f, 0.078431372549019662f, 0.078431372549019662f, 1.0f}, -{0.074509803921568585f, 0.074509803921568585f, 0.074509803921568585f, 1.0f}, -{0.070588235294117618f, 0.070588235294117618f, 0.070588235294117618f, 1.0f}, -{0.066666666666666652f, 0.066666666666666652f, 0.066666666666666652f, 1.0f}, -{0.062745098039215685f, 0.062745098039215685f, 0.062745098039215685f, 1.0f}, -{0.058823529411764719f, 0.058823529411764719f, 0.058823529411764719f, 1.0f}, -{0.054901960784313752f, 0.054901960784313752f, 0.054901960784313752f, 1.0f}, -{0.050980392156862786f, 0.050980392156862786f, 0.050980392156862786f, 1.0f}, -{0.04705882352941182f, 0.04705882352941182f, 0.04705882352941182f, 1.0f}, -{0.043137254901960853f, 0.043137254901960853f, 0.043137254901960853f, 1.0f}, -{0.039215686274509776f, 0.039215686274509776f, 0.039215686274509776f, 1.0f}, -{0.035294117647058809f, 0.035294117647058809f, 0.035294117647058809f, 1.0f}, -{0.031372549019607843f, 0.031372549019607843f, 0.031372549019607843f, 1.0f}, -{0.027450980392156876f, 0.027450980392156876f, 0.027450980392156876f, 1.0f}, -{0.02352941176470591f, 0.02352941176470591f, 0.02352941176470591f, 1.0f}, -{0.019607843137254943f, 0.019607843137254943f, 0.019607843137254943f, 1.0f}, -{0.015686274509803977f, 0.015686274509803977f, 0.015686274509803977f, 1.0f}, -{0.011764705882352899f, 0.011764705882352899f, 0.011764705882352899f, 1.0f}, -{0.0078431372549019329f, 0.0078431372549019329f, 0.0078431372549019329f, 1.0f}, -{0.0039215686274509665f, 0.0039215686274509665f, 0.0039215686274509665f, 1.0f}, -{0.0f, 0.0f, 0.0f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential2/binary.txt b/extern/tfn/colormaps/sequential2/binary.txt deleted file mode 100644 index 0472804..0000000 --- a/extern/tfn/colormaps/sequential2/binary.txt +++ /dev/null @@ -1,256 +0,0 @@ -(1.0, 1.0, 1.0, 1.0) -(0.99607843137254903, 0.99607843137254903, 0.99607843137254903, 1.0) -(0.99215686274509807, 0.99215686274509807, 0.99215686274509807, 1.0) -(0.9882352941176471, 0.9882352941176471, 0.9882352941176471, 1.0) -(0.98431372549019613, 0.98431372549019613, 0.98431372549019613, 1.0) -(0.98039215686274506, 0.98039215686274506, 0.98039215686274506, 1.0) -(0.97647058823529409, 0.97647058823529409, 0.97647058823529409, 1.0) -(0.97254901960784312, 0.97254901960784312, 0.97254901960784312, 1.0) -(0.96862745098039216, 0.96862745098039216, 0.96862745098039216, 1.0) -(0.96470588235294119, 0.96470588235294119, 0.96470588235294119, 1.0) -(0.96078431372549022, 0.96078431372549022, 0.96078431372549022, 1.0) -(0.95686274509803926, 0.95686274509803926, 0.95686274509803926, 1.0) -(0.95294117647058818, 0.95294117647058818, 0.95294117647058818, 1.0) -(0.94901960784313721, 0.94901960784313721, 0.94901960784313721, 1.0) -(0.94509803921568625, 0.94509803921568625, 0.94509803921568625, 1.0) -(0.94117647058823528, 0.94117647058823528, 0.94117647058823528, 1.0) -(0.93725490196078431, 0.93725490196078431, 0.93725490196078431, 1.0) -(0.93333333333333335, 0.93333333333333335, 0.93333333333333335, 1.0) -(0.92941176470588238, 0.92941176470588238, 0.92941176470588238, 1.0) -(0.92549019607843142, 0.92549019607843142, 0.92549019607843142, 1.0) -(0.92156862745098045, 0.92156862745098045, 0.92156862745098045, 1.0) -(0.91764705882352937, 0.91764705882352937, 0.91764705882352937, 1.0) -(0.9137254901960784, 0.9137254901960784, 0.9137254901960784, 1.0) -(0.90980392156862744, 0.90980392156862744, 0.90980392156862744, 1.0) -(0.90588235294117647, 0.90588235294117647, 0.90588235294117647, 1.0) -(0.90196078431372551, 0.90196078431372551, 0.90196078431372551, 1.0) -(0.89803921568627454, 0.89803921568627454, 0.89803921568627454, 1.0) -(0.89411764705882357, 0.89411764705882357, 0.89411764705882357, 1.0) -(0.8901960784313725, 0.8901960784313725, 0.8901960784313725, 1.0) -(0.88627450980392153, 0.88627450980392153, 0.88627450980392153, 1.0) -(0.88235294117647056, 0.88235294117647056, 0.88235294117647056, 1.0) -(0.8784313725490196, 0.8784313725490196, 0.8784313725490196, 1.0) -(0.87450980392156863, 0.87450980392156863, 0.87450980392156863, 1.0) -(0.87058823529411766, 0.87058823529411766, 0.87058823529411766, 1.0) -(0.8666666666666667, 0.8666666666666667, 0.8666666666666667, 1.0) -(0.86274509803921573, 0.86274509803921573, 0.86274509803921573, 1.0) -(0.85882352941176476, 0.85882352941176476, 0.85882352941176476, 1.0) -(0.8549019607843138, 0.8549019607843138, 0.8549019607843138, 1.0) -(0.85098039215686272, 0.85098039215686272, 0.85098039215686272, 1.0) -(0.84705882352941175, 0.84705882352941175, 0.84705882352941175, 1.0) -(0.84313725490196079, 0.84313725490196079, 0.84313725490196079, 1.0) -(0.83921568627450982, 0.83921568627450982, 0.83921568627450982, 1.0) -(0.83529411764705885, 0.83529411764705885, 0.83529411764705885, 1.0) -(0.83137254901960778, 0.83137254901960778, 0.83137254901960778, 1.0) -(0.82745098039215681, 0.82745098039215681, 0.82745098039215681, 1.0) -(0.82352941176470584, 0.82352941176470584, 0.82352941176470584, 1.0) -(0.81960784313725488, 0.81960784313725488, 0.81960784313725488, 1.0) -(0.81568627450980391, 0.81568627450980391, 0.81568627450980391, 1.0) -(0.81176470588235294, 0.81176470588235294, 0.81176470588235294, 1.0) -(0.80784313725490198, 0.80784313725490198, 0.80784313725490198, 1.0) -(0.80392156862745101, 0.80392156862745101, 0.80392156862745101, 1.0) -(0.80000000000000004, 0.80000000000000004, 0.80000000000000004, 1.0) -(0.79607843137254908, 0.79607843137254908, 0.79607843137254908, 1.0) -(0.79215686274509811, 0.79215686274509811, 0.79215686274509811, 1.0) -(0.78823529411764703, 0.78823529411764703, 0.78823529411764703, 1.0) -(0.78431372549019607, 0.78431372549019607, 0.78431372549019607, 1.0) -(0.7803921568627451, 0.7803921568627451, 0.7803921568627451, 1.0) -(0.77647058823529413, 0.77647058823529413, 0.77647058823529413, 1.0) -(0.77254901960784317, 0.77254901960784317, 0.77254901960784317, 1.0) -(0.76862745098039209, 0.76862745098039209, 0.76862745098039209, 1.0) -(0.76470588235294112, 0.76470588235294112, 0.76470588235294112, 1.0) -(0.76078431372549016, 0.76078431372549016, 0.76078431372549016, 1.0) -(0.75686274509803919, 0.75686274509803919, 0.75686274509803919, 1.0) -(0.75294117647058822, 0.75294117647058822, 0.75294117647058822, 1.0) -(0.74901960784313726, 0.74901960784313726, 0.74901960784313726, 1.0) -(0.74509803921568629, 0.74509803921568629, 0.74509803921568629, 1.0) -(0.74117647058823533, 0.74117647058823533, 0.74117647058823533, 1.0) -(0.73725490196078436, 0.73725490196078436, 0.73725490196078436, 1.0) -(0.73333333333333339, 0.73333333333333339, 0.73333333333333339, 1.0) -(0.72941176470588243, 0.72941176470588243, 0.72941176470588243, 1.0) -(0.72549019607843135, 0.72549019607843135, 0.72549019607843135, 1.0) -(0.72156862745098038, 0.72156862745098038, 0.72156862745098038, 1.0) -(0.71764705882352942, 0.71764705882352942, 0.71764705882352942, 1.0) -(0.71372549019607845, 0.71372549019607845, 0.71372549019607845, 1.0) -(0.70980392156862748, 0.70980392156862748, 0.70980392156862748, 1.0) -(0.70588235294117641, 0.70588235294117641, 0.70588235294117641, 1.0) -(0.70196078431372544, 0.70196078431372544, 0.70196078431372544, 1.0) -(0.69803921568627447, 0.69803921568627447, 0.69803921568627447, 1.0) -(0.69411764705882351, 0.69411764705882351, 0.69411764705882351, 1.0) -(0.69019607843137254, 0.69019607843137254, 0.69019607843137254, 1.0) -(0.68627450980392157, 0.68627450980392157, 0.68627450980392157, 1.0) -(0.68235294117647061, 0.68235294117647061, 0.68235294117647061, 1.0) -(0.67843137254901964, 0.67843137254901964, 0.67843137254901964, 1.0) -(0.67450980392156867, 0.67450980392156867, 0.67450980392156867, 1.0) -(0.67058823529411771, 0.67058823529411771, 0.67058823529411771, 1.0) -(0.66666666666666674, 0.66666666666666674, 0.66666666666666674, 1.0) -(0.66274509803921566, 0.66274509803921566, 0.66274509803921566, 1.0) -(0.6588235294117647, 0.6588235294117647, 0.6588235294117647, 1.0) -(0.65490196078431373, 0.65490196078431373, 0.65490196078431373, 1.0) -(0.65098039215686276, 0.65098039215686276, 0.65098039215686276, 1.0) -(0.6470588235294118, 0.6470588235294118, 0.6470588235294118, 1.0) -(0.64313725490196072, 0.64313725490196072, 0.64313725490196072, 1.0) -(0.63921568627450975, 0.63921568627450975, 0.63921568627450975, 1.0) -(0.63529411764705879, 0.63529411764705879, 0.63529411764705879, 1.0) -(0.63137254901960782, 0.63137254901960782, 0.63137254901960782, 1.0) -(0.62745098039215685, 0.62745098039215685, 0.62745098039215685, 1.0) -(0.62352941176470589, 0.62352941176470589, 0.62352941176470589, 1.0) -(0.61960784313725492, 0.61960784313725492, 0.61960784313725492, 1.0) -(0.61568627450980395, 0.61568627450980395, 0.61568627450980395, 1.0) -(0.61176470588235299, 0.61176470588235299, 0.61176470588235299, 1.0) -(0.60784313725490202, 0.60784313725490202, 0.60784313725490202, 1.0) -(0.60392156862745106, 0.60392156862745106, 0.60392156862745106, 1.0) -(0.59999999999999998, 0.59999999999999998, 0.59999999999999998, 1.0) -(0.59607843137254901, 0.59607843137254901, 0.59607843137254901, 1.0) -(0.59215686274509804, 0.59215686274509804, 0.59215686274509804, 1.0) -(0.58823529411764708, 0.58823529411764708, 0.58823529411764708, 1.0) -(0.58431372549019611, 0.58431372549019611, 0.58431372549019611, 1.0) -(0.58039215686274503, 0.58039215686274503, 0.58039215686274503, 1.0) -(0.57647058823529407, 0.57647058823529407, 0.57647058823529407, 1.0) -(0.5725490196078431, 0.5725490196078431, 0.5725490196078431, 1.0) -(0.56862745098039214, 0.56862745098039214, 0.56862745098039214, 1.0) -(0.56470588235294117, 0.56470588235294117, 0.56470588235294117, 1.0) -(0.5607843137254902, 0.5607843137254902, 0.5607843137254902, 1.0) -(0.55686274509803924, 0.55686274509803924, 0.55686274509803924, 1.0) -(0.55294117647058827, 0.55294117647058827, 0.55294117647058827, 1.0) -(0.5490196078431373, 0.5490196078431373, 0.5490196078431373, 1.0) -(0.54509803921568634, 0.54509803921568634, 0.54509803921568634, 1.0) -(0.54117647058823537, 0.54117647058823537, 0.54117647058823537, 1.0) -(0.53725490196078429, 0.53725490196078429, 0.53725490196078429, 1.0) -(0.53333333333333333, 0.53333333333333333, 0.53333333333333333, 1.0) -(0.52941176470588236, 0.52941176470588236, 0.52941176470588236, 1.0) -(0.52549019607843139, 0.52549019607843139, 0.52549019607843139, 1.0) -(0.52156862745098043, 0.52156862745098043, 0.52156862745098043, 1.0) -(0.51764705882352935, 0.51764705882352935, 0.51764705882352935, 1.0) -(0.51372549019607838, 0.51372549019607838, 0.51372549019607838, 1.0) -(0.50980392156862742, 0.50980392156862742, 0.50980392156862742, 1.0) -(0.50588235294117645, 0.50588235294117645, 0.50588235294117645, 1.0) -(0.50196078431372548, 0.50196078431372548, 0.50196078431372548, 1.0) -(0.49803921568627452, 0.49803921568627452, 0.49803921568627452, 1.0) -(0.49411764705882355, 0.49411764705882355, 0.49411764705882355, 1.0) -(0.49019607843137258, 0.49019607843137258, 0.49019607843137258, 1.0) -(0.48627450980392162, 0.48627450980392162, 0.48627450980392162, 1.0) -(0.48235294117647065, 0.48235294117647065, 0.48235294117647065, 1.0) -(0.47843137254901957, 0.47843137254901957, 0.47843137254901957, 1.0) -(0.47450980392156861, 0.47450980392156861, 0.47450980392156861, 1.0) -(0.47058823529411764, 0.47058823529411764, 0.47058823529411764, 1.0) -(0.46666666666666667, 0.46666666666666667, 0.46666666666666667, 1.0) -(0.46274509803921571, 0.46274509803921571, 0.46274509803921571, 1.0) -(0.45882352941176474, 0.45882352941176474, 0.45882352941176474, 1.0) -(0.45490196078431377, 0.45490196078431377, 0.45490196078431377, 1.0) -(0.4509803921568627, 0.4509803921568627, 0.4509803921568627, 1.0) -(0.44705882352941173, 0.44705882352941173, 0.44705882352941173, 1.0) -(0.44313725490196076, 0.44313725490196076, 0.44313725490196076, 1.0) -(0.4392156862745098, 0.4392156862745098, 0.4392156862745098, 1.0) -(0.43529411764705883, 0.43529411764705883, 0.43529411764705883, 1.0) -(0.43137254901960786, 0.43137254901960786, 0.43137254901960786, 1.0) -(0.4274509803921569, 0.4274509803921569, 0.4274509803921569, 1.0) -(0.42352941176470593, 0.42352941176470593, 0.42352941176470593, 1.0) -(0.41960784313725497, 0.41960784313725497, 0.41960784313725497, 1.0) -(0.41568627450980389, 0.41568627450980389, 0.41568627450980389, 1.0) -(0.41176470588235292, 0.41176470588235292, 0.41176470588235292, 1.0) -(0.40784313725490196, 0.40784313725490196, 0.40784313725490196, 1.0) -(0.40392156862745099, 0.40392156862745099, 0.40392156862745099, 1.0) -(0.40000000000000002, 0.40000000000000002, 0.40000000000000002, 1.0) -(0.39607843137254906, 0.39607843137254906, 0.39607843137254906, 1.0) -(0.39215686274509809, 0.39215686274509809, 0.39215686274509809, 1.0) -(0.38823529411764701, 0.38823529411764701, 0.38823529411764701, 1.0) -(0.38431372549019605, 0.38431372549019605, 0.38431372549019605, 1.0) -(0.38039215686274508, 0.38039215686274508, 0.38039215686274508, 1.0) -(0.37647058823529411, 0.37647058823529411, 0.37647058823529411, 1.0) -(0.37254901960784315, 0.37254901960784315, 0.37254901960784315, 1.0) -(0.36862745098039218, 0.36862745098039218, 0.36862745098039218, 1.0) -(0.36470588235294121, 0.36470588235294121, 0.36470588235294121, 1.0) -(0.36078431372549025, 0.36078431372549025, 0.36078431372549025, 1.0) -(0.35686274509803928, 0.35686274509803928, 0.35686274509803928, 1.0) -(0.3529411764705882, 0.3529411764705882, 0.3529411764705882, 1.0) -(0.34901960784313724, 0.34901960784313724, 0.34901960784313724, 1.0) -(0.34509803921568627, 0.34509803921568627, 0.34509803921568627, 1.0) -(0.3411764705882353, 0.3411764705882353, 0.3411764705882353, 1.0) -(0.33725490196078434, 0.33725490196078434, 0.33725490196078434, 1.0) -(0.33333333333333337, 0.33333333333333337, 0.33333333333333337, 1.0) -(0.3294117647058824, 0.3294117647058824, 0.3294117647058824, 1.0) -(0.32549019607843133, 0.32549019607843133, 0.32549019607843133, 1.0) -(0.32156862745098036, 0.32156862745098036, 0.32156862745098036, 1.0) -(0.31764705882352939, 0.31764705882352939, 0.31764705882352939, 1.0) -(0.31372549019607843, 0.31372549019607843, 0.31372549019607843, 1.0) -(0.30980392156862746, 0.30980392156862746, 0.30980392156862746, 1.0) -(0.30588235294117649, 0.30588235294117649, 0.30588235294117649, 1.0) -(0.30196078431372553, 0.30196078431372553, 0.30196078431372553, 1.0) -(0.29803921568627456, 0.29803921568627456, 0.29803921568627456, 1.0) -(0.29411764705882359, 0.29411764705882359, 0.29411764705882359, 1.0) -(0.29019607843137252, 0.29019607843137252, 0.29019607843137252, 1.0) -(0.28627450980392155, 0.28627450980392155, 0.28627450980392155, 1.0) -(0.28235294117647058, 0.28235294117647058, 0.28235294117647058, 1.0) -(0.27843137254901962, 0.27843137254901962, 0.27843137254901962, 1.0) -(0.27450980392156865, 0.27450980392156865, 0.27450980392156865, 1.0) -(0.27058823529411768, 0.27058823529411768, 0.27058823529411768, 1.0) -(0.26666666666666672, 0.26666666666666672, 0.26666666666666672, 1.0) -(0.26274509803921564, 0.26274509803921564, 0.26274509803921564, 1.0) -(0.25882352941176467, 0.25882352941176467, 0.25882352941176467, 1.0) -(0.25490196078431371, 0.25490196078431371, 0.25490196078431371, 1.0) -(0.25098039215686274, 0.25098039215686274, 0.25098039215686274, 1.0) -(0.24705882352941178, 0.24705882352941178, 0.24705882352941178, 1.0) -(0.24313725490196081, 0.24313725490196081, 0.24313725490196081, 1.0) -(0.23921568627450984, 0.23921568627450984, 0.23921568627450984, 1.0) -(0.23529411764705888, 0.23529411764705888, 0.23529411764705888, 1.0) -(0.23137254901960791, 0.23137254901960791, 0.23137254901960791, 1.0) -(0.22745098039215683, 0.22745098039215683, 0.22745098039215683, 1.0) -(0.22352941176470587, 0.22352941176470587, 0.22352941176470587, 1.0) -(0.2196078431372549, 0.2196078431372549, 0.2196078431372549, 1.0) -(0.21568627450980393, 0.21568627450980393, 0.21568627450980393, 1.0) -(0.21176470588235297, 0.21176470588235297, 0.21176470588235297, 1.0) -(0.207843137254902, 0.207843137254902, 0.207843137254902, 1.0) -(0.20392156862745103, 0.20392156862745103, 0.20392156862745103, 1.0) -(0.19999999999999996, 0.19999999999999996, 0.19999999999999996, 1.0) -(0.19607843137254899, 0.19607843137254899, 0.19607843137254899, 1.0) -(0.19215686274509802, 0.19215686274509802, 0.19215686274509802, 1.0) -(0.18823529411764706, 0.18823529411764706, 0.18823529411764706, 1.0) -(0.18431372549019609, 0.18431372549019609, 0.18431372549019609, 1.0) -(0.18039215686274512, 0.18039215686274512, 0.18039215686274512, 1.0) -(0.17647058823529416, 0.17647058823529416, 0.17647058823529416, 1.0) -(0.17254901960784319, 0.17254901960784319, 0.17254901960784319, 1.0) -(0.16862745098039222, 0.16862745098039222, 0.16862745098039222, 1.0) -(0.16470588235294115, 0.16470588235294115, 0.16470588235294115, 1.0) -(0.16078431372549018, 0.16078431372549018, 0.16078431372549018, 1.0) -(0.15686274509803921, 0.15686274509803921, 0.15686274509803921, 1.0) -(0.15294117647058825, 0.15294117647058825, 0.15294117647058825, 1.0) -(0.14901960784313728, 0.14901960784313728, 0.14901960784313728, 1.0) -(0.14509803921568631, 0.14509803921568631, 0.14509803921568631, 1.0) -(0.14117647058823535, 0.14117647058823535, 0.14117647058823535, 1.0) -(0.13725490196078427, 0.13725490196078427, 0.13725490196078427, 1.0) -(0.1333333333333333, 0.1333333333333333, 0.1333333333333333, 1.0) -(0.12941176470588234, 0.12941176470588234, 0.12941176470588234, 1.0) -(0.12549019607843137, 0.12549019607843137, 0.12549019607843137, 1.0) -(0.1215686274509804, 0.1215686274509804, 0.1215686274509804, 1.0) -(0.11764705882352944, 0.11764705882352944, 0.11764705882352944, 1.0) -(0.11372549019607847, 0.11372549019607847, 0.11372549019607847, 1.0) -(0.1098039215686275, 0.1098039215686275, 0.1098039215686275, 1.0) -(0.10588235294117654, 0.10588235294117654, 0.10588235294117654, 1.0) -(0.10196078431372546, 0.10196078431372546, 0.10196078431372546, 1.0) -(0.098039215686274495, 0.098039215686274495, 0.098039215686274495, 1.0) -(0.094117647058823528, 0.094117647058823528, 0.094117647058823528, 1.0) -(0.090196078431372562, 0.090196078431372562, 0.090196078431372562, 1.0) -(0.086274509803921595, 0.086274509803921595, 0.086274509803921595, 1.0) -(0.082352941176470629, 0.082352941176470629, 0.082352941176470629, 1.0) -(0.078431372549019662, 0.078431372549019662, 0.078431372549019662, 1.0) -(0.074509803921568585, 0.074509803921568585, 0.074509803921568585, 1.0) -(0.070588235294117618, 0.070588235294117618, 0.070588235294117618, 1.0) -(0.066666666666666652, 0.066666666666666652, 0.066666666666666652, 1.0) -(0.062745098039215685, 0.062745098039215685, 0.062745098039215685, 1.0) -(0.058823529411764719, 0.058823529411764719, 0.058823529411764719, 1.0) -(0.054901960784313752, 0.054901960784313752, 0.054901960784313752, 1.0) -(0.050980392156862786, 0.050980392156862786, 0.050980392156862786, 1.0) -(0.04705882352941182, 0.04705882352941182, 0.04705882352941182, 1.0) -(0.043137254901960853, 0.043137254901960853, 0.043137254901960853, 1.0) -(0.039215686274509776, 0.039215686274509776, 0.039215686274509776, 1.0) -(0.035294117647058809, 0.035294117647058809, 0.035294117647058809, 1.0) -(0.031372549019607843, 0.031372549019607843, 0.031372549019607843, 1.0) -(0.027450980392156876, 0.027450980392156876, 0.027450980392156876, 1.0) -(0.02352941176470591, 0.02352941176470591, 0.02352941176470591, 1.0) -(0.019607843137254943, 0.019607843137254943, 0.019607843137254943, 1.0) -(0.015686274509803977, 0.015686274509803977, 0.015686274509803977, 1.0) -(0.011764705882352899, 0.011764705882352899, 0.011764705882352899, 1.0) -(0.0078431372549019329, 0.0078431372549019329, 0.0078431372549019329, 1.0) -(0.0039215686274509665, 0.0039215686274509665, 0.0039215686274509665, 1.0) -(0.0, 0.0, 0.0, 1.0) diff --git a/extern/tfn/colormaps/sequential2/bone.cpp b/extern/tfn/colormaps/sequential2/bone.cpp deleted file mode 100644 index 0c4c729..0000000 --- a/extern/tfn/colormaps/sequential2/bone.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential2_bone; -} -const std::vector colormap::data_sequential2_bone = /* NOLINT(cert-err58-cpp) */ -{ -{0.0f, 0.0f, 0.0f, 1.0f}, -{0.0034313725490196078f, 0.0034313712063072676f, 0.0047740835464620632f, 1.0f}, -{0.0068627450980392156f, 0.0068627424126145352f, 0.0095481670929241265f, 1.0f}, -{0.010294117647058823f, 0.010294113618921803f, 0.01432225063938619f, 1.0f}, -{0.013725490196078431f, 0.01372548482522907f, 0.019096334185848253f, 1.0f}, -{0.017156862745098041f, 0.017156856031536338f, 0.023870417732310314f, 1.0f}, -{0.020588235294117647f, 0.020588227237843607f, 0.028644501278772379f, 1.0f}, -{0.024019607843137256f, 0.024019598444150872f, 0.033418584825234438f, 1.0f}, -{0.027450980392156862f, 0.027450969650458141f, 0.038192668371696506f, 1.0f}, -{0.030882352941176472f, 0.030882340856765406f, 0.042966751918158567f, 1.0f}, -{0.034313725490196081f, 0.034313712063072675f, 0.047740835464620629f, 1.0f}, -{0.037745098039215684f, 0.037745083269379948f, 0.052514919011082697f, 1.0f}, -{0.041176470588235294f, 0.041176454475687213f, 0.057289002557544759f, 1.0f}, -{0.044607843137254903f, 0.044607825681994479f, 0.062063086104006814f, 1.0f}, -{0.048039215686274513f, 0.048039196888301744f, 0.066837169650468875f, 1.0f}, -{0.051470588235294115f, 0.051470568094609016f, 0.071611253196930943f, 1.0f}, -{0.054901960784313725f, 0.054901939300916282f, 0.076385336743393012f, 1.0f}, -{0.058333333333333334f, 0.058333310507223554f, 0.08115942028985508f, 1.0f}, -{0.061764705882352944f, 0.061764681713530813f, 0.085933503836317135f, 1.0f}, -{0.065196078431372553f, 0.065196052919838085f, 0.09070758738277919f, 1.0f}, -{0.068627450980392163f, 0.06862742412614535f, 0.095481670929241258f, 1.0f}, -{0.072058823529411759f, 0.07205879533245263f, 0.10025575447570333f, 1.0f}, -{0.075490196078431368f, 0.075490166538759895f, 0.10502983802216539f, 1.0f}, -{0.078921568627450978f, 0.078921537745067147f, 0.10980392156862745f, 1.0f}, -{0.082352941176470587f, 0.082352908951374426f, 0.11457800511508952f, 1.0f}, -{0.085784313725490183f, 0.085784280157681678f, 0.11935208866155156f, 1.0f}, -{0.089215686274509806f, 0.089215651363988957f, 0.12412617220801363f, 1.0f}, -{0.092647058823529402f, 0.092647022570296222f, 0.1289002557544757f, 1.0f}, -{0.096078431372549025f, 0.096078393776603488f, 0.13367433930093775f, 1.0f}, -{0.099509803921568621f, 0.099509764982910767f, 0.13844842284739983f, 1.0f}, -{0.10294117647058823f, 0.10294113618921803f, 0.14322250639386189f, 1.0f}, -{0.10637254901960784f, 0.1063725073955253f, 0.14799658994032397f, 1.0f}, -{0.10980392156862745f, 0.10980387860183256f, 0.15277067348678602f, 1.0f}, -{0.11323529411764703f, 0.1132352498081398f, 0.15754475703324805f, 1.0f}, -{0.11666666666666667f, 0.11666662101444711f, 0.16231884057971016f, 1.0f}, -{0.12009803921568628f, 0.12009799222075436f, 0.16709292412617219f, 1.0f}, -{0.12352941176470589f, 0.12352936342706163f, 0.17186700767263427f, 1.0f}, -{0.12696078431372546f, 0.12696073463336888f, 0.1766410912190963f, 1.0f}, -{0.13039215686274511f, 0.13039210583967617f, 0.18141517476555838f, 1.0f}, -{0.1338235294117647f, 0.13382347704598344f, 0.18618925831202046f, 1.0f}, -{0.13725490196078433f, 0.1372548482522907f, 0.19096334185848252f, 1.0f}, -{0.14068627450980389f, 0.14068621945859794f, 0.19573742540494454f, 1.0f}, -{0.14411764705882352f, 0.14411759066490526f, 0.20051150895140665f, 1.0f}, -{0.14754901960784314f, 0.14754896187121253f, 0.20528559249786871f, 1.0f}, -{0.15098039215686274f, 0.15098033307751979f, 0.21005967604433079f, 1.0f}, -{0.15441176470588233f, 0.15441170428382703f, 0.21483375959079279f, 1.0f}, -{0.15784313725490196f, 0.15784307549013429f, 0.2196078431372549f, 1.0f}, -{0.16127450980392158f, 0.16127444669644159f, 0.22438192668371695f, 1.0f}, -{0.16470588235294117f, 0.16470581790274885f, 0.22915601023017904f, 1.0f}, -{0.16813725490196074f, 0.16813718910905609f, 0.23393009377664103f, 1.0f}, -{0.17156862745098037f, 0.17156856031536336f, 0.23870417732310312f, 1.0f}, -{0.17500000000000002f, 0.17499993152167065f, 0.24347826086956523f, 1.0f}, -{0.17843137254901961f, 0.17843130272797791f, 0.24825234441602725f, 1.0f}, -{0.18186274509803918f, 0.18186267393428515f, 0.25302642796248931f, 1.0f}, -{0.1852941176470588f, 0.18529404514059244f, 0.25780051150895139f, 1.0f}, -{0.18872549019607843f, 0.18872541634689974f, 0.26257459505541347f, 1.0f}, -{0.19215686274509805f, 0.19215678755320698f, 0.2673486786018755f, 1.0f}, -{0.19558823529411762f, 0.19558815875951424f, 0.27212276214833758f, 1.0f}, -{0.19901960784313724f, 0.19901952996582153f, 0.27689684569479966f, 1.0f}, -{0.20245098039215687f, 0.2024509011721288f, 0.28167092924126175f, 1.0f}, -{0.20588235294117646f, 0.20588227237843607f, 0.28644501278772377f, 1.0f}, -{0.20931372549019606f, 0.2093136435847433f, 0.2912190963341858f, 1.0f}, -{0.21274509803921568f, 0.2127450147910506f, 0.29599317988064794f, 1.0f}, -{0.21617647058823528f, 0.21617638599735786f, 0.30076726342710997f, 1.0f}, -{0.2196078431372549f, 0.21960775720366513f, 0.30554134697357205f, 1.0f}, -{0.22303921568627449f, 0.22303912840997239f, 0.31031543052003407f, 1.0f}, -{0.22647058823529406f, 0.2264704996162796f, 0.3150895140664961f, 1.0f}, -{0.22990196078431371f, 0.22990187082258692f, 0.31986359761295824f, 1.0f}, -{0.23333333333333334f, 0.23333324202889422f, 0.32463768115942032f, 1.0f}, -{0.23676470588235293f, 0.23676461323520148f, 0.32941176470588235f, 1.0f}, -{0.24019607843137256f, 0.24019598444150872f, 0.33418584825234438f, 1.0f}, -{0.24362745098039215f, 0.24362735564781601f, 0.33895993179880646f, 1.0f}, -{0.24705882352941178f, 0.24705872685412325f, 0.34373401534526854f, 1.0f}, -{0.25049019607843137f, 0.25049009806043054f, 0.34850809889173062f, 1.0f}, -{0.25392156862745091f, 0.25392146926673775f, 0.35328218243819259f, 1.0f}, -{0.25735294117647062f, 0.25735284047304507f, 0.35805626598465473f, 1.0f}, -{0.26078431372549021f, 0.26078421167935234f, 0.36283034953111676f, 1.0f}, -{0.26421568627450981f, 0.26421558288565961f, 0.3676044330775789f, 1.0f}, -{0.2676470588235294f, 0.26764695409196687f, 0.37237851662404092f, 1.0f}, -{0.271078431372549f, 0.27107832529827414f, 0.37715260017050295f, 1.0f}, -{0.27450980392156865f, 0.2745096965045814f, 0.38192668371696503f, 1.0f}, -{0.27794117647058825f, 0.27794106771088867f, 0.38670076726342706f, 1.0f}, -{0.28137254901960779f, 0.28137243891719588f, 0.39147485080988909f, 1.0f}, -{0.28480392156862744f, 0.2848038101235032f, 0.39624893435635122f, 1.0f}, -{0.28823529411764703f, 0.28823518132981052f, 0.40102301790281331f, 1.0f}, -{0.29166666666666669f, 0.29166655253611773f, 0.40579710144927533f, 1.0f}, -{0.29509803921568628f, 0.29509792374242505f, 0.41057118499573741f, 1.0f}, -{0.29852941176470588f, 0.29852929494873226f, 0.4153452685421995f, 1.0f}, -{0.30196078431372547f, 0.30196066615503958f, 0.42011935208866158f, 1.0f}, -{0.30539215686274507f, 0.30539203736134685f, 0.42489343563512361f, 1.0f}, -{0.30882352941176466f, 0.30882340856765406f, 0.42966751918158558f, 1.0f}, -{0.31225490196078431f, 0.31225477977396138f, 0.43444160272804772f, 1.0f}, -{0.31568627450980391f, 0.31568615098026859f, 0.4392156862745098f, 1.0f}, -{0.31911764705882351f, 0.31911752218657591f, 0.44398976982097188f, 1.0f}, -{0.32254901960784316f, 0.32371322935807584f, 0.44754889530644404f, 1.0f}, -{0.32598039215686275f, 0.32843136580875115f, 0.450980268627522f, 1.0f}, -{0.32941176470588235f, 0.33314950225942647f, 0.45441164194860001f, 1.0f}, -{0.33284313725490194f, 0.33786763871010178f, 0.45784301526967797f, 1.0f}, -{0.33627450980392148f, 0.34258577516077704f, 0.46127438859075592f, 1.0f}, -{0.33970588235294114f, 0.34730391161145246f, 0.46470576191183394f, 1.0f}, -{0.34313725490196073f, 0.35202204806212778f, 0.46813713523291195f, 1.0f}, -{0.34656862745098033f, 0.35674018451280309f, 0.47156850855398991f, 1.0f}, -{0.35000000000000003f, 0.36145832096347841f, 0.47499988187506792f, 1.0f}, -{0.35343137254901963f, 0.36617645741415378f, 0.47843125519614593f, 1.0f}, -{0.35686274509803922f, 0.37089459386482909f, 0.48186262851722389f, 1.0f}, -{0.36029411764705882f, 0.37561273031550441f, 0.48529400183830185f, 1.0f}, -{0.36372549019607836f, 0.38033086676617966f, 0.4887253751593798f, 1.0f}, -{0.36715686274509801f, 0.38504900321685509f, 0.49215674848045787f, 1.0f}, -{0.37058823529411761f, 0.3897671396675304f, 0.49558812180153583f, 1.0f}, -{0.3740196078431372f, 0.39448527611820572f, 0.49901949512261384f, 1.0f}, -{0.37745098039215685f, 0.39920341256888103f, 0.5024508684436918f, 1.0f}, -{0.38088235294117651f, 0.40392154901955635f, 0.50588224176476981f, 1.0f}, -{0.3843137254901961f, 0.40863968547023166f, 0.50931361508584783f, 1.0f}, -{0.3877450980392157f, 0.41335782192090703f, 0.51274498840692573f, 1.0f}, -{0.39117647058823524f, 0.41807595837158229f, 0.51617636172800374f, 1.0f}, -{0.39460784313725489f, 0.42279409482225766f, 0.51960773504908175f, 1.0f}, -{0.39803921568627448f, 0.42751223127293303f, 0.52303910837015977f, 1.0f}, -{0.40147058823529408f, 0.43223036772360834f, 0.52647048169123767f, 1.0f}, -{0.40490196078431373f, 0.43694850417428366f, 0.52990185501231568f, 1.0f}, -{0.40833333333333333f, 0.44166664062495897f, 0.53333322833339369f, 1.0f}, -{0.41176470588235292f, 0.44638477707563429f, 0.53676460165447171f, 1.0f}, -{0.41519607843137257f, 0.45110291352630966f, 0.54019597497554972f, 1.0f}, -{0.41862745098039211f, 0.45582104997698492f, 0.54362734829662762f, 1.0f}, -{0.42205882352941176f, 0.46053918642766029f, 0.54705872161770563f, 1.0f}, -{0.42549019607843136f, 0.46525732287833566f, 0.55049009493878365f, 1.0f}, -{0.42892156862745096f, 0.46997545932901097f, 0.55392146825986166f, 1.0f}, -{0.43235294117647055f, 0.47469359577968628f, 0.55735284158093967f, 1.0f}, -{0.4357843137254902f, 0.4794117322303616f, 0.56078421490201757f, 1.0f}, -{0.4392156862745098f, 0.48412986868103691f, 0.56421558822309559f, 1.0f}, -{0.44264705882352939f, 0.48884800513171223f, 0.5676469615441736f, 1.0f}, -{0.44607843137254899f, 0.49356614158238754f, 0.5710783348652515f, 1.0f}, -{0.44950980392156864f, 0.49828427803306286f, 0.57450970818632952f, 1.0f}, -{0.45294117647058812f, 0.50300241448373806f, 0.57794108150740742f, 1.0f}, -{0.45637254901960783f, 0.50772055093441359f, 0.58137245482848554f, 1.0f}, -{0.45980392156862743f, 0.5124386873850888f, 0.58480382814956355f, 1.0f}, -{0.46323529411764708f, 0.51715682383576422f, 0.58823520147064146f, 1.0f}, -{0.46666666666666667f, 0.52187496028643954f, 0.59166657479171947f, 1.0f}, -{0.47009803921568627f, 0.52659309673711485f, 0.59509794811279748f, 1.0f}, -{0.47352941176470587f, 0.53131123318779017f, 0.59852932143387549f, 1.0f}, -{0.47696078431372546f, 0.53602936963846548f, 0.6019606947549534f, 1.0f}, -{0.48039215686274511f, 0.54074750608914091f, 0.60539206807603141f, 1.0f}, -{0.48382352941176471f, 0.54546564253981611f, 0.60882344139710942f, 1.0f}, -{0.4872549019607843f, 0.55018377899049153f, 0.61225481471818743f, 1.0f}, -{0.49068627450980395f, 0.55490191544116685f, 0.61568618803926545f, 1.0f}, -{0.49411764705882355f, 0.55962005189184216f, 0.61911756136034335f, 1.0f}, -{0.49754901960784315f, 0.56433818834251748f, 0.62254893468142136f, 1.0f}, -{0.50098039215686274f, 0.56905632479319279f, 0.62598030800249937f, 1.0f}, -{0.50441176470588234f, 0.57377446124386822f, 0.62941168132357739f, 1.0f}, -{0.50784313725490182f, 0.57849259769454331f, 0.63284305464465529f, 1.0f}, -{0.51127450980392153f, 0.58321073414521873f, 0.6362744279657333f, 1.0f}, -{0.51470588235294124f, 0.58792887059589405f, 0.63970580128681132f, 1.0f}, -{0.51813725490196083f, 0.59264700704656947f, 0.64313717460788933f, 1.0f}, -{0.52156862745098043f, 0.59736514349724468f, 0.64656854792896723f, 1.0f}, -{0.52500000000000002f, 0.6020832799479201f, 0.64999992125004524f, 1.0f}, -{0.52843137254901962f, 0.60680141639859542f, 0.65343129457112326f, 1.0f}, -{0.53186274509803921f, 0.61151955284927073f, 0.65686266789220127f, 1.0f}, -{0.53529411764705881f, 0.61623768929994616f, 0.66029404121327917f, 1.0f}, -{0.5387254901960784f, 0.62095582575062136f, 0.66372541453435718f, 1.0f}, -{0.542156862745098f, 0.62567396220129667f, 0.6671567878554352f, 1.0f}, -{0.54558823529411771f, 0.63039209865197199f, 0.67058816117651321f, 1.0f}, -{0.5490196078431373f, 0.63511023510264741f, 0.67401953449759122f, 1.0f}, -{0.5524509803921569f, 0.63982837155332262f, 0.67745090781866912f, 1.0f}, -{0.55588235294117649f, 0.64454650800399804f, 0.68088228113974714f, 1.0f}, -{0.55931372549019609f, 0.64926464445467336f, 0.68431365446082515f, 1.0f}, -{0.56274509803921557f, 0.65398278090534856f, 0.68774502778190305f, 1.0f}, -{0.56617647058823528f, 0.6587009173560241f, 0.69117640110298106f, 1.0f}, -{0.56960784313725488f, 0.6634190538066993f, 0.69460777442405908f, 1.0f}, -{0.57303921568627447f, 0.66813719025737461f, 0.69803914774513709f, 1.0f}, -{0.57647058823529407f, 0.67285532670804993f, 0.7014705210662151f, 1.0f}, -{0.57990196078431377f, 0.67757346315872535f, 0.70490189438729312f, 1.0f}, -{0.58333333333333337f, 0.68229159960940056f, 0.70833326770837102f, 1.0f}, -{0.58676470588235297f, 0.68700973606007598f, 0.71176464102944903f, 1.0f}, -{0.59019607843137256f, 0.6917278725107513f, 0.71519601435052693f, 1.0f}, -{0.59362745098039216f, 0.69644600896142661f, 0.71862738767160494f, 1.0f}, -{0.59705882352941175f, 0.70116414541210192f, 0.72205876099268296f, 1.0f}, -{0.60049019607843135f, 0.70588228186277724f, 0.72549013431376097f, 1.0f}, -{0.60392156862745094f, 0.71060041831345255f, 0.72892150763483898f, 1.0f}, -{0.60735294117647054f, 0.71531855476412787f, 0.732352880955917f, 1.0f}, -{0.61078431372549014f, 0.72003669121480329f, 0.73578425427699501f, 1.0f}, -{0.61421568627450984f, 0.7247548276654785f, 0.73921562759807302f, 1.0f}, -{0.61764705882352933f, 0.7294729641161537f, 0.74264700091915081f, 1.0f}, -{0.62107843137254903f, 0.73419110056682924f, 0.74607837424022883f, 1.0f}, -{0.62450980392156863f, 0.73890923701750455f, 0.74950974756130684f, 1.0f}, -{0.62794117647058822f, 0.74362737346817986f, 0.75294112088238485f, 1.0f}, -{0.63137254901960782f, 0.74834550991885518f, 0.75637249420346286f, 1.0f}, -{0.63480392156862742f, 0.7530636463695306f, 0.75980386752454088f, 1.0f}, -{0.63823529411764701f, 0.75778178282020581f, 0.76323524084561889f, 1.0f}, -{0.64166666666666661f, 0.76249991927088123f, 0.7666666141666969f, 1.0f}, -{0.64509803921568631f, 0.76721805572155655f, 0.7700979874877748f, 1.0f}, -{0.64852941176470591f, 0.77193619217223186f, 0.77352936080885282f, 1.0f}, -{0.65196078431372551f, 0.77665432862290718f, 0.77696073412993072f, 1.0f}, -{0.65686262156850395f, 0.7803921568627451f, 0.78039210745100873f, 1.0f}, -{0.66222414310649602f, 0.7838235294117647f, 0.78382348077208674f, 1.0f}, -{0.66758566464448821f, 0.78725490196078429f, 0.78725485409316476f, 1.0f}, -{0.67294718618248028f, 0.79068627450980389f, 0.79068622741424277f, 1.0f}, -{0.67830870772047247f, 0.79411764705882348f, 0.79411760073532078f, 1.0f}, -{0.68367022925846443f, 0.79754901960784308f, 0.79754897405639857f, 1.0f}, -{0.68903175079645673f, 0.80098039215686279f, 0.8009803473774767f, 1.0f}, -{0.69439327233444881f, 0.80441176470588238f, 0.80441172069855471f, 1.0f}, -{0.69975479387244088f, 0.80784313725490198f, 0.80784309401963261f, 1.0f}, -{0.70511631541043307f, 0.81127450980392157f, 0.81127446734071063f, 1.0f}, -{0.71047783694842515f, 0.81470588235294117f, 0.81470584066178864f, 1.0f}, -{0.71583935848641733f, 0.81813725490196076f, 0.81813721398286665f, 1.0f}, -{0.72120088002440941f, 0.82156862745098036f, 0.82156858730394466f, 1.0f}, -{0.72656240156240159f, 0.82499999999999996f, 0.82499996062502257f, 1.0f}, -{0.73192392310039367f, 0.82843137254901955f, 0.82843133394610058f, 1.0f}, -{0.73728544463838586f, 0.83186274509803926f, 0.83186270726717859f, 1.0f}, -{0.74264696617637793f, 0.83529411764705885f, 0.8352940805882566f, 1.0f}, -{0.74800848771437012f, 0.83872549019607845f, 0.83872545390933451f, 1.0f}, -{0.75337000925236219f, 0.84215686274509804f, 0.84215682723041252f, 1.0f}, -{0.75873153079035438f, 0.84558823529411764f, 0.84558820055149053f, 1.0f}, -{0.76409305232834646f, 0.84901960784313724f, 0.84901957387256854f, 1.0f}, -{0.76945457386633842f, 0.85245098039215672f, 0.85245094719364634f, 1.0f}, -{0.77481609540433072f, 0.85588235294117643f, 0.85588232051472446f, 1.0f}, -{0.78017761694232279f, 0.85931372549019613f, 0.85931369383580247f, 1.0f}, -{0.78553913848031498f, 0.86274509803921573f, 0.86274506715688049f, 1.0f}, -{0.79090066001830706f, 0.86617647058823533f, 0.8661764404779585f, 1.0f}, -{0.79626218155629924f, 0.86960784313725492f, 0.8696078137990364f, 1.0f}, -{0.80162370309429132f, 0.87303921568627452f, 0.87303918712011441f, 1.0f}, -{0.8069852246322835f, 0.87647058823529411f, 0.87647056044119243f, 1.0f}, -{0.81234674617027558f, 0.87990196078431371f, 0.87990193376227044f, 1.0f}, -{0.81770826770826766f, 0.8833333333333333f, 0.88333330708334834f, 1.0f}, -{0.82306978924625984f, 0.8867647058823529f, 0.88676468040442635f, 1.0f}, -{0.82843131078425203f, 0.8901960784313725f, 0.89019605372550437f, 1.0f}, -{0.8337928323222441f, 0.89362745098039209f, 0.89362742704658238f, 1.0f}, -{0.83915435386023618f, 0.8970588235294118f, 0.89705880036766028f, 1.0f}, -{0.84451587539822837f, 0.90049019607843139f, 0.90049017368873829f, 1.0f}, -{0.84987739693622044f, 0.90392156862745099f, 0.90392154700981631f, 1.0f}, -{0.85523891847421241f, 0.90735294117647047f, 0.90735292033089421f, 1.0f}, -{0.8606004400122047f, 0.91078431372549018f, 0.91078429365197233f, 1.0f}, -{0.86596196155019678f, 0.91421568627450978f, 0.91421566697305023f, 1.0f}, -{0.87132348308818897f, 0.91764705882352948f, 0.91764704029412825f, 1.0f}, -{0.87668500462618115f, 0.92107843137254908f, 0.92107841361520626f, 1.0f}, -{0.88204652616417323f, 0.92450980392156867f, 0.92450978693628416f, 1.0f}, -{0.8874080477021653f, 0.92794117647058827f, 0.92794116025736217f, 1.0f}, -{0.89276956924015749f, 0.93137254901960786f, 0.93137253357844019f, 1.0f}, -{0.89813109077814968f, 0.93480392156862746f, 0.9348039068995182f, 1.0f}, -{0.90349261231614175f, 0.93823529411764706f, 0.93823528022059621f, 1.0f}, -{0.90885413385413383f, 0.94166666666666665f, 0.94166665354167423f, 1.0f}, -{0.91421565539212601f, 0.94509803921568625f, 0.94509802686275224f, 1.0f}, -{0.9195771769301182f, 0.94852941176470584f, 0.94852940018383025f, 1.0f}, -{0.92493869846811028f, 0.95196078431372544f, 0.95196077350490804f, 1.0f}, -{0.93030022000610235f, 0.95539215686274503f, 0.95539214682598605f, 1.0f}, -{0.93566174154409443f, 0.95882352941176474f, 0.95882352014706407f, 1.0f}, -{0.9410232630820865f, 0.96225490196078423f, 0.96225489346814208f, 1.0f}, -{0.9463847846200788f, 0.96568627450980393f, 0.96568626678922009f, 1.0f}, -{0.95174630615807088f, 0.96911764705882353f, 0.96911764011029811f, 1.0f}, -{0.95710782769606295f, 0.97254901960784312f, 0.97254901343137612f, 1.0f}, -{0.96246934923405514f, 0.97598039215686272f, 0.97598038675245413f, 1.0f}, -{0.96783087077204721f, 0.97941176470588232f, 0.97941176007353192f, 1.0f}, -{0.9731923923100394f, 0.98284313725490202f, 0.98284313339460994f, 1.0f}, -{0.97855391384803148f, 0.98627450980392162f, 0.98627450671568795f, 1.0f}, -{0.98391543538602355f, 0.98970588235294121f, 0.98970588003676596f, 1.0f}, -{0.98927695692401574f, 0.99313725490196081f, 0.99313725335784397f, 1.0f}, -{0.99463847846200792f, 0.9965686274509804f, 0.99656862667892199f, 1.0f}, -{1.0f, 1.0f, 1.0f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential2/bone.txt b/extern/tfn/colormaps/sequential2/bone.txt deleted file mode 100644 index 3f673ed..0000000 --- a/extern/tfn/colormaps/sequential2/bone.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.0, 0.0, 0.0, 1.0) -(0.0034313725490196078, 0.0034313712063072676, 0.0047740835464620632, 1.0) -(0.0068627450980392156, 0.0068627424126145352, 0.0095481670929241265, 1.0) -(0.010294117647058823, 0.010294113618921803, 0.01432225063938619, 1.0) -(0.013725490196078431, 0.01372548482522907, 0.019096334185848253, 1.0) -(0.017156862745098041, 0.017156856031536338, 0.023870417732310314, 1.0) -(0.020588235294117647, 0.020588227237843607, 0.028644501278772379, 1.0) -(0.024019607843137256, 0.024019598444150872, 0.033418584825234438, 1.0) -(0.027450980392156862, 0.027450969650458141, 0.038192668371696506, 1.0) -(0.030882352941176472, 0.030882340856765406, 0.042966751918158567, 1.0) -(0.034313725490196081, 0.034313712063072675, 0.047740835464620629, 1.0) -(0.037745098039215684, 0.037745083269379948, 0.052514919011082697, 1.0) -(0.041176470588235294, 0.041176454475687213, 0.057289002557544759, 1.0) -(0.044607843137254903, 0.044607825681994479, 0.062063086104006814, 1.0) -(0.048039215686274513, 0.048039196888301744, 0.066837169650468875, 1.0) -(0.051470588235294115, 0.051470568094609016, 0.071611253196930943, 1.0) -(0.054901960784313725, 0.054901939300916282, 0.076385336743393012, 1.0) -(0.058333333333333334, 0.058333310507223554, 0.08115942028985508, 1.0) -(0.061764705882352944, 0.061764681713530813, 0.085933503836317135, 1.0) -(0.065196078431372553, 0.065196052919838085, 0.09070758738277919, 1.0) -(0.068627450980392163, 0.06862742412614535, 0.095481670929241258, 1.0) -(0.072058823529411759, 0.07205879533245263, 0.10025575447570333, 1.0) -(0.075490196078431368, 0.075490166538759895, 0.10502983802216539, 1.0) -(0.078921568627450978, 0.078921537745067147, 0.10980392156862745, 1.0) -(0.082352941176470587, 0.082352908951374426, 0.11457800511508952, 1.0) -(0.085784313725490183, 0.085784280157681678, 0.11935208866155156, 1.0) -(0.089215686274509806, 0.089215651363988957, 0.12412617220801363, 1.0) -(0.092647058823529402, 0.092647022570296222, 0.1289002557544757, 1.0) -(0.096078431372549025, 0.096078393776603488, 0.13367433930093775, 1.0) -(0.099509803921568621, 0.099509764982910767, 0.13844842284739983, 1.0) -(0.10294117647058823, 0.10294113618921803, 0.14322250639386189, 1.0) -(0.10637254901960784, 0.1063725073955253, 0.14799658994032397, 1.0) -(0.10980392156862745, 0.10980387860183256, 0.15277067348678602, 1.0) -(0.11323529411764703, 0.1132352498081398, 0.15754475703324805, 1.0) -(0.11666666666666667, 0.11666662101444711, 0.16231884057971016, 1.0) -(0.12009803921568628, 0.12009799222075436, 0.16709292412617219, 1.0) -(0.12352941176470589, 0.12352936342706163, 0.17186700767263427, 1.0) -(0.12696078431372546, 0.12696073463336888, 0.1766410912190963, 1.0) -(0.13039215686274511, 0.13039210583967617, 0.18141517476555838, 1.0) -(0.1338235294117647, 0.13382347704598344, 0.18618925831202046, 1.0) -(0.13725490196078433, 0.1372548482522907, 0.19096334185848252, 1.0) -(0.14068627450980389, 0.14068621945859794, 0.19573742540494454, 1.0) -(0.14411764705882352, 0.14411759066490526, 0.20051150895140665, 1.0) -(0.14754901960784314, 0.14754896187121253, 0.20528559249786871, 1.0) -(0.15098039215686274, 0.15098033307751979, 0.21005967604433079, 1.0) -(0.15441176470588233, 0.15441170428382703, 0.21483375959079279, 1.0) -(0.15784313725490196, 0.15784307549013429, 0.2196078431372549, 1.0) -(0.16127450980392158, 0.16127444669644159, 0.22438192668371695, 1.0) -(0.16470588235294117, 0.16470581790274885, 0.22915601023017904, 1.0) -(0.16813725490196074, 0.16813718910905609, 0.23393009377664103, 1.0) -(0.17156862745098037, 0.17156856031536336, 0.23870417732310312, 1.0) -(0.17500000000000002, 0.17499993152167065, 0.24347826086956523, 1.0) -(0.17843137254901961, 0.17843130272797791, 0.24825234441602725, 1.0) -(0.18186274509803918, 0.18186267393428515, 0.25302642796248931, 1.0) -(0.1852941176470588, 0.18529404514059244, 0.25780051150895139, 1.0) -(0.18872549019607843, 0.18872541634689974, 0.26257459505541347, 1.0) -(0.19215686274509805, 0.19215678755320698, 0.2673486786018755, 1.0) -(0.19558823529411762, 0.19558815875951424, 0.27212276214833758, 1.0) -(0.19901960784313724, 0.19901952996582153, 0.27689684569479966, 1.0) -(0.20245098039215687, 0.2024509011721288, 0.28167092924126175, 1.0) -(0.20588235294117646, 0.20588227237843607, 0.28644501278772377, 1.0) -(0.20931372549019606, 0.2093136435847433, 0.2912190963341858, 1.0) -(0.21274509803921568, 0.2127450147910506, 0.29599317988064794, 1.0) -(0.21617647058823528, 0.21617638599735786, 0.30076726342710997, 1.0) -(0.2196078431372549, 0.21960775720366513, 0.30554134697357205, 1.0) -(0.22303921568627449, 0.22303912840997239, 0.31031543052003407, 1.0) -(0.22647058823529406, 0.2264704996162796, 0.3150895140664961, 1.0) -(0.22990196078431371, 0.22990187082258692, 0.31986359761295824, 1.0) -(0.23333333333333334, 0.23333324202889422, 0.32463768115942032, 1.0) -(0.23676470588235293, 0.23676461323520148, 0.32941176470588235, 1.0) -(0.24019607843137256, 0.24019598444150872, 0.33418584825234438, 1.0) -(0.24362745098039215, 0.24362735564781601, 0.33895993179880646, 1.0) -(0.24705882352941178, 0.24705872685412325, 0.34373401534526854, 1.0) -(0.25049019607843137, 0.25049009806043054, 0.34850809889173062, 1.0) -(0.25392156862745091, 0.25392146926673775, 0.35328218243819259, 1.0) -(0.25735294117647062, 0.25735284047304507, 0.35805626598465473, 1.0) -(0.26078431372549021, 0.26078421167935234, 0.36283034953111676, 1.0) -(0.26421568627450981, 0.26421558288565961, 0.3676044330775789, 1.0) -(0.2676470588235294, 0.26764695409196687, 0.37237851662404092, 1.0) -(0.271078431372549, 0.27107832529827414, 0.37715260017050295, 1.0) -(0.27450980392156865, 0.2745096965045814, 0.38192668371696503, 1.0) -(0.27794117647058825, 0.27794106771088867, 0.38670076726342706, 1.0) -(0.28137254901960779, 0.28137243891719588, 0.39147485080988909, 1.0) -(0.28480392156862744, 0.2848038101235032, 0.39624893435635122, 1.0) -(0.28823529411764703, 0.28823518132981052, 0.40102301790281331, 1.0) -(0.29166666666666669, 0.29166655253611773, 0.40579710144927533, 1.0) -(0.29509803921568628, 0.29509792374242505, 0.41057118499573741, 1.0) -(0.29852941176470588, 0.29852929494873226, 0.4153452685421995, 1.0) -(0.30196078431372547, 0.30196066615503958, 0.42011935208866158, 1.0) -(0.30539215686274507, 0.30539203736134685, 0.42489343563512361, 1.0) -(0.30882352941176466, 0.30882340856765406, 0.42966751918158558, 1.0) -(0.31225490196078431, 0.31225477977396138, 0.43444160272804772, 1.0) -(0.31568627450980391, 0.31568615098026859, 0.4392156862745098, 1.0) -(0.31911764705882351, 0.31911752218657591, 0.44398976982097188, 1.0) -(0.32254901960784316, 0.32371322935807584, 0.44754889530644404, 1.0) -(0.32598039215686275, 0.32843136580875115, 0.450980268627522, 1.0) -(0.32941176470588235, 0.33314950225942647, 0.45441164194860001, 1.0) -(0.33284313725490194, 0.33786763871010178, 0.45784301526967797, 1.0) -(0.33627450980392148, 0.34258577516077704, 0.46127438859075592, 1.0) -(0.33970588235294114, 0.34730391161145246, 0.46470576191183394, 1.0) -(0.34313725490196073, 0.35202204806212778, 0.46813713523291195, 1.0) -(0.34656862745098033, 0.35674018451280309, 0.47156850855398991, 1.0) -(0.35000000000000003, 0.36145832096347841, 0.47499988187506792, 1.0) -(0.35343137254901963, 0.36617645741415378, 0.47843125519614593, 1.0) -(0.35686274509803922, 0.37089459386482909, 0.48186262851722389, 1.0) -(0.36029411764705882, 0.37561273031550441, 0.48529400183830185, 1.0) -(0.36372549019607836, 0.38033086676617966, 0.4887253751593798, 1.0) -(0.36715686274509801, 0.38504900321685509, 0.49215674848045787, 1.0) -(0.37058823529411761, 0.3897671396675304, 0.49558812180153583, 1.0) -(0.3740196078431372, 0.39448527611820572, 0.49901949512261384, 1.0) -(0.37745098039215685, 0.39920341256888103, 0.5024508684436918, 1.0) -(0.38088235294117651, 0.40392154901955635, 0.50588224176476981, 1.0) -(0.3843137254901961, 0.40863968547023166, 0.50931361508584783, 1.0) -(0.3877450980392157, 0.41335782192090703, 0.51274498840692573, 1.0) -(0.39117647058823524, 0.41807595837158229, 0.51617636172800374, 1.0) -(0.39460784313725489, 0.42279409482225766, 0.51960773504908175, 1.0) -(0.39803921568627448, 0.42751223127293303, 0.52303910837015977, 1.0) -(0.40147058823529408, 0.43223036772360834, 0.52647048169123767, 1.0) -(0.40490196078431373, 0.43694850417428366, 0.52990185501231568, 1.0) -(0.40833333333333333, 0.44166664062495897, 0.53333322833339369, 1.0) -(0.41176470588235292, 0.44638477707563429, 0.53676460165447171, 1.0) -(0.41519607843137257, 0.45110291352630966, 0.54019597497554972, 1.0) -(0.41862745098039211, 0.45582104997698492, 0.54362734829662762, 1.0) -(0.42205882352941176, 0.46053918642766029, 0.54705872161770563, 1.0) -(0.42549019607843136, 0.46525732287833566, 0.55049009493878365, 1.0) -(0.42892156862745096, 0.46997545932901097, 0.55392146825986166, 1.0) -(0.43235294117647055, 0.47469359577968628, 0.55735284158093967, 1.0) -(0.4357843137254902, 0.4794117322303616, 0.56078421490201757, 1.0) -(0.4392156862745098, 0.48412986868103691, 0.56421558822309559, 1.0) -(0.44264705882352939, 0.48884800513171223, 0.5676469615441736, 1.0) -(0.44607843137254899, 0.49356614158238754, 0.5710783348652515, 1.0) -(0.44950980392156864, 0.49828427803306286, 0.57450970818632952, 1.0) -(0.45294117647058812, 0.50300241448373806, 0.57794108150740742, 1.0) -(0.45637254901960783, 0.50772055093441359, 0.58137245482848554, 1.0) -(0.45980392156862743, 0.5124386873850888, 0.58480382814956355, 1.0) -(0.46323529411764708, 0.51715682383576422, 0.58823520147064146, 1.0) -(0.46666666666666667, 0.52187496028643954, 0.59166657479171947, 1.0) -(0.47009803921568627, 0.52659309673711485, 0.59509794811279748, 1.0) -(0.47352941176470587, 0.53131123318779017, 0.59852932143387549, 1.0) -(0.47696078431372546, 0.53602936963846548, 0.6019606947549534, 1.0) -(0.48039215686274511, 0.54074750608914091, 0.60539206807603141, 1.0) -(0.48382352941176471, 0.54546564253981611, 0.60882344139710942, 1.0) -(0.4872549019607843, 0.55018377899049153, 0.61225481471818743, 1.0) -(0.49068627450980395, 0.55490191544116685, 0.61568618803926545, 1.0) -(0.49411764705882355, 0.55962005189184216, 0.61911756136034335, 1.0) -(0.49754901960784315, 0.56433818834251748, 0.62254893468142136, 1.0) -(0.50098039215686274, 0.56905632479319279, 0.62598030800249937, 1.0) -(0.50441176470588234, 0.57377446124386822, 0.62941168132357739, 1.0) -(0.50784313725490182, 0.57849259769454331, 0.63284305464465529, 1.0) -(0.51127450980392153, 0.58321073414521873, 0.6362744279657333, 1.0) -(0.51470588235294124, 0.58792887059589405, 0.63970580128681132, 1.0) -(0.51813725490196083, 0.59264700704656947, 0.64313717460788933, 1.0) -(0.52156862745098043, 0.59736514349724468, 0.64656854792896723, 1.0) -(0.52500000000000002, 0.6020832799479201, 0.64999992125004524, 1.0) -(0.52843137254901962, 0.60680141639859542, 0.65343129457112326, 1.0) -(0.53186274509803921, 0.61151955284927073, 0.65686266789220127, 1.0) -(0.53529411764705881, 0.61623768929994616, 0.66029404121327917, 1.0) -(0.5387254901960784, 0.62095582575062136, 0.66372541453435718, 1.0) -(0.542156862745098, 0.62567396220129667, 0.6671567878554352, 1.0) -(0.54558823529411771, 0.63039209865197199, 0.67058816117651321, 1.0) -(0.5490196078431373, 0.63511023510264741, 0.67401953449759122, 1.0) -(0.5524509803921569, 0.63982837155332262, 0.67745090781866912, 1.0) -(0.55588235294117649, 0.64454650800399804, 0.68088228113974714, 1.0) -(0.55931372549019609, 0.64926464445467336, 0.68431365446082515, 1.0) -(0.56274509803921557, 0.65398278090534856, 0.68774502778190305, 1.0) -(0.56617647058823528, 0.6587009173560241, 0.69117640110298106, 1.0) -(0.56960784313725488, 0.6634190538066993, 0.69460777442405908, 1.0) -(0.57303921568627447, 0.66813719025737461, 0.69803914774513709, 1.0) -(0.57647058823529407, 0.67285532670804993, 0.7014705210662151, 1.0) -(0.57990196078431377, 0.67757346315872535, 0.70490189438729312, 1.0) -(0.58333333333333337, 0.68229159960940056, 0.70833326770837102, 1.0) -(0.58676470588235297, 0.68700973606007598, 0.71176464102944903, 1.0) -(0.59019607843137256, 0.6917278725107513, 0.71519601435052693, 1.0) -(0.59362745098039216, 0.69644600896142661, 0.71862738767160494, 1.0) -(0.59705882352941175, 0.70116414541210192, 0.72205876099268296, 1.0) -(0.60049019607843135, 0.70588228186277724, 0.72549013431376097, 1.0) -(0.60392156862745094, 0.71060041831345255, 0.72892150763483898, 1.0) -(0.60735294117647054, 0.71531855476412787, 0.732352880955917, 1.0) -(0.61078431372549014, 0.72003669121480329, 0.73578425427699501, 1.0) -(0.61421568627450984, 0.7247548276654785, 0.73921562759807302, 1.0) -(0.61764705882352933, 0.7294729641161537, 0.74264700091915081, 1.0) -(0.62107843137254903, 0.73419110056682924, 0.74607837424022883, 1.0) -(0.62450980392156863, 0.73890923701750455, 0.74950974756130684, 1.0) -(0.62794117647058822, 0.74362737346817986, 0.75294112088238485, 1.0) -(0.63137254901960782, 0.74834550991885518, 0.75637249420346286, 1.0) -(0.63480392156862742, 0.7530636463695306, 0.75980386752454088, 1.0) -(0.63823529411764701, 0.75778178282020581, 0.76323524084561889, 1.0) -(0.64166666666666661, 0.76249991927088123, 0.7666666141666969, 1.0) -(0.64509803921568631, 0.76721805572155655, 0.7700979874877748, 1.0) -(0.64852941176470591, 0.77193619217223186, 0.77352936080885282, 1.0) -(0.65196078431372551, 0.77665432862290718, 0.77696073412993072, 1.0) -(0.65686262156850395, 0.7803921568627451, 0.78039210745100873, 1.0) -(0.66222414310649602, 0.7838235294117647, 0.78382348077208674, 1.0) -(0.66758566464448821, 0.78725490196078429, 0.78725485409316476, 1.0) -(0.67294718618248028, 0.79068627450980389, 0.79068622741424277, 1.0) -(0.67830870772047247, 0.79411764705882348, 0.79411760073532078, 1.0) -(0.68367022925846443, 0.79754901960784308, 0.79754897405639857, 1.0) -(0.68903175079645673, 0.80098039215686279, 0.8009803473774767, 1.0) -(0.69439327233444881, 0.80441176470588238, 0.80441172069855471, 1.0) -(0.69975479387244088, 0.80784313725490198, 0.80784309401963261, 1.0) -(0.70511631541043307, 0.81127450980392157, 0.81127446734071063, 1.0) -(0.71047783694842515, 0.81470588235294117, 0.81470584066178864, 1.0) -(0.71583935848641733, 0.81813725490196076, 0.81813721398286665, 1.0) -(0.72120088002440941, 0.82156862745098036, 0.82156858730394466, 1.0) -(0.72656240156240159, 0.82499999999999996, 0.82499996062502257, 1.0) -(0.73192392310039367, 0.82843137254901955, 0.82843133394610058, 1.0) -(0.73728544463838586, 0.83186274509803926, 0.83186270726717859, 1.0) -(0.74264696617637793, 0.83529411764705885, 0.8352940805882566, 1.0) -(0.74800848771437012, 0.83872549019607845, 0.83872545390933451, 1.0) -(0.75337000925236219, 0.84215686274509804, 0.84215682723041252, 1.0) -(0.75873153079035438, 0.84558823529411764, 0.84558820055149053, 1.0) -(0.76409305232834646, 0.84901960784313724, 0.84901957387256854, 1.0) -(0.76945457386633842, 0.85245098039215672, 0.85245094719364634, 1.0) -(0.77481609540433072, 0.85588235294117643, 0.85588232051472446, 1.0) -(0.78017761694232279, 0.85931372549019613, 0.85931369383580247, 1.0) -(0.78553913848031498, 0.86274509803921573, 0.86274506715688049, 1.0) -(0.79090066001830706, 0.86617647058823533, 0.8661764404779585, 1.0) -(0.79626218155629924, 0.86960784313725492, 0.8696078137990364, 1.0) -(0.80162370309429132, 0.87303921568627452, 0.87303918712011441, 1.0) -(0.8069852246322835, 0.87647058823529411, 0.87647056044119243, 1.0) -(0.81234674617027558, 0.87990196078431371, 0.87990193376227044, 1.0) -(0.81770826770826766, 0.8833333333333333, 0.88333330708334834, 1.0) -(0.82306978924625984, 0.8867647058823529, 0.88676468040442635, 1.0) -(0.82843131078425203, 0.8901960784313725, 0.89019605372550437, 1.0) -(0.8337928323222441, 0.89362745098039209, 0.89362742704658238, 1.0) -(0.83915435386023618, 0.8970588235294118, 0.89705880036766028, 1.0) -(0.84451587539822837, 0.90049019607843139, 0.90049017368873829, 1.0) -(0.84987739693622044, 0.90392156862745099, 0.90392154700981631, 1.0) -(0.85523891847421241, 0.90735294117647047, 0.90735292033089421, 1.0) -(0.8606004400122047, 0.91078431372549018, 0.91078429365197233, 1.0) -(0.86596196155019678, 0.91421568627450978, 0.91421566697305023, 1.0) -(0.87132348308818897, 0.91764705882352948, 0.91764704029412825, 1.0) -(0.87668500462618115, 0.92107843137254908, 0.92107841361520626, 1.0) -(0.88204652616417323, 0.92450980392156867, 0.92450978693628416, 1.0) -(0.8874080477021653, 0.92794117647058827, 0.92794116025736217, 1.0) -(0.89276956924015749, 0.93137254901960786, 0.93137253357844019, 1.0) -(0.89813109077814968, 0.93480392156862746, 0.9348039068995182, 1.0) -(0.90349261231614175, 0.93823529411764706, 0.93823528022059621, 1.0) -(0.90885413385413383, 0.94166666666666665, 0.94166665354167423, 1.0) -(0.91421565539212601, 0.94509803921568625, 0.94509802686275224, 1.0) -(0.9195771769301182, 0.94852941176470584, 0.94852940018383025, 1.0) -(0.92493869846811028, 0.95196078431372544, 0.95196077350490804, 1.0) -(0.93030022000610235, 0.95539215686274503, 0.95539214682598605, 1.0) -(0.93566174154409443, 0.95882352941176474, 0.95882352014706407, 1.0) -(0.9410232630820865, 0.96225490196078423, 0.96225489346814208, 1.0) -(0.9463847846200788, 0.96568627450980393, 0.96568626678922009, 1.0) -(0.95174630615807088, 0.96911764705882353, 0.96911764011029811, 1.0) -(0.95710782769606295, 0.97254901960784312, 0.97254901343137612, 1.0) -(0.96246934923405514, 0.97598039215686272, 0.97598038675245413, 1.0) -(0.96783087077204721, 0.97941176470588232, 0.97941176007353192, 1.0) -(0.9731923923100394, 0.98284313725490202, 0.98284313339460994, 1.0) -(0.97855391384803148, 0.98627450980392162, 0.98627450671568795, 1.0) -(0.98391543538602355, 0.98970588235294121, 0.98970588003676596, 1.0) -(0.98927695692401574, 0.99313725490196081, 0.99313725335784397, 1.0) -(0.99463847846200792, 0.9965686274509804, 0.99656862667892199, 1.0) -(1.0, 1.0, 1.0, 1.0) diff --git a/extern/tfn/colormaps/sequential2/cool.cpp b/extern/tfn/colormaps/sequential2/cool.cpp deleted file mode 100644 index 10148c7..0000000 --- a/extern/tfn/colormaps/sequential2/cool.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential2_cool; -} -const std::vector colormap::data_sequential2_cool = /* NOLINT(cert-err58-cpp) */ -{ -{0.0f, 1.0f, 1.0f, 1.0f}, -{0.0039215686274509803f, 0.99607843137254903f, 1.0f, 1.0f}, -{0.0078431372549019607f, 0.99215686274509807f, 1.0f, 1.0f}, -{0.011764705882352941f, 0.9882352941176471f, 1.0f, 1.0f}, -{0.015686274509803921f, 0.98431372549019613f, 1.0f, 1.0f}, -{0.019607843137254902f, 0.98039215686274506f, 1.0f, 1.0f}, -{0.023529411764705882f, 0.97647058823529409f, 1.0f, 1.0f}, -{0.027450980392156862f, 0.97254901960784312f, 1.0f, 1.0f}, -{0.031372549019607843f, 0.96862745098039216f, 1.0f, 1.0f}, -{0.035294117647058823f, 0.96470588235294119f, 1.0f, 1.0f}, -{0.039215686274509803f, 0.96078431372549022f, 1.0f, 1.0f}, -{0.043137254901960784f, 0.95686274509803926f, 1.0f, 1.0f}, -{0.047058823529411764f, 0.95294117647058818f, 1.0f, 1.0f}, -{0.050980392156862744f, 0.94901960784313721f, 1.0f, 1.0f}, -{0.054901960784313725f, 0.94509803921568625f, 1.0f, 1.0f}, -{0.058823529411764705f, 0.94117647058823528f, 1.0f, 1.0f}, -{0.062745098039215685f, 0.93725490196078431f, 1.0f, 1.0f}, -{0.066666666666666666f, 0.93333333333333335f, 1.0f, 1.0f}, -{0.070588235294117646f, 0.92941176470588238f, 1.0f, 1.0f}, -{0.074509803921568626f, 0.92549019607843142f, 1.0f, 1.0f}, -{0.078431372549019607f, 0.92156862745098045f, 1.0f, 1.0f}, -{0.082352941176470587f, 0.91764705882352937f, 1.0f, 1.0f}, -{0.086274509803921567f, 0.9137254901960784f, 1.0f, 1.0f}, -{0.090196078431372548f, 0.90980392156862744f, 1.0f, 1.0f}, -{0.094117647058823528f, 0.90588235294117647f, 1.0f, 1.0f}, -{0.098039215686274508f, 0.90196078431372551f, 1.0f, 1.0f}, -{0.10196078431372549f, 0.89803921568627454f, 1.0f, 1.0f}, -{0.10588235294117647f, 0.89411764705882357f, 1.0f, 1.0f}, -{0.10980392156862745f, 0.8901960784313725f, 1.0f, 1.0f}, -{0.11372549019607843f, 0.88627450980392153f, 1.0f, 1.0f}, -{0.11764705882352941f, 0.88235294117647056f, 1.0f, 1.0f}, -{0.12156862745098039f, 0.8784313725490196f, 1.0f, 1.0f}, -{0.12549019607843137f, 0.87450980392156863f, 1.0f, 1.0f}, -{0.12941176470588234f, 0.87058823529411766f, 1.0f, 1.0f}, -{0.13333333333333333f, 0.8666666666666667f, 1.0f, 1.0f}, -{0.13725490196078433f, 0.86274509803921573f, 1.0f, 1.0f}, -{0.14117647058823529f, 0.85882352941176476f, 1.0f, 1.0f}, -{0.14509803921568626f, 0.8549019607843138f, 1.0f, 1.0f}, -{0.14901960784313725f, 0.85098039215686272f, 1.0f, 1.0f}, -{0.15294117647058825f, 0.84705882352941175f, 1.0f, 1.0f}, -{0.15686274509803921f, 0.84313725490196079f, 1.0f, 1.0f}, -{0.16078431372549018f, 0.83921568627450982f, 1.0f, 1.0f}, -{0.16470588235294117f, 0.83529411764705885f, 1.0f, 1.0f}, -{0.16862745098039217f, 0.83137254901960778f, 1.0f, 1.0f}, -{0.17254901960784313f, 0.82745098039215681f, 1.0f, 1.0f}, -{0.1764705882352941f, 0.82352941176470584f, 1.0f, 1.0f}, -{0.1803921568627451f, 0.81960784313725488f, 1.0f, 1.0f}, -{0.18431372549019609f, 0.81568627450980391f, 1.0f, 1.0f}, -{0.18823529411764706f, 0.81176470588235294f, 1.0f, 1.0f}, -{0.19215686274509802f, 0.80784313725490198f, 1.0f, 1.0f}, -{0.19607843137254902f, 0.80392156862745101f, 1.0f, 1.0f}, -{0.20000000000000001f, 0.80000000000000004f, 1.0f, 1.0f}, -{0.20392156862745098f, 0.79607843137254908f, 1.0f, 1.0f}, -{0.20784313725490194f, 0.79215686274509811f, 1.0f, 1.0f}, -{0.21176470588235294f, 0.78823529411764703f, 1.0f, 1.0f}, -{0.21568627450980393f, 0.78431372549019607f, 1.0f, 1.0f}, -{0.2196078431372549f, 0.7803921568627451f, 1.0f, 1.0f}, -{0.22352941176470587f, 0.77647058823529413f, 1.0f, 1.0f}, -{0.22745098039215686f, 0.77254901960784317f, 1.0f, 1.0f}, -{0.23137254901960785f, 0.76862745098039209f, 1.0f, 1.0f}, -{0.23529411764705882f, 0.76470588235294112f, 1.0f, 1.0f}, -{0.23921568627450979f, 0.76078431372549016f, 1.0f, 1.0f}, -{0.24313725490196078f, 0.75686274509803919f, 1.0f, 1.0f}, -{0.24705882352941178f, 0.75294117647058822f, 1.0f, 1.0f}, -{0.25098039215686274f, 0.74901960784313726f, 1.0f, 1.0f}, -{0.25490196078431371f, 0.74509803921568629f, 1.0f, 1.0f}, -{0.25882352941176467f, 0.74117647058823533f, 1.0f, 1.0f}, -{0.2627450980392157f, 0.73725490196078436f, 1.0f, 1.0f}, -{0.26666666666666666f, 0.73333333333333339f, 1.0f, 1.0f}, -{0.27058823529411763f, 0.72941176470588243f, 1.0f, 1.0f}, -{0.27450980392156865f, 0.72549019607843135f, 1.0f, 1.0f}, -{0.27843137254901962f, 0.72156862745098038f, 1.0f, 1.0f}, -{0.28235294117647058f, 0.71764705882352942f, 1.0f, 1.0f}, -{0.28627450980392155f, 0.71372549019607845f, 1.0f, 1.0f}, -{0.29019607843137252f, 0.70980392156862748f, 1.0f, 1.0f}, -{0.29411764705882354f, 0.70588235294117641f, 1.0f, 1.0f}, -{0.29803921568627451f, 0.70196078431372544f, 1.0f, 1.0f}, -{0.30196078431372547f, 0.69803921568627447f, 1.0f, 1.0f}, -{0.30588235294117649f, 0.69411764705882351f, 1.0f, 1.0f}, -{0.30980392156862746f, 0.69019607843137254f, 1.0f, 1.0f}, -{0.31372549019607843f, 0.68627450980392157f, 1.0f, 1.0f}, -{0.31764705882352939f, 0.68235294117647061f, 1.0f, 1.0f}, -{0.32156862745098036f, 0.67843137254901964f, 1.0f, 1.0f}, -{0.32549019607843138f, 0.67450980392156867f, 1.0f, 1.0f}, -{0.32941176470588235f, 0.67058823529411771f, 1.0f, 1.0f}, -{0.33333333333333331f, 0.66666666666666674f, 1.0f, 1.0f}, -{0.33725490196078434f, 0.66274509803921566f, 1.0f, 1.0f}, -{0.3411764705882353f, 0.6588235294117647f, 1.0f, 1.0f}, -{0.34509803921568627f, 0.65490196078431373f, 1.0f, 1.0f}, -{0.34901960784313724f, 0.65098039215686276f, 1.0f, 1.0f}, -{0.3529411764705882f, 0.6470588235294118f, 1.0f, 1.0f}, -{0.35686274509803922f, 0.64313725490196072f, 1.0f, 1.0f}, -{0.36078431372549019f, 0.63921568627450975f, 1.0f, 1.0f}, -{0.36470588235294116f, 0.63529411764705879f, 1.0f, 1.0f}, -{0.36862745098039218f, 0.63137254901960782f, 1.0f, 1.0f}, -{0.37254901960784315f, 0.62745098039215685f, 1.0f, 1.0f}, -{0.37647058823529411f, 0.62352941176470589f, 1.0f, 1.0f}, -{0.38039215686274508f, 0.61960784313725492f, 1.0f, 1.0f}, -{0.38431372549019605f, 0.61568627450980395f, 1.0f, 1.0f}, -{0.38823529411764707f, 0.61176470588235299f, 1.0f, 1.0f}, -{0.39215686274509803f, 0.60784313725490202f, 1.0f, 1.0f}, -{0.396078431372549f, 0.60392156862745106f, 1.0f, 1.0f}, -{0.40000000000000002f, 0.59999999999999998f, 1.0f, 1.0f}, -{0.40392156862745099f, 0.59607843137254901f, 1.0f, 1.0f}, -{0.40784313725490196f, 0.59215686274509804f, 1.0f, 1.0f}, -{0.41176470588235292f, 0.58823529411764708f, 1.0f, 1.0f}, -{0.41568627450980389f, 0.58431372549019611f, 1.0f, 1.0f}, -{0.41960784313725491f, 0.58039215686274503f, 1.0f, 1.0f}, -{0.42352941176470588f, 0.57647058823529407f, 1.0f, 1.0f}, -{0.42745098039215684f, 0.5725490196078431f, 1.0f, 1.0f}, -{0.43137254901960786f, 0.56862745098039214f, 1.0f, 1.0f}, -{0.43529411764705883f, 0.56470588235294117f, 1.0f, 1.0f}, -{0.4392156862745098f, 0.5607843137254902f, 1.0f, 1.0f}, -{0.44313725490196076f, 0.55686274509803924f, 1.0f, 1.0f}, -{0.44705882352941173f, 0.55294117647058827f, 1.0f, 1.0f}, -{0.45098039215686275f, 0.5490196078431373f, 1.0f, 1.0f}, -{0.45490196078431372f, 0.54509803921568634f, 1.0f, 1.0f}, -{0.45882352941176469f, 0.54117647058823537f, 1.0f, 1.0f}, -{0.46274509803921571f, 0.53725490196078429f, 1.0f, 1.0f}, -{0.46666666666666667f, 0.53333333333333333f, 1.0f, 1.0f}, -{0.47058823529411764f, 0.52941176470588236f, 1.0f, 1.0f}, -{0.47450980392156861f, 0.52549019607843139f, 1.0f, 1.0f}, -{0.47843137254901957f, 0.52156862745098043f, 1.0f, 1.0f}, -{0.4823529411764706f, 0.51764705882352935f, 1.0f, 1.0f}, -{0.48627450980392156f, 0.51372549019607838f, 1.0f, 1.0f}, -{0.49019607843137253f, 0.50980392156862742f, 1.0f, 1.0f}, -{0.49411764705882355f, 0.50588235294117645f, 1.0f, 1.0f}, -{0.49803921568627452f, 0.50196078431372548f, 1.0f, 1.0f}, -{0.50196078431372548f, 0.49803921568627452f, 1.0f, 1.0f}, -{0.50588235294117645f, 0.49411764705882355f, 1.0f, 1.0f}, -{0.50980392156862742f, 0.49019607843137258f, 1.0f, 1.0f}, -{0.51372549019607838f, 0.48627450980392162f, 1.0f, 1.0f}, -{0.51764705882352935f, 0.48235294117647065f, 1.0f, 1.0f}, -{0.52156862745098043f, 0.47843137254901957f, 1.0f, 1.0f}, -{0.52549019607843139f, 0.47450980392156861f, 1.0f, 1.0f}, -{0.52941176470588236f, 0.47058823529411764f, 1.0f, 1.0f}, -{0.53333333333333333f, 0.46666666666666667f, 1.0f, 1.0f}, -{0.53725490196078429f, 0.46274509803921571f, 1.0f, 1.0f}, -{0.54117647058823526f, 0.45882352941176474f, 1.0f, 1.0f}, -{0.54509803921568623f, 0.45490196078431377f, 1.0f, 1.0f}, -{0.5490196078431373f, 0.4509803921568627f, 1.0f, 1.0f}, -{0.55294117647058827f, 0.44705882352941173f, 1.0f, 1.0f}, -{0.55686274509803924f, 0.44313725490196076f, 1.0f, 1.0f}, -{0.5607843137254902f, 0.4392156862745098f, 1.0f, 1.0f}, -{0.56470588235294117f, 0.43529411764705883f, 1.0f, 1.0f}, -{0.56862745098039214f, 0.43137254901960786f, 1.0f, 1.0f}, -{0.5725490196078431f, 0.4274509803921569f, 1.0f, 1.0f}, -{0.57647058823529407f, 0.42352941176470593f, 1.0f, 1.0f}, -{0.58039215686274503f, 0.41960784313725497f, 1.0f, 1.0f}, -{0.58431372549019611f, 0.41568627450980389f, 1.0f, 1.0f}, -{0.58823529411764708f, 0.41176470588235292f, 1.0f, 1.0f}, -{0.59215686274509804f, 0.40784313725490196f, 1.0f, 1.0f}, -{0.59607843137254901f, 0.40392156862745099f, 1.0f, 1.0f}, -{0.59999999999999998f, 0.40000000000000002f, 1.0f, 1.0f}, -{0.60392156862745094f, 0.39607843137254906f, 1.0f, 1.0f}, -{0.60784313725490191f, 0.39215686274509809f, 1.0f, 1.0f}, -{0.61176470588235299f, 0.38823529411764701f, 1.0f, 1.0f}, -{0.61568627450980395f, 0.38431372549019605f, 1.0f, 1.0f}, -{0.61960784313725492f, 0.38039215686274508f, 1.0f, 1.0f}, -{0.62352941176470589f, 0.37647058823529411f, 1.0f, 1.0f}, -{0.62745098039215685f, 0.37254901960784315f, 1.0f, 1.0f}, -{0.63137254901960782f, 0.36862745098039218f, 1.0f, 1.0f}, -{0.63529411764705879f, 0.36470588235294121f, 1.0f, 1.0f}, -{0.63921568627450975f, 0.36078431372549025f, 1.0f, 1.0f}, -{0.64313725490196072f, 0.35686274509803928f, 1.0f, 1.0f}, -{0.6470588235294118f, 0.3529411764705882f, 1.0f, 1.0f}, -{0.65098039215686276f, 0.34901960784313724f, 1.0f, 1.0f}, -{0.65490196078431373f, 0.34509803921568627f, 1.0f, 1.0f}, -{0.6588235294117647f, 0.3411764705882353f, 1.0f, 1.0f}, -{0.66274509803921566f, 0.33725490196078434f, 1.0f, 1.0f}, -{0.66666666666666663f, 0.33333333333333337f, 1.0f, 1.0f}, -{0.6705882352941176f, 0.3294117647058824f, 1.0f, 1.0f}, -{0.67450980392156867f, 0.32549019607843133f, 1.0f, 1.0f}, -{0.67843137254901964f, 0.32156862745098036f, 1.0f, 1.0f}, -{0.68235294117647061f, 0.31764705882352939f, 1.0f, 1.0f}, -{0.68627450980392157f, 0.31372549019607843f, 1.0f, 1.0f}, -{0.69019607843137254f, 0.30980392156862746f, 1.0f, 1.0f}, -{0.69411764705882351f, 0.30588235294117649f, 1.0f, 1.0f}, -{0.69803921568627447f, 0.30196078431372553f, 1.0f, 1.0f}, -{0.70196078431372544f, 0.29803921568627456f, 1.0f, 1.0f}, -{0.70588235294117641f, 0.29411764705882359f, 1.0f, 1.0f}, -{0.70980392156862748f, 0.29019607843137252f, 1.0f, 1.0f}, -{0.71372549019607845f, 0.28627450980392155f, 1.0f, 1.0f}, -{0.71764705882352942f, 0.28235294117647058f, 1.0f, 1.0f}, -{0.72156862745098038f, 0.27843137254901962f, 1.0f, 1.0f}, -{0.72549019607843135f, 0.27450980392156865f, 1.0f, 1.0f}, -{0.72941176470588232f, 0.27058823529411768f, 1.0f, 1.0f}, -{0.73333333333333328f, 0.26666666666666672f, 1.0f, 1.0f}, -{0.73725490196078436f, 0.26274509803921564f, 1.0f, 1.0f}, -{0.74117647058823533f, 0.25882352941176467f, 1.0f, 1.0f}, -{0.74509803921568629f, 0.25490196078431371f, 1.0f, 1.0f}, -{0.74901960784313726f, 0.25098039215686274f, 1.0f, 1.0f}, -{0.75294117647058822f, 0.24705882352941178f, 1.0f, 1.0f}, -{0.75686274509803919f, 0.24313725490196081f, 1.0f, 1.0f}, -{0.76078431372549016f, 0.23921568627450984f, 1.0f, 1.0f}, -{0.76470588235294112f, 0.23529411764705888f, 1.0f, 1.0f}, -{0.76862745098039209f, 0.23137254901960791f, 1.0f, 1.0f}, -{0.77254901960784317f, 0.22745098039215683f, 1.0f, 1.0f}, -{0.77647058823529413f, 0.22352941176470587f, 1.0f, 1.0f}, -{0.7803921568627451f, 0.2196078431372549f, 1.0f, 1.0f}, -{0.78431372549019607f, 0.21568627450980393f, 1.0f, 1.0f}, -{0.78823529411764703f, 0.21176470588235297f, 1.0f, 1.0f}, -{0.792156862745098f, 0.207843137254902f, 1.0f, 1.0f}, -{0.79607843137254897f, 0.20392156862745103f, 1.0f, 1.0f}, -{0.80000000000000004f, 0.19999999999999996f, 1.0f, 1.0f}, -{0.80392156862745101f, 0.19607843137254899f, 1.0f, 1.0f}, -{0.80784313725490198f, 0.19215686274509802f, 1.0f, 1.0f}, -{0.81176470588235294f, 0.18823529411764706f, 1.0f, 1.0f}, -{0.81568627450980391f, 0.18431372549019609f, 1.0f, 1.0f}, -{0.81960784313725488f, 0.18039215686274512f, 1.0f, 1.0f}, -{0.82352941176470584f, 0.17647058823529416f, 1.0f, 1.0f}, -{0.82745098039215681f, 0.17254901960784319f, 1.0f, 1.0f}, -{0.83137254901960778f, 0.16862745098039222f, 1.0f, 1.0f}, -{0.83529411764705885f, 0.16470588235294115f, 1.0f, 1.0f}, -{0.83921568627450982f, 0.16078431372549018f, 1.0f, 1.0f}, -{0.84313725490196079f, 0.15686274509803921f, 1.0f, 1.0f}, -{0.84705882352941175f, 0.15294117647058825f, 1.0f, 1.0f}, -{0.85098039215686272f, 0.14901960784313728f, 1.0f, 1.0f}, -{0.85490196078431369f, 0.14509803921568631f, 1.0f, 1.0f}, -{0.85882352941176465f, 0.14117647058823535f, 1.0f, 1.0f}, -{0.86274509803921573f, 0.13725490196078427f, 1.0f, 1.0f}, -{0.8666666666666667f, 0.1333333333333333f, 1.0f, 1.0f}, -{0.87058823529411766f, 0.12941176470588234f, 1.0f, 1.0f}, -{0.87450980392156863f, 0.12549019607843137f, 1.0f, 1.0f}, -{0.8784313725490196f, 0.1215686274509804f, 1.0f, 1.0f}, -{0.88235294117647056f, 0.11764705882352944f, 1.0f, 1.0f}, -{0.88627450980392153f, 0.11372549019607847f, 1.0f, 1.0f}, -{0.8901960784313725f, 0.1098039215686275f, 1.0f, 1.0f}, -{0.89411764705882346f, 0.10588235294117654f, 1.0f, 1.0f}, -{0.89803921568627454f, 0.10196078431372546f, 1.0f, 1.0f}, -{0.90196078431372551f, 0.098039215686274495f, 1.0f, 1.0f}, -{0.90588235294117647f, 0.094117647058823528f, 1.0f, 1.0f}, -{0.90980392156862744f, 0.090196078431372562f, 1.0f, 1.0f}, -{0.9137254901960784f, 0.086274509803921595f, 1.0f, 1.0f}, -{0.91764705882352937f, 0.082352941176470629f, 1.0f, 1.0f}, -{0.92156862745098034f, 0.078431372549019662f, 1.0f, 1.0f}, -{0.92549019607843142f, 0.074509803921568585f, 1.0f, 1.0f}, -{0.92941176470588238f, 0.070588235294117618f, 1.0f, 1.0f}, -{0.93333333333333335f, 0.066666666666666652f, 1.0f, 1.0f}, -{0.93725490196078431f, 0.062745098039215685f, 1.0f, 1.0f}, -{0.94117647058823528f, 0.058823529411764719f, 1.0f, 1.0f}, -{0.94509803921568625f, 0.054901960784313752f, 1.0f, 1.0f}, -{0.94901960784313721f, 0.050980392156862786f, 1.0f, 1.0f}, -{0.95294117647058818f, 0.04705882352941182f, 1.0f, 1.0f}, -{0.95686274509803915f, 0.043137254901960853f, 1.0f, 1.0f}, -{0.96078431372549022f, 0.039215686274509776f, 1.0f, 1.0f}, -{0.96470588235294119f, 0.035294117647058809f, 1.0f, 1.0f}, -{0.96862745098039216f, 0.031372549019607843f, 1.0f, 1.0f}, -{0.97254901960784312f, 0.027450980392156876f, 1.0f, 1.0f}, -{0.97647058823529409f, 0.02352941176470591f, 1.0f, 1.0f}, -{0.98039215686274506f, 0.019607843137254943f, 1.0f, 1.0f}, -{0.98431372549019602f, 0.015686274509803977f, 1.0f, 1.0f}, -{0.9882352941176471f, 0.011764705882352899f, 1.0f, 1.0f}, -{0.99215686274509807f, 0.0078431372549019329f, 1.0f, 1.0f}, -{0.99607843137254903f, 0.0039215686274509665f, 1.0f, 1.0f}, -{1.0f, 0.0f, 1.0f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential2/cool.txt b/extern/tfn/colormaps/sequential2/cool.txt deleted file mode 100644 index 4544381..0000000 --- a/extern/tfn/colormaps/sequential2/cool.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.0, 1.0, 1.0, 1.0) -(0.0039215686274509803, 0.99607843137254903, 1.0, 1.0) -(0.0078431372549019607, 0.99215686274509807, 1.0, 1.0) -(0.011764705882352941, 0.9882352941176471, 1.0, 1.0) -(0.015686274509803921, 0.98431372549019613, 1.0, 1.0) -(0.019607843137254902, 0.98039215686274506, 1.0, 1.0) -(0.023529411764705882, 0.97647058823529409, 1.0, 1.0) -(0.027450980392156862, 0.97254901960784312, 1.0, 1.0) -(0.031372549019607843, 0.96862745098039216, 1.0, 1.0) -(0.035294117647058823, 0.96470588235294119, 1.0, 1.0) -(0.039215686274509803, 0.96078431372549022, 1.0, 1.0) -(0.043137254901960784, 0.95686274509803926, 1.0, 1.0) -(0.047058823529411764, 0.95294117647058818, 1.0, 1.0) -(0.050980392156862744, 0.94901960784313721, 1.0, 1.0) -(0.054901960784313725, 0.94509803921568625, 1.0, 1.0) -(0.058823529411764705, 0.94117647058823528, 1.0, 1.0) -(0.062745098039215685, 0.93725490196078431, 1.0, 1.0) -(0.066666666666666666, 0.93333333333333335, 1.0, 1.0) -(0.070588235294117646, 0.92941176470588238, 1.0, 1.0) -(0.074509803921568626, 0.92549019607843142, 1.0, 1.0) -(0.078431372549019607, 0.92156862745098045, 1.0, 1.0) -(0.082352941176470587, 0.91764705882352937, 1.0, 1.0) -(0.086274509803921567, 0.9137254901960784, 1.0, 1.0) -(0.090196078431372548, 0.90980392156862744, 1.0, 1.0) -(0.094117647058823528, 0.90588235294117647, 1.0, 1.0) -(0.098039215686274508, 0.90196078431372551, 1.0, 1.0) -(0.10196078431372549, 0.89803921568627454, 1.0, 1.0) -(0.10588235294117647, 0.89411764705882357, 1.0, 1.0) -(0.10980392156862745, 0.8901960784313725, 1.0, 1.0) -(0.11372549019607843, 0.88627450980392153, 1.0, 1.0) -(0.11764705882352941, 0.88235294117647056, 1.0, 1.0) -(0.12156862745098039, 0.8784313725490196, 1.0, 1.0) -(0.12549019607843137, 0.87450980392156863, 1.0, 1.0) -(0.12941176470588234, 0.87058823529411766, 1.0, 1.0) -(0.13333333333333333, 0.8666666666666667, 1.0, 1.0) -(0.13725490196078433, 0.86274509803921573, 1.0, 1.0) -(0.14117647058823529, 0.85882352941176476, 1.0, 1.0) -(0.14509803921568626, 0.8549019607843138, 1.0, 1.0) -(0.14901960784313725, 0.85098039215686272, 1.0, 1.0) -(0.15294117647058825, 0.84705882352941175, 1.0, 1.0) -(0.15686274509803921, 0.84313725490196079, 1.0, 1.0) -(0.16078431372549018, 0.83921568627450982, 1.0, 1.0) -(0.16470588235294117, 0.83529411764705885, 1.0, 1.0) -(0.16862745098039217, 0.83137254901960778, 1.0, 1.0) -(0.17254901960784313, 0.82745098039215681, 1.0, 1.0) -(0.1764705882352941, 0.82352941176470584, 1.0, 1.0) -(0.1803921568627451, 0.81960784313725488, 1.0, 1.0) -(0.18431372549019609, 0.81568627450980391, 1.0, 1.0) -(0.18823529411764706, 0.81176470588235294, 1.0, 1.0) -(0.19215686274509802, 0.80784313725490198, 1.0, 1.0) -(0.19607843137254902, 0.80392156862745101, 1.0, 1.0) -(0.20000000000000001, 0.80000000000000004, 1.0, 1.0) -(0.20392156862745098, 0.79607843137254908, 1.0, 1.0) -(0.20784313725490194, 0.79215686274509811, 1.0, 1.0) -(0.21176470588235294, 0.78823529411764703, 1.0, 1.0) -(0.21568627450980393, 0.78431372549019607, 1.0, 1.0) -(0.2196078431372549, 0.7803921568627451, 1.0, 1.0) -(0.22352941176470587, 0.77647058823529413, 1.0, 1.0) -(0.22745098039215686, 0.77254901960784317, 1.0, 1.0) -(0.23137254901960785, 0.76862745098039209, 1.0, 1.0) -(0.23529411764705882, 0.76470588235294112, 1.0, 1.0) -(0.23921568627450979, 0.76078431372549016, 1.0, 1.0) -(0.24313725490196078, 0.75686274509803919, 1.0, 1.0) -(0.24705882352941178, 0.75294117647058822, 1.0, 1.0) -(0.25098039215686274, 0.74901960784313726, 1.0, 1.0) -(0.25490196078431371, 0.74509803921568629, 1.0, 1.0) -(0.25882352941176467, 0.74117647058823533, 1.0, 1.0) -(0.2627450980392157, 0.73725490196078436, 1.0, 1.0) -(0.26666666666666666, 0.73333333333333339, 1.0, 1.0) -(0.27058823529411763, 0.72941176470588243, 1.0, 1.0) -(0.27450980392156865, 0.72549019607843135, 1.0, 1.0) -(0.27843137254901962, 0.72156862745098038, 1.0, 1.0) -(0.28235294117647058, 0.71764705882352942, 1.0, 1.0) -(0.28627450980392155, 0.71372549019607845, 1.0, 1.0) -(0.29019607843137252, 0.70980392156862748, 1.0, 1.0) -(0.29411764705882354, 0.70588235294117641, 1.0, 1.0) -(0.29803921568627451, 0.70196078431372544, 1.0, 1.0) -(0.30196078431372547, 0.69803921568627447, 1.0, 1.0) -(0.30588235294117649, 0.69411764705882351, 1.0, 1.0) -(0.30980392156862746, 0.69019607843137254, 1.0, 1.0) -(0.31372549019607843, 0.68627450980392157, 1.0, 1.0) -(0.31764705882352939, 0.68235294117647061, 1.0, 1.0) -(0.32156862745098036, 0.67843137254901964, 1.0, 1.0) -(0.32549019607843138, 0.67450980392156867, 1.0, 1.0) -(0.32941176470588235, 0.67058823529411771, 1.0, 1.0) -(0.33333333333333331, 0.66666666666666674, 1.0, 1.0) -(0.33725490196078434, 0.66274509803921566, 1.0, 1.0) -(0.3411764705882353, 0.6588235294117647, 1.0, 1.0) -(0.34509803921568627, 0.65490196078431373, 1.0, 1.0) -(0.34901960784313724, 0.65098039215686276, 1.0, 1.0) -(0.3529411764705882, 0.6470588235294118, 1.0, 1.0) -(0.35686274509803922, 0.64313725490196072, 1.0, 1.0) -(0.36078431372549019, 0.63921568627450975, 1.0, 1.0) -(0.36470588235294116, 0.63529411764705879, 1.0, 1.0) -(0.36862745098039218, 0.63137254901960782, 1.0, 1.0) -(0.37254901960784315, 0.62745098039215685, 1.0, 1.0) -(0.37647058823529411, 0.62352941176470589, 1.0, 1.0) -(0.38039215686274508, 0.61960784313725492, 1.0, 1.0) -(0.38431372549019605, 0.61568627450980395, 1.0, 1.0) -(0.38823529411764707, 0.61176470588235299, 1.0, 1.0) -(0.39215686274509803, 0.60784313725490202, 1.0, 1.0) -(0.396078431372549, 0.60392156862745106, 1.0, 1.0) -(0.40000000000000002, 0.59999999999999998, 1.0, 1.0) -(0.40392156862745099, 0.59607843137254901, 1.0, 1.0) -(0.40784313725490196, 0.59215686274509804, 1.0, 1.0) -(0.41176470588235292, 0.58823529411764708, 1.0, 1.0) -(0.41568627450980389, 0.58431372549019611, 1.0, 1.0) -(0.41960784313725491, 0.58039215686274503, 1.0, 1.0) -(0.42352941176470588, 0.57647058823529407, 1.0, 1.0) -(0.42745098039215684, 0.5725490196078431, 1.0, 1.0) -(0.43137254901960786, 0.56862745098039214, 1.0, 1.0) -(0.43529411764705883, 0.56470588235294117, 1.0, 1.0) -(0.4392156862745098, 0.5607843137254902, 1.0, 1.0) -(0.44313725490196076, 0.55686274509803924, 1.0, 1.0) -(0.44705882352941173, 0.55294117647058827, 1.0, 1.0) -(0.45098039215686275, 0.5490196078431373, 1.0, 1.0) -(0.45490196078431372, 0.54509803921568634, 1.0, 1.0) -(0.45882352941176469, 0.54117647058823537, 1.0, 1.0) -(0.46274509803921571, 0.53725490196078429, 1.0, 1.0) -(0.46666666666666667, 0.53333333333333333, 1.0, 1.0) -(0.47058823529411764, 0.52941176470588236, 1.0, 1.0) -(0.47450980392156861, 0.52549019607843139, 1.0, 1.0) -(0.47843137254901957, 0.52156862745098043, 1.0, 1.0) -(0.4823529411764706, 0.51764705882352935, 1.0, 1.0) -(0.48627450980392156, 0.51372549019607838, 1.0, 1.0) -(0.49019607843137253, 0.50980392156862742, 1.0, 1.0) -(0.49411764705882355, 0.50588235294117645, 1.0, 1.0) -(0.49803921568627452, 0.50196078431372548, 1.0, 1.0) -(0.50196078431372548, 0.49803921568627452, 1.0, 1.0) -(0.50588235294117645, 0.49411764705882355, 1.0, 1.0) -(0.50980392156862742, 0.49019607843137258, 1.0, 1.0) -(0.51372549019607838, 0.48627450980392162, 1.0, 1.0) -(0.51764705882352935, 0.48235294117647065, 1.0, 1.0) -(0.52156862745098043, 0.47843137254901957, 1.0, 1.0) -(0.52549019607843139, 0.47450980392156861, 1.0, 1.0) -(0.52941176470588236, 0.47058823529411764, 1.0, 1.0) -(0.53333333333333333, 0.46666666666666667, 1.0, 1.0) -(0.53725490196078429, 0.46274509803921571, 1.0, 1.0) -(0.54117647058823526, 0.45882352941176474, 1.0, 1.0) -(0.54509803921568623, 0.45490196078431377, 1.0, 1.0) -(0.5490196078431373, 0.4509803921568627, 1.0, 1.0) -(0.55294117647058827, 0.44705882352941173, 1.0, 1.0) -(0.55686274509803924, 0.44313725490196076, 1.0, 1.0) -(0.5607843137254902, 0.4392156862745098, 1.0, 1.0) -(0.56470588235294117, 0.43529411764705883, 1.0, 1.0) -(0.56862745098039214, 0.43137254901960786, 1.0, 1.0) -(0.5725490196078431, 0.4274509803921569, 1.0, 1.0) -(0.57647058823529407, 0.42352941176470593, 1.0, 1.0) -(0.58039215686274503, 0.41960784313725497, 1.0, 1.0) -(0.58431372549019611, 0.41568627450980389, 1.0, 1.0) -(0.58823529411764708, 0.41176470588235292, 1.0, 1.0) -(0.59215686274509804, 0.40784313725490196, 1.0, 1.0) -(0.59607843137254901, 0.40392156862745099, 1.0, 1.0) -(0.59999999999999998, 0.40000000000000002, 1.0, 1.0) -(0.60392156862745094, 0.39607843137254906, 1.0, 1.0) -(0.60784313725490191, 0.39215686274509809, 1.0, 1.0) -(0.61176470588235299, 0.38823529411764701, 1.0, 1.0) -(0.61568627450980395, 0.38431372549019605, 1.0, 1.0) -(0.61960784313725492, 0.38039215686274508, 1.0, 1.0) -(0.62352941176470589, 0.37647058823529411, 1.0, 1.0) -(0.62745098039215685, 0.37254901960784315, 1.0, 1.0) -(0.63137254901960782, 0.36862745098039218, 1.0, 1.0) -(0.63529411764705879, 0.36470588235294121, 1.0, 1.0) -(0.63921568627450975, 0.36078431372549025, 1.0, 1.0) -(0.64313725490196072, 0.35686274509803928, 1.0, 1.0) -(0.6470588235294118, 0.3529411764705882, 1.0, 1.0) -(0.65098039215686276, 0.34901960784313724, 1.0, 1.0) -(0.65490196078431373, 0.34509803921568627, 1.0, 1.0) -(0.6588235294117647, 0.3411764705882353, 1.0, 1.0) -(0.66274509803921566, 0.33725490196078434, 1.0, 1.0) -(0.66666666666666663, 0.33333333333333337, 1.0, 1.0) -(0.6705882352941176, 0.3294117647058824, 1.0, 1.0) -(0.67450980392156867, 0.32549019607843133, 1.0, 1.0) -(0.67843137254901964, 0.32156862745098036, 1.0, 1.0) -(0.68235294117647061, 0.31764705882352939, 1.0, 1.0) -(0.68627450980392157, 0.31372549019607843, 1.0, 1.0) -(0.69019607843137254, 0.30980392156862746, 1.0, 1.0) -(0.69411764705882351, 0.30588235294117649, 1.0, 1.0) -(0.69803921568627447, 0.30196078431372553, 1.0, 1.0) -(0.70196078431372544, 0.29803921568627456, 1.0, 1.0) -(0.70588235294117641, 0.29411764705882359, 1.0, 1.0) -(0.70980392156862748, 0.29019607843137252, 1.0, 1.0) -(0.71372549019607845, 0.28627450980392155, 1.0, 1.0) -(0.71764705882352942, 0.28235294117647058, 1.0, 1.0) -(0.72156862745098038, 0.27843137254901962, 1.0, 1.0) -(0.72549019607843135, 0.27450980392156865, 1.0, 1.0) -(0.72941176470588232, 0.27058823529411768, 1.0, 1.0) -(0.73333333333333328, 0.26666666666666672, 1.0, 1.0) -(0.73725490196078436, 0.26274509803921564, 1.0, 1.0) -(0.74117647058823533, 0.25882352941176467, 1.0, 1.0) -(0.74509803921568629, 0.25490196078431371, 1.0, 1.0) -(0.74901960784313726, 0.25098039215686274, 1.0, 1.0) -(0.75294117647058822, 0.24705882352941178, 1.0, 1.0) -(0.75686274509803919, 0.24313725490196081, 1.0, 1.0) -(0.76078431372549016, 0.23921568627450984, 1.0, 1.0) -(0.76470588235294112, 0.23529411764705888, 1.0, 1.0) -(0.76862745098039209, 0.23137254901960791, 1.0, 1.0) -(0.77254901960784317, 0.22745098039215683, 1.0, 1.0) -(0.77647058823529413, 0.22352941176470587, 1.0, 1.0) -(0.7803921568627451, 0.2196078431372549, 1.0, 1.0) -(0.78431372549019607, 0.21568627450980393, 1.0, 1.0) -(0.78823529411764703, 0.21176470588235297, 1.0, 1.0) -(0.792156862745098, 0.207843137254902, 1.0, 1.0) -(0.79607843137254897, 0.20392156862745103, 1.0, 1.0) -(0.80000000000000004, 0.19999999999999996, 1.0, 1.0) -(0.80392156862745101, 0.19607843137254899, 1.0, 1.0) -(0.80784313725490198, 0.19215686274509802, 1.0, 1.0) -(0.81176470588235294, 0.18823529411764706, 1.0, 1.0) -(0.81568627450980391, 0.18431372549019609, 1.0, 1.0) -(0.81960784313725488, 0.18039215686274512, 1.0, 1.0) -(0.82352941176470584, 0.17647058823529416, 1.0, 1.0) -(0.82745098039215681, 0.17254901960784319, 1.0, 1.0) -(0.83137254901960778, 0.16862745098039222, 1.0, 1.0) -(0.83529411764705885, 0.16470588235294115, 1.0, 1.0) -(0.83921568627450982, 0.16078431372549018, 1.0, 1.0) -(0.84313725490196079, 0.15686274509803921, 1.0, 1.0) -(0.84705882352941175, 0.15294117647058825, 1.0, 1.0) -(0.85098039215686272, 0.14901960784313728, 1.0, 1.0) -(0.85490196078431369, 0.14509803921568631, 1.0, 1.0) -(0.85882352941176465, 0.14117647058823535, 1.0, 1.0) -(0.86274509803921573, 0.13725490196078427, 1.0, 1.0) -(0.8666666666666667, 0.1333333333333333, 1.0, 1.0) -(0.87058823529411766, 0.12941176470588234, 1.0, 1.0) -(0.87450980392156863, 0.12549019607843137, 1.0, 1.0) -(0.8784313725490196, 0.1215686274509804, 1.0, 1.0) -(0.88235294117647056, 0.11764705882352944, 1.0, 1.0) -(0.88627450980392153, 0.11372549019607847, 1.0, 1.0) -(0.8901960784313725, 0.1098039215686275, 1.0, 1.0) -(0.89411764705882346, 0.10588235294117654, 1.0, 1.0) -(0.89803921568627454, 0.10196078431372546, 1.0, 1.0) -(0.90196078431372551, 0.098039215686274495, 1.0, 1.0) -(0.90588235294117647, 0.094117647058823528, 1.0, 1.0) -(0.90980392156862744, 0.090196078431372562, 1.0, 1.0) -(0.9137254901960784, 0.086274509803921595, 1.0, 1.0) -(0.91764705882352937, 0.082352941176470629, 1.0, 1.0) -(0.92156862745098034, 0.078431372549019662, 1.0, 1.0) -(0.92549019607843142, 0.074509803921568585, 1.0, 1.0) -(0.92941176470588238, 0.070588235294117618, 1.0, 1.0) -(0.93333333333333335, 0.066666666666666652, 1.0, 1.0) -(0.93725490196078431, 0.062745098039215685, 1.0, 1.0) -(0.94117647058823528, 0.058823529411764719, 1.0, 1.0) -(0.94509803921568625, 0.054901960784313752, 1.0, 1.0) -(0.94901960784313721, 0.050980392156862786, 1.0, 1.0) -(0.95294117647058818, 0.04705882352941182, 1.0, 1.0) -(0.95686274509803915, 0.043137254901960853, 1.0, 1.0) -(0.96078431372549022, 0.039215686274509776, 1.0, 1.0) -(0.96470588235294119, 0.035294117647058809, 1.0, 1.0) -(0.96862745098039216, 0.031372549019607843, 1.0, 1.0) -(0.97254901960784312, 0.027450980392156876, 1.0, 1.0) -(0.97647058823529409, 0.02352941176470591, 1.0, 1.0) -(0.98039215686274506, 0.019607843137254943, 1.0, 1.0) -(0.98431372549019602, 0.015686274509803977, 1.0, 1.0) -(0.9882352941176471, 0.011764705882352899, 1.0, 1.0) -(0.99215686274509807, 0.0078431372549019329, 1.0, 1.0) -(0.99607843137254903, 0.0039215686274509665, 1.0, 1.0) -(1.0, 0.0, 1.0, 1.0) diff --git a/extern/tfn/colormaps/sequential2/copper.cpp b/extern/tfn/colormaps/sequential2/copper.cpp deleted file mode 100644 index bf8d235..0000000 --- a/extern/tfn/colormaps/sequential2/copper.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential2_copper; -} -const std::vector colormap::data_sequential2_copper = /* NOLINT(cert-err58-cpp) */ -{ -{0.0f, 0.0f, 0.0f, 1.0f}, -{0.0048442895176066189f, 0.0030635294117647058f, 0.0019509803921568627f, 1.0f}, -{0.0096885790352132378f, 0.0061270588235294117f, 0.0039019607843137254f, 1.0f}, -{0.014532868552819857f, 0.0091905882352941171f, 0.0058529411764705885f, 1.0f}, -{0.019377158070426476f, 0.012254117647058823f, 0.0078039215686274508f, 1.0f}, -{0.024221447588033095f, 0.01531764705882353f, 0.0097549019607843131f, 1.0f}, -{0.029065737105639713f, 0.018381176470588234f, 0.011705882352941177f, 1.0f}, -{0.033910026623246332f, 0.021444705882352942f, 0.013656862745098039f, 1.0f}, -{0.038754316140852951f, 0.024508235294117647f, 0.015607843137254902f, 1.0f}, -{0.04359860565845957f, 0.027571764705882351f, 0.017558823529411766f, 1.0f}, -{0.048442895176066189f, 0.030635294117647059f, 0.019509803921568626f, 1.0f}, -{0.053287184693672808f, 0.033698823529411767f, 0.02146078431372549f, 1.0f}, -{0.058131474211279427f, 0.036762352941176468f, 0.023411764705882354f, 1.0f}, -{0.062975763728886039f, 0.039825882352941176f, 0.025362745098039215f, 1.0f}, -{0.067820053246492665f, 0.042889411764705884f, 0.027313725490196079f, 1.0f}, -{0.072664342764099277f, 0.045952941176470585f, 0.029264705882352939f, 1.0f}, -{0.077508632281705903f, 0.049016470588235293f, 0.031215686274509803f, 1.0f}, -{0.082352921799312515f, 0.052080000000000001f, 0.033166666666666664f, 1.0f}, -{0.08719721131691914f, 0.055143529411764702f, 0.035117647058823531f, 1.0f}, -{0.092041500834525752f, 0.05820705882352941f, 0.037068627450980392f, 1.0f}, -{0.096885790352132378f, 0.061270588235294118f, 0.039019607843137252f, 1.0f}, -{0.10173007986973899f, 0.064334117647058819f, 0.04097058823529412f, 1.0f}, -{0.10657436938734562f, 0.067397647058823534f, 0.04292156862745098f, 1.0f}, -{0.11141865890495223f, 0.070461176470588235f, 0.044872549019607841f, 1.0f}, -{0.11626294842255885f, 0.073524705882352936f, 0.046823529411764708f, 1.0f}, -{0.12110723794016547f, 0.076588235294117651f, 0.048774509803921569f, 1.0f}, -{0.12595152745777208f, 0.079651764705882352f, 0.050725490196078429f, 1.0f}, -{0.1307958169753787f, 0.082715294117647054f, 0.05267647058823529f, 1.0f}, -{0.13564010649298533f, 0.085778823529411768f, 0.054627450980392157f, 1.0f}, -{0.14048439601059196f, 0.08884235294117647f, 0.056578431372549018f, 1.0f}, -{0.14532868552819855f, 0.091905882352941171f, 0.058529411764705878f, 1.0f}, -{0.15017297504580518f, 0.094969411764705886f, 0.060480392156862746f, 1.0f}, -{0.15501726456341181f, 0.098032941176470587f, 0.062431372549019606f, 1.0f}, -{0.15986155408101838f, 0.10109647058823529f, 0.06438235294117646f, 1.0f}, -{0.16470584359862503f, 0.10416f, 0.066333333333333327f, 1.0f}, -{0.16955013311623165f, 0.10722352941176472f, 0.068284313725490195f, 1.0f}, -{0.17439442263383828f, 0.1102870588235294f, 0.070235294117647062f, 1.0f}, -{0.17923871215144485f, 0.11335058823529411f, 0.072186274509803916f, 1.0f}, -{0.1840830016690515f, 0.11641411764705882f, 0.074137254901960783f, 1.0f}, -{0.18892729118665813f, 0.11947764705882354f, 0.076088235294117651f, 1.0f}, -{0.19377158070426476f, 0.12254117647058824f, 0.078039215686274505f, 1.0f}, -{0.19861587022187133f, 0.12560470588235292f, 0.079990196078431358f, 1.0f}, -{0.20346015973947798f, 0.12866823529411764f, 0.081941176470588239f, 1.0f}, -{0.20830444925708461f, 0.13173176470588235f, 0.083892156862745107f, 1.0f}, -{0.21314873877469123f, 0.13479529411764707f, 0.085843137254901961f, 1.0f}, -{0.2179930282922978f, 0.13785882352941176f, 0.087794117647058814f, 1.0f}, -{0.22283731780990446f, 0.14092235294117647f, 0.089745098039215682f, 1.0f}, -{0.22768160732751108f, 0.14398588235294119f, 0.091696078431372549f, 1.0f}, -{0.23252589684511771f, 0.14704941176470587f, 0.093647058823529417f, 1.0f}, -{0.23737018636272428f, 0.15011294117647059f, 0.09559803921568627f, 1.0f}, -{0.24221447588033093f, 0.1531764705882353f, 0.097549019607843138f, 1.0f}, -{0.24705876539793756f, 0.15624000000000002f, 0.099500000000000005f, 1.0f}, -{0.25190305491554416f, 0.1593035294117647f, 0.10145098039215686f, 1.0f}, -{0.25674734443315078f, 0.16236705882352939f, 0.10340196078431371f, 1.0f}, -{0.26159163395075741f, 0.16543058823529411f, 0.10535294117647058f, 1.0f}, -{0.26643592346836403f, 0.16849411764705882f, 0.10730392156862746f, 1.0f}, -{0.27128021298597066f, 0.17155764705882354f, 0.10925490196078431f, 1.0f}, -{0.27612450250357723f, 0.17462117647058822f, 0.11120588235294117f, 1.0f}, -{0.28096879202118391f, 0.17768470588235294f, 0.11315686274509804f, 1.0f}, -{0.28581308153879054f, 0.18074823529411765f, 0.1151078431372549f, 1.0f}, -{0.29065737105639711f, 0.18381176470588234f, 0.11705882352941176f, 1.0f}, -{0.29550166057400373f, 0.18687529411764706f, 0.11900980392156862f, 1.0f}, -{0.30034595009161036f, 0.18993882352941177f, 0.12096078431372549f, 1.0f}, -{0.30519023960921698f, 0.19300235294117649f, 0.12291176470588236f, 1.0f}, -{0.31003452912682361f, 0.19606588235294117f, 0.12486274509803921f, 1.0f}, -{0.31487881864443024f, 0.19912941176470586f, 0.12681372549019607f, 1.0f}, -{0.31972310816203675f, 0.20219294117647058f, 0.12876470588235292f, 1.0f}, -{0.32456739767964349f, 0.20525647058823529f, 0.1307156862745098f, 1.0f}, -{0.32941168719725006f, 0.20832000000000001f, 0.13266666666666665f, 1.0f}, -{0.33425597671485668f, 0.21138352941176469f, 0.13461764705882351f, 1.0f}, -{0.33910026623246331f, 0.21444705882352944f, 0.13656862745098039f, 1.0f}, -{0.34394455575006994f, 0.21751058823529412f, 0.13851960784313727f, 1.0f}, -{0.34878884526767656f, 0.22057411764705881f, 0.14047058823529412f, 1.0f}, -{0.35363313478528319f, 0.22363764705882352f, 0.14242156862745098f, 1.0f}, -{0.3584774243028897f, 0.22670117647058821f, 0.14437254901960783f, 1.0f}, -{0.36332171382049638f, 0.22976470588235295f, 0.14632352941176471f, 1.0f}, -{0.36816600333810301f, 0.23282823529411764f, 0.14827450980392157f, 1.0f}, -{0.37301029285570964f, 0.23589176470588233f, 0.15022549019607842f, 1.0f}, -{0.37785458237331626f, 0.23895529411764707f, 0.1521764705882353f, 1.0f}, -{0.38269887189092289f, 0.24201882352941179f, 0.15412745098039216f, 1.0f}, -{0.38754316140852951f, 0.24508235294117647f, 0.15607843137254901f, 1.0f}, -{0.39238745092613614f, 0.24814588235294116f, 0.15802941176470586f, 1.0f}, -{0.39723174044374265f, 0.25120941176470585f, 0.15998039215686272f, 1.0f}, -{0.40207602996134933f, 0.25427294117647059f, 0.16193137254901963f, 1.0f}, -{0.40692031947895596f, 0.25733647058823528f, 0.16388235294117648f, 1.0f}, -{0.41176460899656259f, 0.26039999999999996f, 0.16583333333333333f, 1.0f}, -{0.41660889851416921f, 0.26346352941176471f, 0.16778431372549021f, 1.0f}, -{0.42145318803177584f, 0.26652705882352939f, 0.16973529411764707f, 1.0f}, -{0.42629747754938246f, 0.26959058823529414f, 0.17168627450980392f, 1.0f}, -{0.43114176706698909f, 0.27265411764705882f, 0.17363725490196077f, 1.0f}, -{0.4359860565845956f, 0.27571764705882351f, 0.17558823529411763f, 1.0f}, -{0.44083034610220229f, 0.27878117647058825f, 0.17753921568627451f, 1.0f}, -{0.44567463561980891f, 0.28184470588235294f, 0.17949019607843136f, 1.0f}, -{0.45051892513741554f, 0.28490823529411763f, 0.18144117647058822f, 1.0f}, -{0.45536321465502216f, 0.28797176470588237f, 0.1833921568627451f, 1.0f}, -{0.46020750417262879f, 0.29103529411764706f, 0.18534313725490195f, 1.0f}, -{0.46505179369023542f, 0.29409882352941175f, 0.18729411764705883f, 1.0f}, -{0.46989608320784204f, 0.29716235294117643f, 0.18924509803921569f, 1.0f}, -{0.47474037272544856f, 0.30022588235294118f, 0.19119607843137254f, 1.0f}, -{0.47958466224305524f, 0.30328941176470592f, 0.19314705882352942f, 1.0f}, -{0.48442895176066186f, 0.30635294117647061f, 0.19509803921568628f, 1.0f}, -{0.48927324127826849f, 0.30941647058823529f, 0.19704901960784313f, 1.0f}, -{0.49411753079587512f, 0.31248000000000004f, 0.19900000000000001f, 1.0f}, -{0.49896182031348174f, 0.31554352941176472f, 0.20095098039215686f, 1.0f}, -{0.50380610983108831f, 0.31860705882352941f, 0.20290196078431372f, 1.0f}, -{0.50865039934869494f, 0.3216705882352941f, 0.20485294117647057f, 1.0f}, -{0.51349468886630156f, 0.32473411764705878f, 0.20680392156862742f, 1.0f}, -{0.51833897838390819f, 0.32779764705882353f, 0.20875490196078431f, 1.0f}, -{0.52318326790151481f, 0.33086117647058821f, 0.21070588235294116f, 1.0f}, -{0.52802755741912144f, 0.3339247058823529f, 0.21265686274509804f, 1.0f}, -{0.53287184693672807f, 0.33698823529411764f, 0.21460784313725492f, 1.0f}, -{0.53771613645433469f, 0.34005176470588239f, 0.21655882352941178f, 1.0f}, -{0.54256042597194132f, 0.34311529411764707f, 0.21850980392156863f, 1.0f}, -{0.54740471548954794f, 0.34617882352941176f, 0.22046078431372548f, 1.0f}, -{0.55224900500715446f, 0.34924235294117645f, 0.22241176470588234f, 1.0f}, -{0.5570932945247612f, 0.35230588235294119f, 0.22436274509803922f, 1.0f}, -{0.56193758404236782f, 0.35536941176470588f, 0.22631372549019607f, 1.0f}, -{0.56678187355997445f, 0.35843294117647057f, 0.22826470588235293f, 1.0f}, -{0.57162616307758107f, 0.36149647058823531f, 0.23021568627450981f, 1.0f}, -{0.57647045259518759f, 0.36456f, 0.23216666666666666f, 1.0f}, -{0.58131474211279421f, 0.36762352941176468f, 0.23411764705882351f, 1.0f}, -{0.58615903163040084f, 0.37068705882352943f, 0.23606862745098037f, 1.0f}, -{0.59100332114800747f, 0.37375058823529411f, 0.23801960784313725f, 1.0f}, -{0.59584761066561409f, 0.37681411764705885f, 0.23997058823529413f, 1.0f}, -{0.60069190018322072f, 0.37987764705882354f, 0.24192156862745098f, 1.0f}, -{0.60553618970082734f, 0.38294117647058823f, 0.24387254901960784f, 1.0f}, -{0.61038047921843397f, 0.38600470588235297f, 0.24582352941176472f, 1.0f}, -{0.61522476873604059f, 0.38906823529411766f, 0.24777450980392157f, 1.0f}, -{0.62006905825364722f, 0.39213176470588235f, 0.24972549019607843f, 1.0f}, -{0.62491334777125385f, 0.39519529411764703f, 0.25167647058823528f, 1.0f}, -{0.62975763728886047f, 0.39825882352941172f, 0.25362745098039213f, 1.0f}, -{0.6346019268064671f, 0.40132235294117641f, 0.25557843137254899f, 1.0f}, -{0.6394462163240735f, 0.40438588235294115f, 0.25752941176470584f, 1.0f}, -{0.64429050584168035f, 0.40744941176470589f, 0.25948039215686275f, 1.0f}, -{0.64913479535928698f, 0.41051294117647058f, 0.2614313725490196f, 1.0f}, -{0.65397908487689349f, 0.41357647058823532f, 0.26338235294117646f, 1.0f}, -{0.65882337439450012f, 0.41664000000000001f, 0.26533333333333331f, 1.0f}, -{0.66366766391210674f, 0.4197035294117647f, 0.26728431372549016f, 1.0f}, -{0.66851195342971337f, 0.42276705882352938f, 0.26923529411764702f, 1.0f}, -{0.67335624294731999f, 0.42583058823529407f, 0.27118627450980387f, 1.0f}, -{0.67820053246492662f, 0.42889411764705887f, 0.27313725490196078f, 1.0f}, -{0.68304482198253325f, 0.43195764705882356f, 0.27508823529411769f, 1.0f}, -{0.68788911150013987f, 0.43502117647058824f, 0.27703921568627454f, 1.0f}, -{0.6927334010177465f, 0.43808470588235293f, 0.2789901960784314f, 1.0f}, -{0.69757769053535312f, 0.44114823529411762f, 0.28094117647058825f, 1.0f}, -{0.70242198005295975f, 0.44421176470588236f, 0.2828921568627451f, 1.0f}, -{0.70726626957056637f, 0.44727529411764705f, 0.28484313725490196f, 1.0f}, -{0.712110559088173f, 0.45033882352941174f, 0.28679411764705881f, 1.0f}, -{0.7169548486057794f, 0.45340235294117642f, 0.28874509803921566f, 1.0f}, -{0.72179913812338625f, 0.45646588235294122f, 0.29069607843137257f, 1.0f}, -{0.72664342764099277f, 0.45952941176470591f, 0.29264705882352943f, 1.0f}, -{0.73148771715859939f, 0.4625929411764706f, 0.29459803921568628f, 1.0f}, -{0.73633200667620602f, 0.46565647058823528f, 0.29654901960784313f, 1.0f}, -{0.74117629619381264f, 0.46871999999999997f, 0.29849999999999999f, 1.0f}, -{0.74602058571141927f, 0.47178352941176466f, 0.30045098039215684f, 1.0f}, -{0.7508648752290259f, 0.4748470588235294f, 0.30240196078431369f, 1.0f}, -{0.75570916474663252f, 0.47791058823529414f, 0.3043529411764706f, 1.0f}, -{0.76055345426423915f, 0.48097411764705883f, 0.30630392156862746f, 1.0f}, -{0.76539774378184577f, 0.48403764705882357f, 0.30825490196078431f, 1.0f}, -{0.7702420332994524f, 0.48710117647058826f, 0.31020588235294116f, 1.0f}, -{0.77508632281705903f, 0.49016470588235295f, 0.31215686274509802f, 1.0f}, -{0.77993061233466565f, 0.49322823529411763f, 0.31410784313725487f, 1.0f}, -{0.78477490185227228f, 0.49629176470588232f, 0.31605882352941173f, 1.0f}, -{0.7896191913698789f, 0.49935529411764701f, 0.31800980392156858f, 1.0f}, -{0.79446348088748531f, 0.5024188235294117f, 0.31996078431372543f, 1.0f}, -{0.79930777040509216f, 0.50548235294117649f, 0.32191176470588234f, 1.0f}, -{0.80415205992269867f, 0.50854588235294118f, 0.32386274509803925f, 1.0f}, -{0.8089963494403053f, 0.51160941176470587f, 0.3258137254901961f, 1.0f}, -{0.81384063895791192f, 0.51467294117647056f, 0.32776470588235296f, 1.0f}, -{0.81868492847551855f, 0.51773647058823524f, 0.32971568627450981f, 1.0f}, -{0.82352921799312517f, 0.52079999999999993f, 0.33166666666666667f, 1.0f}, -{0.8283735075107318f, 0.52386352941176462f, 0.33361764705882352f, 1.0f}, -{0.83321779702833842f, 0.52692705882352942f, 0.33556862745098043f, 1.0f}, -{0.83806208654594505f, 0.5299905882352941f, 0.33751960784313728f, 1.0f}, -{0.84290637606355168f, 0.53305411764705879f, 0.33947058823529414f, 1.0f}, -{0.8477506655811583f, 0.53611764705882359f, 0.34142156862745099f, 1.0f}, -{0.85259495509876493f, 0.53918117647058827f, 0.34337254901960784f, 1.0f}, -{0.85743924461637155f, 0.54224470588235296f, 0.3453235294117647f, 1.0f}, -{0.86228353413397818f, 0.54530823529411765f, 0.34727450980392155f, 1.0f}, -{0.86712782365158481f, 0.54837176470588234f, 0.3492254901960784f, 1.0f}, -{0.87197211316919121f, 0.55143529411764702f, 0.35117647058823526f, 1.0f}, -{0.87681640268679806f, 0.55449882352941182f, 0.35312745098039217f, 1.0f}, -{0.88166069220440457f, 0.55756235294117651f, 0.35507843137254902f, 1.0f}, -{0.8865049817220112f, 0.5606258823529412f, 0.35702941176470587f, 1.0f}, -{0.89134927123961782f, 0.56368941176470588f, 0.35898039215686273f, 1.0f}, -{0.89619356075722445f, 0.56675294117647057f, 0.36093137254901958f, 1.0f}, -{0.90103785027483108f, 0.56981647058823526f, 0.36288235294117643f, 1.0f}, -{0.9058821397924377f, 0.57287999999999994f, 0.36483333333333329f, 1.0f}, -{0.91072642931004433f, 0.57594352941176474f, 0.3667843137254902f, 1.0f}, -{0.91557071882765095f, 0.57900705882352943f, 0.36873529411764705f, 1.0f}, -{0.92041500834525758f, 0.58207058823529412f, 0.3706862745098039f, 1.0f}, -{0.92525929786286421f, 0.5851341176470588f, 0.37263725490196076f, 1.0f}, -{0.93010358738047083f, 0.58819764705882349f, 0.37458823529411767f, 1.0f}, -{0.93494787689807746f, 0.59126117647058818f, 0.37653921568627452f, 1.0f}, -{0.93979216641568408f, 0.59432470588235287f, 0.37849019607843137f, 1.0f}, -{0.94463645593329071f, 0.59738823529411766f, 0.38044117647058823f, 1.0f}, -{0.94948074545089711f, 0.60045176470588235f, 0.38239215686274508f, 1.0f}, -{0.95432503496850396f, 0.60351529411764704f, 0.38434313725490199f, 1.0f}, -{0.95916932448611048f, 0.60657882352941184f, 0.38629411764705884f, 1.0f}, -{0.9640136140037171f, 0.60964235294117652f, 0.3882450980392157f, 1.0f}, -{0.96885790352132373f, 0.61270588235294121f, 0.39019607843137255f, 1.0f}, -{0.97370219303893035f, 0.6157694117647059f, 0.3921470588235294f, 1.0f}, -{0.97854648255653698f, 0.61883294117647059f, 0.39409803921568626f, 1.0f}, -{0.9833907720741436f, 0.62189647058823527f, 0.39604901960784311f, 1.0f}, -{0.98823506159175023f, 0.62496000000000007f, 0.39800000000000002f, 1.0f}, -{0.99307935110935686f, 0.62802352941176476f, 0.39995098039215687f, 1.0f}, -{0.99792364062696348f, 0.63108705882352945f, 0.40190196078431373f, 1.0f}, -{1.0f, 0.63415058823529413f, 0.40385294117647058f, 1.0f}, -{1.0f, 0.63721411764705882f, 0.40580392156862743f, 1.0f}, -{1.0f, 0.64027764705882351f, 0.40775490196078429f, 1.0f}, -{1.0f, 0.64334117647058819f, 0.40970588235294114f, 1.0f}, -{1.0f, 0.64640470588235288f, 0.411656862745098f, 1.0f}, -{1.0f, 0.64946823529411757f, 0.41360784313725485f, 1.0f}, -{1.0f, 0.65253176470588237f, 0.41555882352941176f, 1.0f}, -{1.0f, 0.65559529411764705f, 0.41750980392156861f, 1.0f}, -{1.0f, 0.65865882352941174f, 0.41946078431372547f, 1.0f}, -{1.0f, 0.66172235294117643f, 0.42141176470588232f, 1.0f}, -{1.0f, 0.66478588235294112f, 0.42336274509803923f, 1.0f}, -{1.0f, 0.6678494117647058f, 0.42531372549019608f, 1.0f}, -{1.0f, 0.6709129411764706f, 0.42726470588235294f, 1.0f}, -{1.0f, 0.67397647058823529f, 0.42921568627450984f, 1.0f}, -{1.0f, 0.67703999999999998f, 0.4311666666666667f, 1.0f}, -{1.0f, 0.68010352941176477f, 0.43311764705882355f, 1.0f}, -{1.0f, 0.68316705882352946f, 0.43506862745098041f, 1.0f}, -{1.0f, 0.68623058823529415f, 0.43701960784313726f, 1.0f}, -{1.0f, 0.68929411764705883f, 0.43897058823529411f, 1.0f}, -{1.0f, 0.69235764705882352f, 0.44092156862745097f, 1.0f}, -{1.0f, 0.69542117647058821f, 0.44287254901960782f, 1.0f}, -{1.0f, 0.6984847058823529f, 0.44482352941176467f, 1.0f}, -{1.0f, 0.70154823529411769f, 0.44677450980392158f, 1.0f}, -{1.0f, 0.70461176470588238f, 0.44872549019607844f, 1.0f}, -{1.0f, 0.70767529411764707f, 0.45067647058823529f, 1.0f}, -{1.0f, 0.71073882352941176f, 0.45262745098039214f, 1.0f}, -{1.0f, 0.71380235294117644f, 0.454578431372549f, 1.0f}, -{1.0f, 0.71686588235294113f, 0.45652941176470585f, 1.0f}, -{1.0f, 0.71992941176470582f, 0.4584803921568627f, 1.0f}, -{1.0f, 0.72299294117647062f, 0.46043137254901961f, 1.0f}, -{1.0f, 0.7260564705882353f, 0.46238235294117647f, 1.0f}, -{1.0f, 0.72911999999999999f, 0.46433333333333332f, 1.0f}, -{1.0f, 0.73218352941176468f, 0.46628431372549017f, 1.0f}, -{1.0f, 0.73524705882352936f, 0.46823529411764703f, 1.0f}, -{1.0f, 0.73831058823529405f, 0.47018627450980388f, 1.0f}, -{1.0f, 0.74137411764705885f, 0.47213725490196073f, 1.0f}, -{1.0f, 0.74443764705882354f, 0.47408823529411764f, 1.0f}, -{1.0f, 0.74750117647058822f, 0.4760392156862745f, 1.0f}, -{1.0f, 0.75056470588235302f, 0.47799019607843141f, 1.0f}, -{1.0f, 0.75362823529411771f, 0.47994117647058826f, 1.0f}, -{1.0f, 0.7566917647058824f, 0.48189215686274511f, 1.0f}, -{1.0f, 0.75975529411764708f, 0.48384313725490197f, 1.0f}, -{1.0f, 0.76281882352941177f, 0.48579411764705882f, 1.0f}, -{1.0f, 0.76588235294117646f, 0.48774509803921567f, 1.0f}, -{1.0f, 0.76894588235294115f, 0.48969607843137253f, 1.0f}, -{1.0f, 0.77200941176470594f, 0.49164705882352944f, 1.0f}, -{1.0f, 0.77507294117647063f, 0.49359803921568629f, 1.0f}, -{1.0f, 0.77813647058823532f, 0.49554901960784314f, 1.0f}, -{1.0f, 0.78120000000000001f, 0.4975f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential2/copper.txt b/extern/tfn/colormaps/sequential2/copper.txt deleted file mode 100644 index c70a7e5..0000000 --- a/extern/tfn/colormaps/sequential2/copper.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.0, 0.0, 0.0, 1.0) -(0.0048442895176066189, 0.0030635294117647058, 0.0019509803921568627, 1.0) -(0.0096885790352132378, 0.0061270588235294117, 0.0039019607843137254, 1.0) -(0.014532868552819857, 0.0091905882352941171, 0.0058529411764705885, 1.0) -(0.019377158070426476, 0.012254117647058823, 0.0078039215686274508, 1.0) -(0.024221447588033095, 0.01531764705882353, 0.0097549019607843131, 1.0) -(0.029065737105639713, 0.018381176470588234, 0.011705882352941177, 1.0) -(0.033910026623246332, 0.021444705882352942, 0.013656862745098039, 1.0) -(0.038754316140852951, 0.024508235294117647, 0.015607843137254902, 1.0) -(0.04359860565845957, 0.027571764705882351, 0.017558823529411766, 1.0) -(0.048442895176066189, 0.030635294117647059, 0.019509803921568626, 1.0) -(0.053287184693672808, 0.033698823529411767, 0.02146078431372549, 1.0) -(0.058131474211279427, 0.036762352941176468, 0.023411764705882354, 1.0) -(0.062975763728886039, 0.039825882352941176, 0.025362745098039215, 1.0) -(0.067820053246492665, 0.042889411764705884, 0.027313725490196079, 1.0) -(0.072664342764099277, 0.045952941176470585, 0.029264705882352939, 1.0) -(0.077508632281705903, 0.049016470588235293, 0.031215686274509803, 1.0) -(0.082352921799312515, 0.052080000000000001, 0.033166666666666664, 1.0) -(0.08719721131691914, 0.055143529411764702, 0.035117647058823531, 1.0) -(0.092041500834525752, 0.05820705882352941, 0.037068627450980392, 1.0) -(0.096885790352132378, 0.061270588235294118, 0.039019607843137252, 1.0) -(0.10173007986973899, 0.064334117647058819, 0.04097058823529412, 1.0) -(0.10657436938734562, 0.067397647058823534, 0.04292156862745098, 1.0) -(0.11141865890495223, 0.070461176470588235, 0.044872549019607841, 1.0) -(0.11626294842255885, 0.073524705882352936, 0.046823529411764708, 1.0) -(0.12110723794016547, 0.076588235294117651, 0.048774509803921569, 1.0) -(0.12595152745777208, 0.079651764705882352, 0.050725490196078429, 1.0) -(0.1307958169753787, 0.082715294117647054, 0.05267647058823529, 1.0) -(0.13564010649298533, 0.085778823529411768, 0.054627450980392157, 1.0) -(0.14048439601059196, 0.08884235294117647, 0.056578431372549018, 1.0) -(0.14532868552819855, 0.091905882352941171, 0.058529411764705878, 1.0) -(0.15017297504580518, 0.094969411764705886, 0.060480392156862746, 1.0) -(0.15501726456341181, 0.098032941176470587, 0.062431372549019606, 1.0) -(0.15986155408101838, 0.10109647058823529, 0.06438235294117646, 1.0) -(0.16470584359862503, 0.10416, 0.066333333333333327, 1.0) -(0.16955013311623165, 0.10722352941176472, 0.068284313725490195, 1.0) -(0.17439442263383828, 0.1102870588235294, 0.070235294117647062, 1.0) -(0.17923871215144485, 0.11335058823529411, 0.072186274509803916, 1.0) -(0.1840830016690515, 0.11641411764705882, 0.074137254901960783, 1.0) -(0.18892729118665813, 0.11947764705882354, 0.076088235294117651, 1.0) -(0.19377158070426476, 0.12254117647058824, 0.078039215686274505, 1.0) -(0.19861587022187133, 0.12560470588235292, 0.079990196078431358, 1.0) -(0.20346015973947798, 0.12866823529411764, 0.081941176470588239, 1.0) -(0.20830444925708461, 0.13173176470588235, 0.083892156862745107, 1.0) -(0.21314873877469123, 0.13479529411764707, 0.085843137254901961, 1.0) -(0.2179930282922978, 0.13785882352941176, 0.087794117647058814, 1.0) -(0.22283731780990446, 0.14092235294117647, 0.089745098039215682, 1.0) -(0.22768160732751108, 0.14398588235294119, 0.091696078431372549, 1.0) -(0.23252589684511771, 0.14704941176470587, 0.093647058823529417, 1.0) -(0.23737018636272428, 0.15011294117647059, 0.09559803921568627, 1.0) -(0.24221447588033093, 0.1531764705882353, 0.097549019607843138, 1.0) -(0.24705876539793756, 0.15624000000000002, 0.099500000000000005, 1.0) -(0.25190305491554416, 0.1593035294117647, 0.10145098039215686, 1.0) -(0.25674734443315078, 0.16236705882352939, 0.10340196078431371, 1.0) -(0.26159163395075741, 0.16543058823529411, 0.10535294117647058, 1.0) -(0.26643592346836403, 0.16849411764705882, 0.10730392156862746, 1.0) -(0.27128021298597066, 0.17155764705882354, 0.10925490196078431, 1.0) -(0.27612450250357723, 0.17462117647058822, 0.11120588235294117, 1.0) -(0.28096879202118391, 0.17768470588235294, 0.11315686274509804, 1.0) -(0.28581308153879054, 0.18074823529411765, 0.1151078431372549, 1.0) -(0.29065737105639711, 0.18381176470588234, 0.11705882352941176, 1.0) -(0.29550166057400373, 0.18687529411764706, 0.11900980392156862, 1.0) -(0.30034595009161036, 0.18993882352941177, 0.12096078431372549, 1.0) -(0.30519023960921698, 0.19300235294117649, 0.12291176470588236, 1.0) -(0.31003452912682361, 0.19606588235294117, 0.12486274509803921, 1.0) -(0.31487881864443024, 0.19912941176470586, 0.12681372549019607, 1.0) -(0.31972310816203675, 0.20219294117647058, 0.12876470588235292, 1.0) -(0.32456739767964349, 0.20525647058823529, 0.1307156862745098, 1.0) -(0.32941168719725006, 0.20832000000000001, 0.13266666666666665, 1.0) -(0.33425597671485668, 0.21138352941176469, 0.13461764705882351, 1.0) -(0.33910026623246331, 0.21444705882352944, 0.13656862745098039, 1.0) -(0.34394455575006994, 0.21751058823529412, 0.13851960784313727, 1.0) -(0.34878884526767656, 0.22057411764705881, 0.14047058823529412, 1.0) -(0.35363313478528319, 0.22363764705882352, 0.14242156862745098, 1.0) -(0.3584774243028897, 0.22670117647058821, 0.14437254901960783, 1.0) -(0.36332171382049638, 0.22976470588235295, 0.14632352941176471, 1.0) -(0.36816600333810301, 0.23282823529411764, 0.14827450980392157, 1.0) -(0.37301029285570964, 0.23589176470588233, 0.15022549019607842, 1.0) -(0.37785458237331626, 0.23895529411764707, 0.1521764705882353, 1.0) -(0.38269887189092289, 0.24201882352941179, 0.15412745098039216, 1.0) -(0.38754316140852951, 0.24508235294117647, 0.15607843137254901, 1.0) -(0.39238745092613614, 0.24814588235294116, 0.15802941176470586, 1.0) -(0.39723174044374265, 0.25120941176470585, 0.15998039215686272, 1.0) -(0.40207602996134933, 0.25427294117647059, 0.16193137254901963, 1.0) -(0.40692031947895596, 0.25733647058823528, 0.16388235294117648, 1.0) -(0.41176460899656259, 0.26039999999999996, 0.16583333333333333, 1.0) -(0.41660889851416921, 0.26346352941176471, 0.16778431372549021, 1.0) -(0.42145318803177584, 0.26652705882352939, 0.16973529411764707, 1.0) -(0.42629747754938246, 0.26959058823529414, 0.17168627450980392, 1.0) -(0.43114176706698909, 0.27265411764705882, 0.17363725490196077, 1.0) -(0.4359860565845956, 0.27571764705882351, 0.17558823529411763, 1.0) -(0.44083034610220229, 0.27878117647058825, 0.17753921568627451, 1.0) -(0.44567463561980891, 0.28184470588235294, 0.17949019607843136, 1.0) -(0.45051892513741554, 0.28490823529411763, 0.18144117647058822, 1.0) -(0.45536321465502216, 0.28797176470588237, 0.1833921568627451, 1.0) -(0.46020750417262879, 0.29103529411764706, 0.18534313725490195, 1.0) -(0.46505179369023542, 0.29409882352941175, 0.18729411764705883, 1.0) -(0.46989608320784204, 0.29716235294117643, 0.18924509803921569, 1.0) -(0.47474037272544856, 0.30022588235294118, 0.19119607843137254, 1.0) -(0.47958466224305524, 0.30328941176470592, 0.19314705882352942, 1.0) -(0.48442895176066186, 0.30635294117647061, 0.19509803921568628, 1.0) -(0.48927324127826849, 0.30941647058823529, 0.19704901960784313, 1.0) -(0.49411753079587512, 0.31248000000000004, 0.19900000000000001, 1.0) -(0.49896182031348174, 0.31554352941176472, 0.20095098039215686, 1.0) -(0.50380610983108831, 0.31860705882352941, 0.20290196078431372, 1.0) -(0.50865039934869494, 0.3216705882352941, 0.20485294117647057, 1.0) -(0.51349468886630156, 0.32473411764705878, 0.20680392156862742, 1.0) -(0.51833897838390819, 0.32779764705882353, 0.20875490196078431, 1.0) -(0.52318326790151481, 0.33086117647058821, 0.21070588235294116, 1.0) -(0.52802755741912144, 0.3339247058823529, 0.21265686274509804, 1.0) -(0.53287184693672807, 0.33698823529411764, 0.21460784313725492, 1.0) -(0.53771613645433469, 0.34005176470588239, 0.21655882352941178, 1.0) -(0.54256042597194132, 0.34311529411764707, 0.21850980392156863, 1.0) -(0.54740471548954794, 0.34617882352941176, 0.22046078431372548, 1.0) -(0.55224900500715446, 0.34924235294117645, 0.22241176470588234, 1.0) -(0.5570932945247612, 0.35230588235294119, 0.22436274509803922, 1.0) -(0.56193758404236782, 0.35536941176470588, 0.22631372549019607, 1.0) -(0.56678187355997445, 0.35843294117647057, 0.22826470588235293, 1.0) -(0.57162616307758107, 0.36149647058823531, 0.23021568627450981, 1.0) -(0.57647045259518759, 0.36456, 0.23216666666666666, 1.0) -(0.58131474211279421, 0.36762352941176468, 0.23411764705882351, 1.0) -(0.58615903163040084, 0.37068705882352943, 0.23606862745098037, 1.0) -(0.59100332114800747, 0.37375058823529411, 0.23801960784313725, 1.0) -(0.59584761066561409, 0.37681411764705885, 0.23997058823529413, 1.0) -(0.60069190018322072, 0.37987764705882354, 0.24192156862745098, 1.0) -(0.60553618970082734, 0.38294117647058823, 0.24387254901960784, 1.0) -(0.61038047921843397, 0.38600470588235297, 0.24582352941176472, 1.0) -(0.61522476873604059, 0.38906823529411766, 0.24777450980392157, 1.0) -(0.62006905825364722, 0.39213176470588235, 0.24972549019607843, 1.0) -(0.62491334777125385, 0.39519529411764703, 0.25167647058823528, 1.0) -(0.62975763728886047, 0.39825882352941172, 0.25362745098039213, 1.0) -(0.6346019268064671, 0.40132235294117641, 0.25557843137254899, 1.0) -(0.6394462163240735, 0.40438588235294115, 0.25752941176470584, 1.0) -(0.64429050584168035, 0.40744941176470589, 0.25948039215686275, 1.0) -(0.64913479535928698, 0.41051294117647058, 0.2614313725490196, 1.0) -(0.65397908487689349, 0.41357647058823532, 0.26338235294117646, 1.0) -(0.65882337439450012, 0.41664000000000001, 0.26533333333333331, 1.0) -(0.66366766391210674, 0.4197035294117647, 0.26728431372549016, 1.0) -(0.66851195342971337, 0.42276705882352938, 0.26923529411764702, 1.0) -(0.67335624294731999, 0.42583058823529407, 0.27118627450980387, 1.0) -(0.67820053246492662, 0.42889411764705887, 0.27313725490196078, 1.0) -(0.68304482198253325, 0.43195764705882356, 0.27508823529411769, 1.0) -(0.68788911150013987, 0.43502117647058824, 0.27703921568627454, 1.0) -(0.6927334010177465, 0.43808470588235293, 0.2789901960784314, 1.0) -(0.69757769053535312, 0.44114823529411762, 0.28094117647058825, 1.0) -(0.70242198005295975, 0.44421176470588236, 0.2828921568627451, 1.0) -(0.70726626957056637, 0.44727529411764705, 0.28484313725490196, 1.0) -(0.712110559088173, 0.45033882352941174, 0.28679411764705881, 1.0) -(0.7169548486057794, 0.45340235294117642, 0.28874509803921566, 1.0) -(0.72179913812338625, 0.45646588235294122, 0.29069607843137257, 1.0) -(0.72664342764099277, 0.45952941176470591, 0.29264705882352943, 1.0) -(0.73148771715859939, 0.4625929411764706, 0.29459803921568628, 1.0) -(0.73633200667620602, 0.46565647058823528, 0.29654901960784313, 1.0) -(0.74117629619381264, 0.46871999999999997, 0.29849999999999999, 1.0) -(0.74602058571141927, 0.47178352941176466, 0.30045098039215684, 1.0) -(0.7508648752290259, 0.4748470588235294, 0.30240196078431369, 1.0) -(0.75570916474663252, 0.47791058823529414, 0.3043529411764706, 1.0) -(0.76055345426423915, 0.48097411764705883, 0.30630392156862746, 1.0) -(0.76539774378184577, 0.48403764705882357, 0.30825490196078431, 1.0) -(0.7702420332994524, 0.48710117647058826, 0.31020588235294116, 1.0) -(0.77508632281705903, 0.49016470588235295, 0.31215686274509802, 1.0) -(0.77993061233466565, 0.49322823529411763, 0.31410784313725487, 1.0) -(0.78477490185227228, 0.49629176470588232, 0.31605882352941173, 1.0) -(0.7896191913698789, 0.49935529411764701, 0.31800980392156858, 1.0) -(0.79446348088748531, 0.5024188235294117, 0.31996078431372543, 1.0) -(0.79930777040509216, 0.50548235294117649, 0.32191176470588234, 1.0) -(0.80415205992269867, 0.50854588235294118, 0.32386274509803925, 1.0) -(0.8089963494403053, 0.51160941176470587, 0.3258137254901961, 1.0) -(0.81384063895791192, 0.51467294117647056, 0.32776470588235296, 1.0) -(0.81868492847551855, 0.51773647058823524, 0.32971568627450981, 1.0) -(0.82352921799312517, 0.52079999999999993, 0.33166666666666667, 1.0) -(0.8283735075107318, 0.52386352941176462, 0.33361764705882352, 1.0) -(0.83321779702833842, 0.52692705882352942, 0.33556862745098043, 1.0) -(0.83806208654594505, 0.5299905882352941, 0.33751960784313728, 1.0) -(0.84290637606355168, 0.53305411764705879, 0.33947058823529414, 1.0) -(0.8477506655811583, 0.53611764705882359, 0.34142156862745099, 1.0) -(0.85259495509876493, 0.53918117647058827, 0.34337254901960784, 1.0) -(0.85743924461637155, 0.54224470588235296, 0.3453235294117647, 1.0) -(0.86228353413397818, 0.54530823529411765, 0.34727450980392155, 1.0) -(0.86712782365158481, 0.54837176470588234, 0.3492254901960784, 1.0) -(0.87197211316919121, 0.55143529411764702, 0.35117647058823526, 1.0) -(0.87681640268679806, 0.55449882352941182, 0.35312745098039217, 1.0) -(0.88166069220440457, 0.55756235294117651, 0.35507843137254902, 1.0) -(0.8865049817220112, 0.5606258823529412, 0.35702941176470587, 1.0) -(0.89134927123961782, 0.56368941176470588, 0.35898039215686273, 1.0) -(0.89619356075722445, 0.56675294117647057, 0.36093137254901958, 1.0) -(0.90103785027483108, 0.56981647058823526, 0.36288235294117643, 1.0) -(0.9058821397924377, 0.57287999999999994, 0.36483333333333329, 1.0) -(0.91072642931004433, 0.57594352941176474, 0.3667843137254902, 1.0) -(0.91557071882765095, 0.57900705882352943, 0.36873529411764705, 1.0) -(0.92041500834525758, 0.58207058823529412, 0.3706862745098039, 1.0) -(0.92525929786286421, 0.5851341176470588, 0.37263725490196076, 1.0) -(0.93010358738047083, 0.58819764705882349, 0.37458823529411767, 1.0) -(0.93494787689807746, 0.59126117647058818, 0.37653921568627452, 1.0) -(0.93979216641568408, 0.59432470588235287, 0.37849019607843137, 1.0) -(0.94463645593329071, 0.59738823529411766, 0.38044117647058823, 1.0) -(0.94948074545089711, 0.60045176470588235, 0.38239215686274508, 1.0) -(0.95432503496850396, 0.60351529411764704, 0.38434313725490199, 1.0) -(0.95916932448611048, 0.60657882352941184, 0.38629411764705884, 1.0) -(0.9640136140037171, 0.60964235294117652, 0.3882450980392157, 1.0) -(0.96885790352132373, 0.61270588235294121, 0.39019607843137255, 1.0) -(0.97370219303893035, 0.6157694117647059, 0.3921470588235294, 1.0) -(0.97854648255653698, 0.61883294117647059, 0.39409803921568626, 1.0) -(0.9833907720741436, 0.62189647058823527, 0.39604901960784311, 1.0) -(0.98823506159175023, 0.62496000000000007, 0.39800000000000002, 1.0) -(0.99307935110935686, 0.62802352941176476, 0.39995098039215687, 1.0) -(0.99792364062696348, 0.63108705882352945, 0.40190196078431373, 1.0) -(1.0, 0.63415058823529413, 0.40385294117647058, 1.0) -(1.0, 0.63721411764705882, 0.40580392156862743, 1.0) -(1.0, 0.64027764705882351, 0.40775490196078429, 1.0) -(1.0, 0.64334117647058819, 0.40970588235294114, 1.0) -(1.0, 0.64640470588235288, 0.411656862745098, 1.0) -(1.0, 0.64946823529411757, 0.41360784313725485, 1.0) -(1.0, 0.65253176470588237, 0.41555882352941176, 1.0) -(1.0, 0.65559529411764705, 0.41750980392156861, 1.0) -(1.0, 0.65865882352941174, 0.41946078431372547, 1.0) -(1.0, 0.66172235294117643, 0.42141176470588232, 1.0) -(1.0, 0.66478588235294112, 0.42336274509803923, 1.0) -(1.0, 0.6678494117647058, 0.42531372549019608, 1.0) -(1.0, 0.6709129411764706, 0.42726470588235294, 1.0) -(1.0, 0.67397647058823529, 0.42921568627450984, 1.0) -(1.0, 0.67703999999999998, 0.4311666666666667, 1.0) -(1.0, 0.68010352941176477, 0.43311764705882355, 1.0) -(1.0, 0.68316705882352946, 0.43506862745098041, 1.0) -(1.0, 0.68623058823529415, 0.43701960784313726, 1.0) -(1.0, 0.68929411764705883, 0.43897058823529411, 1.0) -(1.0, 0.69235764705882352, 0.44092156862745097, 1.0) -(1.0, 0.69542117647058821, 0.44287254901960782, 1.0) -(1.0, 0.6984847058823529, 0.44482352941176467, 1.0) -(1.0, 0.70154823529411769, 0.44677450980392158, 1.0) -(1.0, 0.70461176470588238, 0.44872549019607844, 1.0) -(1.0, 0.70767529411764707, 0.45067647058823529, 1.0) -(1.0, 0.71073882352941176, 0.45262745098039214, 1.0) -(1.0, 0.71380235294117644, 0.454578431372549, 1.0) -(1.0, 0.71686588235294113, 0.45652941176470585, 1.0) -(1.0, 0.71992941176470582, 0.4584803921568627, 1.0) -(1.0, 0.72299294117647062, 0.46043137254901961, 1.0) -(1.0, 0.7260564705882353, 0.46238235294117647, 1.0) -(1.0, 0.72911999999999999, 0.46433333333333332, 1.0) -(1.0, 0.73218352941176468, 0.46628431372549017, 1.0) -(1.0, 0.73524705882352936, 0.46823529411764703, 1.0) -(1.0, 0.73831058823529405, 0.47018627450980388, 1.0) -(1.0, 0.74137411764705885, 0.47213725490196073, 1.0) -(1.0, 0.74443764705882354, 0.47408823529411764, 1.0) -(1.0, 0.74750117647058822, 0.4760392156862745, 1.0) -(1.0, 0.75056470588235302, 0.47799019607843141, 1.0) -(1.0, 0.75362823529411771, 0.47994117647058826, 1.0) -(1.0, 0.7566917647058824, 0.48189215686274511, 1.0) -(1.0, 0.75975529411764708, 0.48384313725490197, 1.0) -(1.0, 0.76281882352941177, 0.48579411764705882, 1.0) -(1.0, 0.76588235294117646, 0.48774509803921567, 1.0) -(1.0, 0.76894588235294115, 0.48969607843137253, 1.0) -(1.0, 0.77200941176470594, 0.49164705882352944, 1.0) -(1.0, 0.77507294117647063, 0.49359803921568629, 1.0) -(1.0, 0.77813647058823532, 0.49554901960784314, 1.0) -(1.0, 0.78120000000000001, 0.4975, 1.0) diff --git a/extern/tfn/colormaps/sequential2/gist_gray.cpp b/extern/tfn/colormaps/sequential2/gist_gray.cpp deleted file mode 100644 index 603e8e4..0000000 --- a/extern/tfn/colormaps/sequential2/gist_gray.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential2_gist_gray; -} -const std::vector colormap::data_sequential2_gist_gray = /* NOLINT(cert-err58-cpp) */ -{ -{0.0f, 0.0f, 0.0f, 1.0f}, -{0.0039215686274509803f, 0.0039215686274509803f, 0.0039215686274509803f, 1.0f}, -{0.0078431372549019607f, 0.0078431372549019607f, 0.0078431372549019607f, 1.0f}, -{0.011764705882352941f, 0.011764705882352941f, 0.011764705882352941f, 1.0f}, -{0.015686274509803921f, 0.015686274509803921f, 0.015686274509803921f, 1.0f}, -{0.019607843137254902f, 0.019607843137254902f, 0.019607843137254902f, 1.0f}, -{0.023529411764705882f, 0.023529411764705882f, 0.023529411764705882f, 1.0f}, -{0.027450980392156862f, 0.027450980392156862f, 0.027450980392156862f, 1.0f}, -{0.031372549019607843f, 0.031372549019607843f, 0.031372549019607843f, 1.0f}, -{0.035294117647058823f, 0.035294117647058823f, 0.035294117647058823f, 1.0f}, -{0.039215686274509803f, 0.039215686274509803f, 0.039215686274509803f, 1.0f}, -{0.043137254901960784f, 0.043137254901960784f, 0.043137254901960784f, 1.0f}, -{0.047058823529411764f, 0.047058823529411764f, 0.047058823529411764f, 1.0f}, -{0.050980392156862744f, 0.050980392156862744f, 0.050980392156862744f, 1.0f}, -{0.054901960784313725f, 0.054901960784313725f, 0.054901960784313725f, 1.0f}, -{0.058823529411764705f, 0.058823529411764705f, 0.058823529411764705f, 1.0f}, -{0.062745098039215685f, 0.062745098039215685f, 0.062745098039215685f, 1.0f}, -{0.066666666666666666f, 0.066666666666666666f, 0.066666666666666666f, 1.0f}, -{0.070588235294117646f, 0.070588235294117646f, 0.070588235294117646f, 1.0f}, -{0.074509803921568626f, 0.074509803921568626f, 0.074509803921568626f, 1.0f}, -{0.078431372549019607f, 0.078431372549019607f, 0.078431372549019607f, 1.0f}, -{0.082352941176470587f, 0.082352941176470587f, 0.082352941176470587f, 1.0f}, -{0.086274509803921567f, 0.086274509803921567f, 0.086274509803921567f, 1.0f}, -{0.090196078431372548f, 0.090196078431372548f, 0.090196078431372548f, 1.0f}, -{0.094117647058823528f, 0.094117647058823528f, 0.094117647058823528f, 1.0f}, -{0.098039215686274508f, 0.098039215686274508f, 0.098039215686274508f, 1.0f}, -{0.10196078431372549f, 0.10196078431372549f, 0.10196078431372549f, 1.0f}, -{0.10588235294117647f, 0.10588235294117647f, 0.10588235294117647f, 1.0f}, -{0.10980392156862745f, 0.10980392156862745f, 0.10980392156862745f, 1.0f}, -{0.11372549019607843f, 0.11372549019607843f, 0.11372549019607843f, 1.0f}, -{0.11764705882352941f, 0.11764705882352941f, 0.11764705882352941f, 1.0f}, -{0.12156862745098039f, 0.12156862745098039f, 0.12156862745098039f, 1.0f}, -{0.12549019607843137f, 0.12549019607843137f, 0.12549019607843137f, 1.0f}, -{0.12941176470588234f, 0.12941176470588234f, 0.12941176470588234f, 1.0f}, -{0.13333333333333333f, 0.13333333333333333f, 0.13333333333333333f, 1.0f}, -{0.13725490196078433f, 0.13725490196078433f, 0.13725490196078433f, 1.0f}, -{0.14117647058823529f, 0.14117647058823529f, 0.14117647058823529f, 1.0f}, -{0.14509803921568626f, 0.14509803921568626f, 0.14509803921568626f, 1.0f}, -{0.14901960784313725f, 0.14901960784313725f, 0.14901960784313725f, 1.0f}, -{0.15294117647058825f, 0.15294117647058825f, 0.15294117647058825f, 1.0f}, -{0.15686274509803921f, 0.15686274509803921f, 0.15686274509803921f, 1.0f}, -{0.16078431372549018f, 0.16078431372549018f, 0.16078431372549018f, 1.0f}, -{0.16470588235294117f, 0.16470588235294117f, 0.16470588235294117f, 1.0f}, -{0.16862745098039217f, 0.16862745098039217f, 0.16862745098039217f, 1.0f}, -{0.17254901960784313f, 0.17254901960784313f, 0.17254901960784313f, 1.0f}, -{0.1764705882352941f, 0.1764705882352941f, 0.1764705882352941f, 1.0f}, -{0.1803921568627451f, 0.1803921568627451f, 0.1803921568627451f, 1.0f}, -{0.18431372549019609f, 0.18431372549019609f, 0.18431372549019609f, 1.0f}, -{0.18823529411764706f, 0.18823529411764706f, 0.18823529411764706f, 1.0f}, -{0.19215686274509802f, 0.19215686274509802f, 0.19215686274509802f, 1.0f}, -{0.19607843137254902f, 0.19607843137254902f, 0.19607843137254902f, 1.0f}, -{0.20000000000000001f, 0.20000000000000001f, 0.20000000000000001f, 1.0f}, -{0.20392156862745098f, 0.20392156862745098f, 0.20392156862745098f, 1.0f}, -{0.20784313725490194f, 0.20784313725490194f, 0.20784313725490194f, 1.0f}, -{0.21176470588235294f, 0.21176470588235294f, 0.21176470588235294f, 1.0f}, -{0.21568627450980393f, 0.21568627450980393f, 0.21568627450980393f, 1.0f}, -{0.2196078431372549f, 0.2196078431372549f, 0.2196078431372549f, 1.0f}, -{0.22352941176470587f, 0.22352941176470587f, 0.22352941176470587f, 1.0f}, -{0.22745098039215686f, 0.22745098039215686f, 0.22745098039215686f, 1.0f}, -{0.23137254901960785f, 0.23137254901960785f, 0.23137254901960785f, 1.0f}, -{0.23529411764705882f, 0.23529411764705882f, 0.23529411764705882f, 1.0f}, -{0.23921568627450979f, 0.23921568627450979f, 0.23921568627450979f, 1.0f}, -{0.24313725490196078f, 0.24313725490196078f, 0.24313725490196078f, 1.0f}, -{0.24705882352941178f, 0.24705882352941178f, 0.24705882352941178f, 1.0f}, -{0.25098039215686274f, 0.25098039215686274f, 0.25098039215686274f, 1.0f}, -{0.25490196078431371f, 0.25490196078431371f, 0.25490196078431371f, 1.0f}, -{0.25882352941176467f, 0.25882352941176467f, 0.25882352941176467f, 1.0f}, -{0.2627450980392157f, 0.2627450980392157f, 0.2627450980392157f, 1.0f}, -{0.26666666666666666f, 0.26666666666666666f, 0.26666666666666666f, 1.0f}, -{0.27058823529411763f, 0.27058823529411763f, 0.27058823529411763f, 1.0f}, -{0.27450980392156865f, 0.27450980392156865f, 0.27450980392156865f, 1.0f}, -{0.27843137254901962f, 0.27843137254901962f, 0.27843137254901962f, 1.0f}, -{0.28235294117647058f, 0.28235294117647058f, 0.28235294117647058f, 1.0f}, -{0.28627450980392155f, 0.28627450980392155f, 0.28627450980392155f, 1.0f}, -{0.29019607843137252f, 0.29019607843137252f, 0.29019607843137252f, 1.0f}, -{0.29411764705882354f, 0.29411764705882354f, 0.29411764705882354f, 1.0f}, -{0.29803921568627451f, 0.29803921568627451f, 0.29803921568627451f, 1.0f}, -{0.30196078431372547f, 0.30196078431372547f, 0.30196078431372547f, 1.0f}, -{0.30588235294117649f, 0.30588235294117649f, 0.30588235294117649f, 1.0f}, -{0.30980392156862746f, 0.30980392156862746f, 0.30980392156862746f, 1.0f}, -{0.31372549019607843f, 0.31372549019607843f, 0.31372549019607843f, 1.0f}, -{0.31764705882352939f, 0.31764705882352939f, 0.31764705882352939f, 1.0f}, -{0.32156862745098036f, 0.32156862745098036f, 0.32156862745098036f, 1.0f}, -{0.32549019607843138f, 0.32549019607843138f, 0.32549019607843138f, 1.0f}, -{0.32941176470588235f, 0.32941176470588235f, 0.32941176470588235f, 1.0f}, -{0.33333333333333331f, 0.33333333333333331f, 0.33333333333333331f, 1.0f}, -{0.33725490196078434f, 0.33725490196078434f, 0.33725490196078434f, 1.0f}, -{0.3411764705882353f, 0.3411764705882353f, 0.3411764705882353f, 1.0f}, -{0.34509803921568627f, 0.34509803921568627f, 0.34509803921568627f, 1.0f}, -{0.34901960784313724f, 0.34901960784313724f, 0.34901960784313724f, 1.0f}, -{0.3529411764705882f, 0.3529411764705882f, 0.3529411764705882f, 1.0f}, -{0.35686274509803922f, 0.35686274509803922f, 0.35686274509803922f, 1.0f}, -{0.36078431372549019f, 0.36078431372549019f, 0.36078431372549019f, 1.0f}, -{0.36470588235294116f, 0.36470588235294116f, 0.36470588235294116f, 1.0f}, -{0.36862745098039218f, 0.36862745098039218f, 0.36862745098039218f, 1.0f}, -{0.37254901960784315f, 0.37254901960784315f, 0.37254901960784315f, 1.0f}, -{0.37647058823529411f, 0.37647058823529411f, 0.37647058823529411f, 1.0f}, -{0.38039215686274508f, 0.38039215686274508f, 0.38039215686274508f, 1.0f}, -{0.38431372549019605f, 0.38431372549019605f, 0.38431372549019605f, 1.0f}, -{0.38823529411764707f, 0.38823529411764707f, 0.38823529411764707f, 1.0f}, -{0.39215686274509803f, 0.39215686274509803f, 0.39215686274509803f, 1.0f}, -{0.396078431372549f, 0.396078431372549f, 0.396078431372549f, 1.0f}, -{0.40000000000000002f, 0.40000000000000002f, 0.40000000000000002f, 1.0f}, -{0.40392156862745099f, 0.40392156862745099f, 0.40392156862745099f, 1.0f}, -{0.40784313725490196f, 0.40784313725490196f, 0.40784313725490196f, 1.0f}, -{0.41176470588235292f, 0.41176470588235292f, 0.41176470588235292f, 1.0f}, -{0.41568627450980389f, 0.41568627450980389f, 0.41568627450980389f, 1.0f}, -{0.41960784313725491f, 0.41960784313725491f, 0.41960784313725491f, 1.0f}, -{0.42352941176470588f, 0.42352941176470588f, 0.42352941176470588f, 1.0f}, -{0.42745098039215684f, 0.42745098039215684f, 0.42745098039215684f, 1.0f}, -{0.43137254901960786f, 0.43137254901960786f, 0.43137254901960786f, 1.0f}, -{0.43529411764705883f, 0.43529411764705883f, 0.43529411764705883f, 1.0f}, -{0.4392156862745098f, 0.4392156862745098f, 0.4392156862745098f, 1.0f}, -{0.44313725490196076f, 0.44313725490196076f, 0.44313725490196076f, 1.0f}, -{0.44705882352941173f, 0.44705882352941173f, 0.44705882352941173f, 1.0f}, -{0.45098039215686275f, 0.45098039215686275f, 0.45098039215686275f, 1.0f}, -{0.45490196078431372f, 0.45490196078431372f, 0.45490196078431372f, 1.0f}, -{0.45882352941176469f, 0.45882352941176469f, 0.45882352941176469f, 1.0f}, -{0.46274509803921571f, 0.46274509803921571f, 0.46274509803921571f, 1.0f}, -{0.46666666666666667f, 0.46666666666666667f, 0.46666666666666667f, 1.0f}, -{0.47058823529411764f, 0.47058823529411764f, 0.47058823529411764f, 1.0f}, -{0.47450980392156861f, 0.47450980392156861f, 0.47450980392156861f, 1.0f}, -{0.47843137254901957f, 0.47843137254901957f, 0.47843137254901957f, 1.0f}, -{0.4823529411764706f, 0.4823529411764706f, 0.4823529411764706f, 1.0f}, -{0.48627450980392156f, 0.48627450980392156f, 0.48627450980392156f, 1.0f}, -{0.49019607843137253f, 0.49019607843137253f, 0.49019607843137253f, 1.0f}, -{0.49411764705882355f, 0.49411764705882355f, 0.49411764705882355f, 1.0f}, -{0.49803921568627452f, 0.49803921568627452f, 0.49803921568627452f, 1.0f}, -{0.50196078431372548f, 0.50196078431372548f, 0.50196078431372548f, 1.0f}, -{0.50588235294117645f, 0.50588235294117645f, 0.50588235294117645f, 1.0f}, -{0.50980392156862742f, 0.50980392156862742f, 0.50980392156862742f, 1.0f}, -{0.51372549019607838f, 0.51372549019607838f, 0.51372549019607838f, 1.0f}, -{0.51764705882352935f, 0.51764705882352935f, 0.51764705882352935f, 1.0f}, -{0.52156862745098043f, 0.52156862745098043f, 0.52156862745098043f, 1.0f}, -{0.52549019607843139f, 0.52549019607843139f, 0.52549019607843139f, 1.0f}, -{0.52941176470588236f, 0.52941176470588236f, 0.52941176470588236f, 1.0f}, -{0.53333333333333333f, 0.53333333333333333f, 0.53333333333333333f, 1.0f}, -{0.53725490196078429f, 0.53725490196078429f, 0.53725490196078429f, 1.0f}, -{0.54117647058823526f, 0.54117647058823526f, 0.54117647058823526f, 1.0f}, -{0.54509803921568623f, 0.54509803921568623f, 0.54509803921568623f, 1.0f}, -{0.5490196078431373f, 0.5490196078431373f, 0.5490196078431373f, 1.0f}, -{0.55294117647058827f, 0.55294117647058827f, 0.55294117647058827f, 1.0f}, -{0.55686274509803924f, 0.55686274509803924f, 0.55686274509803924f, 1.0f}, -{0.5607843137254902f, 0.5607843137254902f, 0.5607843137254902f, 1.0f}, -{0.56470588235294117f, 0.56470588235294117f, 0.56470588235294117f, 1.0f}, -{0.56862745098039214f, 0.56862745098039214f, 0.56862745098039214f, 1.0f}, -{0.5725490196078431f, 0.5725490196078431f, 0.5725490196078431f, 1.0f}, -{0.57647058823529407f, 0.57647058823529407f, 0.57647058823529407f, 1.0f}, -{0.58039215686274503f, 0.58039215686274503f, 0.58039215686274503f, 1.0f}, -{0.58431372549019611f, 0.58431372549019611f, 0.58431372549019611f, 1.0f}, -{0.58823529411764708f, 0.58823529411764708f, 0.58823529411764708f, 1.0f}, -{0.59215686274509804f, 0.59215686274509804f, 0.59215686274509804f, 1.0f}, -{0.59607843137254901f, 0.59607843137254901f, 0.59607843137254901f, 1.0f}, -{0.59999999999999998f, 0.59999999999999998f, 0.59999999999999998f, 1.0f}, -{0.60392156862745094f, 0.60392156862745094f, 0.60392156862745094f, 1.0f}, -{0.60784313725490191f, 0.60784313725490191f, 0.60784313725490191f, 1.0f}, -{0.61176470588235299f, 0.61176470588235299f, 0.61176470588235299f, 1.0f}, -{0.61568627450980395f, 0.61568627450980395f, 0.61568627450980395f, 1.0f}, -{0.61960784313725492f, 0.61960784313725492f, 0.61960784313725492f, 1.0f}, -{0.62352941176470589f, 0.62352941176470589f, 0.62352941176470589f, 1.0f}, -{0.62745098039215685f, 0.62745098039215685f, 0.62745098039215685f, 1.0f}, -{0.63137254901960782f, 0.63137254901960782f, 0.63137254901960782f, 1.0f}, -{0.63529411764705879f, 0.63529411764705879f, 0.63529411764705879f, 1.0f}, -{0.63921568627450975f, 0.63921568627450975f, 0.63921568627450975f, 1.0f}, -{0.64313725490196072f, 0.64313725490196072f, 0.64313725490196072f, 1.0f}, -{0.6470588235294118f, 0.6470588235294118f, 0.6470588235294118f, 1.0f}, -{0.65098039215686276f, 0.65098039215686276f, 0.65098039215686276f, 1.0f}, -{0.65490196078431373f, 0.65490196078431373f, 0.65490196078431373f, 1.0f}, -{0.6588235294117647f, 0.6588235294117647f, 0.6588235294117647f, 1.0f}, -{0.66274509803921566f, 0.66274509803921566f, 0.66274509803921566f, 1.0f}, -{0.66666666666666663f, 0.66666666666666663f, 0.66666666666666663f, 1.0f}, -{0.6705882352941176f, 0.6705882352941176f, 0.6705882352941176f, 1.0f}, -{0.67450980392156867f, 0.67450980392156867f, 0.67450980392156867f, 1.0f}, -{0.67843137254901964f, 0.67843137254901964f, 0.67843137254901964f, 1.0f}, -{0.68235294117647061f, 0.68235294117647061f, 0.68235294117647061f, 1.0f}, -{0.68627450980392157f, 0.68627450980392157f, 0.68627450980392157f, 1.0f}, -{0.69019607843137254f, 0.69019607843137254f, 0.69019607843137254f, 1.0f}, -{0.69411764705882351f, 0.69411764705882351f, 0.69411764705882351f, 1.0f}, -{0.69803921568627447f, 0.69803921568627447f, 0.69803921568627447f, 1.0f}, -{0.70196078431372544f, 0.70196078431372544f, 0.70196078431372544f, 1.0f}, -{0.70588235294117641f, 0.70588235294117641f, 0.70588235294117641f, 1.0f}, -{0.70980392156862748f, 0.70980392156862748f, 0.70980392156862748f, 1.0f}, -{0.71372549019607845f, 0.71372549019607845f, 0.71372549019607845f, 1.0f}, -{0.71764705882352942f, 0.71764705882352942f, 0.71764705882352942f, 1.0f}, -{0.72156862745098038f, 0.72156862745098038f, 0.72156862745098038f, 1.0f}, -{0.72549019607843135f, 0.72549019607843135f, 0.72549019607843135f, 1.0f}, -{0.72941176470588232f, 0.72941176470588232f, 0.72941176470588232f, 1.0f}, -{0.73333333333333328f, 0.73333333333333328f, 0.73333333333333328f, 1.0f}, -{0.73725490196078436f, 0.73725490196078436f, 0.73725490196078436f, 1.0f}, -{0.74117647058823533f, 0.74117647058823533f, 0.74117647058823533f, 1.0f}, -{0.74509803921568629f, 0.74509803921568629f, 0.74509803921568629f, 1.0f}, -{0.74901960784313726f, 0.74901960784313726f, 0.74901960784313726f, 1.0f}, -{0.75294117647058822f, 0.75294117647058822f, 0.75294117647058822f, 1.0f}, -{0.75686274509803919f, 0.75686274509803919f, 0.75686274509803919f, 1.0f}, -{0.76078431372549016f, 0.76078431372549016f, 0.76078431372549016f, 1.0f}, -{0.76470588235294112f, 0.76470588235294112f, 0.76470588235294112f, 1.0f}, -{0.76862745098039209f, 0.76862745098039209f, 0.76862745098039209f, 1.0f}, -{0.77254901960784317f, 0.77254901960784317f, 0.77254901960784317f, 1.0f}, -{0.77647058823529413f, 0.77647058823529413f, 0.77647058823529413f, 1.0f}, -{0.7803921568627451f, 0.7803921568627451f, 0.7803921568627451f, 1.0f}, -{0.78431372549019607f, 0.78431372549019607f, 0.78431372549019607f, 1.0f}, -{0.78823529411764703f, 0.78823529411764703f, 0.78823529411764703f, 1.0f}, -{0.792156862745098f, 0.792156862745098f, 0.792156862745098f, 1.0f}, -{0.79607843137254897f, 0.79607843137254897f, 0.79607843137254897f, 1.0f}, -{0.80000000000000004f, 0.80000000000000004f, 0.80000000000000004f, 1.0f}, -{0.80392156862745101f, 0.80392156862745101f, 0.80392156862745101f, 1.0f}, -{0.80784313725490198f, 0.80784313725490198f, 0.80784313725490198f, 1.0f}, -{0.81176470588235294f, 0.81176470588235294f, 0.81176470588235294f, 1.0f}, -{0.81568627450980391f, 0.81568627450980391f, 0.81568627450980391f, 1.0f}, -{0.81960784313725488f, 0.81960784313725488f, 0.81960784313725488f, 1.0f}, -{0.82352941176470584f, 0.82352941176470584f, 0.82352941176470584f, 1.0f}, -{0.82745098039215681f, 0.82745098039215681f, 0.82745098039215681f, 1.0f}, -{0.83137254901960778f, 0.83137254901960778f, 0.83137254901960778f, 1.0f}, -{0.83529411764705885f, 0.83529411764705885f, 0.83529411764705885f, 1.0f}, -{0.83921568627450982f, 0.83921568627450982f, 0.83921568627450982f, 1.0f}, -{0.84313725490196079f, 0.84313725490196079f, 0.84313725490196079f, 1.0f}, -{0.84705882352941175f, 0.84705882352941175f, 0.84705882352941175f, 1.0f}, -{0.85098039215686272f, 0.85098039215686272f, 0.85098039215686272f, 1.0f}, -{0.85490196078431369f, 0.85490196078431369f, 0.85490196078431369f, 1.0f}, -{0.85882352941176465f, 0.85882352941176465f, 0.85882352941176465f, 1.0f}, -{0.86274509803921573f, 0.86274509803921573f, 0.86274509803921573f, 1.0f}, -{0.8666666666666667f, 0.8666666666666667f, 0.8666666666666667f, 1.0f}, -{0.87058823529411766f, 0.87058823529411766f, 0.87058823529411766f, 1.0f}, -{0.87450980392156863f, 0.87450980392156863f, 0.87450980392156863f, 1.0f}, -{0.8784313725490196f, 0.8784313725490196f, 0.8784313725490196f, 1.0f}, -{0.88235294117647056f, 0.88235294117647056f, 0.88235294117647056f, 1.0f}, -{0.88627450980392153f, 0.88627450980392153f, 0.88627450980392153f, 1.0f}, -{0.8901960784313725f, 0.8901960784313725f, 0.8901960784313725f, 1.0f}, -{0.89411764705882346f, 0.89411764705882346f, 0.89411764705882346f, 1.0f}, -{0.89803921568627454f, 0.89803921568627454f, 0.89803921568627454f, 1.0f}, -{0.90196078431372551f, 0.90196078431372551f, 0.90196078431372551f, 1.0f}, -{0.90588235294117647f, 0.90588235294117647f, 0.90588235294117647f, 1.0f}, -{0.90980392156862744f, 0.90980392156862744f, 0.90980392156862744f, 1.0f}, -{0.9137254901960784f, 0.9137254901960784f, 0.9137254901960784f, 1.0f}, -{0.91764705882352937f, 0.91764705882352937f, 0.91764705882352937f, 1.0f}, -{0.92156862745098034f, 0.92156862745098034f, 0.92156862745098034f, 1.0f}, -{0.92549019607843142f, 0.92549019607843142f, 0.92549019607843142f, 1.0f}, -{0.92941176470588238f, 0.92941176470588238f, 0.92941176470588238f, 1.0f}, -{0.93333333333333335f, 0.93333333333333335f, 0.93333333333333335f, 1.0f}, -{0.93725490196078431f, 0.93725490196078431f, 0.93725490196078431f, 1.0f}, -{0.94117647058823528f, 0.94117647058823528f, 0.94117647058823528f, 1.0f}, -{0.94509803921568625f, 0.94509803921568625f, 0.94509803921568625f, 1.0f}, -{0.94901960784313721f, 0.94901960784313721f, 0.94901960784313721f, 1.0f}, -{0.95294117647058818f, 0.95294117647058818f, 0.95294117647058818f, 1.0f}, -{0.95686274509803915f, 0.95686274509803915f, 0.95686274509803915f, 1.0f}, -{0.96078431372549022f, 0.96078431372549022f, 0.96078431372549022f, 1.0f}, -{0.96470588235294119f, 0.96470588235294119f, 0.96470588235294119f, 1.0f}, -{0.96862745098039216f, 0.96862745098039216f, 0.96862745098039216f, 1.0f}, -{0.97254901960784312f, 0.97254901960784312f, 0.97254901960784312f, 1.0f}, -{0.97647058823529409f, 0.97647058823529409f, 0.97647058823529409f, 1.0f}, -{0.98039215686274506f, 0.98039215686274506f, 0.98039215686274506f, 1.0f}, -{0.98431372549019602f, 0.98431372549019602f, 0.98431372549019602f, 1.0f}, -{0.9882352941176471f, 0.9882352941176471f, 0.9882352941176471f, 1.0f}, -{0.99215686274509807f, 0.99215686274509807f, 0.99215686274509807f, 1.0f}, -{0.99607843137254903f, 0.99607843137254903f, 0.99607843137254903f, 1.0f}, -{1.0f, 1.0f, 1.0f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential2/gist_gray.txt b/extern/tfn/colormaps/sequential2/gist_gray.txt deleted file mode 100644 index 3cc6aef..0000000 --- a/extern/tfn/colormaps/sequential2/gist_gray.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.0, 0.0, 0.0, 1.0) -(0.0039215686274509803, 0.0039215686274509803, 0.0039215686274509803, 1.0) -(0.0078431372549019607, 0.0078431372549019607, 0.0078431372549019607, 1.0) -(0.011764705882352941, 0.011764705882352941, 0.011764705882352941, 1.0) -(0.015686274509803921, 0.015686274509803921, 0.015686274509803921, 1.0) -(0.019607843137254902, 0.019607843137254902, 0.019607843137254902, 1.0) -(0.023529411764705882, 0.023529411764705882, 0.023529411764705882, 1.0) -(0.027450980392156862, 0.027450980392156862, 0.027450980392156862, 1.0) -(0.031372549019607843, 0.031372549019607843, 0.031372549019607843, 1.0) -(0.035294117647058823, 0.035294117647058823, 0.035294117647058823, 1.0) -(0.039215686274509803, 0.039215686274509803, 0.039215686274509803, 1.0) -(0.043137254901960784, 0.043137254901960784, 0.043137254901960784, 1.0) -(0.047058823529411764, 0.047058823529411764, 0.047058823529411764, 1.0) -(0.050980392156862744, 0.050980392156862744, 0.050980392156862744, 1.0) -(0.054901960784313725, 0.054901960784313725, 0.054901960784313725, 1.0) -(0.058823529411764705, 0.058823529411764705, 0.058823529411764705, 1.0) -(0.062745098039215685, 0.062745098039215685, 0.062745098039215685, 1.0) -(0.066666666666666666, 0.066666666666666666, 0.066666666666666666, 1.0) -(0.070588235294117646, 0.070588235294117646, 0.070588235294117646, 1.0) -(0.074509803921568626, 0.074509803921568626, 0.074509803921568626, 1.0) -(0.078431372549019607, 0.078431372549019607, 0.078431372549019607, 1.0) -(0.082352941176470587, 0.082352941176470587, 0.082352941176470587, 1.0) -(0.086274509803921567, 0.086274509803921567, 0.086274509803921567, 1.0) -(0.090196078431372548, 0.090196078431372548, 0.090196078431372548, 1.0) -(0.094117647058823528, 0.094117647058823528, 0.094117647058823528, 1.0) -(0.098039215686274508, 0.098039215686274508, 0.098039215686274508, 1.0) -(0.10196078431372549, 0.10196078431372549, 0.10196078431372549, 1.0) -(0.10588235294117647, 0.10588235294117647, 0.10588235294117647, 1.0) -(0.10980392156862745, 0.10980392156862745, 0.10980392156862745, 1.0) -(0.11372549019607843, 0.11372549019607843, 0.11372549019607843, 1.0) -(0.11764705882352941, 0.11764705882352941, 0.11764705882352941, 1.0) -(0.12156862745098039, 0.12156862745098039, 0.12156862745098039, 1.0) -(0.12549019607843137, 0.12549019607843137, 0.12549019607843137, 1.0) -(0.12941176470588234, 0.12941176470588234, 0.12941176470588234, 1.0) -(0.13333333333333333, 0.13333333333333333, 0.13333333333333333, 1.0) -(0.13725490196078433, 0.13725490196078433, 0.13725490196078433, 1.0) -(0.14117647058823529, 0.14117647058823529, 0.14117647058823529, 1.0) -(0.14509803921568626, 0.14509803921568626, 0.14509803921568626, 1.0) -(0.14901960784313725, 0.14901960784313725, 0.14901960784313725, 1.0) -(0.15294117647058825, 0.15294117647058825, 0.15294117647058825, 1.0) -(0.15686274509803921, 0.15686274509803921, 0.15686274509803921, 1.0) -(0.16078431372549018, 0.16078431372549018, 0.16078431372549018, 1.0) -(0.16470588235294117, 0.16470588235294117, 0.16470588235294117, 1.0) -(0.16862745098039217, 0.16862745098039217, 0.16862745098039217, 1.0) -(0.17254901960784313, 0.17254901960784313, 0.17254901960784313, 1.0) -(0.1764705882352941, 0.1764705882352941, 0.1764705882352941, 1.0) -(0.1803921568627451, 0.1803921568627451, 0.1803921568627451, 1.0) -(0.18431372549019609, 0.18431372549019609, 0.18431372549019609, 1.0) -(0.18823529411764706, 0.18823529411764706, 0.18823529411764706, 1.0) -(0.19215686274509802, 0.19215686274509802, 0.19215686274509802, 1.0) -(0.19607843137254902, 0.19607843137254902, 0.19607843137254902, 1.0) -(0.20000000000000001, 0.20000000000000001, 0.20000000000000001, 1.0) -(0.20392156862745098, 0.20392156862745098, 0.20392156862745098, 1.0) -(0.20784313725490194, 0.20784313725490194, 0.20784313725490194, 1.0) -(0.21176470588235294, 0.21176470588235294, 0.21176470588235294, 1.0) -(0.21568627450980393, 0.21568627450980393, 0.21568627450980393, 1.0) -(0.2196078431372549, 0.2196078431372549, 0.2196078431372549, 1.0) -(0.22352941176470587, 0.22352941176470587, 0.22352941176470587, 1.0) -(0.22745098039215686, 0.22745098039215686, 0.22745098039215686, 1.0) -(0.23137254901960785, 0.23137254901960785, 0.23137254901960785, 1.0) -(0.23529411764705882, 0.23529411764705882, 0.23529411764705882, 1.0) -(0.23921568627450979, 0.23921568627450979, 0.23921568627450979, 1.0) -(0.24313725490196078, 0.24313725490196078, 0.24313725490196078, 1.0) -(0.24705882352941178, 0.24705882352941178, 0.24705882352941178, 1.0) -(0.25098039215686274, 0.25098039215686274, 0.25098039215686274, 1.0) -(0.25490196078431371, 0.25490196078431371, 0.25490196078431371, 1.0) -(0.25882352941176467, 0.25882352941176467, 0.25882352941176467, 1.0) -(0.2627450980392157, 0.2627450980392157, 0.2627450980392157, 1.0) -(0.26666666666666666, 0.26666666666666666, 0.26666666666666666, 1.0) -(0.27058823529411763, 0.27058823529411763, 0.27058823529411763, 1.0) -(0.27450980392156865, 0.27450980392156865, 0.27450980392156865, 1.0) -(0.27843137254901962, 0.27843137254901962, 0.27843137254901962, 1.0) -(0.28235294117647058, 0.28235294117647058, 0.28235294117647058, 1.0) -(0.28627450980392155, 0.28627450980392155, 0.28627450980392155, 1.0) -(0.29019607843137252, 0.29019607843137252, 0.29019607843137252, 1.0) -(0.29411764705882354, 0.29411764705882354, 0.29411764705882354, 1.0) -(0.29803921568627451, 0.29803921568627451, 0.29803921568627451, 1.0) -(0.30196078431372547, 0.30196078431372547, 0.30196078431372547, 1.0) -(0.30588235294117649, 0.30588235294117649, 0.30588235294117649, 1.0) -(0.30980392156862746, 0.30980392156862746, 0.30980392156862746, 1.0) -(0.31372549019607843, 0.31372549019607843, 0.31372549019607843, 1.0) -(0.31764705882352939, 0.31764705882352939, 0.31764705882352939, 1.0) -(0.32156862745098036, 0.32156862745098036, 0.32156862745098036, 1.0) -(0.32549019607843138, 0.32549019607843138, 0.32549019607843138, 1.0) -(0.32941176470588235, 0.32941176470588235, 0.32941176470588235, 1.0) -(0.33333333333333331, 0.33333333333333331, 0.33333333333333331, 1.0) -(0.33725490196078434, 0.33725490196078434, 0.33725490196078434, 1.0) -(0.3411764705882353, 0.3411764705882353, 0.3411764705882353, 1.0) -(0.34509803921568627, 0.34509803921568627, 0.34509803921568627, 1.0) -(0.34901960784313724, 0.34901960784313724, 0.34901960784313724, 1.0) -(0.3529411764705882, 0.3529411764705882, 0.3529411764705882, 1.0) -(0.35686274509803922, 0.35686274509803922, 0.35686274509803922, 1.0) -(0.36078431372549019, 0.36078431372549019, 0.36078431372549019, 1.0) -(0.36470588235294116, 0.36470588235294116, 0.36470588235294116, 1.0) -(0.36862745098039218, 0.36862745098039218, 0.36862745098039218, 1.0) -(0.37254901960784315, 0.37254901960784315, 0.37254901960784315, 1.0) -(0.37647058823529411, 0.37647058823529411, 0.37647058823529411, 1.0) -(0.38039215686274508, 0.38039215686274508, 0.38039215686274508, 1.0) -(0.38431372549019605, 0.38431372549019605, 0.38431372549019605, 1.0) -(0.38823529411764707, 0.38823529411764707, 0.38823529411764707, 1.0) -(0.39215686274509803, 0.39215686274509803, 0.39215686274509803, 1.0) -(0.396078431372549, 0.396078431372549, 0.396078431372549, 1.0) -(0.40000000000000002, 0.40000000000000002, 0.40000000000000002, 1.0) -(0.40392156862745099, 0.40392156862745099, 0.40392156862745099, 1.0) -(0.40784313725490196, 0.40784313725490196, 0.40784313725490196, 1.0) -(0.41176470588235292, 0.41176470588235292, 0.41176470588235292, 1.0) -(0.41568627450980389, 0.41568627450980389, 0.41568627450980389, 1.0) -(0.41960784313725491, 0.41960784313725491, 0.41960784313725491, 1.0) -(0.42352941176470588, 0.42352941176470588, 0.42352941176470588, 1.0) -(0.42745098039215684, 0.42745098039215684, 0.42745098039215684, 1.0) -(0.43137254901960786, 0.43137254901960786, 0.43137254901960786, 1.0) -(0.43529411764705883, 0.43529411764705883, 0.43529411764705883, 1.0) -(0.4392156862745098, 0.4392156862745098, 0.4392156862745098, 1.0) -(0.44313725490196076, 0.44313725490196076, 0.44313725490196076, 1.0) -(0.44705882352941173, 0.44705882352941173, 0.44705882352941173, 1.0) -(0.45098039215686275, 0.45098039215686275, 0.45098039215686275, 1.0) -(0.45490196078431372, 0.45490196078431372, 0.45490196078431372, 1.0) -(0.45882352941176469, 0.45882352941176469, 0.45882352941176469, 1.0) -(0.46274509803921571, 0.46274509803921571, 0.46274509803921571, 1.0) -(0.46666666666666667, 0.46666666666666667, 0.46666666666666667, 1.0) -(0.47058823529411764, 0.47058823529411764, 0.47058823529411764, 1.0) -(0.47450980392156861, 0.47450980392156861, 0.47450980392156861, 1.0) -(0.47843137254901957, 0.47843137254901957, 0.47843137254901957, 1.0) -(0.4823529411764706, 0.4823529411764706, 0.4823529411764706, 1.0) -(0.48627450980392156, 0.48627450980392156, 0.48627450980392156, 1.0) -(0.49019607843137253, 0.49019607843137253, 0.49019607843137253, 1.0) -(0.49411764705882355, 0.49411764705882355, 0.49411764705882355, 1.0) -(0.49803921568627452, 0.49803921568627452, 0.49803921568627452, 1.0) -(0.50196078431372548, 0.50196078431372548, 0.50196078431372548, 1.0) -(0.50588235294117645, 0.50588235294117645, 0.50588235294117645, 1.0) -(0.50980392156862742, 0.50980392156862742, 0.50980392156862742, 1.0) -(0.51372549019607838, 0.51372549019607838, 0.51372549019607838, 1.0) -(0.51764705882352935, 0.51764705882352935, 0.51764705882352935, 1.0) -(0.52156862745098043, 0.52156862745098043, 0.52156862745098043, 1.0) -(0.52549019607843139, 0.52549019607843139, 0.52549019607843139, 1.0) -(0.52941176470588236, 0.52941176470588236, 0.52941176470588236, 1.0) -(0.53333333333333333, 0.53333333333333333, 0.53333333333333333, 1.0) -(0.53725490196078429, 0.53725490196078429, 0.53725490196078429, 1.0) -(0.54117647058823526, 0.54117647058823526, 0.54117647058823526, 1.0) -(0.54509803921568623, 0.54509803921568623, 0.54509803921568623, 1.0) -(0.5490196078431373, 0.5490196078431373, 0.5490196078431373, 1.0) -(0.55294117647058827, 0.55294117647058827, 0.55294117647058827, 1.0) -(0.55686274509803924, 0.55686274509803924, 0.55686274509803924, 1.0) -(0.5607843137254902, 0.5607843137254902, 0.5607843137254902, 1.0) -(0.56470588235294117, 0.56470588235294117, 0.56470588235294117, 1.0) -(0.56862745098039214, 0.56862745098039214, 0.56862745098039214, 1.0) -(0.5725490196078431, 0.5725490196078431, 0.5725490196078431, 1.0) -(0.57647058823529407, 0.57647058823529407, 0.57647058823529407, 1.0) -(0.58039215686274503, 0.58039215686274503, 0.58039215686274503, 1.0) -(0.58431372549019611, 0.58431372549019611, 0.58431372549019611, 1.0) -(0.58823529411764708, 0.58823529411764708, 0.58823529411764708, 1.0) -(0.59215686274509804, 0.59215686274509804, 0.59215686274509804, 1.0) -(0.59607843137254901, 0.59607843137254901, 0.59607843137254901, 1.0) -(0.59999999999999998, 0.59999999999999998, 0.59999999999999998, 1.0) -(0.60392156862745094, 0.60392156862745094, 0.60392156862745094, 1.0) -(0.60784313725490191, 0.60784313725490191, 0.60784313725490191, 1.0) -(0.61176470588235299, 0.61176470588235299, 0.61176470588235299, 1.0) -(0.61568627450980395, 0.61568627450980395, 0.61568627450980395, 1.0) -(0.61960784313725492, 0.61960784313725492, 0.61960784313725492, 1.0) -(0.62352941176470589, 0.62352941176470589, 0.62352941176470589, 1.0) -(0.62745098039215685, 0.62745098039215685, 0.62745098039215685, 1.0) -(0.63137254901960782, 0.63137254901960782, 0.63137254901960782, 1.0) -(0.63529411764705879, 0.63529411764705879, 0.63529411764705879, 1.0) -(0.63921568627450975, 0.63921568627450975, 0.63921568627450975, 1.0) -(0.64313725490196072, 0.64313725490196072, 0.64313725490196072, 1.0) -(0.6470588235294118, 0.6470588235294118, 0.6470588235294118, 1.0) -(0.65098039215686276, 0.65098039215686276, 0.65098039215686276, 1.0) -(0.65490196078431373, 0.65490196078431373, 0.65490196078431373, 1.0) -(0.6588235294117647, 0.6588235294117647, 0.6588235294117647, 1.0) -(0.66274509803921566, 0.66274509803921566, 0.66274509803921566, 1.0) -(0.66666666666666663, 0.66666666666666663, 0.66666666666666663, 1.0) -(0.6705882352941176, 0.6705882352941176, 0.6705882352941176, 1.0) -(0.67450980392156867, 0.67450980392156867, 0.67450980392156867, 1.0) -(0.67843137254901964, 0.67843137254901964, 0.67843137254901964, 1.0) -(0.68235294117647061, 0.68235294117647061, 0.68235294117647061, 1.0) -(0.68627450980392157, 0.68627450980392157, 0.68627450980392157, 1.0) -(0.69019607843137254, 0.69019607843137254, 0.69019607843137254, 1.0) -(0.69411764705882351, 0.69411764705882351, 0.69411764705882351, 1.0) -(0.69803921568627447, 0.69803921568627447, 0.69803921568627447, 1.0) -(0.70196078431372544, 0.70196078431372544, 0.70196078431372544, 1.0) -(0.70588235294117641, 0.70588235294117641, 0.70588235294117641, 1.0) -(0.70980392156862748, 0.70980392156862748, 0.70980392156862748, 1.0) -(0.71372549019607845, 0.71372549019607845, 0.71372549019607845, 1.0) -(0.71764705882352942, 0.71764705882352942, 0.71764705882352942, 1.0) -(0.72156862745098038, 0.72156862745098038, 0.72156862745098038, 1.0) -(0.72549019607843135, 0.72549019607843135, 0.72549019607843135, 1.0) -(0.72941176470588232, 0.72941176470588232, 0.72941176470588232, 1.0) -(0.73333333333333328, 0.73333333333333328, 0.73333333333333328, 1.0) -(0.73725490196078436, 0.73725490196078436, 0.73725490196078436, 1.0) -(0.74117647058823533, 0.74117647058823533, 0.74117647058823533, 1.0) -(0.74509803921568629, 0.74509803921568629, 0.74509803921568629, 1.0) -(0.74901960784313726, 0.74901960784313726, 0.74901960784313726, 1.0) -(0.75294117647058822, 0.75294117647058822, 0.75294117647058822, 1.0) -(0.75686274509803919, 0.75686274509803919, 0.75686274509803919, 1.0) -(0.76078431372549016, 0.76078431372549016, 0.76078431372549016, 1.0) -(0.76470588235294112, 0.76470588235294112, 0.76470588235294112, 1.0) -(0.76862745098039209, 0.76862745098039209, 0.76862745098039209, 1.0) -(0.77254901960784317, 0.77254901960784317, 0.77254901960784317, 1.0) -(0.77647058823529413, 0.77647058823529413, 0.77647058823529413, 1.0) -(0.7803921568627451, 0.7803921568627451, 0.7803921568627451, 1.0) -(0.78431372549019607, 0.78431372549019607, 0.78431372549019607, 1.0) -(0.78823529411764703, 0.78823529411764703, 0.78823529411764703, 1.0) -(0.792156862745098, 0.792156862745098, 0.792156862745098, 1.0) -(0.79607843137254897, 0.79607843137254897, 0.79607843137254897, 1.0) -(0.80000000000000004, 0.80000000000000004, 0.80000000000000004, 1.0) -(0.80392156862745101, 0.80392156862745101, 0.80392156862745101, 1.0) -(0.80784313725490198, 0.80784313725490198, 0.80784313725490198, 1.0) -(0.81176470588235294, 0.81176470588235294, 0.81176470588235294, 1.0) -(0.81568627450980391, 0.81568627450980391, 0.81568627450980391, 1.0) -(0.81960784313725488, 0.81960784313725488, 0.81960784313725488, 1.0) -(0.82352941176470584, 0.82352941176470584, 0.82352941176470584, 1.0) -(0.82745098039215681, 0.82745098039215681, 0.82745098039215681, 1.0) -(0.83137254901960778, 0.83137254901960778, 0.83137254901960778, 1.0) -(0.83529411764705885, 0.83529411764705885, 0.83529411764705885, 1.0) -(0.83921568627450982, 0.83921568627450982, 0.83921568627450982, 1.0) -(0.84313725490196079, 0.84313725490196079, 0.84313725490196079, 1.0) -(0.84705882352941175, 0.84705882352941175, 0.84705882352941175, 1.0) -(0.85098039215686272, 0.85098039215686272, 0.85098039215686272, 1.0) -(0.85490196078431369, 0.85490196078431369, 0.85490196078431369, 1.0) -(0.85882352941176465, 0.85882352941176465, 0.85882352941176465, 1.0) -(0.86274509803921573, 0.86274509803921573, 0.86274509803921573, 1.0) -(0.8666666666666667, 0.8666666666666667, 0.8666666666666667, 1.0) -(0.87058823529411766, 0.87058823529411766, 0.87058823529411766, 1.0) -(0.87450980392156863, 0.87450980392156863, 0.87450980392156863, 1.0) -(0.8784313725490196, 0.8784313725490196, 0.8784313725490196, 1.0) -(0.88235294117647056, 0.88235294117647056, 0.88235294117647056, 1.0) -(0.88627450980392153, 0.88627450980392153, 0.88627450980392153, 1.0) -(0.8901960784313725, 0.8901960784313725, 0.8901960784313725, 1.0) -(0.89411764705882346, 0.89411764705882346, 0.89411764705882346, 1.0) -(0.89803921568627454, 0.89803921568627454, 0.89803921568627454, 1.0) -(0.90196078431372551, 0.90196078431372551, 0.90196078431372551, 1.0) -(0.90588235294117647, 0.90588235294117647, 0.90588235294117647, 1.0) -(0.90980392156862744, 0.90980392156862744, 0.90980392156862744, 1.0) -(0.9137254901960784, 0.9137254901960784, 0.9137254901960784, 1.0) -(0.91764705882352937, 0.91764705882352937, 0.91764705882352937, 1.0) -(0.92156862745098034, 0.92156862745098034, 0.92156862745098034, 1.0) -(0.92549019607843142, 0.92549019607843142, 0.92549019607843142, 1.0) -(0.92941176470588238, 0.92941176470588238, 0.92941176470588238, 1.0) -(0.93333333333333335, 0.93333333333333335, 0.93333333333333335, 1.0) -(0.93725490196078431, 0.93725490196078431, 0.93725490196078431, 1.0) -(0.94117647058823528, 0.94117647058823528, 0.94117647058823528, 1.0) -(0.94509803921568625, 0.94509803921568625, 0.94509803921568625, 1.0) -(0.94901960784313721, 0.94901960784313721, 0.94901960784313721, 1.0) -(0.95294117647058818, 0.95294117647058818, 0.95294117647058818, 1.0) -(0.95686274509803915, 0.95686274509803915, 0.95686274509803915, 1.0) -(0.96078431372549022, 0.96078431372549022, 0.96078431372549022, 1.0) -(0.96470588235294119, 0.96470588235294119, 0.96470588235294119, 1.0) -(0.96862745098039216, 0.96862745098039216, 0.96862745098039216, 1.0) -(0.97254901960784312, 0.97254901960784312, 0.97254901960784312, 1.0) -(0.97647058823529409, 0.97647058823529409, 0.97647058823529409, 1.0) -(0.98039215686274506, 0.98039215686274506, 0.98039215686274506, 1.0) -(0.98431372549019602, 0.98431372549019602, 0.98431372549019602, 1.0) -(0.9882352941176471, 0.9882352941176471, 0.9882352941176471, 1.0) -(0.99215686274509807, 0.99215686274509807, 0.99215686274509807, 1.0) -(0.99607843137254903, 0.99607843137254903, 0.99607843137254903, 1.0) -(1.0, 1.0, 1.0, 1.0) diff --git a/extern/tfn/colormaps/sequential2/gist_heat.cpp b/extern/tfn/colormaps/sequential2/gist_heat.cpp deleted file mode 100644 index 92f5468..0000000 --- a/extern/tfn/colormaps/sequential2/gist_heat.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential2_gist_heat; -} -const std::vector colormap::data_sequential2_gist_heat = /* NOLINT(cert-err58-cpp) */ -{ -{0.0f, 0.0f, 0.0f, 1.0f}, -{0.0058823529411764705f, 0.0f, 0.0f, 1.0f}, -{0.011764705882352941f, 0.0f, 0.0f, 1.0f}, -{0.017647058823529412f, 0.0f, 0.0f, 1.0f}, -{0.023529411764705882f, 0.0f, 0.0f, 1.0f}, -{0.029411764705882353f, 0.0f, 0.0f, 1.0f}, -{0.035294117647058823f, 0.0f, 0.0f, 1.0f}, -{0.041176470588235294f, 0.0f, 0.0f, 1.0f}, -{0.047058823529411764f, 0.0f, 0.0f, 1.0f}, -{0.052941176470588235f, 0.0f, 0.0f, 1.0f}, -{0.058823529411764705f, 0.0f, 0.0f, 1.0f}, -{0.064705882352941169f, 0.0f, 0.0f, 1.0f}, -{0.070588235294117646f, 0.0f, 0.0f, 1.0f}, -{0.076470588235294124f, 0.0f, 0.0f, 1.0f}, -{0.082352941176470587f, 0.0f, 0.0f, 1.0f}, -{0.088235294117647051f, 0.0f, 0.0f, 1.0f}, -{0.094117647058823528f, 0.0f, 0.0f, 1.0f}, -{0.10000000000000001f, 0.0f, 0.0f, 1.0f}, -{0.10588235294117647f, 0.0f, 0.0f, 1.0f}, -{0.11176470588235293f, 0.0f, 0.0f, 1.0f}, -{0.11764705882352941f, 0.0f, 0.0f, 1.0f}, -{0.12352941176470589f, 0.0f, 0.0f, 1.0f}, -{0.12941176470588234f, 0.0f, 0.0f, 1.0f}, -{0.13529411764705881f, 0.0f, 0.0f, 1.0f}, -{0.14117647058823529f, 0.0f, 0.0f, 1.0f}, -{0.14705882352941177f, 0.0f, 0.0f, 1.0f}, -{0.15294117647058825f, 0.0f, 0.0f, 1.0f}, -{0.1588235294117647f, 0.0f, 0.0f, 1.0f}, -{0.16470588235294117f, 0.0f, 0.0f, 1.0f}, -{0.17058823529411765f, 0.0f, 0.0f, 1.0f}, -{0.1764705882352941f, 0.0f, 0.0f, 1.0f}, -{0.18235294117647058f, 0.0f, 0.0f, 1.0f}, -{0.18823529411764706f, 0.0f, 0.0f, 1.0f}, -{0.19411764705882351f, 0.0f, 0.0f, 1.0f}, -{0.20000000000000001f, 0.0f, 0.0f, 1.0f}, -{0.20588235294117649f, 0.0f, 0.0f, 1.0f}, -{0.21176470588235294f, 0.0f, 0.0f, 1.0f}, -{0.21764705882352939f, 0.0f, 0.0f, 1.0f}, -{0.22352941176470587f, 0.0f, 0.0f, 1.0f}, -{0.22941176470588237f, 0.0f, 0.0f, 1.0f}, -{0.23529411764705882f, 0.0f, 0.0f, 1.0f}, -{0.24117647058823527f, 0.0f, 0.0f, 1.0f}, -{0.24705882352941178f, 0.0f, 0.0f, 1.0f}, -{0.25294117647058822f, 0.0f, 0.0f, 1.0f}, -{0.25882352941176467f, 0.0f, 0.0f, 1.0f}, -{0.26470588235294112f, 0.0f, 0.0f, 1.0f}, -{0.27058823529411763f, 0.0f, 0.0f, 1.0f}, -{0.27647058823529413f, 0.0f, 0.0f, 1.0f}, -{0.28235294117647058f, 0.0f, 0.0f, 1.0f}, -{0.28823529411764703f, 0.0f, 0.0f, 1.0f}, -{0.29411764705882354f, 0.0f, 0.0f, 1.0f}, -{0.30000000000000004f, 0.0f, 0.0f, 1.0f}, -{0.30588235294117649f, 0.0f, 0.0f, 1.0f}, -{0.31176470588235294f, 0.0f, 0.0f, 1.0f}, -{0.31764705882352939f, 0.0f, 0.0f, 1.0f}, -{0.3235294117647059f, 0.0f, 0.0f, 1.0f}, -{0.32941176470588235f, 0.0f, 0.0f, 1.0f}, -{0.3352941176470588f, 0.0f, 0.0f, 1.0f}, -{0.3411764705882353f, 0.0f, 0.0f, 1.0f}, -{0.34705882352941175f, 0.0f, 0.0f, 1.0f}, -{0.3529411764705882f, 0.0f, 0.0f, 1.0f}, -{0.35882352941176465f, 0.0f, 0.0f, 1.0f}, -{0.36470588235294116f, 0.0f, 0.0f, 1.0f}, -{0.37058823529411766f, 0.0f, 0.0f, 1.0f}, -{0.37647058823529411f, 0.0f, 0.0f, 1.0f}, -{0.38235294117647056f, 0.0f, 0.0f, 1.0f}, -{0.38823529411764701f, 0.0f, 0.0f, 1.0f}, -{0.39411764705882357f, 0.0f, 0.0f, 1.0f}, -{0.40000000000000002f, 0.0f, 0.0f, 1.0f}, -{0.40588235294117647f, 0.0f, 0.0f, 1.0f}, -{0.41176470588235298f, 0.0f, 0.0f, 1.0f}, -{0.41764705882352943f, 0.0f, 0.0f, 1.0f}, -{0.42352941176470588f, 0.0f, 0.0f, 1.0f}, -{0.42941176470588233f, 0.0f, 0.0f, 1.0f}, -{0.43529411764705878f, 0.0f, 0.0f, 1.0f}, -{0.44117647058823528f, 0.0f, 0.0f, 1.0f}, -{0.44705882352941173f, 0.0f, 0.0f, 1.0f}, -{0.45294117647058818f, 0.0f, 0.0f, 1.0f}, -{0.45882352941176474f, 0.0f, 0.0f, 1.0f}, -{0.46470588235294119f, 0.0f, 0.0f, 1.0f}, -{0.47058823529411764f, 0.0f, 0.0f, 1.0f}, -{0.47647058823529409f, 0.0f, 0.0f, 1.0f}, -{0.48235294117647054f, 0.0f, 0.0f, 1.0f}, -{0.4882352941176471f, 0.0f, 0.0f, 1.0f}, -{0.49411764705882355f, 0.0f, 0.0f, 1.0f}, -{0.5f, 0.0f, 0.0f, 1.0f}, -{0.50588235294117645f, 0.0f, 0.0f, 1.0f}, -{0.5117647058823529f, 0.0f, 0.0f, 1.0f}, -{0.51764705882352935f, 0.0f, 0.0f, 1.0f}, -{0.5235294117647058f, 0.0f, 0.0f, 1.0f}, -{0.52941176470588225f, 0.0f, 0.0f, 1.0f}, -{0.53529411764705881f, 0.0f, 0.0f, 1.0f}, -{0.54117647058823526f, 0.0f, 0.0f, 1.0f}, -{0.54705882352941171f, 0.0f, 0.0f, 1.0f}, -{0.55294117647058827f, 0.0f, 0.0f, 1.0f}, -{0.55882352941176472f, 0.0f, 0.0f, 1.0f}, -{0.56470588235294117f, 0.0f, 0.0f, 1.0f}, -{0.57058823529411762f, 0.0f, 0.0f, 1.0f}, -{0.57647058823529407f, 0.0f, 0.0f, 1.0f}, -{0.58235294117647063f, 0.0f, 0.0f, 1.0f}, -{0.58823529411764708f, 0.0f, 0.0f, 1.0f}, -{0.59411764705882353f, 0.0f, 0.0f, 1.0f}, -{0.60000000000000009f, 0.0f, 0.0f, 1.0f}, -{0.60588235294117654f, 0.0f, 0.0f, 1.0f}, -{0.61176470588235299f, 0.0f, 0.0f, 1.0f}, -{0.61764705882352944f, 0.0f, 0.0f, 1.0f}, -{0.62352941176470589f, 0.0f, 0.0f, 1.0f}, -{0.62941176470588234f, 0.0f, 0.0f, 1.0f}, -{0.63529411764705879f, 0.0f, 0.0f, 1.0f}, -{0.64117647058823524f, 0.0f, 0.0f, 1.0f}, -{0.6470588235294118f, 0.0f, 0.0f, 1.0f}, -{0.65294117647058825f, 0.0f, 0.0f, 1.0f}, -{0.6588235294117647f, 0.0f, 0.0f, 1.0f}, -{0.66470588235294115f, 0.0f, 0.0f, 1.0f}, -{0.6705882352941176f, 0.0f, 0.0f, 1.0f}, -{0.67647058823529416f, 0.0f, 0.0f, 1.0f}, -{0.68235294117647061f, 0.0f, 0.0f, 1.0f}, -{0.68823529411764706f, 0.0f, 0.0f, 1.0f}, -{0.69411764705882351f, 0.0f, 0.0f, 1.0f}, -{0.69999999999999996f, 0.0f, 0.0f, 1.0f}, -{0.70588235294117641f, 0.0f, 0.0f, 1.0f}, -{0.71176470588235285f, 0.0f, 0.0f, 1.0f}, -{0.7176470588235293f, 0.0f, 0.0f, 1.0f}, -{0.72352941176470587f, 0.0f, 0.0f, 1.0f}, -{0.72941176470588232f, 0.0f, 0.0f, 1.0f}, -{0.73529411764705876f, 0.0f, 0.0f, 1.0f}, -{0.74117647058823533f, 0.0f, 0.0f, 1.0f}, -{0.74705882352941178f, 0.0f, 0.0f, 1.0f}, -{0.75294117647058822f, 0.0039215686274509665f, 0.0f, 1.0f}, -{0.75882352941176467f, 0.011764705882352899f, 0.0f, 1.0f}, -{0.76470588235294112f, 0.019607843137254832f, 0.0f, 1.0f}, -{0.77058823529411757f, 0.027450980392156765f, 0.0f, 1.0f}, -{0.77647058823529402f, 0.035294117647058698f, 0.0f, 1.0f}, -{0.7823529411764707f, 0.043137254901960853f, 0.0f, 1.0f}, -{0.78823529411764715f, 0.050980392156862786f, 0.0f, 1.0f}, -{0.79411764705882359f, 0.058823529411764719f, 0.0f, 1.0f}, -{0.80000000000000004f, 0.066666666666666652f, 0.0f, 1.0f}, -{0.80588235294117649f, 0.074509803921568585f, 0.0f, 1.0f}, -{0.81176470588235294f, 0.082352941176470518f, 0.0f, 1.0f}, -{0.81764705882352939f, 0.090196078431372451f, 0.0f, 1.0f}, -{0.82352941176470595f, 0.098039215686274606f, 0.0f, 1.0f}, -{0.8294117647058824f, 0.10588235294117654f, 0.0f, 1.0f}, -{0.83529411764705885f, 0.11372549019607847f, 0.0f, 1.0f}, -{0.8411764705882353f, 0.1215686274509804f, 0.0f, 1.0f}, -{0.84705882352941175f, 0.12941176470588234f, 0.0f, 1.0f}, -{0.8529411764705882f, 0.13725490196078427f, 0.0f, 1.0f}, -{0.85882352941176465f, 0.1450980392156862f, 0.0f, 1.0f}, -{0.8647058823529411f, 0.15294117647058814f, 0.0f, 1.0f}, -{0.87058823529411755f, 0.16078431372549007f, 0.0f, 1.0f}, -{0.87647058823529411f, 0.16862745098039222f, 0.0f, 1.0f}, -{0.88235294117647056f, 0.17647058823529416f, 0.0f, 1.0f}, -{0.88823529411764701f, 0.18431372549019609f, 0.0f, 1.0f}, -{0.89411764705882346f, 0.19215686274509802f, 0.0f, 1.0f}, -{0.89999999999999991f, 0.19999999999999996f, 0.0f, 1.0f}, -{0.90588235294117636f, 0.20784313725490189f, 0.0f, 1.0f}, -{0.91176470588235281f, 0.21568627450980382f, 0.0f, 1.0f}, -{0.91764705882352948f, 0.22352941176470598f, 0.0f, 1.0f}, -{0.92352941176470593f, 0.23137254901960791f, 0.0f, 1.0f}, -{0.92941176470588238f, 0.23921568627450984f, 0.0f, 1.0f}, -{0.93529411764705883f, 0.24705882352941178f, 0.0f, 1.0f}, -{0.94117647058823528f, 0.25490196078431371f, 0.0f, 1.0f}, -{0.94705882352941173f, 0.26274509803921564f, 0.0f, 1.0f}, -{0.95294117647058818f, 0.27058823529411757f, 0.0f, 1.0f}, -{0.95882352941176463f, 0.27843137254901951f, 0.0f, 1.0f}, -{0.96470588235294108f, 0.28627450980392144f, 0.0f, 1.0f}, -{0.97058823529411775f, 0.29411764705882359f, 0.0f, 1.0f}, -{0.9764705882352942f, 0.30196078431372553f, 0.0f, 1.0f}, -{0.98235294117647065f, 0.30980392156862746f, 0.0f, 1.0f}, -{0.9882352941176471f, 0.31764705882352939f, 0.0f, 1.0f}, -{0.99411764705882355f, 0.32549019607843133f, 0.0f, 1.0f}, -{1.0f, 0.33333333333333326f, 0.0f, 1.0f}, -{1.0f, 0.34117647058823519f, 0.0f, 1.0f}, -{1.0f, 0.34901960784313735f, 0.0f, 1.0f}, -{1.0f, 0.35686274509803928f, 0.0f, 1.0f}, -{1.0f, 0.36470588235294121f, 0.0f, 1.0f}, -{1.0f, 0.37254901960784315f, 0.0f, 1.0f}, -{1.0f, 0.38039215686274508f, 0.0f, 1.0f}, -{1.0f, 0.38823529411764701f, 0.0f, 1.0f}, -{1.0f, 0.39607843137254894f, 0.0f, 1.0f}, -{1.0f, 0.40392156862745088f, 0.0f, 1.0f}, -{1.0f, 0.41176470588235281f, 0.0f, 1.0f}, -{1.0f, 0.41960784313725497f, 0.0f, 1.0f}, -{1.0f, 0.4274509803921569f, 0.0f, 1.0f}, -{1.0f, 0.43529411764705883f, 0.0f, 1.0f}, -{1.0f, 0.44313725490196076f, 0.0f, 1.0f}, -{1.0f, 0.4509803921568627f, 0.0f, 1.0f}, -{1.0f, 0.45882352941176463f, 0.0f, 1.0f}, -{1.0f, 0.46666666666666656f, 0.0f, 1.0f}, -{1.0f, 0.47450980392156872f, 0.0f, 1.0f}, -{1.0f, 0.48235294117647065f, 0.0f, 1.0f}, -{1.0f, 0.49019607843137258f, 0.0f, 1.0f}, -{1.0f, 0.49803921568627452f, 0.0f, 1.0f}, -{1.0f, 0.50588235294117645f, 0.011764705882352899f, 1.0f}, -{1.0f, 0.51372549019607838f, 0.027450980392156765f, 1.0f}, -{1.0f, 0.52156862745098032f, 0.043137254901960631f, 1.0f}, -{1.0f, 0.52941176470588225f, 0.058823529411764497f, 1.0f}, -{1.0f, 0.53725490196078418f, 0.074509803921568363f, 1.0f}, -{1.0f, 0.54509803921568634f, 0.090196078431372673f, 1.0f}, -{1.0f, 0.55294117647058827f, 0.10588235294117654f, 1.0f}, -{1.0f, 0.5607843137254902f, 0.1215686274509804f, 1.0f}, -{1.0f, 0.56862745098039214f, 0.13725490196078427f, 1.0f}, -{1.0f, 0.57647058823529407f, 0.15294117647058814f, 1.0f}, -{1.0f, 0.584313725490196f, 0.168627450980392f, 1.0f}, -{1.0f, 0.59215686274509793f, 0.18431372549019587f, 1.0f}, -{1.0f, 0.60000000000000009f, 0.20000000000000018f, 1.0f}, -{1.0f, 0.60784313725490202f, 0.21568627450980404f, 1.0f}, -{1.0f, 0.61568627450980395f, 0.23137254901960791f, 1.0f}, -{1.0f, 0.62352941176470589f, 0.24705882352941178f, 1.0f}, -{1.0f, 0.63137254901960782f, 0.26274509803921564f, 1.0f}, -{1.0f, 0.63921568627450975f, 0.27843137254901951f, 1.0f}, -{1.0f, 0.64705882352941169f, 0.29411764705882337f, 1.0f}, -{1.0f, 0.65490196078431362f, 0.30980392156862724f, 1.0f}, -{1.0f, 0.66274509803921555f, 0.3254901960784311f, 1.0f}, -{1.0f, 0.67058823529411771f, 0.34117647058823541f, 1.0f}, -{1.0f, 0.67843137254901964f, 0.35686274509803928f, 1.0f}, -{1.0f, 0.68627450980392157f, 0.37254901960784315f, 1.0f}, -{1.0f, 0.69411764705882351f, 0.38823529411764701f, 1.0f}, -{1.0f, 0.70196078431372544f, 0.40392156862745088f, 1.0f}, -{1.0f, 0.70980392156862737f, 0.41960784313725474f, 1.0f}, -{1.0f, 0.7176470588235293f, 0.43529411764705861f, 1.0f}, -{1.0f, 0.72549019607843146f, 0.45098039215686292f, 1.0f}, -{1.0f, 0.73333333333333339f, 0.46666666666666679f, 1.0f}, -{1.0f, 0.74117647058823533f, 0.48235294117647065f, 1.0f}, -{1.0f, 0.74901960784313726f, 0.49803921568627452f, 1.0f}, -{1.0f, 0.75686274509803919f, 0.51372549019607838f, 1.0f}, -{1.0f, 0.76470588235294112f, 0.52941176470588225f, 1.0f}, -{1.0f, 0.77254901960784306f, 0.54509803921568611f, 1.0f}, -{1.0f, 0.78039215686274499f, 0.56078431372548998f, 1.0f}, -{1.0f, 0.78823529411764692f, 0.57647058823529385f, 1.0f}, -{1.0f, 0.79607843137254908f, 0.59215686274509816f, 1.0f}, -{1.0f, 0.80392156862745101f, 0.60784313725490202f, 1.0f}, -{1.0f, 0.81176470588235294f, 0.62352941176470589f, 1.0f}, -{1.0f, 0.81960784313725488f, 0.63921568627450975f, 1.0f}, -{1.0f, 0.82745098039215681f, 0.65490196078431362f, 1.0f}, -{1.0f, 0.83529411764705874f, 0.67058823529411749f, 1.0f}, -{1.0f, 0.84313725490196068f, 0.68627450980392135f, 1.0f}, -{1.0f, 0.85098039215686283f, 0.70196078431372566f, 1.0f}, -{1.0f, 0.85882352941176476f, 0.71764705882352953f, 1.0f}, -{1.0f, 0.8666666666666667f, 0.73333333333333339f, 1.0f}, -{1.0f, 0.87450980392156863f, 0.74901960784313726f, 1.0f}, -{1.0f, 0.88235294117647056f, 0.76470588235294112f, 1.0f}, -{1.0f, 0.8901960784313725f, 0.78039215686274499f, 1.0f}, -{1.0f, 0.89803921568627443f, 0.79607843137254886f, 1.0f}, -{1.0f, 0.90588235294117636f, 0.81176470588235272f, 1.0f}, -{1.0f, 0.91372549019607829f, 0.82745098039215659f, 1.0f}, -{1.0f, 0.92156862745098045f, 0.8431372549019609f, 1.0f}, -{1.0f, 0.92941176470588238f, 0.85882352941176476f, 1.0f}, -{1.0f, 0.93725490196078431f, 0.87450980392156863f, 1.0f}, -{1.0f, 0.94509803921568625f, 0.8901960784313725f, 1.0f}, -{1.0f, 0.95294117647058818f, 0.90588235294117636f, 1.0f}, -{1.0f, 0.96078431372549011f, 0.92156862745098023f, 1.0f}, -{1.0f, 0.96862745098039205f, 0.93725490196078409f, 1.0f}, -{1.0f, 0.9764705882352942f, 0.9529411764705884f, 1.0f}, -{1.0f, 0.98431372549019613f, 0.96862745098039227f, 1.0f}, -{1.0f, 0.99215686274509807f, 0.98431372549019613f, 1.0f}, -{1.0f, 1.0f, 1.0f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential2/gist_heat.txt b/extern/tfn/colormaps/sequential2/gist_heat.txt deleted file mode 100644 index 06b98d3..0000000 --- a/extern/tfn/colormaps/sequential2/gist_heat.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.0, 0.0, 0.0, 1.0) -(0.0058823529411764705, 0.0, 0.0, 1.0) -(0.011764705882352941, 0.0, 0.0, 1.0) -(0.017647058823529412, 0.0, 0.0, 1.0) -(0.023529411764705882, 0.0, 0.0, 1.0) -(0.029411764705882353, 0.0, 0.0, 1.0) -(0.035294117647058823, 0.0, 0.0, 1.0) -(0.041176470588235294, 0.0, 0.0, 1.0) -(0.047058823529411764, 0.0, 0.0, 1.0) -(0.052941176470588235, 0.0, 0.0, 1.0) -(0.058823529411764705, 0.0, 0.0, 1.0) -(0.064705882352941169, 0.0, 0.0, 1.0) -(0.070588235294117646, 0.0, 0.0, 1.0) -(0.076470588235294124, 0.0, 0.0, 1.0) -(0.082352941176470587, 0.0, 0.0, 1.0) -(0.088235294117647051, 0.0, 0.0, 1.0) -(0.094117647058823528, 0.0, 0.0, 1.0) -(0.10000000000000001, 0.0, 0.0, 1.0) -(0.10588235294117647, 0.0, 0.0, 1.0) -(0.11176470588235293, 0.0, 0.0, 1.0) -(0.11764705882352941, 0.0, 0.0, 1.0) -(0.12352941176470589, 0.0, 0.0, 1.0) -(0.12941176470588234, 0.0, 0.0, 1.0) -(0.13529411764705881, 0.0, 0.0, 1.0) -(0.14117647058823529, 0.0, 0.0, 1.0) -(0.14705882352941177, 0.0, 0.0, 1.0) -(0.15294117647058825, 0.0, 0.0, 1.0) -(0.1588235294117647, 0.0, 0.0, 1.0) -(0.16470588235294117, 0.0, 0.0, 1.0) -(0.17058823529411765, 0.0, 0.0, 1.0) -(0.1764705882352941, 0.0, 0.0, 1.0) -(0.18235294117647058, 0.0, 0.0, 1.0) -(0.18823529411764706, 0.0, 0.0, 1.0) -(0.19411764705882351, 0.0, 0.0, 1.0) -(0.20000000000000001, 0.0, 0.0, 1.0) -(0.20588235294117649, 0.0, 0.0, 1.0) -(0.21176470588235294, 0.0, 0.0, 1.0) -(0.21764705882352939, 0.0, 0.0, 1.0) -(0.22352941176470587, 0.0, 0.0, 1.0) -(0.22941176470588237, 0.0, 0.0, 1.0) -(0.23529411764705882, 0.0, 0.0, 1.0) -(0.24117647058823527, 0.0, 0.0, 1.0) -(0.24705882352941178, 0.0, 0.0, 1.0) -(0.25294117647058822, 0.0, 0.0, 1.0) -(0.25882352941176467, 0.0, 0.0, 1.0) -(0.26470588235294112, 0.0, 0.0, 1.0) -(0.27058823529411763, 0.0, 0.0, 1.0) -(0.27647058823529413, 0.0, 0.0, 1.0) -(0.28235294117647058, 0.0, 0.0, 1.0) -(0.28823529411764703, 0.0, 0.0, 1.0) -(0.29411764705882354, 0.0, 0.0, 1.0) -(0.30000000000000004, 0.0, 0.0, 1.0) -(0.30588235294117649, 0.0, 0.0, 1.0) -(0.31176470588235294, 0.0, 0.0, 1.0) -(0.31764705882352939, 0.0, 0.0, 1.0) -(0.3235294117647059, 0.0, 0.0, 1.0) -(0.32941176470588235, 0.0, 0.0, 1.0) -(0.3352941176470588, 0.0, 0.0, 1.0) -(0.3411764705882353, 0.0, 0.0, 1.0) -(0.34705882352941175, 0.0, 0.0, 1.0) -(0.3529411764705882, 0.0, 0.0, 1.0) -(0.35882352941176465, 0.0, 0.0, 1.0) -(0.36470588235294116, 0.0, 0.0, 1.0) -(0.37058823529411766, 0.0, 0.0, 1.0) -(0.37647058823529411, 0.0, 0.0, 1.0) -(0.38235294117647056, 0.0, 0.0, 1.0) -(0.38823529411764701, 0.0, 0.0, 1.0) -(0.39411764705882357, 0.0, 0.0, 1.0) -(0.40000000000000002, 0.0, 0.0, 1.0) -(0.40588235294117647, 0.0, 0.0, 1.0) -(0.41176470588235298, 0.0, 0.0, 1.0) -(0.41764705882352943, 0.0, 0.0, 1.0) -(0.42352941176470588, 0.0, 0.0, 1.0) -(0.42941176470588233, 0.0, 0.0, 1.0) -(0.43529411764705878, 0.0, 0.0, 1.0) -(0.44117647058823528, 0.0, 0.0, 1.0) -(0.44705882352941173, 0.0, 0.0, 1.0) -(0.45294117647058818, 0.0, 0.0, 1.0) -(0.45882352941176474, 0.0, 0.0, 1.0) -(0.46470588235294119, 0.0, 0.0, 1.0) -(0.47058823529411764, 0.0, 0.0, 1.0) -(0.47647058823529409, 0.0, 0.0, 1.0) -(0.48235294117647054, 0.0, 0.0, 1.0) -(0.4882352941176471, 0.0, 0.0, 1.0) -(0.49411764705882355, 0.0, 0.0, 1.0) -(0.5, 0.0, 0.0, 1.0) -(0.50588235294117645, 0.0, 0.0, 1.0) -(0.5117647058823529, 0.0, 0.0, 1.0) -(0.51764705882352935, 0.0, 0.0, 1.0) -(0.5235294117647058, 0.0, 0.0, 1.0) -(0.52941176470588225, 0.0, 0.0, 1.0) -(0.53529411764705881, 0.0, 0.0, 1.0) -(0.54117647058823526, 0.0, 0.0, 1.0) -(0.54705882352941171, 0.0, 0.0, 1.0) -(0.55294117647058827, 0.0, 0.0, 1.0) -(0.55882352941176472, 0.0, 0.0, 1.0) -(0.56470588235294117, 0.0, 0.0, 1.0) -(0.57058823529411762, 0.0, 0.0, 1.0) -(0.57647058823529407, 0.0, 0.0, 1.0) -(0.58235294117647063, 0.0, 0.0, 1.0) -(0.58823529411764708, 0.0, 0.0, 1.0) -(0.59411764705882353, 0.0, 0.0, 1.0) -(0.60000000000000009, 0.0, 0.0, 1.0) -(0.60588235294117654, 0.0, 0.0, 1.0) -(0.61176470588235299, 0.0, 0.0, 1.0) -(0.61764705882352944, 0.0, 0.0, 1.0) -(0.62352941176470589, 0.0, 0.0, 1.0) -(0.62941176470588234, 0.0, 0.0, 1.0) -(0.63529411764705879, 0.0, 0.0, 1.0) -(0.64117647058823524, 0.0, 0.0, 1.0) -(0.6470588235294118, 0.0, 0.0, 1.0) -(0.65294117647058825, 0.0, 0.0, 1.0) -(0.6588235294117647, 0.0, 0.0, 1.0) -(0.66470588235294115, 0.0, 0.0, 1.0) -(0.6705882352941176, 0.0, 0.0, 1.0) -(0.67647058823529416, 0.0, 0.0, 1.0) -(0.68235294117647061, 0.0, 0.0, 1.0) -(0.68823529411764706, 0.0, 0.0, 1.0) -(0.69411764705882351, 0.0, 0.0, 1.0) -(0.69999999999999996, 0.0, 0.0, 1.0) -(0.70588235294117641, 0.0, 0.0, 1.0) -(0.71176470588235285, 0.0, 0.0, 1.0) -(0.7176470588235293, 0.0, 0.0, 1.0) -(0.72352941176470587, 0.0, 0.0, 1.0) -(0.72941176470588232, 0.0, 0.0, 1.0) -(0.73529411764705876, 0.0, 0.0, 1.0) -(0.74117647058823533, 0.0, 0.0, 1.0) -(0.74705882352941178, 0.0, 0.0, 1.0) -(0.75294117647058822, 0.0039215686274509665, 0.0, 1.0) -(0.75882352941176467, 0.011764705882352899, 0.0, 1.0) -(0.76470588235294112, 0.019607843137254832, 0.0, 1.0) -(0.77058823529411757, 0.027450980392156765, 0.0, 1.0) -(0.77647058823529402, 0.035294117647058698, 0.0, 1.0) -(0.7823529411764707, 0.043137254901960853, 0.0, 1.0) -(0.78823529411764715, 0.050980392156862786, 0.0, 1.0) -(0.79411764705882359, 0.058823529411764719, 0.0, 1.0) -(0.80000000000000004, 0.066666666666666652, 0.0, 1.0) -(0.80588235294117649, 0.074509803921568585, 0.0, 1.0) -(0.81176470588235294, 0.082352941176470518, 0.0, 1.0) -(0.81764705882352939, 0.090196078431372451, 0.0, 1.0) -(0.82352941176470595, 0.098039215686274606, 0.0, 1.0) -(0.8294117647058824, 0.10588235294117654, 0.0, 1.0) -(0.83529411764705885, 0.11372549019607847, 0.0, 1.0) -(0.8411764705882353, 0.1215686274509804, 0.0, 1.0) -(0.84705882352941175, 0.12941176470588234, 0.0, 1.0) -(0.8529411764705882, 0.13725490196078427, 0.0, 1.0) -(0.85882352941176465, 0.1450980392156862, 0.0, 1.0) -(0.8647058823529411, 0.15294117647058814, 0.0, 1.0) -(0.87058823529411755, 0.16078431372549007, 0.0, 1.0) -(0.87647058823529411, 0.16862745098039222, 0.0, 1.0) -(0.88235294117647056, 0.17647058823529416, 0.0, 1.0) -(0.88823529411764701, 0.18431372549019609, 0.0, 1.0) -(0.89411764705882346, 0.19215686274509802, 0.0, 1.0) -(0.89999999999999991, 0.19999999999999996, 0.0, 1.0) -(0.90588235294117636, 0.20784313725490189, 0.0, 1.0) -(0.91176470588235281, 0.21568627450980382, 0.0, 1.0) -(0.91764705882352948, 0.22352941176470598, 0.0, 1.0) -(0.92352941176470593, 0.23137254901960791, 0.0, 1.0) -(0.92941176470588238, 0.23921568627450984, 0.0, 1.0) -(0.93529411764705883, 0.24705882352941178, 0.0, 1.0) -(0.94117647058823528, 0.25490196078431371, 0.0, 1.0) -(0.94705882352941173, 0.26274509803921564, 0.0, 1.0) -(0.95294117647058818, 0.27058823529411757, 0.0, 1.0) -(0.95882352941176463, 0.27843137254901951, 0.0, 1.0) -(0.96470588235294108, 0.28627450980392144, 0.0, 1.0) -(0.97058823529411775, 0.29411764705882359, 0.0, 1.0) -(0.9764705882352942, 0.30196078431372553, 0.0, 1.0) -(0.98235294117647065, 0.30980392156862746, 0.0, 1.0) -(0.9882352941176471, 0.31764705882352939, 0.0, 1.0) -(0.99411764705882355, 0.32549019607843133, 0.0, 1.0) -(1.0, 0.33333333333333326, 0.0, 1.0) -(1.0, 0.34117647058823519, 0.0, 1.0) -(1.0, 0.34901960784313735, 0.0, 1.0) -(1.0, 0.35686274509803928, 0.0, 1.0) -(1.0, 0.36470588235294121, 0.0, 1.0) -(1.0, 0.37254901960784315, 0.0, 1.0) -(1.0, 0.38039215686274508, 0.0, 1.0) -(1.0, 0.38823529411764701, 0.0, 1.0) -(1.0, 0.39607843137254894, 0.0, 1.0) -(1.0, 0.40392156862745088, 0.0, 1.0) -(1.0, 0.41176470588235281, 0.0, 1.0) -(1.0, 0.41960784313725497, 0.0, 1.0) -(1.0, 0.4274509803921569, 0.0, 1.0) -(1.0, 0.43529411764705883, 0.0, 1.0) -(1.0, 0.44313725490196076, 0.0, 1.0) -(1.0, 0.4509803921568627, 0.0, 1.0) -(1.0, 0.45882352941176463, 0.0, 1.0) -(1.0, 0.46666666666666656, 0.0, 1.0) -(1.0, 0.47450980392156872, 0.0, 1.0) -(1.0, 0.48235294117647065, 0.0, 1.0) -(1.0, 0.49019607843137258, 0.0, 1.0) -(1.0, 0.49803921568627452, 0.0, 1.0) -(1.0, 0.50588235294117645, 0.011764705882352899, 1.0) -(1.0, 0.51372549019607838, 0.027450980392156765, 1.0) -(1.0, 0.52156862745098032, 0.043137254901960631, 1.0) -(1.0, 0.52941176470588225, 0.058823529411764497, 1.0) -(1.0, 0.53725490196078418, 0.074509803921568363, 1.0) -(1.0, 0.54509803921568634, 0.090196078431372673, 1.0) -(1.0, 0.55294117647058827, 0.10588235294117654, 1.0) -(1.0, 0.5607843137254902, 0.1215686274509804, 1.0) -(1.0, 0.56862745098039214, 0.13725490196078427, 1.0) -(1.0, 0.57647058823529407, 0.15294117647058814, 1.0) -(1.0, 0.584313725490196, 0.168627450980392, 1.0) -(1.0, 0.59215686274509793, 0.18431372549019587, 1.0) -(1.0, 0.60000000000000009, 0.20000000000000018, 1.0) -(1.0, 0.60784313725490202, 0.21568627450980404, 1.0) -(1.0, 0.61568627450980395, 0.23137254901960791, 1.0) -(1.0, 0.62352941176470589, 0.24705882352941178, 1.0) -(1.0, 0.63137254901960782, 0.26274509803921564, 1.0) -(1.0, 0.63921568627450975, 0.27843137254901951, 1.0) -(1.0, 0.64705882352941169, 0.29411764705882337, 1.0) -(1.0, 0.65490196078431362, 0.30980392156862724, 1.0) -(1.0, 0.66274509803921555, 0.3254901960784311, 1.0) -(1.0, 0.67058823529411771, 0.34117647058823541, 1.0) -(1.0, 0.67843137254901964, 0.35686274509803928, 1.0) -(1.0, 0.68627450980392157, 0.37254901960784315, 1.0) -(1.0, 0.69411764705882351, 0.38823529411764701, 1.0) -(1.0, 0.70196078431372544, 0.40392156862745088, 1.0) -(1.0, 0.70980392156862737, 0.41960784313725474, 1.0) -(1.0, 0.7176470588235293, 0.43529411764705861, 1.0) -(1.0, 0.72549019607843146, 0.45098039215686292, 1.0) -(1.0, 0.73333333333333339, 0.46666666666666679, 1.0) -(1.0, 0.74117647058823533, 0.48235294117647065, 1.0) -(1.0, 0.74901960784313726, 0.49803921568627452, 1.0) -(1.0, 0.75686274509803919, 0.51372549019607838, 1.0) -(1.0, 0.76470588235294112, 0.52941176470588225, 1.0) -(1.0, 0.77254901960784306, 0.54509803921568611, 1.0) -(1.0, 0.78039215686274499, 0.56078431372548998, 1.0) -(1.0, 0.78823529411764692, 0.57647058823529385, 1.0) -(1.0, 0.79607843137254908, 0.59215686274509816, 1.0) -(1.0, 0.80392156862745101, 0.60784313725490202, 1.0) -(1.0, 0.81176470588235294, 0.62352941176470589, 1.0) -(1.0, 0.81960784313725488, 0.63921568627450975, 1.0) -(1.0, 0.82745098039215681, 0.65490196078431362, 1.0) -(1.0, 0.83529411764705874, 0.67058823529411749, 1.0) -(1.0, 0.84313725490196068, 0.68627450980392135, 1.0) -(1.0, 0.85098039215686283, 0.70196078431372566, 1.0) -(1.0, 0.85882352941176476, 0.71764705882352953, 1.0) -(1.0, 0.8666666666666667, 0.73333333333333339, 1.0) -(1.0, 0.87450980392156863, 0.74901960784313726, 1.0) -(1.0, 0.88235294117647056, 0.76470588235294112, 1.0) -(1.0, 0.8901960784313725, 0.78039215686274499, 1.0) -(1.0, 0.89803921568627443, 0.79607843137254886, 1.0) -(1.0, 0.90588235294117636, 0.81176470588235272, 1.0) -(1.0, 0.91372549019607829, 0.82745098039215659, 1.0) -(1.0, 0.92156862745098045, 0.8431372549019609, 1.0) -(1.0, 0.92941176470588238, 0.85882352941176476, 1.0) -(1.0, 0.93725490196078431, 0.87450980392156863, 1.0) -(1.0, 0.94509803921568625, 0.8901960784313725, 1.0) -(1.0, 0.95294117647058818, 0.90588235294117636, 1.0) -(1.0, 0.96078431372549011, 0.92156862745098023, 1.0) -(1.0, 0.96862745098039205, 0.93725490196078409, 1.0) -(1.0, 0.9764705882352942, 0.9529411764705884, 1.0) -(1.0, 0.98431372549019613, 0.96862745098039227, 1.0) -(1.0, 0.99215686274509807, 0.98431372549019613, 1.0) -(1.0, 1.0, 1.0, 1.0) diff --git a/extern/tfn/colormaps/sequential2/gist_yarg.cpp b/extern/tfn/colormaps/sequential2/gist_yarg.cpp deleted file mode 100644 index f0e8529..0000000 --- a/extern/tfn/colormaps/sequential2/gist_yarg.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential2_gist_yarg; -} -const std::vector colormap::data_sequential2_gist_yarg = /* NOLINT(cert-err58-cpp) */ -{ -{1.0f, 1.0f, 1.0f, 1.0f}, -{0.99607843137254903f, 0.99607843137254903f, 0.99607843137254903f, 1.0f}, -{0.99215686274509807f, 0.99215686274509807f, 0.99215686274509807f, 1.0f}, -{0.9882352941176471f, 0.9882352941176471f, 0.9882352941176471f, 1.0f}, -{0.98431372549019613f, 0.98431372549019613f, 0.98431372549019613f, 1.0f}, -{0.98039215686274506f, 0.98039215686274506f, 0.98039215686274506f, 1.0f}, -{0.97647058823529409f, 0.97647058823529409f, 0.97647058823529409f, 1.0f}, -{0.97254901960784312f, 0.97254901960784312f, 0.97254901960784312f, 1.0f}, -{0.96862745098039216f, 0.96862745098039216f, 0.96862745098039216f, 1.0f}, -{0.96470588235294119f, 0.96470588235294119f, 0.96470588235294119f, 1.0f}, -{0.96078431372549022f, 0.96078431372549022f, 0.96078431372549022f, 1.0f}, -{0.95686274509803926f, 0.95686274509803926f, 0.95686274509803926f, 1.0f}, -{0.95294117647058818f, 0.95294117647058818f, 0.95294117647058818f, 1.0f}, -{0.94901960784313721f, 0.94901960784313721f, 0.94901960784313721f, 1.0f}, -{0.94509803921568625f, 0.94509803921568625f, 0.94509803921568625f, 1.0f}, -{0.94117647058823528f, 0.94117647058823528f, 0.94117647058823528f, 1.0f}, -{0.93725490196078431f, 0.93725490196078431f, 0.93725490196078431f, 1.0f}, -{0.93333333333333335f, 0.93333333333333335f, 0.93333333333333335f, 1.0f}, -{0.92941176470588238f, 0.92941176470588238f, 0.92941176470588238f, 1.0f}, -{0.92549019607843142f, 0.92549019607843142f, 0.92549019607843142f, 1.0f}, -{0.92156862745098045f, 0.92156862745098045f, 0.92156862745098045f, 1.0f}, -{0.91764705882352937f, 0.91764705882352937f, 0.91764705882352937f, 1.0f}, -{0.9137254901960784f, 0.9137254901960784f, 0.9137254901960784f, 1.0f}, -{0.90980392156862744f, 0.90980392156862744f, 0.90980392156862744f, 1.0f}, -{0.90588235294117647f, 0.90588235294117647f, 0.90588235294117647f, 1.0f}, -{0.90196078431372551f, 0.90196078431372551f, 0.90196078431372551f, 1.0f}, -{0.89803921568627454f, 0.89803921568627454f, 0.89803921568627454f, 1.0f}, -{0.89411764705882357f, 0.89411764705882357f, 0.89411764705882357f, 1.0f}, -{0.8901960784313725f, 0.8901960784313725f, 0.8901960784313725f, 1.0f}, -{0.88627450980392153f, 0.88627450980392153f, 0.88627450980392153f, 1.0f}, -{0.88235294117647056f, 0.88235294117647056f, 0.88235294117647056f, 1.0f}, -{0.8784313725490196f, 0.8784313725490196f, 0.8784313725490196f, 1.0f}, -{0.87450980392156863f, 0.87450980392156863f, 0.87450980392156863f, 1.0f}, -{0.87058823529411766f, 0.87058823529411766f, 0.87058823529411766f, 1.0f}, -{0.8666666666666667f, 0.8666666666666667f, 0.8666666666666667f, 1.0f}, -{0.86274509803921573f, 0.86274509803921573f, 0.86274509803921573f, 1.0f}, -{0.85882352941176476f, 0.85882352941176476f, 0.85882352941176476f, 1.0f}, -{0.8549019607843138f, 0.8549019607843138f, 0.8549019607843138f, 1.0f}, -{0.85098039215686272f, 0.85098039215686272f, 0.85098039215686272f, 1.0f}, -{0.84705882352941175f, 0.84705882352941175f, 0.84705882352941175f, 1.0f}, -{0.84313725490196079f, 0.84313725490196079f, 0.84313725490196079f, 1.0f}, -{0.83921568627450982f, 0.83921568627450982f, 0.83921568627450982f, 1.0f}, -{0.83529411764705885f, 0.83529411764705885f, 0.83529411764705885f, 1.0f}, -{0.83137254901960778f, 0.83137254901960778f, 0.83137254901960778f, 1.0f}, -{0.82745098039215681f, 0.82745098039215681f, 0.82745098039215681f, 1.0f}, -{0.82352941176470584f, 0.82352941176470584f, 0.82352941176470584f, 1.0f}, -{0.81960784313725488f, 0.81960784313725488f, 0.81960784313725488f, 1.0f}, -{0.81568627450980391f, 0.81568627450980391f, 0.81568627450980391f, 1.0f}, -{0.81176470588235294f, 0.81176470588235294f, 0.81176470588235294f, 1.0f}, -{0.80784313725490198f, 0.80784313725490198f, 0.80784313725490198f, 1.0f}, -{0.80392156862745101f, 0.80392156862745101f, 0.80392156862745101f, 1.0f}, -{0.80000000000000004f, 0.80000000000000004f, 0.80000000000000004f, 1.0f}, -{0.79607843137254908f, 0.79607843137254908f, 0.79607843137254908f, 1.0f}, -{0.79215686274509811f, 0.79215686274509811f, 0.79215686274509811f, 1.0f}, -{0.78823529411764703f, 0.78823529411764703f, 0.78823529411764703f, 1.0f}, -{0.78431372549019607f, 0.78431372549019607f, 0.78431372549019607f, 1.0f}, -{0.7803921568627451f, 0.7803921568627451f, 0.7803921568627451f, 1.0f}, -{0.77647058823529413f, 0.77647058823529413f, 0.77647058823529413f, 1.0f}, -{0.77254901960784317f, 0.77254901960784317f, 0.77254901960784317f, 1.0f}, -{0.76862745098039209f, 0.76862745098039209f, 0.76862745098039209f, 1.0f}, -{0.76470588235294112f, 0.76470588235294112f, 0.76470588235294112f, 1.0f}, -{0.76078431372549016f, 0.76078431372549016f, 0.76078431372549016f, 1.0f}, -{0.75686274509803919f, 0.75686274509803919f, 0.75686274509803919f, 1.0f}, -{0.75294117647058822f, 0.75294117647058822f, 0.75294117647058822f, 1.0f}, -{0.74901960784313726f, 0.74901960784313726f, 0.74901960784313726f, 1.0f}, -{0.74509803921568629f, 0.74509803921568629f, 0.74509803921568629f, 1.0f}, -{0.74117647058823533f, 0.74117647058823533f, 0.74117647058823533f, 1.0f}, -{0.73725490196078436f, 0.73725490196078436f, 0.73725490196078436f, 1.0f}, -{0.73333333333333339f, 0.73333333333333339f, 0.73333333333333339f, 1.0f}, -{0.72941176470588243f, 0.72941176470588243f, 0.72941176470588243f, 1.0f}, -{0.72549019607843135f, 0.72549019607843135f, 0.72549019607843135f, 1.0f}, -{0.72156862745098038f, 0.72156862745098038f, 0.72156862745098038f, 1.0f}, -{0.71764705882352942f, 0.71764705882352942f, 0.71764705882352942f, 1.0f}, -{0.71372549019607845f, 0.71372549019607845f, 0.71372549019607845f, 1.0f}, -{0.70980392156862748f, 0.70980392156862748f, 0.70980392156862748f, 1.0f}, -{0.70588235294117641f, 0.70588235294117641f, 0.70588235294117641f, 1.0f}, -{0.70196078431372544f, 0.70196078431372544f, 0.70196078431372544f, 1.0f}, -{0.69803921568627447f, 0.69803921568627447f, 0.69803921568627447f, 1.0f}, -{0.69411764705882351f, 0.69411764705882351f, 0.69411764705882351f, 1.0f}, -{0.69019607843137254f, 0.69019607843137254f, 0.69019607843137254f, 1.0f}, -{0.68627450980392157f, 0.68627450980392157f, 0.68627450980392157f, 1.0f}, -{0.68235294117647061f, 0.68235294117647061f, 0.68235294117647061f, 1.0f}, -{0.67843137254901964f, 0.67843137254901964f, 0.67843137254901964f, 1.0f}, -{0.67450980392156867f, 0.67450980392156867f, 0.67450980392156867f, 1.0f}, -{0.67058823529411771f, 0.67058823529411771f, 0.67058823529411771f, 1.0f}, -{0.66666666666666674f, 0.66666666666666674f, 0.66666666666666674f, 1.0f}, -{0.66274509803921566f, 0.66274509803921566f, 0.66274509803921566f, 1.0f}, -{0.6588235294117647f, 0.6588235294117647f, 0.6588235294117647f, 1.0f}, -{0.65490196078431373f, 0.65490196078431373f, 0.65490196078431373f, 1.0f}, -{0.65098039215686276f, 0.65098039215686276f, 0.65098039215686276f, 1.0f}, -{0.6470588235294118f, 0.6470588235294118f, 0.6470588235294118f, 1.0f}, -{0.64313725490196072f, 0.64313725490196072f, 0.64313725490196072f, 1.0f}, -{0.63921568627450975f, 0.63921568627450975f, 0.63921568627450975f, 1.0f}, -{0.63529411764705879f, 0.63529411764705879f, 0.63529411764705879f, 1.0f}, -{0.63137254901960782f, 0.63137254901960782f, 0.63137254901960782f, 1.0f}, -{0.62745098039215685f, 0.62745098039215685f, 0.62745098039215685f, 1.0f}, -{0.62352941176470589f, 0.62352941176470589f, 0.62352941176470589f, 1.0f}, -{0.61960784313725492f, 0.61960784313725492f, 0.61960784313725492f, 1.0f}, -{0.61568627450980395f, 0.61568627450980395f, 0.61568627450980395f, 1.0f}, -{0.61176470588235299f, 0.61176470588235299f, 0.61176470588235299f, 1.0f}, -{0.60784313725490202f, 0.60784313725490202f, 0.60784313725490202f, 1.0f}, -{0.60392156862745106f, 0.60392156862745106f, 0.60392156862745106f, 1.0f}, -{0.59999999999999998f, 0.59999999999999998f, 0.59999999999999998f, 1.0f}, -{0.59607843137254901f, 0.59607843137254901f, 0.59607843137254901f, 1.0f}, -{0.59215686274509804f, 0.59215686274509804f, 0.59215686274509804f, 1.0f}, -{0.58823529411764708f, 0.58823529411764708f, 0.58823529411764708f, 1.0f}, -{0.58431372549019611f, 0.58431372549019611f, 0.58431372549019611f, 1.0f}, -{0.58039215686274503f, 0.58039215686274503f, 0.58039215686274503f, 1.0f}, -{0.57647058823529407f, 0.57647058823529407f, 0.57647058823529407f, 1.0f}, -{0.5725490196078431f, 0.5725490196078431f, 0.5725490196078431f, 1.0f}, -{0.56862745098039214f, 0.56862745098039214f, 0.56862745098039214f, 1.0f}, -{0.56470588235294117f, 0.56470588235294117f, 0.56470588235294117f, 1.0f}, -{0.5607843137254902f, 0.5607843137254902f, 0.5607843137254902f, 1.0f}, -{0.55686274509803924f, 0.55686274509803924f, 0.55686274509803924f, 1.0f}, -{0.55294117647058827f, 0.55294117647058827f, 0.55294117647058827f, 1.0f}, -{0.5490196078431373f, 0.5490196078431373f, 0.5490196078431373f, 1.0f}, -{0.54509803921568634f, 0.54509803921568634f, 0.54509803921568634f, 1.0f}, -{0.54117647058823537f, 0.54117647058823537f, 0.54117647058823537f, 1.0f}, -{0.53725490196078429f, 0.53725490196078429f, 0.53725490196078429f, 1.0f}, -{0.53333333333333333f, 0.53333333333333333f, 0.53333333333333333f, 1.0f}, -{0.52941176470588236f, 0.52941176470588236f, 0.52941176470588236f, 1.0f}, -{0.52549019607843139f, 0.52549019607843139f, 0.52549019607843139f, 1.0f}, -{0.52156862745098043f, 0.52156862745098043f, 0.52156862745098043f, 1.0f}, -{0.51764705882352935f, 0.51764705882352935f, 0.51764705882352935f, 1.0f}, -{0.51372549019607838f, 0.51372549019607838f, 0.51372549019607838f, 1.0f}, -{0.50980392156862742f, 0.50980392156862742f, 0.50980392156862742f, 1.0f}, -{0.50588235294117645f, 0.50588235294117645f, 0.50588235294117645f, 1.0f}, -{0.50196078431372548f, 0.50196078431372548f, 0.50196078431372548f, 1.0f}, -{0.49803921568627452f, 0.49803921568627452f, 0.49803921568627452f, 1.0f}, -{0.49411764705882355f, 0.49411764705882355f, 0.49411764705882355f, 1.0f}, -{0.49019607843137258f, 0.49019607843137258f, 0.49019607843137258f, 1.0f}, -{0.48627450980392162f, 0.48627450980392162f, 0.48627450980392162f, 1.0f}, -{0.48235294117647065f, 0.48235294117647065f, 0.48235294117647065f, 1.0f}, -{0.47843137254901957f, 0.47843137254901957f, 0.47843137254901957f, 1.0f}, -{0.47450980392156861f, 0.47450980392156861f, 0.47450980392156861f, 1.0f}, -{0.47058823529411764f, 0.47058823529411764f, 0.47058823529411764f, 1.0f}, -{0.46666666666666667f, 0.46666666666666667f, 0.46666666666666667f, 1.0f}, -{0.46274509803921571f, 0.46274509803921571f, 0.46274509803921571f, 1.0f}, -{0.45882352941176474f, 0.45882352941176474f, 0.45882352941176474f, 1.0f}, -{0.45490196078431377f, 0.45490196078431377f, 0.45490196078431377f, 1.0f}, -{0.4509803921568627f, 0.4509803921568627f, 0.4509803921568627f, 1.0f}, -{0.44705882352941173f, 0.44705882352941173f, 0.44705882352941173f, 1.0f}, -{0.44313725490196076f, 0.44313725490196076f, 0.44313725490196076f, 1.0f}, -{0.4392156862745098f, 0.4392156862745098f, 0.4392156862745098f, 1.0f}, -{0.43529411764705883f, 0.43529411764705883f, 0.43529411764705883f, 1.0f}, -{0.43137254901960786f, 0.43137254901960786f, 0.43137254901960786f, 1.0f}, -{0.4274509803921569f, 0.4274509803921569f, 0.4274509803921569f, 1.0f}, -{0.42352941176470593f, 0.42352941176470593f, 0.42352941176470593f, 1.0f}, -{0.41960784313725497f, 0.41960784313725497f, 0.41960784313725497f, 1.0f}, -{0.41568627450980389f, 0.41568627450980389f, 0.41568627450980389f, 1.0f}, -{0.41176470588235292f, 0.41176470588235292f, 0.41176470588235292f, 1.0f}, -{0.40784313725490196f, 0.40784313725490196f, 0.40784313725490196f, 1.0f}, -{0.40392156862745099f, 0.40392156862745099f, 0.40392156862745099f, 1.0f}, -{0.40000000000000002f, 0.40000000000000002f, 0.40000000000000002f, 1.0f}, -{0.39607843137254906f, 0.39607843137254906f, 0.39607843137254906f, 1.0f}, -{0.39215686274509809f, 0.39215686274509809f, 0.39215686274509809f, 1.0f}, -{0.38823529411764701f, 0.38823529411764701f, 0.38823529411764701f, 1.0f}, -{0.38431372549019605f, 0.38431372549019605f, 0.38431372549019605f, 1.0f}, -{0.38039215686274508f, 0.38039215686274508f, 0.38039215686274508f, 1.0f}, -{0.37647058823529411f, 0.37647058823529411f, 0.37647058823529411f, 1.0f}, -{0.37254901960784315f, 0.37254901960784315f, 0.37254901960784315f, 1.0f}, -{0.36862745098039218f, 0.36862745098039218f, 0.36862745098039218f, 1.0f}, -{0.36470588235294121f, 0.36470588235294121f, 0.36470588235294121f, 1.0f}, -{0.36078431372549025f, 0.36078431372549025f, 0.36078431372549025f, 1.0f}, -{0.35686274509803928f, 0.35686274509803928f, 0.35686274509803928f, 1.0f}, -{0.3529411764705882f, 0.3529411764705882f, 0.3529411764705882f, 1.0f}, -{0.34901960784313724f, 0.34901960784313724f, 0.34901960784313724f, 1.0f}, -{0.34509803921568627f, 0.34509803921568627f, 0.34509803921568627f, 1.0f}, -{0.3411764705882353f, 0.3411764705882353f, 0.3411764705882353f, 1.0f}, -{0.33725490196078434f, 0.33725490196078434f, 0.33725490196078434f, 1.0f}, -{0.33333333333333337f, 0.33333333333333337f, 0.33333333333333337f, 1.0f}, -{0.3294117647058824f, 0.3294117647058824f, 0.3294117647058824f, 1.0f}, -{0.32549019607843133f, 0.32549019607843133f, 0.32549019607843133f, 1.0f}, -{0.32156862745098036f, 0.32156862745098036f, 0.32156862745098036f, 1.0f}, -{0.31764705882352939f, 0.31764705882352939f, 0.31764705882352939f, 1.0f}, -{0.31372549019607843f, 0.31372549019607843f, 0.31372549019607843f, 1.0f}, -{0.30980392156862746f, 0.30980392156862746f, 0.30980392156862746f, 1.0f}, -{0.30588235294117649f, 0.30588235294117649f, 0.30588235294117649f, 1.0f}, -{0.30196078431372553f, 0.30196078431372553f, 0.30196078431372553f, 1.0f}, -{0.29803921568627456f, 0.29803921568627456f, 0.29803921568627456f, 1.0f}, -{0.29411764705882359f, 0.29411764705882359f, 0.29411764705882359f, 1.0f}, -{0.29019607843137252f, 0.29019607843137252f, 0.29019607843137252f, 1.0f}, -{0.28627450980392155f, 0.28627450980392155f, 0.28627450980392155f, 1.0f}, -{0.28235294117647058f, 0.28235294117647058f, 0.28235294117647058f, 1.0f}, -{0.27843137254901962f, 0.27843137254901962f, 0.27843137254901962f, 1.0f}, -{0.27450980392156865f, 0.27450980392156865f, 0.27450980392156865f, 1.0f}, -{0.27058823529411768f, 0.27058823529411768f, 0.27058823529411768f, 1.0f}, -{0.26666666666666672f, 0.26666666666666672f, 0.26666666666666672f, 1.0f}, -{0.26274509803921564f, 0.26274509803921564f, 0.26274509803921564f, 1.0f}, -{0.25882352941176467f, 0.25882352941176467f, 0.25882352941176467f, 1.0f}, -{0.25490196078431371f, 0.25490196078431371f, 0.25490196078431371f, 1.0f}, -{0.25098039215686274f, 0.25098039215686274f, 0.25098039215686274f, 1.0f}, -{0.24705882352941178f, 0.24705882352941178f, 0.24705882352941178f, 1.0f}, -{0.24313725490196081f, 0.24313725490196081f, 0.24313725490196081f, 1.0f}, -{0.23921568627450984f, 0.23921568627450984f, 0.23921568627450984f, 1.0f}, -{0.23529411764705888f, 0.23529411764705888f, 0.23529411764705888f, 1.0f}, -{0.23137254901960791f, 0.23137254901960791f, 0.23137254901960791f, 1.0f}, -{0.22745098039215683f, 0.22745098039215683f, 0.22745098039215683f, 1.0f}, -{0.22352941176470587f, 0.22352941176470587f, 0.22352941176470587f, 1.0f}, -{0.2196078431372549f, 0.2196078431372549f, 0.2196078431372549f, 1.0f}, -{0.21568627450980393f, 0.21568627450980393f, 0.21568627450980393f, 1.0f}, -{0.21176470588235297f, 0.21176470588235297f, 0.21176470588235297f, 1.0f}, -{0.207843137254902f, 0.207843137254902f, 0.207843137254902f, 1.0f}, -{0.20392156862745103f, 0.20392156862745103f, 0.20392156862745103f, 1.0f}, -{0.19999999999999996f, 0.19999999999999996f, 0.19999999999999996f, 1.0f}, -{0.19607843137254899f, 0.19607843137254899f, 0.19607843137254899f, 1.0f}, -{0.19215686274509802f, 0.19215686274509802f, 0.19215686274509802f, 1.0f}, -{0.18823529411764706f, 0.18823529411764706f, 0.18823529411764706f, 1.0f}, -{0.18431372549019609f, 0.18431372549019609f, 0.18431372549019609f, 1.0f}, -{0.18039215686274512f, 0.18039215686274512f, 0.18039215686274512f, 1.0f}, -{0.17647058823529416f, 0.17647058823529416f, 0.17647058823529416f, 1.0f}, -{0.17254901960784319f, 0.17254901960784319f, 0.17254901960784319f, 1.0f}, -{0.16862745098039222f, 0.16862745098039222f, 0.16862745098039222f, 1.0f}, -{0.16470588235294115f, 0.16470588235294115f, 0.16470588235294115f, 1.0f}, -{0.16078431372549018f, 0.16078431372549018f, 0.16078431372549018f, 1.0f}, -{0.15686274509803921f, 0.15686274509803921f, 0.15686274509803921f, 1.0f}, -{0.15294117647058825f, 0.15294117647058825f, 0.15294117647058825f, 1.0f}, -{0.14901960784313728f, 0.14901960784313728f, 0.14901960784313728f, 1.0f}, -{0.14509803921568631f, 0.14509803921568631f, 0.14509803921568631f, 1.0f}, -{0.14117647058823535f, 0.14117647058823535f, 0.14117647058823535f, 1.0f}, -{0.13725490196078427f, 0.13725490196078427f, 0.13725490196078427f, 1.0f}, -{0.1333333333333333f, 0.1333333333333333f, 0.1333333333333333f, 1.0f}, -{0.12941176470588234f, 0.12941176470588234f, 0.12941176470588234f, 1.0f}, -{0.12549019607843137f, 0.12549019607843137f, 0.12549019607843137f, 1.0f}, -{0.1215686274509804f, 0.1215686274509804f, 0.1215686274509804f, 1.0f}, -{0.11764705882352944f, 0.11764705882352944f, 0.11764705882352944f, 1.0f}, -{0.11372549019607847f, 0.11372549019607847f, 0.11372549019607847f, 1.0f}, -{0.1098039215686275f, 0.1098039215686275f, 0.1098039215686275f, 1.0f}, -{0.10588235294117654f, 0.10588235294117654f, 0.10588235294117654f, 1.0f}, -{0.10196078431372546f, 0.10196078431372546f, 0.10196078431372546f, 1.0f}, -{0.098039215686274495f, 0.098039215686274495f, 0.098039215686274495f, 1.0f}, -{0.094117647058823528f, 0.094117647058823528f, 0.094117647058823528f, 1.0f}, -{0.090196078431372562f, 0.090196078431372562f, 0.090196078431372562f, 1.0f}, -{0.086274509803921595f, 0.086274509803921595f, 0.086274509803921595f, 1.0f}, -{0.082352941176470629f, 0.082352941176470629f, 0.082352941176470629f, 1.0f}, -{0.078431372549019662f, 0.078431372549019662f, 0.078431372549019662f, 1.0f}, -{0.074509803921568585f, 0.074509803921568585f, 0.074509803921568585f, 1.0f}, -{0.070588235294117618f, 0.070588235294117618f, 0.070588235294117618f, 1.0f}, -{0.066666666666666652f, 0.066666666666666652f, 0.066666666666666652f, 1.0f}, -{0.062745098039215685f, 0.062745098039215685f, 0.062745098039215685f, 1.0f}, -{0.058823529411764719f, 0.058823529411764719f, 0.058823529411764719f, 1.0f}, -{0.054901960784313752f, 0.054901960784313752f, 0.054901960784313752f, 1.0f}, -{0.050980392156862786f, 0.050980392156862786f, 0.050980392156862786f, 1.0f}, -{0.04705882352941182f, 0.04705882352941182f, 0.04705882352941182f, 1.0f}, -{0.043137254901960853f, 0.043137254901960853f, 0.043137254901960853f, 1.0f}, -{0.039215686274509776f, 0.039215686274509776f, 0.039215686274509776f, 1.0f}, -{0.035294117647058809f, 0.035294117647058809f, 0.035294117647058809f, 1.0f}, -{0.031372549019607843f, 0.031372549019607843f, 0.031372549019607843f, 1.0f}, -{0.027450980392156876f, 0.027450980392156876f, 0.027450980392156876f, 1.0f}, -{0.02352941176470591f, 0.02352941176470591f, 0.02352941176470591f, 1.0f}, -{0.019607843137254943f, 0.019607843137254943f, 0.019607843137254943f, 1.0f}, -{0.015686274509803977f, 0.015686274509803977f, 0.015686274509803977f, 1.0f}, -{0.011764705882352899f, 0.011764705882352899f, 0.011764705882352899f, 1.0f}, -{0.0078431372549019329f, 0.0078431372549019329f, 0.0078431372549019329f, 1.0f}, -{0.0039215686274509665f, 0.0039215686274509665f, 0.0039215686274509665f, 1.0f}, -{0.0f, 0.0f, 0.0f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential2/gist_yarg.txt b/extern/tfn/colormaps/sequential2/gist_yarg.txt deleted file mode 100644 index 0472804..0000000 --- a/extern/tfn/colormaps/sequential2/gist_yarg.txt +++ /dev/null @@ -1,256 +0,0 @@ -(1.0, 1.0, 1.0, 1.0) -(0.99607843137254903, 0.99607843137254903, 0.99607843137254903, 1.0) -(0.99215686274509807, 0.99215686274509807, 0.99215686274509807, 1.0) -(0.9882352941176471, 0.9882352941176471, 0.9882352941176471, 1.0) -(0.98431372549019613, 0.98431372549019613, 0.98431372549019613, 1.0) -(0.98039215686274506, 0.98039215686274506, 0.98039215686274506, 1.0) -(0.97647058823529409, 0.97647058823529409, 0.97647058823529409, 1.0) -(0.97254901960784312, 0.97254901960784312, 0.97254901960784312, 1.0) -(0.96862745098039216, 0.96862745098039216, 0.96862745098039216, 1.0) -(0.96470588235294119, 0.96470588235294119, 0.96470588235294119, 1.0) -(0.96078431372549022, 0.96078431372549022, 0.96078431372549022, 1.0) -(0.95686274509803926, 0.95686274509803926, 0.95686274509803926, 1.0) -(0.95294117647058818, 0.95294117647058818, 0.95294117647058818, 1.0) -(0.94901960784313721, 0.94901960784313721, 0.94901960784313721, 1.0) -(0.94509803921568625, 0.94509803921568625, 0.94509803921568625, 1.0) -(0.94117647058823528, 0.94117647058823528, 0.94117647058823528, 1.0) -(0.93725490196078431, 0.93725490196078431, 0.93725490196078431, 1.0) -(0.93333333333333335, 0.93333333333333335, 0.93333333333333335, 1.0) -(0.92941176470588238, 0.92941176470588238, 0.92941176470588238, 1.0) -(0.92549019607843142, 0.92549019607843142, 0.92549019607843142, 1.0) -(0.92156862745098045, 0.92156862745098045, 0.92156862745098045, 1.0) -(0.91764705882352937, 0.91764705882352937, 0.91764705882352937, 1.0) -(0.9137254901960784, 0.9137254901960784, 0.9137254901960784, 1.0) -(0.90980392156862744, 0.90980392156862744, 0.90980392156862744, 1.0) -(0.90588235294117647, 0.90588235294117647, 0.90588235294117647, 1.0) -(0.90196078431372551, 0.90196078431372551, 0.90196078431372551, 1.0) -(0.89803921568627454, 0.89803921568627454, 0.89803921568627454, 1.0) -(0.89411764705882357, 0.89411764705882357, 0.89411764705882357, 1.0) -(0.8901960784313725, 0.8901960784313725, 0.8901960784313725, 1.0) -(0.88627450980392153, 0.88627450980392153, 0.88627450980392153, 1.0) -(0.88235294117647056, 0.88235294117647056, 0.88235294117647056, 1.0) -(0.8784313725490196, 0.8784313725490196, 0.8784313725490196, 1.0) -(0.87450980392156863, 0.87450980392156863, 0.87450980392156863, 1.0) -(0.87058823529411766, 0.87058823529411766, 0.87058823529411766, 1.0) -(0.8666666666666667, 0.8666666666666667, 0.8666666666666667, 1.0) -(0.86274509803921573, 0.86274509803921573, 0.86274509803921573, 1.0) -(0.85882352941176476, 0.85882352941176476, 0.85882352941176476, 1.0) -(0.8549019607843138, 0.8549019607843138, 0.8549019607843138, 1.0) -(0.85098039215686272, 0.85098039215686272, 0.85098039215686272, 1.0) -(0.84705882352941175, 0.84705882352941175, 0.84705882352941175, 1.0) -(0.84313725490196079, 0.84313725490196079, 0.84313725490196079, 1.0) -(0.83921568627450982, 0.83921568627450982, 0.83921568627450982, 1.0) -(0.83529411764705885, 0.83529411764705885, 0.83529411764705885, 1.0) -(0.83137254901960778, 0.83137254901960778, 0.83137254901960778, 1.0) -(0.82745098039215681, 0.82745098039215681, 0.82745098039215681, 1.0) -(0.82352941176470584, 0.82352941176470584, 0.82352941176470584, 1.0) -(0.81960784313725488, 0.81960784313725488, 0.81960784313725488, 1.0) -(0.81568627450980391, 0.81568627450980391, 0.81568627450980391, 1.0) -(0.81176470588235294, 0.81176470588235294, 0.81176470588235294, 1.0) -(0.80784313725490198, 0.80784313725490198, 0.80784313725490198, 1.0) -(0.80392156862745101, 0.80392156862745101, 0.80392156862745101, 1.0) -(0.80000000000000004, 0.80000000000000004, 0.80000000000000004, 1.0) -(0.79607843137254908, 0.79607843137254908, 0.79607843137254908, 1.0) -(0.79215686274509811, 0.79215686274509811, 0.79215686274509811, 1.0) -(0.78823529411764703, 0.78823529411764703, 0.78823529411764703, 1.0) -(0.78431372549019607, 0.78431372549019607, 0.78431372549019607, 1.0) -(0.7803921568627451, 0.7803921568627451, 0.7803921568627451, 1.0) -(0.77647058823529413, 0.77647058823529413, 0.77647058823529413, 1.0) -(0.77254901960784317, 0.77254901960784317, 0.77254901960784317, 1.0) -(0.76862745098039209, 0.76862745098039209, 0.76862745098039209, 1.0) -(0.76470588235294112, 0.76470588235294112, 0.76470588235294112, 1.0) -(0.76078431372549016, 0.76078431372549016, 0.76078431372549016, 1.0) -(0.75686274509803919, 0.75686274509803919, 0.75686274509803919, 1.0) -(0.75294117647058822, 0.75294117647058822, 0.75294117647058822, 1.0) -(0.74901960784313726, 0.74901960784313726, 0.74901960784313726, 1.0) -(0.74509803921568629, 0.74509803921568629, 0.74509803921568629, 1.0) -(0.74117647058823533, 0.74117647058823533, 0.74117647058823533, 1.0) -(0.73725490196078436, 0.73725490196078436, 0.73725490196078436, 1.0) -(0.73333333333333339, 0.73333333333333339, 0.73333333333333339, 1.0) -(0.72941176470588243, 0.72941176470588243, 0.72941176470588243, 1.0) -(0.72549019607843135, 0.72549019607843135, 0.72549019607843135, 1.0) -(0.72156862745098038, 0.72156862745098038, 0.72156862745098038, 1.0) -(0.71764705882352942, 0.71764705882352942, 0.71764705882352942, 1.0) -(0.71372549019607845, 0.71372549019607845, 0.71372549019607845, 1.0) -(0.70980392156862748, 0.70980392156862748, 0.70980392156862748, 1.0) -(0.70588235294117641, 0.70588235294117641, 0.70588235294117641, 1.0) -(0.70196078431372544, 0.70196078431372544, 0.70196078431372544, 1.0) -(0.69803921568627447, 0.69803921568627447, 0.69803921568627447, 1.0) -(0.69411764705882351, 0.69411764705882351, 0.69411764705882351, 1.0) -(0.69019607843137254, 0.69019607843137254, 0.69019607843137254, 1.0) -(0.68627450980392157, 0.68627450980392157, 0.68627450980392157, 1.0) -(0.68235294117647061, 0.68235294117647061, 0.68235294117647061, 1.0) -(0.67843137254901964, 0.67843137254901964, 0.67843137254901964, 1.0) -(0.67450980392156867, 0.67450980392156867, 0.67450980392156867, 1.0) -(0.67058823529411771, 0.67058823529411771, 0.67058823529411771, 1.0) -(0.66666666666666674, 0.66666666666666674, 0.66666666666666674, 1.0) -(0.66274509803921566, 0.66274509803921566, 0.66274509803921566, 1.0) -(0.6588235294117647, 0.6588235294117647, 0.6588235294117647, 1.0) -(0.65490196078431373, 0.65490196078431373, 0.65490196078431373, 1.0) -(0.65098039215686276, 0.65098039215686276, 0.65098039215686276, 1.0) -(0.6470588235294118, 0.6470588235294118, 0.6470588235294118, 1.0) -(0.64313725490196072, 0.64313725490196072, 0.64313725490196072, 1.0) -(0.63921568627450975, 0.63921568627450975, 0.63921568627450975, 1.0) -(0.63529411764705879, 0.63529411764705879, 0.63529411764705879, 1.0) -(0.63137254901960782, 0.63137254901960782, 0.63137254901960782, 1.0) -(0.62745098039215685, 0.62745098039215685, 0.62745098039215685, 1.0) -(0.62352941176470589, 0.62352941176470589, 0.62352941176470589, 1.0) -(0.61960784313725492, 0.61960784313725492, 0.61960784313725492, 1.0) -(0.61568627450980395, 0.61568627450980395, 0.61568627450980395, 1.0) -(0.61176470588235299, 0.61176470588235299, 0.61176470588235299, 1.0) -(0.60784313725490202, 0.60784313725490202, 0.60784313725490202, 1.0) -(0.60392156862745106, 0.60392156862745106, 0.60392156862745106, 1.0) -(0.59999999999999998, 0.59999999999999998, 0.59999999999999998, 1.0) -(0.59607843137254901, 0.59607843137254901, 0.59607843137254901, 1.0) -(0.59215686274509804, 0.59215686274509804, 0.59215686274509804, 1.0) -(0.58823529411764708, 0.58823529411764708, 0.58823529411764708, 1.0) -(0.58431372549019611, 0.58431372549019611, 0.58431372549019611, 1.0) -(0.58039215686274503, 0.58039215686274503, 0.58039215686274503, 1.0) -(0.57647058823529407, 0.57647058823529407, 0.57647058823529407, 1.0) -(0.5725490196078431, 0.5725490196078431, 0.5725490196078431, 1.0) -(0.56862745098039214, 0.56862745098039214, 0.56862745098039214, 1.0) -(0.56470588235294117, 0.56470588235294117, 0.56470588235294117, 1.0) -(0.5607843137254902, 0.5607843137254902, 0.5607843137254902, 1.0) -(0.55686274509803924, 0.55686274509803924, 0.55686274509803924, 1.0) -(0.55294117647058827, 0.55294117647058827, 0.55294117647058827, 1.0) -(0.5490196078431373, 0.5490196078431373, 0.5490196078431373, 1.0) -(0.54509803921568634, 0.54509803921568634, 0.54509803921568634, 1.0) -(0.54117647058823537, 0.54117647058823537, 0.54117647058823537, 1.0) -(0.53725490196078429, 0.53725490196078429, 0.53725490196078429, 1.0) -(0.53333333333333333, 0.53333333333333333, 0.53333333333333333, 1.0) -(0.52941176470588236, 0.52941176470588236, 0.52941176470588236, 1.0) -(0.52549019607843139, 0.52549019607843139, 0.52549019607843139, 1.0) -(0.52156862745098043, 0.52156862745098043, 0.52156862745098043, 1.0) -(0.51764705882352935, 0.51764705882352935, 0.51764705882352935, 1.0) -(0.51372549019607838, 0.51372549019607838, 0.51372549019607838, 1.0) -(0.50980392156862742, 0.50980392156862742, 0.50980392156862742, 1.0) -(0.50588235294117645, 0.50588235294117645, 0.50588235294117645, 1.0) -(0.50196078431372548, 0.50196078431372548, 0.50196078431372548, 1.0) -(0.49803921568627452, 0.49803921568627452, 0.49803921568627452, 1.0) -(0.49411764705882355, 0.49411764705882355, 0.49411764705882355, 1.0) -(0.49019607843137258, 0.49019607843137258, 0.49019607843137258, 1.0) -(0.48627450980392162, 0.48627450980392162, 0.48627450980392162, 1.0) -(0.48235294117647065, 0.48235294117647065, 0.48235294117647065, 1.0) -(0.47843137254901957, 0.47843137254901957, 0.47843137254901957, 1.0) -(0.47450980392156861, 0.47450980392156861, 0.47450980392156861, 1.0) -(0.47058823529411764, 0.47058823529411764, 0.47058823529411764, 1.0) -(0.46666666666666667, 0.46666666666666667, 0.46666666666666667, 1.0) -(0.46274509803921571, 0.46274509803921571, 0.46274509803921571, 1.0) -(0.45882352941176474, 0.45882352941176474, 0.45882352941176474, 1.0) -(0.45490196078431377, 0.45490196078431377, 0.45490196078431377, 1.0) -(0.4509803921568627, 0.4509803921568627, 0.4509803921568627, 1.0) -(0.44705882352941173, 0.44705882352941173, 0.44705882352941173, 1.0) -(0.44313725490196076, 0.44313725490196076, 0.44313725490196076, 1.0) -(0.4392156862745098, 0.4392156862745098, 0.4392156862745098, 1.0) -(0.43529411764705883, 0.43529411764705883, 0.43529411764705883, 1.0) -(0.43137254901960786, 0.43137254901960786, 0.43137254901960786, 1.0) -(0.4274509803921569, 0.4274509803921569, 0.4274509803921569, 1.0) -(0.42352941176470593, 0.42352941176470593, 0.42352941176470593, 1.0) -(0.41960784313725497, 0.41960784313725497, 0.41960784313725497, 1.0) -(0.41568627450980389, 0.41568627450980389, 0.41568627450980389, 1.0) -(0.41176470588235292, 0.41176470588235292, 0.41176470588235292, 1.0) -(0.40784313725490196, 0.40784313725490196, 0.40784313725490196, 1.0) -(0.40392156862745099, 0.40392156862745099, 0.40392156862745099, 1.0) -(0.40000000000000002, 0.40000000000000002, 0.40000000000000002, 1.0) -(0.39607843137254906, 0.39607843137254906, 0.39607843137254906, 1.0) -(0.39215686274509809, 0.39215686274509809, 0.39215686274509809, 1.0) -(0.38823529411764701, 0.38823529411764701, 0.38823529411764701, 1.0) -(0.38431372549019605, 0.38431372549019605, 0.38431372549019605, 1.0) -(0.38039215686274508, 0.38039215686274508, 0.38039215686274508, 1.0) -(0.37647058823529411, 0.37647058823529411, 0.37647058823529411, 1.0) -(0.37254901960784315, 0.37254901960784315, 0.37254901960784315, 1.0) -(0.36862745098039218, 0.36862745098039218, 0.36862745098039218, 1.0) -(0.36470588235294121, 0.36470588235294121, 0.36470588235294121, 1.0) -(0.36078431372549025, 0.36078431372549025, 0.36078431372549025, 1.0) -(0.35686274509803928, 0.35686274509803928, 0.35686274509803928, 1.0) -(0.3529411764705882, 0.3529411764705882, 0.3529411764705882, 1.0) -(0.34901960784313724, 0.34901960784313724, 0.34901960784313724, 1.0) -(0.34509803921568627, 0.34509803921568627, 0.34509803921568627, 1.0) -(0.3411764705882353, 0.3411764705882353, 0.3411764705882353, 1.0) -(0.33725490196078434, 0.33725490196078434, 0.33725490196078434, 1.0) -(0.33333333333333337, 0.33333333333333337, 0.33333333333333337, 1.0) -(0.3294117647058824, 0.3294117647058824, 0.3294117647058824, 1.0) -(0.32549019607843133, 0.32549019607843133, 0.32549019607843133, 1.0) -(0.32156862745098036, 0.32156862745098036, 0.32156862745098036, 1.0) -(0.31764705882352939, 0.31764705882352939, 0.31764705882352939, 1.0) -(0.31372549019607843, 0.31372549019607843, 0.31372549019607843, 1.0) -(0.30980392156862746, 0.30980392156862746, 0.30980392156862746, 1.0) -(0.30588235294117649, 0.30588235294117649, 0.30588235294117649, 1.0) -(0.30196078431372553, 0.30196078431372553, 0.30196078431372553, 1.0) -(0.29803921568627456, 0.29803921568627456, 0.29803921568627456, 1.0) -(0.29411764705882359, 0.29411764705882359, 0.29411764705882359, 1.0) -(0.29019607843137252, 0.29019607843137252, 0.29019607843137252, 1.0) -(0.28627450980392155, 0.28627450980392155, 0.28627450980392155, 1.0) -(0.28235294117647058, 0.28235294117647058, 0.28235294117647058, 1.0) -(0.27843137254901962, 0.27843137254901962, 0.27843137254901962, 1.0) -(0.27450980392156865, 0.27450980392156865, 0.27450980392156865, 1.0) -(0.27058823529411768, 0.27058823529411768, 0.27058823529411768, 1.0) -(0.26666666666666672, 0.26666666666666672, 0.26666666666666672, 1.0) -(0.26274509803921564, 0.26274509803921564, 0.26274509803921564, 1.0) -(0.25882352941176467, 0.25882352941176467, 0.25882352941176467, 1.0) -(0.25490196078431371, 0.25490196078431371, 0.25490196078431371, 1.0) -(0.25098039215686274, 0.25098039215686274, 0.25098039215686274, 1.0) -(0.24705882352941178, 0.24705882352941178, 0.24705882352941178, 1.0) -(0.24313725490196081, 0.24313725490196081, 0.24313725490196081, 1.0) -(0.23921568627450984, 0.23921568627450984, 0.23921568627450984, 1.0) -(0.23529411764705888, 0.23529411764705888, 0.23529411764705888, 1.0) -(0.23137254901960791, 0.23137254901960791, 0.23137254901960791, 1.0) -(0.22745098039215683, 0.22745098039215683, 0.22745098039215683, 1.0) -(0.22352941176470587, 0.22352941176470587, 0.22352941176470587, 1.0) -(0.2196078431372549, 0.2196078431372549, 0.2196078431372549, 1.0) -(0.21568627450980393, 0.21568627450980393, 0.21568627450980393, 1.0) -(0.21176470588235297, 0.21176470588235297, 0.21176470588235297, 1.0) -(0.207843137254902, 0.207843137254902, 0.207843137254902, 1.0) -(0.20392156862745103, 0.20392156862745103, 0.20392156862745103, 1.0) -(0.19999999999999996, 0.19999999999999996, 0.19999999999999996, 1.0) -(0.19607843137254899, 0.19607843137254899, 0.19607843137254899, 1.0) -(0.19215686274509802, 0.19215686274509802, 0.19215686274509802, 1.0) -(0.18823529411764706, 0.18823529411764706, 0.18823529411764706, 1.0) -(0.18431372549019609, 0.18431372549019609, 0.18431372549019609, 1.0) -(0.18039215686274512, 0.18039215686274512, 0.18039215686274512, 1.0) -(0.17647058823529416, 0.17647058823529416, 0.17647058823529416, 1.0) -(0.17254901960784319, 0.17254901960784319, 0.17254901960784319, 1.0) -(0.16862745098039222, 0.16862745098039222, 0.16862745098039222, 1.0) -(0.16470588235294115, 0.16470588235294115, 0.16470588235294115, 1.0) -(0.16078431372549018, 0.16078431372549018, 0.16078431372549018, 1.0) -(0.15686274509803921, 0.15686274509803921, 0.15686274509803921, 1.0) -(0.15294117647058825, 0.15294117647058825, 0.15294117647058825, 1.0) -(0.14901960784313728, 0.14901960784313728, 0.14901960784313728, 1.0) -(0.14509803921568631, 0.14509803921568631, 0.14509803921568631, 1.0) -(0.14117647058823535, 0.14117647058823535, 0.14117647058823535, 1.0) -(0.13725490196078427, 0.13725490196078427, 0.13725490196078427, 1.0) -(0.1333333333333333, 0.1333333333333333, 0.1333333333333333, 1.0) -(0.12941176470588234, 0.12941176470588234, 0.12941176470588234, 1.0) -(0.12549019607843137, 0.12549019607843137, 0.12549019607843137, 1.0) -(0.1215686274509804, 0.1215686274509804, 0.1215686274509804, 1.0) -(0.11764705882352944, 0.11764705882352944, 0.11764705882352944, 1.0) -(0.11372549019607847, 0.11372549019607847, 0.11372549019607847, 1.0) -(0.1098039215686275, 0.1098039215686275, 0.1098039215686275, 1.0) -(0.10588235294117654, 0.10588235294117654, 0.10588235294117654, 1.0) -(0.10196078431372546, 0.10196078431372546, 0.10196078431372546, 1.0) -(0.098039215686274495, 0.098039215686274495, 0.098039215686274495, 1.0) -(0.094117647058823528, 0.094117647058823528, 0.094117647058823528, 1.0) -(0.090196078431372562, 0.090196078431372562, 0.090196078431372562, 1.0) -(0.086274509803921595, 0.086274509803921595, 0.086274509803921595, 1.0) -(0.082352941176470629, 0.082352941176470629, 0.082352941176470629, 1.0) -(0.078431372549019662, 0.078431372549019662, 0.078431372549019662, 1.0) -(0.074509803921568585, 0.074509803921568585, 0.074509803921568585, 1.0) -(0.070588235294117618, 0.070588235294117618, 0.070588235294117618, 1.0) -(0.066666666666666652, 0.066666666666666652, 0.066666666666666652, 1.0) -(0.062745098039215685, 0.062745098039215685, 0.062745098039215685, 1.0) -(0.058823529411764719, 0.058823529411764719, 0.058823529411764719, 1.0) -(0.054901960784313752, 0.054901960784313752, 0.054901960784313752, 1.0) -(0.050980392156862786, 0.050980392156862786, 0.050980392156862786, 1.0) -(0.04705882352941182, 0.04705882352941182, 0.04705882352941182, 1.0) -(0.043137254901960853, 0.043137254901960853, 0.043137254901960853, 1.0) -(0.039215686274509776, 0.039215686274509776, 0.039215686274509776, 1.0) -(0.035294117647058809, 0.035294117647058809, 0.035294117647058809, 1.0) -(0.031372549019607843, 0.031372549019607843, 0.031372549019607843, 1.0) -(0.027450980392156876, 0.027450980392156876, 0.027450980392156876, 1.0) -(0.02352941176470591, 0.02352941176470591, 0.02352941176470591, 1.0) -(0.019607843137254943, 0.019607843137254943, 0.019607843137254943, 1.0) -(0.015686274509803977, 0.015686274509803977, 0.015686274509803977, 1.0) -(0.011764705882352899, 0.011764705882352899, 0.011764705882352899, 1.0) -(0.0078431372549019329, 0.0078431372549019329, 0.0078431372549019329, 1.0) -(0.0039215686274509665, 0.0039215686274509665, 0.0039215686274509665, 1.0) -(0.0, 0.0, 0.0, 1.0) diff --git a/extern/tfn/colormaps/sequential2/gray.cpp b/extern/tfn/colormaps/sequential2/gray.cpp deleted file mode 100644 index 8de13a4..0000000 --- a/extern/tfn/colormaps/sequential2/gray.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential2_gray; -} -const std::vector colormap::data_sequential2_gray = /* NOLINT(cert-err58-cpp) */ -{ -{0.0f, 0.0f, 0.0f, 1.0f}, -{0.0039215686274509803f, 0.0039215686274509803f, 0.0039215686274509803f, 1.0f}, -{0.0078431372549019607f, 0.0078431372549019607f, 0.0078431372549019607f, 1.0f}, -{0.011764705882352941f, 0.011764705882352941f, 0.011764705882352941f, 1.0f}, -{0.015686274509803921f, 0.015686274509803921f, 0.015686274509803921f, 1.0f}, -{0.019607843137254902f, 0.019607843137254902f, 0.019607843137254902f, 1.0f}, -{0.023529411764705882f, 0.023529411764705882f, 0.023529411764705882f, 1.0f}, -{0.027450980392156862f, 0.027450980392156862f, 0.027450980392156862f, 1.0f}, -{0.031372549019607843f, 0.031372549019607843f, 0.031372549019607843f, 1.0f}, -{0.035294117647058823f, 0.035294117647058823f, 0.035294117647058823f, 1.0f}, -{0.039215686274509803f, 0.039215686274509803f, 0.039215686274509803f, 1.0f}, -{0.043137254901960784f, 0.043137254901960784f, 0.043137254901960784f, 1.0f}, -{0.047058823529411764f, 0.047058823529411764f, 0.047058823529411764f, 1.0f}, -{0.050980392156862744f, 0.050980392156862744f, 0.050980392156862744f, 1.0f}, -{0.054901960784313725f, 0.054901960784313725f, 0.054901960784313725f, 1.0f}, -{0.058823529411764705f, 0.058823529411764705f, 0.058823529411764705f, 1.0f}, -{0.062745098039215685f, 0.062745098039215685f, 0.062745098039215685f, 1.0f}, -{0.066666666666666666f, 0.066666666666666666f, 0.066666666666666666f, 1.0f}, -{0.070588235294117646f, 0.070588235294117646f, 0.070588235294117646f, 1.0f}, -{0.074509803921568626f, 0.074509803921568626f, 0.074509803921568626f, 1.0f}, -{0.078431372549019607f, 0.078431372549019607f, 0.078431372549019607f, 1.0f}, -{0.082352941176470587f, 0.082352941176470587f, 0.082352941176470587f, 1.0f}, -{0.086274509803921567f, 0.086274509803921567f, 0.086274509803921567f, 1.0f}, -{0.090196078431372548f, 0.090196078431372548f, 0.090196078431372548f, 1.0f}, -{0.094117647058823528f, 0.094117647058823528f, 0.094117647058823528f, 1.0f}, -{0.098039215686274508f, 0.098039215686274508f, 0.098039215686274508f, 1.0f}, -{0.10196078431372549f, 0.10196078431372549f, 0.10196078431372549f, 1.0f}, -{0.10588235294117647f, 0.10588235294117647f, 0.10588235294117647f, 1.0f}, -{0.10980392156862745f, 0.10980392156862745f, 0.10980392156862745f, 1.0f}, -{0.11372549019607843f, 0.11372549019607843f, 0.11372549019607843f, 1.0f}, -{0.11764705882352941f, 0.11764705882352941f, 0.11764705882352941f, 1.0f}, -{0.12156862745098039f, 0.12156862745098039f, 0.12156862745098039f, 1.0f}, -{0.12549019607843137f, 0.12549019607843137f, 0.12549019607843137f, 1.0f}, -{0.12941176470588234f, 0.12941176470588234f, 0.12941176470588234f, 1.0f}, -{0.13333333333333333f, 0.13333333333333333f, 0.13333333333333333f, 1.0f}, -{0.13725490196078433f, 0.13725490196078433f, 0.13725490196078433f, 1.0f}, -{0.14117647058823529f, 0.14117647058823529f, 0.14117647058823529f, 1.0f}, -{0.14509803921568626f, 0.14509803921568626f, 0.14509803921568626f, 1.0f}, -{0.14901960784313725f, 0.14901960784313725f, 0.14901960784313725f, 1.0f}, -{0.15294117647058825f, 0.15294117647058825f, 0.15294117647058825f, 1.0f}, -{0.15686274509803921f, 0.15686274509803921f, 0.15686274509803921f, 1.0f}, -{0.16078431372549018f, 0.16078431372549018f, 0.16078431372549018f, 1.0f}, -{0.16470588235294117f, 0.16470588235294117f, 0.16470588235294117f, 1.0f}, -{0.16862745098039217f, 0.16862745098039217f, 0.16862745098039217f, 1.0f}, -{0.17254901960784313f, 0.17254901960784313f, 0.17254901960784313f, 1.0f}, -{0.1764705882352941f, 0.1764705882352941f, 0.1764705882352941f, 1.0f}, -{0.1803921568627451f, 0.1803921568627451f, 0.1803921568627451f, 1.0f}, -{0.18431372549019609f, 0.18431372549019609f, 0.18431372549019609f, 1.0f}, -{0.18823529411764706f, 0.18823529411764706f, 0.18823529411764706f, 1.0f}, -{0.19215686274509802f, 0.19215686274509802f, 0.19215686274509802f, 1.0f}, -{0.19607843137254902f, 0.19607843137254902f, 0.19607843137254902f, 1.0f}, -{0.20000000000000001f, 0.20000000000000001f, 0.20000000000000001f, 1.0f}, -{0.20392156862745098f, 0.20392156862745098f, 0.20392156862745098f, 1.0f}, -{0.20784313725490194f, 0.20784313725490194f, 0.20784313725490194f, 1.0f}, -{0.21176470588235294f, 0.21176470588235294f, 0.21176470588235294f, 1.0f}, -{0.21568627450980393f, 0.21568627450980393f, 0.21568627450980393f, 1.0f}, -{0.2196078431372549f, 0.2196078431372549f, 0.2196078431372549f, 1.0f}, -{0.22352941176470587f, 0.22352941176470587f, 0.22352941176470587f, 1.0f}, -{0.22745098039215686f, 0.22745098039215686f, 0.22745098039215686f, 1.0f}, -{0.23137254901960785f, 0.23137254901960785f, 0.23137254901960785f, 1.0f}, -{0.23529411764705882f, 0.23529411764705882f, 0.23529411764705882f, 1.0f}, -{0.23921568627450979f, 0.23921568627450979f, 0.23921568627450979f, 1.0f}, -{0.24313725490196078f, 0.24313725490196078f, 0.24313725490196078f, 1.0f}, -{0.24705882352941178f, 0.24705882352941178f, 0.24705882352941178f, 1.0f}, -{0.25098039215686274f, 0.25098039215686274f, 0.25098039215686274f, 1.0f}, -{0.25490196078431371f, 0.25490196078431371f, 0.25490196078431371f, 1.0f}, -{0.25882352941176467f, 0.25882352941176467f, 0.25882352941176467f, 1.0f}, -{0.2627450980392157f, 0.2627450980392157f, 0.2627450980392157f, 1.0f}, -{0.26666666666666666f, 0.26666666666666666f, 0.26666666666666666f, 1.0f}, -{0.27058823529411763f, 0.27058823529411763f, 0.27058823529411763f, 1.0f}, -{0.27450980392156865f, 0.27450980392156865f, 0.27450980392156865f, 1.0f}, -{0.27843137254901962f, 0.27843137254901962f, 0.27843137254901962f, 1.0f}, -{0.28235294117647058f, 0.28235294117647058f, 0.28235294117647058f, 1.0f}, -{0.28627450980392155f, 0.28627450980392155f, 0.28627450980392155f, 1.0f}, -{0.29019607843137252f, 0.29019607843137252f, 0.29019607843137252f, 1.0f}, -{0.29411764705882354f, 0.29411764705882354f, 0.29411764705882354f, 1.0f}, -{0.29803921568627451f, 0.29803921568627451f, 0.29803921568627451f, 1.0f}, -{0.30196078431372547f, 0.30196078431372547f, 0.30196078431372547f, 1.0f}, -{0.30588235294117649f, 0.30588235294117649f, 0.30588235294117649f, 1.0f}, -{0.30980392156862746f, 0.30980392156862746f, 0.30980392156862746f, 1.0f}, -{0.31372549019607843f, 0.31372549019607843f, 0.31372549019607843f, 1.0f}, -{0.31764705882352939f, 0.31764705882352939f, 0.31764705882352939f, 1.0f}, -{0.32156862745098036f, 0.32156862745098036f, 0.32156862745098036f, 1.0f}, -{0.32549019607843138f, 0.32549019607843138f, 0.32549019607843138f, 1.0f}, -{0.32941176470588235f, 0.32941176470588235f, 0.32941176470588235f, 1.0f}, -{0.33333333333333331f, 0.33333333333333331f, 0.33333333333333331f, 1.0f}, -{0.33725490196078434f, 0.33725490196078434f, 0.33725490196078434f, 1.0f}, -{0.3411764705882353f, 0.3411764705882353f, 0.3411764705882353f, 1.0f}, -{0.34509803921568627f, 0.34509803921568627f, 0.34509803921568627f, 1.0f}, -{0.34901960784313724f, 0.34901960784313724f, 0.34901960784313724f, 1.0f}, -{0.3529411764705882f, 0.3529411764705882f, 0.3529411764705882f, 1.0f}, -{0.35686274509803922f, 0.35686274509803922f, 0.35686274509803922f, 1.0f}, -{0.36078431372549019f, 0.36078431372549019f, 0.36078431372549019f, 1.0f}, -{0.36470588235294116f, 0.36470588235294116f, 0.36470588235294116f, 1.0f}, -{0.36862745098039218f, 0.36862745098039218f, 0.36862745098039218f, 1.0f}, -{0.37254901960784315f, 0.37254901960784315f, 0.37254901960784315f, 1.0f}, -{0.37647058823529411f, 0.37647058823529411f, 0.37647058823529411f, 1.0f}, -{0.38039215686274508f, 0.38039215686274508f, 0.38039215686274508f, 1.0f}, -{0.38431372549019605f, 0.38431372549019605f, 0.38431372549019605f, 1.0f}, -{0.38823529411764707f, 0.38823529411764707f, 0.38823529411764707f, 1.0f}, -{0.39215686274509803f, 0.39215686274509803f, 0.39215686274509803f, 1.0f}, -{0.396078431372549f, 0.396078431372549f, 0.396078431372549f, 1.0f}, -{0.40000000000000002f, 0.40000000000000002f, 0.40000000000000002f, 1.0f}, -{0.40392156862745099f, 0.40392156862745099f, 0.40392156862745099f, 1.0f}, -{0.40784313725490196f, 0.40784313725490196f, 0.40784313725490196f, 1.0f}, -{0.41176470588235292f, 0.41176470588235292f, 0.41176470588235292f, 1.0f}, -{0.41568627450980389f, 0.41568627450980389f, 0.41568627450980389f, 1.0f}, -{0.41960784313725491f, 0.41960784313725491f, 0.41960784313725491f, 1.0f}, -{0.42352941176470588f, 0.42352941176470588f, 0.42352941176470588f, 1.0f}, -{0.42745098039215684f, 0.42745098039215684f, 0.42745098039215684f, 1.0f}, -{0.43137254901960786f, 0.43137254901960786f, 0.43137254901960786f, 1.0f}, -{0.43529411764705883f, 0.43529411764705883f, 0.43529411764705883f, 1.0f}, -{0.4392156862745098f, 0.4392156862745098f, 0.4392156862745098f, 1.0f}, -{0.44313725490196076f, 0.44313725490196076f, 0.44313725490196076f, 1.0f}, -{0.44705882352941173f, 0.44705882352941173f, 0.44705882352941173f, 1.0f}, -{0.45098039215686275f, 0.45098039215686275f, 0.45098039215686275f, 1.0f}, -{0.45490196078431372f, 0.45490196078431372f, 0.45490196078431372f, 1.0f}, -{0.45882352941176469f, 0.45882352941176469f, 0.45882352941176469f, 1.0f}, -{0.46274509803921571f, 0.46274509803921571f, 0.46274509803921571f, 1.0f}, -{0.46666666666666667f, 0.46666666666666667f, 0.46666666666666667f, 1.0f}, -{0.47058823529411764f, 0.47058823529411764f, 0.47058823529411764f, 1.0f}, -{0.47450980392156861f, 0.47450980392156861f, 0.47450980392156861f, 1.0f}, -{0.47843137254901957f, 0.47843137254901957f, 0.47843137254901957f, 1.0f}, -{0.4823529411764706f, 0.4823529411764706f, 0.4823529411764706f, 1.0f}, -{0.48627450980392156f, 0.48627450980392156f, 0.48627450980392156f, 1.0f}, -{0.49019607843137253f, 0.49019607843137253f, 0.49019607843137253f, 1.0f}, -{0.49411764705882355f, 0.49411764705882355f, 0.49411764705882355f, 1.0f}, -{0.49803921568627452f, 0.49803921568627452f, 0.49803921568627452f, 1.0f}, -{0.50196078431372548f, 0.50196078431372548f, 0.50196078431372548f, 1.0f}, -{0.50588235294117645f, 0.50588235294117645f, 0.50588235294117645f, 1.0f}, -{0.50980392156862742f, 0.50980392156862742f, 0.50980392156862742f, 1.0f}, -{0.51372549019607838f, 0.51372549019607838f, 0.51372549019607838f, 1.0f}, -{0.51764705882352935f, 0.51764705882352935f, 0.51764705882352935f, 1.0f}, -{0.52156862745098043f, 0.52156862745098043f, 0.52156862745098043f, 1.0f}, -{0.52549019607843139f, 0.52549019607843139f, 0.52549019607843139f, 1.0f}, -{0.52941176470588236f, 0.52941176470588236f, 0.52941176470588236f, 1.0f}, -{0.53333333333333333f, 0.53333333333333333f, 0.53333333333333333f, 1.0f}, -{0.53725490196078429f, 0.53725490196078429f, 0.53725490196078429f, 1.0f}, -{0.54117647058823526f, 0.54117647058823526f, 0.54117647058823526f, 1.0f}, -{0.54509803921568623f, 0.54509803921568623f, 0.54509803921568623f, 1.0f}, -{0.5490196078431373f, 0.5490196078431373f, 0.5490196078431373f, 1.0f}, -{0.55294117647058827f, 0.55294117647058827f, 0.55294117647058827f, 1.0f}, -{0.55686274509803924f, 0.55686274509803924f, 0.55686274509803924f, 1.0f}, -{0.5607843137254902f, 0.5607843137254902f, 0.5607843137254902f, 1.0f}, -{0.56470588235294117f, 0.56470588235294117f, 0.56470588235294117f, 1.0f}, -{0.56862745098039214f, 0.56862745098039214f, 0.56862745098039214f, 1.0f}, -{0.5725490196078431f, 0.5725490196078431f, 0.5725490196078431f, 1.0f}, -{0.57647058823529407f, 0.57647058823529407f, 0.57647058823529407f, 1.0f}, -{0.58039215686274503f, 0.58039215686274503f, 0.58039215686274503f, 1.0f}, -{0.58431372549019611f, 0.58431372549019611f, 0.58431372549019611f, 1.0f}, -{0.58823529411764708f, 0.58823529411764708f, 0.58823529411764708f, 1.0f}, -{0.59215686274509804f, 0.59215686274509804f, 0.59215686274509804f, 1.0f}, -{0.59607843137254901f, 0.59607843137254901f, 0.59607843137254901f, 1.0f}, -{0.59999999999999998f, 0.59999999999999998f, 0.59999999999999998f, 1.0f}, -{0.60392156862745094f, 0.60392156862745094f, 0.60392156862745094f, 1.0f}, -{0.60784313725490191f, 0.60784313725490191f, 0.60784313725490191f, 1.0f}, -{0.61176470588235299f, 0.61176470588235299f, 0.61176470588235299f, 1.0f}, -{0.61568627450980395f, 0.61568627450980395f, 0.61568627450980395f, 1.0f}, -{0.61960784313725492f, 0.61960784313725492f, 0.61960784313725492f, 1.0f}, -{0.62352941176470589f, 0.62352941176470589f, 0.62352941176470589f, 1.0f}, -{0.62745098039215685f, 0.62745098039215685f, 0.62745098039215685f, 1.0f}, -{0.63137254901960782f, 0.63137254901960782f, 0.63137254901960782f, 1.0f}, -{0.63529411764705879f, 0.63529411764705879f, 0.63529411764705879f, 1.0f}, -{0.63921568627450975f, 0.63921568627450975f, 0.63921568627450975f, 1.0f}, -{0.64313725490196072f, 0.64313725490196072f, 0.64313725490196072f, 1.0f}, -{0.6470588235294118f, 0.6470588235294118f, 0.6470588235294118f, 1.0f}, -{0.65098039215686276f, 0.65098039215686276f, 0.65098039215686276f, 1.0f}, -{0.65490196078431373f, 0.65490196078431373f, 0.65490196078431373f, 1.0f}, -{0.6588235294117647f, 0.6588235294117647f, 0.6588235294117647f, 1.0f}, -{0.66274509803921566f, 0.66274509803921566f, 0.66274509803921566f, 1.0f}, -{0.66666666666666663f, 0.66666666666666663f, 0.66666666666666663f, 1.0f}, -{0.6705882352941176f, 0.6705882352941176f, 0.6705882352941176f, 1.0f}, -{0.67450980392156867f, 0.67450980392156867f, 0.67450980392156867f, 1.0f}, -{0.67843137254901964f, 0.67843137254901964f, 0.67843137254901964f, 1.0f}, -{0.68235294117647061f, 0.68235294117647061f, 0.68235294117647061f, 1.0f}, -{0.68627450980392157f, 0.68627450980392157f, 0.68627450980392157f, 1.0f}, -{0.69019607843137254f, 0.69019607843137254f, 0.69019607843137254f, 1.0f}, -{0.69411764705882351f, 0.69411764705882351f, 0.69411764705882351f, 1.0f}, -{0.69803921568627447f, 0.69803921568627447f, 0.69803921568627447f, 1.0f}, -{0.70196078431372544f, 0.70196078431372544f, 0.70196078431372544f, 1.0f}, -{0.70588235294117641f, 0.70588235294117641f, 0.70588235294117641f, 1.0f}, -{0.70980392156862748f, 0.70980392156862748f, 0.70980392156862748f, 1.0f}, -{0.71372549019607845f, 0.71372549019607845f, 0.71372549019607845f, 1.0f}, -{0.71764705882352942f, 0.71764705882352942f, 0.71764705882352942f, 1.0f}, -{0.72156862745098038f, 0.72156862745098038f, 0.72156862745098038f, 1.0f}, -{0.72549019607843135f, 0.72549019607843135f, 0.72549019607843135f, 1.0f}, -{0.72941176470588232f, 0.72941176470588232f, 0.72941176470588232f, 1.0f}, -{0.73333333333333328f, 0.73333333333333328f, 0.73333333333333328f, 1.0f}, -{0.73725490196078436f, 0.73725490196078436f, 0.73725490196078436f, 1.0f}, -{0.74117647058823533f, 0.74117647058823533f, 0.74117647058823533f, 1.0f}, -{0.74509803921568629f, 0.74509803921568629f, 0.74509803921568629f, 1.0f}, -{0.74901960784313726f, 0.74901960784313726f, 0.74901960784313726f, 1.0f}, -{0.75294117647058822f, 0.75294117647058822f, 0.75294117647058822f, 1.0f}, -{0.75686274509803919f, 0.75686274509803919f, 0.75686274509803919f, 1.0f}, -{0.76078431372549016f, 0.76078431372549016f, 0.76078431372549016f, 1.0f}, -{0.76470588235294112f, 0.76470588235294112f, 0.76470588235294112f, 1.0f}, -{0.76862745098039209f, 0.76862745098039209f, 0.76862745098039209f, 1.0f}, -{0.77254901960784317f, 0.77254901960784317f, 0.77254901960784317f, 1.0f}, -{0.77647058823529413f, 0.77647058823529413f, 0.77647058823529413f, 1.0f}, -{0.7803921568627451f, 0.7803921568627451f, 0.7803921568627451f, 1.0f}, -{0.78431372549019607f, 0.78431372549019607f, 0.78431372549019607f, 1.0f}, -{0.78823529411764703f, 0.78823529411764703f, 0.78823529411764703f, 1.0f}, -{0.792156862745098f, 0.792156862745098f, 0.792156862745098f, 1.0f}, -{0.79607843137254897f, 0.79607843137254897f, 0.79607843137254897f, 1.0f}, -{0.80000000000000004f, 0.80000000000000004f, 0.80000000000000004f, 1.0f}, -{0.80392156862745101f, 0.80392156862745101f, 0.80392156862745101f, 1.0f}, -{0.80784313725490198f, 0.80784313725490198f, 0.80784313725490198f, 1.0f}, -{0.81176470588235294f, 0.81176470588235294f, 0.81176470588235294f, 1.0f}, -{0.81568627450980391f, 0.81568627450980391f, 0.81568627450980391f, 1.0f}, -{0.81960784313725488f, 0.81960784313725488f, 0.81960784313725488f, 1.0f}, -{0.82352941176470584f, 0.82352941176470584f, 0.82352941176470584f, 1.0f}, -{0.82745098039215681f, 0.82745098039215681f, 0.82745098039215681f, 1.0f}, -{0.83137254901960778f, 0.83137254901960778f, 0.83137254901960778f, 1.0f}, -{0.83529411764705885f, 0.83529411764705885f, 0.83529411764705885f, 1.0f}, -{0.83921568627450982f, 0.83921568627450982f, 0.83921568627450982f, 1.0f}, -{0.84313725490196079f, 0.84313725490196079f, 0.84313725490196079f, 1.0f}, -{0.84705882352941175f, 0.84705882352941175f, 0.84705882352941175f, 1.0f}, -{0.85098039215686272f, 0.85098039215686272f, 0.85098039215686272f, 1.0f}, -{0.85490196078431369f, 0.85490196078431369f, 0.85490196078431369f, 1.0f}, -{0.85882352941176465f, 0.85882352941176465f, 0.85882352941176465f, 1.0f}, -{0.86274509803921573f, 0.86274509803921573f, 0.86274509803921573f, 1.0f}, -{0.8666666666666667f, 0.8666666666666667f, 0.8666666666666667f, 1.0f}, -{0.87058823529411766f, 0.87058823529411766f, 0.87058823529411766f, 1.0f}, -{0.87450980392156863f, 0.87450980392156863f, 0.87450980392156863f, 1.0f}, -{0.8784313725490196f, 0.8784313725490196f, 0.8784313725490196f, 1.0f}, -{0.88235294117647056f, 0.88235294117647056f, 0.88235294117647056f, 1.0f}, -{0.88627450980392153f, 0.88627450980392153f, 0.88627450980392153f, 1.0f}, -{0.8901960784313725f, 0.8901960784313725f, 0.8901960784313725f, 1.0f}, -{0.89411764705882346f, 0.89411764705882346f, 0.89411764705882346f, 1.0f}, -{0.89803921568627454f, 0.89803921568627454f, 0.89803921568627454f, 1.0f}, -{0.90196078431372551f, 0.90196078431372551f, 0.90196078431372551f, 1.0f}, -{0.90588235294117647f, 0.90588235294117647f, 0.90588235294117647f, 1.0f}, -{0.90980392156862744f, 0.90980392156862744f, 0.90980392156862744f, 1.0f}, -{0.9137254901960784f, 0.9137254901960784f, 0.9137254901960784f, 1.0f}, -{0.91764705882352937f, 0.91764705882352937f, 0.91764705882352937f, 1.0f}, -{0.92156862745098034f, 0.92156862745098034f, 0.92156862745098034f, 1.0f}, -{0.92549019607843142f, 0.92549019607843142f, 0.92549019607843142f, 1.0f}, -{0.92941176470588238f, 0.92941176470588238f, 0.92941176470588238f, 1.0f}, -{0.93333333333333335f, 0.93333333333333335f, 0.93333333333333335f, 1.0f}, -{0.93725490196078431f, 0.93725490196078431f, 0.93725490196078431f, 1.0f}, -{0.94117647058823528f, 0.94117647058823528f, 0.94117647058823528f, 1.0f}, -{0.94509803921568625f, 0.94509803921568625f, 0.94509803921568625f, 1.0f}, -{0.94901960784313721f, 0.94901960784313721f, 0.94901960784313721f, 1.0f}, -{0.95294117647058818f, 0.95294117647058818f, 0.95294117647058818f, 1.0f}, -{0.95686274509803915f, 0.95686274509803915f, 0.95686274509803915f, 1.0f}, -{0.96078431372549022f, 0.96078431372549022f, 0.96078431372549022f, 1.0f}, -{0.96470588235294119f, 0.96470588235294119f, 0.96470588235294119f, 1.0f}, -{0.96862745098039216f, 0.96862745098039216f, 0.96862745098039216f, 1.0f}, -{0.97254901960784312f, 0.97254901960784312f, 0.97254901960784312f, 1.0f}, -{0.97647058823529409f, 0.97647058823529409f, 0.97647058823529409f, 1.0f}, -{0.98039215686274506f, 0.98039215686274506f, 0.98039215686274506f, 1.0f}, -{0.98431372549019602f, 0.98431372549019602f, 0.98431372549019602f, 1.0f}, -{0.9882352941176471f, 0.9882352941176471f, 0.9882352941176471f, 1.0f}, -{0.99215686274509807f, 0.99215686274509807f, 0.99215686274509807f, 1.0f}, -{0.99607843137254903f, 0.99607843137254903f, 0.99607843137254903f, 1.0f}, -{1.0f, 1.0f, 1.0f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential2/gray.txt b/extern/tfn/colormaps/sequential2/gray.txt deleted file mode 100644 index 3cc6aef..0000000 --- a/extern/tfn/colormaps/sequential2/gray.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.0, 0.0, 0.0, 1.0) -(0.0039215686274509803, 0.0039215686274509803, 0.0039215686274509803, 1.0) -(0.0078431372549019607, 0.0078431372549019607, 0.0078431372549019607, 1.0) -(0.011764705882352941, 0.011764705882352941, 0.011764705882352941, 1.0) -(0.015686274509803921, 0.015686274509803921, 0.015686274509803921, 1.0) -(0.019607843137254902, 0.019607843137254902, 0.019607843137254902, 1.0) -(0.023529411764705882, 0.023529411764705882, 0.023529411764705882, 1.0) -(0.027450980392156862, 0.027450980392156862, 0.027450980392156862, 1.0) -(0.031372549019607843, 0.031372549019607843, 0.031372549019607843, 1.0) -(0.035294117647058823, 0.035294117647058823, 0.035294117647058823, 1.0) -(0.039215686274509803, 0.039215686274509803, 0.039215686274509803, 1.0) -(0.043137254901960784, 0.043137254901960784, 0.043137254901960784, 1.0) -(0.047058823529411764, 0.047058823529411764, 0.047058823529411764, 1.0) -(0.050980392156862744, 0.050980392156862744, 0.050980392156862744, 1.0) -(0.054901960784313725, 0.054901960784313725, 0.054901960784313725, 1.0) -(0.058823529411764705, 0.058823529411764705, 0.058823529411764705, 1.0) -(0.062745098039215685, 0.062745098039215685, 0.062745098039215685, 1.0) -(0.066666666666666666, 0.066666666666666666, 0.066666666666666666, 1.0) -(0.070588235294117646, 0.070588235294117646, 0.070588235294117646, 1.0) -(0.074509803921568626, 0.074509803921568626, 0.074509803921568626, 1.0) -(0.078431372549019607, 0.078431372549019607, 0.078431372549019607, 1.0) -(0.082352941176470587, 0.082352941176470587, 0.082352941176470587, 1.0) -(0.086274509803921567, 0.086274509803921567, 0.086274509803921567, 1.0) -(0.090196078431372548, 0.090196078431372548, 0.090196078431372548, 1.0) -(0.094117647058823528, 0.094117647058823528, 0.094117647058823528, 1.0) -(0.098039215686274508, 0.098039215686274508, 0.098039215686274508, 1.0) -(0.10196078431372549, 0.10196078431372549, 0.10196078431372549, 1.0) -(0.10588235294117647, 0.10588235294117647, 0.10588235294117647, 1.0) -(0.10980392156862745, 0.10980392156862745, 0.10980392156862745, 1.0) -(0.11372549019607843, 0.11372549019607843, 0.11372549019607843, 1.0) -(0.11764705882352941, 0.11764705882352941, 0.11764705882352941, 1.0) -(0.12156862745098039, 0.12156862745098039, 0.12156862745098039, 1.0) -(0.12549019607843137, 0.12549019607843137, 0.12549019607843137, 1.0) -(0.12941176470588234, 0.12941176470588234, 0.12941176470588234, 1.0) -(0.13333333333333333, 0.13333333333333333, 0.13333333333333333, 1.0) -(0.13725490196078433, 0.13725490196078433, 0.13725490196078433, 1.0) -(0.14117647058823529, 0.14117647058823529, 0.14117647058823529, 1.0) -(0.14509803921568626, 0.14509803921568626, 0.14509803921568626, 1.0) -(0.14901960784313725, 0.14901960784313725, 0.14901960784313725, 1.0) -(0.15294117647058825, 0.15294117647058825, 0.15294117647058825, 1.0) -(0.15686274509803921, 0.15686274509803921, 0.15686274509803921, 1.0) -(0.16078431372549018, 0.16078431372549018, 0.16078431372549018, 1.0) -(0.16470588235294117, 0.16470588235294117, 0.16470588235294117, 1.0) -(0.16862745098039217, 0.16862745098039217, 0.16862745098039217, 1.0) -(0.17254901960784313, 0.17254901960784313, 0.17254901960784313, 1.0) -(0.1764705882352941, 0.1764705882352941, 0.1764705882352941, 1.0) -(0.1803921568627451, 0.1803921568627451, 0.1803921568627451, 1.0) -(0.18431372549019609, 0.18431372549019609, 0.18431372549019609, 1.0) -(0.18823529411764706, 0.18823529411764706, 0.18823529411764706, 1.0) -(0.19215686274509802, 0.19215686274509802, 0.19215686274509802, 1.0) -(0.19607843137254902, 0.19607843137254902, 0.19607843137254902, 1.0) -(0.20000000000000001, 0.20000000000000001, 0.20000000000000001, 1.0) -(0.20392156862745098, 0.20392156862745098, 0.20392156862745098, 1.0) -(0.20784313725490194, 0.20784313725490194, 0.20784313725490194, 1.0) -(0.21176470588235294, 0.21176470588235294, 0.21176470588235294, 1.0) -(0.21568627450980393, 0.21568627450980393, 0.21568627450980393, 1.0) -(0.2196078431372549, 0.2196078431372549, 0.2196078431372549, 1.0) -(0.22352941176470587, 0.22352941176470587, 0.22352941176470587, 1.0) -(0.22745098039215686, 0.22745098039215686, 0.22745098039215686, 1.0) -(0.23137254901960785, 0.23137254901960785, 0.23137254901960785, 1.0) -(0.23529411764705882, 0.23529411764705882, 0.23529411764705882, 1.0) -(0.23921568627450979, 0.23921568627450979, 0.23921568627450979, 1.0) -(0.24313725490196078, 0.24313725490196078, 0.24313725490196078, 1.0) -(0.24705882352941178, 0.24705882352941178, 0.24705882352941178, 1.0) -(0.25098039215686274, 0.25098039215686274, 0.25098039215686274, 1.0) -(0.25490196078431371, 0.25490196078431371, 0.25490196078431371, 1.0) -(0.25882352941176467, 0.25882352941176467, 0.25882352941176467, 1.0) -(0.2627450980392157, 0.2627450980392157, 0.2627450980392157, 1.0) -(0.26666666666666666, 0.26666666666666666, 0.26666666666666666, 1.0) -(0.27058823529411763, 0.27058823529411763, 0.27058823529411763, 1.0) -(0.27450980392156865, 0.27450980392156865, 0.27450980392156865, 1.0) -(0.27843137254901962, 0.27843137254901962, 0.27843137254901962, 1.0) -(0.28235294117647058, 0.28235294117647058, 0.28235294117647058, 1.0) -(0.28627450980392155, 0.28627450980392155, 0.28627450980392155, 1.0) -(0.29019607843137252, 0.29019607843137252, 0.29019607843137252, 1.0) -(0.29411764705882354, 0.29411764705882354, 0.29411764705882354, 1.0) -(0.29803921568627451, 0.29803921568627451, 0.29803921568627451, 1.0) -(0.30196078431372547, 0.30196078431372547, 0.30196078431372547, 1.0) -(0.30588235294117649, 0.30588235294117649, 0.30588235294117649, 1.0) -(0.30980392156862746, 0.30980392156862746, 0.30980392156862746, 1.0) -(0.31372549019607843, 0.31372549019607843, 0.31372549019607843, 1.0) -(0.31764705882352939, 0.31764705882352939, 0.31764705882352939, 1.0) -(0.32156862745098036, 0.32156862745098036, 0.32156862745098036, 1.0) -(0.32549019607843138, 0.32549019607843138, 0.32549019607843138, 1.0) -(0.32941176470588235, 0.32941176470588235, 0.32941176470588235, 1.0) -(0.33333333333333331, 0.33333333333333331, 0.33333333333333331, 1.0) -(0.33725490196078434, 0.33725490196078434, 0.33725490196078434, 1.0) -(0.3411764705882353, 0.3411764705882353, 0.3411764705882353, 1.0) -(0.34509803921568627, 0.34509803921568627, 0.34509803921568627, 1.0) -(0.34901960784313724, 0.34901960784313724, 0.34901960784313724, 1.0) -(0.3529411764705882, 0.3529411764705882, 0.3529411764705882, 1.0) -(0.35686274509803922, 0.35686274509803922, 0.35686274509803922, 1.0) -(0.36078431372549019, 0.36078431372549019, 0.36078431372549019, 1.0) -(0.36470588235294116, 0.36470588235294116, 0.36470588235294116, 1.0) -(0.36862745098039218, 0.36862745098039218, 0.36862745098039218, 1.0) -(0.37254901960784315, 0.37254901960784315, 0.37254901960784315, 1.0) -(0.37647058823529411, 0.37647058823529411, 0.37647058823529411, 1.0) -(0.38039215686274508, 0.38039215686274508, 0.38039215686274508, 1.0) -(0.38431372549019605, 0.38431372549019605, 0.38431372549019605, 1.0) -(0.38823529411764707, 0.38823529411764707, 0.38823529411764707, 1.0) -(0.39215686274509803, 0.39215686274509803, 0.39215686274509803, 1.0) -(0.396078431372549, 0.396078431372549, 0.396078431372549, 1.0) -(0.40000000000000002, 0.40000000000000002, 0.40000000000000002, 1.0) -(0.40392156862745099, 0.40392156862745099, 0.40392156862745099, 1.0) -(0.40784313725490196, 0.40784313725490196, 0.40784313725490196, 1.0) -(0.41176470588235292, 0.41176470588235292, 0.41176470588235292, 1.0) -(0.41568627450980389, 0.41568627450980389, 0.41568627450980389, 1.0) -(0.41960784313725491, 0.41960784313725491, 0.41960784313725491, 1.0) -(0.42352941176470588, 0.42352941176470588, 0.42352941176470588, 1.0) -(0.42745098039215684, 0.42745098039215684, 0.42745098039215684, 1.0) -(0.43137254901960786, 0.43137254901960786, 0.43137254901960786, 1.0) -(0.43529411764705883, 0.43529411764705883, 0.43529411764705883, 1.0) -(0.4392156862745098, 0.4392156862745098, 0.4392156862745098, 1.0) -(0.44313725490196076, 0.44313725490196076, 0.44313725490196076, 1.0) -(0.44705882352941173, 0.44705882352941173, 0.44705882352941173, 1.0) -(0.45098039215686275, 0.45098039215686275, 0.45098039215686275, 1.0) -(0.45490196078431372, 0.45490196078431372, 0.45490196078431372, 1.0) -(0.45882352941176469, 0.45882352941176469, 0.45882352941176469, 1.0) -(0.46274509803921571, 0.46274509803921571, 0.46274509803921571, 1.0) -(0.46666666666666667, 0.46666666666666667, 0.46666666666666667, 1.0) -(0.47058823529411764, 0.47058823529411764, 0.47058823529411764, 1.0) -(0.47450980392156861, 0.47450980392156861, 0.47450980392156861, 1.0) -(0.47843137254901957, 0.47843137254901957, 0.47843137254901957, 1.0) -(0.4823529411764706, 0.4823529411764706, 0.4823529411764706, 1.0) -(0.48627450980392156, 0.48627450980392156, 0.48627450980392156, 1.0) -(0.49019607843137253, 0.49019607843137253, 0.49019607843137253, 1.0) -(0.49411764705882355, 0.49411764705882355, 0.49411764705882355, 1.0) -(0.49803921568627452, 0.49803921568627452, 0.49803921568627452, 1.0) -(0.50196078431372548, 0.50196078431372548, 0.50196078431372548, 1.0) -(0.50588235294117645, 0.50588235294117645, 0.50588235294117645, 1.0) -(0.50980392156862742, 0.50980392156862742, 0.50980392156862742, 1.0) -(0.51372549019607838, 0.51372549019607838, 0.51372549019607838, 1.0) -(0.51764705882352935, 0.51764705882352935, 0.51764705882352935, 1.0) -(0.52156862745098043, 0.52156862745098043, 0.52156862745098043, 1.0) -(0.52549019607843139, 0.52549019607843139, 0.52549019607843139, 1.0) -(0.52941176470588236, 0.52941176470588236, 0.52941176470588236, 1.0) -(0.53333333333333333, 0.53333333333333333, 0.53333333333333333, 1.0) -(0.53725490196078429, 0.53725490196078429, 0.53725490196078429, 1.0) -(0.54117647058823526, 0.54117647058823526, 0.54117647058823526, 1.0) -(0.54509803921568623, 0.54509803921568623, 0.54509803921568623, 1.0) -(0.5490196078431373, 0.5490196078431373, 0.5490196078431373, 1.0) -(0.55294117647058827, 0.55294117647058827, 0.55294117647058827, 1.0) -(0.55686274509803924, 0.55686274509803924, 0.55686274509803924, 1.0) -(0.5607843137254902, 0.5607843137254902, 0.5607843137254902, 1.0) -(0.56470588235294117, 0.56470588235294117, 0.56470588235294117, 1.0) -(0.56862745098039214, 0.56862745098039214, 0.56862745098039214, 1.0) -(0.5725490196078431, 0.5725490196078431, 0.5725490196078431, 1.0) -(0.57647058823529407, 0.57647058823529407, 0.57647058823529407, 1.0) -(0.58039215686274503, 0.58039215686274503, 0.58039215686274503, 1.0) -(0.58431372549019611, 0.58431372549019611, 0.58431372549019611, 1.0) -(0.58823529411764708, 0.58823529411764708, 0.58823529411764708, 1.0) -(0.59215686274509804, 0.59215686274509804, 0.59215686274509804, 1.0) -(0.59607843137254901, 0.59607843137254901, 0.59607843137254901, 1.0) -(0.59999999999999998, 0.59999999999999998, 0.59999999999999998, 1.0) -(0.60392156862745094, 0.60392156862745094, 0.60392156862745094, 1.0) -(0.60784313725490191, 0.60784313725490191, 0.60784313725490191, 1.0) -(0.61176470588235299, 0.61176470588235299, 0.61176470588235299, 1.0) -(0.61568627450980395, 0.61568627450980395, 0.61568627450980395, 1.0) -(0.61960784313725492, 0.61960784313725492, 0.61960784313725492, 1.0) -(0.62352941176470589, 0.62352941176470589, 0.62352941176470589, 1.0) -(0.62745098039215685, 0.62745098039215685, 0.62745098039215685, 1.0) -(0.63137254901960782, 0.63137254901960782, 0.63137254901960782, 1.0) -(0.63529411764705879, 0.63529411764705879, 0.63529411764705879, 1.0) -(0.63921568627450975, 0.63921568627450975, 0.63921568627450975, 1.0) -(0.64313725490196072, 0.64313725490196072, 0.64313725490196072, 1.0) -(0.6470588235294118, 0.6470588235294118, 0.6470588235294118, 1.0) -(0.65098039215686276, 0.65098039215686276, 0.65098039215686276, 1.0) -(0.65490196078431373, 0.65490196078431373, 0.65490196078431373, 1.0) -(0.6588235294117647, 0.6588235294117647, 0.6588235294117647, 1.0) -(0.66274509803921566, 0.66274509803921566, 0.66274509803921566, 1.0) -(0.66666666666666663, 0.66666666666666663, 0.66666666666666663, 1.0) -(0.6705882352941176, 0.6705882352941176, 0.6705882352941176, 1.0) -(0.67450980392156867, 0.67450980392156867, 0.67450980392156867, 1.0) -(0.67843137254901964, 0.67843137254901964, 0.67843137254901964, 1.0) -(0.68235294117647061, 0.68235294117647061, 0.68235294117647061, 1.0) -(0.68627450980392157, 0.68627450980392157, 0.68627450980392157, 1.0) -(0.69019607843137254, 0.69019607843137254, 0.69019607843137254, 1.0) -(0.69411764705882351, 0.69411764705882351, 0.69411764705882351, 1.0) -(0.69803921568627447, 0.69803921568627447, 0.69803921568627447, 1.0) -(0.70196078431372544, 0.70196078431372544, 0.70196078431372544, 1.0) -(0.70588235294117641, 0.70588235294117641, 0.70588235294117641, 1.0) -(0.70980392156862748, 0.70980392156862748, 0.70980392156862748, 1.0) -(0.71372549019607845, 0.71372549019607845, 0.71372549019607845, 1.0) -(0.71764705882352942, 0.71764705882352942, 0.71764705882352942, 1.0) -(0.72156862745098038, 0.72156862745098038, 0.72156862745098038, 1.0) -(0.72549019607843135, 0.72549019607843135, 0.72549019607843135, 1.0) -(0.72941176470588232, 0.72941176470588232, 0.72941176470588232, 1.0) -(0.73333333333333328, 0.73333333333333328, 0.73333333333333328, 1.0) -(0.73725490196078436, 0.73725490196078436, 0.73725490196078436, 1.0) -(0.74117647058823533, 0.74117647058823533, 0.74117647058823533, 1.0) -(0.74509803921568629, 0.74509803921568629, 0.74509803921568629, 1.0) -(0.74901960784313726, 0.74901960784313726, 0.74901960784313726, 1.0) -(0.75294117647058822, 0.75294117647058822, 0.75294117647058822, 1.0) -(0.75686274509803919, 0.75686274509803919, 0.75686274509803919, 1.0) -(0.76078431372549016, 0.76078431372549016, 0.76078431372549016, 1.0) -(0.76470588235294112, 0.76470588235294112, 0.76470588235294112, 1.0) -(0.76862745098039209, 0.76862745098039209, 0.76862745098039209, 1.0) -(0.77254901960784317, 0.77254901960784317, 0.77254901960784317, 1.0) -(0.77647058823529413, 0.77647058823529413, 0.77647058823529413, 1.0) -(0.7803921568627451, 0.7803921568627451, 0.7803921568627451, 1.0) -(0.78431372549019607, 0.78431372549019607, 0.78431372549019607, 1.0) -(0.78823529411764703, 0.78823529411764703, 0.78823529411764703, 1.0) -(0.792156862745098, 0.792156862745098, 0.792156862745098, 1.0) -(0.79607843137254897, 0.79607843137254897, 0.79607843137254897, 1.0) -(0.80000000000000004, 0.80000000000000004, 0.80000000000000004, 1.0) -(0.80392156862745101, 0.80392156862745101, 0.80392156862745101, 1.0) -(0.80784313725490198, 0.80784313725490198, 0.80784313725490198, 1.0) -(0.81176470588235294, 0.81176470588235294, 0.81176470588235294, 1.0) -(0.81568627450980391, 0.81568627450980391, 0.81568627450980391, 1.0) -(0.81960784313725488, 0.81960784313725488, 0.81960784313725488, 1.0) -(0.82352941176470584, 0.82352941176470584, 0.82352941176470584, 1.0) -(0.82745098039215681, 0.82745098039215681, 0.82745098039215681, 1.0) -(0.83137254901960778, 0.83137254901960778, 0.83137254901960778, 1.0) -(0.83529411764705885, 0.83529411764705885, 0.83529411764705885, 1.0) -(0.83921568627450982, 0.83921568627450982, 0.83921568627450982, 1.0) -(0.84313725490196079, 0.84313725490196079, 0.84313725490196079, 1.0) -(0.84705882352941175, 0.84705882352941175, 0.84705882352941175, 1.0) -(0.85098039215686272, 0.85098039215686272, 0.85098039215686272, 1.0) -(0.85490196078431369, 0.85490196078431369, 0.85490196078431369, 1.0) -(0.85882352941176465, 0.85882352941176465, 0.85882352941176465, 1.0) -(0.86274509803921573, 0.86274509803921573, 0.86274509803921573, 1.0) -(0.8666666666666667, 0.8666666666666667, 0.8666666666666667, 1.0) -(0.87058823529411766, 0.87058823529411766, 0.87058823529411766, 1.0) -(0.87450980392156863, 0.87450980392156863, 0.87450980392156863, 1.0) -(0.8784313725490196, 0.8784313725490196, 0.8784313725490196, 1.0) -(0.88235294117647056, 0.88235294117647056, 0.88235294117647056, 1.0) -(0.88627450980392153, 0.88627450980392153, 0.88627450980392153, 1.0) -(0.8901960784313725, 0.8901960784313725, 0.8901960784313725, 1.0) -(0.89411764705882346, 0.89411764705882346, 0.89411764705882346, 1.0) -(0.89803921568627454, 0.89803921568627454, 0.89803921568627454, 1.0) -(0.90196078431372551, 0.90196078431372551, 0.90196078431372551, 1.0) -(0.90588235294117647, 0.90588235294117647, 0.90588235294117647, 1.0) -(0.90980392156862744, 0.90980392156862744, 0.90980392156862744, 1.0) -(0.9137254901960784, 0.9137254901960784, 0.9137254901960784, 1.0) -(0.91764705882352937, 0.91764705882352937, 0.91764705882352937, 1.0) -(0.92156862745098034, 0.92156862745098034, 0.92156862745098034, 1.0) -(0.92549019607843142, 0.92549019607843142, 0.92549019607843142, 1.0) -(0.92941176470588238, 0.92941176470588238, 0.92941176470588238, 1.0) -(0.93333333333333335, 0.93333333333333335, 0.93333333333333335, 1.0) -(0.93725490196078431, 0.93725490196078431, 0.93725490196078431, 1.0) -(0.94117647058823528, 0.94117647058823528, 0.94117647058823528, 1.0) -(0.94509803921568625, 0.94509803921568625, 0.94509803921568625, 1.0) -(0.94901960784313721, 0.94901960784313721, 0.94901960784313721, 1.0) -(0.95294117647058818, 0.95294117647058818, 0.95294117647058818, 1.0) -(0.95686274509803915, 0.95686274509803915, 0.95686274509803915, 1.0) -(0.96078431372549022, 0.96078431372549022, 0.96078431372549022, 1.0) -(0.96470588235294119, 0.96470588235294119, 0.96470588235294119, 1.0) -(0.96862745098039216, 0.96862745098039216, 0.96862745098039216, 1.0) -(0.97254901960784312, 0.97254901960784312, 0.97254901960784312, 1.0) -(0.97647058823529409, 0.97647058823529409, 0.97647058823529409, 1.0) -(0.98039215686274506, 0.98039215686274506, 0.98039215686274506, 1.0) -(0.98431372549019602, 0.98431372549019602, 0.98431372549019602, 1.0) -(0.9882352941176471, 0.9882352941176471, 0.9882352941176471, 1.0) -(0.99215686274509807, 0.99215686274509807, 0.99215686274509807, 1.0) -(0.99607843137254903, 0.99607843137254903, 0.99607843137254903, 1.0) -(1.0, 1.0, 1.0, 1.0) diff --git a/extern/tfn/colormaps/sequential2/hot.cpp b/extern/tfn/colormaps/sequential2/hot.cpp deleted file mode 100644 index df8ab83..0000000 --- a/extern/tfn/colormaps/sequential2/hot.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential2_hot; -} -const std::vector colormap::data_sequential2_hot = /* NOLINT(cert-err58-cpp) */ -{ -{0.041599999999999998f, 0.0f, 0.0f, 1.0f}, -{0.051894844054434848f, 0.0f, 0.0f, 1.0f}, -{0.062189688108869698f, 0.0f, 0.0f, 1.0f}, -{0.072484532163304541f, 0.0f, 0.0f, 1.0f}, -{0.082779376217739398f, 0.0f, 0.0f, 1.0f}, -{0.093074220272174241f, 0.0f, 0.0f, 1.0f}, -{0.10336906432660908f, 0.0f, 0.0f, 1.0f}, -{0.11366390838104393f, 0.0f, 0.0f, 1.0f}, -{0.12395875243547878f, 0.0f, 0.0f, 1.0f}, -{0.13425359648991364f, 0.0f, 0.0f, 1.0f}, -{0.14454844054434846f, 0.0f, 0.0f, 1.0f}, -{0.15484328459878333f, 0.0f, 0.0f, 1.0f}, -{0.1651381286532182f, 0.0f, 0.0f, 1.0f}, -{0.17543297270765301f, 0.0f, 0.0f, 1.0f}, -{0.18572781676208786f, 0.0f, 0.0f, 1.0f}, -{0.1960226608165227f, 0.0f, 0.0f, 1.0f}, -{0.20631750487095757f, 0.0f, 0.0f, 1.0f}, -{0.21661234892539241f, 0.0f, 0.0f, 1.0f}, -{0.22690719297982725f, 0.0f, 0.0f, 1.0f}, -{0.2372020370342621f, 0.0f, 0.0f, 1.0f}, -{0.24749688108869694f, 0.0f, 0.0f, 1.0f}, -{0.25779172514313181f, 0.0f, 0.0f, 1.0f}, -{0.26808656919756668f, 0.0f, 0.0f, 1.0f}, -{0.2783814132520015f, 0.0f, 0.0f, 1.0f}, -{0.28867625730643637f, 0.0f, 0.0f, 1.0f}, -{0.29897110136087113f, 0.0f, 0.0f, 1.0f}, -{0.30926594541530605f, 0.0f, 0.0f, 1.0f}, -{0.31956078946974087f, 0.0f, 0.0f, 1.0f}, -{0.32985563352417568f, 0.0f, 0.0f, 1.0f}, -{0.34015047757861061f, 0.0f, 0.0f, 1.0f}, -{0.35044532163304543f, 0.0f, 0.0f, 1.0f}, -{0.36074016568748024f, 0.0f, 0.0f, 1.0f}, -{0.37103500974191517f, 0.0f, 0.0f, 1.0f}, -{0.38132985379634987f, 0.0f, 0.0f, 1.0f}, -{0.3916246978507848f, 0.0f, 0.0f, 1.0f}, -{0.40191954190521961f, 0.0f, 0.0f, 1.0f}, -{0.41221438595965454f, 0.0f, 0.0f, 1.0f}, -{0.42250923001408924f, 0.0f, 0.0f, 1.0f}, -{0.43280407406852417f, 0.0f, 0.0f, 1.0f}, -{0.4430989181229591f, 0.0f, 0.0f, 1.0f}, -{0.45339376217739391f, 0.0f, 0.0f, 1.0f}, -{0.46368860623182862f, 0.0f, 0.0f, 1.0f}, -{0.47398345028626365f, 0.0f, 0.0f, 1.0f}, -{0.48427829434069847f, 0.0f, 0.0f, 1.0f}, -{0.49457313839513328f, 0.0f, 0.0f, 1.0f}, -{0.5048679824495681f, 0.0f, 0.0f, 1.0f}, -{0.51516282650400291f, 0.0f, 0.0f, 1.0f}, -{0.52545767055843784f, 0.0f, 0.0f, 1.0f}, -{0.53575251461287277f, 0.0f, 0.0f, 1.0f}, -{0.54604735866730736f, 0.0f, 0.0f, 1.0f}, -{0.55634220272174228f, 0.0f, 0.0f, 1.0f}, -{0.56663704677617721f, 0.0f, 0.0f, 1.0f}, -{0.57693189083061203f, 0.0f, 0.0f, 1.0f}, -{0.58722673488504684f, 0.0f, 0.0f, 1.0f}, -{0.59752157893948166f, 0.0f, 0.0f, 1.0f}, -{0.60781642299391658f, 0.0f, 0.0f, 1.0f}, -{0.6181112670483514f, 0.0f, 0.0f, 1.0f}, -{0.62840611110278621f, 0.0f, 0.0f, 1.0f}, -{0.63870095515722114f, 0.0f, 0.0f, 1.0f}, -{0.64899579921165607f, 0.0f, 0.0f, 1.0f}, -{0.65929064326609077f, 0.0f, 0.0f, 1.0f}, -{0.66958548732052559f, 0.0f, 0.0f, 1.0f}, -{0.67988033137496051f, 0.0f, 0.0f, 1.0f}, -{0.69017517542939533f, 0.0f, 0.0f, 1.0f}, -{0.70047001948383025f, 0.0f, 0.0f, 1.0f}, -{0.71076486353826507f, 0.0f, 0.0f, 1.0f}, -{0.72105970759269977f, 0.0f, 0.0f, 1.0f}, -{0.7313545516471347f, 0.0f, 0.0f, 1.0f}, -{0.74164939570156962f, 0.0f, 0.0f, 1.0f}, -{0.75194423975600444f, 0.0f, 0.0f, 1.0f}, -{0.76223908381043926f, 0.0f, 0.0f, 1.0f}, -{0.77253392786487418f, 0.0f, 0.0f, 1.0f}, -{0.782828771919309f, 0.0f, 0.0f, 1.0f}, -{0.79312361597374381f, 0.0f, 0.0f, 1.0f}, -{0.80341846002817852f, 0.0f, 0.0f, 1.0f}, -{0.81371330408261355f, 0.0f, 0.0f, 1.0f}, -{0.82400814813704837f, 0.0f, 0.0f, 1.0f}, -{0.83430299219148329f, 0.0f, 0.0f, 1.0f}, -{0.84459783624591811f, 0.0f, 0.0f, 1.0f}, -{0.85489268030035281f, 0.0f, 0.0f, 1.0f}, -{0.86518752435478774f, 0.0f, 0.0f, 1.0f}, -{0.87548236840922256f, 0.0f, 0.0f, 1.0f}, -{0.88577721246365726f, 0.0f, 0.0f, 1.0f}, -{0.8960720565180923f, 0.0f, 0.0f, 1.0f}, -{0.90636690057252722f, 0.0f, 0.0f, 1.0f}, -{0.91666174462696193f, 0.0f, 0.0f, 1.0f}, -{0.92695658868139685f, 0.0f, 0.0f, 1.0f}, -{0.93725143273583167f, 0.0f, 0.0f, 1.0f}, -{0.9475462767902666f, 0.0f, 0.0f, 1.0f}, -{0.95784112084470141f, 0.0f, 0.0f, 1.0f}, -{0.96813596489913611f, 0.0f, 0.0f, 1.0f}, -{0.97843080895357104f, 0.0f, 0.0f, 1.0f}, -{0.98872565300800586f, 0.0f, 0.0f, 1.0f}, -{0.99902049706244078f, 0.0f, 0.0f, 1.0f}, -{1.0f, 0.0093146686871927731f, 0.0f, 1.0f}, -{1.0f, 0.019608769606337603f, 0.0f, 1.0f}, -{1.0f, 0.029902870525482433f, 0.0f, 1.0f}, -{1.0f, 0.040196971444627264f, 0.0f, 1.0f}, -{1.0f, 0.050491072363771948f, 0.0f, 1.0f}, -{1.0f, 0.060785173282916924f, 0.0f, 1.0f}, -{1.0f, 0.071079274202061754f, 0.0f, 1.0f}, -{1.0f, 0.081373375121206584f, 0.0f, 1.0f}, -{1.0f, 0.091667476040351414f, 0.0f, 1.0f}, -{1.0f, 0.10196157695949624f, 0.0f, 1.0f}, -{1.0f, 0.11225567787864107f, 0.0f, 1.0f}, -{1.0f, 0.12254977879778592f, 0.0f, 1.0f}, -{1.0f, 0.1328438797169306f, 0.0f, 1.0f}, -{1.0f, 0.14313798063607558f, 0.0f, 1.0f}, -{1.0f, 0.1534320815552204f, 0.0f, 1.0f}, -{1.0f, 0.16372618247436524f, 0.0f, 1.0f}, -{1.0f, 0.17402028339351006f, 0.0f, 1.0f}, -{1.0f, 0.1843143843126549f, 0.0f, 1.0f}, -{1.0f, 0.19460848523179972f, 0.0f, 1.0f}, -{1.0f, 0.20490258615094456f, 0.0f, 1.0f}, -{1.0f, 0.21519668707008924f, 0.0f, 1.0f}, -{1.0f, 0.22549078798923422f, 0.0f, 1.0f}, -{1.0f, 0.23578488890837906f, 0.0f, 1.0f}, -{1.0f, 0.24607898982752388f, 0.0f, 1.0f}, -{1.0f, 0.2563730907466687f, 0.0f, 1.0f}, -{1.0f, 0.26666719166581354f, 0.0f, 1.0f}, -{1.0f, 0.27696129258495839f, 0.0f, 1.0f}, -{1.0f, 0.28725539350410323f, 0.0f, 1.0f}, -{1.0f, 0.29754949442324791f, 0.0f, 1.0f}, -{1.0f, 0.30784359534239286f, 0.0f, 1.0f}, -{1.0f, 0.31813769626153771f, 0.0f, 1.0f}, -{1.0f, 0.32843179718068255f, 0.0f, 1.0f}, -{1.0f, 0.33872589809982734f, 0.0f, 1.0f}, -{1.0f, 0.34901999901897218f, 0.0f, 1.0f}, -{1.0f, 0.35931409993811703f, 0.0f, 1.0f}, -{1.0f, 0.36960820085726187f, 0.0f, 1.0f}, -{1.0f, 0.37990230177640666f, 0.0f, 1.0f}, -{1.0f, 0.3901964026955515f, 0.0f, 1.0f}, -{1.0f, 0.40049050361469607f, 0.0f, 1.0f}, -{1.0f, 0.41078460453384119f, 0.0f, 1.0f}, -{1.0f, 0.42107870545298598f, 0.0f, 1.0f}, -{1.0f, 0.43137280637213082f, 0.0f, 1.0f}, -{1.0f, 0.44166690729127567f, 0.0f, 1.0f}, -{1.0f, 0.45196100821042051f, 0.0f, 1.0f}, -{1.0f, 0.46225510912956536f, 0.0f, 1.0f}, -{1.0f, 0.47254921004871014f, 0.0f, 1.0f}, -{1.0f, 0.48284331096785499f, 0.0f, 1.0f}, -{1.0f, 0.49313741188699983f, 0.0f, 1.0f}, -{1.0f, 0.50343151280614462f, 0.0f, 1.0f}, -{1.0f, 0.51372561372528946f, 0.0f, 1.0f}, -{1.0f, 0.52401971464443431f, 0.0f, 1.0f}, -{1.0f, 0.53431381556357915f, 0.0f, 1.0f}, -{1.0f, 0.544607916482724f, 0.0f, 1.0f}, -{1.0f, 0.55490201740186884f, 0.0f, 1.0f}, -{1.0f, 0.56519611832101335f, 0.0f, 1.0f}, -{1.0f, 0.57549021924015842f, 0.0f, 1.0f}, -{1.0f, 0.58578432015930326f, 0.0f, 1.0f}, -{1.0f, 0.59607842107844811f, 0.0f, 1.0f}, -{1.0f, 0.60637252199759295f, 0.0f, 1.0f}, -{1.0f, 0.61666662291673779f, 0.0f, 1.0f}, -{1.0f, 0.62696072383588264f, 0.0f, 1.0f}, -{1.0f, 0.63725482475502748f, 0.0f, 1.0f}, -{1.0f, 0.64754892567417233f, 0.0f, 1.0f}, -{1.0f, 0.65784302659331717f, 0.0f, 1.0f}, -{1.0f, 0.6681371275124619f, 0.0f, 1.0f}, -{1.0f, 0.67843122843160675f, 0.0f, 1.0f}, -{1.0f, 0.68872532935075159f, 0.0f, 1.0f}, -{1.0f, 0.69901943026989644f, 0.0f, 1.0f}, -{1.0f, 0.70931353118904128f, 0.0f, 1.0f}, -{1.0f, 0.71960763210818612f, 0.0f, 1.0f}, -{1.0f, 0.72990173302733063f, 0.0f, 1.0f}, -{1.0f, 0.74019583394647581f, 0.0f, 1.0f}, -{1.0f, 0.75048993486562054f, 0.0f, 1.0f}, -{1.0f, 0.76078403578476539f, 0.0f, 1.0f}, -{1.0f, 0.77107813670391023f, 0.0f, 1.0f}, -{1.0f, 0.78137223762305508f, 0.0f, 1.0f}, -{1.0f, 0.79166633854219992f, 0.0f, 1.0f}, -{1.0f, 0.80196043946134477f, 0.0f, 1.0f}, -{1.0f, 0.81225454038048961f, 0.0f, 1.0f}, -{1.0f, 0.82254864129963445f, 0.0f, 1.0f}, -{1.0f, 0.83284274221877919f, 0.0f, 1.0f}, -{1.0f, 0.84313684313792403f, 0.0f, 1.0f}, -{1.0f, 0.85343094405706887f, 0.0f, 1.0f}, -{1.0f, 0.86372504497621372f, 0.0f, 1.0f}, -{1.0f, 0.87401914589535856f, 0.0f, 1.0f}, -{1.0f, 0.88431324681450341f, 0.0f, 1.0f}, -{1.0f, 0.89460734773364792f, 0.0f, 1.0f}, -{1.0f, 0.90490144865279309f, 0.0f, 1.0f}, -{1.0f, 0.91519554957193794f, 0.0f, 1.0f}, -{1.0f, 0.92548965049108267f, 0.0f, 1.0f}, -{1.0f, 0.93578375141022752f, 0.0f, 1.0f}, -{1.0f, 0.94607785232937236f, 0.0f, 1.0f}, -{1.0f, 0.9563719532485172f, 0.0f, 1.0f}, -{1.0f, 0.96666605416766205f, 0.0f, 1.0f}, -{1.0f, 0.97696015508680689f, 0.0f, 1.0f}, -{1.0f, 0.98725425600595174f, 0.0f, 1.0f}, -{1.0f, 0.99754835692509658f, 0.0f, 1.0f}, -{1.0f, 1.0f, 0.011763717646070686f, 1.0f}, -{1.0f, 1.0f, 0.027204909557850831f, 1.0f}, -{1.0f, 1.0f, 0.042646101469630979f, 1.0f}, -{1.0f, 1.0f, 0.058087293381411123f, 1.0f}, -{1.0f, 1.0f, 0.073528485293191267f, 1.0f}, -{1.0f, 1.0f, 0.088969677204970982f, 1.0f}, -{1.0f, 1.0f, 0.10441086911675156f, 1.0f}, -{1.0f, 1.0f, 0.1198520610285317f, 1.0f}, -{1.0f, 1.0f, 0.13529325294031186f, 1.0f}, -{1.0f, 1.0f, 0.150734444852092f, 1.0f}, -{1.0f, 1.0f, 0.16617563676387215f, 1.0f}, -{1.0f, 1.0f, 0.18161682867565229f, 1.0f}, -{1.0f, 1.0f, 0.19705802058743244f, 1.0f}, -{1.0f, 1.0f, 0.21249921249921258f, 1.0f}, -{1.0f, 1.0f, 0.22794040441099273f, 1.0f}, -{1.0f, 1.0f, 0.24338159632277287f, 1.0f}, -{1.0f, 1.0f, 0.25882278823455301f, 1.0f}, -{1.0f, 1.0f, 0.27426398014633319f, 1.0f}, -{1.0f, 1.0f, 0.2897051720581133f, 1.0f}, -{1.0f, 1.0f, 0.30514636396989347f, 1.0f}, -{1.0f, 1.0f, 0.32058755588167359f, 1.0f}, -{1.0f, 1.0f, 0.33602874779345332f, 1.0f}, -{1.0f, 1.0f, 0.35146993970523388f, 1.0f}, -{1.0f, 1.0f, 0.36691113161701405f, 1.0f}, -{1.0f, 1.0f, 0.38235232352879417f, 1.0f}, -{1.0f, 1.0f, 0.39779351544057434f, 1.0f}, -{1.0f, 1.0f, 0.41323470735235446f, 1.0f}, -{1.0f, 1.0f, 0.42867589926413463f, 1.0f}, -{1.0f, 1.0f, 0.44411709117591475f, 1.0f}, -{1.0f, 1.0f, 0.45955828308769492f, 1.0f}, -{1.0f, 1.0f, 0.47499947499947504f, 1.0f}, -{1.0f, 1.0f, 0.49044066691125521f, 1.0f}, -{1.0f, 1.0f, 0.50588185882303538f, 1.0f}, -{1.0f, 1.0f, 0.52132305073481544f, 1.0f}, -{1.0f, 1.0f, 0.53676424264659561f, 1.0f}, -{1.0f, 1.0f, 0.55220543455837579f, 1.0f}, -{1.0f, 1.0f, 0.56764662647015596f, 1.0f}, -{1.0f, 1.0f, 0.58308781838193569f, 1.0f}, -{1.0f, 1.0f, 0.59852901029371619f, 1.0f}, -{1.0f, 1.0f, 0.61397020220549636f, 1.0f}, -{1.0f, 1.0f, 0.62941139411727653f, 1.0f}, -{1.0f, 1.0f, 0.64485258602905671f, 1.0f}, -{1.0f, 1.0f, 0.66029377794083677f, 1.0f}, -{1.0f, 1.0f, 0.67573496985261694f, 1.0f}, -{1.0f, 1.0f, 0.69117616176439711f, 1.0f}, -{1.0f, 1.0f, 0.70661735367617728f, 1.0f}, -{1.0f, 1.0f, 0.72205854558795735f, 1.0f}, -{1.0f, 1.0f, 0.73749973749973752f, 1.0f}, -{1.0f, 1.0f, 0.75294092941151769f, 1.0f}, -{1.0f, 1.0f, 0.76838212132329786f, 1.0f}, -{1.0f, 1.0f, 0.78382331323507792f, 1.0f}, -{1.0f, 1.0f, 0.7992645051468581f, 1.0f}, -{1.0f, 1.0f, 0.81470569705863827f, 1.0f}, -{1.0f, 1.0f, 0.830146888970418f, 1.0f}, -{1.0f, 1.0f, 0.8455880808821985f, 1.0f}, -{1.0f, 1.0f, 0.86102927279397867f, 1.0f}, -{1.0f, 1.0f, 0.87647046470575884f, 1.0f}, -{1.0f, 1.0f, 0.89191165661753902f, 1.0f}, -{1.0f, 1.0f, 0.90735284852931908f, 1.0f}, -{1.0f, 1.0f, 0.92279404044109925f, 1.0f}, -{1.0f, 1.0f, 0.93823523235287942f, 1.0f}, -{1.0f, 1.0f, 0.95367642426465959f, 1.0f}, -{1.0f, 1.0f, 0.96911761617643966f, 1.0f}, -{1.0f, 1.0f, 0.98455880808821983f, 1.0f}, -{1.0f, 1.0f, 1.0f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential2/hot.txt b/extern/tfn/colormaps/sequential2/hot.txt deleted file mode 100644 index 2d2b8f6..0000000 --- a/extern/tfn/colormaps/sequential2/hot.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.041599999999999998, 0.0, 0.0, 1.0) -(0.051894844054434848, 0.0, 0.0, 1.0) -(0.062189688108869698, 0.0, 0.0, 1.0) -(0.072484532163304541, 0.0, 0.0, 1.0) -(0.082779376217739398, 0.0, 0.0, 1.0) -(0.093074220272174241, 0.0, 0.0, 1.0) -(0.10336906432660908, 0.0, 0.0, 1.0) -(0.11366390838104393, 0.0, 0.0, 1.0) -(0.12395875243547878, 0.0, 0.0, 1.0) -(0.13425359648991364, 0.0, 0.0, 1.0) -(0.14454844054434846, 0.0, 0.0, 1.0) -(0.15484328459878333, 0.0, 0.0, 1.0) -(0.1651381286532182, 0.0, 0.0, 1.0) -(0.17543297270765301, 0.0, 0.0, 1.0) -(0.18572781676208786, 0.0, 0.0, 1.0) -(0.1960226608165227, 0.0, 0.0, 1.0) -(0.20631750487095757, 0.0, 0.0, 1.0) -(0.21661234892539241, 0.0, 0.0, 1.0) -(0.22690719297982725, 0.0, 0.0, 1.0) -(0.2372020370342621, 0.0, 0.0, 1.0) -(0.24749688108869694, 0.0, 0.0, 1.0) -(0.25779172514313181, 0.0, 0.0, 1.0) -(0.26808656919756668, 0.0, 0.0, 1.0) -(0.2783814132520015, 0.0, 0.0, 1.0) -(0.28867625730643637, 0.0, 0.0, 1.0) -(0.29897110136087113, 0.0, 0.0, 1.0) -(0.30926594541530605, 0.0, 0.0, 1.0) -(0.31956078946974087, 0.0, 0.0, 1.0) -(0.32985563352417568, 0.0, 0.0, 1.0) -(0.34015047757861061, 0.0, 0.0, 1.0) -(0.35044532163304543, 0.0, 0.0, 1.0) -(0.36074016568748024, 0.0, 0.0, 1.0) -(0.37103500974191517, 0.0, 0.0, 1.0) -(0.38132985379634987, 0.0, 0.0, 1.0) -(0.3916246978507848, 0.0, 0.0, 1.0) -(0.40191954190521961, 0.0, 0.0, 1.0) -(0.41221438595965454, 0.0, 0.0, 1.0) -(0.42250923001408924, 0.0, 0.0, 1.0) -(0.43280407406852417, 0.0, 0.0, 1.0) -(0.4430989181229591, 0.0, 0.0, 1.0) -(0.45339376217739391, 0.0, 0.0, 1.0) -(0.46368860623182862, 0.0, 0.0, 1.0) -(0.47398345028626365, 0.0, 0.0, 1.0) -(0.48427829434069847, 0.0, 0.0, 1.0) -(0.49457313839513328, 0.0, 0.0, 1.0) -(0.5048679824495681, 0.0, 0.0, 1.0) -(0.51516282650400291, 0.0, 0.0, 1.0) -(0.52545767055843784, 0.0, 0.0, 1.0) -(0.53575251461287277, 0.0, 0.0, 1.0) -(0.54604735866730736, 0.0, 0.0, 1.0) -(0.55634220272174228, 0.0, 0.0, 1.0) -(0.56663704677617721, 0.0, 0.0, 1.0) -(0.57693189083061203, 0.0, 0.0, 1.0) -(0.58722673488504684, 0.0, 0.0, 1.0) -(0.59752157893948166, 0.0, 0.0, 1.0) -(0.60781642299391658, 0.0, 0.0, 1.0) -(0.6181112670483514, 0.0, 0.0, 1.0) -(0.62840611110278621, 0.0, 0.0, 1.0) -(0.63870095515722114, 0.0, 0.0, 1.0) -(0.64899579921165607, 0.0, 0.0, 1.0) -(0.65929064326609077, 0.0, 0.0, 1.0) -(0.66958548732052559, 0.0, 0.0, 1.0) -(0.67988033137496051, 0.0, 0.0, 1.0) -(0.69017517542939533, 0.0, 0.0, 1.0) -(0.70047001948383025, 0.0, 0.0, 1.0) -(0.71076486353826507, 0.0, 0.0, 1.0) -(0.72105970759269977, 0.0, 0.0, 1.0) -(0.7313545516471347, 0.0, 0.0, 1.0) -(0.74164939570156962, 0.0, 0.0, 1.0) -(0.75194423975600444, 0.0, 0.0, 1.0) -(0.76223908381043926, 0.0, 0.0, 1.0) -(0.77253392786487418, 0.0, 0.0, 1.0) -(0.782828771919309, 0.0, 0.0, 1.0) -(0.79312361597374381, 0.0, 0.0, 1.0) -(0.80341846002817852, 0.0, 0.0, 1.0) -(0.81371330408261355, 0.0, 0.0, 1.0) -(0.82400814813704837, 0.0, 0.0, 1.0) -(0.83430299219148329, 0.0, 0.0, 1.0) -(0.84459783624591811, 0.0, 0.0, 1.0) -(0.85489268030035281, 0.0, 0.0, 1.0) -(0.86518752435478774, 0.0, 0.0, 1.0) -(0.87548236840922256, 0.0, 0.0, 1.0) -(0.88577721246365726, 0.0, 0.0, 1.0) -(0.8960720565180923, 0.0, 0.0, 1.0) -(0.90636690057252722, 0.0, 0.0, 1.0) -(0.91666174462696193, 0.0, 0.0, 1.0) -(0.92695658868139685, 0.0, 0.0, 1.0) -(0.93725143273583167, 0.0, 0.0, 1.0) -(0.9475462767902666, 0.0, 0.0, 1.0) -(0.95784112084470141, 0.0, 0.0, 1.0) -(0.96813596489913611, 0.0, 0.0, 1.0) -(0.97843080895357104, 0.0, 0.0, 1.0) -(0.98872565300800586, 0.0, 0.0, 1.0) -(0.99902049706244078, 0.0, 0.0, 1.0) -(1.0, 0.0093146686871927731, 0.0, 1.0) -(1.0, 0.019608769606337603, 0.0, 1.0) -(1.0, 0.029902870525482433, 0.0, 1.0) -(1.0, 0.040196971444627264, 0.0, 1.0) -(1.0, 0.050491072363771948, 0.0, 1.0) -(1.0, 0.060785173282916924, 0.0, 1.0) -(1.0, 0.071079274202061754, 0.0, 1.0) -(1.0, 0.081373375121206584, 0.0, 1.0) -(1.0, 0.091667476040351414, 0.0, 1.0) -(1.0, 0.10196157695949624, 0.0, 1.0) -(1.0, 0.11225567787864107, 0.0, 1.0) -(1.0, 0.12254977879778592, 0.0, 1.0) -(1.0, 0.1328438797169306, 0.0, 1.0) -(1.0, 0.14313798063607558, 0.0, 1.0) -(1.0, 0.1534320815552204, 0.0, 1.0) -(1.0, 0.16372618247436524, 0.0, 1.0) -(1.0, 0.17402028339351006, 0.0, 1.0) -(1.0, 0.1843143843126549, 0.0, 1.0) -(1.0, 0.19460848523179972, 0.0, 1.0) -(1.0, 0.20490258615094456, 0.0, 1.0) -(1.0, 0.21519668707008924, 0.0, 1.0) -(1.0, 0.22549078798923422, 0.0, 1.0) -(1.0, 0.23578488890837906, 0.0, 1.0) -(1.0, 0.24607898982752388, 0.0, 1.0) -(1.0, 0.2563730907466687, 0.0, 1.0) -(1.0, 0.26666719166581354, 0.0, 1.0) -(1.0, 0.27696129258495839, 0.0, 1.0) -(1.0, 0.28725539350410323, 0.0, 1.0) -(1.0, 0.29754949442324791, 0.0, 1.0) -(1.0, 0.30784359534239286, 0.0, 1.0) -(1.0, 0.31813769626153771, 0.0, 1.0) -(1.0, 0.32843179718068255, 0.0, 1.0) -(1.0, 0.33872589809982734, 0.0, 1.0) -(1.0, 0.34901999901897218, 0.0, 1.0) -(1.0, 0.35931409993811703, 0.0, 1.0) -(1.0, 0.36960820085726187, 0.0, 1.0) -(1.0, 0.37990230177640666, 0.0, 1.0) -(1.0, 0.3901964026955515, 0.0, 1.0) -(1.0, 0.40049050361469607, 0.0, 1.0) -(1.0, 0.41078460453384119, 0.0, 1.0) -(1.0, 0.42107870545298598, 0.0, 1.0) -(1.0, 0.43137280637213082, 0.0, 1.0) -(1.0, 0.44166690729127567, 0.0, 1.0) -(1.0, 0.45196100821042051, 0.0, 1.0) -(1.0, 0.46225510912956536, 0.0, 1.0) -(1.0, 0.47254921004871014, 0.0, 1.0) -(1.0, 0.48284331096785499, 0.0, 1.0) -(1.0, 0.49313741188699983, 0.0, 1.0) -(1.0, 0.50343151280614462, 0.0, 1.0) -(1.0, 0.51372561372528946, 0.0, 1.0) -(1.0, 0.52401971464443431, 0.0, 1.0) -(1.0, 0.53431381556357915, 0.0, 1.0) -(1.0, 0.544607916482724, 0.0, 1.0) -(1.0, 0.55490201740186884, 0.0, 1.0) -(1.0, 0.56519611832101335, 0.0, 1.0) -(1.0, 0.57549021924015842, 0.0, 1.0) -(1.0, 0.58578432015930326, 0.0, 1.0) -(1.0, 0.59607842107844811, 0.0, 1.0) -(1.0, 0.60637252199759295, 0.0, 1.0) -(1.0, 0.61666662291673779, 0.0, 1.0) -(1.0, 0.62696072383588264, 0.0, 1.0) -(1.0, 0.63725482475502748, 0.0, 1.0) -(1.0, 0.64754892567417233, 0.0, 1.0) -(1.0, 0.65784302659331717, 0.0, 1.0) -(1.0, 0.6681371275124619, 0.0, 1.0) -(1.0, 0.67843122843160675, 0.0, 1.0) -(1.0, 0.68872532935075159, 0.0, 1.0) -(1.0, 0.69901943026989644, 0.0, 1.0) -(1.0, 0.70931353118904128, 0.0, 1.0) -(1.0, 0.71960763210818612, 0.0, 1.0) -(1.0, 0.72990173302733063, 0.0, 1.0) -(1.0, 0.74019583394647581, 0.0, 1.0) -(1.0, 0.75048993486562054, 0.0, 1.0) -(1.0, 0.76078403578476539, 0.0, 1.0) -(1.0, 0.77107813670391023, 0.0, 1.0) -(1.0, 0.78137223762305508, 0.0, 1.0) -(1.0, 0.79166633854219992, 0.0, 1.0) -(1.0, 0.80196043946134477, 0.0, 1.0) -(1.0, 0.81225454038048961, 0.0, 1.0) -(1.0, 0.82254864129963445, 0.0, 1.0) -(1.0, 0.83284274221877919, 0.0, 1.0) -(1.0, 0.84313684313792403, 0.0, 1.0) -(1.0, 0.85343094405706887, 0.0, 1.0) -(1.0, 0.86372504497621372, 0.0, 1.0) -(1.0, 0.87401914589535856, 0.0, 1.0) -(1.0, 0.88431324681450341, 0.0, 1.0) -(1.0, 0.89460734773364792, 0.0, 1.0) -(1.0, 0.90490144865279309, 0.0, 1.0) -(1.0, 0.91519554957193794, 0.0, 1.0) -(1.0, 0.92548965049108267, 0.0, 1.0) -(1.0, 0.93578375141022752, 0.0, 1.0) -(1.0, 0.94607785232937236, 0.0, 1.0) -(1.0, 0.9563719532485172, 0.0, 1.0) -(1.0, 0.96666605416766205, 0.0, 1.0) -(1.0, 0.97696015508680689, 0.0, 1.0) -(1.0, 0.98725425600595174, 0.0, 1.0) -(1.0, 0.99754835692509658, 0.0, 1.0) -(1.0, 1.0, 0.011763717646070686, 1.0) -(1.0, 1.0, 0.027204909557850831, 1.0) -(1.0, 1.0, 0.042646101469630979, 1.0) -(1.0, 1.0, 0.058087293381411123, 1.0) -(1.0, 1.0, 0.073528485293191267, 1.0) -(1.0, 1.0, 0.088969677204970982, 1.0) -(1.0, 1.0, 0.10441086911675156, 1.0) -(1.0, 1.0, 0.1198520610285317, 1.0) -(1.0, 1.0, 0.13529325294031186, 1.0) -(1.0, 1.0, 0.150734444852092, 1.0) -(1.0, 1.0, 0.16617563676387215, 1.0) -(1.0, 1.0, 0.18161682867565229, 1.0) -(1.0, 1.0, 0.19705802058743244, 1.0) -(1.0, 1.0, 0.21249921249921258, 1.0) -(1.0, 1.0, 0.22794040441099273, 1.0) -(1.0, 1.0, 0.24338159632277287, 1.0) -(1.0, 1.0, 0.25882278823455301, 1.0) -(1.0, 1.0, 0.27426398014633319, 1.0) -(1.0, 1.0, 0.2897051720581133, 1.0) -(1.0, 1.0, 0.30514636396989347, 1.0) -(1.0, 1.0, 0.32058755588167359, 1.0) -(1.0, 1.0, 0.33602874779345332, 1.0) -(1.0, 1.0, 0.35146993970523388, 1.0) -(1.0, 1.0, 0.36691113161701405, 1.0) -(1.0, 1.0, 0.38235232352879417, 1.0) -(1.0, 1.0, 0.39779351544057434, 1.0) -(1.0, 1.0, 0.41323470735235446, 1.0) -(1.0, 1.0, 0.42867589926413463, 1.0) -(1.0, 1.0, 0.44411709117591475, 1.0) -(1.0, 1.0, 0.45955828308769492, 1.0) -(1.0, 1.0, 0.47499947499947504, 1.0) -(1.0, 1.0, 0.49044066691125521, 1.0) -(1.0, 1.0, 0.50588185882303538, 1.0) -(1.0, 1.0, 0.52132305073481544, 1.0) -(1.0, 1.0, 0.53676424264659561, 1.0) -(1.0, 1.0, 0.55220543455837579, 1.0) -(1.0, 1.0, 0.56764662647015596, 1.0) -(1.0, 1.0, 0.58308781838193569, 1.0) -(1.0, 1.0, 0.59852901029371619, 1.0) -(1.0, 1.0, 0.61397020220549636, 1.0) -(1.0, 1.0, 0.62941139411727653, 1.0) -(1.0, 1.0, 0.64485258602905671, 1.0) -(1.0, 1.0, 0.66029377794083677, 1.0) -(1.0, 1.0, 0.67573496985261694, 1.0) -(1.0, 1.0, 0.69117616176439711, 1.0) -(1.0, 1.0, 0.70661735367617728, 1.0) -(1.0, 1.0, 0.72205854558795735, 1.0) -(1.0, 1.0, 0.73749973749973752, 1.0) -(1.0, 1.0, 0.75294092941151769, 1.0) -(1.0, 1.0, 0.76838212132329786, 1.0) -(1.0, 1.0, 0.78382331323507792, 1.0) -(1.0, 1.0, 0.7992645051468581, 1.0) -(1.0, 1.0, 0.81470569705863827, 1.0) -(1.0, 1.0, 0.830146888970418, 1.0) -(1.0, 1.0, 0.8455880808821985, 1.0) -(1.0, 1.0, 0.86102927279397867, 1.0) -(1.0, 1.0, 0.87647046470575884, 1.0) -(1.0, 1.0, 0.89191165661753902, 1.0) -(1.0, 1.0, 0.90735284852931908, 1.0) -(1.0, 1.0, 0.92279404044109925, 1.0) -(1.0, 1.0, 0.93823523235287942, 1.0) -(1.0, 1.0, 0.95367642426465959, 1.0) -(1.0, 1.0, 0.96911761617643966, 1.0) -(1.0, 1.0, 0.98455880808821983, 1.0) -(1.0, 1.0, 1.0, 1.0) diff --git a/extern/tfn/colormaps/sequential2/pink.cpp b/extern/tfn/colormaps/sequential2/pink.cpp deleted file mode 100644 index 4fc14a7..0000000 --- a/extern/tfn/colormaps/sequential2/pink.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential2_pink; -} -const std::vector colormap::data_sequential2_pink = /* NOLINT(cert-err58-cpp) */ -{ -{0.1178f, 0.0f, 0.0f, 1.0f}, -{0.13708468987292516f, 0.025414719532366591f, 0.025414719532366591f, 1.0f}, -{0.15636937974585033f, 0.050829439064733181f, 0.050829439064733181f, 1.0f}, -{0.1756540696187755f, 0.076244158597099765f, 0.076244158597099765f, 1.0f}, -{0.19493875949170067f, 0.10165887812946636f, 0.10165887812946636f, 1.0f}, -{0.20875212652265593f, 0.11289493498887616f, 0.11289493498887616f, 1.0f}, -{0.22229195182718714f, 0.1234221219866514f, 0.1234221219866514f, 1.0f}, -{0.23583177713171832f, 0.13394930898442661f, 0.13394930898442661f, 1.0f}, -{0.24937160243624951f, 0.14447649598220186f, 0.14447649598220186f, 1.0f}, -{0.26067678198272315f, 0.15278736681601388f, 0.15278736681601388f, 1.0f}, -{0.27174675775858131f, 0.1608649631289043f, 0.1608649631289043f, 1.0f}, -{0.28281673353443942f, 0.16894255944179473f, 0.16894255944179473f, 1.0f}, -{0.29388670931029753f, 0.17702015575468516f, 0.17702015575468516f, 1.0f}, -{0.30369645420821889f, 0.18401117088211205f, 0.18401117088211205f, 1.0f}, -{0.31329618145500499f, 0.19082110710381298f, 0.19082110710381298f, 1.0f}, -{0.32289590870179102f, 0.1976310433255139f, 0.1976310433255139f, 1.0f}, -{0.33249563594857712f, 0.20444097954721482f, 0.20444097954721482f, 1.0f}, -{0.3412817461097461f, 0.21059490199290198f, 0.21059490199290198f, 1.0f}, -{0.3498764370573782f, 0.2165944844630727f, 0.2165944844630727f, 1.0f}, -{0.35847112800501035f, 0.22259406693324341f, 0.22259406693324341f, 1.0f}, -{0.36706581895264245f, 0.22859364940341409f, 0.22859364940341409f, 1.0f}, -{0.37509428252934135f, 0.23415463154969035f, 0.23415463154969035f, 1.0f}, -{0.3829458197926433f, 0.23957856638538991f, 0.23957856638538991f, 1.0f}, -{0.39079735705594532f, 0.24500250122108944f, 0.24500250122108944f, 1.0f}, -{0.39864889431924727f, 0.25042643605678894f, 0.25042643605678894f, 1.0f}, -{0.4060872994763583f, 0.25553906587953645f, 0.25553906587953645f, 1.0f}, -{0.41336047145541266f, 0.2605271885147179f, 0.2605271885147179f, 1.0f}, -{0.42063364343446696f, 0.2655153111498994f, 0.2655153111498994f, 1.0f}, -{0.42790681541352132f, 0.27050343378508085f, 0.27050343378508085f, 1.0f}, -{0.43486900915971505f, 0.275261122867417f, 0.275261122867417f, 1.0f}, -{0.44167573361349832f, 0.27990360986284518f, 0.27990360986284518f, 1.0f}, -{0.4484824580672816f, 0.28454609685827337f, 0.28454609685827337f, 1.0f}, -{0.45528918252106487f, 0.2891885838537015f, 0.2891885838537015f, 1.0f}, -{0.4618563883249765f, 0.29365655566426152f, 0.29365655566426152f, 1.0f}, -{0.46827621827421828f, 0.29801714826014825f, 0.29801714826014825f, 1.0f}, -{0.47469604822345995f, 0.30237774085603497f, 0.30237774085603497f, 1.0f}, -{0.48111587817270168f, 0.3067383334519217f, 0.3067383334519217f, 1.0f}, -{0.48734835481511946f, 0.31096381141734081f, 0.31096381141734081f, 1.0f}, -{0.49344033737769027f, 0.31508796848267434f, 0.31508796848267434f, 1.0f}, -{0.49953231994026109f, 0.31921212554800787f, 0.31921212554800787f, 1.0f}, -{0.50562430250283186f, 0.32333628261334141f, 0.32333628261334141f, 1.0f}, -{0.51156861468420289f, 0.3273549608349608f, 0.3273549608349608f, 1.0f}, -{0.5173787028472322f, 0.33127776475776471f, 0.33127776475776471f, 1.0f}, -{0.52318879101026161f, 0.33520056868056863f, 0.33520056868056863f, 1.0f}, -{0.52899887917329091f, 0.33912337260337255f, 0.33912337260337255f, 1.0f}, -{0.53469177979254445f, 0.3429628745372274f, 0.3429628745372274f, 1.0f}, -{0.5402557971212677f, 0.34671076063805473f, 0.34671076063805473f, 1.0f}, -{0.54581981444999095f, 0.350458646738882f, 0.350458646738882f, 1.0f}, -{0.55138383177871408f, 0.35420653283970926f, 0.35420653283970926f, 1.0f}, -{0.55685466198366196f, 0.3578888702705173f, 0.3578888702705173f, 1.0f}, -{0.56220126733026732f, 0.36148382680665031f, 0.36148382680665031f, 1.0f}, -{0.56754787267687268f, 0.36507878334278332f, 0.36507878334278332f, 1.0f}, -{0.57289447802347804f, 0.36867373987891633f, 0.36867373987891633f, 1.0f}, -{0.57816728486899072f, 0.37221692450739507f, 0.37221692450739507f, 1.0f}, -{0.58332019590425477f, 0.37567599855470446f, 0.37567599855470446f, 1.0f}, -{0.58847310693951871f, 0.37913507260201379f, 0.37913507260201379f, 1.0f}, -{0.59362601797478265f, 0.38259414664932312f, 0.38259414664932312f, 1.0f}, -{0.5987208602584484f, 0.38601277848807258f, 0.38601277848807258f, 1.0f}, -{0.60369959464894762f, 0.38935054653172302f, 0.38935054653172302f, 1.0f}, -{0.60867832903944663f, 0.3926883145753734f, 0.3926883145753734f, 1.0f}, -{0.61365706342994575f, 0.39602608261902378f, 0.39602608261902378f, 1.0f}, -{0.61859089411789414f, 0.39933250279485571f, 0.39933250279485571f, 1.0f}, -{0.6234124989394989f, 0.40256057661116484f, 0.40256057661116484f, 1.0f}, -{0.62823410376110378f, 0.40578865042747392f, 0.40578865042747392f, 1.0f}, -{0.63305570858270854f, 0.40901672424378305f, 0.40901672424378305f, 1.0f}, -{0.63784306876395103f, 0.41222108570602689f, 0.41222108570602689f, 1.0f}, -{0.64252088520647332f, 0.41534959471688876f, 0.41534959471688876f, 1.0f}, -{0.64719870164899573f, 0.41847810372775079f, 0.41847810372775079f, 1.0f}, -{0.65187651809151803f, 0.42160661273861272f, 0.42160661273861272f, 1.0f}, -{0.656529337246749f, 0.42471789198083315f, 0.42471789198083315f, 1.0f}, -{0.66107596532278889f, 0.42775597737185972f, 0.42775597737185972f, 1.0f}, -{0.66562259339882868f, 0.43079406276288629f, 0.43079406276288629f, 1.0f}, -{0.67016922147486857f, 0.43383214815391286f, 0.43383214815391286f, 1.0f}, -{0.67469858190811138f, 0.43685829803723919f, 0.43685829803723919f, 1.0f}, -{0.67912439809863334f, 0.43981287746240683f, 0.43981287746240683f, 1.0f}, -{0.68355021428915552f, 0.44276745688757452f, 0.44276745688757452f, 1.0f}, -{0.68797603047967759f, 0.44572203631274215f, 0.44572203631274215f, 1.0f}, -{0.69239117922900284f, 0.44866931572296276f, 0.44866931572296276f, 1.0f}, -{0.69670507766054823f, 0.451547306836248f, 0.451547306836248f, 1.0f}, -{0.70101897609209374f, 0.45442529794953324f, 0.45442529794953324f, 1.0f}, -{0.70533287452363924f, 0.45730328906281847f, 0.45730328906281847f, 1.0f}, -{0.70964183515848223f, 0.46017788617741556f, 0.46017788617741556f, 1.0f}, -{0.71385221583945102f, 0.46298472427837128f, 0.46298472427837128f, 1.0f}, -{0.71806259652042004f, 0.46579156237932706f, 0.46579156237932706f, 1.0f}, -{0.72227297720138894f, 0.46859840048028284f, 0.46859840048028284f, 1.0f}, -{0.72648334967134964f, 0.47140523295323294f, 0.47140523295323294f, 1.0f}, -{0.73059713025571849f, 0.47414585922327102f, 0.47414585922327102f, 1.0f}, -{0.73471091084008722f, 0.47688648549330903f, 0.47688648549330903f, 1.0f}, -{0.73882469142445606f, 0.47962711176334705f, 0.47962711176334705f, 1.0f}, -{0.7429384720088249f, 0.48236773803338506f, 0.48236773803338506f, 1.0f}, -{0.74696659744071492f, 0.48504977053153514f, 0.48504977053153514f, 1.0f}, -{0.7509904485233897f, 0.48772887909299673f, 0.48772887909299673f, 1.0f}, -{0.75501429960606425f, 0.49040798765445826f, 0.49040798765445826f, 1.0f}, -{0.75903815068873892f, 0.49308709621591973f, 0.49308709621591973f, 1.0f}, -{0.76097133752592572f, 0.49875353864312688f, 0.49571411701335227f, 1.0f}, -{0.76268469218045687f, 0.50473409756486221f, 0.49833566081136665f, 1.0f}, -{0.76439804683498802f, 0.51071465648659764f, 0.50095720460938109f, 1.0f}, -{0.76611140148951917f, 0.51669521540833308f, 0.50357874840739547f, 1.0f}, -{0.76781162523115465f, 0.52244661872114806f, 0.50615369864352211f, 1.0f}, -{0.7695096622233093f, 0.52815985972850676f, 0.50872088944600713f, 1.0f}, -{0.77120769921546395f, 0.53387310073586547f, 0.51128808024849204f, 1.0f}, -{0.7729057362076186f, 0.53958634174322417f, 0.51385527105097695f, 1.0f}, -{0.77459177168777171f, 0.54510955881055889f, 0.51638165671265679f, 1.0f}, -{0.77627498513569104f, 0.55058809370085848f, 0.51889844746474156f, 1.0f}, -{0.77795819858361037f, 0.55606662859115807f, 0.52141523821682645f, 1.0f}, -{0.7796414120315297f, 0.56154516348145767f, 0.52393202896891133f, 1.0f}, -{0.78131351805198868f, 0.56686537046507635f, 0.52641192047044982f, 1.0f}, -{0.78298215501474333f, 0.57213612867701114f, 0.52888028764469941f, 1.0f}, -{0.78465079197749787f, 0.57740688688894581f, 0.531348654818949f, 1.0f}, -{0.78631942894025253f, 0.58267764510088049f, 0.53381702199319858f, 1.0f}, -{0.78797782903265257f, 0.58781567699373583f, 0.53625326657426664f, 1.0f}, -{0.78963213656931308f, 0.59290064678458798f, 0.53867666899766908f, 1.0f}, -{0.79128644410597349f, 0.59798561657544014f, 0.54110007142107142f, 1.0f}, -{0.792940751642634f, 0.60307058636629229f, 0.54352347384447386f, 1.0f}, -{0.79458583407265759f, 0.6080438664732194f, 0.54591821254368311f, 1.0f}, -{0.79622630630136515f, 0.61296133021421262f, 0.54829862668880314f, 1.0f}, -{0.7978667785300726f, 0.61787879395520573f, 0.55067904083392316f, 1.0f}, -{0.79950725075878015f, 0.62279625769619895f, 0.55305945497904319f, 1.0f}, -{0.80113946258969781f, 0.62761964468458598f, 0.55541462901980543f, 1.0f}, -{0.80276659362859359f, 0.63238516709716719f, 0.5577542784182784f, 1.0f}, -{0.80439372466748937f, 0.6371506895097484f, 0.56009392781675138f, 1.0f}, -{0.80602085570638515f, 0.64191621192232962f, 0.56243357721522436f, 1.0f}, -{0.80764036158824393f, 0.6466026586323057f, 0.56475119838225718f, 1.0f}, -{0.80925415143732793f, 0.65122982796535744f, 0.56705230656571837f, 1.0f}, -{0.81086794128641193f, 0.65585699729840907f, 0.56935341474917944f, 1.0f}, -{0.81248173113549593f, 0.66048416663146081f, 0.57165452293264063f, 1.0f}, -{0.81408873711359309f, 0.66504439491510359f, 0.57393613995508752f, 1.0f}, -{0.81568957903786432f, 0.66954379830503452f, 0.57620004665169589f, 1.0f}, -{0.81729042096213567f, 0.67404320169496545f, 0.57846395334830425f, 1.0f}, -{0.8188912628864069f, 0.6785426050848965f, 0.58072786004491261f, 1.0f}, -{0.8204862720145073f, 0.68298627573768744f, 0.58297525076001555f, 1.0f}, -{0.82207486183839118f, 0.68736860953178602f, 0.58520446475393539f, 1.0f}, -{0.82366345166227517f, 0.69175094332588438f, 0.58743367874785524f, 1.0f}, -{0.82525204148615916f, 0.69613327711998296f, 0.58966289274177519f, 1.0f}, -{0.82683523283464455f, 0.70046914168467111f, 0.59187771080129903f, 1.0f}, -{0.82841122264592848f, 0.70474301654678129f, 0.59407332476161889f, 1.0f}, -{0.82998721245721252f, 0.70901689140889135f, 0.59626893872193876f, 1.0f}, -{0.83156320226849645f, 0.71329076627100152f, 0.59846455268225862f, 1.0f}, -{0.83313467582020528f, 0.71752625292672356f, 0.60064793510622927f, 1.0f}, -{0.83469880679610087f, 0.72169932768803358f, 0.60281143138737259f, 1.0f}, -{0.83626293777199656f, 0.72587240244934359f, 0.6049749276685159f, 1.0f}, -{0.83782706874789226f, 0.7300454772106536f, 0.60713842394965922f, 1.0f}, -{0.83938733044768332f, 0.7341871861380096f, 0.60929162960286487f, 1.0f}, -{0.84093984964726143f, 0.73826613139342545f, 0.61142424350018465f, 1.0f}, -{0.84249236884683942f, 0.74234507664884131f, 0.61355685739750443f, 1.0f}, -{0.84404488804641742f, 0.74642402190425716f, 0.61568947129482421f, 1.0f}, -{0.84559416142592614f, 0.7504779178960943f, 0.61781375895805313f, 1.0f}, -{0.84713531590825708f, 0.75446915718145124f, 0.61991721988504345f, 1.0f}, -{0.84867647039058802f, 0.75846039646680807f, 0.62202068081203377f, 1.0f}, -{0.85021762487291896f, 0.76245163575216512f, 0.62412414173902409f, 1.0f}, -{0.8517560746661923f, 0.76642317784547198f, 0.62622084094337038f, 1.0f}, -{0.85328586443127619f, 0.77033165234218171f, 0.62829589007724307f, 1.0f}, -{0.85481565419636008f, 0.77424012683889154f, 0.63037093921111564f, 1.0f}, -{0.85634544396144396f, 0.77814860133560138f, 0.63244598834498833f, 1.0f}, -{0.85787311720235249f, 0.78204230719695422f, 0.63451591078696956f, 1.0f}, -{0.85939178930925986f, 0.7858732051454993f, 0.63656403048214805f, 1.0f}, -{0.86091046141616734f, 0.78970410309404426f, 0.63861215017732664f, 1.0f}, -{0.86242913352307471f, 0.79353500104258923f, 0.64066026987250513f, 1.0f}, -{0.86394628901340664f, 0.79735545902587079f, 0.64270465093147444f, 1.0f}, -{0.86545433758027879f, 0.80111322748952163f, 0.64472658236517055f, 1.0f}, -{0.86696238614715082f, 0.80487099595317246f, 0.64674851379886666f, 1.0f}, -{0.86847043471402297f, 0.8086287644168233f, 0.64877044523256289f, 1.0f}, -{0.86997749601061369f, 0.81237997458503342f, 0.65078997900986135f, 1.0f}, -{0.87147516809652104f, 0.8160688135679901f, 0.65278671041835745f, 1.0f}, -{0.87297284018242838f, 0.81975765255094657f, 0.65478344182685355f, 1.0f}, -{0.87447051226833583f, 0.82344649153390326f, 0.65678017323534965f, 1.0f}, -{0.87596769116010298f, 0.82713220695397172f, 0.65877576560023621f, 1.0f}, -{0.87745498676504563f, 0.83075532822415177f, 0.66074853227888519f, 1.0f}, -{0.87894228236998828f, 0.83437844949433182f, 0.66272129895753429f, 1.0f}, -{0.88042957797493082f, 0.83800157076451187f, 0.66469406563618327f, 1.0f}, -{0.88191687357987347f, 0.84162469203469192f, 0.66666683231483226f, 1.0f}, -{0.8833940406239229f, 0.84518605378723022f, 0.66861588333870681f, 1.0f}, -{0.88487120680697151f, 0.84874741028976319f, 0.67056493234657943f, 1.0f}, -{0.88634837299002001f, 0.85230876679229617f, 0.67251398135445195f, 1.0f}, -{0.88782553917306861f, 0.85587012329482914f, 0.67446303036232447f, 1.0f}, -{0.88929329438200022f, 0.85937524922701392f, 0.6763909046784341f, 1.0f}, -{0.89076057820222532f, 0.86287755861167625f, 0.67831771836995369f, 1.0f}, -{0.8922278620224503f, 0.86637986799633859f, 0.68024453206147328f, 1.0f}, -{0.89369514584267529f, 0.86988217738100093f, 0.68217134575299287f, 1.0f}, -{0.8951537127481245f, 0.8733335263408204f, 0.68407849050860814f, 1.0f}, -{0.89661136126459651f, 0.87677950625738843f, 0.68598356300191587f, 1.0f}, -{0.89806900978106863f, 0.88022548617395668f, 0.68788863549522372f, 1.0f}, -{0.89952665829754064f, 0.88367146609052483f, 0.68979370798853146f, 1.0f}, -{0.90097626043114276f, 0.8870717086728851f, 0.69168057024692309f, 1.0f}, -{0.90242452070293244f, 0.89046432383020613f, 0.69356439566016026f, 1.0f}, -{0.90387278097472212f, 0.89385693898752716f, 0.69544822107339743f, 1.0f}, -{0.9053210412465118f, 0.89724955414484819f, 0.6973320464866346f, 1.0f}, -{0.90676170215670215f, 0.9006007727797728f, 0.69919947327747323f, 1.0f}, -{0.90820057418380951f, 0.90394224670948198f, 0.7010630398469222f, 1.0f}, -{0.90963944621091686f, 0.90728372063919127f, 0.70292660641637117f, 1.0f}, -{0.91107831823802421f, 0.91062519456890045f, 0.70479017298582003f, 1.0f}, -{0.91251022614428501f, 0.91251022614428501f, 0.70936202968661799f, 1.0f}, -{0.91393995698578057f, 0.91393995698578057f, 0.71478052922276458f, 1.0f}, -{0.91536968782727612f, 0.91536968782727612f, 0.72019902875891106f, 1.0f}, -{0.91679941866877168f, 0.91679941866877168f, 0.72561752829505766f, 1.0f}, -{0.91822262064697358f, 0.91822262064697358f, 0.73092256677450795f, 1.0f}, -{0.91964321030285734f, 0.91964321030285734f, 0.736182207328266f, 1.0f}, -{0.9210637999587411f, 0.9210637999587411f, 0.74144184788202439f, 1.0f}, -{0.92248438961462487f, 0.92248438961462487f, 0.74670148843578266f, 1.0f}, -{0.92389921504886208f, 0.92389921504886208f, 0.7518642900658784f, 1.0f}, -{0.92531115763727523f, 0.92531115763727523f, 0.75697865988613056f, 1.0f}, -{0.92672310022568849f, 0.92672310022568849f, 0.76209302970638271f, 1.0f}, -{0.92813504281410164f, 0.92813504281410164f, 0.76720739952663486f, 1.0f}, -{0.92954163291098579f, 0.92954163291098579f, 0.77223872926402337f, 1.0f}, -{0.93094492843192844f, 0.93094492843192844f, 0.77721894600894603f, 1.0f}, -{0.93234822395287098f, 0.93234822395287098f, 0.78219916275386858f, 1.0f}, -{0.93375151947381363f, 0.93375151947381363f, 0.78717937949879124f, 1.0f}, -{0.93515001539795661f, 0.93515001539795661f, 0.79208859044400215f, 1.0f}, -{0.93654491091049918f, 0.93654491091049918f, 0.79694453647641883f, 1.0f}, -{0.93793980642304176f, 0.93793980642304176f, 0.80180048250883551f, 1.0f}, -{0.93933470193558433f, 0.93933470193558433f, 0.80665642854125208f, 1.0f}, -{0.94072519781772723f, 0.94072519781772723f, 0.81145220315790911f, 1.0f}, -{0.94211169332186973f, 0.94211169332186973f, 0.81619326672250192f, 1.0f}, -{0.94349818882601233f, 0.94349818882601233f, 0.82093433028709506f, 1.0f}, -{0.94488468433015493f, 0.94488468433015493f, 0.82567539385168798f, 1.0f}, -{0.94626729780747432f, 0.94626729780747432f, 0.83036516760734413f, 1.0f}, -{0.94764564036228738f, 0.94764564036228738f, 0.83499851341716058f, 1.0f}, -{0.94902398291710055f, 0.94902398291710055f, 0.83963185922697692f, 1.0f}, -{0.95040232547191372f, 0.95040232547191372f, 0.84426520503679336f, 1.0f}, -{0.95177717420258601f, 0.95177717420258601f, 0.84885556622233094f, 1.0f}, -{0.95314736380806975f, 0.95314736380806975f, 0.85338860604948841f, 1.0f}, -{0.95451755341355349f, 0.95451755341355349f, 0.85792164587664588f, 1.0f}, -{0.95588774301903712f, 0.95588774301903712f, 0.86245468570380335f, 1.0f}, -{0.95725492111280353f, 0.95725492111280353f, 0.86695196382931672f, 1.0f}, -{0.95861720482802837f, 0.95861720482802837f, 0.87139112120965057f, 1.0f}, -{0.95997948854325332f, 0.95997948854325332f, 0.87583027858998452f, 1.0f}, -{0.96134177225847817f, 0.96134177225847817f, 0.88026943597031837f, 1.0f}, -{0.9627015032469739f, 0.9627015032469739f, 0.88467894878218412f, 1.0f}, -{0.96405612813101049f, 0.96405612813101049f, 0.88902916489710604f, 1.0f}, -{0.96541075301504709f, 0.96541075301504709f, 0.89337938101202807f, 1.0f}, -{0.96676537789908379f, 0.96676537789908379f, 0.89772959712695011f, 1.0f}, -{0.96811781473163827f, 0.96811781473163827f, 0.9020560975870977f, 1.0f}, -{0.96946478078448661f, 0.96946478078448661f, 0.90632330185430188f, 1.0f}, -{0.97081174683733507f, 0.97081174683733507f, 0.91059050612150616f, 1.0f}, -{0.97215871289018341f, 0.97215871289018341f, 0.91485771038871044f, 1.0f}, -{0.97350391438538497f, 0.97350391438538497f, 0.91910609270768096f, 1.0f}, -{0.97484346866611571f, 0.97484346866611571f, 0.92329423807229694f, 1.0f}, -{0.97618302294684645f, 0.97618302294684645f, 0.92748238343691292f, 1.0f}, -{0.97752257722757718f, 0.97752257722757718f, 0.93167052880152879f, 1.0f}, -{0.97886071986219048f, 0.97886071986219048f, 0.93584446359522833f, 1.0f}, -{0.9801928623708035f, 0.9801928623708035f, 0.93995799712052652f, 1.0f}, -{0.98152500487941663f, 0.98152500487941663f, 0.94407153064582472f, 1.0f}, -{0.98285714738802965f, 0.98285714738802965f, 0.94818506417112292f, 1.0f}, -{0.98418823116205467f, 0.98418823116205467f, 0.95228850442668089f, 1.0f}, -{0.98551296189855009f, 0.98551296189855009f, 0.95633137905779064f, 1.0f}, -{0.98683769263504562f, 0.98683769263504562f, 0.96037425368890073f, 1.0f}, -{0.98816242337154103f, 0.98816242337154103f, 0.9644171283200107f, 1.0f}, -{0.98948649533984834f, 0.98948649533984834f, 0.96845360348872123f, 1.0f}, -{0.99080430842236733f, 0.99080430842236733f, 0.97242927805263102f, 1.0f}, -{0.99212212150488621f, 0.99212212150488621f, 0.97640495261654092f, 1.0f}, -{0.9934399345874052f, 0.9934399345874052f, 0.98038062718045071f, 1.0f}, -{0.99475740652211242f, 0.99475740652211242f, 0.98435325494149029f, 1.0f}, -{0.99606805489158434f, 0.99606805489158434f, 0.98826494120611774f, 1.0f}, -{0.99737870326105615f, 0.99737870326105615f, 0.99217662747074509f, 1.0f}, -{0.99868935163052808f, 0.99868935163052808f, 0.99608831373537254f, 1.0f}, -{1.0f, 1.0f, 1.0f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential2/pink.txt b/extern/tfn/colormaps/sequential2/pink.txt deleted file mode 100644 index 6651639..0000000 --- a/extern/tfn/colormaps/sequential2/pink.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.1178, 0.0, 0.0, 1.0) -(0.13708468987292516, 0.025414719532366591, 0.025414719532366591, 1.0) -(0.15636937974585033, 0.050829439064733181, 0.050829439064733181, 1.0) -(0.1756540696187755, 0.076244158597099765, 0.076244158597099765, 1.0) -(0.19493875949170067, 0.10165887812946636, 0.10165887812946636, 1.0) -(0.20875212652265593, 0.11289493498887616, 0.11289493498887616, 1.0) -(0.22229195182718714, 0.1234221219866514, 0.1234221219866514, 1.0) -(0.23583177713171832, 0.13394930898442661, 0.13394930898442661, 1.0) -(0.24937160243624951, 0.14447649598220186, 0.14447649598220186, 1.0) -(0.26067678198272315, 0.15278736681601388, 0.15278736681601388, 1.0) -(0.27174675775858131, 0.1608649631289043, 0.1608649631289043, 1.0) -(0.28281673353443942, 0.16894255944179473, 0.16894255944179473, 1.0) -(0.29388670931029753, 0.17702015575468516, 0.17702015575468516, 1.0) -(0.30369645420821889, 0.18401117088211205, 0.18401117088211205, 1.0) -(0.31329618145500499, 0.19082110710381298, 0.19082110710381298, 1.0) -(0.32289590870179102, 0.1976310433255139, 0.1976310433255139, 1.0) -(0.33249563594857712, 0.20444097954721482, 0.20444097954721482, 1.0) -(0.3412817461097461, 0.21059490199290198, 0.21059490199290198, 1.0) -(0.3498764370573782, 0.2165944844630727, 0.2165944844630727, 1.0) -(0.35847112800501035, 0.22259406693324341, 0.22259406693324341, 1.0) -(0.36706581895264245, 0.22859364940341409, 0.22859364940341409, 1.0) -(0.37509428252934135, 0.23415463154969035, 0.23415463154969035, 1.0) -(0.3829458197926433, 0.23957856638538991, 0.23957856638538991, 1.0) -(0.39079735705594532, 0.24500250122108944, 0.24500250122108944, 1.0) -(0.39864889431924727, 0.25042643605678894, 0.25042643605678894, 1.0) -(0.4060872994763583, 0.25553906587953645, 0.25553906587953645, 1.0) -(0.41336047145541266, 0.2605271885147179, 0.2605271885147179, 1.0) -(0.42063364343446696, 0.2655153111498994, 0.2655153111498994, 1.0) -(0.42790681541352132, 0.27050343378508085, 0.27050343378508085, 1.0) -(0.43486900915971505, 0.275261122867417, 0.275261122867417, 1.0) -(0.44167573361349832, 0.27990360986284518, 0.27990360986284518, 1.0) -(0.4484824580672816, 0.28454609685827337, 0.28454609685827337, 1.0) -(0.45528918252106487, 0.2891885838537015, 0.2891885838537015, 1.0) -(0.4618563883249765, 0.29365655566426152, 0.29365655566426152, 1.0) -(0.46827621827421828, 0.29801714826014825, 0.29801714826014825, 1.0) -(0.47469604822345995, 0.30237774085603497, 0.30237774085603497, 1.0) -(0.48111587817270168, 0.3067383334519217, 0.3067383334519217, 1.0) -(0.48734835481511946, 0.31096381141734081, 0.31096381141734081, 1.0) -(0.49344033737769027, 0.31508796848267434, 0.31508796848267434, 1.0) -(0.49953231994026109, 0.31921212554800787, 0.31921212554800787, 1.0) -(0.50562430250283186, 0.32333628261334141, 0.32333628261334141, 1.0) -(0.51156861468420289, 0.3273549608349608, 0.3273549608349608, 1.0) -(0.5173787028472322, 0.33127776475776471, 0.33127776475776471, 1.0) -(0.52318879101026161, 0.33520056868056863, 0.33520056868056863, 1.0) -(0.52899887917329091, 0.33912337260337255, 0.33912337260337255, 1.0) -(0.53469177979254445, 0.3429628745372274, 0.3429628745372274, 1.0) -(0.5402557971212677, 0.34671076063805473, 0.34671076063805473, 1.0) -(0.54581981444999095, 0.350458646738882, 0.350458646738882, 1.0) -(0.55138383177871408, 0.35420653283970926, 0.35420653283970926, 1.0) -(0.55685466198366196, 0.3578888702705173, 0.3578888702705173, 1.0) -(0.56220126733026732, 0.36148382680665031, 0.36148382680665031, 1.0) -(0.56754787267687268, 0.36507878334278332, 0.36507878334278332, 1.0) -(0.57289447802347804, 0.36867373987891633, 0.36867373987891633, 1.0) -(0.57816728486899072, 0.37221692450739507, 0.37221692450739507, 1.0) -(0.58332019590425477, 0.37567599855470446, 0.37567599855470446, 1.0) -(0.58847310693951871, 0.37913507260201379, 0.37913507260201379, 1.0) -(0.59362601797478265, 0.38259414664932312, 0.38259414664932312, 1.0) -(0.5987208602584484, 0.38601277848807258, 0.38601277848807258, 1.0) -(0.60369959464894762, 0.38935054653172302, 0.38935054653172302, 1.0) -(0.60867832903944663, 0.3926883145753734, 0.3926883145753734, 1.0) -(0.61365706342994575, 0.39602608261902378, 0.39602608261902378, 1.0) -(0.61859089411789414, 0.39933250279485571, 0.39933250279485571, 1.0) -(0.6234124989394989, 0.40256057661116484, 0.40256057661116484, 1.0) -(0.62823410376110378, 0.40578865042747392, 0.40578865042747392, 1.0) -(0.63305570858270854, 0.40901672424378305, 0.40901672424378305, 1.0) -(0.63784306876395103, 0.41222108570602689, 0.41222108570602689, 1.0) -(0.64252088520647332, 0.41534959471688876, 0.41534959471688876, 1.0) -(0.64719870164899573, 0.41847810372775079, 0.41847810372775079, 1.0) -(0.65187651809151803, 0.42160661273861272, 0.42160661273861272, 1.0) -(0.656529337246749, 0.42471789198083315, 0.42471789198083315, 1.0) -(0.66107596532278889, 0.42775597737185972, 0.42775597737185972, 1.0) -(0.66562259339882868, 0.43079406276288629, 0.43079406276288629, 1.0) -(0.67016922147486857, 0.43383214815391286, 0.43383214815391286, 1.0) -(0.67469858190811138, 0.43685829803723919, 0.43685829803723919, 1.0) -(0.67912439809863334, 0.43981287746240683, 0.43981287746240683, 1.0) -(0.68355021428915552, 0.44276745688757452, 0.44276745688757452, 1.0) -(0.68797603047967759, 0.44572203631274215, 0.44572203631274215, 1.0) -(0.69239117922900284, 0.44866931572296276, 0.44866931572296276, 1.0) -(0.69670507766054823, 0.451547306836248, 0.451547306836248, 1.0) -(0.70101897609209374, 0.45442529794953324, 0.45442529794953324, 1.0) -(0.70533287452363924, 0.45730328906281847, 0.45730328906281847, 1.0) -(0.70964183515848223, 0.46017788617741556, 0.46017788617741556, 1.0) -(0.71385221583945102, 0.46298472427837128, 0.46298472427837128, 1.0) -(0.71806259652042004, 0.46579156237932706, 0.46579156237932706, 1.0) -(0.72227297720138894, 0.46859840048028284, 0.46859840048028284, 1.0) -(0.72648334967134964, 0.47140523295323294, 0.47140523295323294, 1.0) -(0.73059713025571849, 0.47414585922327102, 0.47414585922327102, 1.0) -(0.73471091084008722, 0.47688648549330903, 0.47688648549330903, 1.0) -(0.73882469142445606, 0.47962711176334705, 0.47962711176334705, 1.0) -(0.7429384720088249, 0.48236773803338506, 0.48236773803338506, 1.0) -(0.74696659744071492, 0.48504977053153514, 0.48504977053153514, 1.0) -(0.7509904485233897, 0.48772887909299673, 0.48772887909299673, 1.0) -(0.75501429960606425, 0.49040798765445826, 0.49040798765445826, 1.0) -(0.75903815068873892, 0.49308709621591973, 0.49308709621591973, 1.0) -(0.76097133752592572, 0.49875353864312688, 0.49571411701335227, 1.0) -(0.76268469218045687, 0.50473409756486221, 0.49833566081136665, 1.0) -(0.76439804683498802, 0.51071465648659764, 0.50095720460938109, 1.0) -(0.76611140148951917, 0.51669521540833308, 0.50357874840739547, 1.0) -(0.76781162523115465, 0.52244661872114806, 0.50615369864352211, 1.0) -(0.7695096622233093, 0.52815985972850676, 0.50872088944600713, 1.0) -(0.77120769921546395, 0.53387310073586547, 0.51128808024849204, 1.0) -(0.7729057362076186, 0.53958634174322417, 0.51385527105097695, 1.0) -(0.77459177168777171, 0.54510955881055889, 0.51638165671265679, 1.0) -(0.77627498513569104, 0.55058809370085848, 0.51889844746474156, 1.0) -(0.77795819858361037, 0.55606662859115807, 0.52141523821682645, 1.0) -(0.7796414120315297, 0.56154516348145767, 0.52393202896891133, 1.0) -(0.78131351805198868, 0.56686537046507635, 0.52641192047044982, 1.0) -(0.78298215501474333, 0.57213612867701114, 0.52888028764469941, 1.0) -(0.78465079197749787, 0.57740688688894581, 0.531348654818949, 1.0) -(0.78631942894025253, 0.58267764510088049, 0.53381702199319858, 1.0) -(0.78797782903265257, 0.58781567699373583, 0.53625326657426664, 1.0) -(0.78963213656931308, 0.59290064678458798, 0.53867666899766908, 1.0) -(0.79128644410597349, 0.59798561657544014, 0.54110007142107142, 1.0) -(0.792940751642634, 0.60307058636629229, 0.54352347384447386, 1.0) -(0.79458583407265759, 0.6080438664732194, 0.54591821254368311, 1.0) -(0.79622630630136515, 0.61296133021421262, 0.54829862668880314, 1.0) -(0.7978667785300726, 0.61787879395520573, 0.55067904083392316, 1.0) -(0.79950725075878015, 0.62279625769619895, 0.55305945497904319, 1.0) -(0.80113946258969781, 0.62761964468458598, 0.55541462901980543, 1.0) -(0.80276659362859359, 0.63238516709716719, 0.5577542784182784, 1.0) -(0.80439372466748937, 0.6371506895097484, 0.56009392781675138, 1.0) -(0.80602085570638515, 0.64191621192232962, 0.56243357721522436, 1.0) -(0.80764036158824393, 0.6466026586323057, 0.56475119838225718, 1.0) -(0.80925415143732793, 0.65122982796535744, 0.56705230656571837, 1.0) -(0.81086794128641193, 0.65585699729840907, 0.56935341474917944, 1.0) -(0.81248173113549593, 0.66048416663146081, 0.57165452293264063, 1.0) -(0.81408873711359309, 0.66504439491510359, 0.57393613995508752, 1.0) -(0.81568957903786432, 0.66954379830503452, 0.57620004665169589, 1.0) -(0.81729042096213567, 0.67404320169496545, 0.57846395334830425, 1.0) -(0.8188912628864069, 0.6785426050848965, 0.58072786004491261, 1.0) -(0.8204862720145073, 0.68298627573768744, 0.58297525076001555, 1.0) -(0.82207486183839118, 0.68736860953178602, 0.58520446475393539, 1.0) -(0.82366345166227517, 0.69175094332588438, 0.58743367874785524, 1.0) -(0.82525204148615916, 0.69613327711998296, 0.58966289274177519, 1.0) -(0.82683523283464455, 0.70046914168467111, 0.59187771080129903, 1.0) -(0.82841122264592848, 0.70474301654678129, 0.59407332476161889, 1.0) -(0.82998721245721252, 0.70901689140889135, 0.59626893872193876, 1.0) -(0.83156320226849645, 0.71329076627100152, 0.59846455268225862, 1.0) -(0.83313467582020528, 0.71752625292672356, 0.60064793510622927, 1.0) -(0.83469880679610087, 0.72169932768803358, 0.60281143138737259, 1.0) -(0.83626293777199656, 0.72587240244934359, 0.6049749276685159, 1.0) -(0.83782706874789226, 0.7300454772106536, 0.60713842394965922, 1.0) -(0.83938733044768332, 0.7341871861380096, 0.60929162960286487, 1.0) -(0.84093984964726143, 0.73826613139342545, 0.61142424350018465, 1.0) -(0.84249236884683942, 0.74234507664884131, 0.61355685739750443, 1.0) -(0.84404488804641742, 0.74642402190425716, 0.61568947129482421, 1.0) -(0.84559416142592614, 0.7504779178960943, 0.61781375895805313, 1.0) -(0.84713531590825708, 0.75446915718145124, 0.61991721988504345, 1.0) -(0.84867647039058802, 0.75846039646680807, 0.62202068081203377, 1.0) -(0.85021762487291896, 0.76245163575216512, 0.62412414173902409, 1.0) -(0.8517560746661923, 0.76642317784547198, 0.62622084094337038, 1.0) -(0.85328586443127619, 0.77033165234218171, 0.62829589007724307, 1.0) -(0.85481565419636008, 0.77424012683889154, 0.63037093921111564, 1.0) -(0.85634544396144396, 0.77814860133560138, 0.63244598834498833, 1.0) -(0.85787311720235249, 0.78204230719695422, 0.63451591078696956, 1.0) -(0.85939178930925986, 0.7858732051454993, 0.63656403048214805, 1.0) -(0.86091046141616734, 0.78970410309404426, 0.63861215017732664, 1.0) -(0.86242913352307471, 0.79353500104258923, 0.64066026987250513, 1.0) -(0.86394628901340664, 0.79735545902587079, 0.64270465093147444, 1.0) -(0.86545433758027879, 0.80111322748952163, 0.64472658236517055, 1.0) -(0.86696238614715082, 0.80487099595317246, 0.64674851379886666, 1.0) -(0.86847043471402297, 0.8086287644168233, 0.64877044523256289, 1.0) -(0.86997749601061369, 0.81237997458503342, 0.65078997900986135, 1.0) -(0.87147516809652104, 0.8160688135679901, 0.65278671041835745, 1.0) -(0.87297284018242838, 0.81975765255094657, 0.65478344182685355, 1.0) -(0.87447051226833583, 0.82344649153390326, 0.65678017323534965, 1.0) -(0.87596769116010298, 0.82713220695397172, 0.65877576560023621, 1.0) -(0.87745498676504563, 0.83075532822415177, 0.66074853227888519, 1.0) -(0.87894228236998828, 0.83437844949433182, 0.66272129895753429, 1.0) -(0.88042957797493082, 0.83800157076451187, 0.66469406563618327, 1.0) -(0.88191687357987347, 0.84162469203469192, 0.66666683231483226, 1.0) -(0.8833940406239229, 0.84518605378723022, 0.66861588333870681, 1.0) -(0.88487120680697151, 0.84874741028976319, 0.67056493234657943, 1.0) -(0.88634837299002001, 0.85230876679229617, 0.67251398135445195, 1.0) -(0.88782553917306861, 0.85587012329482914, 0.67446303036232447, 1.0) -(0.88929329438200022, 0.85937524922701392, 0.6763909046784341, 1.0) -(0.89076057820222532, 0.86287755861167625, 0.67831771836995369, 1.0) -(0.8922278620224503, 0.86637986799633859, 0.68024453206147328, 1.0) -(0.89369514584267529, 0.86988217738100093, 0.68217134575299287, 1.0) -(0.8951537127481245, 0.8733335263408204, 0.68407849050860814, 1.0) -(0.89661136126459651, 0.87677950625738843, 0.68598356300191587, 1.0) -(0.89806900978106863, 0.88022548617395668, 0.68788863549522372, 1.0) -(0.89952665829754064, 0.88367146609052483, 0.68979370798853146, 1.0) -(0.90097626043114276, 0.8870717086728851, 0.69168057024692309, 1.0) -(0.90242452070293244, 0.89046432383020613, 0.69356439566016026, 1.0) -(0.90387278097472212, 0.89385693898752716, 0.69544822107339743, 1.0) -(0.9053210412465118, 0.89724955414484819, 0.6973320464866346, 1.0) -(0.90676170215670215, 0.9006007727797728, 0.69919947327747323, 1.0) -(0.90820057418380951, 0.90394224670948198, 0.7010630398469222, 1.0) -(0.90963944621091686, 0.90728372063919127, 0.70292660641637117, 1.0) -(0.91107831823802421, 0.91062519456890045, 0.70479017298582003, 1.0) -(0.91251022614428501, 0.91251022614428501, 0.70936202968661799, 1.0) -(0.91393995698578057, 0.91393995698578057, 0.71478052922276458, 1.0) -(0.91536968782727612, 0.91536968782727612, 0.72019902875891106, 1.0) -(0.91679941866877168, 0.91679941866877168, 0.72561752829505766, 1.0) -(0.91822262064697358, 0.91822262064697358, 0.73092256677450795, 1.0) -(0.91964321030285734, 0.91964321030285734, 0.736182207328266, 1.0) -(0.9210637999587411, 0.9210637999587411, 0.74144184788202439, 1.0) -(0.92248438961462487, 0.92248438961462487, 0.74670148843578266, 1.0) -(0.92389921504886208, 0.92389921504886208, 0.7518642900658784, 1.0) -(0.92531115763727523, 0.92531115763727523, 0.75697865988613056, 1.0) -(0.92672310022568849, 0.92672310022568849, 0.76209302970638271, 1.0) -(0.92813504281410164, 0.92813504281410164, 0.76720739952663486, 1.0) -(0.92954163291098579, 0.92954163291098579, 0.77223872926402337, 1.0) -(0.93094492843192844, 0.93094492843192844, 0.77721894600894603, 1.0) -(0.93234822395287098, 0.93234822395287098, 0.78219916275386858, 1.0) -(0.93375151947381363, 0.93375151947381363, 0.78717937949879124, 1.0) -(0.93515001539795661, 0.93515001539795661, 0.79208859044400215, 1.0) -(0.93654491091049918, 0.93654491091049918, 0.79694453647641883, 1.0) -(0.93793980642304176, 0.93793980642304176, 0.80180048250883551, 1.0) -(0.93933470193558433, 0.93933470193558433, 0.80665642854125208, 1.0) -(0.94072519781772723, 0.94072519781772723, 0.81145220315790911, 1.0) -(0.94211169332186973, 0.94211169332186973, 0.81619326672250192, 1.0) -(0.94349818882601233, 0.94349818882601233, 0.82093433028709506, 1.0) -(0.94488468433015493, 0.94488468433015493, 0.82567539385168798, 1.0) -(0.94626729780747432, 0.94626729780747432, 0.83036516760734413, 1.0) -(0.94764564036228738, 0.94764564036228738, 0.83499851341716058, 1.0) -(0.94902398291710055, 0.94902398291710055, 0.83963185922697692, 1.0) -(0.95040232547191372, 0.95040232547191372, 0.84426520503679336, 1.0) -(0.95177717420258601, 0.95177717420258601, 0.84885556622233094, 1.0) -(0.95314736380806975, 0.95314736380806975, 0.85338860604948841, 1.0) -(0.95451755341355349, 0.95451755341355349, 0.85792164587664588, 1.0) -(0.95588774301903712, 0.95588774301903712, 0.86245468570380335, 1.0) -(0.95725492111280353, 0.95725492111280353, 0.86695196382931672, 1.0) -(0.95861720482802837, 0.95861720482802837, 0.87139112120965057, 1.0) -(0.95997948854325332, 0.95997948854325332, 0.87583027858998452, 1.0) -(0.96134177225847817, 0.96134177225847817, 0.88026943597031837, 1.0) -(0.9627015032469739, 0.9627015032469739, 0.88467894878218412, 1.0) -(0.96405612813101049, 0.96405612813101049, 0.88902916489710604, 1.0) -(0.96541075301504709, 0.96541075301504709, 0.89337938101202807, 1.0) -(0.96676537789908379, 0.96676537789908379, 0.89772959712695011, 1.0) -(0.96811781473163827, 0.96811781473163827, 0.9020560975870977, 1.0) -(0.96946478078448661, 0.96946478078448661, 0.90632330185430188, 1.0) -(0.97081174683733507, 0.97081174683733507, 0.91059050612150616, 1.0) -(0.97215871289018341, 0.97215871289018341, 0.91485771038871044, 1.0) -(0.97350391438538497, 0.97350391438538497, 0.91910609270768096, 1.0) -(0.97484346866611571, 0.97484346866611571, 0.92329423807229694, 1.0) -(0.97618302294684645, 0.97618302294684645, 0.92748238343691292, 1.0) -(0.97752257722757718, 0.97752257722757718, 0.93167052880152879, 1.0) -(0.97886071986219048, 0.97886071986219048, 0.93584446359522833, 1.0) -(0.9801928623708035, 0.9801928623708035, 0.93995799712052652, 1.0) -(0.98152500487941663, 0.98152500487941663, 0.94407153064582472, 1.0) -(0.98285714738802965, 0.98285714738802965, 0.94818506417112292, 1.0) -(0.98418823116205467, 0.98418823116205467, 0.95228850442668089, 1.0) -(0.98551296189855009, 0.98551296189855009, 0.95633137905779064, 1.0) -(0.98683769263504562, 0.98683769263504562, 0.96037425368890073, 1.0) -(0.98816242337154103, 0.98816242337154103, 0.9644171283200107, 1.0) -(0.98948649533984834, 0.98948649533984834, 0.96845360348872123, 1.0) -(0.99080430842236733, 0.99080430842236733, 0.97242927805263102, 1.0) -(0.99212212150488621, 0.99212212150488621, 0.97640495261654092, 1.0) -(0.9934399345874052, 0.9934399345874052, 0.98038062718045071, 1.0) -(0.99475740652211242, 0.99475740652211242, 0.98435325494149029, 1.0) -(0.99606805489158434, 0.99606805489158434, 0.98826494120611774, 1.0) -(0.99737870326105615, 0.99737870326105615, 0.99217662747074509, 1.0) -(0.99868935163052808, 0.99868935163052808, 0.99608831373537254, 1.0) -(1.0, 1.0, 1.0, 1.0) diff --git a/extern/tfn/colormaps/sequential2/spring.cpp b/extern/tfn/colormaps/sequential2/spring.cpp deleted file mode 100644 index 994ca1c..0000000 --- a/extern/tfn/colormaps/sequential2/spring.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential2_spring; -} -const std::vector colormap::data_sequential2_spring = /* NOLINT(cert-err58-cpp) */ -{ -{1.0f, 0.0f, 1.0f, 1.0f}, -{1.0f, 0.0039215686274509803f, 0.99607843137254903f, 1.0f}, -{1.0f, 0.0078431372549019607f, 0.99215686274509807f, 1.0f}, -{1.0f, 0.011764705882352941f, 0.9882352941176471f, 1.0f}, -{1.0f, 0.015686274509803921f, 0.98431372549019613f, 1.0f}, -{1.0f, 0.019607843137254902f, 0.98039215686274506f, 1.0f}, -{1.0f, 0.023529411764705882f, 0.97647058823529409f, 1.0f}, -{1.0f, 0.027450980392156862f, 0.97254901960784312f, 1.0f}, -{1.0f, 0.031372549019607843f, 0.96862745098039216f, 1.0f}, -{1.0f, 0.035294117647058823f, 0.96470588235294119f, 1.0f}, -{1.0f, 0.039215686274509803f, 0.96078431372549022f, 1.0f}, -{1.0f, 0.043137254901960784f, 0.95686274509803926f, 1.0f}, -{1.0f, 0.047058823529411764f, 0.95294117647058818f, 1.0f}, -{1.0f, 0.050980392156862744f, 0.94901960784313721f, 1.0f}, -{1.0f, 0.054901960784313725f, 0.94509803921568625f, 1.0f}, -{1.0f, 0.058823529411764705f, 0.94117647058823528f, 1.0f}, -{1.0f, 0.062745098039215685f, 0.93725490196078431f, 1.0f}, -{1.0f, 0.066666666666666666f, 0.93333333333333335f, 1.0f}, -{1.0f, 0.070588235294117646f, 0.92941176470588238f, 1.0f}, -{1.0f, 0.074509803921568626f, 0.92549019607843142f, 1.0f}, -{1.0f, 0.078431372549019607f, 0.92156862745098045f, 1.0f}, -{1.0f, 0.082352941176470587f, 0.91764705882352937f, 1.0f}, -{1.0f, 0.086274509803921567f, 0.9137254901960784f, 1.0f}, -{1.0f, 0.090196078431372548f, 0.90980392156862744f, 1.0f}, -{1.0f, 0.094117647058823528f, 0.90588235294117647f, 1.0f}, -{1.0f, 0.098039215686274508f, 0.90196078431372551f, 1.0f}, -{1.0f, 0.10196078431372549f, 0.89803921568627454f, 1.0f}, -{1.0f, 0.10588235294117647f, 0.89411764705882357f, 1.0f}, -{1.0f, 0.10980392156862745f, 0.8901960784313725f, 1.0f}, -{1.0f, 0.11372549019607843f, 0.88627450980392153f, 1.0f}, -{1.0f, 0.11764705882352941f, 0.88235294117647056f, 1.0f}, -{1.0f, 0.12156862745098039f, 0.8784313725490196f, 1.0f}, -{1.0f, 0.12549019607843137f, 0.87450980392156863f, 1.0f}, -{1.0f, 0.12941176470588234f, 0.87058823529411766f, 1.0f}, -{1.0f, 0.13333333333333333f, 0.8666666666666667f, 1.0f}, -{1.0f, 0.13725490196078433f, 0.86274509803921573f, 1.0f}, -{1.0f, 0.14117647058823529f, 0.85882352941176476f, 1.0f}, -{1.0f, 0.14509803921568626f, 0.8549019607843138f, 1.0f}, -{1.0f, 0.14901960784313725f, 0.85098039215686272f, 1.0f}, -{1.0f, 0.15294117647058825f, 0.84705882352941175f, 1.0f}, -{1.0f, 0.15686274509803921f, 0.84313725490196079f, 1.0f}, -{1.0f, 0.16078431372549018f, 0.83921568627450982f, 1.0f}, -{1.0f, 0.16470588235294117f, 0.83529411764705885f, 1.0f}, -{1.0f, 0.16862745098039217f, 0.83137254901960778f, 1.0f}, -{1.0f, 0.17254901960784313f, 0.82745098039215681f, 1.0f}, -{1.0f, 0.1764705882352941f, 0.82352941176470584f, 1.0f}, -{1.0f, 0.1803921568627451f, 0.81960784313725488f, 1.0f}, -{1.0f, 0.18431372549019609f, 0.81568627450980391f, 1.0f}, -{1.0f, 0.18823529411764706f, 0.81176470588235294f, 1.0f}, -{1.0f, 0.19215686274509802f, 0.80784313725490198f, 1.0f}, -{1.0f, 0.19607843137254902f, 0.80392156862745101f, 1.0f}, -{1.0f, 0.20000000000000001f, 0.80000000000000004f, 1.0f}, -{1.0f, 0.20392156862745098f, 0.79607843137254908f, 1.0f}, -{1.0f, 0.20784313725490194f, 0.79215686274509811f, 1.0f}, -{1.0f, 0.21176470588235294f, 0.78823529411764703f, 1.0f}, -{1.0f, 0.21568627450980393f, 0.78431372549019607f, 1.0f}, -{1.0f, 0.2196078431372549f, 0.7803921568627451f, 1.0f}, -{1.0f, 0.22352941176470587f, 0.77647058823529413f, 1.0f}, -{1.0f, 0.22745098039215686f, 0.77254901960784317f, 1.0f}, -{1.0f, 0.23137254901960785f, 0.76862745098039209f, 1.0f}, -{1.0f, 0.23529411764705882f, 0.76470588235294112f, 1.0f}, -{1.0f, 0.23921568627450979f, 0.76078431372549016f, 1.0f}, -{1.0f, 0.24313725490196078f, 0.75686274509803919f, 1.0f}, -{1.0f, 0.24705882352941178f, 0.75294117647058822f, 1.0f}, -{1.0f, 0.25098039215686274f, 0.74901960784313726f, 1.0f}, -{1.0f, 0.25490196078431371f, 0.74509803921568629f, 1.0f}, -{1.0f, 0.25882352941176467f, 0.74117647058823533f, 1.0f}, -{1.0f, 0.2627450980392157f, 0.73725490196078436f, 1.0f}, -{1.0f, 0.26666666666666666f, 0.73333333333333339f, 1.0f}, -{1.0f, 0.27058823529411763f, 0.72941176470588243f, 1.0f}, -{1.0f, 0.27450980392156865f, 0.72549019607843135f, 1.0f}, -{1.0f, 0.27843137254901962f, 0.72156862745098038f, 1.0f}, -{1.0f, 0.28235294117647058f, 0.71764705882352942f, 1.0f}, -{1.0f, 0.28627450980392155f, 0.71372549019607845f, 1.0f}, -{1.0f, 0.29019607843137252f, 0.70980392156862748f, 1.0f}, -{1.0f, 0.29411764705882354f, 0.70588235294117641f, 1.0f}, -{1.0f, 0.29803921568627451f, 0.70196078431372544f, 1.0f}, -{1.0f, 0.30196078431372547f, 0.69803921568627447f, 1.0f}, -{1.0f, 0.30588235294117649f, 0.69411764705882351f, 1.0f}, -{1.0f, 0.30980392156862746f, 0.69019607843137254f, 1.0f}, -{1.0f, 0.31372549019607843f, 0.68627450980392157f, 1.0f}, -{1.0f, 0.31764705882352939f, 0.68235294117647061f, 1.0f}, -{1.0f, 0.32156862745098036f, 0.67843137254901964f, 1.0f}, -{1.0f, 0.32549019607843138f, 0.67450980392156867f, 1.0f}, -{1.0f, 0.32941176470588235f, 0.67058823529411771f, 1.0f}, -{1.0f, 0.33333333333333331f, 0.66666666666666674f, 1.0f}, -{1.0f, 0.33725490196078434f, 0.66274509803921566f, 1.0f}, -{1.0f, 0.3411764705882353f, 0.6588235294117647f, 1.0f}, -{1.0f, 0.34509803921568627f, 0.65490196078431373f, 1.0f}, -{1.0f, 0.34901960784313724f, 0.65098039215686276f, 1.0f}, -{1.0f, 0.3529411764705882f, 0.6470588235294118f, 1.0f}, -{1.0f, 0.35686274509803922f, 0.64313725490196072f, 1.0f}, -{1.0f, 0.36078431372549019f, 0.63921568627450975f, 1.0f}, -{1.0f, 0.36470588235294116f, 0.63529411764705879f, 1.0f}, -{1.0f, 0.36862745098039218f, 0.63137254901960782f, 1.0f}, -{1.0f, 0.37254901960784315f, 0.62745098039215685f, 1.0f}, -{1.0f, 0.37647058823529411f, 0.62352941176470589f, 1.0f}, -{1.0f, 0.38039215686274508f, 0.61960784313725492f, 1.0f}, -{1.0f, 0.38431372549019605f, 0.61568627450980395f, 1.0f}, -{1.0f, 0.38823529411764707f, 0.61176470588235299f, 1.0f}, -{1.0f, 0.39215686274509803f, 0.60784313725490202f, 1.0f}, -{1.0f, 0.396078431372549f, 0.60392156862745106f, 1.0f}, -{1.0f, 0.40000000000000002f, 0.59999999999999998f, 1.0f}, -{1.0f, 0.40392156862745099f, 0.59607843137254901f, 1.0f}, -{1.0f, 0.40784313725490196f, 0.59215686274509804f, 1.0f}, -{1.0f, 0.41176470588235292f, 0.58823529411764708f, 1.0f}, -{1.0f, 0.41568627450980389f, 0.58431372549019611f, 1.0f}, -{1.0f, 0.41960784313725491f, 0.58039215686274503f, 1.0f}, -{1.0f, 0.42352941176470588f, 0.57647058823529407f, 1.0f}, -{1.0f, 0.42745098039215684f, 0.5725490196078431f, 1.0f}, -{1.0f, 0.43137254901960786f, 0.56862745098039214f, 1.0f}, -{1.0f, 0.43529411764705883f, 0.56470588235294117f, 1.0f}, -{1.0f, 0.4392156862745098f, 0.5607843137254902f, 1.0f}, -{1.0f, 0.44313725490196076f, 0.55686274509803924f, 1.0f}, -{1.0f, 0.44705882352941173f, 0.55294117647058827f, 1.0f}, -{1.0f, 0.45098039215686275f, 0.5490196078431373f, 1.0f}, -{1.0f, 0.45490196078431372f, 0.54509803921568634f, 1.0f}, -{1.0f, 0.45882352941176469f, 0.54117647058823537f, 1.0f}, -{1.0f, 0.46274509803921571f, 0.53725490196078429f, 1.0f}, -{1.0f, 0.46666666666666667f, 0.53333333333333333f, 1.0f}, -{1.0f, 0.47058823529411764f, 0.52941176470588236f, 1.0f}, -{1.0f, 0.47450980392156861f, 0.52549019607843139f, 1.0f}, -{1.0f, 0.47843137254901957f, 0.52156862745098043f, 1.0f}, -{1.0f, 0.4823529411764706f, 0.51764705882352935f, 1.0f}, -{1.0f, 0.48627450980392156f, 0.51372549019607838f, 1.0f}, -{1.0f, 0.49019607843137253f, 0.50980392156862742f, 1.0f}, -{1.0f, 0.49411764705882355f, 0.50588235294117645f, 1.0f}, -{1.0f, 0.49803921568627452f, 0.50196078431372548f, 1.0f}, -{1.0f, 0.50196078431372548f, 0.49803921568627452f, 1.0f}, -{1.0f, 0.50588235294117645f, 0.49411764705882355f, 1.0f}, -{1.0f, 0.50980392156862742f, 0.49019607843137258f, 1.0f}, -{1.0f, 0.51372549019607838f, 0.48627450980392162f, 1.0f}, -{1.0f, 0.51764705882352935f, 0.48235294117647065f, 1.0f}, -{1.0f, 0.52156862745098043f, 0.47843137254901957f, 1.0f}, -{1.0f, 0.52549019607843139f, 0.47450980392156861f, 1.0f}, -{1.0f, 0.52941176470588236f, 0.47058823529411764f, 1.0f}, -{1.0f, 0.53333333333333333f, 0.46666666666666667f, 1.0f}, -{1.0f, 0.53725490196078429f, 0.46274509803921571f, 1.0f}, -{1.0f, 0.54117647058823526f, 0.45882352941176474f, 1.0f}, -{1.0f, 0.54509803921568623f, 0.45490196078431377f, 1.0f}, -{1.0f, 0.5490196078431373f, 0.4509803921568627f, 1.0f}, -{1.0f, 0.55294117647058827f, 0.44705882352941173f, 1.0f}, -{1.0f, 0.55686274509803924f, 0.44313725490196076f, 1.0f}, -{1.0f, 0.5607843137254902f, 0.4392156862745098f, 1.0f}, -{1.0f, 0.56470588235294117f, 0.43529411764705883f, 1.0f}, -{1.0f, 0.56862745098039214f, 0.43137254901960786f, 1.0f}, -{1.0f, 0.5725490196078431f, 0.4274509803921569f, 1.0f}, -{1.0f, 0.57647058823529407f, 0.42352941176470593f, 1.0f}, -{1.0f, 0.58039215686274503f, 0.41960784313725497f, 1.0f}, -{1.0f, 0.58431372549019611f, 0.41568627450980389f, 1.0f}, -{1.0f, 0.58823529411764708f, 0.41176470588235292f, 1.0f}, -{1.0f, 0.59215686274509804f, 0.40784313725490196f, 1.0f}, -{1.0f, 0.59607843137254901f, 0.40392156862745099f, 1.0f}, -{1.0f, 0.59999999999999998f, 0.40000000000000002f, 1.0f}, -{1.0f, 0.60392156862745094f, 0.39607843137254906f, 1.0f}, -{1.0f, 0.60784313725490191f, 0.39215686274509809f, 1.0f}, -{1.0f, 0.61176470588235299f, 0.38823529411764701f, 1.0f}, -{1.0f, 0.61568627450980395f, 0.38431372549019605f, 1.0f}, -{1.0f, 0.61960784313725492f, 0.38039215686274508f, 1.0f}, -{1.0f, 0.62352941176470589f, 0.37647058823529411f, 1.0f}, -{1.0f, 0.62745098039215685f, 0.37254901960784315f, 1.0f}, -{1.0f, 0.63137254901960782f, 0.36862745098039218f, 1.0f}, -{1.0f, 0.63529411764705879f, 0.36470588235294121f, 1.0f}, -{1.0f, 0.63921568627450975f, 0.36078431372549025f, 1.0f}, -{1.0f, 0.64313725490196072f, 0.35686274509803928f, 1.0f}, -{1.0f, 0.6470588235294118f, 0.3529411764705882f, 1.0f}, -{1.0f, 0.65098039215686276f, 0.34901960784313724f, 1.0f}, -{1.0f, 0.65490196078431373f, 0.34509803921568627f, 1.0f}, -{1.0f, 0.6588235294117647f, 0.3411764705882353f, 1.0f}, -{1.0f, 0.66274509803921566f, 0.33725490196078434f, 1.0f}, -{1.0f, 0.66666666666666663f, 0.33333333333333337f, 1.0f}, -{1.0f, 0.6705882352941176f, 0.3294117647058824f, 1.0f}, -{1.0f, 0.67450980392156867f, 0.32549019607843133f, 1.0f}, -{1.0f, 0.67843137254901964f, 0.32156862745098036f, 1.0f}, -{1.0f, 0.68235294117647061f, 0.31764705882352939f, 1.0f}, -{1.0f, 0.68627450980392157f, 0.31372549019607843f, 1.0f}, -{1.0f, 0.69019607843137254f, 0.30980392156862746f, 1.0f}, -{1.0f, 0.69411764705882351f, 0.30588235294117649f, 1.0f}, -{1.0f, 0.69803921568627447f, 0.30196078431372553f, 1.0f}, -{1.0f, 0.70196078431372544f, 0.29803921568627456f, 1.0f}, -{1.0f, 0.70588235294117641f, 0.29411764705882359f, 1.0f}, -{1.0f, 0.70980392156862748f, 0.29019607843137252f, 1.0f}, -{1.0f, 0.71372549019607845f, 0.28627450980392155f, 1.0f}, -{1.0f, 0.71764705882352942f, 0.28235294117647058f, 1.0f}, -{1.0f, 0.72156862745098038f, 0.27843137254901962f, 1.0f}, -{1.0f, 0.72549019607843135f, 0.27450980392156865f, 1.0f}, -{1.0f, 0.72941176470588232f, 0.27058823529411768f, 1.0f}, -{1.0f, 0.73333333333333328f, 0.26666666666666672f, 1.0f}, -{1.0f, 0.73725490196078436f, 0.26274509803921564f, 1.0f}, -{1.0f, 0.74117647058823533f, 0.25882352941176467f, 1.0f}, -{1.0f, 0.74509803921568629f, 0.25490196078431371f, 1.0f}, -{1.0f, 0.74901960784313726f, 0.25098039215686274f, 1.0f}, -{1.0f, 0.75294117647058822f, 0.24705882352941178f, 1.0f}, -{1.0f, 0.75686274509803919f, 0.24313725490196081f, 1.0f}, -{1.0f, 0.76078431372549016f, 0.23921568627450984f, 1.0f}, -{1.0f, 0.76470588235294112f, 0.23529411764705888f, 1.0f}, -{1.0f, 0.76862745098039209f, 0.23137254901960791f, 1.0f}, -{1.0f, 0.77254901960784317f, 0.22745098039215683f, 1.0f}, -{1.0f, 0.77647058823529413f, 0.22352941176470587f, 1.0f}, -{1.0f, 0.7803921568627451f, 0.2196078431372549f, 1.0f}, -{1.0f, 0.78431372549019607f, 0.21568627450980393f, 1.0f}, -{1.0f, 0.78823529411764703f, 0.21176470588235297f, 1.0f}, -{1.0f, 0.792156862745098f, 0.207843137254902f, 1.0f}, -{1.0f, 0.79607843137254897f, 0.20392156862745103f, 1.0f}, -{1.0f, 0.80000000000000004f, 0.19999999999999996f, 1.0f}, -{1.0f, 0.80392156862745101f, 0.19607843137254899f, 1.0f}, -{1.0f, 0.80784313725490198f, 0.19215686274509802f, 1.0f}, -{1.0f, 0.81176470588235294f, 0.18823529411764706f, 1.0f}, -{1.0f, 0.81568627450980391f, 0.18431372549019609f, 1.0f}, -{1.0f, 0.81960784313725488f, 0.18039215686274512f, 1.0f}, -{1.0f, 0.82352941176470584f, 0.17647058823529416f, 1.0f}, -{1.0f, 0.82745098039215681f, 0.17254901960784319f, 1.0f}, -{1.0f, 0.83137254901960778f, 0.16862745098039222f, 1.0f}, -{1.0f, 0.83529411764705885f, 0.16470588235294115f, 1.0f}, -{1.0f, 0.83921568627450982f, 0.16078431372549018f, 1.0f}, -{1.0f, 0.84313725490196079f, 0.15686274509803921f, 1.0f}, -{1.0f, 0.84705882352941175f, 0.15294117647058825f, 1.0f}, -{1.0f, 0.85098039215686272f, 0.14901960784313728f, 1.0f}, -{1.0f, 0.85490196078431369f, 0.14509803921568631f, 1.0f}, -{1.0f, 0.85882352941176465f, 0.14117647058823535f, 1.0f}, -{1.0f, 0.86274509803921573f, 0.13725490196078427f, 1.0f}, -{1.0f, 0.8666666666666667f, 0.1333333333333333f, 1.0f}, -{1.0f, 0.87058823529411766f, 0.12941176470588234f, 1.0f}, -{1.0f, 0.87450980392156863f, 0.12549019607843137f, 1.0f}, -{1.0f, 0.8784313725490196f, 0.1215686274509804f, 1.0f}, -{1.0f, 0.88235294117647056f, 0.11764705882352944f, 1.0f}, -{1.0f, 0.88627450980392153f, 0.11372549019607847f, 1.0f}, -{1.0f, 0.8901960784313725f, 0.1098039215686275f, 1.0f}, -{1.0f, 0.89411764705882346f, 0.10588235294117654f, 1.0f}, -{1.0f, 0.89803921568627454f, 0.10196078431372546f, 1.0f}, -{1.0f, 0.90196078431372551f, 0.098039215686274495f, 1.0f}, -{1.0f, 0.90588235294117647f, 0.094117647058823528f, 1.0f}, -{1.0f, 0.90980392156862744f, 0.090196078431372562f, 1.0f}, -{1.0f, 0.9137254901960784f, 0.086274509803921595f, 1.0f}, -{1.0f, 0.91764705882352937f, 0.082352941176470629f, 1.0f}, -{1.0f, 0.92156862745098034f, 0.078431372549019662f, 1.0f}, -{1.0f, 0.92549019607843142f, 0.074509803921568585f, 1.0f}, -{1.0f, 0.92941176470588238f, 0.070588235294117618f, 1.0f}, -{1.0f, 0.93333333333333335f, 0.066666666666666652f, 1.0f}, -{1.0f, 0.93725490196078431f, 0.062745098039215685f, 1.0f}, -{1.0f, 0.94117647058823528f, 0.058823529411764719f, 1.0f}, -{1.0f, 0.94509803921568625f, 0.054901960784313752f, 1.0f}, -{1.0f, 0.94901960784313721f, 0.050980392156862786f, 1.0f}, -{1.0f, 0.95294117647058818f, 0.04705882352941182f, 1.0f}, -{1.0f, 0.95686274509803915f, 0.043137254901960853f, 1.0f}, -{1.0f, 0.96078431372549022f, 0.039215686274509776f, 1.0f}, -{1.0f, 0.96470588235294119f, 0.035294117647058809f, 1.0f}, -{1.0f, 0.96862745098039216f, 0.031372549019607843f, 1.0f}, -{1.0f, 0.97254901960784312f, 0.027450980392156876f, 1.0f}, -{1.0f, 0.97647058823529409f, 0.02352941176470591f, 1.0f}, -{1.0f, 0.98039215686274506f, 0.019607843137254943f, 1.0f}, -{1.0f, 0.98431372549019602f, 0.015686274509803977f, 1.0f}, -{1.0f, 0.9882352941176471f, 0.011764705882352899f, 1.0f}, -{1.0f, 0.99215686274509807f, 0.0078431372549019329f, 1.0f}, -{1.0f, 0.99607843137254903f, 0.0039215686274509665f, 1.0f}, -{1.0f, 1.0f, 0.0f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential2/spring.txt b/extern/tfn/colormaps/sequential2/spring.txt deleted file mode 100644 index 8c8fbbc..0000000 --- a/extern/tfn/colormaps/sequential2/spring.txt +++ /dev/null @@ -1,256 +0,0 @@ -(1.0, 0.0, 1.0, 1.0) -(1.0, 0.0039215686274509803, 0.99607843137254903, 1.0) -(1.0, 0.0078431372549019607, 0.99215686274509807, 1.0) -(1.0, 0.011764705882352941, 0.9882352941176471, 1.0) -(1.0, 0.015686274509803921, 0.98431372549019613, 1.0) -(1.0, 0.019607843137254902, 0.98039215686274506, 1.0) -(1.0, 0.023529411764705882, 0.97647058823529409, 1.0) -(1.0, 0.027450980392156862, 0.97254901960784312, 1.0) -(1.0, 0.031372549019607843, 0.96862745098039216, 1.0) -(1.0, 0.035294117647058823, 0.96470588235294119, 1.0) -(1.0, 0.039215686274509803, 0.96078431372549022, 1.0) -(1.0, 0.043137254901960784, 0.95686274509803926, 1.0) -(1.0, 0.047058823529411764, 0.95294117647058818, 1.0) -(1.0, 0.050980392156862744, 0.94901960784313721, 1.0) -(1.0, 0.054901960784313725, 0.94509803921568625, 1.0) -(1.0, 0.058823529411764705, 0.94117647058823528, 1.0) -(1.0, 0.062745098039215685, 0.93725490196078431, 1.0) -(1.0, 0.066666666666666666, 0.93333333333333335, 1.0) -(1.0, 0.070588235294117646, 0.92941176470588238, 1.0) -(1.0, 0.074509803921568626, 0.92549019607843142, 1.0) -(1.0, 0.078431372549019607, 0.92156862745098045, 1.0) -(1.0, 0.082352941176470587, 0.91764705882352937, 1.0) -(1.0, 0.086274509803921567, 0.9137254901960784, 1.0) -(1.0, 0.090196078431372548, 0.90980392156862744, 1.0) -(1.0, 0.094117647058823528, 0.90588235294117647, 1.0) -(1.0, 0.098039215686274508, 0.90196078431372551, 1.0) -(1.0, 0.10196078431372549, 0.89803921568627454, 1.0) -(1.0, 0.10588235294117647, 0.89411764705882357, 1.0) -(1.0, 0.10980392156862745, 0.8901960784313725, 1.0) -(1.0, 0.11372549019607843, 0.88627450980392153, 1.0) -(1.0, 0.11764705882352941, 0.88235294117647056, 1.0) -(1.0, 0.12156862745098039, 0.8784313725490196, 1.0) -(1.0, 0.12549019607843137, 0.87450980392156863, 1.0) -(1.0, 0.12941176470588234, 0.87058823529411766, 1.0) -(1.0, 0.13333333333333333, 0.8666666666666667, 1.0) -(1.0, 0.13725490196078433, 0.86274509803921573, 1.0) -(1.0, 0.14117647058823529, 0.85882352941176476, 1.0) -(1.0, 0.14509803921568626, 0.8549019607843138, 1.0) -(1.0, 0.14901960784313725, 0.85098039215686272, 1.0) -(1.0, 0.15294117647058825, 0.84705882352941175, 1.0) -(1.0, 0.15686274509803921, 0.84313725490196079, 1.0) -(1.0, 0.16078431372549018, 0.83921568627450982, 1.0) -(1.0, 0.16470588235294117, 0.83529411764705885, 1.0) -(1.0, 0.16862745098039217, 0.83137254901960778, 1.0) -(1.0, 0.17254901960784313, 0.82745098039215681, 1.0) -(1.0, 0.1764705882352941, 0.82352941176470584, 1.0) -(1.0, 0.1803921568627451, 0.81960784313725488, 1.0) -(1.0, 0.18431372549019609, 0.81568627450980391, 1.0) -(1.0, 0.18823529411764706, 0.81176470588235294, 1.0) -(1.0, 0.19215686274509802, 0.80784313725490198, 1.0) -(1.0, 0.19607843137254902, 0.80392156862745101, 1.0) -(1.0, 0.20000000000000001, 0.80000000000000004, 1.0) -(1.0, 0.20392156862745098, 0.79607843137254908, 1.0) -(1.0, 0.20784313725490194, 0.79215686274509811, 1.0) -(1.0, 0.21176470588235294, 0.78823529411764703, 1.0) -(1.0, 0.21568627450980393, 0.78431372549019607, 1.0) -(1.0, 0.2196078431372549, 0.7803921568627451, 1.0) -(1.0, 0.22352941176470587, 0.77647058823529413, 1.0) -(1.0, 0.22745098039215686, 0.77254901960784317, 1.0) -(1.0, 0.23137254901960785, 0.76862745098039209, 1.0) -(1.0, 0.23529411764705882, 0.76470588235294112, 1.0) -(1.0, 0.23921568627450979, 0.76078431372549016, 1.0) -(1.0, 0.24313725490196078, 0.75686274509803919, 1.0) -(1.0, 0.24705882352941178, 0.75294117647058822, 1.0) -(1.0, 0.25098039215686274, 0.74901960784313726, 1.0) -(1.0, 0.25490196078431371, 0.74509803921568629, 1.0) -(1.0, 0.25882352941176467, 0.74117647058823533, 1.0) -(1.0, 0.2627450980392157, 0.73725490196078436, 1.0) -(1.0, 0.26666666666666666, 0.73333333333333339, 1.0) -(1.0, 0.27058823529411763, 0.72941176470588243, 1.0) -(1.0, 0.27450980392156865, 0.72549019607843135, 1.0) -(1.0, 0.27843137254901962, 0.72156862745098038, 1.0) -(1.0, 0.28235294117647058, 0.71764705882352942, 1.0) -(1.0, 0.28627450980392155, 0.71372549019607845, 1.0) -(1.0, 0.29019607843137252, 0.70980392156862748, 1.0) -(1.0, 0.29411764705882354, 0.70588235294117641, 1.0) -(1.0, 0.29803921568627451, 0.70196078431372544, 1.0) -(1.0, 0.30196078431372547, 0.69803921568627447, 1.0) -(1.0, 0.30588235294117649, 0.69411764705882351, 1.0) -(1.0, 0.30980392156862746, 0.69019607843137254, 1.0) -(1.0, 0.31372549019607843, 0.68627450980392157, 1.0) -(1.0, 0.31764705882352939, 0.68235294117647061, 1.0) -(1.0, 0.32156862745098036, 0.67843137254901964, 1.0) -(1.0, 0.32549019607843138, 0.67450980392156867, 1.0) -(1.0, 0.32941176470588235, 0.67058823529411771, 1.0) -(1.0, 0.33333333333333331, 0.66666666666666674, 1.0) -(1.0, 0.33725490196078434, 0.66274509803921566, 1.0) -(1.0, 0.3411764705882353, 0.6588235294117647, 1.0) -(1.0, 0.34509803921568627, 0.65490196078431373, 1.0) -(1.0, 0.34901960784313724, 0.65098039215686276, 1.0) -(1.0, 0.3529411764705882, 0.6470588235294118, 1.0) -(1.0, 0.35686274509803922, 0.64313725490196072, 1.0) -(1.0, 0.36078431372549019, 0.63921568627450975, 1.0) -(1.0, 0.36470588235294116, 0.63529411764705879, 1.0) -(1.0, 0.36862745098039218, 0.63137254901960782, 1.0) -(1.0, 0.37254901960784315, 0.62745098039215685, 1.0) -(1.0, 0.37647058823529411, 0.62352941176470589, 1.0) -(1.0, 0.38039215686274508, 0.61960784313725492, 1.0) -(1.0, 0.38431372549019605, 0.61568627450980395, 1.0) -(1.0, 0.38823529411764707, 0.61176470588235299, 1.0) -(1.0, 0.39215686274509803, 0.60784313725490202, 1.0) -(1.0, 0.396078431372549, 0.60392156862745106, 1.0) -(1.0, 0.40000000000000002, 0.59999999999999998, 1.0) -(1.0, 0.40392156862745099, 0.59607843137254901, 1.0) -(1.0, 0.40784313725490196, 0.59215686274509804, 1.0) -(1.0, 0.41176470588235292, 0.58823529411764708, 1.0) -(1.0, 0.41568627450980389, 0.58431372549019611, 1.0) -(1.0, 0.41960784313725491, 0.58039215686274503, 1.0) -(1.0, 0.42352941176470588, 0.57647058823529407, 1.0) -(1.0, 0.42745098039215684, 0.5725490196078431, 1.0) -(1.0, 0.43137254901960786, 0.56862745098039214, 1.0) -(1.0, 0.43529411764705883, 0.56470588235294117, 1.0) -(1.0, 0.4392156862745098, 0.5607843137254902, 1.0) -(1.0, 0.44313725490196076, 0.55686274509803924, 1.0) -(1.0, 0.44705882352941173, 0.55294117647058827, 1.0) -(1.0, 0.45098039215686275, 0.5490196078431373, 1.0) -(1.0, 0.45490196078431372, 0.54509803921568634, 1.0) -(1.0, 0.45882352941176469, 0.54117647058823537, 1.0) -(1.0, 0.46274509803921571, 0.53725490196078429, 1.0) -(1.0, 0.46666666666666667, 0.53333333333333333, 1.0) -(1.0, 0.47058823529411764, 0.52941176470588236, 1.0) -(1.0, 0.47450980392156861, 0.52549019607843139, 1.0) -(1.0, 0.47843137254901957, 0.52156862745098043, 1.0) -(1.0, 0.4823529411764706, 0.51764705882352935, 1.0) -(1.0, 0.48627450980392156, 0.51372549019607838, 1.0) -(1.0, 0.49019607843137253, 0.50980392156862742, 1.0) -(1.0, 0.49411764705882355, 0.50588235294117645, 1.0) -(1.0, 0.49803921568627452, 0.50196078431372548, 1.0) -(1.0, 0.50196078431372548, 0.49803921568627452, 1.0) -(1.0, 0.50588235294117645, 0.49411764705882355, 1.0) -(1.0, 0.50980392156862742, 0.49019607843137258, 1.0) -(1.0, 0.51372549019607838, 0.48627450980392162, 1.0) -(1.0, 0.51764705882352935, 0.48235294117647065, 1.0) -(1.0, 0.52156862745098043, 0.47843137254901957, 1.0) -(1.0, 0.52549019607843139, 0.47450980392156861, 1.0) -(1.0, 0.52941176470588236, 0.47058823529411764, 1.0) -(1.0, 0.53333333333333333, 0.46666666666666667, 1.0) -(1.0, 0.53725490196078429, 0.46274509803921571, 1.0) -(1.0, 0.54117647058823526, 0.45882352941176474, 1.0) -(1.0, 0.54509803921568623, 0.45490196078431377, 1.0) -(1.0, 0.5490196078431373, 0.4509803921568627, 1.0) -(1.0, 0.55294117647058827, 0.44705882352941173, 1.0) -(1.0, 0.55686274509803924, 0.44313725490196076, 1.0) -(1.0, 0.5607843137254902, 0.4392156862745098, 1.0) -(1.0, 0.56470588235294117, 0.43529411764705883, 1.0) -(1.0, 0.56862745098039214, 0.43137254901960786, 1.0) -(1.0, 0.5725490196078431, 0.4274509803921569, 1.0) -(1.0, 0.57647058823529407, 0.42352941176470593, 1.0) -(1.0, 0.58039215686274503, 0.41960784313725497, 1.0) -(1.0, 0.58431372549019611, 0.41568627450980389, 1.0) -(1.0, 0.58823529411764708, 0.41176470588235292, 1.0) -(1.0, 0.59215686274509804, 0.40784313725490196, 1.0) -(1.0, 0.59607843137254901, 0.40392156862745099, 1.0) -(1.0, 0.59999999999999998, 0.40000000000000002, 1.0) -(1.0, 0.60392156862745094, 0.39607843137254906, 1.0) -(1.0, 0.60784313725490191, 0.39215686274509809, 1.0) -(1.0, 0.61176470588235299, 0.38823529411764701, 1.0) -(1.0, 0.61568627450980395, 0.38431372549019605, 1.0) -(1.0, 0.61960784313725492, 0.38039215686274508, 1.0) -(1.0, 0.62352941176470589, 0.37647058823529411, 1.0) -(1.0, 0.62745098039215685, 0.37254901960784315, 1.0) -(1.0, 0.63137254901960782, 0.36862745098039218, 1.0) -(1.0, 0.63529411764705879, 0.36470588235294121, 1.0) -(1.0, 0.63921568627450975, 0.36078431372549025, 1.0) -(1.0, 0.64313725490196072, 0.35686274509803928, 1.0) -(1.0, 0.6470588235294118, 0.3529411764705882, 1.0) -(1.0, 0.65098039215686276, 0.34901960784313724, 1.0) -(1.0, 0.65490196078431373, 0.34509803921568627, 1.0) -(1.0, 0.6588235294117647, 0.3411764705882353, 1.0) -(1.0, 0.66274509803921566, 0.33725490196078434, 1.0) -(1.0, 0.66666666666666663, 0.33333333333333337, 1.0) -(1.0, 0.6705882352941176, 0.3294117647058824, 1.0) -(1.0, 0.67450980392156867, 0.32549019607843133, 1.0) -(1.0, 0.67843137254901964, 0.32156862745098036, 1.0) -(1.0, 0.68235294117647061, 0.31764705882352939, 1.0) -(1.0, 0.68627450980392157, 0.31372549019607843, 1.0) -(1.0, 0.69019607843137254, 0.30980392156862746, 1.0) -(1.0, 0.69411764705882351, 0.30588235294117649, 1.0) -(1.0, 0.69803921568627447, 0.30196078431372553, 1.0) -(1.0, 0.70196078431372544, 0.29803921568627456, 1.0) -(1.0, 0.70588235294117641, 0.29411764705882359, 1.0) -(1.0, 0.70980392156862748, 0.29019607843137252, 1.0) -(1.0, 0.71372549019607845, 0.28627450980392155, 1.0) -(1.0, 0.71764705882352942, 0.28235294117647058, 1.0) -(1.0, 0.72156862745098038, 0.27843137254901962, 1.0) -(1.0, 0.72549019607843135, 0.27450980392156865, 1.0) -(1.0, 0.72941176470588232, 0.27058823529411768, 1.0) -(1.0, 0.73333333333333328, 0.26666666666666672, 1.0) -(1.0, 0.73725490196078436, 0.26274509803921564, 1.0) -(1.0, 0.74117647058823533, 0.25882352941176467, 1.0) -(1.0, 0.74509803921568629, 0.25490196078431371, 1.0) -(1.0, 0.74901960784313726, 0.25098039215686274, 1.0) -(1.0, 0.75294117647058822, 0.24705882352941178, 1.0) -(1.0, 0.75686274509803919, 0.24313725490196081, 1.0) -(1.0, 0.76078431372549016, 0.23921568627450984, 1.0) -(1.0, 0.76470588235294112, 0.23529411764705888, 1.0) -(1.0, 0.76862745098039209, 0.23137254901960791, 1.0) -(1.0, 0.77254901960784317, 0.22745098039215683, 1.0) -(1.0, 0.77647058823529413, 0.22352941176470587, 1.0) -(1.0, 0.7803921568627451, 0.2196078431372549, 1.0) -(1.0, 0.78431372549019607, 0.21568627450980393, 1.0) -(1.0, 0.78823529411764703, 0.21176470588235297, 1.0) -(1.0, 0.792156862745098, 0.207843137254902, 1.0) -(1.0, 0.79607843137254897, 0.20392156862745103, 1.0) -(1.0, 0.80000000000000004, 0.19999999999999996, 1.0) -(1.0, 0.80392156862745101, 0.19607843137254899, 1.0) -(1.0, 0.80784313725490198, 0.19215686274509802, 1.0) -(1.0, 0.81176470588235294, 0.18823529411764706, 1.0) -(1.0, 0.81568627450980391, 0.18431372549019609, 1.0) -(1.0, 0.81960784313725488, 0.18039215686274512, 1.0) -(1.0, 0.82352941176470584, 0.17647058823529416, 1.0) -(1.0, 0.82745098039215681, 0.17254901960784319, 1.0) -(1.0, 0.83137254901960778, 0.16862745098039222, 1.0) -(1.0, 0.83529411764705885, 0.16470588235294115, 1.0) -(1.0, 0.83921568627450982, 0.16078431372549018, 1.0) -(1.0, 0.84313725490196079, 0.15686274509803921, 1.0) -(1.0, 0.84705882352941175, 0.15294117647058825, 1.0) -(1.0, 0.85098039215686272, 0.14901960784313728, 1.0) -(1.0, 0.85490196078431369, 0.14509803921568631, 1.0) -(1.0, 0.85882352941176465, 0.14117647058823535, 1.0) -(1.0, 0.86274509803921573, 0.13725490196078427, 1.0) -(1.0, 0.8666666666666667, 0.1333333333333333, 1.0) -(1.0, 0.87058823529411766, 0.12941176470588234, 1.0) -(1.0, 0.87450980392156863, 0.12549019607843137, 1.0) -(1.0, 0.8784313725490196, 0.1215686274509804, 1.0) -(1.0, 0.88235294117647056, 0.11764705882352944, 1.0) -(1.0, 0.88627450980392153, 0.11372549019607847, 1.0) -(1.0, 0.8901960784313725, 0.1098039215686275, 1.0) -(1.0, 0.89411764705882346, 0.10588235294117654, 1.0) -(1.0, 0.89803921568627454, 0.10196078431372546, 1.0) -(1.0, 0.90196078431372551, 0.098039215686274495, 1.0) -(1.0, 0.90588235294117647, 0.094117647058823528, 1.0) -(1.0, 0.90980392156862744, 0.090196078431372562, 1.0) -(1.0, 0.9137254901960784, 0.086274509803921595, 1.0) -(1.0, 0.91764705882352937, 0.082352941176470629, 1.0) -(1.0, 0.92156862745098034, 0.078431372549019662, 1.0) -(1.0, 0.92549019607843142, 0.074509803921568585, 1.0) -(1.0, 0.92941176470588238, 0.070588235294117618, 1.0) -(1.0, 0.93333333333333335, 0.066666666666666652, 1.0) -(1.0, 0.93725490196078431, 0.062745098039215685, 1.0) -(1.0, 0.94117647058823528, 0.058823529411764719, 1.0) -(1.0, 0.94509803921568625, 0.054901960784313752, 1.0) -(1.0, 0.94901960784313721, 0.050980392156862786, 1.0) -(1.0, 0.95294117647058818, 0.04705882352941182, 1.0) -(1.0, 0.95686274509803915, 0.043137254901960853, 1.0) -(1.0, 0.96078431372549022, 0.039215686274509776, 1.0) -(1.0, 0.96470588235294119, 0.035294117647058809, 1.0) -(1.0, 0.96862745098039216, 0.031372549019607843, 1.0) -(1.0, 0.97254901960784312, 0.027450980392156876, 1.0) -(1.0, 0.97647058823529409, 0.02352941176470591, 1.0) -(1.0, 0.98039215686274506, 0.019607843137254943, 1.0) -(1.0, 0.98431372549019602, 0.015686274509803977, 1.0) -(1.0, 0.9882352941176471, 0.011764705882352899, 1.0) -(1.0, 0.99215686274509807, 0.0078431372549019329, 1.0) -(1.0, 0.99607843137254903, 0.0039215686274509665, 1.0) -(1.0, 1.0, 0.0, 1.0) diff --git a/extern/tfn/colormaps/sequential2/summer.cpp b/extern/tfn/colormaps/sequential2/summer.cpp deleted file mode 100644 index 24cb143..0000000 --- a/extern/tfn/colormaps/sequential2/summer.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential2_summer; -} -const std::vector colormap::data_sequential2_summer = /* NOLINT(cert-err58-cpp) */ -{ -{0.0f, 0.5f, 0.40000000000000002f, 1.0f}, -{0.0039215686274509803f, 0.50196078431372548f, 0.40000000000000002f, 1.0f}, -{0.0078431372549019607f, 0.50392156862745097f, 0.40000000000000002f, 1.0f}, -{0.011764705882352941f, 0.50588235294117645f, 0.40000000000000002f, 1.0f}, -{0.015686274509803921f, 0.50784313725490193f, 0.40000000000000002f, 1.0f}, -{0.019607843137254902f, 0.50980392156862742f, 0.40000000000000002f, 1.0f}, -{0.023529411764705882f, 0.5117647058823529f, 0.40000000000000002f, 1.0f}, -{0.027450980392156862f, 0.51372549019607838f, 0.40000000000000002f, 1.0f}, -{0.031372549019607843f, 0.51568627450980387f, 0.40000000000000002f, 1.0f}, -{0.035294117647058823f, 0.51764705882352946f, 0.40000000000000002f, 1.0f}, -{0.039215686274509803f, 0.51960784313725494f, 0.40000000000000002f, 1.0f}, -{0.043137254901960784f, 0.52156862745098043f, 0.40000000000000002f, 1.0f}, -{0.047058823529411764f, 0.52352941176470591f, 0.40000000000000002f, 1.0f}, -{0.050980392156862744f, 0.52549019607843139f, 0.40000000000000002f, 1.0f}, -{0.054901960784313725f, 0.52745098039215688f, 0.40000000000000002f, 1.0f}, -{0.058823529411764705f, 0.52941176470588236f, 0.40000000000000002f, 1.0f}, -{0.062745098039215685f, 0.53137254901960784f, 0.40000000000000002f, 1.0f}, -{0.066666666666666666f, 0.53333333333333333f, 0.40000000000000002f, 1.0f}, -{0.070588235294117646f, 0.53529411764705881f, 0.40000000000000002f, 1.0f}, -{0.074509803921568626f, 0.53725490196078429f, 0.40000000000000002f, 1.0f}, -{0.078431372549019607f, 0.53921568627450978f, 0.40000000000000002f, 1.0f}, -{0.082352941176470587f, 0.54117647058823526f, 0.40000000000000002f, 1.0f}, -{0.086274509803921567f, 0.54313725490196074f, 0.40000000000000002f, 1.0f}, -{0.090196078431372548f, 0.54509803921568623f, 0.40000000000000002f, 1.0f}, -{0.094117647058823528f, 0.54705882352941182f, 0.40000000000000002f, 1.0f}, -{0.098039215686274508f, 0.5490196078431373f, 0.40000000000000002f, 1.0f}, -{0.10196078431372549f, 0.55098039215686279f, 0.40000000000000002f, 1.0f}, -{0.10588235294117647f, 0.55294117647058827f, 0.40000000000000002f, 1.0f}, -{0.10980392156862745f, 0.55490196078431375f, 0.40000000000000002f, 1.0f}, -{0.11372549019607843f, 0.55686274509803924f, 0.40000000000000002f, 1.0f}, -{0.11764705882352941f, 0.55882352941176472f, 0.40000000000000002f, 1.0f}, -{0.12156862745098039f, 0.5607843137254902f, 0.40000000000000002f, 1.0f}, -{0.12549019607843137f, 0.56274509803921569f, 0.40000000000000002f, 1.0f}, -{0.12941176470588234f, 0.56470588235294117f, 0.40000000000000002f, 1.0f}, -{0.13333333333333333f, 0.56666666666666665f, 0.40000000000000002f, 1.0f}, -{0.13725490196078433f, 0.56862745098039214f, 0.40000000000000002f, 1.0f}, -{0.14117647058823529f, 0.57058823529411762f, 0.40000000000000002f, 1.0f}, -{0.14509803921568626f, 0.5725490196078431f, 0.40000000000000002f, 1.0f}, -{0.14901960784313725f, 0.57450980392156858f, 0.40000000000000002f, 1.0f}, -{0.15294117647058825f, 0.57647058823529407f, 0.40000000000000002f, 1.0f}, -{0.15686274509803921f, 0.57843137254901955f, 0.40000000000000002f, 1.0f}, -{0.16078431372549018f, 0.58039215686274503f, 0.40000000000000002f, 1.0f}, -{0.16470588235294117f, 0.58235294117647063f, 0.40000000000000002f, 1.0f}, -{0.16862745098039217f, 0.58431372549019611f, 0.40000000000000002f, 1.0f}, -{0.17254901960784313f, 0.5862745098039216f, 0.40000000000000002f, 1.0f}, -{0.1764705882352941f, 0.58823529411764708f, 0.40000000000000002f, 1.0f}, -{0.1803921568627451f, 0.59019607843137256f, 0.40000000000000002f, 1.0f}, -{0.18431372549019609f, 0.59215686274509804f, 0.40000000000000002f, 1.0f}, -{0.18823529411764706f, 0.59411764705882353f, 0.40000000000000002f, 1.0f}, -{0.19215686274509802f, 0.59607843137254901f, 0.40000000000000002f, 1.0f}, -{0.19607843137254902f, 0.59803921568627449f, 0.40000000000000002f, 1.0f}, -{0.20000000000000001f, 0.59999999999999998f, 0.40000000000000002f, 1.0f}, -{0.20392156862745098f, 0.60196078431372546f, 0.40000000000000002f, 1.0f}, -{0.20784313725490194f, 0.60392156862745094f, 0.40000000000000002f, 1.0f}, -{0.21176470588235294f, 0.60588235294117643f, 0.40000000000000002f, 1.0f}, -{0.21568627450980393f, 0.60784313725490202f, 0.40000000000000002f, 1.0f}, -{0.2196078431372549f, 0.6098039215686275f, 0.40000000000000002f, 1.0f}, -{0.22352941176470587f, 0.61176470588235299f, 0.40000000000000002f, 1.0f}, -{0.22745098039215686f, 0.61372549019607847f, 0.40000000000000002f, 1.0f}, -{0.23137254901960785f, 0.61568627450980395f, 0.40000000000000002f, 1.0f}, -{0.23529411764705882f, 0.61764705882352944f, 0.40000000000000002f, 1.0f}, -{0.23921568627450979f, 0.61960784313725492f, 0.40000000000000002f, 1.0f}, -{0.24313725490196078f, 0.6215686274509804f, 0.40000000000000002f, 1.0f}, -{0.24705882352941178f, 0.62352941176470589f, 0.40000000000000002f, 1.0f}, -{0.25098039215686274f, 0.62549019607843137f, 0.40000000000000002f, 1.0f}, -{0.25490196078431371f, 0.62745098039215685f, 0.40000000000000002f, 1.0f}, -{0.25882352941176467f, 0.62941176470588234f, 0.40000000000000002f, 1.0f}, -{0.2627450980392157f, 0.63137254901960782f, 0.40000000000000002f, 1.0f}, -{0.26666666666666666f, 0.6333333333333333f, 0.40000000000000002f, 1.0f}, -{0.27058823529411763f, 0.63529411764705879f, 0.40000000000000002f, 1.0f}, -{0.27450980392156865f, 0.63725490196078427f, 0.40000000000000002f, 1.0f}, -{0.27843137254901962f, 0.63921568627450975f, 0.40000000000000002f, 1.0f}, -{0.28235294117647058f, 0.64117647058823524f, 0.40000000000000002f, 1.0f}, -{0.28627450980392155f, 0.64313725490196072f, 0.40000000000000002f, 1.0f}, -{0.29019607843137252f, 0.6450980392156862f, 0.40000000000000002f, 1.0f}, -{0.29411764705882354f, 0.6470588235294118f, 0.40000000000000002f, 1.0f}, -{0.29803921568627451f, 0.64901960784313728f, 0.40000000000000002f, 1.0f}, -{0.30196078431372547f, 0.65098039215686276f, 0.40000000000000002f, 1.0f}, -{0.30588235294117649f, 0.65294117647058825f, 0.40000000000000002f, 1.0f}, -{0.30980392156862746f, 0.65490196078431373f, 0.40000000000000002f, 1.0f}, -{0.31372549019607843f, 0.65686274509803921f, 0.40000000000000002f, 1.0f}, -{0.31764705882352939f, 0.6588235294117647f, 0.40000000000000002f, 1.0f}, -{0.32156862745098036f, 0.66078431372549018f, 0.40000000000000002f, 1.0f}, -{0.32549019607843138f, 0.66274509803921566f, 0.40000000000000002f, 1.0f}, -{0.32941176470588235f, 0.66470588235294115f, 0.40000000000000002f, 1.0f}, -{0.33333333333333331f, 0.66666666666666663f, 0.40000000000000002f, 1.0f}, -{0.33725490196078434f, 0.66862745098039222f, 0.40000000000000002f, 1.0f}, -{0.3411764705882353f, 0.67058823529411771f, 0.40000000000000002f, 1.0f}, -{0.34509803921568627f, 0.67254901960784319f, 0.40000000000000002f, 1.0f}, -{0.34901960784313724f, 0.67450980392156867f, 0.40000000000000002f, 1.0f}, -{0.3529411764705882f, 0.67647058823529416f, 0.40000000000000002f, 1.0f}, -{0.35686274509803922f, 0.67843137254901964f, 0.40000000000000002f, 1.0f}, -{0.36078431372549019f, 0.68039215686274512f, 0.40000000000000002f, 1.0f}, -{0.36470588235294116f, 0.68235294117647061f, 0.40000000000000002f, 1.0f}, -{0.36862745098039218f, 0.68431372549019609f, 0.40000000000000002f, 1.0f}, -{0.37254901960784315f, 0.68627450980392157f, 0.40000000000000002f, 1.0f}, -{0.37647058823529411f, 0.68823529411764706f, 0.40000000000000002f, 1.0f}, -{0.38039215686274508f, 0.69019607843137254f, 0.40000000000000002f, 1.0f}, -{0.38431372549019605f, 0.69215686274509802f, 0.40000000000000002f, 1.0f}, -{0.38823529411764707f, 0.69411764705882351f, 0.40000000000000002f, 1.0f}, -{0.39215686274509803f, 0.69607843137254899f, 0.40000000000000002f, 1.0f}, -{0.396078431372549f, 0.69803921568627447f, 0.40000000000000002f, 1.0f}, -{0.40000000000000002f, 0.69999999999999996f, 0.40000000000000002f, 1.0f}, -{0.40392156862745099f, 0.70196078431372544f, 0.40000000000000002f, 1.0f}, -{0.40784313725490196f, 0.70392156862745092f, 0.40000000000000002f, 1.0f}, -{0.41176470588235292f, 0.70588235294117641f, 0.40000000000000002f, 1.0f}, -{0.41568627450980389f, 0.70784313725490189f, 0.40000000000000002f, 1.0f}, -{0.41960784313725491f, 0.70980392156862748f, 0.40000000000000002f, 1.0f}, -{0.42352941176470588f, 0.71176470588235297f, 0.40000000000000002f, 1.0f}, -{0.42745098039215684f, 0.71372549019607845f, 0.40000000000000002f, 1.0f}, -{0.43137254901960786f, 0.71568627450980393f, 0.40000000000000002f, 1.0f}, -{0.43529411764705883f, 0.71764705882352942f, 0.40000000000000002f, 1.0f}, -{0.4392156862745098f, 0.7196078431372549f, 0.40000000000000002f, 1.0f}, -{0.44313725490196076f, 0.72156862745098038f, 0.40000000000000002f, 1.0f}, -{0.44705882352941173f, 0.72352941176470587f, 0.40000000000000002f, 1.0f}, -{0.45098039215686275f, 0.72549019607843135f, 0.40000000000000002f, 1.0f}, -{0.45490196078431372f, 0.72745098039215683f, 0.40000000000000002f, 1.0f}, -{0.45882352941176469f, 0.72941176470588232f, 0.40000000000000002f, 1.0f}, -{0.46274509803921571f, 0.73137254901960791f, 0.40000000000000002f, 1.0f}, -{0.46666666666666667f, 0.73333333333333339f, 0.40000000000000002f, 1.0f}, -{0.47058823529411764f, 0.73529411764705888f, 0.40000000000000002f, 1.0f}, -{0.47450980392156861f, 0.73725490196078436f, 0.40000000000000002f, 1.0f}, -{0.47843137254901957f, 0.73921568627450984f, 0.40000000000000002f, 1.0f}, -{0.4823529411764706f, 0.74117647058823533f, 0.40000000000000002f, 1.0f}, -{0.48627450980392156f, 0.74313725490196081f, 0.40000000000000002f, 1.0f}, -{0.49019607843137253f, 0.74509803921568629f, 0.40000000000000002f, 1.0f}, -{0.49411764705882355f, 0.74705882352941178f, 0.40000000000000002f, 1.0f}, -{0.49803921568627452f, 0.74901960784313726f, 0.40000000000000002f, 1.0f}, -{0.50196078431372548f, 0.75098039215686274f, 0.40000000000000002f, 1.0f}, -{0.50588235294117645f, 0.75294117647058822f, 0.40000000000000002f, 1.0f}, -{0.50980392156862742f, 0.75490196078431371f, 0.40000000000000002f, 1.0f}, -{0.51372549019607838f, 0.75686274509803919f, 0.40000000000000002f, 1.0f}, -{0.51764705882352935f, 0.75882352941176467f, 0.40000000000000002f, 1.0f}, -{0.52156862745098043f, 0.76078431372549016f, 0.40000000000000002f, 1.0f}, -{0.52549019607843139f, 0.76274509803921564f, 0.40000000000000002f, 1.0f}, -{0.52941176470588236f, 0.76470588235294112f, 0.40000000000000002f, 1.0f}, -{0.53333333333333333f, 0.76666666666666661f, 0.40000000000000002f, 1.0f}, -{0.53725490196078429f, 0.76862745098039209f, 0.40000000000000002f, 1.0f}, -{0.54117647058823526f, 0.77058823529411757f, 0.40000000000000002f, 1.0f}, -{0.54509803921568623f, 0.77254901960784306f, 0.40000000000000002f, 1.0f}, -{0.5490196078431373f, 0.77450980392156865f, 0.40000000000000002f, 1.0f}, -{0.55294117647058827f, 0.77647058823529413f, 0.40000000000000002f, 1.0f}, -{0.55686274509803924f, 0.77843137254901962f, 0.40000000000000002f, 1.0f}, -{0.5607843137254902f, 0.7803921568627451f, 0.40000000000000002f, 1.0f}, -{0.56470588235294117f, 0.78235294117647058f, 0.40000000000000002f, 1.0f}, -{0.56862745098039214f, 0.78431372549019607f, 0.40000000000000002f, 1.0f}, -{0.5725490196078431f, 0.78627450980392155f, 0.40000000000000002f, 1.0f}, -{0.57647058823529407f, 0.78823529411764703f, 0.40000000000000002f, 1.0f}, -{0.58039215686274503f, 0.79019607843137252f, 0.40000000000000002f, 1.0f}, -{0.58431372549019611f, 0.79215686274509811f, 0.40000000000000002f, 1.0f}, -{0.58823529411764708f, 0.79411764705882359f, 0.40000000000000002f, 1.0f}, -{0.59215686274509804f, 0.79607843137254908f, 0.40000000000000002f, 1.0f}, -{0.59607843137254901f, 0.79803921568627456f, 0.40000000000000002f, 1.0f}, -{0.59999999999999998f, 0.80000000000000004f, 0.40000000000000002f, 1.0f}, -{0.60392156862745094f, 0.80196078431372553f, 0.40000000000000002f, 1.0f}, -{0.60784313725490191f, 0.80392156862745101f, 0.40000000000000002f, 1.0f}, -{0.61176470588235299f, 0.80588235294117649f, 0.40000000000000002f, 1.0f}, -{0.61568627450980395f, 0.80784313725490198f, 0.40000000000000002f, 1.0f}, -{0.61960784313725492f, 0.80980392156862746f, 0.40000000000000002f, 1.0f}, -{0.62352941176470589f, 0.81176470588235294f, 0.40000000000000002f, 1.0f}, -{0.62745098039215685f, 0.81372549019607843f, 0.40000000000000002f, 1.0f}, -{0.63137254901960782f, 0.81568627450980391f, 0.40000000000000002f, 1.0f}, -{0.63529411764705879f, 0.81764705882352939f, 0.40000000000000002f, 1.0f}, -{0.63921568627450975f, 0.81960784313725488f, 0.40000000000000002f, 1.0f}, -{0.64313725490196072f, 0.82156862745098036f, 0.40000000000000002f, 1.0f}, -{0.6470588235294118f, 0.82352941176470584f, 0.40000000000000002f, 1.0f}, -{0.65098039215686276f, 0.82549019607843133f, 0.40000000000000002f, 1.0f}, -{0.65490196078431373f, 0.82745098039215681f, 0.40000000000000002f, 1.0f}, -{0.6588235294117647f, 0.82941176470588229f, 0.40000000000000002f, 1.0f}, -{0.66274509803921566f, 0.83137254901960778f, 0.40000000000000002f, 1.0f}, -{0.66666666666666663f, 0.83333333333333326f, 0.40000000000000002f, 1.0f}, -{0.6705882352941176f, 0.83529411764705874f, 0.40000000000000002f, 1.0f}, -{0.67450980392156867f, 0.83725490196078434f, 0.40000000000000002f, 1.0f}, -{0.67843137254901964f, 0.83921568627450982f, 0.40000000000000002f, 1.0f}, -{0.68235294117647061f, 0.8411764705882353f, 0.40000000000000002f, 1.0f}, -{0.68627450980392157f, 0.84313725490196079f, 0.40000000000000002f, 1.0f}, -{0.69019607843137254f, 0.84509803921568627f, 0.40000000000000002f, 1.0f}, -{0.69411764705882351f, 0.84705882352941175f, 0.40000000000000002f, 1.0f}, -{0.69803921568627447f, 0.84901960784313724f, 0.40000000000000002f, 1.0f}, -{0.70196078431372544f, 0.85098039215686272f, 0.40000000000000002f, 1.0f}, -{0.70588235294117641f, 0.8529411764705882f, 0.40000000000000002f, 1.0f}, -{0.70980392156862748f, 0.8549019607843138f, 0.40000000000000002f, 1.0f}, -{0.71372549019607845f, 0.85686274509803928f, 0.40000000000000002f, 1.0f}, -{0.71764705882352942f, 0.85882352941176476f, 0.40000000000000002f, 1.0f}, -{0.72156862745098038f, 0.86078431372549025f, 0.40000000000000002f, 1.0f}, -{0.72549019607843135f, 0.86274509803921573f, 0.40000000000000002f, 1.0f}, -{0.72941176470588232f, 0.86470588235294121f, 0.40000000000000002f, 1.0f}, -{0.73333333333333328f, 0.8666666666666667f, 0.40000000000000002f, 1.0f}, -{0.73725490196078436f, 0.86862745098039218f, 0.40000000000000002f, 1.0f}, -{0.74117647058823533f, 0.87058823529411766f, 0.40000000000000002f, 1.0f}, -{0.74509803921568629f, 0.87254901960784315f, 0.40000000000000002f, 1.0f}, -{0.74901960784313726f, 0.87450980392156863f, 0.40000000000000002f, 1.0f}, -{0.75294117647058822f, 0.87647058823529411f, 0.40000000000000002f, 1.0f}, -{0.75686274509803919f, 0.8784313725490196f, 0.40000000000000002f, 1.0f}, -{0.76078431372549016f, 0.88039215686274508f, 0.40000000000000002f, 1.0f}, -{0.76470588235294112f, 0.88235294117647056f, 0.40000000000000002f, 1.0f}, -{0.76862745098039209f, 0.88431372549019605f, 0.40000000000000002f, 1.0f}, -{0.77254901960784317f, 0.88627450980392153f, 0.40000000000000002f, 1.0f}, -{0.77647058823529413f, 0.88823529411764701f, 0.40000000000000002f, 1.0f}, -{0.7803921568627451f, 0.8901960784313725f, 0.40000000000000002f, 1.0f}, -{0.78431372549019607f, 0.89215686274509798f, 0.40000000000000002f, 1.0f}, -{0.78823529411764703f, 0.89411764705882346f, 0.40000000000000002f, 1.0f}, -{0.792156862745098f, 0.89607843137254894f, 0.40000000000000002f, 1.0f}, -{0.79607843137254897f, 0.89803921568627443f, 0.40000000000000002f, 1.0f}, -{0.80000000000000004f, 0.90000000000000002f, 0.40000000000000002f, 1.0f}, -{0.80392156862745101f, 0.90196078431372551f, 0.40000000000000002f, 1.0f}, -{0.80784313725490198f, 0.90392156862745099f, 0.40000000000000002f, 1.0f}, -{0.81176470588235294f, 0.90588235294117647f, 0.40000000000000002f, 1.0f}, -{0.81568627450980391f, 0.90784313725490196f, 0.40000000000000002f, 1.0f}, -{0.81960784313725488f, 0.90980392156862744f, 0.40000000000000002f, 1.0f}, -{0.82352941176470584f, 0.91176470588235292f, 0.40000000000000002f, 1.0f}, -{0.82745098039215681f, 0.9137254901960784f, 0.40000000000000002f, 1.0f}, -{0.83137254901960778f, 0.91568627450980389f, 0.40000000000000002f, 1.0f}, -{0.83529411764705885f, 0.91764705882352948f, 0.40000000000000002f, 1.0f}, -{0.83921568627450982f, 0.91960784313725497f, 0.40000000000000002f, 1.0f}, -{0.84313725490196079f, 0.92156862745098045f, 0.40000000000000002f, 1.0f}, -{0.84705882352941175f, 0.92352941176470593f, 0.40000000000000002f, 1.0f}, -{0.85098039215686272f, 0.92549019607843142f, 0.40000000000000002f, 1.0f}, -{0.85490196078431369f, 0.9274509803921569f, 0.40000000000000002f, 1.0f}, -{0.85882352941176465f, 0.92941176470588238f, 0.40000000000000002f, 1.0f}, -{0.86274509803921573f, 0.93137254901960786f, 0.40000000000000002f, 1.0f}, -{0.8666666666666667f, 0.93333333333333335f, 0.40000000000000002f, 1.0f}, -{0.87058823529411766f, 0.93529411764705883f, 0.40000000000000002f, 1.0f}, -{0.87450980392156863f, 0.93725490196078431f, 0.40000000000000002f, 1.0f}, -{0.8784313725490196f, 0.9392156862745098f, 0.40000000000000002f, 1.0f}, -{0.88235294117647056f, 0.94117647058823528f, 0.40000000000000002f, 1.0f}, -{0.88627450980392153f, 0.94313725490196076f, 0.40000000000000002f, 1.0f}, -{0.8901960784313725f, 0.94509803921568625f, 0.40000000000000002f, 1.0f}, -{0.89411764705882346f, 0.94705882352941173f, 0.40000000000000002f, 1.0f}, -{0.89803921568627454f, 0.94901960784313721f, 0.40000000000000002f, 1.0f}, -{0.90196078431372551f, 0.9509803921568627f, 0.40000000000000002f, 1.0f}, -{0.90588235294117647f, 0.95294117647058818f, 0.40000000000000002f, 1.0f}, -{0.90980392156862744f, 0.95490196078431366f, 0.40000000000000002f, 1.0f}, -{0.9137254901960784f, 0.95686274509803915f, 0.40000000000000002f, 1.0f}, -{0.91764705882352937f, 0.95882352941176463f, 0.40000000000000002f, 1.0f}, -{0.92156862745098034f, 0.96078431372549011f, 0.40000000000000002f, 1.0f}, -{0.92549019607843142f, 0.96274509803921571f, 0.40000000000000002f, 1.0f}, -{0.92941176470588238f, 0.96470588235294119f, 0.40000000000000002f, 1.0f}, -{0.93333333333333335f, 0.96666666666666667f, 0.40000000000000002f, 1.0f}, -{0.93725490196078431f, 0.96862745098039216f, 0.40000000000000002f, 1.0f}, -{0.94117647058823528f, 0.97058823529411764f, 0.40000000000000002f, 1.0f}, -{0.94509803921568625f, 0.97254901960784312f, 0.40000000000000002f, 1.0f}, -{0.94901960784313721f, 0.97450980392156861f, 0.40000000000000002f, 1.0f}, -{0.95294117647058818f, 0.97647058823529409f, 0.40000000000000002f, 1.0f}, -{0.95686274509803915f, 0.97843137254901957f, 0.40000000000000002f, 1.0f}, -{0.96078431372549022f, 0.98039215686274517f, 0.40000000000000002f, 1.0f}, -{0.96470588235294119f, 0.98235294117647065f, 0.40000000000000002f, 1.0f}, -{0.96862745098039216f, 0.98431372549019613f, 0.40000000000000002f, 1.0f}, -{0.97254901960784312f, 0.98627450980392162f, 0.40000000000000002f, 1.0f}, -{0.97647058823529409f, 0.9882352941176471f, 0.40000000000000002f, 1.0f}, -{0.98039215686274506f, 0.99019607843137258f, 0.40000000000000002f, 1.0f}, -{0.98431372549019602f, 0.99215686274509807f, 0.40000000000000002f, 1.0f}, -{0.9882352941176471f, 0.99411764705882355f, 0.40000000000000002f, 1.0f}, -{0.99215686274509807f, 0.99607843137254903f, 0.40000000000000002f, 1.0f}, -{0.99607843137254903f, 0.99803921568627452f, 0.40000000000000002f, 1.0f}, -{1.0f, 1.0f, 0.40000000000000002f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential2/summer.txt b/extern/tfn/colormaps/sequential2/summer.txt deleted file mode 100644 index 833b1d6..0000000 --- a/extern/tfn/colormaps/sequential2/summer.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.0, 0.5, 0.40000000000000002, 1.0) -(0.0039215686274509803, 0.50196078431372548, 0.40000000000000002, 1.0) -(0.0078431372549019607, 0.50392156862745097, 0.40000000000000002, 1.0) -(0.011764705882352941, 0.50588235294117645, 0.40000000000000002, 1.0) -(0.015686274509803921, 0.50784313725490193, 0.40000000000000002, 1.0) -(0.019607843137254902, 0.50980392156862742, 0.40000000000000002, 1.0) -(0.023529411764705882, 0.5117647058823529, 0.40000000000000002, 1.0) -(0.027450980392156862, 0.51372549019607838, 0.40000000000000002, 1.0) -(0.031372549019607843, 0.51568627450980387, 0.40000000000000002, 1.0) -(0.035294117647058823, 0.51764705882352946, 0.40000000000000002, 1.0) -(0.039215686274509803, 0.51960784313725494, 0.40000000000000002, 1.0) -(0.043137254901960784, 0.52156862745098043, 0.40000000000000002, 1.0) -(0.047058823529411764, 0.52352941176470591, 0.40000000000000002, 1.0) -(0.050980392156862744, 0.52549019607843139, 0.40000000000000002, 1.0) -(0.054901960784313725, 0.52745098039215688, 0.40000000000000002, 1.0) -(0.058823529411764705, 0.52941176470588236, 0.40000000000000002, 1.0) -(0.062745098039215685, 0.53137254901960784, 0.40000000000000002, 1.0) -(0.066666666666666666, 0.53333333333333333, 0.40000000000000002, 1.0) -(0.070588235294117646, 0.53529411764705881, 0.40000000000000002, 1.0) -(0.074509803921568626, 0.53725490196078429, 0.40000000000000002, 1.0) -(0.078431372549019607, 0.53921568627450978, 0.40000000000000002, 1.0) -(0.082352941176470587, 0.54117647058823526, 0.40000000000000002, 1.0) -(0.086274509803921567, 0.54313725490196074, 0.40000000000000002, 1.0) -(0.090196078431372548, 0.54509803921568623, 0.40000000000000002, 1.0) -(0.094117647058823528, 0.54705882352941182, 0.40000000000000002, 1.0) -(0.098039215686274508, 0.5490196078431373, 0.40000000000000002, 1.0) -(0.10196078431372549, 0.55098039215686279, 0.40000000000000002, 1.0) -(0.10588235294117647, 0.55294117647058827, 0.40000000000000002, 1.0) -(0.10980392156862745, 0.55490196078431375, 0.40000000000000002, 1.0) -(0.11372549019607843, 0.55686274509803924, 0.40000000000000002, 1.0) -(0.11764705882352941, 0.55882352941176472, 0.40000000000000002, 1.0) -(0.12156862745098039, 0.5607843137254902, 0.40000000000000002, 1.0) -(0.12549019607843137, 0.56274509803921569, 0.40000000000000002, 1.0) -(0.12941176470588234, 0.56470588235294117, 0.40000000000000002, 1.0) -(0.13333333333333333, 0.56666666666666665, 0.40000000000000002, 1.0) -(0.13725490196078433, 0.56862745098039214, 0.40000000000000002, 1.0) -(0.14117647058823529, 0.57058823529411762, 0.40000000000000002, 1.0) -(0.14509803921568626, 0.5725490196078431, 0.40000000000000002, 1.0) -(0.14901960784313725, 0.57450980392156858, 0.40000000000000002, 1.0) -(0.15294117647058825, 0.57647058823529407, 0.40000000000000002, 1.0) -(0.15686274509803921, 0.57843137254901955, 0.40000000000000002, 1.0) -(0.16078431372549018, 0.58039215686274503, 0.40000000000000002, 1.0) -(0.16470588235294117, 0.58235294117647063, 0.40000000000000002, 1.0) -(0.16862745098039217, 0.58431372549019611, 0.40000000000000002, 1.0) -(0.17254901960784313, 0.5862745098039216, 0.40000000000000002, 1.0) -(0.1764705882352941, 0.58823529411764708, 0.40000000000000002, 1.0) -(0.1803921568627451, 0.59019607843137256, 0.40000000000000002, 1.0) -(0.18431372549019609, 0.59215686274509804, 0.40000000000000002, 1.0) -(0.18823529411764706, 0.59411764705882353, 0.40000000000000002, 1.0) -(0.19215686274509802, 0.59607843137254901, 0.40000000000000002, 1.0) -(0.19607843137254902, 0.59803921568627449, 0.40000000000000002, 1.0) -(0.20000000000000001, 0.59999999999999998, 0.40000000000000002, 1.0) -(0.20392156862745098, 0.60196078431372546, 0.40000000000000002, 1.0) -(0.20784313725490194, 0.60392156862745094, 0.40000000000000002, 1.0) -(0.21176470588235294, 0.60588235294117643, 0.40000000000000002, 1.0) -(0.21568627450980393, 0.60784313725490202, 0.40000000000000002, 1.0) -(0.2196078431372549, 0.6098039215686275, 0.40000000000000002, 1.0) -(0.22352941176470587, 0.61176470588235299, 0.40000000000000002, 1.0) -(0.22745098039215686, 0.61372549019607847, 0.40000000000000002, 1.0) -(0.23137254901960785, 0.61568627450980395, 0.40000000000000002, 1.0) -(0.23529411764705882, 0.61764705882352944, 0.40000000000000002, 1.0) -(0.23921568627450979, 0.61960784313725492, 0.40000000000000002, 1.0) -(0.24313725490196078, 0.6215686274509804, 0.40000000000000002, 1.0) -(0.24705882352941178, 0.62352941176470589, 0.40000000000000002, 1.0) -(0.25098039215686274, 0.62549019607843137, 0.40000000000000002, 1.0) -(0.25490196078431371, 0.62745098039215685, 0.40000000000000002, 1.0) -(0.25882352941176467, 0.62941176470588234, 0.40000000000000002, 1.0) -(0.2627450980392157, 0.63137254901960782, 0.40000000000000002, 1.0) -(0.26666666666666666, 0.6333333333333333, 0.40000000000000002, 1.0) -(0.27058823529411763, 0.63529411764705879, 0.40000000000000002, 1.0) -(0.27450980392156865, 0.63725490196078427, 0.40000000000000002, 1.0) -(0.27843137254901962, 0.63921568627450975, 0.40000000000000002, 1.0) -(0.28235294117647058, 0.64117647058823524, 0.40000000000000002, 1.0) -(0.28627450980392155, 0.64313725490196072, 0.40000000000000002, 1.0) -(0.29019607843137252, 0.6450980392156862, 0.40000000000000002, 1.0) -(0.29411764705882354, 0.6470588235294118, 0.40000000000000002, 1.0) -(0.29803921568627451, 0.64901960784313728, 0.40000000000000002, 1.0) -(0.30196078431372547, 0.65098039215686276, 0.40000000000000002, 1.0) -(0.30588235294117649, 0.65294117647058825, 0.40000000000000002, 1.0) -(0.30980392156862746, 0.65490196078431373, 0.40000000000000002, 1.0) -(0.31372549019607843, 0.65686274509803921, 0.40000000000000002, 1.0) -(0.31764705882352939, 0.6588235294117647, 0.40000000000000002, 1.0) -(0.32156862745098036, 0.66078431372549018, 0.40000000000000002, 1.0) -(0.32549019607843138, 0.66274509803921566, 0.40000000000000002, 1.0) -(0.32941176470588235, 0.66470588235294115, 0.40000000000000002, 1.0) -(0.33333333333333331, 0.66666666666666663, 0.40000000000000002, 1.0) -(0.33725490196078434, 0.66862745098039222, 0.40000000000000002, 1.0) -(0.3411764705882353, 0.67058823529411771, 0.40000000000000002, 1.0) -(0.34509803921568627, 0.67254901960784319, 0.40000000000000002, 1.0) -(0.34901960784313724, 0.67450980392156867, 0.40000000000000002, 1.0) -(0.3529411764705882, 0.67647058823529416, 0.40000000000000002, 1.0) -(0.35686274509803922, 0.67843137254901964, 0.40000000000000002, 1.0) -(0.36078431372549019, 0.68039215686274512, 0.40000000000000002, 1.0) -(0.36470588235294116, 0.68235294117647061, 0.40000000000000002, 1.0) -(0.36862745098039218, 0.68431372549019609, 0.40000000000000002, 1.0) -(0.37254901960784315, 0.68627450980392157, 0.40000000000000002, 1.0) -(0.37647058823529411, 0.68823529411764706, 0.40000000000000002, 1.0) -(0.38039215686274508, 0.69019607843137254, 0.40000000000000002, 1.0) -(0.38431372549019605, 0.69215686274509802, 0.40000000000000002, 1.0) -(0.38823529411764707, 0.69411764705882351, 0.40000000000000002, 1.0) -(0.39215686274509803, 0.69607843137254899, 0.40000000000000002, 1.0) -(0.396078431372549, 0.69803921568627447, 0.40000000000000002, 1.0) -(0.40000000000000002, 0.69999999999999996, 0.40000000000000002, 1.0) -(0.40392156862745099, 0.70196078431372544, 0.40000000000000002, 1.0) -(0.40784313725490196, 0.70392156862745092, 0.40000000000000002, 1.0) -(0.41176470588235292, 0.70588235294117641, 0.40000000000000002, 1.0) -(0.41568627450980389, 0.70784313725490189, 0.40000000000000002, 1.0) -(0.41960784313725491, 0.70980392156862748, 0.40000000000000002, 1.0) -(0.42352941176470588, 0.71176470588235297, 0.40000000000000002, 1.0) -(0.42745098039215684, 0.71372549019607845, 0.40000000000000002, 1.0) -(0.43137254901960786, 0.71568627450980393, 0.40000000000000002, 1.0) -(0.43529411764705883, 0.71764705882352942, 0.40000000000000002, 1.0) -(0.4392156862745098, 0.7196078431372549, 0.40000000000000002, 1.0) -(0.44313725490196076, 0.72156862745098038, 0.40000000000000002, 1.0) -(0.44705882352941173, 0.72352941176470587, 0.40000000000000002, 1.0) -(0.45098039215686275, 0.72549019607843135, 0.40000000000000002, 1.0) -(0.45490196078431372, 0.72745098039215683, 0.40000000000000002, 1.0) -(0.45882352941176469, 0.72941176470588232, 0.40000000000000002, 1.0) -(0.46274509803921571, 0.73137254901960791, 0.40000000000000002, 1.0) -(0.46666666666666667, 0.73333333333333339, 0.40000000000000002, 1.0) -(0.47058823529411764, 0.73529411764705888, 0.40000000000000002, 1.0) -(0.47450980392156861, 0.73725490196078436, 0.40000000000000002, 1.0) -(0.47843137254901957, 0.73921568627450984, 0.40000000000000002, 1.0) -(0.4823529411764706, 0.74117647058823533, 0.40000000000000002, 1.0) -(0.48627450980392156, 0.74313725490196081, 0.40000000000000002, 1.0) -(0.49019607843137253, 0.74509803921568629, 0.40000000000000002, 1.0) -(0.49411764705882355, 0.74705882352941178, 0.40000000000000002, 1.0) -(0.49803921568627452, 0.74901960784313726, 0.40000000000000002, 1.0) -(0.50196078431372548, 0.75098039215686274, 0.40000000000000002, 1.0) -(0.50588235294117645, 0.75294117647058822, 0.40000000000000002, 1.0) -(0.50980392156862742, 0.75490196078431371, 0.40000000000000002, 1.0) -(0.51372549019607838, 0.75686274509803919, 0.40000000000000002, 1.0) -(0.51764705882352935, 0.75882352941176467, 0.40000000000000002, 1.0) -(0.52156862745098043, 0.76078431372549016, 0.40000000000000002, 1.0) -(0.52549019607843139, 0.76274509803921564, 0.40000000000000002, 1.0) -(0.52941176470588236, 0.76470588235294112, 0.40000000000000002, 1.0) -(0.53333333333333333, 0.76666666666666661, 0.40000000000000002, 1.0) -(0.53725490196078429, 0.76862745098039209, 0.40000000000000002, 1.0) -(0.54117647058823526, 0.77058823529411757, 0.40000000000000002, 1.0) -(0.54509803921568623, 0.77254901960784306, 0.40000000000000002, 1.0) -(0.5490196078431373, 0.77450980392156865, 0.40000000000000002, 1.0) -(0.55294117647058827, 0.77647058823529413, 0.40000000000000002, 1.0) -(0.55686274509803924, 0.77843137254901962, 0.40000000000000002, 1.0) -(0.5607843137254902, 0.7803921568627451, 0.40000000000000002, 1.0) -(0.56470588235294117, 0.78235294117647058, 0.40000000000000002, 1.0) -(0.56862745098039214, 0.78431372549019607, 0.40000000000000002, 1.0) -(0.5725490196078431, 0.78627450980392155, 0.40000000000000002, 1.0) -(0.57647058823529407, 0.78823529411764703, 0.40000000000000002, 1.0) -(0.58039215686274503, 0.79019607843137252, 0.40000000000000002, 1.0) -(0.58431372549019611, 0.79215686274509811, 0.40000000000000002, 1.0) -(0.58823529411764708, 0.79411764705882359, 0.40000000000000002, 1.0) -(0.59215686274509804, 0.79607843137254908, 0.40000000000000002, 1.0) -(0.59607843137254901, 0.79803921568627456, 0.40000000000000002, 1.0) -(0.59999999999999998, 0.80000000000000004, 0.40000000000000002, 1.0) -(0.60392156862745094, 0.80196078431372553, 0.40000000000000002, 1.0) -(0.60784313725490191, 0.80392156862745101, 0.40000000000000002, 1.0) -(0.61176470588235299, 0.80588235294117649, 0.40000000000000002, 1.0) -(0.61568627450980395, 0.80784313725490198, 0.40000000000000002, 1.0) -(0.61960784313725492, 0.80980392156862746, 0.40000000000000002, 1.0) -(0.62352941176470589, 0.81176470588235294, 0.40000000000000002, 1.0) -(0.62745098039215685, 0.81372549019607843, 0.40000000000000002, 1.0) -(0.63137254901960782, 0.81568627450980391, 0.40000000000000002, 1.0) -(0.63529411764705879, 0.81764705882352939, 0.40000000000000002, 1.0) -(0.63921568627450975, 0.81960784313725488, 0.40000000000000002, 1.0) -(0.64313725490196072, 0.82156862745098036, 0.40000000000000002, 1.0) -(0.6470588235294118, 0.82352941176470584, 0.40000000000000002, 1.0) -(0.65098039215686276, 0.82549019607843133, 0.40000000000000002, 1.0) -(0.65490196078431373, 0.82745098039215681, 0.40000000000000002, 1.0) -(0.6588235294117647, 0.82941176470588229, 0.40000000000000002, 1.0) -(0.66274509803921566, 0.83137254901960778, 0.40000000000000002, 1.0) -(0.66666666666666663, 0.83333333333333326, 0.40000000000000002, 1.0) -(0.6705882352941176, 0.83529411764705874, 0.40000000000000002, 1.0) -(0.67450980392156867, 0.83725490196078434, 0.40000000000000002, 1.0) -(0.67843137254901964, 0.83921568627450982, 0.40000000000000002, 1.0) -(0.68235294117647061, 0.8411764705882353, 0.40000000000000002, 1.0) -(0.68627450980392157, 0.84313725490196079, 0.40000000000000002, 1.0) -(0.69019607843137254, 0.84509803921568627, 0.40000000000000002, 1.0) -(0.69411764705882351, 0.84705882352941175, 0.40000000000000002, 1.0) -(0.69803921568627447, 0.84901960784313724, 0.40000000000000002, 1.0) -(0.70196078431372544, 0.85098039215686272, 0.40000000000000002, 1.0) -(0.70588235294117641, 0.8529411764705882, 0.40000000000000002, 1.0) -(0.70980392156862748, 0.8549019607843138, 0.40000000000000002, 1.0) -(0.71372549019607845, 0.85686274509803928, 0.40000000000000002, 1.0) -(0.71764705882352942, 0.85882352941176476, 0.40000000000000002, 1.0) -(0.72156862745098038, 0.86078431372549025, 0.40000000000000002, 1.0) -(0.72549019607843135, 0.86274509803921573, 0.40000000000000002, 1.0) -(0.72941176470588232, 0.86470588235294121, 0.40000000000000002, 1.0) -(0.73333333333333328, 0.8666666666666667, 0.40000000000000002, 1.0) -(0.73725490196078436, 0.86862745098039218, 0.40000000000000002, 1.0) -(0.74117647058823533, 0.87058823529411766, 0.40000000000000002, 1.0) -(0.74509803921568629, 0.87254901960784315, 0.40000000000000002, 1.0) -(0.74901960784313726, 0.87450980392156863, 0.40000000000000002, 1.0) -(0.75294117647058822, 0.87647058823529411, 0.40000000000000002, 1.0) -(0.75686274509803919, 0.8784313725490196, 0.40000000000000002, 1.0) -(0.76078431372549016, 0.88039215686274508, 0.40000000000000002, 1.0) -(0.76470588235294112, 0.88235294117647056, 0.40000000000000002, 1.0) -(0.76862745098039209, 0.88431372549019605, 0.40000000000000002, 1.0) -(0.77254901960784317, 0.88627450980392153, 0.40000000000000002, 1.0) -(0.77647058823529413, 0.88823529411764701, 0.40000000000000002, 1.0) -(0.7803921568627451, 0.8901960784313725, 0.40000000000000002, 1.0) -(0.78431372549019607, 0.89215686274509798, 0.40000000000000002, 1.0) -(0.78823529411764703, 0.89411764705882346, 0.40000000000000002, 1.0) -(0.792156862745098, 0.89607843137254894, 0.40000000000000002, 1.0) -(0.79607843137254897, 0.89803921568627443, 0.40000000000000002, 1.0) -(0.80000000000000004, 0.90000000000000002, 0.40000000000000002, 1.0) -(0.80392156862745101, 0.90196078431372551, 0.40000000000000002, 1.0) -(0.80784313725490198, 0.90392156862745099, 0.40000000000000002, 1.0) -(0.81176470588235294, 0.90588235294117647, 0.40000000000000002, 1.0) -(0.81568627450980391, 0.90784313725490196, 0.40000000000000002, 1.0) -(0.81960784313725488, 0.90980392156862744, 0.40000000000000002, 1.0) -(0.82352941176470584, 0.91176470588235292, 0.40000000000000002, 1.0) -(0.82745098039215681, 0.9137254901960784, 0.40000000000000002, 1.0) -(0.83137254901960778, 0.91568627450980389, 0.40000000000000002, 1.0) -(0.83529411764705885, 0.91764705882352948, 0.40000000000000002, 1.0) -(0.83921568627450982, 0.91960784313725497, 0.40000000000000002, 1.0) -(0.84313725490196079, 0.92156862745098045, 0.40000000000000002, 1.0) -(0.84705882352941175, 0.92352941176470593, 0.40000000000000002, 1.0) -(0.85098039215686272, 0.92549019607843142, 0.40000000000000002, 1.0) -(0.85490196078431369, 0.9274509803921569, 0.40000000000000002, 1.0) -(0.85882352941176465, 0.92941176470588238, 0.40000000000000002, 1.0) -(0.86274509803921573, 0.93137254901960786, 0.40000000000000002, 1.0) -(0.8666666666666667, 0.93333333333333335, 0.40000000000000002, 1.0) -(0.87058823529411766, 0.93529411764705883, 0.40000000000000002, 1.0) -(0.87450980392156863, 0.93725490196078431, 0.40000000000000002, 1.0) -(0.8784313725490196, 0.9392156862745098, 0.40000000000000002, 1.0) -(0.88235294117647056, 0.94117647058823528, 0.40000000000000002, 1.0) -(0.88627450980392153, 0.94313725490196076, 0.40000000000000002, 1.0) -(0.8901960784313725, 0.94509803921568625, 0.40000000000000002, 1.0) -(0.89411764705882346, 0.94705882352941173, 0.40000000000000002, 1.0) -(0.89803921568627454, 0.94901960784313721, 0.40000000000000002, 1.0) -(0.90196078431372551, 0.9509803921568627, 0.40000000000000002, 1.0) -(0.90588235294117647, 0.95294117647058818, 0.40000000000000002, 1.0) -(0.90980392156862744, 0.95490196078431366, 0.40000000000000002, 1.0) -(0.9137254901960784, 0.95686274509803915, 0.40000000000000002, 1.0) -(0.91764705882352937, 0.95882352941176463, 0.40000000000000002, 1.0) -(0.92156862745098034, 0.96078431372549011, 0.40000000000000002, 1.0) -(0.92549019607843142, 0.96274509803921571, 0.40000000000000002, 1.0) -(0.92941176470588238, 0.96470588235294119, 0.40000000000000002, 1.0) -(0.93333333333333335, 0.96666666666666667, 0.40000000000000002, 1.0) -(0.93725490196078431, 0.96862745098039216, 0.40000000000000002, 1.0) -(0.94117647058823528, 0.97058823529411764, 0.40000000000000002, 1.0) -(0.94509803921568625, 0.97254901960784312, 0.40000000000000002, 1.0) -(0.94901960784313721, 0.97450980392156861, 0.40000000000000002, 1.0) -(0.95294117647058818, 0.97647058823529409, 0.40000000000000002, 1.0) -(0.95686274509803915, 0.97843137254901957, 0.40000000000000002, 1.0) -(0.96078431372549022, 0.98039215686274517, 0.40000000000000002, 1.0) -(0.96470588235294119, 0.98235294117647065, 0.40000000000000002, 1.0) -(0.96862745098039216, 0.98431372549019613, 0.40000000000000002, 1.0) -(0.97254901960784312, 0.98627450980392162, 0.40000000000000002, 1.0) -(0.97647058823529409, 0.9882352941176471, 0.40000000000000002, 1.0) -(0.98039215686274506, 0.99019607843137258, 0.40000000000000002, 1.0) -(0.98431372549019602, 0.99215686274509807, 0.40000000000000002, 1.0) -(0.9882352941176471, 0.99411764705882355, 0.40000000000000002, 1.0) -(0.99215686274509807, 0.99607843137254903, 0.40000000000000002, 1.0) -(0.99607843137254903, 0.99803921568627452, 0.40000000000000002, 1.0) -(1.0, 1.0, 0.40000000000000002, 1.0) diff --git a/extern/tfn/colormaps/sequential2/winter.cpp b/extern/tfn/colormaps/sequential2/winter.cpp deleted file mode 100644 index 42f9573..0000000 --- a/extern/tfn/colormaps/sequential2/winter.cpp +++ /dev/null @@ -1,287 +0,0 @@ -// -// Automatically generated file, do not modify. -// -// ======================================================================== // -// Copyright 2019-2020 Qi Wu // -// // -// Licensed under the Apache License, Version 2.0 (the "License"); // -// you may not use this file except in compliance with the License. // -// You may obtain a copy of the License at // -// // -// http://www.apache.org/licenses/LICENSE-2.0 // -// // -// Unless required by applicable law or agreed to in writing, software // -// distributed under the License is distributed on an "AS IS" BASIS, // -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // -// See the License for the specific language governing permissions and // -// limitations under the License. // -// ======================================================================== // -// -// clang-format off -// -#include -#include -#include -namespace colormap { -struct color_t { float r, g, b, a; }; -extern const std::vector data_sequential2_winter; -} -const std::vector colormap::data_sequential2_winter = /* NOLINT(cert-err58-cpp) */ -{ -{0.0f, 0.0f, 1.0f, 1.0f}, -{0.0f, 0.0039215686274509803f, 0.99803921568627452f, 1.0f}, -{0.0f, 0.0078431372549019607f, 0.99607843137254903f, 1.0f}, -{0.0f, 0.011764705882352941f, 0.99411764705882355f, 1.0f}, -{0.0f, 0.015686274509803921f, 0.99215686274509807f, 1.0f}, -{0.0f, 0.019607843137254902f, 0.99019607843137258f, 1.0f}, -{0.0f, 0.023529411764705882f, 0.9882352941176471f, 1.0f}, -{0.0f, 0.027450980392156862f, 0.98627450980392162f, 1.0f}, -{0.0f, 0.031372549019607843f, 0.98431372549019613f, 1.0f}, -{0.0f, 0.035294117647058823f, 0.98235294117647054f, 1.0f}, -{0.0f, 0.039215686274509803f, 0.98039215686274506f, 1.0f}, -{0.0f, 0.043137254901960784f, 0.97843137254901957f, 1.0f}, -{0.0f, 0.047058823529411764f, 0.97647058823529409f, 1.0f}, -{0.0f, 0.050980392156862744f, 0.97450980392156861f, 1.0f}, -{0.0f, 0.054901960784313725f, 0.97254901960784312f, 1.0f}, -{0.0f, 0.058823529411764705f, 0.97058823529411764f, 1.0f}, -{0.0f, 0.062745098039215685f, 0.96862745098039216f, 1.0f}, -{0.0f, 0.066666666666666666f, 0.96666666666666667f, 1.0f}, -{0.0f, 0.070588235294117646f, 0.96470588235294119f, 1.0f}, -{0.0f, 0.074509803921568626f, 0.96274509803921571f, 1.0f}, -{0.0f, 0.078431372549019607f, 0.96078431372549022f, 1.0f}, -{0.0f, 0.082352941176470587f, 0.95882352941176474f, 1.0f}, -{0.0f, 0.086274509803921567f, 0.95686274509803926f, 1.0f}, -{0.0f, 0.090196078431372548f, 0.95490196078431377f, 1.0f}, -{0.0f, 0.094117647058823528f, 0.95294117647058818f, 1.0f}, -{0.0f, 0.098039215686274508f, 0.9509803921568627f, 1.0f}, -{0.0f, 0.10196078431372549f, 0.94901960784313721f, 1.0f}, -{0.0f, 0.10588235294117647f, 0.94705882352941173f, 1.0f}, -{0.0f, 0.10980392156862745f, 0.94509803921568625f, 1.0f}, -{0.0f, 0.11372549019607843f, 0.94313725490196076f, 1.0f}, -{0.0f, 0.11764705882352941f, 0.94117647058823528f, 1.0f}, -{0.0f, 0.12156862745098039f, 0.9392156862745098f, 1.0f}, -{0.0f, 0.12549019607843137f, 0.93725490196078431f, 1.0f}, -{0.0f, 0.12941176470588234f, 0.93529411764705883f, 1.0f}, -{0.0f, 0.13333333333333333f, 0.93333333333333335f, 1.0f}, -{0.0f, 0.13725490196078433f, 0.93137254901960786f, 1.0f}, -{0.0f, 0.14117647058823529f, 0.92941176470588238f, 1.0f}, -{0.0f, 0.14509803921568626f, 0.9274509803921569f, 1.0f}, -{0.0f, 0.14901960784313725f, 0.92549019607843142f, 1.0f}, -{0.0f, 0.15294117647058825f, 0.92352941176470593f, 1.0f}, -{0.0f, 0.15686274509803921f, 0.92156862745098045f, 1.0f}, -{0.0f, 0.16078431372549018f, 0.91960784313725497f, 1.0f}, -{0.0f, 0.16470588235294117f, 0.91764705882352937f, 1.0f}, -{0.0f, 0.16862745098039217f, 0.91568627450980389f, 1.0f}, -{0.0f, 0.17254901960784313f, 0.9137254901960784f, 1.0f}, -{0.0f, 0.1764705882352941f, 0.91176470588235292f, 1.0f}, -{0.0f, 0.1803921568627451f, 0.90980392156862744f, 1.0f}, -{0.0f, 0.18431372549019609f, 0.90784313725490196f, 1.0f}, -{0.0f, 0.18823529411764706f, 0.90588235294117647f, 1.0f}, -{0.0f, 0.19215686274509802f, 0.90392156862745099f, 1.0f}, -{0.0f, 0.19607843137254902f, 0.90196078431372551f, 1.0f}, -{0.0f, 0.20000000000000001f, 0.90000000000000002f, 1.0f}, -{0.0f, 0.20392156862745098f, 0.89803921568627454f, 1.0f}, -{0.0f, 0.20784313725490194f, 0.89607843137254906f, 1.0f}, -{0.0f, 0.21176470588235294f, 0.89411764705882357f, 1.0f}, -{0.0f, 0.21568627450980393f, 0.89215686274509798f, 1.0f}, -{0.0f, 0.2196078431372549f, 0.8901960784313725f, 1.0f}, -{0.0f, 0.22352941176470587f, 0.88823529411764701f, 1.0f}, -{0.0f, 0.22745098039215686f, 0.88627450980392153f, 1.0f}, -{0.0f, 0.23137254901960785f, 0.88431372549019605f, 1.0f}, -{0.0f, 0.23529411764705882f, 0.88235294117647056f, 1.0f}, -{0.0f, 0.23921568627450979f, 0.88039215686274508f, 1.0f}, -{0.0f, 0.24313725490196078f, 0.8784313725490196f, 1.0f}, -{0.0f, 0.24705882352941178f, 0.87647058823529411f, 1.0f}, -{0.0f, 0.25098039215686274f, 0.87450980392156863f, 1.0f}, -{0.0f, 0.25490196078431371f, 0.87254901960784315f, 1.0f}, -{0.0f, 0.25882352941176467f, 0.87058823529411766f, 1.0f}, -{0.0f, 0.2627450980392157f, 0.86862745098039218f, 1.0f}, -{0.0f, 0.26666666666666666f, 0.8666666666666667f, 1.0f}, -{0.0f, 0.27058823529411763f, 0.86470588235294121f, 1.0f}, -{0.0f, 0.27450980392156865f, 0.86274509803921573f, 1.0f}, -{0.0f, 0.27843137254901962f, 0.86078431372549025f, 1.0f}, -{0.0f, 0.28235294117647058f, 0.85882352941176476f, 1.0f}, -{0.0f, 0.28627450980392155f, 0.85686274509803928f, 1.0f}, -{0.0f, 0.29019607843137252f, 0.8549019607843138f, 1.0f}, -{0.0f, 0.29411764705882354f, 0.8529411764705882f, 1.0f}, -{0.0f, 0.29803921568627451f, 0.85098039215686272f, 1.0f}, -{0.0f, 0.30196078431372547f, 0.84901960784313724f, 1.0f}, -{0.0f, 0.30588235294117649f, 0.84705882352941175f, 1.0f}, -{0.0f, 0.30980392156862746f, 0.84509803921568627f, 1.0f}, -{0.0f, 0.31372549019607843f, 0.84313725490196079f, 1.0f}, -{0.0f, 0.31764705882352939f, 0.8411764705882353f, 1.0f}, -{0.0f, 0.32156862745098036f, 0.83921568627450982f, 1.0f}, -{0.0f, 0.32549019607843138f, 0.83725490196078434f, 1.0f}, -{0.0f, 0.32941176470588235f, 0.83529411764705885f, 1.0f}, -{0.0f, 0.33333333333333331f, 0.83333333333333337f, 1.0f}, -{0.0f, 0.33725490196078434f, 0.83137254901960778f, 1.0f}, -{0.0f, 0.3411764705882353f, 0.82941176470588229f, 1.0f}, -{0.0f, 0.34509803921568627f, 0.82745098039215681f, 1.0f}, -{0.0f, 0.34901960784313724f, 0.82549019607843133f, 1.0f}, -{0.0f, 0.3529411764705882f, 0.82352941176470584f, 1.0f}, -{0.0f, 0.35686274509803922f, 0.82156862745098036f, 1.0f}, -{0.0f, 0.36078431372549019f, 0.81960784313725488f, 1.0f}, -{0.0f, 0.36470588235294116f, 0.81764705882352939f, 1.0f}, -{0.0f, 0.36862745098039218f, 0.81568627450980391f, 1.0f}, -{0.0f, 0.37254901960784315f, 0.81372549019607843f, 1.0f}, -{0.0f, 0.37647058823529411f, 0.81176470588235294f, 1.0f}, -{0.0f, 0.38039215686274508f, 0.80980392156862746f, 1.0f}, -{0.0f, 0.38431372549019605f, 0.80784313725490198f, 1.0f}, -{0.0f, 0.38823529411764707f, 0.80588235294117649f, 1.0f}, -{0.0f, 0.39215686274509803f, 0.80392156862745101f, 1.0f}, -{0.0f, 0.396078431372549f, 0.80196078431372553f, 1.0f}, -{0.0f, 0.40000000000000002f, 0.80000000000000004f, 1.0f}, -{0.0f, 0.40392156862745099f, 0.79803921568627456f, 1.0f}, -{0.0f, 0.40784313725490196f, 0.79607843137254908f, 1.0f}, -{0.0f, 0.41176470588235292f, 0.79411764705882359f, 1.0f}, -{0.0f, 0.41568627450980389f, 0.79215686274509811f, 1.0f}, -{0.0f, 0.41960784313725491f, 0.79019607843137252f, 1.0f}, -{0.0f, 0.42352941176470588f, 0.78823529411764703f, 1.0f}, -{0.0f, 0.42745098039215684f, 0.78627450980392155f, 1.0f}, -{0.0f, 0.43137254901960786f, 0.78431372549019607f, 1.0f}, -{0.0f, 0.43529411764705883f, 0.78235294117647058f, 1.0f}, -{0.0f, 0.4392156862745098f, 0.7803921568627451f, 1.0f}, -{0.0f, 0.44313725490196076f, 0.77843137254901962f, 1.0f}, -{0.0f, 0.44705882352941173f, 0.77647058823529413f, 1.0f}, -{0.0f, 0.45098039215686275f, 0.77450980392156865f, 1.0f}, -{0.0f, 0.45490196078431372f, 0.77254901960784317f, 1.0f}, -{0.0f, 0.45882352941176469f, 0.77058823529411768f, 1.0f}, -{0.0f, 0.46274509803921571f, 0.76862745098039209f, 1.0f}, -{0.0f, 0.46666666666666667f, 0.76666666666666661f, 1.0f}, -{0.0f, 0.47058823529411764f, 0.76470588235294112f, 1.0f}, -{0.0f, 0.47450980392156861f, 0.76274509803921564f, 1.0f}, -{0.0f, 0.47843137254901957f, 0.76078431372549016f, 1.0f}, -{0.0f, 0.4823529411764706f, 0.75882352941176467f, 1.0f}, -{0.0f, 0.48627450980392156f, 0.75686274509803919f, 1.0f}, -{0.0f, 0.49019607843137253f, 0.75490196078431371f, 1.0f}, -{0.0f, 0.49411764705882355f, 0.75294117647058822f, 1.0f}, -{0.0f, 0.49803921568627452f, 0.75098039215686274f, 1.0f}, -{0.0f, 0.50196078431372548f, 0.74901960784313726f, 1.0f}, -{0.0f, 0.50588235294117645f, 0.74705882352941178f, 1.0f}, -{0.0f, 0.50980392156862742f, 0.74509803921568629f, 1.0f}, -{0.0f, 0.51372549019607838f, 0.74313725490196081f, 1.0f}, -{0.0f, 0.51764705882352935f, 0.74117647058823533f, 1.0f}, -{0.0f, 0.52156862745098043f, 0.73921568627450984f, 1.0f}, -{0.0f, 0.52549019607843139f, 0.73725490196078436f, 1.0f}, -{0.0f, 0.52941176470588236f, 0.73529411764705888f, 1.0f}, -{0.0f, 0.53333333333333333f, 0.73333333333333339f, 1.0f}, -{0.0f, 0.53725490196078429f, 0.73137254901960791f, 1.0f}, -{0.0f, 0.54117647058823526f, 0.72941176470588243f, 1.0f}, -{0.0f, 0.54509803921568623f, 0.72745098039215694f, 1.0f}, -{0.0f, 0.5490196078431373f, 0.72549019607843135f, 1.0f}, -{0.0f, 0.55294117647058827f, 0.72352941176470587f, 1.0f}, -{0.0f, 0.55686274509803924f, 0.72156862745098038f, 1.0f}, -{0.0f, 0.5607843137254902f, 0.7196078431372549f, 1.0f}, -{0.0f, 0.56470588235294117f, 0.71764705882352942f, 1.0f}, -{0.0f, 0.56862745098039214f, 0.71568627450980393f, 1.0f}, -{0.0f, 0.5725490196078431f, 0.71372549019607845f, 1.0f}, -{0.0f, 0.57647058823529407f, 0.71176470588235297f, 1.0f}, -{0.0f, 0.58039215686274503f, 0.70980392156862748f, 1.0f}, -{0.0f, 0.58431372549019611f, 0.70784313725490189f, 1.0f}, -{0.0f, 0.58823529411764708f, 0.70588235294117641f, 1.0f}, -{0.0f, 0.59215686274509804f, 0.70392156862745092f, 1.0f}, -{0.0f, 0.59607843137254901f, 0.70196078431372544f, 1.0f}, -{0.0f, 0.59999999999999998f, 0.69999999999999996f, 1.0f}, -{0.0f, 0.60392156862745094f, 0.69803921568627447f, 1.0f}, -{0.0f, 0.60784313725490191f, 0.69607843137254899f, 1.0f}, -{0.0f, 0.61176470588235299f, 0.69411764705882351f, 1.0f}, -{0.0f, 0.61568627450980395f, 0.69215686274509802f, 1.0f}, -{0.0f, 0.61960784313725492f, 0.69019607843137254f, 1.0f}, -{0.0f, 0.62352941176470589f, 0.68823529411764706f, 1.0f}, -{0.0f, 0.62745098039215685f, 0.68627450980392157f, 1.0f}, -{0.0f, 0.63137254901960782f, 0.68431372549019609f, 1.0f}, -{0.0f, 0.63529411764705879f, 0.68235294117647061f, 1.0f}, -{0.0f, 0.63921568627450975f, 0.68039215686274512f, 1.0f}, -{0.0f, 0.64313725490196072f, 0.67843137254901964f, 1.0f}, -{0.0f, 0.6470588235294118f, 0.67647058823529416f, 1.0f}, -{0.0f, 0.65098039215686276f, 0.67450980392156867f, 1.0f}, -{0.0f, 0.65490196078431373f, 0.67254901960784319f, 1.0f}, -{0.0f, 0.6588235294117647f, 0.67058823529411771f, 1.0f}, -{0.0f, 0.66274509803921566f, 0.66862745098039222f, 1.0f}, -{0.0f, 0.66666666666666663f, 0.66666666666666674f, 1.0f}, -{0.0f, 0.6705882352941176f, 0.66470588235294126f, 1.0f}, -{0.0f, 0.67450980392156867f, 0.66274509803921566f, 1.0f}, -{0.0f, 0.67843137254901964f, 0.66078431372549018f, 1.0f}, -{0.0f, 0.68235294117647061f, 0.6588235294117647f, 1.0f}, -{0.0f, 0.68627450980392157f, 0.65686274509803921f, 1.0f}, -{0.0f, 0.69019607843137254f, 0.65490196078431373f, 1.0f}, -{0.0f, 0.69411764705882351f, 0.65294117647058825f, 1.0f}, -{0.0f, 0.69803921568627447f, 0.65098039215686276f, 1.0f}, -{0.0f, 0.70196078431372544f, 0.64901960784313728f, 1.0f}, -{0.0f, 0.70588235294117641f, 0.6470588235294118f, 1.0f}, -{0.0f, 0.70980392156862748f, 0.6450980392156862f, 1.0f}, -{0.0f, 0.71372549019607845f, 0.64313725490196072f, 1.0f}, -{0.0f, 0.71764705882352942f, 0.64117647058823524f, 1.0f}, -{0.0f, 0.72156862745098038f, 0.63921568627450975f, 1.0f}, -{0.0f, 0.72549019607843135f, 0.63725490196078427f, 1.0f}, -{0.0f, 0.72941176470588232f, 0.63529411764705879f, 1.0f}, -{0.0f, 0.73333333333333328f, 0.6333333333333333f, 1.0f}, -{0.0f, 0.73725490196078436f, 0.63137254901960782f, 1.0f}, -{0.0f, 0.74117647058823533f, 0.62941176470588234f, 1.0f}, -{0.0f, 0.74509803921568629f, 0.62745098039215685f, 1.0f}, -{0.0f, 0.74901960784313726f, 0.62549019607843137f, 1.0f}, -{0.0f, 0.75294117647058822f, 0.62352941176470589f, 1.0f}, -{0.0f, 0.75686274509803919f, 0.6215686274509804f, 1.0f}, -{0.0f, 0.76078431372549016f, 0.61960784313725492f, 1.0f}, -{0.0f, 0.76470588235294112f, 0.61764705882352944f, 1.0f}, -{0.0f, 0.76862745098039209f, 0.61568627450980395f, 1.0f}, -{0.0f, 0.77254901960784317f, 0.61372549019607847f, 1.0f}, -{0.0f, 0.77647058823529413f, 0.61176470588235299f, 1.0f}, -{0.0f, 0.7803921568627451f, 0.6098039215686275f, 1.0f}, -{0.0f, 0.78431372549019607f, 0.60784313725490202f, 1.0f}, -{0.0f, 0.78823529411764703f, 0.60588235294117654f, 1.0f}, -{0.0f, 0.792156862745098f, 0.60392156862745106f, 1.0f}, -{0.0f, 0.79607843137254897f, 0.60196078431372557f, 1.0f}, -{0.0f, 0.80000000000000004f, 0.59999999999999998f, 1.0f}, -{0.0f, 0.80392156862745101f, 0.59803921568627449f, 1.0f}, -{0.0f, 0.80784313725490198f, 0.59607843137254901f, 1.0f}, -{0.0f, 0.81176470588235294f, 0.59411764705882353f, 1.0f}, -{0.0f, 0.81568627450980391f, 0.59215686274509804f, 1.0f}, -{0.0f, 0.81960784313725488f, 0.59019607843137256f, 1.0f}, -{0.0f, 0.82352941176470584f, 0.58823529411764708f, 1.0f}, -{0.0f, 0.82745098039215681f, 0.5862745098039216f, 1.0f}, -{0.0f, 0.83137254901960778f, 0.58431372549019611f, 1.0f}, -{0.0f, 0.83529411764705885f, 0.58235294117647052f, 1.0f}, -{0.0f, 0.83921568627450982f, 0.58039215686274503f, 1.0f}, -{0.0f, 0.84313725490196079f, 0.57843137254901955f, 1.0f}, -{0.0f, 0.84705882352941175f, 0.57647058823529407f, 1.0f}, -{0.0f, 0.85098039215686272f, 0.57450980392156858f, 1.0f}, -{0.0f, 0.85490196078431369f, 0.5725490196078431f, 1.0f}, -{0.0f, 0.85882352941176465f, 0.57058823529411762f, 1.0f}, -{0.0f, 0.86274509803921573f, 0.56862745098039214f, 1.0f}, -{0.0f, 0.8666666666666667f, 0.56666666666666665f, 1.0f}, -{0.0f, 0.87058823529411766f, 0.56470588235294117f, 1.0f}, -{0.0f, 0.87450980392156863f, 0.56274509803921569f, 1.0f}, -{0.0f, 0.8784313725490196f, 0.5607843137254902f, 1.0f}, -{0.0f, 0.88235294117647056f, 0.55882352941176472f, 1.0f}, -{0.0f, 0.88627450980392153f, 0.55686274509803924f, 1.0f}, -{0.0f, 0.8901960784313725f, 0.55490196078431375f, 1.0f}, -{0.0f, 0.89411764705882346f, 0.55294117647058827f, 1.0f}, -{0.0f, 0.89803921568627454f, 0.55098039215686279f, 1.0f}, -{0.0f, 0.90196078431372551f, 0.5490196078431373f, 1.0f}, -{0.0f, 0.90588235294117647f, 0.54705882352941182f, 1.0f}, -{0.0f, 0.90980392156862744f, 0.54509803921568634f, 1.0f}, -{0.0f, 0.9137254901960784f, 0.54313725490196085f, 1.0f}, -{0.0f, 0.91764705882352937f, 0.54117647058823537f, 1.0f}, -{0.0f, 0.92156862745098034f, 0.53921568627450989f, 1.0f}, -{0.0f, 0.92549019607843142f, 0.53725490196078429f, 1.0f}, -{0.0f, 0.92941176470588238f, 0.53529411764705881f, 1.0f}, -{0.0f, 0.93333333333333335f, 0.53333333333333333f, 1.0f}, -{0.0f, 0.93725490196078431f, 0.53137254901960784f, 1.0f}, -{0.0f, 0.94117647058823528f, 0.52941176470588236f, 1.0f}, -{0.0f, 0.94509803921568625f, 0.52745098039215688f, 1.0f}, -{0.0f, 0.94901960784313721f, 0.52549019607843139f, 1.0f}, -{0.0f, 0.95294117647058818f, 0.52352941176470591f, 1.0f}, -{0.0f, 0.95686274509803915f, 0.52156862745098043f, 1.0f}, -{0.0f, 0.96078431372549022f, 0.51960784313725483f, 1.0f}, -{0.0f, 0.96470588235294119f, 0.51764705882352935f, 1.0f}, -{0.0f, 0.96862745098039216f, 0.51568627450980387f, 1.0f}, -{0.0f, 0.97254901960784312f, 0.51372549019607838f, 1.0f}, -{0.0f, 0.97647058823529409f, 0.5117647058823529f, 1.0f}, -{0.0f, 0.98039215686274506f, 0.50980392156862742f, 1.0f}, -{0.0f, 0.98431372549019602f, 0.50784313725490193f, 1.0f}, -{0.0f, 0.9882352941176471f, 0.50588235294117645f, 1.0f}, -{0.0f, 0.99215686274509807f, 0.50392156862745097f, 1.0f}, -{0.0f, 0.99607843137254903f, 0.50196078431372548f, 1.0f}, -{0.0f, 1.0f, 0.5f, 1.0f}, -}; diff --git a/extern/tfn/colormaps/sequential2/winter.txt b/extern/tfn/colormaps/sequential2/winter.txt deleted file mode 100644 index 78eb274..0000000 --- a/extern/tfn/colormaps/sequential2/winter.txt +++ /dev/null @@ -1,256 +0,0 @@ -(0.0, 0.0, 1.0, 1.0) -(0.0, 0.0039215686274509803, 0.99803921568627452, 1.0) -(0.0, 0.0078431372549019607, 0.99607843137254903, 1.0) -(0.0, 0.011764705882352941, 0.99411764705882355, 1.0) -(0.0, 0.015686274509803921, 0.99215686274509807, 1.0) -(0.0, 0.019607843137254902, 0.99019607843137258, 1.0) -(0.0, 0.023529411764705882, 0.9882352941176471, 1.0) -(0.0, 0.027450980392156862, 0.98627450980392162, 1.0) -(0.0, 0.031372549019607843, 0.98431372549019613, 1.0) -(0.0, 0.035294117647058823, 0.98235294117647054, 1.0) -(0.0, 0.039215686274509803, 0.98039215686274506, 1.0) -(0.0, 0.043137254901960784, 0.97843137254901957, 1.0) -(0.0, 0.047058823529411764, 0.97647058823529409, 1.0) -(0.0, 0.050980392156862744, 0.97450980392156861, 1.0) -(0.0, 0.054901960784313725, 0.97254901960784312, 1.0) -(0.0, 0.058823529411764705, 0.97058823529411764, 1.0) -(0.0, 0.062745098039215685, 0.96862745098039216, 1.0) -(0.0, 0.066666666666666666, 0.96666666666666667, 1.0) -(0.0, 0.070588235294117646, 0.96470588235294119, 1.0) -(0.0, 0.074509803921568626, 0.96274509803921571, 1.0) -(0.0, 0.078431372549019607, 0.96078431372549022, 1.0) -(0.0, 0.082352941176470587, 0.95882352941176474, 1.0) -(0.0, 0.086274509803921567, 0.95686274509803926, 1.0) -(0.0, 0.090196078431372548, 0.95490196078431377, 1.0) -(0.0, 0.094117647058823528, 0.95294117647058818, 1.0) -(0.0, 0.098039215686274508, 0.9509803921568627, 1.0) -(0.0, 0.10196078431372549, 0.94901960784313721, 1.0) -(0.0, 0.10588235294117647, 0.94705882352941173, 1.0) -(0.0, 0.10980392156862745, 0.94509803921568625, 1.0) -(0.0, 0.11372549019607843, 0.94313725490196076, 1.0) -(0.0, 0.11764705882352941, 0.94117647058823528, 1.0) -(0.0, 0.12156862745098039, 0.9392156862745098, 1.0) -(0.0, 0.12549019607843137, 0.93725490196078431, 1.0) -(0.0, 0.12941176470588234, 0.93529411764705883, 1.0) -(0.0, 0.13333333333333333, 0.93333333333333335, 1.0) -(0.0, 0.13725490196078433, 0.93137254901960786, 1.0) -(0.0, 0.14117647058823529, 0.92941176470588238, 1.0) -(0.0, 0.14509803921568626, 0.9274509803921569, 1.0) -(0.0, 0.14901960784313725, 0.92549019607843142, 1.0) -(0.0, 0.15294117647058825, 0.92352941176470593, 1.0) -(0.0, 0.15686274509803921, 0.92156862745098045, 1.0) -(0.0, 0.16078431372549018, 0.91960784313725497, 1.0) -(0.0, 0.16470588235294117, 0.91764705882352937, 1.0) -(0.0, 0.16862745098039217, 0.91568627450980389, 1.0) -(0.0, 0.17254901960784313, 0.9137254901960784, 1.0) -(0.0, 0.1764705882352941, 0.91176470588235292, 1.0) -(0.0, 0.1803921568627451, 0.90980392156862744, 1.0) -(0.0, 0.18431372549019609, 0.90784313725490196, 1.0) -(0.0, 0.18823529411764706, 0.90588235294117647, 1.0) -(0.0, 0.19215686274509802, 0.90392156862745099, 1.0) -(0.0, 0.19607843137254902, 0.90196078431372551, 1.0) -(0.0, 0.20000000000000001, 0.90000000000000002, 1.0) -(0.0, 0.20392156862745098, 0.89803921568627454, 1.0) -(0.0, 0.20784313725490194, 0.89607843137254906, 1.0) -(0.0, 0.21176470588235294, 0.89411764705882357, 1.0) -(0.0, 0.21568627450980393, 0.89215686274509798, 1.0) -(0.0, 0.2196078431372549, 0.8901960784313725, 1.0) -(0.0, 0.22352941176470587, 0.88823529411764701, 1.0) -(0.0, 0.22745098039215686, 0.88627450980392153, 1.0) -(0.0, 0.23137254901960785, 0.88431372549019605, 1.0) -(0.0, 0.23529411764705882, 0.88235294117647056, 1.0) -(0.0, 0.23921568627450979, 0.88039215686274508, 1.0) -(0.0, 0.24313725490196078, 0.8784313725490196, 1.0) -(0.0, 0.24705882352941178, 0.87647058823529411, 1.0) -(0.0, 0.25098039215686274, 0.87450980392156863, 1.0) -(0.0, 0.25490196078431371, 0.87254901960784315, 1.0) -(0.0, 0.25882352941176467, 0.87058823529411766, 1.0) -(0.0, 0.2627450980392157, 0.86862745098039218, 1.0) -(0.0, 0.26666666666666666, 0.8666666666666667, 1.0) -(0.0, 0.27058823529411763, 0.86470588235294121, 1.0) -(0.0, 0.27450980392156865, 0.86274509803921573, 1.0) -(0.0, 0.27843137254901962, 0.86078431372549025, 1.0) -(0.0, 0.28235294117647058, 0.85882352941176476, 1.0) -(0.0, 0.28627450980392155, 0.85686274509803928, 1.0) -(0.0, 0.29019607843137252, 0.8549019607843138, 1.0) -(0.0, 0.29411764705882354, 0.8529411764705882, 1.0) -(0.0, 0.29803921568627451, 0.85098039215686272, 1.0) -(0.0, 0.30196078431372547, 0.84901960784313724, 1.0) -(0.0, 0.30588235294117649, 0.84705882352941175, 1.0) -(0.0, 0.30980392156862746, 0.84509803921568627, 1.0) -(0.0, 0.31372549019607843, 0.84313725490196079, 1.0) -(0.0, 0.31764705882352939, 0.8411764705882353, 1.0) -(0.0, 0.32156862745098036, 0.83921568627450982, 1.0) -(0.0, 0.32549019607843138, 0.83725490196078434, 1.0) -(0.0, 0.32941176470588235, 0.83529411764705885, 1.0) -(0.0, 0.33333333333333331, 0.83333333333333337, 1.0) -(0.0, 0.33725490196078434, 0.83137254901960778, 1.0) -(0.0, 0.3411764705882353, 0.82941176470588229, 1.0) -(0.0, 0.34509803921568627, 0.82745098039215681, 1.0) -(0.0, 0.34901960784313724, 0.82549019607843133, 1.0) -(0.0, 0.3529411764705882, 0.82352941176470584, 1.0) -(0.0, 0.35686274509803922, 0.82156862745098036, 1.0) -(0.0, 0.36078431372549019, 0.81960784313725488, 1.0) -(0.0, 0.36470588235294116, 0.81764705882352939, 1.0) -(0.0, 0.36862745098039218, 0.81568627450980391, 1.0) -(0.0, 0.37254901960784315, 0.81372549019607843, 1.0) -(0.0, 0.37647058823529411, 0.81176470588235294, 1.0) -(0.0, 0.38039215686274508, 0.80980392156862746, 1.0) -(0.0, 0.38431372549019605, 0.80784313725490198, 1.0) -(0.0, 0.38823529411764707, 0.80588235294117649, 1.0) -(0.0, 0.39215686274509803, 0.80392156862745101, 1.0) -(0.0, 0.396078431372549, 0.80196078431372553, 1.0) -(0.0, 0.40000000000000002, 0.80000000000000004, 1.0) -(0.0, 0.40392156862745099, 0.79803921568627456, 1.0) -(0.0, 0.40784313725490196, 0.79607843137254908, 1.0) -(0.0, 0.41176470588235292, 0.79411764705882359, 1.0) -(0.0, 0.41568627450980389, 0.79215686274509811, 1.0) -(0.0, 0.41960784313725491, 0.79019607843137252, 1.0) -(0.0, 0.42352941176470588, 0.78823529411764703, 1.0) -(0.0, 0.42745098039215684, 0.78627450980392155, 1.0) -(0.0, 0.43137254901960786, 0.78431372549019607, 1.0) -(0.0, 0.43529411764705883, 0.78235294117647058, 1.0) -(0.0, 0.4392156862745098, 0.7803921568627451, 1.0) -(0.0, 0.44313725490196076, 0.77843137254901962, 1.0) -(0.0, 0.44705882352941173, 0.77647058823529413, 1.0) -(0.0, 0.45098039215686275, 0.77450980392156865, 1.0) -(0.0, 0.45490196078431372, 0.77254901960784317, 1.0) -(0.0, 0.45882352941176469, 0.77058823529411768, 1.0) -(0.0, 0.46274509803921571, 0.76862745098039209, 1.0) -(0.0, 0.46666666666666667, 0.76666666666666661, 1.0) -(0.0, 0.47058823529411764, 0.76470588235294112, 1.0) -(0.0, 0.47450980392156861, 0.76274509803921564, 1.0) -(0.0, 0.47843137254901957, 0.76078431372549016, 1.0) -(0.0, 0.4823529411764706, 0.75882352941176467, 1.0) -(0.0, 0.48627450980392156, 0.75686274509803919, 1.0) -(0.0, 0.49019607843137253, 0.75490196078431371, 1.0) -(0.0, 0.49411764705882355, 0.75294117647058822, 1.0) -(0.0, 0.49803921568627452, 0.75098039215686274, 1.0) -(0.0, 0.50196078431372548, 0.74901960784313726, 1.0) -(0.0, 0.50588235294117645, 0.74705882352941178, 1.0) -(0.0, 0.50980392156862742, 0.74509803921568629, 1.0) -(0.0, 0.51372549019607838, 0.74313725490196081, 1.0) -(0.0, 0.51764705882352935, 0.74117647058823533, 1.0) -(0.0, 0.52156862745098043, 0.73921568627450984, 1.0) -(0.0, 0.52549019607843139, 0.73725490196078436, 1.0) -(0.0, 0.52941176470588236, 0.73529411764705888, 1.0) -(0.0, 0.53333333333333333, 0.73333333333333339, 1.0) -(0.0, 0.53725490196078429, 0.73137254901960791, 1.0) -(0.0, 0.54117647058823526, 0.72941176470588243, 1.0) -(0.0, 0.54509803921568623, 0.72745098039215694, 1.0) -(0.0, 0.5490196078431373, 0.72549019607843135, 1.0) -(0.0, 0.55294117647058827, 0.72352941176470587, 1.0) -(0.0, 0.55686274509803924, 0.72156862745098038, 1.0) -(0.0, 0.5607843137254902, 0.7196078431372549, 1.0) -(0.0, 0.56470588235294117, 0.71764705882352942, 1.0) -(0.0, 0.56862745098039214, 0.71568627450980393, 1.0) -(0.0, 0.5725490196078431, 0.71372549019607845, 1.0) -(0.0, 0.57647058823529407, 0.71176470588235297, 1.0) -(0.0, 0.58039215686274503, 0.70980392156862748, 1.0) -(0.0, 0.58431372549019611, 0.70784313725490189, 1.0) -(0.0, 0.58823529411764708, 0.70588235294117641, 1.0) -(0.0, 0.59215686274509804, 0.70392156862745092, 1.0) -(0.0, 0.59607843137254901, 0.70196078431372544, 1.0) -(0.0, 0.59999999999999998, 0.69999999999999996, 1.0) -(0.0, 0.60392156862745094, 0.69803921568627447, 1.0) -(0.0, 0.60784313725490191, 0.69607843137254899, 1.0) -(0.0, 0.61176470588235299, 0.69411764705882351, 1.0) -(0.0, 0.61568627450980395, 0.69215686274509802, 1.0) -(0.0, 0.61960784313725492, 0.69019607843137254, 1.0) -(0.0, 0.62352941176470589, 0.68823529411764706, 1.0) -(0.0, 0.62745098039215685, 0.68627450980392157, 1.0) -(0.0, 0.63137254901960782, 0.68431372549019609, 1.0) -(0.0, 0.63529411764705879, 0.68235294117647061, 1.0) -(0.0, 0.63921568627450975, 0.68039215686274512, 1.0) -(0.0, 0.64313725490196072, 0.67843137254901964, 1.0) -(0.0, 0.6470588235294118, 0.67647058823529416, 1.0) -(0.0, 0.65098039215686276, 0.67450980392156867, 1.0) -(0.0, 0.65490196078431373, 0.67254901960784319, 1.0) -(0.0, 0.6588235294117647, 0.67058823529411771, 1.0) -(0.0, 0.66274509803921566, 0.66862745098039222, 1.0) -(0.0, 0.66666666666666663, 0.66666666666666674, 1.0) -(0.0, 0.6705882352941176, 0.66470588235294126, 1.0) -(0.0, 0.67450980392156867, 0.66274509803921566, 1.0) -(0.0, 0.67843137254901964, 0.66078431372549018, 1.0) -(0.0, 0.68235294117647061, 0.6588235294117647, 1.0) -(0.0, 0.68627450980392157, 0.65686274509803921, 1.0) -(0.0, 0.69019607843137254, 0.65490196078431373, 1.0) -(0.0, 0.69411764705882351, 0.65294117647058825, 1.0) -(0.0, 0.69803921568627447, 0.65098039215686276, 1.0) -(0.0, 0.70196078431372544, 0.64901960784313728, 1.0) -(0.0, 0.70588235294117641, 0.6470588235294118, 1.0) -(0.0, 0.70980392156862748, 0.6450980392156862, 1.0) -(0.0, 0.71372549019607845, 0.64313725490196072, 1.0) -(0.0, 0.71764705882352942, 0.64117647058823524, 1.0) -(0.0, 0.72156862745098038, 0.63921568627450975, 1.0) -(0.0, 0.72549019607843135, 0.63725490196078427, 1.0) -(0.0, 0.72941176470588232, 0.63529411764705879, 1.0) -(0.0, 0.73333333333333328, 0.6333333333333333, 1.0) -(0.0, 0.73725490196078436, 0.63137254901960782, 1.0) -(0.0, 0.74117647058823533, 0.62941176470588234, 1.0) -(0.0, 0.74509803921568629, 0.62745098039215685, 1.0) -(0.0, 0.74901960784313726, 0.62549019607843137, 1.0) -(0.0, 0.75294117647058822, 0.62352941176470589, 1.0) -(0.0, 0.75686274509803919, 0.6215686274509804, 1.0) -(0.0, 0.76078431372549016, 0.61960784313725492, 1.0) -(0.0, 0.76470588235294112, 0.61764705882352944, 1.0) -(0.0, 0.76862745098039209, 0.61568627450980395, 1.0) -(0.0, 0.77254901960784317, 0.61372549019607847, 1.0) -(0.0, 0.77647058823529413, 0.61176470588235299, 1.0) -(0.0, 0.7803921568627451, 0.6098039215686275, 1.0) -(0.0, 0.78431372549019607, 0.60784313725490202, 1.0) -(0.0, 0.78823529411764703, 0.60588235294117654, 1.0) -(0.0, 0.792156862745098, 0.60392156862745106, 1.0) -(0.0, 0.79607843137254897, 0.60196078431372557, 1.0) -(0.0, 0.80000000000000004, 0.59999999999999998, 1.0) -(0.0, 0.80392156862745101, 0.59803921568627449, 1.0) -(0.0, 0.80784313725490198, 0.59607843137254901, 1.0) -(0.0, 0.81176470588235294, 0.59411764705882353, 1.0) -(0.0, 0.81568627450980391, 0.59215686274509804, 1.0) -(0.0, 0.81960784313725488, 0.59019607843137256, 1.0) -(0.0, 0.82352941176470584, 0.58823529411764708, 1.0) -(0.0, 0.82745098039215681, 0.5862745098039216, 1.0) -(0.0, 0.83137254901960778, 0.58431372549019611, 1.0) -(0.0, 0.83529411764705885, 0.58235294117647052, 1.0) -(0.0, 0.83921568627450982, 0.58039215686274503, 1.0) -(0.0, 0.84313725490196079, 0.57843137254901955, 1.0) -(0.0, 0.84705882352941175, 0.57647058823529407, 1.0) -(0.0, 0.85098039215686272, 0.57450980392156858, 1.0) -(0.0, 0.85490196078431369, 0.5725490196078431, 1.0) -(0.0, 0.85882352941176465, 0.57058823529411762, 1.0) -(0.0, 0.86274509803921573, 0.56862745098039214, 1.0) -(0.0, 0.8666666666666667, 0.56666666666666665, 1.0) -(0.0, 0.87058823529411766, 0.56470588235294117, 1.0) -(0.0, 0.87450980392156863, 0.56274509803921569, 1.0) -(0.0, 0.8784313725490196, 0.5607843137254902, 1.0) -(0.0, 0.88235294117647056, 0.55882352941176472, 1.0) -(0.0, 0.88627450980392153, 0.55686274509803924, 1.0) -(0.0, 0.8901960784313725, 0.55490196078431375, 1.0) -(0.0, 0.89411764705882346, 0.55294117647058827, 1.0) -(0.0, 0.89803921568627454, 0.55098039215686279, 1.0) -(0.0, 0.90196078431372551, 0.5490196078431373, 1.0) -(0.0, 0.90588235294117647, 0.54705882352941182, 1.0) -(0.0, 0.90980392156862744, 0.54509803921568634, 1.0) -(0.0, 0.9137254901960784, 0.54313725490196085, 1.0) -(0.0, 0.91764705882352937, 0.54117647058823537, 1.0) -(0.0, 0.92156862745098034, 0.53921568627450989, 1.0) -(0.0, 0.92549019607843142, 0.53725490196078429, 1.0) -(0.0, 0.92941176470588238, 0.53529411764705881, 1.0) -(0.0, 0.93333333333333335, 0.53333333333333333, 1.0) -(0.0, 0.93725490196078431, 0.53137254901960784, 1.0) -(0.0, 0.94117647058823528, 0.52941176470588236, 1.0) -(0.0, 0.94509803921568625, 0.52745098039215688, 1.0) -(0.0, 0.94901960784313721, 0.52549019607843139, 1.0) -(0.0, 0.95294117647058818, 0.52352941176470591, 1.0) -(0.0, 0.95686274509803915, 0.52156862745098043, 1.0) -(0.0, 0.96078431372549022, 0.51960784313725483, 1.0) -(0.0, 0.96470588235294119, 0.51764705882352935, 1.0) -(0.0, 0.96862745098039216, 0.51568627450980387, 1.0) -(0.0, 0.97254901960784312, 0.51372549019607838, 1.0) -(0.0, 0.97647058823529409, 0.5117647058823529, 1.0) -(0.0, 0.98039215686274506, 0.50980392156862742, 1.0) -(0.0, 0.98431372549019602, 0.50784313725490193, 1.0) -(0.0, 0.9882352941176471, 0.50588235294117645, 1.0) -(0.0, 0.99215686274509807, 0.50392156862745097, 1.0) -(0.0, 0.99607843137254903, 0.50196078431372548, 1.0) -(0.0, 1.0, 0.5, 1.0) diff --git a/extern/tfn/core.h b/extern/tfn/core.h deleted file mode 100644 index b336488..0000000 --- a/extern/tfn/core.h +++ /dev/null @@ -1,792 +0,0 @@ -// ======================================================================== // -// Copyright Qi Wu, since 2019 // -// Copyright SCI Institute, University of Utah, 2018 // -// ======================================================================== // -#pragma once - -#define TFN_MODULE_INTERFACE // place-holder - -#include "helper.h" -#include "json.h" - -#include -#include -#include -#include -#include -#include - -namespace tfn { - -// ======================================================================== -#define TFN_MODULE_VERSION "0.03 WIP" -inline TFN_MODULE_INTERFACE const char *GetVersion() -{ - return TFN_MODULE_VERSION; - return TFN_MODULE_VERSION; - return TFN_MODULE_VERSION; -}; - -// ======================================================================== -// The magic number is 'OSTF' in ASCII -const static uint32_t MAGIC_NUMBER = 0x4f535446; -const static uint64_t CURRENT_VERSION = 1; - -#ifdef TFN_MODULE_EXTERNAL_VECTOR_TYPES -/*! we assume the app already defines osp::vec types. Note those - HAVE to be compatible with the data layouts used below. - Note: this feature allows the application to use its own vector - type library in the following way - a) include your own vector library (say, ospcommon::vec3f etc, when using - the ospcommon library) - b) make sure the proper vec3f etc are defined in a osp:: namespace, e.g., - using - namespace tfn { - typedef ospcommon::vec3f vec3f; - } - c) defines OSPRAY_EXTERNAL_VECTOR_TYPES - d) include vec.h - ! */ -#else -// clang-format off -struct vec2f { float x, y; }; -struct vec2i { int x, y; }; -struct vec3f { float x, y, z; }; -struct vec3i { int x, y, z; }; -struct vec4f { float x, y, z, w; }; -struct vec4i { int x, y, z, w; }; -// clang-format on -#endif - -using json = nlohmann::json; -#define define_vector_serialization(T) \ - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(vec2##T, x, y); \ - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(vec3##T, x, y, z); \ - NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(vec4##T, x, y, z, w); -define_vector_serialization(i); -define_vector_serialization(f); -#undef define_vector_serialization - -using list1f = std::vector; -using list2f = std::vector; -using list3f = std::vector; -using list4f = std::vector; - -class TransferFunctionCore -{ - template - inline T1 mix(const T1 &x, const T1 &y, const T2 &a) - { - return (x + a * (y - x)); - } - - public: - struct ColorControl - { - ColorControl() : position(0.0f), color(1.0f, 1.0f, 1.0f) {} - ColorControl(float _value, float r, float g, float b) : position(_value), color(r, g, b) {} - ColorControl(float _value, const vec3f &rgb) : position(_value), color(rgb) {} - bool operator<(const ColorControl &other) const { return (position < other.position); } - - float& p() { return position; } - const float& p() const { return position; } - - float position; - vec3f color; - }; - - static_assert(sizeof(ColorControl) == sizeof(vec4f), "ColorControl = vec4f"); - - struct AlphaControl - { - AlphaControl() : pos(0.0) {} - AlphaControl(const vec2f &pos_) : pos(pos_) {} - - float& p() { return pos.x; } - const float& p() const { return pos.x; } - - vec2f pos; - }; - - static_assert(sizeof(AlphaControl) == sizeof(vec2f), "AlphaControl = vec2f"); - - struct GaussianObject - { - GaussianObject(); - GaussianObject(float _mean, float _sigma, float _heightFactor, int resolution); - float value(float x) const; - float height() const; - void setHeight(float h); - void update(); - - float mean; - float sigma; - float heightFactor; - std::vector alphaArray; - }; - - public: - TransferFunctionCore(int resolution = 1024); - TransferFunctionCore(const TransferFunctionCore &other); - ~TransferFunctionCore() {} - - TransferFunctionCore &operator=(const TransferFunctionCore &) = default; // deep copy - - void clear(); - - const vec4f *data() const; - int size() const; - int resolution() const; - - float *alphaArray(); - const float *alphaArray() const; - void clearAlphaTable(); - - int colorControlCount() const; - std::vector *colorControlVector() { return &m_colorControls; } - const std::vector *colorControlVector() const { return &m_colorControls; } - ColorControl &colorControl(int index); - const ColorControl &colorControl(int index) const; - ColorControl &addColorControl(const ColorControl &control); - ColorControl &addColorControl(float value, float r, float g, float b); - ColorControl &insertColorControl(float pos); - void removeColorControl(int index); - void clearColorControls(); - - int alphaControlCount() const; - std::vector *alphaControlVector() { return &m_alphaControls; } - const std::vector *alphaControlVector() const { return &m_alphaControls; } - AlphaControl &alphaControl(int index); - const AlphaControl &alphaControl(int index) const; - AlphaControl &addAlphaControl(const AlphaControl &ctrl); - AlphaControl &addAlphaControl(const vec2f &pos); - void removeAlphaControl(int index); - void clearAlphaControls(); - - int gaussianObjectCount() const; - GaussianObject &gaussianObject(int index); - const GaussianObject &gaussianObject(int index) const; - GaussianObject &addGaussianObject(const GaussianObject &gaussObj); - GaussianObject &addGaussianObject(float mean, float sigma, float heightFactor); - void removeGaussianObject(int index); - void clearGaussianObjects(); - - void updateColorMap(); - - static std::unique_ptr fromRainbowMap(int resolution = 1024); - - protected: - void updateFromAlphaControls(); - - private: - std::vector m_rgbaTable; - std::vector m_alphaArray; - std::vector m_colorControls; // color control points - std::vector m_alphaControls; - std::vector m_gaussianObjects; -}; - -// ======================================================================== -// ======================================================================== - -template -static ScalarT scalarFromJson(const json &in) -{ - ScalarT v; - from_json(in, v); - return v; -} -template -static json scalarToJson(const ScalarT &in) -{ - json v; - to_json(v, in); - return v; -} - -static std::string toBase64(const char *byteArray, size_t size, bool urlEncoding = false) -{ - const char alphabetBase64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - const char alphabetBase64Url[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; - const char *const alphabet = (urlEncoding ? alphabetBase64Url : alphabetBase64); - const char padchar = '='; - int padlen = 0; - std::unique_ptr tmp(new char[size * 4 / 3 + 3 + 1]); - size_t i = 0; - char *out = tmp.get(); - while (i < size) { - // encode 3 bytes at a time - int chunk = 0; - chunk |= int((unsigned char)(byteArray[i++])) << 16; - if (i == size) { - padlen = 2; - } else { - chunk |= int((unsigned char)(byteArray[i++])) << 8; - if (i == size) { - padlen = 1; - } else { - chunk |= int((unsigned char)(byteArray[i++])); - } - } - int j0 = (chunk & 0x00fc0000) >> 18; - int j1 = (chunk & 0x0003f000) >> 12; - int j2 = (chunk & 0x00000fc0) >> 6; - int j3 = (chunk & 0x0000003f); - *out++ = alphabet[j0]; - *out++ = alphabet[j1]; - *out++ = (padlen > 1 ? padchar : alphabet[j2]); - *out++ = (padlen > 0 ? padchar : alphabet[j3]); - } - *out = '\0'; - return std::string(tmp.get()); -} - -static void fromBase64(const std::string &base64, char *byteArray, bool urlEncoding = false) -{ - unsigned int buf = 0; - int nbits = 0; - char *tmp = byteArray; - int offset = 0; - for (int i = 0; i < base64.size(); ++i) { - int ch = base64[i]; - int d; - if (ch >= 'A' && ch <= 'Z') { - d = ch - 'A'; - } else if (ch >= 'a' && ch <= 'z') { - d = ch - 'a' + 26; - } else if (ch >= '0' && ch <= '9') { - d = ch - '0' + 52; - } else if (ch == '+' && !urlEncoding) { - d = 62; - } else if (ch == '-' && urlEncoding) { - d = 62; - } else if (ch == '/' && !urlEncoding) { - d = 63; - } else if (ch == '_' && urlEncoding) { - d = 63; - } else { - d = -1; - } - if (d != -1) { - buf = (buf << 6) | d; - nbits += 6; - if (nbits >= 8) { - nbits -= 8; - tmp[offset++] = buf >> nbits; - buf &= (1 << nbits) - 1; - } - } - } -} - -static size_t sizeBase64(const std::string &base64) -{ - size_t size = base64.size() * 3 / 4; - if (base64.size() >= 1 && base64[base64.size() - 1] == '=') - size--; - if (base64.size() >= 2 && base64[base64.size() - 2] == '=') - size--; - return size; -} - -namespace { - -template -T colorFromJson(json jscolor); - -template <> -inline vec3f colorFromJson(json jscolor) -{ - if (!jscolor.contains("r") || !jscolor.contains("g") || !jscolor.contains("b")) - return vec3f(); - return vec3f(jscolor["r"].get(), jscolor["g"].get(), jscolor["b"].get()); -} - -template <> -inline vec4f colorFromJson(json jscolor) -{ - if (!jscolor.contains("r") || !jscolor.contains("g") || !jscolor.contains("b") || !jscolor.contains("a")) - return vec4f(); - return vec4f(jscolor["r"].get(), jscolor["g"].get(), jscolor["b"].get(), jscolor["a"].get()); -} - -} - -static json colorToJson(const vec3f &color) -{ - json js; - js["r"] = color.x; - js["g"] = color.y; - js["b"] = color.z; - return js; -} - -static json colorToJson(const vec4f &color) -{ - json js; - js["r"] = color.x; - js["g"] = color.y; - js["b"] = color.z; - js["a"] = color.w; - return js; -} - -static vec2f rangeFromJson(json jsrange) -{ - if (!jsrange.contains("minimum") || !jsrange.contains("maximum")) - return vec2f(0.0, 0.0); - return vec2f(jsrange["minimum"].get(), jsrange["maximum"].get()); -} - -// ======================================================================== -// ======================================================================== - -inline TransferFunctionCore::GaussianObject::GaussianObject() : mean(0.5f), sigma(1.0f), heightFactor(1.0f), alphaArray(1024) -{ - update(); -} - -inline TransferFunctionCore::GaussianObject::GaussianObject(float _mean, float _sigma, float _heightFactor, int resolution) - : mean(_mean), sigma(_sigma), heightFactor(_heightFactor), alphaArray(resolution) -{ - update(); -} - -inline float TransferFunctionCore::GaussianObject::value(float x) const -{ - float diff = x - mean; - return heightFactor / (sigma * std::sqrt(2.0f * float(M_PI))) * std::exp(-(diff * diff) / (2.0f * sigma * sigma)); -} - -inline float TransferFunctionCore::GaussianObject::height() const -{ - return value(mean); -} - -inline void TransferFunctionCore::GaussianObject::setHeight(float h) -{ - heightFactor = h * sigma * std::sqrt(2.0f * float(M_PI)); -} - -inline void TransferFunctionCore::GaussianObject::update() -{ - float invRes = 1.0f / float(alphaArray.size()); - for (size_t i = 0; i < alphaArray.size(); ++i) { - float val = value((float(i) + 0.5f) * invRes); - alphaArray[i] = clamp(val, 0.0f, 1.0f); - } -} - -inline TransferFunctionCore::TransferFunctionCore(int resolution) - : m_rgbaTable(resolution), m_alphaArray(resolution, 0) -{ - assert(resolution > 0); - // m_colorControls.push_back(ColorControl(0.0f, 0.0f, 0.0f, 0.0f)); - // m_colorControls.push_back(ColorControl(1.0f, 1.0f, 1.0f, 1.0f)); - // GaussianObject gaussObj = GaussianObject(0.5f, 0.1f, 1.0f, resolution); - // gaussObj.setHeight(0.5f); - // gaussObj.update(); - // for (int i = 0; i < resolution; ++i) m_alphaArray[i] = gaussObj.alphaArray[i]; - updateColorMap(); -} - -inline TransferFunctionCore::TransferFunctionCore(const TransferFunctionCore &other) -{ - *this = other; -} - -inline void TransferFunctionCore::clear() -{ - m_rgbaTable.clear(); - m_alphaArray.clear(); - m_colorControls.clear(); - m_alphaControls.clear(); - m_gaussianObjects.clear(); -} - -inline const vec4f * TransferFunctionCore::data() const -{ - return m_rgbaTable.data(); -} - -inline int TransferFunctionCore::size() const -{ - return int(m_rgbaTable.size()); -} - -inline int TransferFunctionCore::resolution() const -{ - return int(m_rgbaTable.size()); -} - -inline float * TransferFunctionCore::alphaArray() -{ - return &m_alphaArray.front(); -} - -inline const float * TransferFunctionCore::alphaArray() const -{ - return &m_alphaArray.front(); -} - -inline void TransferFunctionCore::clearAlphaTable() -{ - for (int i = 0; i < int(m_alphaArray.size()); ++i) m_alphaArray[i] = 0.0f; - updateColorMap(); -} - -inline int TransferFunctionCore::colorControlCount() const -{ - return int(m_colorControls.size()); -} - -inline TransferFunctionCore::ColorControl& TransferFunctionCore::colorControl(int index) -{ - return m_colorControls[index]; -} - -inline const TransferFunctionCore::ColorControl& TransferFunctionCore::colorControl(int index) const -{ - return m_colorControls[index]; -} - -inline TransferFunctionCore::ColorControl& TransferFunctionCore::addColorControl(const ColorControl &control) -{ - m_colorControls.push_back(control); - updateColorMap(); - return m_colorControls.back(); -} - -inline TransferFunctionCore::ColorControl& TransferFunctionCore::addColorControl(float value, float r, float g, float b) -{ - return addColorControl(ColorControl(value, r, g, b)); -} - -inline TransferFunctionCore::ColorControl& TransferFunctionCore::insertColorControl(float pos) -{ - ColorControl control; - control.position = pos; - std::vector colorControls = m_colorControls; - std::sort(colorControls.begin(), colorControls.end()); - int controlCount = int(colorControls.size()); - // find the first color control greater than the value - int firstLarger = 0; - while (firstLarger < controlCount && pos > colorControls[firstLarger].position) - firstLarger++; - // less than the leftmost color control - if (firstLarger <= 0) { - control.color = colorControls[firstLarger].color; - } - // greater than the rightmost color control - else if (firstLarger >= controlCount) { - control.color = colorControls[firstLarger - 1].color; - } - // between two color controls - else { - ColorControl &left = colorControls[firstLarger - 1]; - ColorControl &right = colorControls[firstLarger]; - float w = std::abs(pos - left.position) / std::abs(right.position - left.position); - control.color = mix(left.color, right.color, w); - } - m_colorControls.push_back(control); - updateColorMap(); - return m_colorControls.back(); -} - -inline void TransferFunctionCore::removeColorControl(int index) -{ - assert(index >= 0 && index < int(m_colorControls.size())); - for (int i = index; i < int(m_colorControls.size()) - 1; ++i) m_colorControls[i] = m_colorControls[i + 1]; - m_colorControls.pop_back(); - updateColorMap(); -} - -inline void TransferFunctionCore::clearColorControls() -{ - m_colorControls.clear(); - updateColorMap(); -} - -inline int TransferFunctionCore::alphaControlCount() const -{ - return int(m_alphaControls.size()); -} - -inline TransferFunctionCore::AlphaControl& TransferFunctionCore::alphaControl(int index) -{ - return m_alphaControls[index]; -} - -inline const TransferFunctionCore::AlphaControl& TransferFunctionCore::alphaControl(int index) const -{ - return m_alphaControls[index]; -} - -inline TransferFunctionCore::AlphaControl& TransferFunctionCore::addAlphaControl(const AlphaControl &ctrl) -{ - m_alphaControls.push_back(ctrl); - updateColorMap(); - return m_alphaControls.back(); -} - -inline TransferFunctionCore::AlphaControl& TransferFunctionCore::addAlphaControl(const vec2f &pos) -{ - return addAlphaControl(AlphaControl(pos)); -} - -inline void TransferFunctionCore::removeAlphaControl(int index) -{ - assert(index >= 0 && index < int(m_alphaControls.size())); - for (int i = index; i < int(m_alphaControls.size()) - 1; ++i) m_alphaControls[i] = m_alphaControls[i + 1]; - m_alphaControls.pop_back(); - updateColorMap(); -} - -inline void TransferFunctionCore::clearAlphaControls() -{ - m_alphaControls.clear(); - updateColorMap(); -} - -inline int TransferFunctionCore::gaussianObjectCount() const -{ - return int(m_gaussianObjects.size()); -} - -inline TransferFunctionCore::GaussianObject& TransferFunctionCore::gaussianObject(int index) -{ - return m_gaussianObjects[index]; -} - -inline const TransferFunctionCore::GaussianObject& TransferFunctionCore::gaussianObject(int index) const -{ - return m_gaussianObjects[index]; -} - -inline TransferFunctionCore::GaussianObject& TransferFunctionCore::addGaussianObject(const GaussianObject &gaussObj) -{ - m_gaussianObjects.push_back(gaussObj); - if (m_gaussianObjects.back().alphaArray.size() != m_alphaArray.size()) { - m_gaussianObjects.back().alphaArray.resize(m_alphaArray.size()); - m_gaussianObjects.back().update(); - } - updateColorMap(); - return m_gaussianObjects.back(); -} - -inline TransferFunctionCore::GaussianObject& TransferFunctionCore::addGaussianObject(float mean, float sigma, float heightFactor) -{ - m_gaussianObjects.push_back(GaussianObject(mean, sigma, heightFactor, resolution())); - updateColorMap(); - return m_gaussianObjects.back(); -} - -inline void TransferFunctionCore::removeGaussianObject(int index) -{ - assert(index >= 0 && index < int(m_gaussianObjects.size())); - for (int i = index; i < int(m_gaussianObjects.size()) - 1; ++i) m_gaussianObjects[i] = m_gaussianObjects[i + 1]; - m_gaussianObjects.pop_back(); - updateColorMap(); -} - -inline void TransferFunctionCore::clearGaussianObjects() -{ - m_gaussianObjects.clear(); - updateColorMap(); -} - -inline void TransferFunctionCore::updateColorMap() -{ - std::vector colorControls = m_colorControls; - if (colorControls.empty()) { - colorControls.push_back(ColorControl(0.0f, 0.0f, 0.0f, 0.0f)); - } - std::sort(colorControls.begin(), colorControls.end()); - int controlCount = int(colorControls.size()); - auto upperBound = colorControls.begin(); - for (int i = 0; i < resolution(); ++i) { - float value = (float(i) + 0.5f) / float(resolution()); - vec3f color; - upperBound = std::upper_bound(upperBound, colorControls.end(), ColorControl(value, 0.0f, 0.0f, 0.0f)); - int ubIndex = int(upperBound - colorControls.begin()); - // less than the leftmost color control - if (ubIndex <= 0) { - color = colorControls[ubIndex].color; - } - - // greater than the rightmost color control - else if (ubIndex >= controlCount) { - color = colorControls[ubIndex - 1].color; - } - // between two color controls - else { - ColorControl &left = colorControls[ubIndex - 1]; - ColorControl &right = colorControls[ubIndex]; - float w = std::abs(value - left.position) / std::abs(right.position - left.position); - color = mix(left.color, right.color, w); - } - m_rgbaTable[i] = vec4f(color, m_alphaArray[i]); - for (int j = 0; j < int(m_gaussianObjects.size()); ++j) { - m_rgbaTable[i].w = std::max(m_rgbaTable[i].w, m_gaussianObjects[j].alphaArray[i]); - } - } - updateFromAlphaControls(); -} - -inline std::unique_ptr TransferFunctionCore::fromRainbowMap(int resolution) -{ - std::unique_ptr ret(new TransferFunctionCore(resolution)); - ret->m_colorControls.clear(); - ret->m_colorControls.push_back(ColorControl(0.0f / 6.0f, 0.0f, 0.364706f, 1.0f)); - ret->m_colorControls.push_back(ColorControl(1.0f / 6.0f, 0.0f, 1.0f, 0.976471f)); - ret->m_colorControls.push_back(ColorControl(2.0f / 6.0f, 0.0f, 1.0f, 0.105882f)); - ret->m_colorControls.push_back(ColorControl(3.0f / 6.0f, 0.968627f, 1.0f, 0.0f)); - ret->m_colorControls.push_back(ColorControl(4.0f / 6.0f, 1.0f, 0.490196f, 0.0f)); - ret->m_colorControls.push_back(ColorControl(5.0f / 6.0f, 1.0f, 0.0f, 0.0f)); - ret->m_colorControls.push_back(ColorControl(6.0f / 6.0f, 0.662745f, 0.0f, 1.0f)); - ret->m_gaussianObjects.clear(); - ret->updateColorMap(); - return ret; -} - -inline void TransferFunctionCore::updateFromAlphaControls() -{ - if (m_alphaControls.empty()) return; - std::vector opcControls = m_alphaControls; - auto compFunc = [](const AlphaControl &a, const AlphaControl &b) { - return (a.pos.x < b.pos.x); - }; - std::sort(opcControls.begin(), opcControls.end(), compFunc); - int controlCount = int(opcControls.size()); - auto upperBound = opcControls.begin(); - for (int i = 0; i < resolution(); ++i) { - // double value = (double(i) + 0.5f) / double(resolution()); - double value = double(i) / double(resolution() - 1); - upperBound = std::upper_bound(upperBound, opcControls.end(), AlphaControl(vec2f((float)value, 0.0f)), compFunc); - int ubIndex = int(upperBound - opcControls.begin()); - double alpha; - // less than the leftmost control - if (ubIndex <= 0) { - alpha = opcControls[ubIndex].pos.y; - } - // greater than the rightmost control - else if (ubIndex >= controlCount) { - alpha = opcControls[ubIndex - 1].pos.y; - } - // between two color controls - else { - auto &left = opcControls[ubIndex - 1]; - auto &right = opcControls[ubIndex]; - double w = std::abs(value - left.pos.x) / std::abs(right.pos.x - left.pos.x); - alpha = mix(left.pos.y, right.pos.y, (float)w); - } - m_rgbaTable[i].w = std::max(m_rgbaTable[i].w, float(alpha)); - } -} - -inline void saveTransferFunction(const TransferFunctionCore& tfn, json& jstfn) -{ - jstfn["resolution"] = tfn.resolution(); - jstfn["alphaArray"]["encoding"] = "BASE64"; - jstfn["alphaArray"]["data"] = toBase64(reinterpret_cast(tfn.alphaArray()), sizeof(float) * tfn.resolution()); - - for (int i = 0; i < tfn.colorControlCount(); ++i) { - auto cControl = tfn.colorControl(i); - jstfn["colorControls"][i]["position"] = cControl.position; - jstfn["colorControls"][i]["color"] = colorToJson(cControl.color); - } - for (int i = 0; i < tfn.alphaControlCount(); ++i) { - auto oControl = tfn.alphaControl(i); - jstfn["opacityControl"][i]["position"] = scalarToJson(oControl.pos); - } - for (int i = 0; i < tfn.gaussianObjectCount(); ++i) { - auto gaussianObject = tfn.gaussianObject(i); - jstfn["gaussianObjects"][i]["mean"] = gaussianObject.mean; - jstfn["gaussianObjects"][i]["sigma"] = gaussianObject.sigma; - jstfn["gaussianObjects"][i]["heightFactor"] = gaussianObject.heightFactor; - } -} - -inline void loadTransferFunction(const json& jstfn, TransferFunctionCore& tfn) -{ - int resolution = 1024; - if (jstfn.contains("resolution")) { - resolution = jstfn["resolution"].get(); - } - - std::string alphaArrayBase64; - if (jstfn.contains("alphaArray") && jstfn["alphaArray"].contains("data")) { - if (jstfn["alphaArray"].contains("encoding") && jstfn["alphaArray"]["encoding"].get() == "BASE64") { - alphaArrayBase64 = jstfn["alphaArray"]["data"].get(); - resolution = int(sizeBase64(alphaArrayBase64) / sizeof(float)); - } - } - - TransferFunctionCore tf(resolution); - if (!alphaArrayBase64.empty()) { - fromBase64(alphaArrayBase64, reinterpret_cast(tf.alphaArray())); - } - - tf.clearColorControls(); - if (jstfn.contains("colorControls")) { - int count = (int)jstfn["colorControls"].size(); - for (int i = 0; i < count; ++i) { - const json &js_cc = jstfn["colorControls"][i]; - if (!js_cc.contains("position") || !js_cc.contains("color")) continue; - TransferFunctionCore::ColorControl colorControl; - colorControl.position = js_cc["position"].get(); - colorControl.color = colorFromJson(js_cc["color"]); - tf.addColorControl(colorControl); - } - } - - tf.clearAlphaControls(); - if (jstfn.contains("opacityControl")) { - int count = (int)jstfn["opacityControl"].size(); - for (int i = 0; i < count; ++i) { - const json &js_oc = jstfn["opacityControl"][i]; - if (!js_oc.contains("position")) continue; - TransferFunctionCore::AlphaControl opcControl(scalarFromJson(js_oc["position"])); - tf.addAlphaControl(opcControl); - } - } - - tf.clearGaussianObjects(); - if (jstfn.contains("gaussianObjects")) { - int count = (int)jstfn["gaussianObjects"].size(); - for (int i = 0; i < count; ++i) { - const json &json_go = jstfn["gaussianObjects"][i]; - if (!json_go.contains("mean") || !json_go.contains("sigma") || !json_go.contains("heightFactor")) continue; - TransferFunctionCore::GaussianObject gaussianObject(json_go["mean"].get(), json_go["sigma"].get(), json_go["heightFactor"].get(), resolution); - tf.addGaussianObject(gaussianObject); - } - } - tf.updateColorMap(); - - /* finalize */ - - // auto *table = (vec4f *)tf.data(); - // std::vector color(tf.resolution()); - // std::vector alpha(tf.resolution()); - // for (int i = 0; i < tf.resolution(); ++i) { - // auto rgba = table[i]; - // color[i] = vec4f((float)i / (tf.resolution() - 1), rgba.x, rgba.y, rgba.z); - // alpha[i] = vec2f((float)i / (tf.resolution() - 1), rgba.w); - // } - // tfn.color = std::move(color); - // tfn.alpha = std::move(alpha); - - // if (jstfn.contains("valueRange")) { - // auto r = rangeFromJson(jstfn["valueRange"]); - // tfn.range.x = r.x; - // tfn.range.y = r.y; - // } - // else { - // tfn.range.x = 0.f; - // tfn.range.y = 1.f; - // } - - tfn = std::move(tf); -} - -} // namespace tfn diff --git a/extern/tfn/default.h b/extern/tfn/default.h deleted file mode 100644 index 2678551..0000000 --- a/extern/tfn/default.h +++ /dev/null @@ -1,1248 +0,0 @@ -// ======================================================================== // -// Copyright Qi Wu, since 2019 // -// Copyright SCI Institute, University of Utah, 2018 // -// ======================================================================== // -#pragma once - -#include -#include -#include - -namespace tfn { - -static const std::map> _predef_color_table_ = { - {"bluehot", {0.f, 0.f, 0.f, 1.f, 0.25f, 0.f, 1.f, 1.f, 0.5f, 0.f, 1.f, 0.f, 0.75f, 1.f, 1.f, 0.f, 1.f, 1.f, 0.f, 0.f}}, - {"caleblack", - { - 0.f, - 0.f, - 0.f, - 0.f, - 0.17f, - 0.f, - 0.f, - 1.f, - 0.34f, - 0.f, - 1.f, - 1.f, - 0.50f, - 0.f, - 1.f, - 0.f, - 0.67f, - 1.f, - 1.f, - 0.f, - 0.84f, - 1.f, - 0.f, - 0.f, - 1.f, - 1.f, - 0.f, - 1.f, - }}, - {"calewhite", - { - 0.f, - 1.f, - 1.f, - 1.f, - 0.17f, - 0.f, - 0.f, - 1.f, - 0.34f, - 0.f, - 1.f, - 1.f, - 0.50f, - 0.f, - 1.f, - 0.f, - 0.67f, - 1.f, - 1.f, - 0.f, - 0.84f, - 1.f, - 0.f, - 0.f, - 1.f, - 1.f, - 0.f, - 1.f, - }}, - {"gray", {0.f, 0.f, 0.f, 0.f, 1.f, 1.f, 1.f, 1.f}}, - {"xray", {0.f, 1.f, 1.f, 1.f, 1.f, 0.f, 0.f, 0.f}}, - {"rainbow", - { - 0.f, - 1.f, - 0.f, - 1.f, - 0.2f, - 0.f, - 0.f, - 1.f, - 0.4f, - 0.f, - 1.f, - 1.f, - 0.6f, - 0.f, - 1.f, - 0.f, - 0.8f, - 1.f, - 1.f, - 0.f, - 1.0f, - 1.f, - 0.f, - 0.f, - }}, - {"contoured", - { - 0.f, - 0.f, - 0.f, - 1.f, - 0.333f, - 0.f, - 1.f, - 0.f, - 0.666f, - 1.f, - 1.f, - 0.f, - 1.0f, - 1.f, - 0.f, - 0.f, - }}, - {"levels", - { - 0.000f, - 1.00f, - 0.00f, - 0.00f, - 0.034f, - 0.00f, - 1.00f, - 0.00f, - 0.069f, - 0.00f, - 0.00f, - 1.00f, - 0.103f, - 0.00f, - 1.00f, - 1.00f, - 0.138f, - 1.00f, - 0.00f, - 1.00f, - 0.172f, - 1.00f, - 1.00f, - 0.00f, - 0.207f, - 1.00f, - 0.53f, - 0.00f, - 0.241f, - 1.00f, - 0.00f, - 0.53f, - 0.276f, - 0.66f, - 0.66f, - 0.66f, - 0.310f, - 1.00f, - 0.27f, - 0.27f, - 0.345f, - 0.39f, - 1.00f, - 0.39f, - 0.379f, - 0.39f, - 0.39f, - 1.00f, - 0.414f, - 0.16f, - 0.65f, - 0.65f, - 0.448f, - 1.00f, - 0.39f, - 1.00f, - 0.483f, - 1.00f, - 1.00f, - 0.39f, - 0.517f, - 1.00f, - 0.67f, - 0.39f, - 0.552f, - 0.67f, - 0.31f, - 1.00f, - 0.586f, - 0.59f, - 0.00f, - 0.00f, - 0.621f, - 0.00f, - 0.59f, - 0.00f, - 0.655f, - 0.00f, - 0.00f, - 0.59f, - 0.690f, - 0.00f, - 0.43f, - 0.43f, - 0.724f, - 0.59f, - 0.00f, - 0.59f, - 0.759f, - 0.59f, - 0.59f, - 0.00f, - 0.793f, - 0.59f, - 0.33f, - 0.00f, - 0.828f, - 0.63f, - 0.00f, - 0.31f, - 0.862f, - 1.00f, - 0.41f, - 0.11f, - 0.897f, - 0.00f, - 0.67f, - 0.32f, - 0.931f, - 0.27f, - 1.00f, - 0.49f, - 0.966f, - 0.00f, - 0.51f, - 1.00f, - 1.000f, - 0.51f, - 0.00f, - 1.00f, - }}, - {"bluehot", - { - 0.f, - 0.f, - 0.f, - 0.f, - 0.333f, - 0.f, - 0.f, - 0.5f, - 0.666f, - 0.f, - 0.5f, - 1.f, - 1.0f, - 1.f, - 1.f, - 1.f, - }}, - {"orangehot", - { - 0.f, - 0.f, - 0.f, - 0.f, - 0.333f, - 0.5f, - 0.f, - 0.f, - 0.666f, - 1.f, - 0.5f, - 0.f, - 1.0f, - 1.f, - 1.f, - 1.f, - }}, - {"hot_and_cold", - { - 0.f, - 0.f, - 1.f, - 1.f, - 0.45f, - 0.f, - 0.f, - 1.f, - 0.5f, - 0.f, - 0.f, - 0.5f, - 0.55f, - 1.f, - 0.f, - 0.f, - 1.0f, - 1.f, - 1.f, - 0.f, - }}, - {"hot_desaturated", - { - 0.0f, - 0.28f, - 0.28f, - 0.86f, - 0.143f, - 0.f, - 0.f, - 0.36f, - 0.285f, - 0.f, - 1.f, - 1.f, - 0.429f, - 0.f, - 0.5f, - 0.f, - 0.571f, - 1.f, - 1.f, - 0.f, - 0.714f, - 1.f, - 0.38f, - 0.f, - 0.857f, - 0.42f, - 0.f, - 0.f, - 1.0f, - 0.88f, - 0.3f, - 0.3f, - }}, - {"difference", - { - 0.f, - 0.f, - 0.f, - 1.f, - 0.5f, - 1.f, - 1.f, - 1.f, - 1.0f, - 1.f, - 0.f, - 0.f, - }}, - {"jmol_colors", /* CPK Molecular Colors used by Jmol */ - { - 0.000f, - 0.125f, - 0.125f, - 0.125f, - 0.009f, - 1.000f, - 1.000f, - 1.000f, - 0.018f, - 0.851f, - 1.000f, - 1.000f, - 0.028f, - 0.800f, - 0.502f, - 1.000f, - 0.037f, - 0.761f, - 1.000f, - 0.000f, - 0.046f, - 1.000f, - 0.710f, - 0.710f, - 0.055f, - 0.565f, - 0.565f, - 0.565f, - 0.064f, - 0.188f, - 0.314f, - 0.973f, - 0.073f, - 1.000f, - 0.051f, - 0.051f, - 0.083f, - 0.565f, - 0.878f, - 0.314f, - 0.092f, - 0.702f, - 0.890f, - 0.961f, - 0.101f, - 0.671f, - 0.361f, - 0.949f, - 0.110f, - 0.541f, - 1.000f, - 0.000f, - 0.119f, - 0.749f, - 0.651f, - 0.651f, - 0.128f, - 0.941f, - 0.784f, - 0.627f, - 0.138f, - 1.000f, - 0.502f, - 0.000f, - 0.147f, - 1.000f, - 1.000f, - 0.188f, - 0.156f, - 0.122f, - 0.941f, - 0.122f, - 0.165f, - 0.502f, - 0.820f, - 0.890f, - 0.174f, - 0.561f, - 0.251f, - 0.831f, - 0.183f, - 0.239f, - 1.000f, - 0.000f, - 0.193f, - 0.902f, - 0.902f, - 0.902f, - 0.202f, - 0.749f, - 0.761f, - 0.780f, - 0.211f, - 0.651f, - 0.651f, - 0.671f, - 0.220f, - 0.541f, - 0.600f, - 0.780f, - 0.229f, - 0.612f, - 0.478f, - 0.780f, - 0.239f, - 0.878f, - 0.400f, - 0.200f, - 0.248f, - 0.941f, - 0.565f, - 0.627f, - 0.257f, - 0.314f, - 0.816f, - 0.314f, - 0.266f, - 0.784f, - 0.502f, - 0.200f, - 0.275f, - 0.490f, - 0.502f, - 0.690f, - 0.284f, - 0.761f, - 0.561f, - 0.561f, - 0.294f, - 0.400f, - 0.561f, - 0.561f, - 0.303f, - 0.741f, - 0.502f, - 0.890f, - 0.312f, - 1.000f, - 0.631f, - 0.000f, - 0.321f, - 0.651f, - 0.161f, - 0.161f, - 0.330f, - 0.361f, - 0.722f, - 0.820f, - 0.339f, - 0.439f, - 0.180f, - 0.690f, - 0.349f, - 0.000f, - 1.000f, - 0.000f, - 0.358f, - 0.580f, - 1.000f, - 1.000f, - 0.367f, - 0.580f, - 0.878f, - 0.878f, - 0.376f, - 0.451f, - 0.761f, - 0.788f, - 0.385f, - 0.329f, - 0.710f, - 0.710f, - 0.394f, - 0.231f, - 0.620f, - 0.620f, - 0.404f, - 0.141f, - 0.561f, - 0.561f, - 0.413f, - 0.039f, - 0.490f, - 0.549f, - 0.422f, - 0.000f, - 0.412f, - 0.522f, - 0.431f, - 0.753f, - 0.753f, - 0.753f, - 0.440f, - 1.000f, - 0.851f, - 0.561f, - 0.450f, - 0.651f, - 0.459f, - 0.451f, - 0.459f, - 0.400f, - 0.502f, - 0.502f, - 0.468f, - 0.620f, - 0.388f, - 0.710f, - 0.477f, - 0.831f, - 0.478f, - 0.000f, - 0.486f, - 0.580f, - 0.000f, - 0.580f, - 0.495f, - 0.259f, - 0.620f, - 0.690f, - 0.505f, - 0.341f, - 0.090f, - 0.561f, - 0.514f, - 0.000f, - 0.788f, - 0.000f, - 0.523f, - 0.439f, - 0.831f, - 1.000f, - 0.532f, - 1.000f, - 1.000f, - 0.780f, - 0.541f, - 0.851f, - 1.000f, - 0.780f, - 0.550f, - 0.780f, - 1.000f, - 0.780f, - 0.560f, - 0.639f, - 1.000f, - 0.780f, - 0.569f, - 0.561f, - 1.000f, - 0.780f, - 0.578f, - 0.380f, - 1.000f, - 0.780f, - 0.587f, - 0.271f, - 1.000f, - 0.780f, - 0.596f, - 0.188f, - 1.000f, - 0.780f, - 0.606f, - 0.122f, - 1.000f, - 0.780f, - 0.615f, - 0.000f, - 1.000f, - 0.612f, - 0.624f, - 0.000f, - 0.902f, - 0.459f, - 0.633f, - 0.000f, - 0.831f, - 0.322f, - 0.642f, - 0.000f, - 0.749f, - 0.220f, - 0.651f, - 0.000f, - 0.671f, - 0.141f, - 0.661f, - 0.302f, - 0.761f, - 1.000f, - 0.670f, - 0.302f, - 0.651f, - 1.000f, - 0.679f, - 0.129f, - 0.580f, - 0.839f, - 0.688f, - 0.149f, - 0.490f, - 0.671f, - 0.697f, - 0.149f, - 0.400f, - 0.588f, - 0.706f, - 0.090f, - 0.329f, - 0.529f, - 0.716f, - 0.816f, - 0.816f, - 0.878f, - 0.725f, - 1.000f, - 0.820f, - 0.137f, - 0.734f, - 0.722f, - 0.722f, - 0.816f, - 0.743f, - 0.651f, - 0.329f, - 0.302f, - 0.752f, - 0.341f, - 0.349f, - 0.380f, - 0.761f, - 0.620f, - 0.310f, - 0.710f, - 0.771f, - 0.671f, - 0.361f, - 0.000f, - 0.780f, - 0.459f, - 0.310f, - 0.271f, - 0.789f, - 0.259f, - 0.510f, - 0.588f, - 0.798f, - 0.259f, - 0.000f, - 0.400f, - 0.807f, - 0.000f, - 0.490f, - 0.000f, - 0.817f, - 0.439f, - 0.671f, - 0.980f, - 0.826f, - 0.000f, - 0.729f, - 1.000f, - 0.835f, - 0.000f, - 0.631f, - 1.000f, - 0.844f, - 0.000f, - 0.561f, - 1.000f, - 0.853f, - 0.000f, - 0.502f, - 1.000f, - 0.862f, - 0.000f, - 0.420f, - 1.000f, - 0.872f, - 0.329f, - 0.361f, - 0.949f, - 0.881f, - 0.471f, - 0.361f, - 0.890f, - 0.890f, - 0.541f, - 0.310f, - 0.890f, - 0.899f, - 0.631f, - 0.212f, - 0.831f, - 0.908f, - 0.702f, - 0.122f, - 0.831f, - 0.917f, - 0.702f, - 0.122f, - 0.729f, - 0.927f, - 0.702f, - 0.051f, - 0.651f, - 0.936f, - 0.741f, - 0.051f, - 0.529f, - 0.945f, - 0.780f, - 0.000f, - 0.400f, - 0.954f, - 0.800f, - 0.000f, - 0.349f, - 0.963f, - 0.820f, - 0.000f, - 0.310f, - 0.972f, - 0.851f, - 0.000f, - 0.271f, - 0.982f, - 0.878f, - 0.000f, - 0.220f, - 0.991f, - 0.902f, - 0.000f, - 0.180f, - 1.000f, - 0.922f, - 0.000f, - 0.149f, - }}, - {"rasmol_colors", /* CPK Molecular Colors used by Rasmol */ - { - 0.000f, - 0.125f, - 0.125f, - 0.125f, - 0.009f, - 1.000f, - 1.000f, - 1.000f, - 0.018f, - 1.000f, - 0.753f, - 0.796f, - 0.028f, - 0.698f, - 0.133f, - 0.133f, - 0.037f, - 1.000f, - 0.078f, - 0.576f, - 0.046f, - 0.000f, - 1.000f, - 0.000f, - 0.055f, - 0.784f, - 0.784f, - 0.784f, - 0.064f, - 0.561f, - 0.561f, - 1.000f, - 0.073f, - 0.941f, - 0.000f, - 0.000f, - 0.083f, - 0.855f, - 0.647f, - 0.125f, - 0.092f, - 1.000f, - 0.078f, - 0.576f, - 0.101f, - 0.000f, - 0.000f, - 1.000f, - 0.110f, - 0.133f, - 0.545f, - 0.133f, - 0.119f, - 0.502f, - 0.502f, - 0.565f, - 0.128f, - 0.855f, - 0.647f, - 0.125f, - 0.138f, - 1.000f, - 0.647f, - 0.000f, - 0.147f, - 1.000f, - 0.784f, - 0.196f, - 0.156f, - 0.000f, - 1.000f, - 0.000f, - 0.165f, - 1.000f, - 0.078f, - 0.576f, - 0.174f, - 1.000f, - 0.078f, - 0.576f, - 0.183f, - 0.502f, - 0.502f, - 0.565f, - 0.193f, - 1.000f, - 0.078f, - 0.576f, - 0.202f, - 0.502f, - 0.502f, - 0.565f, - 0.211f, - 1.000f, - 0.078f, - 0.576f, - 0.220f, - 0.502f, - 0.502f, - 0.565f, - 0.229f, - 0.502f, - 0.502f, - 0.565f, - 0.239f, - 1.000f, - 0.647f, - 0.000f, - 0.248f, - 1.000f, - 0.078f, - 0.576f, - 0.257f, - 0.647f, - 0.165f, - 0.165f, - 0.266f, - 0.647f, - 0.165f, - 0.165f, - 0.275f, - 0.647f, - 0.165f, - 0.165f, - 0.284f, - 1.000f, - 0.078f, - 0.576f, - 0.294f, - 1.000f, - 0.078f, - 0.576f, - 0.303f, - 1.000f, - 0.078f, - 0.576f, - 0.312f, - 1.000f, - 0.078f, - 0.576f, - 0.321f, - 0.647f, - 0.165f, - 0.165f, - 0.330f, - 1.000f, - 0.078f, - 0.576f, - 0.339f, - 1.000f, - 0.078f, - 0.576f, - 0.349f, - 1.000f, - 0.078f, - 0.576f, - 0.358f, - 1.000f, - 0.078f, - 0.576f, - 0.367f, - 1.000f, - 0.078f, - 0.576f, - 0.376f, - 1.000f, - 0.078f, - 0.576f, - 0.385f, - 1.000f, - 0.078f, - 0.576f, - 0.394f, - 1.000f, - 0.078f, - 0.576f, - 0.404f, - 1.000f, - 0.078f, - 0.576f, - 0.413f, - 1.000f, - 0.078f, - 0.576f, - 0.422f, - 1.000f, - 0.078f, - 0.576f, - 0.431f, - 0.502f, - 0.502f, - 0.565f, - 0.440f, - 1.000f, - 0.078f, - 0.576f, - 0.450f, - 1.000f, - 0.078f, - 0.576f, - 0.459f, - 1.000f, - 0.078f, - 0.576f, - 0.468f, - 1.000f, - 0.078f, - 0.576f, - 0.477f, - 1.000f, - 0.078f, - 0.576f, - 0.486f, - 0.627f, - 0.125f, - 0.941f, - 0.495f, - 1.000f, - 0.078f, - 0.576f, - 0.505f, - 1.000f, - 0.078f, - 0.576f, - 0.514f, - 1.000f, - 0.647f, - 0.000f, - 0.523f, - 1.000f, - 0.078f, - 0.576f, - 0.532f, - 1.000f, - 0.078f, - 0.576f, - 0.541f, - 1.000f, - 0.078f, - 0.576f, - 0.550f, - 1.000f, - 0.078f, - 0.576f, - 0.560f, - 1.000f, - 0.078f, - 0.576f, - 0.569f, - 1.000f, - 0.078f, - 0.576f, - 0.578f, - 1.000f, - 0.078f, - 0.576f, - 0.587f, - 1.000f, - 0.078f, - 0.576f, - 0.596f, - 1.000f, - 0.078f, - 0.576f, - 0.606f, - 1.000f, - 0.078f, - 0.576f, - 0.615f, - 1.000f, - 0.078f, - 0.576f, - 0.624f, - 1.000f, - 0.078f, - 0.576f, - 0.633f, - 1.000f, - 0.078f, - 0.576f, - 0.642f, - 1.000f, - 0.078f, - 0.576f, - 0.651f, - 1.000f, - 0.078f, - 0.576f, - 0.661f, - 1.000f, - 0.078f, - 0.576f, - 0.670f, - 1.000f, - 0.078f, - 0.576f, - 0.679f, - 1.000f, - 0.078f, - 0.576f, - 0.688f, - 1.000f, - 0.078f, - 0.576f, - 0.697f, - 1.000f, - 0.078f, - 0.576f, - 0.706f, - 1.000f, - 0.078f, - 0.576f, - 0.716f, - 1.000f, - 0.078f, - 0.576f, - 0.725f, - 0.855f, - 0.647f, - 0.125f, - 0.734f, - 1.000f, - 0.078f, - 0.576f, - 0.743f, - 1.000f, - 0.078f, - 0.576f, - 0.752f, - 1.000f, - 0.078f, - 0.576f, - 0.761f, - 1.000f, - 0.078f, - 0.576f, - 0.771f, - 1.000f, - 0.078f, - 0.576f, - 0.780f, - 1.000f, - 0.078f, - 0.576f, - 0.789f, - 1.000f, - 0.078f, - 0.576f, - 0.798f, - 1.000f, - 0.078f, - 0.576f, - 0.807f, - 1.000f, - 0.078f, - 0.576f, - 0.817f, - 1.000f, - 0.078f, - 0.576f, - 0.826f, - 1.000f, - 0.078f, - 0.576f, - 0.835f, - 1.000f, - 0.078f, - 0.576f, - 0.844f, - 1.000f, - 0.078f, - 0.576f, - 0.853f, - 1.000f, - 0.078f, - 0.576f, - 0.862f, - 1.000f, - 0.078f, - 0.576f, - 0.872f, - 1.000f, - 0.078f, - 0.576f, - 0.881f, - 1.000f, - 0.078f, - 0.576f, - 0.890f, - 1.000f, - 0.078f, - 0.576f, - 0.899f, - 1.000f, - 0.078f, - 0.576f, - 0.908f, - 1.000f, - 0.078f, - 0.576f, - 0.917f, - 1.000f, - 0.078f, - 0.576f, - 0.927f, - 1.000f, - 0.078f, - 0.576f, - 0.936f, - 1.000f, - 0.078f, - 0.576f, - 0.945f, - 1.000f, - 0.078f, - 0.576f, - 0.954f, - 1.000f, - 0.078f, - 0.576f, - 0.963f, - 1.000f, - 0.078f, - 0.576f, - 0.972f, - 1.000f, - 0.078f, - 0.576f, - 0.982f, - 1.000f, - 0.078f, - 0.576f, - 0.991f, - 1.000f, - 0.078f, - 0.576f, - 1.000f, - 1.000f, - 0.078f, - 0.576f, - }}, - {"jet", {0.0f, 0.f, 0.f, 1.f, 0.3f, 0.f, 1.f, 1.f, 0.6f, 1.f, 1.f, 0.f, 1.0f, 1.f, 0.f, 0.f}}, -}; - -} // namespace tfn diff --git a/extern/tfn/examples/v1/black_body_radiation.tfn b/extern/tfn/examples/v1/black_body_radiation.tfn deleted file mode 100644 index f9f54ee..0000000 Binary files a/extern/tfn/examples/v1/black_body_radiation.tfn and /dev/null differ diff --git a/extern/tfn/examples/v1/blackbody.tfn b/extern/tfn/examples/v1/blackbody.tfn deleted file mode 100644 index f9f54ee..0000000 Binary files a/extern/tfn/examples/v1/blackbody.tfn and /dev/null differ diff --git a/extern/tfn/examples/v1/blue_yellow.tfn b/extern/tfn/examples/v1/blue_yellow.tfn deleted file mode 100644 index 2ca67d2..0000000 Binary files a/extern/tfn/examples/v1/blue_yellow.tfn and /dev/null differ diff --git a/extern/tfn/examples/v1/cool_warm_extended.tfn b/extern/tfn/examples/v1/cool_warm_extended.tfn deleted file mode 100644 index 42f8a91..0000000 Binary files a/extern/tfn/examples/v1/cool_warm_extended.tfn and /dev/null differ diff --git a/extern/tfn/examples/v1/green_blue_asym_diverge.tfn b/extern/tfn/examples/v1/green_blue_asym_diverge.tfn deleted file mode 100644 index 4bf6937..0000000 Binary files a/extern/tfn/examples/v1/green_blue_asym_diverge.tfn and /dev/null differ diff --git a/extern/tfn/examples/v1/linear_green.tfn b/extern/tfn/examples/v1/linear_green.tfn deleted file mode 100644 index be342e3..0000000 Binary files a/extern/tfn/examples/v1/linear_green.tfn and /dev/null differ diff --git a/extern/tfn/examples/v1/linear_ygb1211g.tfn b/extern/tfn/examples/v1/linear_ygb1211g.tfn deleted file mode 100644 index 8ff9333..0000000 Binary files a/extern/tfn/examples/v1/linear_ygb1211g.tfn and /dev/null differ diff --git a/extern/tfn/examples/v1/matplotlib_plasma.tfn b/extern/tfn/examples/v1/matplotlib_plasma.tfn deleted file mode 100644 index f655719..0000000 Binary files a/extern/tfn/examples/v1/matplotlib_plasma.tfn and /dev/null differ diff --git a/extern/tfn/examples/v1/matplotlib_virdis.tfn b/extern/tfn/examples/v1/matplotlib_virdis.tfn deleted file mode 100644 index 363bc98..0000000 Binary files a/extern/tfn/examples/v1/matplotlib_virdis.tfn and /dev/null differ diff --git a/extern/tfn/examples/v1/savr-video-tfn.tfn b/extern/tfn/examples/v1/savr-video-tfn.tfn deleted file mode 100644 index 4b60a9c..0000000 Binary files a/extern/tfn/examples/v1/savr-video-tfn.tfn and /dev/null differ diff --git a/extern/tfn/examples/visit_tfn/CTHead_attribute.xml b/extern/tfn/examples/visit_tfn/CTHead_attribute.xml deleted file mode 100644 index 6048eb6..0000000 --- a/extern/tfn/examples/visit_tfn/CTHead_attribute.xml +++ /dev/null @@ -1,130 +0,0 @@ - - - true - true - - - - 0 0 255 255 - 0 - - - 0 255 255 255 - 0.25 - - - 0 255 0 255 - 0.5 - - - 255 255 0 255 - 0.75 - - - 255 0 0 255 - 1 - - Linear - false - false - - - - 1 - GaussianMode - - - - 0.15 - 0.5 - 0.09017095 - 0 - 0 - - - 0.25 - 0.5 - 0.05 - 0 - 0 - - - 0.35 - 0.5 - 0.05 - 0 - 0 - - - 0.45 - 0.5 - 0.05 - 0 - 0 - - - 0.55 - 0.5 - 0.05 - 0 - 0 - - - 0.65 - 0.5 - 0.05 - 0 - 0 - - - 0.75 - 0.5 - 0.05 - 0 - 0 - - - 0.85 - 0.5 - 0.05 - 0 - 0 - - - 0.95 - 0.5 - 0.05 - 0 - 0 - - - - true - 50000 - default - default - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - false - 0 - false - 0 - false - 0 - false - 0 - false - 500 - OSPRaySLIVR - SobelOperator - 200 - Linear - 1 - OriginalData - Rasterization - 3 - 1 - Lower - false - 1 - 0.4 0.75 0 15 - diff --git a/extern/tfn/examples/visit_tfn/DNS_0_attribute.xml b/extern/tfn/examples/visit_tfn/DNS_0_attribute.xml deleted file mode 100644 index ca38a69..0000000 --- a/extern/tfn/examples/visit_tfn/DNS_0_attribute.xml +++ /dev/null @@ -1,85 +0,0 @@ - - - true - false - - - - 60 89 255 255 - 0.2788898 - - - 117 255 251 255 - 0.3939151 - - - 113 255 103 255 - 0.4683747 - - - 255 255 78 255 - 0.5158794 - - - 255 255 70 255 - 0.6311716 - - - 255 100 48 255 - 0.6760074 - - Linear - false - false - - - - 0.2039216 - FreeformMode - - - - 0.3450835 - 0.638472 - 0.3008216 - 0 - 0 - - - 0.7362841 - 0.006821275 - 0.1757355 - 0 - 0 - - - - true - 50000 - default - default - 101 102 104 106 108 110 113 116 120 123 127 130 134 138 141 144 146 149 152 154 156 159 161 163 164 165 167 168 169 170 171 171 172 173 173 174 175 175 175 176 176 177 177 178 178 178 178 179 179 180 180 181 181 182 182 182 183 183 183 184 184 184 185 185 185 186 186 186 186 186 186 186 187 187 187 187 187 186 185 185 184 184 184 185 185 185 184 183 182 181 179 177 174 172 169 165 161 157 153 149 146 144 141 139 136 134 131 129 127 124 123 121 120 119 118 116 115 113 111 110 109 107 106 105 103 103 102 102 101 101 101 98 97 95 95 94 93 92 91 90 89 88 87 86 85 83 82 85 85 84 83 83 82 81 80 79 78 77 76 75 74 72 72 71 69 68 67 65 64 63 63 61 59 57 54 52 51 45 43 40 34 28 25 22 19 16 14 13 12 11 10 9 9 8 7 6 5 4 2 2 0 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - false - 0 - false - 0 - false - 0 - false - 0 - false - 500 - OSPRaySLIVR - SobelOperator - 200 - Linear - 1 - OriginalData - Rasterization - 3 - 1 - Lower - false - 1 - 0.4 0.75 0 15 - diff --git a/extern/tfn/examples/visit_tfn/DNS_1_attribute.xml b/extern/tfn/examples/visit_tfn/DNS_1_attribute.xml deleted file mode 100644 index d3d18fc..0000000 --- a/extern/tfn/examples/visit_tfn/DNS_1_attribute.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - true - false - - - - 23 104 203 255 - 0.299803 - - - 51 102 255 255 - 0.4056579 - - - 0 204 255 255 - 0.5009341 - - - 204 255 255 255 - 0.6092874 - - - 255 255 0 255 - 0.6762744 - - - 255 100 48 255 - 0.7181745 - - - 255 0 0 255 - 0.7702162 - - Linear - false - false - - - - 0.2039216 - FreeformMode - - - - 0.3450835 - 0.638472 - 0.3008216 - 0 - 0 - - - 0.7362841 - 0.006821275 - 0.1757355 - 0 - 0 - - - - true - 50000 - default - default - 101 102 104 106 108 110 113 116 120 123 127 130 134 138 141 144 146 149 152 154 156 159 161 163 164 165 167 168 169 170 171 171 172 173 173 174 175 175 175 176 176 177 177 178 178 178 178 179 179 180 180 181 181 182 182 182 183 183 183 184 184 184 185 185 185 186 186 186 186 186 186 186 187 187 187 187 187 186 185 185 184 184 184 185 185 185 184 183 182 181 179 177 174 172 169 165 161 157 153 149 146 144 141 139 136 134 131 129 127 124 123 121 120 119 118 116 115 113 111 110 109 107 106 105 103 103 102 102 101 101 101 98 97 95 95 94 93 92 91 90 89 88 87 86 85 83 82 85 85 84 83 83 82 81 80 79 78 77 76 75 74 72 72 71 69 68 67 65 64 63 63 61 59 57 54 52 51 45 43 40 34 28 25 22 19 16 14 13 10 12 14 15 15 11 8 5 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 11 16 20 23 21 24 21 18 14 10 8 5 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - false - 0 - false - 0 - false - 0 - false - 0 - false - 500 - OSPRaySLIVR - SobelOperator - 200 - Linear - 1 - OriginalData - Rasterization - 3 - 1 - Lower - false - 1 - 0.4 0.75 0 15 - diff --git a/extern/tfn/examples/visit_tfn/DNS_2_attribute.xml b/extern/tfn/examples/visit_tfn/DNS_2_attribute.xml deleted file mode 100644 index 3d1cd75..0000000 --- a/extern/tfn/examples/visit_tfn/DNS_2_attribute.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - true - false - - - - 0 71 239 255 - 0.299803 - - - 51 102 255 255 - 0.4056579 - - - 0 204 255 255 - 0.5447024 - - - 204 255 255 255 - 0.6271684 - - - 255 255 0 255 - 0.6698692 - - - 255 100 48 255 - 0.6949559 - - - 255 0 0 255 - 0.7163064 - - Linear - false - false - - - - 0.2039216 - FreeformMode - - - - 0.3450835 - 0.638472 - 0.3008216 - 0 - 0 - - - 0.7362841 - 0.006821275 - 0.1757355 - 0 - 0 - - - - true - 50000 - default - default - 101 102 104 106 108 110 113 116 120 123 127 130 134 138 141 144 146 149 152 154 156 159 161 163 164 165 167 168 169 170 171 171 172 173 173 174 175 175 175 176 176 177 177 178 178 178 178 179 179 180 180 181 181 182 182 182 183 183 183 184 184 184 185 185 185 186 186 186 186 186 186 186 187 187 187 187 187 186 185 185 184 184 184 185 185 185 184 183 182 181 179 177 174 172 169 165 161 157 153 149 146 144 141 139 136 134 131 129 127 124 123 121 120 119 118 116 115 113 111 110 109 107 106 105 103 103 102 102 101 101 101 98 97 95 95 94 93 92 91 90 89 88 87 86 85 83 82 85 85 84 83 83 82 81 80 79 78 77 76 75 74 72 72 71 69 68 67 65 64 63 63 61 59 57 54 52 51 45 43 40 34 28 25 22 19 16 14 13 10 12 14 15 15 11 8 5 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 20 20 18 16 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - false - 0 - false - 0 - false - 0 - false - 0 - false - 500 - OSPRaySLIVR - SobelOperator - 200 - Linear - 1 - OriginalData - Rasterization - 3 - 1 - Lower - false - 1 - 0.4 0.75 0 15 - diff --git a/extern/tfn/examples/visit_tfn/WhiteMatter-FA.xml b/extern/tfn/examples/visit_tfn/WhiteMatter-FA.xml deleted file mode 100644 index 0bb62fb..0000000 --- a/extern/tfn/examples/visit_tfn/WhiteMatter-FA.xml +++ /dev/null @@ -1,207 +0,0 @@ - - - true - false - - - - 0 0 255 255 - 0 - - - 0 255 255 255 - 0.4288225 - - - 0 255 0 255 - 0.5653193 - - - 255 255 0 255 - 0.75 - - - 255 0 0 255 - 1 - - Linear - false - false - - - - 0.5568628 - GaussianMode - - - - 0.025 - 0.9972222 - 0.025 - 0 - 0 - - - 0.075 - 0.8833333 - 0.025 - 0 - 0 - - - 0.125 - 0.7055556 - 0.025 - 0 - 0 - - - 0.175 - 0.5 - 0.025 - 0 - 0 - - - 0.225 - 0.5 - 0.025 - 0 - 0 - - - 0.275 - 0.5 - 0.025 - 0 - 0 - - - 0.325 - 0.5 - 0.025 - 0 - 0 - - - 0.375 - 0.3083333 - 0.025 - 0 - 0 - - - 0.425 - 0.2472222 - 0.025 - 0 - 0 - - - 0.475 - 0.2083333 - 0.025 - 0 - 0 - - - 0.525 - 0.1666667 - 0.025 - 0 - 0 - - - 0.575 - 0.2138889 - 0.025 - 0 - 0 - - - 0.625 - 0.2361111 - 0.025 - 0 - 0 - - - 0.675 - 0.2944444 - 0.025 - 0 - 0 - - - 0.725 - 0.2472222 - 0.025 - 0 - 0 - - - 0.775 - 0.1527778 - 0.025 - 0 - 0 - - - 0.825 - 0.2083333 - 0.025 - 0 - 0 - - - 0.875 - 0.1805556 - 0.025 - 0 - 0 - - - 0.925 - 0.2944444 - 0.025 - 0 - 0 - - - 0.975 - 0.3694444 - 0.025 - 0 - 0 - - - - true - 50000 - default - default - 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 - false - 0 - true - 0.3 - false - 0 - false - 0 - false - 500 - OSPRaySLIVR - SobelOperator - 200 - Linear - 1 - OriginalData - Rasterization - 8 - 1 - Lower - false - 1 - 0.4 0.75 0 15 - diff --git a/extern/tfn/examples/visit_tfn/aneurysm_attribute.xml b/extern/tfn/examples/visit_tfn/aneurysm_attribute.xml deleted file mode 100644 index 7132592..0000000 --- a/extern/tfn/examples/visit_tfn/aneurysm_attribute.xml +++ /dev/null @@ -1,149 +0,0 @@ - - - true - true - - - - 71 71 219 255 - 0 - - - 0 0 91 255 - 0.143 - - - 0 255 255 255 - 0.285 - - - 0 127 0 255 - 0.429 - - - 255 255 0 255 - 0.571 - - - 255 96 0 255 - 0.714 - - - 107 0 0 255 - 0.857 - - - 224 76 76 255 - 1 - - Linear - false - false - - - - 0.3843137 - GaussianMode - - - - 0.05 - 0.3529412 - 0.01964856 - 0 - 0 - - - 0.15 - 0.3529412 - 0.01996805 - 0 - 0 - - - 0.25 - 0.3375959 - 0.0129393 - 0 - 0 - - - 0.35 - 0.3759591 - 0.01198086 - 0 - 0 - - - 0.45 - 0.4450128 - 0.0129393 - 0 - 0 - - - 0.55 - 0.5 - 0.01389778 - 0 - 0 - - - 0.65 - 0.5984654 - 0.0135783 - 0 - 0 - - - 0.75 - 0.6547315 - 0.01389778 - 0 - 0 - - - 0.85 - 0.7723785 - 0.02060705 - 0 - 0 - - - 0.95 - 0.8491049 - 0.02220452 - 0 - 0 - - - - true - 50000 - default - default - 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 - false - 0 - false - 0 - false - 0 - false - 0 - false - 500 - OSPRaySLIVR - SobelOperator - 200 - Linear - 1 - OriginalData - Rasterization - 3 - 1 - Lower - false - 1 - 0.4 0.75 0 15 - diff --git a/extern/tfn/examples/visit_tfn/bsf_o2_attribute.xml b/extern/tfn/examples/visit_tfn/bsf_o2_attribute.xml deleted file mode 100644 index a3e5402..0000000 --- a/extern/tfn/examples/visit_tfn/bsf_o2_attribute.xml +++ /dev/null @@ -1,137 +0,0 @@ - - - true - true - - - - 0 0 255 255 - 0 - - - 0 255 255 255 - 0.09024745 - - - 0 255 0 255 - 0.1965065 - - - 255 255 0 255 - 0.2954876 - - - 255 0 0 255 - 0.6244541 - - Linear - false - false - - - - 0.4392157 - GaussianMode - - - - 0.06134094 - 0.1666667 - 0.05 - 0 - 0 - - - 0.15 - 0.25 - 0.05 - 0 - 0 - - - 0.25 - 0.4166667 - 0.05 - 0 - 0 - - - 0.35 - 0.5 - 0.05 - 0 - 0 - - - 0.45 - 0.5 - 0.05 - 0 - 0 - - - 0.55 - 0.5 - 0.05 - 0 - 0 - - - 0.65 - 0.5 - 0.05 - 0 - 0 - - - 0.75 - 0.5 - 0.05 - 0 - 0 - - - 0.85 - 0.5 - 0.05 - 0 - 0 - - - 0.95 - 0.5 - 0.05 - 0 - 0 - - - - true - 50000 - default - default - 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 - false - 0 - false - 0 - false - 0 - false - 0 - false - 500 - OSPRaySLIVR - SobelOperator - 200 - Linear - 1 - OriginalData - Rasterization - 3 - 1 - Lower - false - 1 - 0.4 0.75 0 15 - diff --git a/extern/tfn/examples/visit_tfn/bsf_residence_attribute.xml b/extern/tfn/examples/visit_tfn/bsf_residence_attribute.xml deleted file mode 100644 index 2deef2c..0000000 --- a/extern/tfn/examples/visit_tfn/bsf_residence_attribute.xml +++ /dev/null @@ -1,137 +0,0 @@ - - - true - true - - - - 0 0 255 255 - 0 - - - 0 255 255 255 - 0.25 - - - 0 255 0 255 - 0.5 - - - 255 255 0 255 - 0.75 - - - 255 0 0 255 - 1 - - Linear - false - false - - - - 0.3568628 - GaussianMode - - - - 0.06569187 - 0.25 - 0.05699002 - -0.01718973 - 0 - - - 0.15 - 0.4166667 - 0.05 - 0 - 0 - - - 0.25 - 0.5 - 0.05 - 0 - 0 - - - 0.35 - 0.5 - 0.05 - 0 - 0 - - - 0.45 - 0.5 - 0.05 - 0 - 0 - - - 0.55 - 0.5 - 0.05 - 0 - 0 - - - 0.65 - 0.5 - 0.05 - 0 - 0 - - - 0.75 - 0.5 - 0.05 - 0 - 0 - - - 0.85 - 0.5 - 0.05 - 0 - 0 - - - 0.95 - 0.5 - 0.05 - 0 - 0 - - - - true - 50000 - default - default - 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 - false - 0 - false - 0 - false - 0 - false - 0 - false - 500 - OSPRaySLIVR - SobelOperator - 200 - Linear - 1 - OriginalData - Rasterization - 3 - 1 - Lower - false - 1 - 0.4 0.75 0 15 - diff --git a/extern/tfn/examples/visit_tfn/csafe.xml b/extern/tfn/examples/visit_tfn/csafe.xml deleted file mode 100644 index 2da63f1..0000000 --- a/extern/tfn/examples/visit_tfn/csafe.xml +++ /dev/null @@ -1,137 +0,0 @@ - - - true - true - - - - 0 0 255 255 - 0 - - - 0 255 255 255 - 0.25 - - - 0 255 0 255 - 0.5 - - - 255 255 0 255 - 0.75 - - - 255 0 0 255 - 1 - - Linear - false - false - - - - 0.2509804 - GaussianMode - - - - 0.08559201 - 0.1833333 - 0.0599144 - 0 - 0 - - - 0.1726106 - 0.45 - 0.08537802 - 0 - 0 - - - 0.2639087 - 0.5 - 0.01034237 - 0 - 0 - - - 0.363766 - 0.6333333 - 0.01519257 - 0 - 0 - - - 0.4579173 - 0.6833333 - 0.0150499 - 0 - 0 - - - 0.65 - 0.7333333 - 0.01619112 - 0 - 0 - - - 0.75 - 0.8 - 0.01319546 - 0 - 0 - - - 0.85 - 0.8333333 - 0.0159058 - 0 - 0 - - - 0.6234664 - 0.65 - 0.3809557 - 0.3765336 - 0.09090889 - - - 0.5549216 - 0.7833333 - 0.01 - 0 - 0 - - - - true - 50000 - default - default - 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 - false - 0 - false - 0 - false - 0 - false - 0 - false - 500 - OSPRaySLIVR - SobelOperator - 200 - Linear - 1 - OriginalData - Rasterization - 3 - 1 - Lower - false - 1 - 0.4 0.75 0 15 - diff --git a/extern/tfn/examples/visit_tfn/magnetic_attribute.xml b/extern/tfn/examples/visit_tfn/magnetic_attribute.xml deleted file mode 100644 index 5caa561..0000000 --- a/extern/tfn/examples/visit_tfn/magnetic_attribute.xml +++ /dev/null @@ -1,137 +0,0 @@ - - - true - true - - - - 51 102 255 255 - 0 - - - 0 255 255 255 - 0.2116689 - - - 0 255 0 255 - 0.3093623 - - - 255 153 0 255 - 0.4450475 - - - 255 0 0 255 - 1 - - Linear - false - false - - - - 1 - GaussianMode - - - - 0.08649174 - 0.2701252 - 0.01 - 0 - 0 - - - 0.15 - 0.3506261 - 0.01 - 0 - 0 - - - 0.25 - 0.4347048 - 0.05 - 0 - 0 - - - 0.35 - 0.5 - 0.05 - 0 - 0 - - - 0.45 - 0.5330948 - 0.05 - 0 - 0 - - - 0.55 - 0.5652952 - 0.05 - 0 - 0 - - - 0.65 - 0.5724508 - 0.05 - 0 - 0 - - - 0.75 - 0.5 - 0.05 - 0 - 0 - - - 0.85 - 0.5 - 0.05 - 0 - 0 - - - 0.95 - 0.5 - 0.05 - 0 - 0 - - - - true - 50000 - default - default - 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 - true - 0 - true - 12 - false - 0 - false - 0 - false - 500 - OSPRaySLIVR - SobelOperator - 200 - Linear - 1 - OriginalData - Rasterization - 3 - 1 - Lower - false - 1 - 0.4 0.75 0 15 - diff --git a/extern/tfn/examples/visit_tfn/pidx_cooley_attribute_ospray_harris_v0.xml b/extern/tfn/examples/visit_tfn/pidx_cooley_attribute_ospray_harris_v0.xml deleted file mode 100644 index b787c68..0000000 --- a/extern/tfn/examples/visit_tfn/pidx_cooley_attribute_ospray_harris_v0.xml +++ /dev/null @@ -1,128 +0,0 @@ - - - true - false - - - - 71 71 219 255 - 0 - - - 0 0 91 255 - 0.143 - - - 0 255 255 255 - 0.285 - - - 0 127 0 255 - 0.429 - - - 255 255 0 255 - 0.571 - - - 255 96 0 255 - 0.714 - - - 107 0 0 255 - 0.857 - - - 224 76 76 255 - 1 - - Linear - false - false - - - - 0.2705882 - GaussianMode - - - - 0.1206897 - 0.7671233 - 0.1172414 - 0 - 0 - - - 0.3551724 - 0.8630137 - 0.1206897 - 0 - 0 - - - 0.6189655 - 0.9452055 - 0.1482759 - 0 - 0 - - - 0.9017242 - 0.7808219 - 0.1586207 - 0 - 0 - - - 0.4758621 - 0.8 - 0.03965518 - 0 - 0 - - - 0.7603448 - 0.9 - 0.03448278 - 0 - 0 - - - 0.2344828 - 0.7833333 - 0.02586207 - 0 - 0 - - - - true - 50000 - default - default - 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 - true - 0 - true - 1 - false - 0 - false - 0 - true - 500 - OSPRaySLIVR - SobelOperator - 200 - Linear - 1 - OriginalData - Trilinear - 3 - 1 - Lower - false - 1 - 0.4 0.75 0 15 - diff --git a/extern/tfn/examples/visit_tfn/pidx_cooley_attribute_ospray_harris_v1.xml b/extern/tfn/examples/visit_tfn/pidx_cooley_attribute_ospray_harris_v1.xml deleted file mode 100644 index c1e4ba4..0000000 --- a/extern/tfn/examples/visit_tfn/pidx_cooley_attribute_ospray_harris_v1.xml +++ /dev/null @@ -1,198 +0,0 @@ - - - true - false - - - - 71 71 219 255 - 0 - - - 0 0 91 255 - 0.143 - - - 0 255 255 255 - 0.285 - - - 0 127 0 255 - 0.429 - - - 255 255 0 255 - 0.571 - - - 255 96 0 255 - 0.714 - - - 107 0 0 255 - 0.857 - - - 224 76 76 255 - 1 - - Linear - false - false - - - - 0.1529412 - GaussianMode - - - - 0.2344828 - 0.35 - 0.02586207 - 0 - 0 - - - 0.06206897 - 0.2333333 - 0.02413793 - 0 - 0 - - - 0.1155172 - 0.25 - 0.03275862 - 0 - 0 - - - 0.1706897 - 0.2833334 - 0.03448276 - 0 - 0 - - - 0.2844827 - 0.3666667 - 0.03275862 - 0 - 0 - - - 0.3396552 - 0.4833333 - 0.02931035 - 0 - 0 - - - 0.3862069 - 0.5166667 - 0.02931035 - 0 - 0 - - - 0.4362069 - 0.5333333 - 0.03103447 - 0 - 0 - - - 0.4931034 - 0.5333333 - 0.02241379 - 0 - 0 - - - 0.5413793 - 0.65 - 0.02068961 - 0 - 0 - - - 0.5913793 - 0.5666667 - 0.02931035 - 0 - 0 - - - 0.637931 - 0.6833333 - 0.02586204 - 0 - 0 - - - 0.6982759 - 0.7333333 - 0.0362069 - 0 - 0 - - - 0.8534483 - 0.7166667 - 0.08448279 - 0 - 0 - - - 0.962069 - 0.8166667 - 0.07413793 - 0 - 0 - - - 0.7706897 - 0.7666667 - 0.03103447 - 0 - 0 - - - 0.02413793 - 0.1666667 - 0.01 - 0 - 0 - - - - true - 50000 - default - default - 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 - true - 0 - true - 0.4 - false - 0 - false - 0 - true - 500 - OSPRaySLIVR - SobelOperator - 200 - Linear - 1 - OriginalData - Trilinear - 3 - 1 - Lower - false - 1 - 0.4 0.75 0 15 - diff --git a/extern/tfn/examples/visit_tfn/pidx_cooley_attribute_ospray_harris_v2.xml b/extern/tfn/examples/visit_tfn/pidx_cooley_attribute_ospray_harris_v2.xml deleted file mode 100644 index 979bb54..0000000 --- a/extern/tfn/examples/visit_tfn/pidx_cooley_attribute_ospray_harris_v2.xml +++ /dev/null @@ -1,177 +0,0 @@ - - - true - false - - - - 71 71 219 255 - 0 - - - 0 0 91 255 - 0.143 - - - 0 255 255 255 - 0.285 - - - 0 127 0 255 - 0.429 - - - 255 255 0 255 - 0.571 - - - 255 96 0 255 - 0.714 - - - 107 0 0 255 - 0.857 - - - 224 76 76 255 - 1 - - Linear - false - false - - - - 0.08627451 - GaussianMode - - - - 0.1150568 - 0.7671233 - 0.109375 - -0.00994318 - 0.04285709 - - - 0.3551724 - 0.8630137 - 0.1094338 - 0 - 0 - - - 0.6022727 - 0.9452055 - 0.1491477 - 0 - 0 - - - 0.8579546 - 0.776 - 0.1605114 - 0.001420438 - 0.3114385 - - - 0.4758621 - 0.832 - 0.02839929 - 0 - 0 - - - 0.7443182 - 0.816 - 0.03693181 - 0 - 0 - - - 0.2344828 - 0.7833333 - 0.02586207 - 0 - 0 - - - 0.03125 - 0.304 - 0.01704545 - -0.008522727 - 0.05263129 - - - 0.4502841 - 0.648 - 0.02272728 - 0 - 0 - - - 0.4985795 - 0.688 - 0.02272725 - 0 - 0 - - - 0.65625 - 0.728 - 0.03125 - 0 - 0 - - - 0.7130682 - 0.704 - 0.02840912 - 0 - 0 - - - 0.7755682 - 0.728 - 0.02414775 - 0 - 0 - - - 0.9715909 - 0.936 - 0.06392044 - -0.0142045 - 0 - - - - true - 50000 - default - default - 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 - true - 0 - true - 0.9635 - false - 0 - false - 0 - true - 500 - OSPRaySLIVR - SobelOperator - 200 - Linear - 1 - OriginalData - Trilinear - 3 - 1 - Lower - false - 1 - 0.4 0.75 0.1 15 - diff --git a/extern/tfn/examples/visit_tfn/pidx_cooley_attribute_ospray_harris_v3.xml b/extern/tfn/examples/visit_tfn/pidx_cooley_attribute_ospray_harris_v3.xml deleted file mode 100644 index 4556158..0000000 --- a/extern/tfn/examples/visit_tfn/pidx_cooley_attribute_ospray_harris_v3.xml +++ /dev/null @@ -1,191 +0,0 @@ - - - true - false - - - - 71 71 219 255 - 0 - - - 0 0 91 255 - 0.143 - - - 0 255 255 255 - 0.285 - - - 0 127 0 255 - 0.429 - - - 255 255 0 255 - 0.571 - - - 255 96 0 255 - 0.714 - - - 107 0 0 255 - 0.857 - - - 224 76 76 255 - 1 - - Linear - false - false - - - - 0.1764706 - GaussianMode - - - - 0.8579546 - 0.864 - 0.1448864 - 0.001420438 - 0.3114385 - - - 0.9602273 - 0.912 - 0.08096588 - 0 - 0 - - - 0.02840909 - 0.272 - 0.015625 - 0 - 0 - - - 0.1818182 - 0.664 - 0.06392045 - 0 - 0 - - - 0.3238636 - 0.72 - 0.08096589 - -0.001420438 - 0 - - - 0.3196023 - 0.912 - 0.03125 - -0.01278412 - 0.2280701 - - - 0.3565341 - 0.872 - 0.03125 - 0 - 0 - - - 0.4332386 - 0.52 - 0.02840909 - 0 - 0 - - - 0.4815341 - 0.608 - 0.07102272 - 0 - 0 - - - 0.4900568 - 0.632 - 0.01704544 - 0 - 0 - - - 0.5113636 - 0.68 - 0.02130684 - 0 - 0 - - - 0.5326704 - 0.696 - 0.03125 - 0 - 0 - - - 0.5852273 - 0.68 - 0.03125 - 0 - 0 - - - 0.6292614 - 0.712 - 0.02272725 - 0 - 0 - - - 0.6775568 - 0.76 - 0.04119319 - 0 - 0 - - - 0.7428977 - 0.856 - 0.03409088 - 0 - 0 - - - - true - 50000 - default - default - 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 - true - 0 - true - 0.6532 - false - 0 - false - 0 - true - 500 - OSPRaySLIVR - SobelOperator - 200 - Linear - 1 - OriginalData - Trilinear - 3 - 1 - Lower - false - 1 - 0.4 0.75 0.1 15 - diff --git a/extern/tfn/examples/visit_tfn/pidx_cooley_attribute_ospray_qi.xml b/extern/tfn/examples/visit_tfn/pidx_cooley_attribute_ospray_qi.xml deleted file mode 100644 index 450e1db..0000000 --- a/extern/tfn/examples/visit_tfn/pidx_cooley_attribute_ospray_qi.xml +++ /dev/null @@ -1,110 +0,0 @@ - - - true - false - - - - 0 0 143 255 - 0 - - - 0 0 255 255 - 0.166666 - - - 0 255 255 255 - 0.333333 - - - 128 255 128 255 - 0.5 - - - 255 255 0 255 - 0.666667 - - - 255 0 0 255 - 0.833333 - - - 128 0 0 255 - 1 - - Linear - false - false - - - - 0.2862745 - FreeformMode - - - - 0.2 - 0.515625 - 0.1404558 - 0 - 0 - - - 0.4 - 0.734375 - 0.1669516 - 0 - 0 - - - 0.6 - 0.6875 - 0.1527066 - 0 - 0 - - - 0.8 - 0.59375 - 0.1957265 - 0.001994312 - 0 - - - 0.97151 - 0.09375 - 0.0626781 - 0.02136749 - 2 - - - - true - 50000 - default - default - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 5 7 10 14 18 22 26 30 34 38 43 47 51 55 59 62 65 69 72 76 79 83 87 90 94 98 101 105 108 111 114 116 118 120 121 123 124 126 127 129 131 132 134 135 136 137 139 140 142 144 145 146 147 148 149 150 151 152 153 154 156 157 158 159 160 161 162 162 163 164 165 167 168 169 170 170 170 170 171 171 172 173 174 176 178 180 180 180 179 178 176 174 173 172 171 170 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 169 168 168 168 168 168 168 168 168 167 167 166 166 166 166 166 166 166 166 165 165 165 165 165 164 163 162 161 160 159 158 158 157 156 155 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 154 155 155 156 157 157 159 160 161 162 161 159 155 150 143 137 131 125 120 115 111 106 102 97 93 89 85 81 76 72 68 64 60 57 53 50 47 44 42 40 38 37 36 35 35 35 34 34 34 33 33 32 32 32 32 31 31 30 29 27 25 23 - true - 0 - true - 0.15 - false - 0 - false - 0 - false - 2 - OSPRaySLIVR - CenteredDifferences - 200 - Linear - 1 - OriginalData - Rasterization - 3 - 1 - Lower - false - 1 - 0.4 0.75 0 15 - diff --git a/extern/tfn/examples/visit_tfn/pidx_cooley_attribute_ospray_steve.xml b/extern/tfn/examples/visit_tfn/pidx_cooley_attribute_ospray_steve.xml deleted file mode 100644 index 2fc3e2d..0000000 --- a/extern/tfn/examples/visit_tfn/pidx_cooley_attribute_ospray_steve.xml +++ /dev/null @@ -1,134 +0,0 @@ - - - true - false - - - - 0 0 128 255 - 0 - - - 0 0 255 255 - 0.1586608 - - - 0 255 255 255 - 0.3391558 - - - 0 255 0 255 - 0.5094614 - - - 255 255 0 255 - 0.6812227 - - - 255 0 0 255 - 1 - - Linear - false - false - - - - 0.2156863 - GaussianMode - - - - 0.05 - 0.25 - 0.05 - 0 - 0 - - - 0.15 - 0.35 - 0.06220929 - 0 - 0 - - - 0.25 - 0.3666667 - 0.05813953 - 0 - 0 - - - 0.35 - 0.5166667 - 0.06947675 - 0 - 0 - - - 0.45 - 0.6 - 0.06773257 - 0 - 0 - - - 0.55 - 0.6166667 - 0.06744188 - 0 - 0 - - - 0.6526163 - 0.5166667 - 0.07267445 - 0 - 0 - - - 0.8037791 - 0.4833333 - 0.1177325 - 0 - 0 - - - 0.95 - 0.4 - 0.06046516 - 0 - 0 - - - - true - 50000 - default - default - 2 4 7 12 19 29 41 56 73 90 105 118 125 127 122 112 98 81 64 48 34 23 15 9 5 3 3 5 9 15 23 34 48 64 81 98 112 122 127 125 118 105 90 73 56 41 29 19 12 7 4 2 4 7 12 19 29 41 56 73 90 105 118 125 127 122 112 98 81 64 48 34 23 15 9 5 3 3 5 9 15 23 34 48 64 81 98 112 122 127 125 118 105 90 73 56 41 29 19 12 7 4 2 4 7 12 19 29 41 56 73 90 105 118 125 127 122 112 98 81 64 48 34 23 15 9 5 3 3 5 9 15 23 34 48 64 81 98 112 122 127 125 118 105 90 73 56 41 29 19 12 7 4 2 4 7 12 19 29 41 56 73 90 105 118 125 127 122 112 98 81 64 48 34 23 15 9 5 3 3 5 9 15 23 34 48 64 81 98 112 122 127 125 118 105 90 73 56 41 29 19 12 7 4 2 4 7 12 19 29 41 56 73 90 105 118 125 127 122 112 98 81 64 48 34 23 15 9 5 3 3 5 9 15 23 34 48 64 81 98 112 122 127 125 118 105 90 73 56 41 29 19 12 7 4 2 - true - 0 - true - 0.15 - false - 0 - false - 0 - false - 2 - OSPRaySLIVR - CenteredDifferences - 200 - Linear - 1 - OriginalData - Rasterization - 3 - 1 - Lower - false - 1 - 0.4 0.75 0 15 - diff --git a/extern/tfn/examples/visit_tfn/pidx_cooley_attribute_pascal.xml b/extern/tfn/examples/visit_tfn/pidx_cooley_attribute_pascal.xml deleted file mode 100644 index d0c26ad..0000000 --- a/extern/tfn/examples/visit_tfn/pidx_cooley_attribute_pascal.xml +++ /dev/null @@ -1,134 +0,0 @@ - - - true - false - - - - 0 0 128 255 - 0 - - - 0 0 255 255 - 0.1586608 - - - 0 255 255 255 - 0.3391558 - - - 0 255 0 255 - 0.5094614 - - - 255 255 0 255 - 0.6812227 - - - 255 0 0 255 - 1 - - Linear - false - false - - - - 0.2156863 - GaussianMode - - - - 0.05 - 0.25 - 0.05 - 0 - 0 - - - 0.15 - 0.35 - 0.06220929 - 0 - 0 - - - 0.25 - 0.3666667 - 0.05813953 - 0 - 0 - - - 0.35 - 0.5166667 - 0.06947675 - 0 - 0 - - - 0.45 - 0.6 - 0.06773257 - 0 - 0 - - - 0.55 - 0.6166667 - 0.06744188 - 0 - 0 - - - 0.6526163 - 0.5166667 - 0.07267445 - 0 - 0 - - - 0.8037791 - 0.4833333 - 0.1177325 - 0 - 0 - - - 0.95 - 0.4 - 0.06046516 - 0 - 0 - - - - true - 50000 - default - default - 2 4 7 12 19 29 41 56 73 90 105 118 125 127 122 112 98 81 64 48 34 23 15 9 5 3 3 5 9 15 23 34 48 64 81 98 112 122 127 125 118 105 90 73 56 41 29 19 12 7 4 2 4 7 12 19 29 41 56 73 90 105 118 125 127 122 112 98 81 64 48 34 23 15 9 5 3 3 5 9 15 23 34 48 64 81 98 112 122 127 125 118 105 90 73 56 41 29 19 12 7 4 2 4 7 12 19 29 41 56 73 90 105 118 125 127 122 112 98 81 64 48 34 23 15 9 5 3 3 5 9 15 23 34 48 64 81 98 112 122 127 125 118 105 90 73 56 41 29 19 12 7 4 2 4 7 12 19 29 41 56 73 90 105 118 125 127 122 112 98 81 64 48 34 23 15 9 5 3 3 5 9 15 23 34 48 64 81 98 112 122 127 125 118 105 90 73 56 41 29 19 12 7 4 2 4 7 12 19 29 41 56 73 90 105 118 125 127 122 112 98 81 64 48 34 23 15 9 5 3 3 5 9 15 23 34 48 64 81 98 112 122 127 125 118 105 90 73 56 41 29 19 12 7 4 2 - true - 0 - true - 0.15 - false - 0 - false - 0 - false - 2 - RayCastingSLIVR - CenteredDifferences - 200 - Linear - 1 - OriginalData - Rasterization - 3 - 1 - Lower - false - 1 - 0.4 0.75 0 15 - diff --git a/extern/tfn/examples/visit_tfn/pidx_test_attribute_ospray.xml b/extern/tfn/examples/visit_tfn/pidx_test_attribute_ospray.xml deleted file mode 100644 index 4521bcb..0000000 --- a/extern/tfn/examples/visit_tfn/pidx_test_attribute_ospray.xml +++ /dev/null @@ -1,130 +0,0 @@ - - - true - true - - - - 0 0 255 255 - 0 - - - 0 255 255 255 - 0.25 - - - 0 255 0 255 - 0.5 - - - 255 255 0 255 - 0.75 - - - 255 0 0 255 - 1 - - Linear - false - false - - - - 0.2156863 - FreeformMode - - - - 0.05 - 0.25 - 0.05 - 0 - 0 - - - 0.15 - 0.35 - 0.06220929 - 0 - 0 - - - 0.25 - 0.3666667 - 0.05813953 - 0 - 0 - - - 0.35 - 0.5166667 - 0.06947675 - 0 - 0 - - - 0.45 - 0.6 - 0.06773257 - 0 - 0 - - - 0.55 - 0.6166667 - 0.06744188 - 0 - 0 - - - 0.6526163 - 0.5166667 - 0.07267445 - 0 - 0 - - - 0.8037791 - 0.4833333 - 0.1177325 - 0 - 0 - - - 0.95 - 0.4 - 0.06046516 - 0 - 0 - - - - true - 50000 - default - default - 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 - false - 0 - false - 0 - false - 0 - false - 0 - false - 500 - OSPRaySLIVR - SobelOperator - 200 - Linear - 1 - OriginalData - Rasterization - 3 - 1 - Lower - false - 1 - 0.4 0.75 0 15 - diff --git a/extern/tfn/examples/visit_tfn/pidx_test_attribute_pascal.xml b/extern/tfn/examples/visit_tfn/pidx_test_attribute_pascal.xml deleted file mode 100644 index dd47969..0000000 --- a/extern/tfn/examples/visit_tfn/pidx_test_attribute_pascal.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - true - true - - - - 0 0 255 255 - 0 - - - 0 255 255 255 - 0.25 - - - 0 255 0 255 - 0.5 - - - 255 255 0 255 - 0.75 - - - 255 0 0 255 - 1 - - Linear - false - false - - - - 0.2156863 - FreeformMode - - - - - true - 50000 - default - default - 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 - false - 0 - false - 0 - false - 0 - false - 0 - false - 500 - RayCastingSLIVR - SobelOperator - 200 - Linear - 1 - OriginalData - Rasterization - 3 - 1 - Lower - false - 1 - 0.4 0.75 0 15 - diff --git a/extern/tfn/examples/visit_tfn/pig_heart_attribute.xml b/extern/tfn/examples/visit_tfn/pig_heart_attribute.xml deleted file mode 100644 index d8b7f85..0000000 --- a/extern/tfn/examples/visit_tfn/pig_heart_attribute.xml +++ /dev/null @@ -1,154 +0,0 @@ - - - true - true - - - - 158 1 66 255 - 0.1290667 - - - 213 62 79 255 - 0.2442667 - - - 244 109 67 255 - 0.3365333 - - - 253 174 97 255 - 0.4096 - - - 254 224 139 255 - 0.4906667 - - - 255 255 191 255 - 0.5568 - - - 230 245 152 255 - 0.632 - - - 171 221 164 255 - 0.6928 - - - 102 194 165 255 - 0.7813333 - - - 50 136 189 255 - 0.8549333 - - - 94 79 162 255 - 1 - - Linear - false - false - - - - 0.3333333 - GaussianMode - - - - 0.3719095 - 0.7839644 - 0.01 - 0 - 2 - - - 0.9110994 - 0.5684062 - 0.03020781 - 0 - 2 - - - 0.8027354 - 0.6755995 - 0.01 - 0 - 2 - - - 0.6254603 - 0.5444288 - 0.04629147 - 0 - 0 - - - 0.1309837 - 0.07475317 - 0.094687 - 0 - 0 - - - 0.2751184 - 0.4541608 - 0.03208837 - 0 - 0 - - - 0.4776433 - 0.787024 - 0.01 - 0 - 0 - - - 0.5597054 - 0.8377997 - 0.01 - 0 - 0 - - - 0.7222515 - 0.7221439 - 0.01578116 - 0 - 0 - - - - true - 50000 - default - default - 0 5 8 11 14 16 18 21 24 27 29 32 35 37 40 42 45 50 54 59 63 68 72 77 82 85 90 93 96 99 102 105 107 108 109 110 110 111 111 111 111 110 109 109 108 107 106 105 103 102 101 100 98 97 96 95 94 91 90 88 86 84 82 78 75 72 69 66 64 62 59 58 55 54 52 51 51 50 50 49 48 48 48 47 47 47 47 47 47 47 47 47 47 47 47 47 48 49 50 51 52 52 52 53 54 54 55 56 58 59 60 61 62 63 65 66 67 68 71 73 74 76 78 80 82 85 87 90 91 95 96 99 101 104 105 106 108 109 111 112 113 114 116 118 120 121 122 123 124 125 125 125 126 126 126 126 126 126 127 127 127 127 128 127 126 125 125 123 122 120 118 116 114 112 111 109 108 106 104 102 100 98 96 94 92 90 88 86 84 82 80 79 77 76 75 75 74 73 73 72 72 71 71 70 70 70 69 68 68 68 68 68 68 68 68 68 69 70 70 71 72 73 74 75 76 77 78 80 82 84 86 88 89 91 95 98 101 105 107 109 112 114 116 118 120 122 125 127 130 133 136 138 141 143 146 159 - true - 500 - true - 900 - false - 0 - false - 0 - false - 500 - OSPRaySLIVR - SobelOperator - 200 - Linear - 1 - OriginalData - Rasterization - 3 - 1 - Lower - false - 1 - 0.3 0.9 0.1 15 - diff --git a/extern/tfn/examples/visit_tfn/slivr_ospray_attribute.xml b/extern/tfn/examples/visit_tfn/slivr_ospray_attribute.xml deleted file mode 100644 index f27da13..0000000 --- a/extern/tfn/examples/visit_tfn/slivr_ospray_attribute.xml +++ /dev/null @@ -1,109 +0,0 @@ - - - true - false - - - - 0 0 255 255 - 0 - - - 0 255 255 255 - 0.25 - - - 0 255 0 255 - 0.5 - - - 255 255 0 255 - 0.75 - - - 255 0 0 255 - 1 - - Linear - false - false - - - - 0.3529412 - FreeformMode - - - - 0.0625 - 0.693548 - 0.0592105 - 0 - 0 - - - 0.223684 - 0.629032 - 0.0707237 - 0 - 0 - - - 0.399671 - 0.612903 - 0.0805921 - 0 - 0 - - - 0.598684 - 0.629032 - 0.087171 - 0 - 0 - - - 0.787829 - 0.741935 - 0.0723684 - 0 - 0 - - - 0.980263 - 0.677419 - 0.0625 - 0 - 0 - - - - false - 50000 - default - default - 0 0 0 0 0 0 0 0 0 7 19 36 63 71 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 - false - 0 - false - 0 - false - 0 - false - 0 - false - 500 - OSPRaySLIVR - CenteredDifferences - 200 - Linear - 1 - OriginalData - Trilinear - 3 - 1 - High - false - 1 - 0.4 0.75 0.8 15 - diff --git a/extern/tfn/examples/visit_tfn/slivr_pascal_attribute.xml b/extern/tfn/examples/visit_tfn/slivr_pascal_attribute.xml deleted file mode 100644 index c033a60..0000000 --- a/extern/tfn/examples/visit_tfn/slivr_pascal_attribute.xml +++ /dev/null @@ -1,109 +0,0 @@ - - - true - false - - - - 0 0 255 255 - 0 - - - 0 255 255 255 - 0.25 - - - 0 255 0 255 - 0.5 - - - 255 255 0 255 - 0.75 - - - 255 0 0 255 - 1 - - Linear - false - false - - - - 0.3529412 - FreeformMode - - - - 0.0625 - 0.693548 - 0.0592105 - 0 - 0 - - - 0.223684 - 0.629032 - 0.0707237 - 0 - 0 - - - 0.399671 - 0.612903 - 0.0805921 - 0 - 0 - - - 0.598684 - 0.629032 - 0.087171 - 0 - 0 - - - 0.787829 - 0.741935 - 0.0723684 - 0 - 0 - - - 0.980263 - 0.677419 - 0.0625 - 0 - 0 - - - - false - 50000 - default - default - 0 0 0 0 0 0 0 0 0 7 19 36 63 71 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 - false - 0 - false - 0 - false - 0 - false - 0 - false - 500 - RayCastingSLIVR - CenteredDifferences - 200 - Linear - 1 - OriginalData - Trilinear - 3 - 1 - High - false - 1 - 0.4 0.75 0.8 15 - diff --git a/extern/tfn/examples/visit_tfn/supernova.xml b/extern/tfn/examples/visit_tfn/supernova.xml deleted file mode 100644 index 3fe6133..0000000 --- a/extern/tfn/examples/visit_tfn/supernova.xml +++ /dev/null @@ -1,198 +0,0 @@ - - - true - true - - - - 71 71 219 255 - 0 - - - 0 0 91 255 - 0.143 - - - 0 255 255 255 - 0.285 - - - 0 127 0 255 - 0.429 - - - 255 255 0 255 - 0.571 - - - 255 96 0 255 - 0.714 - - - 107 0 0 255 - 0.857 - - - 224 76 76 255 - 1 - - Linear - false - false - - - - 0.1843137 - GaussianMode - - - - 0.07339449 - 0.08536583 - 0.0560616 - -0.01179554 - 0.6000004 - - - 0.175 - 0.3658537 - 0.025 - 0 - 0 - - - 0.225 - 0.6166667 - 0.01484273 - 0 - 0 - - - 0.275 - 0.9390244 - 0.01 - 0 - 0 - - - 0.325 - 0.4166667 - 0.025 - 0 - 0 - - - 0.375 - 0.4 - 0.01 - 0 - 0 - - - 0.425 - 0.8414634 - 0.01 - 0 - 0 - - - 0.475 - 0.1341463 - 0.03745088 - 0 - 0 - - - 0.542595 - 0.1219512 - 0.06215596 - 0 - 0 - - - 0.5845347 - 0.7073171 - 0.01 - 0 - 0 - - - 0.6841416 - 0.6219512 - 0.01 - 0 - 0 - - - 0.725 - 0.3048781 - 0.025 - 0 - 0 - - - 0.775 - 0.2073171 - 0.0415138 - 0 - 0 - - - 0.8387942 - 0.9512195 - 0.01965928 - 0 - 0 - - - 0.9279161 - 0.3414634 - 0.09305376 - -0.0235911 - 0 - - - 0.129751 - 0.7439024 - 0.02359109 - 0 - 0 - - - 0.6304063 - 0.3902439 - 0.0157274 - 0 - 0 - - - - true - 50000 - default - default - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 2 2 3 4 5 6 7 8 9 10 12 13 14 15 15 16 16 16 16 16 16 15 14 13 12 11 9 8 7 7 9 11 13 16 19 21 24 26 29 31 32 33 33 33 33 31 29 27 25 22 19 17 14 12 11 14 18 22 27 32 38 45 51 59 66 73 80 87 92 97 101 104 106 106 104 102 98 93 88 81 74 67 60 53 46 39 33 28 23 19 15 12 9 11 14 17 21 25 30 36 42 48 56 63 71 79 88 96 103 111 117 123 128 132 134 135 135 134 131 127 122 116 109 101 94 85 77 69 61 54 47 40 34 29 24 20 16 13 10 8 10 12 15 18 21 24 28 33 38 43 49 56 63 70 78 86 95 103 112 121 130 138 147 154 162 169 175 180 184 187 189 191 191 190 187 184 180 175 169 162 155 147 138 130 121 112 104 95 86 78 70 63 56 56 63 69 76 83 90 98 105 113 120 128 135 142 148 154 160 165 169 172 175 177 178 178 177 176 173 170 166 161 156 150 143 137 130 122 115 107 - true - 0.0015 - true - 0.09 - false - 0 - false - 0 - false - 500 - OSPRaySLIVR - SobelOperator - 200 - Linear - 1 - OriginalData - Rasterization - 3 - 1 - Lower - false - 1 - 0.4 0.75 0 15 - diff --git a/extern/tfn/examples/visit_tfn/turbulence_attribute.xml b/extern/tfn/examples/visit_tfn/turbulence_attribute.xml deleted file mode 100644 index 5ee6544..0000000 --- a/extern/tfn/examples/visit_tfn/turbulence_attribute.xml +++ /dev/null @@ -1,137 +0,0 @@ - - - true - true - - - - 0 0 255 255 - 0 - - - 0 255 255 255 - 0.25 - - - 0 255 0 255 - 0.3057143 - - - 255 255 0 255 - 0.3571429 - - - 255 0 0 255 - 1 - - Linear - false - false - - - - 0.2470588 - GaussianMode - - - - 0.05706134 - 0.2333333 - 0.03994294 - 0 - 0 - - - 0.15 - 0.2833334 - 0.05 - 0 - 0 - - - 0.25 - 0.3833333 - 0.05 - 0 - 0 - - - 0.35 - 0.5 - 0.05 - 0 - 0 - - - 0.45 - 0.5 - 0.05 - 0 - 0 - - - 0.55 - 0.5 - 0.05 - 0 - 0 - - - 0.65 - 0.7333333 - 0.05 - 0 - 0 - - - 0.75 - 0.75 - 0.05 - 0 - 0 - - - 0.85 - 0.75 - 0.05 - 0 - 0 - - - 0.95 - 0.8333333 - 0.05 - 0 - 0 - - - - true - 50000 - default - default - 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 195 173 151 130 108 86 65 43 21 0 0 21 43 65 86 108 130 151 173 - false - 0 - true - 10 - false - 0 - false - 0 - false - 500 - OSPRaySLIVR - SobelOperator - 200 - Linear - 1 - OriginalData - Rasterization - 3 - 1 - Lower - false - 1 - 0.4 0.75 0 15 - diff --git a/extern/tfn/examples/vtk_tfn/black_body_radiation.json b/extern/tfn/examples/vtk_tfn/black_body_radiation.json deleted file mode 100644 index 5cf0c54..0000000 --- a/extern/tfn/examples/vtk_tfn/black_body_radiation.json +++ /dev/null @@ -1,26 +0,0 @@ -[ - { - "ColorSpace" : "RGB", - "Name" : "Black-Body Radiation", - "NanColor" : [ 0, 0.49803921568600001, 1 ], - "RGBPoints" : [ - 0, - 0, - 0, - 0, - 0.40000000000000002, - 0.90196078431399995, - 0, - 0, - 0.80000000000000004, - 0.90196078431399995, - 0.90196078431399995, - 0, - 1, - 1, - 1, - 1 - ] - } -] - diff --git a/extern/tfn/examples/vtk_tfn/blackbody.json b/extern/tfn/examples/vtk_tfn/blackbody.json deleted file mode 100644 index 5cf0c54..0000000 --- a/extern/tfn/examples/vtk_tfn/blackbody.json +++ /dev/null @@ -1,26 +0,0 @@ -[ - { - "ColorSpace" : "RGB", - "Name" : "Black-Body Radiation", - "NanColor" : [ 0, 0.49803921568600001, 1 ], - "RGBPoints" : [ - 0, - 0, - 0, - 0, - 0.40000000000000002, - 0.90196078431399995, - 0, - 0, - 0.80000000000000004, - 0.90196078431399995, - 0.90196078431399995, - 0, - 1, - 1, - 1, - 1 - ] - } -] - diff --git a/extern/tfn/examples/vtk_tfn/blue_yellow.json b/extern/tfn/examples/vtk_tfn/blue_yellow.json deleted file mode 100644 index bd68c42..0000000 --- a/extern/tfn/examples/vtk_tfn/blue_yellow.json +++ /dev/null @@ -1,18 +0,0 @@ -[ - { - "ColorSpace" : "RGB", - "Name" : "Blue to Yellow", - "NanColor" : [ 1, 0, 0 ], - "RGBPoints" : [ - 0, - 0.039215686274499999, - 0.039215686274499999, - 0.94901960784299999, - 1, - 0.94901960784299999, - 0.94901960784299999, - 0.039215686274499999 - ] - } -] - diff --git a/extern/tfn/examples/vtk_tfn/cool_warm_extended.json b/extern/tfn/examples/vtk_tfn/cool_warm_extended.json deleted file mode 100644 index 3436342..0000000 --- a/extern/tfn/examples/vtk_tfn/cool_warm_extended.json +++ /dev/null @@ -1,151 +0,0 @@ -[ - { - "ColorSpace" : "Lab", - "Creator" : "Francesca Samsel", - "Name" : "Cool to Warm (Extended)", - "NanColor" : [ 0.25, 0, 0 ], - "RGBPoints" : [ - 0, - 0, - 0, - 0.34902, - 0.03125, - 0.039216000000000001, - 0.062744999999999995, - 0.38039200000000001, - 0.0625, - 0.062744999999999995, - 0.117647, - 0.41176499999999999, - 0.09375, - 0.090195999999999998, - 0.18431400000000001, - 0.45097999999999999, - 0.125, - 0.12548999999999999, - 0.26274500000000001, - 0.50196099999999999, - 0.15625, - 0.16078400000000001, - 0.33725500000000003, - 0.54117599999999999, - 0.1875, - 0.20000000000000001, - 0.39607799999999999, - 0.56862699999999999, - 0.21875, - 0.23921600000000001, - 0.45490199999999997, - 0.59999999999999998, - 0.25, - 0.286275, - 0.52156899999999995, - 0.65098, - 0.28125, - 0.33725500000000003, - 0.59215700000000004, - 0.70196099999999995, - 0.3125, - 0.388235, - 0.65490199999999998, - 0.74902000000000002, - 0.34375, - 0.466667, - 0.73725499999999999, - 0.819608, - 0.375, - 0.57254899999999997, - 0.819608, - 0.87843099999999996, - 0.40625, - 0.65490199999999998, - 0.86666699999999997, - 0.90980399999999995, - 0.4375, - 0.75294099999999997, - 0.91764699999999999, - 0.94117600000000001, - 0.46875, - 0.82352899999999996, - 0.95686300000000002, - 0.96862700000000002, - 0.5, - 0.98823499999999997, - 0.96078399999999997, - 0.90196100000000001, - 0.5, - 0.94117600000000001, - 0.98431400000000002, - 0.98823499999999997, - 0.52000000000000002, - 0.98823499999999997, - 0.94509799999999999, - 0.85097999999999996, - 0.54000000000000004, - 0.98039200000000004, - 0.89803900000000003, - 0.78431399999999996, - 0.5625, - 0.96862700000000002, - 0.83529399999999998, - 0.69803899999999997, - 0.59375, - 0.94901999999999997, - 0.73333300000000001, - 0.58823499999999995, - 0.625, - 0.92941200000000002, - 0.65098, - 0.50980400000000003, - 0.65625, - 0.90980399999999995, - 0.56470600000000004, - 0.43529400000000001, - 0.6875, - 0.87843099999999996, - 0.45882400000000001, - 0.352941, - 0.71875, - 0.83921599999999996, - 0.388235, - 0.286275, - 0.75, - 0.76078400000000002, - 0.29411799999999999, - 0.21176500000000001, - 0.78125, - 0.70196099999999995, - 0.21176500000000001, - 0.168627, - 0.8125, - 0.65098, - 0.156863, - 0.129412, - 0.84375, - 0.59999999999999998, - 0.094117999999999993, - 0.094117999999999993, - 0.875, - 0.54901999999999995, - 0.066667000000000004, - 0.098039000000000001, - 0.90625, - 0.50196099999999999, - 0.050979999999999998, - 0.12548999999999999, - 0.9375, - 0.45097999999999999, - 0.054901999999999999, - 0.17254900000000001, - 0.96875, - 0.40000000000000002, - 0.054901999999999999, - 0.19215699999999999, - 1, - 0.34902, - 0.070587999999999998, - 0.21176500000000001 - ] - } -] - diff --git a/extern/tfn/examples/vtk_tfn/green_blue_asym_diverge.json b/extern/tfn/examples/vtk_tfn/green_blue_asym_diverge.json deleted file mode 100644 index d8e6ae5..0000000 --- a/extern/tfn/examples/vtk_tfn/green_blue_asym_diverge.json +++ /dev/null @@ -1,99 +0,0 @@ -[ - { - "ColorSpace" : "Lab", - "Creator" : "Francesca Samsel", - "Name" : "Green-Blue Asymmetric Divergent (62Blbc)", - "NanColor" : [ 0.25, 0, 0 ], - "RGBPoints" : [ - 0, - 0.121569, - 0.20000000000000001, - 0.145098, - 0.050000000000000003, - 0.196078, - 0.30196099999999998, - 0.22352900000000001, - 0.10000000000000001, - 0.258824, - 0.40000000000000002, - 0.27843099999999998, - 0.20000000000000001, - 0.34117599999999998, - 0.54901999999999995, - 0.34117599999999998, - 0.25, - 0.41960799999999998, - 0.61960800000000005, - 0.376471, - 0.29999999999999999, - 0.54509799999999997, - 0.70196099999999995, - 0.39215699999999998, - 0.34999999999999998, - 0.64313699999999996, - 0.78039199999999997, - 0.403922, - 0.40000000000000002, - 0.72941199999999995, - 0.819608, - 0.45097999999999999, - 0.45000000000000001, - 0.81176499999999996, - 0.87058800000000003, - 0.52156899999999995, - 0.5, - 0.89803900000000003, - 0.90980399999999995, - 0.56470600000000004, - 0.55000000000000004, - 0.94117600000000001, - 0.92549000000000003, - 0.68627499999999997, - 0.59999999999999998, - 0.96078399999999997, - 0.94901999999999997, - 0.77647100000000002, - 0.64000000000000001, - 1, - 1, - 1, - 0.65000000000000002, - 0.89019599999999999, - 0.98823499999999997, - 0.972549, - 0.69999999999999996, - 0.72156900000000002, - 0.89411799999999997, - 0.90196100000000001, - 0.75, - 0.63137299999999996, - 0.82352899999999996, - 0.83921599999999996, - 0.80000000000000004, - 0.51764699999999997, - 0.66274500000000003, - 0.70196099999999995, - 0.84999999999999998, - 0.38431399999999999, - 0.494118, - 0.54901999999999995, - 0.90000000000000002, - 0.298039, - 0.36078399999999999, - 0.45097999999999999, - 0.94999999999999996, - 0.22352900000000001, - 0.25097999999999998, - 0.34902, - 0.98999999999999999, - 0.156863, - 0.17254900000000001, - 0.25097999999999998, - 1, - 0.13725499999999999, - 0.13725499999999999, - 0.18823500000000001 - ] - } -] - diff --git a/extern/tfn/examples/vtk_tfn/linear_green.json b/extern/tfn/examples/vtk_tfn/linear_green.json deleted file mode 100644 index c2f6792..0000000 --- a/extern/tfn/examples/vtk_tfn/linear_green.json +++ /dev/null @@ -1,95 +0,0 @@ -[ - { - "ColorSpace" : "CIELAB", - "Creator" : "Francesca Samsel", - "Name" : "Linear Green (Gr4L)", - "NanColor" : [ 0.25, 0, 0 ], - "RGBPoints" : [ - 0, - 0.054901999999999999, - 0.109804, - 0.121569, - 0.050000000000000003, - 0.074510000000000007, - 0.17254900000000001, - 0.180392, - 0.10000000000000001, - 0.086275000000000004, - 0.231373, - 0.219608, - 0.14999999999999999, - 0.094117999999999993, - 0.27843099999999998, - 0.25097999999999998, - 0.20000000000000001, - 0.109804, - 0.34902, - 0.27843099999999998, - 0.25, - 0.11372500000000001, - 0.40000000000000002, - 0.27843099999999998, - 0.29999999999999999, - 0.117647, - 0.45097999999999999, - 0.270588, - 0.34999999999999998, - 0.117647, - 0.49019600000000002, - 0.24313699999999999, - 0.40000000000000002, - 0.11372500000000001, - 0.52156899999999995, - 0.20392199999999999, - 0.45000000000000001, - 0.109804, - 0.54901999999999995, - 0.15294099999999999, - 0.5, - 0.082352999999999996, - 0.58823499999999995, - 0.082352999999999996, - 0.55000000000000004, - 0.109804, - 0.63137299999999996, - 0.050979999999999998, - 0.59999999999999998, - 0.21176500000000001, - 0.67843100000000001, - 0.082352999999999996, - 0.65000000000000002, - 0.31764700000000001, - 0.72156900000000002, - 0.11372500000000001, - 0.69999999999999996, - 0.43137300000000001, - 0.76078400000000002, - 0.16078400000000001, - 0.75, - 0.556863, - 0.80000000000000004, - 0.23921600000000001, - 0.80000000000000004, - 0.66666700000000001, - 0.83921599999999996, - 0.29411799999999999, - 0.84999999999999998, - 0.78431399999999996, - 0.87843099999999996, - 0.39607799999999999, - 0.90000000000000002, - 0.88627500000000003, - 0.92156899999999997, - 0.53333299999999995, - 0.94999999999999996, - 0.96078399999999997, - 0.94901999999999997, - 0.67058799999999996, - 1, - 1, - 0.98431400000000002, - 0.90196100000000001 - ] - } -] - diff --git a/extern/tfn/examples/vtk_tfn/linear_ygb1211g.json b/extern/tfn/examples/vtk_tfn/linear_ygb1211g.json deleted file mode 100644 index 5abd846..0000000 --- a/extern/tfn/examples/vtk_tfn/linear_ygb1211g.json +++ /dev/null @@ -1,99 +0,0 @@ -[ - { - "ColorSpace" : "Lab", - "Creator" : "Francesca Samsel", - "Name" : "Linear YGB 1211g", - "NanColor" : [ 0.25, 0, 0 ], - "RGBPoints" : [ - 0, - 1, - 0.98823499999999997, - 0.96862700000000002, - 0.02, - 1, - 0.95294100000000004, - 0.87843099999999996, - 0.050000000000000003, - 0.96862700000000002, - 0.90588199999999997, - 0.77647100000000002, - 0.10000000000000001, - 0.94901999999999997, - 0.89803900000000003, - 0.64705900000000005, - 0.14999999999999999, - 0.90196100000000001, - 0.87843099999999996, - 0.556863, - 0.20000000000000001, - 0.84705900000000001, - 0.85882400000000003, - 0.48235299999999998, - 0.25, - 0.69019600000000003, - 0.819608, - 0.43529400000000001, - 0.29999999999999999, - 0.51372499999999999, - 0.76862699999999995, - 0.38431399999999999, - 0.34999999999999998, - 0.33725500000000003, - 0.72156900000000002, - 0.33725500000000003, - 0.40000000000000002, - 0.27843099999999998, - 0.65882399999999997, - 0.39215699999999998, - 0.45000000000000001, - 0.231373, - 0.63921600000000001, - 0.43529400000000001, - 0.5, - 0.20392199999999999, - 0.59999999999999998, - 0.48627500000000001, - 0.55000000000000004, - 0.17254900000000001, - 0.56862699999999999, - 0.53725500000000004, - 0.59999999999999998, - 0.141176, - 0.51764699999999997, - 0.54901999999999995, - 0.65000000000000002, - 0.13333300000000001, - 0.45882400000000001, - 0.54117599999999999, - 0.69999999999999996, - 0.12548999999999999, - 0.39607799999999999, - 0.52941199999999999, - 0.75, - 0.117647, - 0.32156899999999999, - 0.52156899999999995, - 0.80000000000000004, - 0.121569, - 0.258824, - 0.50980400000000003, - 0.84999999999999998, - 0.13333300000000001, - 0.22745099999999999, - 0.50196099999999999, - 0.90000000000000002, - 0.145098, - 0.19215699999999999, - 0.49019600000000002, - 0.94999999999999996, - 0.18823500000000001, - 0.16470599999999999, - 0.47058800000000001, - 1, - 0.258824, - 0.196078, - 0.439216 - ] - } -] - diff --git a/extern/tfn/examples/vtk_tfn/matplotlib_plasma.json b/extern/tfn/examples/vtk_tfn/matplotlib_plasma.json deleted file mode 100644 index bb90cad..0000000 --- a/extern/tfn/examples/vtk_tfn/matplotlib_plasma.json +++ /dev/null @@ -1,1037 +0,0 @@ -[ - { - "ColorSpace" : "Diverging", - "Creator" : "Nathaniel J. Smith & Stefan van der Walt", - "License" : "CC0", - "Name" : "Plasma (matplotlib)", - "NanColor" : [ 0, 1, 0 ], - "RGBPoints" : [ - 0, - 0.050382999999999997, - 0.029803, - 0.52797499999999997, - 0.0039220000000000001, - 0.063535999999999995, - 0.028426, - 0.53312400000000004, - 0.0078429999999999993, - 0.075353000000000003, - 0.027206000000000001, - 0.53800700000000001, - 0.011764999999999999, - 0.086221999999999993, - 0.026124999999999999, - 0.54265799999999997, - 0.015685999999999999, - 0.096379000000000006, - 0.025165, - 0.54710300000000001, - 0.019608, - 0.10598, - 0.024309000000000001, - 0.55136799999999997, - 0.023529000000000001, - 0.115124, - 0.023556000000000001, - 0.55546799999999996, - 0.027451, - 0.123903, - 0.022877999999999999, - 0.559423, - 0.031372999999999998, - 0.132381, - 0.022258, - 0.56325000000000003, - 0.035293999999999999, - 0.14060300000000001, - 0.021687000000000001, - 0.56695899999999999, - 0.039216000000000001, - 0.14860699999999999, - 0.021153999999999999, - 0.57056200000000001, - 0.043137000000000002, - 0.156421, - 0.020650999999999999, - 0.57406500000000005, - 0.047058999999999997, - 0.16406999999999999, - 0.020171000000000001, - 0.57747800000000005, - 0.050979999999999998, - 0.171574, - 0.019706000000000001, - 0.58080600000000004, - 0.054901999999999999, - 0.17895, - 0.019251999999999998, - 0.58405399999999996, - 0.058824000000000001, - 0.18621299999999999, - 0.018803, - 0.58722799999999997, - 0.062744999999999995, - 0.19337399999999999, - 0.018353999999999999, - 0.59033000000000002, - 0.066667000000000004, - 0.20044500000000001, - 0.017902000000000001, - 0.593364, - 0.070587999999999998, - 0.20743500000000001, - 0.017441999999999999, - 0.596333, - 0.074510000000000007, - 0.21435000000000001, - 0.016972999999999999, - 0.59923899999999997, - 0.078431000000000001, - 0.221197, - 0.016497000000000001, - 0.60208300000000003, - 0.082352999999999996, - 0.22798299999999999, - 0.016007, - 0.60486700000000004, - 0.086275000000000004, - 0.23471500000000001, - 0.015502, - 0.60759200000000002, - 0.090195999999999998, - 0.241396, - 0.014978999999999999, - 0.610259, - 0.094117999999999993, - 0.248032, - 0.014439, - 0.61286799999999997, - 0.098039000000000001, - 0.25462699999999999, - 0.013882, - 0.61541900000000005, - 0.101961, - 0.261183, - 0.013308, - 0.61791099999999999, - 0.105882, - 0.26770300000000002, - 0.012716, - 0.62034599999999995, - 0.109804, - 0.27419100000000002, - 0.012109, - 0.622722, - 0.11372500000000001, - 0.28064800000000001, - 0.011488, - 0.62503799999999998, - 0.117647, - 0.287076, - 0.010855, - 0.62729500000000005, - 0.121569, - 0.29347800000000002, - 0.010213, - 0.62948999999999999, - 0.12548999999999999, - 0.29985499999999998, - 0.0095610000000000001, - 0.63162399999999996, - 0.129412, - 0.30620999999999998, - 0.0089020000000000002, - 0.63369399999999998, - 0.13333300000000001, - 0.31254300000000002, - 0.0082389999999999998, - 0.63570000000000004, - 0.13725499999999999, - 0.31885599999999997, - 0.0075760000000000003, - 0.63763999999999998, - 0.141176, - 0.32514999999999999, - 0.0069150000000000001, - 0.63951199999999997, - 0.145098, - 0.331426, - 0.0062610000000000001, - 0.641316, - 0.14902000000000001, - 0.33768300000000001, - 0.0056179999999999997, - 0.64304899999999998, - 0.15294099999999999, - 0.34392499999999998, - 0.0049909999999999998, - 0.64471000000000001, - 0.156863, - 0.35015000000000002, - 0.0043819999999999996, - 0.64629800000000004, - 0.16078400000000001, - 0.35635899999999998, - 0.0037980000000000002, - 0.64781, - 0.16470599999999999, - 0.36255300000000001, - 0.0032429999999999998, - 0.64924499999999996, - 0.168627, - 0.36873299999999998, - 0.0027239999999999999, - 0.65060099999999998, - 0.17254900000000001, - 0.37489699999999998, - 0.002245, - 0.65187600000000001, - 0.17647099999999999, - 0.38104700000000002, - 0.0018140000000000001, - 0.65306799999999998, - 0.180392, - 0.387183, - 0.0014339999999999999, - 0.65417700000000001, - 0.18431400000000001, - 0.39330399999999999, - 0.001114, - 0.65519899999999998, - 0.18823500000000001, - 0.39941100000000002, - 0.00085899999999999995, - 0.65613299999999997, - 0.19215699999999999, - 0.405503, - 0.000678, - 0.65697700000000003, - 0.196078, - 0.41158, - 0.00057700000000000004, - 0.65773000000000004, - 0.20000000000000001, - 0.41764200000000001, - 0.00056400000000000005, - 0.65839000000000003, - 0.20392199999999999, - 0.42368899999999998, - 0.00064599999999999998, - 0.65895599999999999, - 0.207843, - 0.42971900000000002, - 0.00083100000000000003, - 0.65942500000000004, - 0.21176500000000001, - 0.43573400000000001, - 0.001127, - 0.65979699999999997, - 0.21568599999999999, - 0.44173200000000001, - 0.0015399999999999999, - 0.66006900000000002, - 0.219608, - 0.447714, - 0.0020799999999999998, - 0.66024000000000005, - 0.22352900000000001, - 0.453677, - 0.0027550000000000001, - 0.66030999999999995, - 0.22745099999999999, - 0.459623, - 0.0035739999999999999, - 0.660277, - 0.231373, - 0.46555000000000002, - 0.0045450000000000004, - 0.66013900000000003, - 0.235294, - 0.47145700000000001, - 0.0056779999999999999, - 0.65989699999999996, - 0.23921600000000001, - 0.47734399999999999, - 0.0069800000000000001, - 0.65954900000000005, - 0.24313699999999999, - 0.48320999999999997, - 0.0084600000000000005, - 0.65909499999999999, - 0.247059, - 0.48905500000000002, - 0.010127000000000001, - 0.65853399999999995, - 0.25097999999999998, - 0.49487700000000001, - 0.011990000000000001, - 0.65786500000000003, - 0.25490200000000002, - 0.50067799999999996, - 0.014055, - 0.65708800000000001, - 0.258824, - 0.50645399999999996, - 0.016333, - 0.65620199999999995, - 0.26274500000000001, - 0.51220600000000005, - 0.018832999999999999, - 0.65520900000000004, - 0.26666699999999999, - 0.51793299999999998, - 0.021562999999999999, - 0.65410900000000005, - 0.270588, - 0.52363300000000002, - 0.024532000000000002, - 0.65290099999999995, - 0.27450999999999998, - 0.52930600000000005, - 0.027747000000000001, - 0.651586, - 0.27843099999999998, - 0.53495199999999998, - 0.031217000000000002, - 0.65016499999999999, - 0.28235300000000002, - 0.54056999999999999, - 0.034950000000000002, - 0.64863999999999999, - 0.286275, - 0.546157, - 0.038954000000000003, - 0.64700999999999997, - 0.29019600000000001, - 0.55171499999999996, - 0.043136000000000001, - 0.64527699999999999, - 0.29411799999999999, - 0.55724300000000004, - 0.047330999999999998, - 0.64344299999999999, - 0.298039, - 0.56273799999999996, - 0.051545000000000001, - 0.641509, - 0.30196099999999998, - 0.56820099999999996, - 0.055778000000000001, - 0.63947699999999996, - 0.30588199999999999, - 0.57363200000000003, - 0.060027999999999998, - 0.63734900000000005, - 0.30980400000000002, - 0.57902900000000002, - 0.064296000000000006, - 0.63512599999999997, - 0.31372499999999998, - 0.58439099999999999, - 0.068579000000000001, - 0.63281200000000004, - 0.31764700000000001, - 0.58971899999999999, - 0.072877999999999998, - 0.63040799999999997, - 0.32156899999999999, - 0.59501099999999996, - 0.077189999999999995, - 0.62791699999999995, - 0.32549, - 0.60026599999999997, - 0.081516000000000005, - 0.62534199999999995, - 0.32941199999999998, - 0.60548500000000005, - 0.085854, - 0.62268599999999996, - 0.33333299999999999, - 0.61066699999999996, - 0.090204000000000006, - 0.61995100000000003, - 0.33725500000000003, - 0.61581200000000003, - 0.094563999999999995, - 0.61714000000000002, - 0.34117599999999998, - 0.620919, - 0.098933999999999994, - 0.61425700000000005, - 0.34509800000000002, - 0.62598699999999996, - 0.103312, - 0.61130499999999999, - 0.34902, - 0.63101700000000005, - 0.107699, - 0.60828700000000002, - 0.352941, - 0.63600800000000002, - 0.112092, - 0.60520499999999999, - 0.35686299999999999, - 0.64095899999999995, - 0.116492, - 0.60206499999999996, - 0.36078399999999999, - 0.645872, - 0.12089800000000001, - 0.59886700000000004, - 0.36470599999999997, - 0.65074600000000005, - 0.125309, - 0.59561699999999995, - 0.36862699999999998, - 0.65558000000000005, - 0.12972500000000001, - 0.59231699999999998, - 0.37254900000000002, - 0.66037400000000002, - 0.13414400000000001, - 0.58897100000000002, - 0.376471, - 0.66512899999999997, - 0.13856599999999999, - 0.58558200000000005, - 0.38039200000000001, - 0.66984500000000002, - 0.14299200000000001, - 0.58215399999999995, - 0.38431399999999999, - 0.67452199999999995, - 0.14741899999999999, - 0.57868799999999998, - 0.388235, - 0.67915999999999999, - 0.15184800000000001, - 0.57518899999999995, - 0.39215699999999998, - 0.68375799999999998, - 0.156278, - 0.57165999999999995, - 0.39607799999999999, - 0.68831799999999999, - 0.16070899999999999, - 0.56810300000000002, - 0.40000000000000002, - 0.69284000000000001, - 0.16514100000000001, - 0.56452199999999997, - 0.403922, - 0.69732400000000005, - 0.169573, - 0.56091899999999995, - 0.40784300000000001, - 0.70176899999999998, - 0.17400499999999999, - 0.55729600000000001, - 0.41176499999999999, - 0.70617799999999997, - 0.17843700000000001, - 0.55365699999999995, - 0.415686, - 0.71054899999999999, - 0.182868, - 0.55000400000000005, - 0.41960799999999998, - 0.71488300000000005, - 0.18729899999999999, - 0.54633799999999999, - 0.42352899999999999, - 0.71918099999999996, - 0.19172900000000001, - 0.54266300000000001, - 0.42745100000000003, - 0.72344399999999998, - 0.196158, - 0.53898100000000004, - 0.43137300000000001, - 0.72767000000000004, - 0.20058599999999999, - 0.53529300000000002, - 0.43529400000000001, - 0.73186200000000001, - 0.205013, - 0.53160099999999999, - 0.439216, - 0.73601899999999998, - 0.20943899999999999, - 0.52790800000000004, - 0.443137, - 0.740143, - 0.213864, - 0.52421600000000002, - 0.44705899999999998, - 0.744232, - 0.21828800000000001, - 0.52052399999999999, - 0.45097999999999999, - 0.74828899999999998, - 0.22271099999999999, - 0.51683400000000002, - 0.45490199999999997, - 0.75231199999999998, - 0.227133, - 0.51314899999999997, - 0.45882400000000001, - 0.75630399999999998, - 0.23155500000000001, - 0.50946800000000003, - 0.46274500000000002, - 0.76026400000000005, - 0.23597599999999999, - 0.50579399999999997, - 0.466667, - 0.76419300000000001, - 0.240396, - 0.50212599999999996, - 0.47058800000000001, - 0.76809000000000005, - 0.24481700000000001, - 0.49846499999999999, - 0.47450999999999999, - 0.77195800000000003, - 0.24923699999999999, - 0.494813, - 0.478431, - 0.77579600000000004, - 0.25365799999999999, - 0.49117100000000002, - 0.48235299999999998, - 0.77960399999999996, - 0.25807799999999997, - 0.487539, - 0.48627500000000001, - 0.78338300000000005, - 0.26250000000000001, - 0.48391800000000001, - 0.49019600000000002, - 0.78713299999999997, - 0.26692199999999999, - 0.48030699999999998, - 0.494118, - 0.79085499999999997, - 0.271345, - 0.47670600000000002, - 0.49803900000000001, - 0.79454899999999995, - 0.27577000000000002, - 0.47311700000000001, - 0.50196099999999999, - 0.79821600000000004, - 0.28019699999999997, - 0.46953800000000001, - 0.50588200000000005, - 0.80185499999999998, - 0.28462599999999999, - 0.46597100000000002, - 0.50980400000000003, - 0.80546700000000004, - 0.28905700000000001, - 0.46241500000000002, - 0.51372499999999999, - 0.80905199999999999, - 0.293491, - 0.45887, - 0.51764699999999997, - 0.812612, - 0.29792800000000003, - 0.45533800000000002, - 0.52156899999999995, - 0.81614399999999998, - 0.30236800000000003, - 0.451816, - 0.52549000000000001, - 0.81965100000000002, - 0.30681199999999997, - 0.44830599999999998, - 0.52941199999999999, - 0.82313199999999997, - 0.31126100000000001, - 0.44480599999999998, - 0.53333299999999995, - 0.82658799999999999, - 0.31571399999999999, - 0.44131599999999999, - 0.53725500000000004, - 0.83001800000000003, - 0.32017200000000001, - 0.437836, - 0.54117599999999999, - 0.833422, - 0.32463500000000001, - 0.43436599999999997, - 0.54509799999999997, - 0.83680100000000002, - 0.32910499999999998, - 0.43090499999999998, - 0.54901999999999995, - 0.84015499999999999, - 0.33357999999999999, - 0.42745499999999997, - 0.55294100000000002, - 0.84348400000000001, - 0.33806199999999997, - 0.42401299999999997, - 0.556863, - 0.84678799999999999, - 0.34255099999999999, - 0.42057899999999998, - 0.56078399999999995, - 0.85006599999999999, - 0.34704800000000002, - 0.417153, - 0.56470600000000004, - 0.85331900000000005, - 0.351553, - 0.41373399999999999, - 0.56862699999999999, - 0.85654699999999995, - 0.35606599999999999, - 0.41032200000000002, - 0.57254899999999997, - 0.85975000000000001, - 0.36058800000000002, - 0.40691699999999997, - 0.57647099999999996, - 0.862927, - 0.36511900000000003, - 0.40351900000000002, - 0.58039200000000002, - 0.86607800000000001, - 0.36965999999999999, - 0.40012599999999998, - 0.584314, - 0.86920299999999995, - 0.37421199999999999, - 0.39673799999999998, - 0.58823499999999995, - 0.87230300000000005, - 0.378774, - 0.39335500000000001, - 0.59215700000000004, - 0.87537600000000004, - 0.38334699999999999, - 0.38997599999999999, - 0.596078, - 0.87842299999999995, - 0.387932, - 0.3866, - 0.59999999999999998, - 0.88144299999999998, - 0.39252900000000002, - 0.38322899999999999, - 0.60392199999999996, - 0.884436, - 0.39713900000000002, - 0.37985999999999998, - 0.60784300000000002, - 0.88740200000000002, - 0.40176200000000001, - 0.376494, - 0.611765, - 0.89034000000000002, - 0.40639799999999998, - 0.37313000000000002, - 0.61568599999999996, - 0.89324999999999999, - 0.41104800000000002, - 0.36976799999999999, - 0.61960800000000005, - 0.89613100000000001, - 0.41571200000000003, - 0.36640699999999998, - 0.623529, - 0.89898400000000001, - 0.42039199999999999, - 0.36304700000000001, - 0.62745099999999998, - 0.90180700000000003, - 0.42508699999999999, - 0.35968800000000001, - 0.63137299999999996, - 0.90460099999999999, - 0.42979699999999998, - 0.35632900000000001, - 0.63529400000000003, - 0.90736499999999998, - 0.43452400000000002, - 0.35297000000000001, - 0.63921600000000001, - 0.91009799999999996, - 0.43926799999999999, - 0.34960999999999998, - 0.64313699999999996, - 0.91279999999999994, - 0.44402900000000001, - 0.34625099999999998, - 0.64705900000000005, - 0.91547100000000003, - 0.44880700000000001, - 0.34288999999999997, - 0.65098, - 0.91810899999999995, - 0.45360299999999998, - 0.33952900000000003, - 0.65490199999999998, - 0.92071400000000003, - 0.45841700000000002, - 0.33616600000000002, - 0.65882399999999997, - 0.92328699999999997, - 0.46325100000000002, - 0.33280100000000001, - 0.66274500000000003, - 0.92582500000000001, - 0.46810299999999999, - 0.32943499999999998, - 0.66666700000000001, - 0.92832899999999996, - 0.47297499999999998, - 0.326067, - 0.67058799999999996, - 0.93079800000000001, - 0.47786699999999999, - 0.32269700000000001, - 0.67451000000000005, - 0.93323199999999995, - 0.48277999999999999, - 0.31932500000000003, - 0.67843100000000001, - 0.93562999999999996, - 0.48771199999999998, - 0.31595200000000001, - 0.68235299999999999, - 0.93798999999999999, - 0.49266700000000002, - 0.31257499999999999, - 0.68627499999999997, - 0.94031299999999995, - 0.49764199999999997, - 0.309197, - 0.69019600000000003, - 0.94259800000000005, - 0.50263899999999995, - 0.30581599999999998, - 0.69411800000000001, - 0.94484400000000002, - 0.50765800000000005, - 0.30243300000000001, - 0.69803899999999997, - 0.94705099999999998, - 0.51269900000000002, - 0.29904900000000001, - 0.70196099999999995, - 0.94921699999999998, - 0.51776299999999997, - 0.29566199999999998, - 0.70588200000000001, - 0.95134399999999997, - 0.52285000000000004, - 0.29227500000000001, - 0.70980399999999999, - 0.95342800000000005, - 0.52795999999999998, - 0.288883, - 0.71372500000000005, - 0.95547000000000004, - 0.53309300000000004, - 0.28549000000000002, - 0.71764700000000003, - 0.95746900000000001, - 0.53825000000000001, - 0.28209600000000001, - 0.72156900000000002, - 0.95942400000000005, - 0.543431, - 0.27870099999999998, - 0.72548999999999997, - 0.96133599999999997, - 0.54863600000000001, - 0.27530500000000002, - 0.72941199999999995, - 0.96320300000000003, - 0.55386500000000005, - 0.27190900000000001, - 0.73333300000000001, - 0.96502399999999999, - 0.559118, - 0.268513, - 0.73725499999999999, - 0.96679800000000005, - 0.56439600000000001, - 0.26511800000000002, - 0.74117599999999995, - 0.968526, - 0.56969999999999998, - 0.26172099999999998, - 0.74509800000000004, - 0.97020499999999998, - 0.57502799999999998, - 0.25832500000000003, - 0.74902000000000002, - 0.971835, - 0.58038199999999995, - 0.25493100000000002, - 0.75294099999999997, - 0.97341599999999995, - 0.58576099999999998, - 0.25153999999999999, - 0.75686299999999995, - 0.97494700000000001, - 0.59116500000000005, - 0.24815100000000001, - 0.76078400000000002, - 0.97642799999999996, - 0.59659499999999999, - 0.24476700000000001, - 0.764706, - 0.97785599999999995, - 0.602051, - 0.24138699999999999, - 0.76862699999999995, - 0.97923300000000002, - 0.60753199999999996, - 0.238013, - 0.77254900000000004, - 0.98055599999999998, - 0.613039, - 0.23464599999999999, - 0.77647100000000002, - 0.98182599999999998, - 0.61857200000000001, - 0.23128699999999999, - 0.78039199999999997, - 0.98304100000000005, - 0.62413099999999999, - 0.227937, - 0.78431399999999996, - 0.98419900000000005, - 0.629718, - 0.22459499999999999, - 0.78823500000000002, - 0.98530099999999998, - 0.63532999999999995, - 0.22126499999999999, - 0.792157, - 0.98634500000000003, - 0.64096900000000001, - 0.217948, - 0.79607799999999995, - 0.98733199999999999, - 0.64663300000000001, - 0.21464800000000001, - 0.80000000000000004, - 0.98826000000000003, - 0.65232500000000004, - 0.211364, - 0.80392200000000003, - 0.98912800000000001, - 0.65804300000000004, - 0.20810000000000001, - 0.80784299999999998, - 0.98993500000000001, - 0.66378700000000002, - 0.20485900000000001, - 0.81176499999999996, - 0.99068100000000003, - 0.66955799999999999, - 0.20164199999999999, - 0.81568600000000002, - 0.99136500000000005, - 0.67535500000000004, - 0.19845299999999999, - 0.819608, - 0.99198500000000001, - 0.68117899999999998, - 0.195295, - 0.82352899999999996, - 0.99254100000000001, - 0.68703000000000003, - 0.19217000000000001, - 0.82745100000000005, - 0.99303200000000003, - 0.69290700000000005, - 0.189084, - 0.83137300000000003, - 0.99345600000000001, - 0.69881000000000004, - 0.18604100000000001, - 0.83529399999999998, - 0.99381399999999998, - 0.70474099999999995, - 0.18304300000000001, - 0.83921599999999996, - 0.99410299999999996, - 0.71069800000000005, - 0.18009700000000001, - 0.84313700000000003, - 0.99432399999999999, - 0.71668100000000001, - 0.177208, - 0.84705900000000001, - 0.99447399999999997, - 0.72269099999999997, - 0.17438100000000001, - 0.85097999999999996, - 0.99455300000000002, - 0.72872800000000004, - 0.171622, - 0.85490200000000005, - 0.99456100000000003, - 0.73479099999999997, - 0.168938, - 0.85882400000000003, - 0.99449500000000002, - 0.74087999999999998, - 0.16633500000000001, - 0.86274499999999998, - 0.99435499999999999, - 0.74699499999999996, - 0.16382099999999999, - 0.86666699999999997, - 0.99414100000000005, - 0.75313699999999995, - 0.16140399999999999, - 0.87058800000000003, - 0.99385100000000004, - 0.75930399999999998, - 0.15909200000000001, - 0.87451000000000001, - 0.99348199999999998, - 0.76549900000000004, - 0.156891, - 0.87843099999999996, - 0.99303300000000005, - 0.77171999999999996, - 0.154808, - 0.88235300000000005, - 0.99250499999999997, - 0.77796699999999996, - 0.15285499999999999, - 0.88627500000000003, - 0.99189700000000003, - 0.78423900000000002, - 0.15104200000000001, - 0.89019599999999999, - 0.99120900000000001, - 0.79053700000000005, - 0.14937700000000001, - 0.89411799999999997, - 0.99043899999999996, - 0.79685899999999998, - 0.14787, - 0.89803900000000003, - 0.98958699999999999, - 0.80320499999999995, - 0.14652899999999999, - 0.90196100000000001, - 0.98864799999999997, - 0.80957900000000005, - 0.14535699999999999, - 0.90588199999999997, - 0.98762099999999997, - 0.81597799999999998, - 0.14436299999999999, - 0.90980399999999995, - 0.98650899999999997, - 0.82240100000000005, - 0.14355699999999999, - 0.91372500000000001, - 0.98531400000000002, - 0.82884599999999997, - 0.14294499999999999, - 0.91764699999999999, - 0.98403099999999999, - 0.83531500000000003, - 0.14252799999999999, - 0.92156899999999997, - 0.982653, - 0.841812, - 0.14230300000000001, - 0.92549000000000003, - 0.98119000000000001, - 0.848329, - 0.14227899999999999, - 0.92941200000000002, - 0.97964399999999996, - 0.85486600000000001, - 0.142453, - 0.93333299999999997, - 0.97799499999999995, - 0.86143199999999998, - 0.14280799999999999, - 0.93725499999999995, - 0.97626500000000005, - 0.86801600000000001, - 0.14335100000000001, - 0.94117600000000001, - 0.97444299999999995, - 0.87462200000000001, - 0.14406099999999999, - 0.94509799999999999, - 0.97253000000000001, - 0.88124999999999998, - 0.144923, - 0.94901999999999997, - 0.97053299999999998, - 0.88789600000000002, - 0.14591899999999999, - 0.95294100000000004, - 0.96844300000000005, - 0.89456400000000003, - 0.14701400000000001, - 0.95686300000000002, - 0.96627099999999999, - 0.90124899999999997, - 0.14818000000000001, - 0.96078399999999997, - 0.96402100000000002, - 0.90795000000000003, - 0.14937, - 0.96470599999999995, - 0.96168100000000001, - 0.91467200000000004, - 0.15051999999999999, - 0.96862700000000002, - 0.95927600000000002, - 0.92140699999999998, - 0.15156600000000001, - 0.972549, - 0.95680799999999999, - 0.92815199999999998, - 0.15240899999999999, - 0.97647099999999998, - 0.954287, - 0.93490799999999996, - 0.152921, - 0.98039200000000004, - 0.95172599999999996, - 0.94167100000000004, - 0.15292500000000001, - 0.98431400000000002, - 0.94915099999999997, - 0.94843500000000003, - 0.15217800000000001, - 0.98823499999999997, - 0.94660200000000005, - 0.95518999999999998, - 0.15032799999999999, - 0.99215699999999996, - 0.94415199999999999, - 0.96191599999999999, - 0.14686099999999999, - 0.99607800000000002, - 0.94189599999999996, - 0.96858999999999995, - 0.140956, - 1, - 0.94001500000000004, - 0.97515799999999997, - 0.131326 - ], - "Source" : "https://github.com/BIDS/colormap/blob/master/colormaps.py" - } -] - diff --git a/extern/tfn/examples/vtk_tfn/matplotlib_virdis.json b/extern/tfn/examples/vtk_tfn/matplotlib_virdis.json deleted file mode 100644 index 3884839..0000000 --- a/extern/tfn/examples/vtk_tfn/matplotlib_virdis.json +++ /dev/null @@ -1,1037 +0,0 @@ -[ - { - "ColorSpace" : "Diverging", - "Creator" : "Eric Firing", - "License" : "CC0", - "Name" : "Viridis (matplotlib)", - "NanColor" : [ 1, 0, 0 ], - "RGBPoints" : [ - 0, - 0.26700400000000002, - 0.0048739999999999999, - 0.32941500000000001, - 0.0039220000000000001, - 0.26851000000000003, - 0.0096050000000000007, - 0.33542699999999998, - 0.0078429999999999993, - 0.26994400000000002, - 0.014625000000000001, - 0.34137899999999999, - 0.011764999999999999, - 0.27130500000000002, - 0.019942000000000001, - 0.34726899999999999, - 0.015685999999999999, - 0.272594, - 0.025562999999999999, - 0.35309299999999999, - 0.019608, - 0.27380900000000002, - 0.031496999999999997, - 0.35885299999999998, - 0.023529000000000001, - 0.27495199999999997, - 0.037752000000000001, - 0.36454300000000001, - 0.027451, - 0.27602199999999999, - 0.044166999999999998, - 0.37016399999999999, - 0.031372999999999998, - 0.27701799999999999, - 0.050344, - 0.37571500000000002, - 0.035293999999999999, - 0.27794099999999999, - 0.056323999999999999, - 0.381191, - 0.039216000000000001, - 0.27879100000000001, - 0.062144999999999999, - 0.38659199999999999, - 0.043137000000000002, - 0.27956599999999998, - 0.067835999999999994, - 0.39191700000000002, - 0.047058999999999997, - 0.28026699999999999, - 0.073416999999999996, - 0.39716299999999999, - 0.050979999999999998, - 0.28089399999999998, - 0.078907000000000005, - 0.40232899999999999, - 0.054901999999999999, - 0.28144599999999997, - 0.084320000000000006, - 0.407414, - 0.058824000000000001, - 0.28192400000000001, - 0.089665999999999996, - 0.41241499999999998, - 0.062744999999999995, - 0.28232699999999999, - 0.094954999999999998, - 0.41733100000000001, - 0.066667000000000004, - 0.28265600000000002, - 0.10019599999999999, - 0.42215999999999998, - 0.070587999999999998, - 0.28290999999999999, - 0.105393, - 0.426902, - 0.074510000000000007, - 0.28309099999999998, - 0.110553, - 0.43155399999999999, - 0.078431000000000001, - 0.28319699999999998, - 0.11568000000000001, - 0.43611499999999997, - 0.082352999999999996, - 0.28322900000000001, - 0.120777, - 0.44058399999999998, - 0.086275000000000004, - 0.28318700000000002, - 0.12584799999999999, - 0.44496000000000002, - 0.090195999999999998, - 0.28307199999999999, - 0.13089500000000001, - 0.449241, - 0.094117999999999993, - 0.28288400000000002, - 0.13592000000000001, - 0.45342700000000002, - 0.098039000000000001, - 0.28262300000000001, - 0.140926, - 0.45751700000000001, - 0.101961, - 0.28228999999999999, - 0.14591199999999999, - 0.46150999999999998, - 0.105882, - 0.281887, - 0.15088099999999999, - 0.46540500000000001, - 0.109804, - 0.281412, - 0.155834, - 0.46920099999999998, - 0.11372500000000001, - 0.28086800000000001, - 0.160771, - 0.47289900000000001, - 0.117647, - 0.28025499999999998, - 0.16569300000000001, - 0.47649799999999998, - 0.121569, - 0.27957399999999999, - 0.170599, - 0.47999700000000001, - 0.12548999999999999, - 0.27882600000000002, - 0.17549000000000001, - 0.48339700000000002, - 0.129412, - 0.27801199999999998, - 0.180367, - 0.48669699999999999, - 0.13333300000000001, - 0.27713399999999999, - 0.185228, - 0.489898, - 0.13725499999999999, - 0.276194, - 0.19007399999999999, - 0.49300100000000002, - 0.141176, - 0.27519100000000002, - 0.19490499999999999, - 0.49600499999999997, - 0.145098, - 0.27412799999999998, - 0.19972100000000001, - 0.49891099999999999, - 0.14902000000000001, - 0.27300600000000003, - 0.20452000000000001, - 0.50172099999999997, - 0.15294099999999999, - 0.27182800000000001, - 0.20930299999999999, - 0.50443400000000005, - 0.156863, - 0.27059499999999997, - 0.21406900000000001, - 0.50705199999999995, - 0.16078400000000001, - 0.26930799999999999, - 0.21881800000000001, - 0.50957699999999995, - 0.16470599999999999, - 0.26796799999999998, - 0.223549, - 0.51200800000000002, - 0.168627, - 0.26657999999999998, - 0.22826199999999999, - 0.51434899999999995, - 0.17254900000000001, - 0.26514500000000002, - 0.232956, - 0.51659900000000003, - 0.17647099999999999, - 0.26366299999999998, - 0.23763100000000001, - 0.51876199999999995, - 0.180392, - 0.26213799999999998, - 0.242286, - 0.52083699999999999, - 0.18431400000000001, - 0.260571, - 0.246922, - 0.52282799999999996, - 0.18823500000000001, - 0.258965, - 0.25153700000000001, - 0.52473599999999998, - 0.19215699999999999, - 0.257322, - 0.25613000000000002, - 0.526563, - 0.196078, - 0.25564500000000001, - 0.26070300000000002, - 0.528312, - 0.20000000000000001, - 0.25393500000000002, - 0.26525399999999999, - 0.52998299999999998, - 0.20392199999999999, - 0.25219399999999997, - 0.269783, - 0.53157900000000002, - 0.207843, - 0.25042500000000001, - 0.27428999999999998, - 0.53310299999999999, - 0.21176500000000001, - 0.24862899999999999, - 0.278775, - 0.53455600000000003, - 0.21568599999999999, - 0.246811, - 0.28323700000000002, - 0.535941, - 0.219608, - 0.244972, - 0.28767500000000001, - 0.53725999999999996, - 0.22352900000000001, - 0.243113, - 0.29209200000000002, - 0.53851599999999999, - 0.22745099999999999, - 0.24123700000000001, - 0.296485, - 0.53970899999999999, - 0.231373, - 0.239346, - 0.30085499999999998, - 0.54084399999999999, - 0.235294, - 0.23744100000000001, - 0.30520199999999997, - 0.54192099999999999, - 0.23921600000000001, - 0.23552600000000001, - 0.309527, - 0.54294399999999998, - 0.24313699999999999, - 0.23360300000000001, - 0.313828, - 0.54391400000000001, - 0.247059, - 0.23167399999999999, - 0.318106, - 0.54483400000000004, - 0.25097999999999998, - 0.229739, - 0.32236100000000001, - 0.54570600000000002, - 0.25490200000000002, - 0.227802, - 0.326594, - 0.54653200000000002, - 0.258824, - 0.22586300000000001, - 0.33080500000000002, - 0.54731399999999997, - 0.26274500000000001, - 0.22392500000000001, - 0.33499400000000001, - 0.54805300000000001, - 0.26666699999999999, - 0.22198899999999999, - 0.33916099999999999, - 0.54875200000000002, - 0.270588, - 0.220057, - 0.34330699999999997, - 0.54941300000000004, - 0.27450999999999998, - 0.21812999999999999, - 0.34743200000000002, - 0.55003800000000003, - 0.27843099999999998, - 0.21621000000000001, - 0.35153499999999999, - 0.55062699999999998, - 0.28235300000000002, - 0.21429799999999999, - 0.35561900000000002, - 0.55118400000000001, - 0.286275, - 0.212395, - 0.35968299999999997, - 0.55171000000000003, - 0.29019600000000001, - 0.210503, - 0.36372700000000002, - 0.55220599999999997, - 0.29411799999999999, - 0.208623, - 0.36775200000000002, - 0.55267500000000003, - 0.298039, - 0.206756, - 0.37175799999999998, - 0.55311699999999997, - 0.30196099999999998, - 0.204903, - 0.37574600000000002, - 0.55353300000000005, - 0.30588199999999999, - 0.20306299999999999, - 0.379716, - 0.553925, - 0.30980400000000002, - 0.201239, - 0.38367000000000001, - 0.55429399999999995, - 0.31372499999999998, - 0.19943, - 0.38760699999999998, - 0.55464199999999997, - 0.31764700000000001, - 0.19763600000000001, - 0.39152799999999999, - 0.55496900000000005, - 0.32156899999999999, - 0.19586000000000001, - 0.39543299999999998, - 0.55527599999999999, - 0.32549, - 0.19409999999999999, - 0.39932299999999998, - 0.55556499999999998, - 0.32941199999999998, - 0.192357, - 0.40319899999999997, - 0.555836, - 0.33333299999999999, - 0.19063099999999999, - 0.40706100000000001, - 0.55608900000000006, - 0.33725500000000003, - 0.18892300000000001, - 0.41091, - 0.55632599999999999, - 0.34117599999999998, - 0.18723100000000001, - 0.414746, - 0.55654700000000001, - 0.34509800000000002, - 0.185556, - 0.41857, - 0.55675300000000005, - 0.34902, - 0.18389800000000001, - 0.42238300000000001, - 0.55694399999999999, - 0.352941, - 0.182256, - 0.42618400000000001, - 0.55711999999999995, - 0.35686299999999999, - 0.18062900000000001, - 0.429975, - 0.55728200000000006, - 0.36078399999999999, - 0.17901900000000001, - 0.43375599999999997, - 0.55742999999999998, - 0.36470599999999997, - 0.177423, - 0.437527, - 0.55756499999999998, - 0.36862699999999998, - 0.175841, - 0.44129000000000002, - 0.55768499999999999, - 0.37254900000000002, - 0.17427400000000001, - 0.445044, - 0.55779199999999995, - 0.376471, - 0.17271900000000001, - 0.448791, - 0.55788499999999996, - 0.38039200000000001, - 0.17117599999999999, - 0.45252999999999999, - 0.55796500000000004, - 0.38431399999999999, - 0.16964599999999999, - 0.456262, - 0.55803000000000003, - 0.388235, - 0.168126, - 0.45998800000000001, - 0.55808199999999997, - 0.39215699999999998, - 0.16661699999999999, - 0.46370800000000001, - 0.55811900000000003, - 0.39607799999999999, - 0.16511700000000001, - 0.46742299999999998, - 0.558141, - 0.40000000000000002, - 0.16362499999999999, - 0.47113300000000002, - 0.55814799999999998, - 0.403922, - 0.16214200000000001, - 0.47483799999999998, - 0.55813999999999997, - 0.40784300000000001, - 0.160665, - 0.47854000000000002, - 0.55811500000000003, - 0.41176499999999999, - 0.159194, - 0.48223700000000003, - 0.55807300000000004, - 0.415686, - 0.15772900000000001, - 0.48593199999999998, - 0.55801299999999998, - 0.41960799999999998, - 0.15626999999999999, - 0.489624, - 0.55793599999999999, - 0.42352899999999999, - 0.15481500000000001, - 0.493313, - 0.55784, - 0.42745100000000003, - 0.153364, - 0.497, - 0.557724, - 0.43137300000000001, - 0.151918, - 0.50068500000000005, - 0.55758700000000005, - 0.43529400000000001, - 0.150476, - 0.50436899999999996, - 0.55742999999999998, - 0.439216, - 0.149039, - 0.50805100000000003, - 0.55725000000000002, - 0.443137, - 0.14760699999999999, - 0.51173299999999999, - 0.55704900000000002, - 0.44705899999999998, - 0.14618, - 0.51541300000000001, - 0.55682299999999996, - 0.45097999999999999, - 0.144759, - 0.51909300000000003, - 0.55657199999999996, - 0.45490199999999997, - 0.143343, - 0.52277300000000004, - 0.55629499999999998, - 0.45882400000000001, - 0.14193500000000001, - 0.52645299999999995, - 0.55599100000000001, - 0.46274500000000002, - 0.14053599999999999, - 0.53013200000000005, - 0.55565900000000001, - 0.466667, - 0.13914699999999999, - 0.53381199999999995, - 0.55529799999999996, - 0.47058800000000001, - 0.13777, - 0.53749199999999997, - 0.55490600000000001, - 0.47450999999999999, - 0.136408, - 0.54117300000000002, - 0.55448299999999995, - 0.478431, - 0.13506599999999999, - 0.54485300000000003, - 0.55402899999999999, - 0.48235299999999998, - 0.133743, - 0.54853499999999999, - 0.55354099999999995, - 0.48627500000000001, - 0.13244400000000001, - 0.55221600000000004, - 0.55301800000000001, - 0.49019600000000002, - 0.13117200000000001, - 0.55589900000000003, - 0.55245900000000003, - 0.494118, - 0.12993299999999999, - 0.55958200000000002, - 0.55186400000000002, - 0.49803900000000001, - 0.12872900000000001, - 0.56326500000000002, - 0.55122899999999997, - 0.50196099999999999, - 0.12756799999999999, - 0.56694900000000004, - 0.55055600000000005, - 0.50588200000000005, - 0.12645300000000001, - 0.57063299999999995, - 0.54984100000000002, - 0.50980400000000003, - 0.12539400000000001, - 0.574318, - 0.54908599999999996, - 0.51372499999999999, - 0.12439500000000001, - 0.57800200000000002, - 0.54828699999999997, - 0.51764699999999997, - 0.123463, - 0.58168699999999995, - 0.54744499999999996, - 0.52156899999999995, - 0.12260600000000001, - 0.58537099999999997, - 0.54655699999999996, - 0.52549000000000001, - 0.12183099999999999, - 0.589055, - 0.54562299999999997, - 0.52941199999999999, - 0.12114800000000001, - 0.59273900000000002, - 0.54464100000000004, - 0.53333299999999995, - 0.12056500000000001, - 0.59642200000000001, - 0.54361099999999996, - 0.53725500000000004, - 0.120092, - 0.60010399999999997, - 0.54252999999999996, - 0.54117599999999999, - 0.119738, - 0.60378500000000002, - 0.54139999999999999, - 0.54509799999999997, - 0.11951199999999999, - 0.607464, - 0.54021799999999998, - 0.54901999999999995, - 0.119423, - 0.61114100000000005, - 0.53898199999999996, - 0.55294100000000002, - 0.11948300000000001, - 0.61481699999999995, - 0.53769199999999995, - 0.556863, - 0.119699, - 0.61848999999999998, - 0.53634700000000002, - 0.56078399999999995, - 0.12008099999999999, - 0.62216099999999996, - 0.53494600000000003, - 0.56470600000000004, - 0.120638, - 0.62582800000000005, - 0.53348799999999996, - 0.56862699999999999, - 0.12138, - 0.62949200000000005, - 0.53197300000000003, - 0.57254899999999997, - 0.122312, - 0.63315299999999997, - 0.53039800000000004, - 0.57647099999999996, - 0.123444, - 0.63680899999999996, - 0.52876299999999998, - 0.58039200000000002, - 0.12478, - 0.64046099999999995, - 0.52706799999999998, - 0.584314, - 0.12632599999999999, - 0.64410699999999999, - 0.52531099999999997, - 0.58823499999999995, - 0.12808700000000001, - 0.64774900000000002, - 0.52349100000000004, - 0.59215700000000004, - 0.13006699999999999, - 0.65138399999999996, - 0.52160799999999996, - 0.596078, - 0.132268, - 0.65501399999999999, - 0.51966100000000004, - 0.59999999999999998, - 0.13469200000000001, - 0.658636, - 0.51764900000000003, - 0.60392199999999996, - 0.13733899999999999, - 0.66225199999999995, - 0.515571, - 0.60784300000000002, - 0.14021, - 0.66585899999999998, - 0.51342699999999997, - 0.611765, - 0.14330300000000001, - 0.66945900000000003, - 0.51121499999999997, - 0.61568599999999996, - 0.146616, - 0.67305000000000004, - 0.50893600000000006, - 0.61960800000000005, - 0.150148, - 0.67663099999999998, - 0.50658899999999996, - 0.623529, - 0.153894, - 0.680203, - 0.50417199999999995, - 0.62745099999999998, - 0.15785099999999999, - 0.68376499999999996, - 0.50168599999999997, - 0.63137299999999996, - 0.16201599999999999, - 0.68731600000000004, - 0.49912899999999999, - 0.63529400000000003, - 0.166383, - 0.69085600000000003, - 0.496502, - 0.63921600000000001, - 0.17094799999999999, - 0.694384, - 0.49380299999999999, - 0.64313699999999996, - 0.175707, - 0.69789999999999996, - 0.491033, - 0.64705900000000005, - 0.18065300000000001, - 0.70140199999999997, - 0.48818899999999998, - 0.65098, - 0.185783, - 0.70489100000000005, - 0.48527300000000001, - 0.65490199999999998, - 0.19109000000000001, - 0.70836600000000005, - 0.48228399999999999, - 0.65882399999999997, - 0.196571, - 0.71182699999999999, - 0.47922100000000001, - 0.66274500000000003, - 0.20221900000000001, - 0.71527200000000002, - 0.47608400000000001, - 0.66666700000000001, - 0.20802999999999999, - 0.71870100000000003, - 0.47287299999999999, - 0.67058799999999996, - 0.214, - 0.72211400000000003, - 0.46958800000000001, - 0.67451000000000005, - 0.22012399999999999, - 0.72550899999999996, - 0.46622599999999997, - 0.67843100000000001, - 0.22639699999999999, - 0.72888799999999998, - 0.46278900000000001, - 0.68235299999999999, - 0.23281499999999999, - 0.73224699999999998, - 0.45927699999999999, - 0.68627499999999997, - 0.239374, - 0.73558800000000002, - 0.45568799999999998, - 0.69019600000000003, - 0.24607000000000001, - 0.73890999999999996, - 0.45202399999999998, - 0.69411800000000001, - 0.25289899999999998, - 0.74221099999999995, - 0.44828400000000002, - 0.69803899999999997, - 0.259857, - 0.74549200000000004, - 0.444467, - 0.70196099999999995, - 0.26694099999999998, - 0.74875100000000006, - 0.44057299999999999, - 0.70588200000000001, - 0.27414899999999998, - 0.75198799999999999, - 0.43660100000000002, - 0.70980399999999999, - 0.28147699999999998, - 0.75520299999999996, - 0.43255199999999999, - 0.71372500000000005, - 0.28892099999999998, - 0.75839400000000001, - 0.42842599999999997, - 0.71764700000000003, - 0.29647899999999999, - 0.76156100000000004, - 0.42422300000000002, - 0.72156900000000002, - 0.30414799999999997, - 0.76470400000000005, - 0.41994300000000001, - 0.72548999999999997, - 0.31192500000000001, - 0.767822, - 0.41558600000000001, - 0.72941199999999995, - 0.31980900000000001, - 0.77091399999999999, - 0.41115200000000002, - 0.73333300000000001, - 0.32779599999999998, - 0.77398, - 0.40664, - 0.73725499999999999, - 0.33588499999999999, - 0.77701799999999999, - 0.40204899999999999, - 0.74117599999999995, - 0.34407399999999999, - 0.78002899999999997, - 0.39738099999999998, - 0.74509800000000004, - 0.35236000000000001, - 0.78301100000000001, - 0.39263599999999999, - 0.74902000000000002, - 0.36074099999999998, - 0.785964, - 0.38781399999999999, - 0.75294099999999997, - 0.36921399999999999, - 0.78888800000000003, - 0.38291399999999998, - 0.75686299999999995, - 0.37777899999999998, - 0.79178099999999996, - 0.37793900000000002, - 0.76078400000000002, - 0.38643300000000003, - 0.79464400000000002, - 0.372886, - 0.764706, - 0.39517400000000003, - 0.79747500000000004, - 0.367757, - 0.76862699999999995, - 0.404001, - 0.80027499999999996, - 0.36255199999999999, - 0.77254900000000004, - 0.41291299999999997, - 0.803041, - 0.357269, - 0.77647100000000002, - 0.42190800000000001, - 0.80577399999999999, - 0.35191, - 0.78039199999999997, - 0.430983, - 0.808473, - 0.34647600000000001, - 0.78431399999999996, - 0.440137, - 0.81113800000000003, - 0.34096700000000002, - 0.78823500000000002, - 0.44936799999999999, - 0.81376800000000005, - 0.33538400000000002, - 0.792157, - 0.45867400000000003, - 0.81636299999999995, - 0.32972699999999999, - 0.79607799999999995, - 0.468053, - 0.81892100000000001, - 0.32399800000000001, - 0.80000000000000004, - 0.47750399999999998, - 0.82144399999999995, - 0.31819500000000001, - 0.80392200000000003, - 0.48702600000000001, - 0.82392900000000002, - 0.31232100000000002, - 0.80784299999999998, - 0.49661499999999997, - 0.826376, - 0.30637700000000001, - 0.81176499999999996, - 0.50627100000000003, - 0.82878600000000002, - 0.30036200000000002, - 0.81568600000000002, - 0.51599200000000001, - 0.83115799999999995, - 0.29427900000000001, - 0.819608, - 0.52577600000000002, - 0.83349099999999998, - 0.28812700000000002, - 0.82352899999999996, - 0.53562100000000001, - 0.835785, - 0.28190799999999999, - 0.82745100000000005, - 0.54552400000000001, - 0.83803899999999998, - 0.27562599999999998, - 0.83137300000000003, - 0.55548399999999998, - 0.84025399999999995, - 0.26928099999999999, - 0.83529399999999998, - 0.56549799999999995, - 0.84243000000000001, - 0.26287700000000003, - 0.83921599999999996, - 0.57556300000000005, - 0.84456600000000004, - 0.256415, - 0.84313700000000003, - 0.58567800000000003, - 0.846661, - 0.24989700000000001, - 0.84705900000000001, - 0.59583900000000001, - 0.84871700000000005, - 0.24332899999999999, - 0.85097999999999996, - 0.60604499999999994, - 0.85073299999999996, - 0.23671200000000001, - 0.85490200000000005, - 0.61629299999999998, - 0.85270900000000005, - 0.23005200000000001, - 0.85882400000000003, - 0.626579, - 0.85464499999999999, - 0.223353, - 0.86274499999999998, - 0.63690199999999997, - 0.85654200000000003, - 0.21662000000000001, - 0.86666699999999997, - 0.64725699999999997, - 0.85840000000000005, - 0.20986099999999999, - 0.87058800000000003, - 0.65764199999999995, - 0.86021899999999996, - 0.20308200000000001, - 0.87451000000000001, - 0.66805400000000004, - 0.86199899999999996, - 0.196293, - 0.87843099999999996, - 0.67848900000000001, - 0.86374200000000001, - 0.189503, - 0.88235300000000005, - 0.688944, - 0.865448, - 0.182725, - 0.88627500000000003, - 0.69941500000000001, - 0.86711700000000003, - 0.17597099999999999, - 0.89019599999999999, - 0.70989800000000003, - 0.86875100000000005, - 0.16925699999999999, - 0.89411799999999997, - 0.720391, - 0.87034999999999996, - 0.162603, - 0.89803900000000003, - 0.73088900000000001, - 0.87191600000000002, - 0.156029, - 0.90196100000000001, - 0.74138800000000005, - 0.87344900000000003, - 0.149561, - 0.90588199999999997, - 0.751884, - 0.87495100000000003, - 0.14322799999999999, - 0.90980399999999995, - 0.76237299999999997, - 0.87642399999999998, - 0.13706399999999999, - 0.91372500000000001, - 0.77285199999999998, - 0.87786799999999998, - 0.131109, - 0.91764699999999999, - 0.78331499999999998, - 0.87928499999999998, - 0.12540499999999999, - 0.92156899999999997, - 0.79376000000000002, - 0.88067799999999996, - 0.120005, - 0.92549000000000003, - 0.80418199999999995, - 0.882046, - 0.114965, - 0.92941200000000002, - 0.81457599999999997, - 0.88339299999999998, - 0.110347, - 0.93333299999999997, - 0.82494000000000001, - 0.88471999999999995, - 0.10621700000000001, - 0.93725499999999995, - 0.83526999999999996, - 0.88602899999999996, - 0.102646, - 0.94117600000000001, - 0.84556100000000001, - 0.88732200000000006, - 0.099701999999999999, - 0.94509799999999999, - 0.85580999999999996, - 0.88860099999999997, - 0.097451999999999997, - 0.94901999999999997, - 0.86601300000000003, - 0.88986799999999999, - 0.095952999999999997, - 0.95294100000000004, - 0.87616799999999995, - 0.89112499999999994, - 0.095250000000000001, - 0.95686300000000002, - 0.88627100000000003, - 0.892374, - 0.095374, - 0.96078399999999997, - 0.89632000000000001, - 0.89361599999999997, - 0.096335000000000004, - 0.96470599999999995, - 0.90631099999999998, - 0.89485499999999996, - 0.098125000000000004, - 0.96862700000000002, - 0.916242, - 0.89609099999999997, - 0.100717, - 0.972549, - 0.92610599999999998, - 0.89732999999999996, - 0.104071, - 0.97647099999999998, - 0.93590399999999996, - 0.89856999999999998, - 0.108131, - 0.98039200000000004, - 0.94563600000000003, - 0.89981500000000003, - 0.11283799999999999, - 0.98431400000000002, - 0.95530000000000004, - 0.901065, - 0.118128, - 0.98823499999999997, - 0.96489400000000003, - 0.90232299999999999, - 0.123941, - 0.99215699999999996, - 0.97441699999999998, - 0.90359, - 0.130215, - 0.99607800000000002, - 0.98386799999999996, - 0.90486699999999998, - 0.13689699999999999, - 1, - 0.99324800000000002, - 0.90615699999999999, - 0.14393600000000001 - ], - "Source" : "https://github.com/BIDS/colormap/blob/master/colormaps.py" - } -] - diff --git a/extern/tfn/helper.h b/extern/tfn/helper.h deleted file mode 100644 index aefbc64..0000000 --- a/extern/tfn/helper.h +++ /dev/null @@ -1,101 +0,0 @@ -// ======================================================================== // -// Copyright Qi Wu, since 2019 // -// Copyright SCI Institute, University of Utah, 2018 // -// ======================================================================== // -#pragma once - -#ifndef _USE_MATH_DEFINES -#define _USE_MATH_DEFINES -#endif -#include -#include - -namespace tfn { - -template -inline const T &clamp(const T &v, const T &lo, const T &hi) -{ - return (v < lo) ? lo : (hi < v ? hi : v); -} - -template -inline std::pair find_interval(std::vector *array, float p) -{ - p = clamp(p, 0.f, 1.f); - - typename std::vector::iterator it_lower, it_upper; - - if (array->begin()->p() > p) - return std::make_pair(0, 1); - - it_upper = std::lower_bound(array->begin(), array->end(), p, [](const T &pt, float p) { return pt.p() < p; }); - - if (it_upper == array->end()) { - it_lower = array->end() - 1; - it_upper = array->end() - 1; - } else if (it_upper == array->begin()) { - it_lower = array->begin(); - it_upper = array->begin(); - } else { - it_lower = it_upper - 1; - } - - return std::make_pair((int)std::distance(array->begin(), it_lower), (int)std::distance(array->begin(), it_upper)); -} - -inline float lerp(const float &l, const float &r, const float &pl, const float &pr, const float &p) -{ - const float dl = std::abs(pr - pl) > std::numeric_limits::epsilon() ? (p - pl) / (pr - pl) : 0.f; - const float dr = 1.f - dl; - return l * dr + r * dl; -} - -struct GaussianKernel -{ - GaussianKernel() : mean(0.5f), sigma(1.0f), height_factor(1.0f) {} - - GaussianKernel(float _mean, float _sigma, float _height_factor) : mean(_mean), sigma(_sigma), height_factor(_height_factor) {} - - float operator()(float x) const - { - float diff = x - mean; - return height_factor / (sigma * std::sqrt(2.0f * float(M_PI))) * std::exp(-(diff * diff) / (2.0f * sigma * sigma)); - } - - float get_height() const - { - return operator()(mean); - } - - void set_height(float h) - { - height_factor = h * sigma * std::sqrt(2.0f * float(M_PI)); - } - - float get_mean() const - { - return mean; - } - - void set_mean(float m) - { - mean = m; - } - - float get_sigma() const - { - return sigma; - } - - void set_sigma(float s) - { - sigma = s > 1e-4f ? s : 1e-4f; - } - - private: - float mean; - float sigma; - float height_factor; -}; - -} // namespace tfn diff --git a/extern/tfn/json.h b/extern/tfn/json.h deleted file mode 100644 index 58c7a1d..0000000 --- a/extern/tfn/json.h +++ /dev/null @@ -1,26713 +0,0 @@ -/* - __ _____ _____ _____ - __| | __| | | | JSON for Modern C++ -| | |__ | | | | | | version 3.10.4 -|_____|_____|_____|_|___| https://github.com/nlohmann/json - -Licensed under the MIT License . -SPDX-License-Identifier: MIT -Copyright (c) 2013-2019 Niels Lohmann . - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#ifndef INCLUDE_NLOHMANN_JSON_HPP_ -#define INCLUDE_NLOHMANN_JSON_HPP_ - -#define NLOHMANN_JSON_VERSION_MAJOR 3 -#define NLOHMANN_JSON_VERSION_MINOR 10 -#define NLOHMANN_JSON_VERSION_PATCH 4 - -#include // all_of, find, for_each -#include // nullptr_t, ptrdiff_t, size_t -#include // hash, less -#include // initializer_list -#ifndef JSON_NO_IO - #include // istream, ostream -#endif // JSON_NO_IO -#include // random_access_iterator_tag -#include // unique_ptr -#include // accumulate -#include // string, stoi, to_string -#include // declval, forward, move, pair, swap -#include // vector - -// #include - - -#include -#include - -// #include - - -#include // transform -#include // array -#include // forward_list -#include // inserter, front_inserter, end -#include // map -#include // string -#include // tuple, make_tuple -#include // is_arithmetic, is_same, is_enum, underlying_type, is_convertible -#include // unordered_map -#include // pair, declval -#include // valarray - -// #include - - -#include // exception -#include // runtime_error -#include // to_string -#include // vector - -// #include - - -#include // array -#include // size_t -#include // uint8_t -#include // string - -namespace nlohmann -{ -namespace detail -{ -/////////////////////////// -// JSON type enumeration // -/////////////////////////// - -/*! -@brief the JSON type enumeration - -This enumeration collects the different JSON types. It is internally used to -distinguish the stored values, and the functions @ref basic_json::is_null(), -@ref basic_json::is_object(), @ref basic_json::is_array(), -@ref basic_json::is_string(), @ref basic_json::is_boolean(), -@ref basic_json::is_number() (with @ref basic_json::is_number_integer(), -@ref basic_json::is_number_unsigned(), and @ref basic_json::is_number_float()), -@ref basic_json::is_discarded(), @ref basic_json::is_primitive(), and -@ref basic_json::is_structured() rely on it. - -@note There are three enumeration entries (number_integer, number_unsigned, and -number_float), because the library distinguishes these three types for numbers: -@ref basic_json::number_unsigned_t is used for unsigned integers, -@ref basic_json::number_integer_t is used for signed integers, and -@ref basic_json::number_float_t is used for floating-point numbers or to -approximate integers which do not fit in the limits of their respective type. - -@sa see @ref basic_json::basic_json(const value_t value_type) -- create a JSON -value with the default value for a given type - -@since version 1.0.0 -*/ -enum class value_t : std::uint8_t -{ - null, ///< null value - object, ///< object (unordered set of name/value pairs) - array, ///< array (ordered collection of values) - string, ///< string value - boolean, ///< boolean value - number_integer, ///< number value (signed integer) - number_unsigned, ///< number value (unsigned integer) - number_float, ///< number value (floating-point) - binary, ///< binary array (ordered collection of bytes) - discarded ///< discarded by the parser callback function -}; - -/*! -@brief comparison operator for JSON types - -Returns an ordering that is similar to Python: -- order: null < boolean < number < object < array < string < binary -- furthermore, each type is not smaller than itself -- discarded values are not comparable -- binary is represented as a b"" string in python and directly comparable to a - string; however, making a binary array directly comparable with a string would - be surprising behavior in a JSON file. - -@since version 1.0.0 -*/ -inline bool operator<(const value_t lhs, const value_t rhs) noexcept -{ - static constexpr std::array order = {{ - 0 /* null */, 3 /* object */, 4 /* array */, 5 /* string */, - 1 /* boolean */, 2 /* integer */, 2 /* unsigned */, 2 /* float */, - 6 /* binary */ - } - }; - - const auto l_index = static_cast(lhs); - const auto r_index = static_cast(rhs); - return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index]; -} -} // namespace detail -} // namespace nlohmann - -// #include - - -#include -// #include - - -#include // declval, pair -// #include - - -/* Hedley - https://nemequ.github.io/hedley - * Created by Evan Nemerson - * - * To the extent possible under law, the author(s) have dedicated all - * copyright and related and neighboring rights to this software to - * the public domain worldwide. This software is distributed without - * any warranty. - * - * For details, see . - * SPDX-License-Identifier: CC0-1.0 - */ - -#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15) -#if defined(JSON_HEDLEY_VERSION) - #undef JSON_HEDLEY_VERSION -#endif -#define JSON_HEDLEY_VERSION 15 - -#if defined(JSON_HEDLEY_STRINGIFY_EX) - #undef JSON_HEDLEY_STRINGIFY_EX -#endif -#define JSON_HEDLEY_STRINGIFY_EX(x) #x - -#if defined(JSON_HEDLEY_STRINGIFY) - #undef JSON_HEDLEY_STRINGIFY -#endif -#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x) - -#if defined(JSON_HEDLEY_CONCAT_EX) - #undef JSON_HEDLEY_CONCAT_EX -#endif -#define JSON_HEDLEY_CONCAT_EX(a,b) a##b - -#if defined(JSON_HEDLEY_CONCAT) - #undef JSON_HEDLEY_CONCAT -#endif -#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b) - -#if defined(JSON_HEDLEY_CONCAT3_EX) - #undef JSON_HEDLEY_CONCAT3_EX -#endif -#define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c - -#if defined(JSON_HEDLEY_CONCAT3) - #undef JSON_HEDLEY_CONCAT3 -#endif -#define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c) - -#if defined(JSON_HEDLEY_VERSION_ENCODE) - #undef JSON_HEDLEY_VERSION_ENCODE -#endif -#define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision)) - -#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR) - #undef JSON_HEDLEY_VERSION_DECODE_MAJOR -#endif -#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000) - -#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR) - #undef JSON_HEDLEY_VERSION_DECODE_MINOR -#endif -#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000) - -#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION) - #undef JSON_HEDLEY_VERSION_DECODE_REVISION -#endif -#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000) - -#if defined(JSON_HEDLEY_GNUC_VERSION) - #undef JSON_HEDLEY_GNUC_VERSION -#endif -#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__) - #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) -#elif defined(__GNUC__) - #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0) -#endif - -#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK) - #undef JSON_HEDLEY_GNUC_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_GNUC_VERSION) - #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_MSVC_VERSION) - #undef JSON_HEDLEY_MSVC_VERSION -#endif -#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL) - #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100) -#elif defined(_MSC_FULL_VER) && !defined(__ICL) - #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10) -#elif defined(_MSC_VER) && !defined(__ICL) - #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0) -#endif - -#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK) - #undef JSON_HEDLEY_MSVC_VERSION_CHECK -#endif -#if !defined(JSON_HEDLEY_MSVC_VERSION) - #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0) -#elif defined(_MSC_VER) && (_MSC_VER >= 1400) - #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch))) -#elif defined(_MSC_VER) && (_MSC_VER >= 1200) - #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch))) -#else - #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor))) -#endif - -#if defined(JSON_HEDLEY_INTEL_VERSION) - #undef JSON_HEDLEY_INTEL_VERSION -#endif -#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL) - #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE) -#elif defined(__INTEL_COMPILER) && !defined(__ICL) - #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0) -#endif - -#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK) - #undef JSON_HEDLEY_INTEL_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_INTEL_VERSION) - #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_INTEL_CL_VERSION) - #undef JSON_HEDLEY_INTEL_CL_VERSION -#endif -#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL) - #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0) -#endif - -#if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK) - #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_INTEL_CL_VERSION) - #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_PGI_VERSION) - #undef JSON_HEDLEY_PGI_VERSION -#endif -#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__) - #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__) -#endif - -#if defined(JSON_HEDLEY_PGI_VERSION_CHECK) - #undef JSON_HEDLEY_PGI_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_PGI_VERSION) - #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_SUNPRO_VERSION) - #undef JSON_HEDLEY_SUNPRO_VERSION -#endif -#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000) - #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10) -#elif defined(__SUNPRO_C) - #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf) -#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000) - #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10) -#elif defined(__SUNPRO_CC) - #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf) -#endif - -#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK) - #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_SUNPRO_VERSION) - #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION) - #undef JSON_HEDLEY_EMSCRIPTEN_VERSION -#endif -#if defined(__EMSCRIPTEN__) - #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__) -#endif - -#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK) - #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION) - #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_ARM_VERSION) - #undef JSON_HEDLEY_ARM_VERSION -#endif -#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION) - #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100) -#elif defined(__CC_ARM) && defined(__ARMCC_VERSION) - #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100) -#endif - -#if defined(JSON_HEDLEY_ARM_VERSION_CHECK) - #undef JSON_HEDLEY_ARM_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_ARM_VERSION) - #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_IBM_VERSION) - #undef JSON_HEDLEY_IBM_VERSION -#endif -#if defined(__ibmxl__) - #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__) -#elif defined(__xlC__) && defined(__xlC_ver__) - #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff) -#elif defined(__xlC__) - #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0) -#endif - -#if defined(JSON_HEDLEY_IBM_VERSION_CHECK) - #undef JSON_HEDLEY_IBM_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_IBM_VERSION) - #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_VERSION) - #undef JSON_HEDLEY_TI_VERSION -#endif -#if \ - defined(__TI_COMPILER_VERSION__) && \ - ( \ - defined(__TMS470__) || defined(__TI_ARM__) || \ - defined(__MSP430__) || \ - defined(__TMS320C2000__) \ - ) -#if (__TI_COMPILER_VERSION__ >= 16000000) - #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif -#endif - -#if defined(JSON_HEDLEY_TI_VERSION_CHECK) - #undef JSON_HEDLEY_TI_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_VERSION) - #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_CL2000_VERSION) - #undef JSON_HEDLEY_TI_CL2000_VERSION -#endif -#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__) - #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif - -#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK) - #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_CL2000_VERSION) - #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_CL430_VERSION) - #undef JSON_HEDLEY_TI_CL430_VERSION -#endif -#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__) - #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif - -#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK) - #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_CL430_VERSION) - #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_ARMCL_VERSION) - #undef JSON_HEDLEY_TI_ARMCL_VERSION -#endif -#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__)) - #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif - -#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK) - #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_ARMCL_VERSION) - #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_CL6X_VERSION) - #undef JSON_HEDLEY_TI_CL6X_VERSION -#endif -#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__) - #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif - -#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK) - #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_CL6X_VERSION) - #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_CL7X_VERSION) - #undef JSON_HEDLEY_TI_CL7X_VERSION -#endif -#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__) - #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif - -#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK) - #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_CL7X_VERSION) - #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_CLPRU_VERSION) - #undef JSON_HEDLEY_TI_CLPRU_VERSION -#endif -#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__) - #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif - -#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK) - #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_CLPRU_VERSION) - #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_CRAY_VERSION) - #undef JSON_HEDLEY_CRAY_VERSION -#endif -#if defined(_CRAYC) - #if defined(_RELEASE_PATCHLEVEL) - #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL) - #else - #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0) - #endif -#endif - -#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK) - #undef JSON_HEDLEY_CRAY_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_CRAY_VERSION) - #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_IAR_VERSION) - #undef JSON_HEDLEY_IAR_VERSION -#endif -#if defined(__IAR_SYSTEMS_ICC__) - #if __VER__ > 1000 - #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000)) - #else - #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0) - #endif -#endif - -#if defined(JSON_HEDLEY_IAR_VERSION_CHECK) - #undef JSON_HEDLEY_IAR_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_IAR_VERSION) - #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TINYC_VERSION) - #undef JSON_HEDLEY_TINYC_VERSION -#endif -#if defined(__TINYC__) - #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100) -#endif - -#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK) - #undef JSON_HEDLEY_TINYC_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TINYC_VERSION) - #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_DMC_VERSION) - #undef JSON_HEDLEY_DMC_VERSION -#endif -#if defined(__DMC__) - #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf) -#endif - -#if defined(JSON_HEDLEY_DMC_VERSION_CHECK) - #undef JSON_HEDLEY_DMC_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_DMC_VERSION) - #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_COMPCERT_VERSION) - #undef JSON_HEDLEY_COMPCERT_VERSION -#endif -#if defined(__COMPCERT_VERSION__) - #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100) -#endif - -#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK) - #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_COMPCERT_VERSION) - #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_PELLES_VERSION) - #undef JSON_HEDLEY_PELLES_VERSION -#endif -#if defined(__POCC__) - #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0) -#endif - -#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK) - #undef JSON_HEDLEY_PELLES_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_PELLES_VERSION) - #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_MCST_LCC_VERSION) - #undef JSON_HEDLEY_MCST_LCC_VERSION -#endif -#if defined(__LCC__) && defined(__LCC_MINOR__) - #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__) -#endif - -#if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK) - #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_MCST_LCC_VERSION) - #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_GCC_VERSION) - #undef JSON_HEDLEY_GCC_VERSION -#endif -#if \ - defined(JSON_HEDLEY_GNUC_VERSION) && \ - !defined(__clang__) && \ - !defined(JSON_HEDLEY_INTEL_VERSION) && \ - !defined(JSON_HEDLEY_PGI_VERSION) && \ - !defined(JSON_HEDLEY_ARM_VERSION) && \ - !defined(JSON_HEDLEY_CRAY_VERSION) && \ - !defined(JSON_HEDLEY_TI_VERSION) && \ - !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \ - !defined(JSON_HEDLEY_TI_CL430_VERSION) && \ - !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \ - !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \ - !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \ - !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \ - !defined(__COMPCERT__) && \ - !defined(JSON_HEDLEY_MCST_LCC_VERSION) - #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION -#endif - -#if defined(JSON_HEDLEY_GCC_VERSION_CHECK) - #undef JSON_HEDLEY_GCC_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_GCC_VERSION) - #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_HAS_ATTRIBUTE) - #undef JSON_HEDLEY_HAS_ATTRIBUTE -#endif -#if \ - defined(__has_attribute) && \ - ( \ - (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \ - ) -# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute) -#else -# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE) - #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE -#endif -#if defined(__has_attribute) - #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) -#else - #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE) - #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE -#endif -#if defined(__has_attribute) - #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) -#else - #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE) - #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE -#endif -#if \ - defined(__has_cpp_attribute) && \ - defined(__cplusplus) && \ - (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) - #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute) -#else - #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0) -#endif - -#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS) - #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS -#endif -#if !defined(__cplusplus) || !defined(__has_cpp_attribute) - #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0) -#elif \ - !defined(JSON_HEDLEY_PGI_VERSION) && \ - !defined(JSON_HEDLEY_IAR_VERSION) && \ - (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \ - (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0)) - #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute) -#else - #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE) - #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE -#endif -#if defined(__has_cpp_attribute) && defined(__cplusplus) - #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) -#else - #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE) - #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE -#endif -#if defined(__has_cpp_attribute) && defined(__cplusplus) - #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) -#else - #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_HAS_BUILTIN) - #undef JSON_HEDLEY_HAS_BUILTIN -#endif -#if defined(__has_builtin) - #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin) -#else - #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN) - #undef JSON_HEDLEY_GNUC_HAS_BUILTIN -#endif -#if defined(__has_builtin) - #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) -#else - #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN) - #undef JSON_HEDLEY_GCC_HAS_BUILTIN -#endif -#if defined(__has_builtin) - #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) -#else - #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_HAS_FEATURE) - #undef JSON_HEDLEY_HAS_FEATURE -#endif -#if defined(__has_feature) - #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature) -#else - #define JSON_HEDLEY_HAS_FEATURE(feature) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE) - #undef JSON_HEDLEY_GNUC_HAS_FEATURE -#endif -#if defined(__has_feature) - #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) -#else - #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_FEATURE) - #undef JSON_HEDLEY_GCC_HAS_FEATURE -#endif -#if defined(__has_feature) - #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) -#else - #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_HAS_EXTENSION) - #undef JSON_HEDLEY_HAS_EXTENSION -#endif -#if defined(__has_extension) - #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension) -#else - #define JSON_HEDLEY_HAS_EXTENSION(extension) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION) - #undef JSON_HEDLEY_GNUC_HAS_EXTENSION -#endif -#if defined(__has_extension) - #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) -#else - #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION) - #undef JSON_HEDLEY_GCC_HAS_EXTENSION -#endif -#if defined(__has_extension) - #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) -#else - #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE) - #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE -#endif -#if defined(__has_declspec_attribute) - #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute) -#else - #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE) - #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE -#endif -#if defined(__has_declspec_attribute) - #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) -#else - #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE) - #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE -#endif -#if defined(__has_declspec_attribute) - #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) -#else - #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_HAS_WARNING) - #undef JSON_HEDLEY_HAS_WARNING -#endif -#if defined(__has_warning) - #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning) -#else - #define JSON_HEDLEY_HAS_WARNING(warning) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_WARNING) - #undef JSON_HEDLEY_GNUC_HAS_WARNING -#endif -#if defined(__has_warning) - #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) -#else - #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_WARNING) - #undef JSON_HEDLEY_GCC_HAS_WARNING -#endif -#if defined(__has_warning) - #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) -#else - #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if \ - (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ - defined(__clang__) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \ - JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \ - (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR)) - #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value) -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define JSON_HEDLEY_PRAGMA(value) __pragma(value) -#else - #define JSON_HEDLEY_PRAGMA(value) -#endif - -#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH) - #undef JSON_HEDLEY_DIAGNOSTIC_PUSH -#endif -#if defined(JSON_HEDLEY_DIAGNOSTIC_POP) - #undef JSON_HEDLEY_DIAGNOSTIC_POP -#endif -#if defined(__clang__) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") -#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") -#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push)) - #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop)) -#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop") -#elif \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") -#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") -#else - #define JSON_HEDLEY_DIAGNOSTIC_PUSH - #define JSON_HEDLEY_DIAGNOSTIC_POP -#endif - -/* JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ is for - HEDLEY INTERNAL USE ONLY. API subject to change without notice. */ -#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_) - #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ -#endif -#if defined(__cplusplus) -# if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat") -# if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions") -# if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions") -# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ - _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ - _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \ - xpr \ - JSON_HEDLEY_DIAGNOSTIC_POP -# else -# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ - _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ - xpr \ - JSON_HEDLEY_DIAGNOSTIC_POP -# endif -# else -# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ - xpr \ - JSON_HEDLEY_DIAGNOSTIC_POP -# endif -# endif -#endif -#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x -#endif - -#if defined(JSON_HEDLEY_CONST_CAST) - #undef JSON_HEDLEY_CONST_CAST -#endif -#if defined(__cplusplus) -# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast(expr)) -#elif \ - JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) -# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \ - ((T) (expr)); \ - JSON_HEDLEY_DIAGNOSTIC_POP \ - })) -#else -# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr)) -#endif - -#if defined(JSON_HEDLEY_REINTERPRET_CAST) - #undef JSON_HEDLEY_REINTERPRET_CAST -#endif -#if defined(__cplusplus) - #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast(expr)) -#else - #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr)) -#endif - -#if defined(JSON_HEDLEY_STATIC_CAST) - #undef JSON_HEDLEY_STATIC_CAST -#endif -#if defined(__cplusplus) - #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast(expr)) -#else - #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr)) -#endif - -#if defined(JSON_HEDLEY_CPP_CAST) - #undef JSON_HEDLEY_CPP_CAST -#endif -#if defined(__cplusplus) -# if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast") -# define JSON_HEDLEY_CPP_CAST(T, expr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \ - ((T) (expr)) \ - JSON_HEDLEY_DIAGNOSTIC_POP -# elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0) -# define JSON_HEDLEY_CPP_CAST(T, expr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("diag_suppress=Pe137") \ - JSON_HEDLEY_DIAGNOSTIC_POP -# else -# define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr)) -# endif -#else -# define JSON_HEDLEY_CPP_CAST(T, expr) (expr) -#endif - -#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED) - #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations") - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") -#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)") -#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786)) -#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445") -#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") -#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996)) -#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") -#elif \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718") -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)") -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)") -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215") -#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)") -#else - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED -#endif - -#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS) - #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") -#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)") -#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161)) -#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675") -#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"") -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068)) -#elif \ - JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") -#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161") -#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161") -#else - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS -#endif - -#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES) - #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes") - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"") -#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") -#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)") -#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292)) -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030)) -#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098") -#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097") -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)") -#elif \ - JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173") -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097") -#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097") -#else - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES -#endif - -#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL) - #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wcast-qual") - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"") -#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)") -#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") -#else - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL -#endif - -#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION) - #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wunused-function") - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"") -#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"") -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505)) -#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142") -#else - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION -#endif - -#if defined(JSON_HEDLEY_DEPRECATED) - #undef JSON_HEDLEY_DEPRECATED -#endif -#if defined(JSON_HEDLEY_DEPRECATED_FOR) - #undef JSON_HEDLEY_DEPRECATED_FOR -#endif -#if \ - JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since)) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement)) -#elif \ - (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) -#elif defined(__cplusplus) && (__cplusplus >= 201402L) - #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]]) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]]) -#elif \ - JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) - #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__)) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__)) -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated) -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated") - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated") -#else - #define JSON_HEDLEY_DEPRECATED(since) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) -#endif - -#if defined(JSON_HEDLEY_UNAVAILABLE) - #undef JSON_HEDLEY_UNAVAILABLE -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since))) -#else - #define JSON_HEDLEY_UNAVAILABLE(available_since) -#endif - -#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT) - #undef JSON_HEDLEY_WARN_UNUSED_RESULT -#endif -#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG) - #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) - #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__)) -#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L) - #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) - #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]]) -#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) - #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) - #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) -#elif defined(_Check_return_) /* SAL */ - #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_ - #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_ -#else - #define JSON_HEDLEY_WARN_UNUSED_RESULT - #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) -#endif - -#if defined(JSON_HEDLEY_SENTINEL) - #undef JSON_HEDLEY_SENTINEL -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position))) -#else - #define JSON_HEDLEY_SENTINEL(position) -#endif - -#if defined(JSON_HEDLEY_NO_RETURN) - #undef JSON_HEDLEY_NO_RETURN -#endif -#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_NO_RETURN __noreturn -#elif \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) -#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - #define JSON_HEDLEY_NO_RETURN _Noreturn -#elif defined(__cplusplus) && (__cplusplus >= 201103L) - #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]]) -#elif \ - JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) - #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) - #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return") -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) -#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus) - #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;") -#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) - #define JSON_HEDLEY_NO_RETURN __attribute((noreturn)) -#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) - #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) -#else - #define JSON_HEDLEY_NO_RETURN -#endif - -#if defined(JSON_HEDLEY_NO_ESCAPE) - #undef JSON_HEDLEY_NO_ESCAPE -#endif -#if JSON_HEDLEY_HAS_ATTRIBUTE(noescape) - #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__)) -#else - #define JSON_HEDLEY_NO_ESCAPE -#endif - -#if defined(JSON_HEDLEY_UNREACHABLE) - #undef JSON_HEDLEY_UNREACHABLE -#endif -#if defined(JSON_HEDLEY_UNREACHABLE_RETURN) - #undef JSON_HEDLEY_UNREACHABLE_RETURN -#endif -#if defined(JSON_HEDLEY_ASSUME) - #undef JSON_HEDLEY_ASSUME -#endif -#if \ - JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_ASSUME(expr) __assume(expr) -#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume) - #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr) -#elif \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) - #if defined(__cplusplus) - #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr) - #else - #define JSON_HEDLEY_ASSUME(expr) _nassert(expr) - #endif -#endif -#if \ - (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable() -#elif defined(JSON_HEDLEY_ASSUME) - #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0) -#endif -#if !defined(JSON_HEDLEY_ASSUME) - #if defined(JSON_HEDLEY_UNREACHABLE) - #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1))) - #else - #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr) - #endif -#endif -#if defined(JSON_HEDLEY_UNREACHABLE) - #if \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) - #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value)) - #else - #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE() - #endif -#else - #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value) -#endif -#if !defined(JSON_HEDLEY_UNREACHABLE) - #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0) -#endif - -JSON_HEDLEY_DIAGNOSTIC_PUSH -#if JSON_HEDLEY_HAS_WARNING("-Wpedantic") - #pragma clang diagnostic ignored "-Wpedantic" -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus) - #pragma clang diagnostic ignored "-Wc++98-compat-pedantic" -#endif -#if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0) - #if defined(__clang__) - #pragma clang diagnostic ignored "-Wvariadic-macros" - #elif defined(JSON_HEDLEY_GCC_VERSION) - #pragma GCC diagnostic ignored "-Wvariadic-macros" - #endif -#endif -#if defined(JSON_HEDLEY_NON_NULL) - #undef JSON_HEDLEY_NON_NULL -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) - #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__))) -#else - #define JSON_HEDLEY_NON_NULL(...) -#endif -JSON_HEDLEY_DIAGNOSTIC_POP - -#if defined(JSON_HEDLEY_PRINTF_FORMAT) - #undef JSON_HEDLEY_PRINTF_FORMAT -#endif -#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO) - #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check))) -#elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO) - #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check))) -#elif \ - JSON_HEDLEY_HAS_ATTRIBUTE(format) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check))) -#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0) - #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check)) -#else - #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) -#endif - -#if defined(JSON_HEDLEY_CONSTEXPR) - #undef JSON_HEDLEY_CONSTEXPR -#endif -#if defined(__cplusplus) - #if __cplusplus >= 201103L - #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr) - #endif -#endif -#if !defined(JSON_HEDLEY_CONSTEXPR) - #define JSON_HEDLEY_CONSTEXPR -#endif - -#if defined(JSON_HEDLEY_PREDICT) - #undef JSON_HEDLEY_PREDICT -#endif -#if defined(JSON_HEDLEY_LIKELY) - #undef JSON_HEDLEY_LIKELY -#endif -#if defined(JSON_HEDLEY_UNLIKELY) - #undef JSON_HEDLEY_UNLIKELY -#endif -#if defined(JSON_HEDLEY_UNPREDICTABLE) - #undef JSON_HEDLEY_UNPREDICTABLE -#endif -#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable) - #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr)) -#endif -#if \ - (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) -# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability)) -# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability)) -# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability)) -# define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 ) -# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 ) -#elif \ - (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) -# define JSON_HEDLEY_PREDICT(expr, expected, probability) \ - (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))) -# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \ - (__extension__ ({ \ - double hedley_probability_ = (probability); \ - ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \ - })) -# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \ - (__extension__ ({ \ - double hedley_probability_ = (probability); \ - ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \ - })) -# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) -# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) -#else -# define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)) -# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr)) -# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr)) -# define JSON_HEDLEY_LIKELY(expr) (!!(expr)) -# define JSON_HEDLEY_UNLIKELY(expr) (!!(expr)) -#endif -#if !defined(JSON_HEDLEY_UNPREDICTABLE) - #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5) -#endif - -#if defined(JSON_HEDLEY_MALLOC) - #undef JSON_HEDLEY_MALLOC -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_MALLOC __attribute__((__malloc__)) -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) - #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory") -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_MALLOC __declspec(restrict) -#else - #define JSON_HEDLEY_MALLOC -#endif - -#if defined(JSON_HEDLEY_PURE) - #undef JSON_HEDLEY_PURE -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) -# define JSON_HEDLEY_PURE __attribute__((__pure__)) -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) -# define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data") -#elif defined(__cplusplus) && \ - ( \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \ - ) -# define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;") -#else -# define JSON_HEDLEY_PURE -#endif - -#if defined(JSON_HEDLEY_CONST) - #undef JSON_HEDLEY_CONST -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(const) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_CONST __attribute__((__const__)) -#elif \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) - #define JSON_HEDLEY_CONST _Pragma("no_side_effect") -#else - #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE -#endif - -#if defined(JSON_HEDLEY_RESTRICT) - #undef JSON_HEDLEY_RESTRICT -#endif -#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus) - #define JSON_HEDLEY_RESTRICT restrict -#elif \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ - defined(__clang__) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_RESTRICT __restrict -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus) - #define JSON_HEDLEY_RESTRICT _Restrict -#else - #define JSON_HEDLEY_RESTRICT -#endif - -#if defined(JSON_HEDLEY_INLINE) - #undef JSON_HEDLEY_INLINE -#endif -#if \ - (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ - (defined(__cplusplus) && (__cplusplus >= 199711L)) - #define JSON_HEDLEY_INLINE inline -#elif \ - defined(JSON_HEDLEY_GCC_VERSION) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0) - #define JSON_HEDLEY_INLINE __inline__ -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_INLINE __inline -#else - #define JSON_HEDLEY_INLINE -#endif - -#if defined(JSON_HEDLEY_ALWAYS_INLINE) - #undef JSON_HEDLEY_ALWAYS_INLINE -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) -# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) -# define JSON_HEDLEY_ALWAYS_INLINE __forceinline -#elif defined(__cplusplus) && \ - ( \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \ - ) -# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;") -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) -# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced") -#else -# define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE -#endif - -#if defined(JSON_HEDLEY_NEVER_INLINE) - #undef JSON_HEDLEY_NEVER_INLINE -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) - #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__)) -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) -#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0) - #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline") -#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus) - #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;") -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never") -#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) - #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline)) -#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) - #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) -#else - #define JSON_HEDLEY_NEVER_INLINE -#endif - -#if defined(JSON_HEDLEY_PRIVATE) - #undef JSON_HEDLEY_PRIVATE -#endif -#if defined(JSON_HEDLEY_PUBLIC) - #undef JSON_HEDLEY_PUBLIC -#endif -#if defined(JSON_HEDLEY_IMPORT) - #undef JSON_HEDLEY_IMPORT -#endif -#if defined(_WIN32) || defined(__CYGWIN__) -# define JSON_HEDLEY_PRIVATE -# define JSON_HEDLEY_PUBLIC __declspec(dllexport) -# define JSON_HEDLEY_IMPORT __declspec(dllimport) -#else -# if \ - JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ - ( \ - defined(__TI_EABI__) && \ - ( \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \ - ) \ - ) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) -# define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden"))) -# define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default"))) -# else -# define JSON_HEDLEY_PRIVATE -# define JSON_HEDLEY_PUBLIC -# endif -# define JSON_HEDLEY_IMPORT extern -#endif - -#if defined(JSON_HEDLEY_NO_THROW) - #undef JSON_HEDLEY_NO_THROW -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__)) -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) - #define JSON_HEDLEY_NO_THROW __declspec(nothrow) -#else - #define JSON_HEDLEY_NO_THROW -#endif - -#if defined(JSON_HEDLEY_FALL_THROUGH) - #undef JSON_HEDLEY_FALL_THROUGH -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) -#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough) - #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]]) -#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough) - #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]]) -#elif defined(__fallthrough) /* SAL */ - #define JSON_HEDLEY_FALL_THROUGH __fallthrough -#else - #define JSON_HEDLEY_FALL_THROUGH -#endif - -#if defined(JSON_HEDLEY_RETURNS_NON_NULL) - #undef JSON_HEDLEY_RETURNS_NON_NULL -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__)) -#elif defined(_Ret_notnull_) /* SAL */ - #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_ -#else - #define JSON_HEDLEY_RETURNS_NON_NULL -#endif - -#if defined(JSON_HEDLEY_ARRAY_PARAM) - #undef JSON_HEDLEY_ARRAY_PARAM -#endif -#if \ - defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ - !defined(__STDC_NO_VLA__) && \ - !defined(__cplusplus) && \ - !defined(JSON_HEDLEY_PGI_VERSION) && \ - !defined(JSON_HEDLEY_TINYC_VERSION) - #define JSON_HEDLEY_ARRAY_PARAM(name) (name) -#else - #define JSON_HEDLEY_ARRAY_PARAM(name) -#endif - -#if defined(JSON_HEDLEY_IS_CONSTANT) - #undef JSON_HEDLEY_IS_CONSTANT -#endif -#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR) - #undef JSON_HEDLEY_REQUIRE_CONSTEXPR -#endif -/* JSON_HEDLEY_IS_CONSTEXPR_ is for - HEDLEY INTERNAL USE ONLY. API subject to change without notice. */ -#if defined(JSON_HEDLEY_IS_CONSTEXPR_) - #undef JSON_HEDLEY_IS_CONSTEXPR_ -#endif -#if \ - JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ - (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr) -#endif -#if !defined(__cplusplus) -# if \ - JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ - JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24) -#if defined(__INTPTR_TYPE__) - #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*) -#else - #include - #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*) -#endif -# elif \ - ( \ - defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \ - !defined(JSON_HEDLEY_SUNPRO_VERSION) && \ - !defined(JSON_HEDLEY_PGI_VERSION) && \ - !defined(JSON_HEDLEY_IAR_VERSION)) || \ - (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0) -#if defined(__INTPTR_TYPE__) - #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0) -#else - #include - #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0) -#endif -# elif \ - defined(JSON_HEDLEY_GCC_VERSION) || \ - defined(JSON_HEDLEY_INTEL_VERSION) || \ - defined(JSON_HEDLEY_TINYC_VERSION) || \ - defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \ - defined(JSON_HEDLEY_TI_CL2000_VERSION) || \ - defined(JSON_HEDLEY_TI_CL6X_VERSION) || \ - defined(JSON_HEDLEY_TI_CL7X_VERSION) || \ - defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \ - defined(__clang__) -# define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \ - sizeof(void) != \ - sizeof(*( \ - 1 ? \ - ((void*) ((expr) * 0L) ) : \ -((struct { char v[sizeof(void) * 2]; } *) 1) \ - ) \ - ) \ - ) -# endif -#endif -#if defined(JSON_HEDLEY_IS_CONSTEXPR_) - #if !defined(JSON_HEDLEY_IS_CONSTANT) - #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr) - #endif - #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1)) -#else - #if !defined(JSON_HEDLEY_IS_CONSTANT) - #define JSON_HEDLEY_IS_CONSTANT(expr) (0) - #endif - #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr) -#endif - -#if defined(JSON_HEDLEY_BEGIN_C_DECLS) - #undef JSON_HEDLEY_BEGIN_C_DECLS -#endif -#if defined(JSON_HEDLEY_END_C_DECLS) - #undef JSON_HEDLEY_END_C_DECLS -#endif -#if defined(JSON_HEDLEY_C_DECL) - #undef JSON_HEDLEY_C_DECL -#endif -#if defined(__cplusplus) - #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" { - #define JSON_HEDLEY_END_C_DECLS } - #define JSON_HEDLEY_C_DECL extern "C" -#else - #define JSON_HEDLEY_BEGIN_C_DECLS - #define JSON_HEDLEY_END_C_DECLS - #define JSON_HEDLEY_C_DECL -#endif - -#if defined(JSON_HEDLEY_STATIC_ASSERT) - #undef JSON_HEDLEY_STATIC_ASSERT -#endif -#if \ - !defined(__cplusplus) && ( \ - (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \ - (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - defined(_Static_assert) \ - ) -# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message) -#elif \ - (defined(__cplusplus) && (__cplusplus >= 201103L)) || \ - JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) -# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message)) -#else -# define JSON_HEDLEY_STATIC_ASSERT(expr, message) -#endif - -#if defined(JSON_HEDLEY_NULL) - #undef JSON_HEDLEY_NULL -#endif -#if defined(__cplusplus) - #if __cplusplus >= 201103L - #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr) - #elif defined(NULL) - #define JSON_HEDLEY_NULL NULL - #else - #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0) - #endif -#elif defined(NULL) - #define JSON_HEDLEY_NULL NULL -#else - #define JSON_HEDLEY_NULL ((void*) 0) -#endif - -#if defined(JSON_HEDLEY_MESSAGE) - #undef JSON_HEDLEY_MESSAGE -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") -# define JSON_HEDLEY_MESSAGE(msg) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ - JSON_HEDLEY_PRAGMA(message msg) \ - JSON_HEDLEY_DIAGNOSTIC_POP -#elif \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) -# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg) -#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) -# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg) -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) -# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg)) -#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0) -# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg)) -#else -# define JSON_HEDLEY_MESSAGE(msg) -#endif - -#if defined(JSON_HEDLEY_WARNING) - #undef JSON_HEDLEY_WARNING -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") -# define JSON_HEDLEY_WARNING(msg) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ - JSON_HEDLEY_PRAGMA(clang warning msg) \ - JSON_HEDLEY_DIAGNOSTIC_POP -#elif \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) -# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg) -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) -# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg)) -#else -# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg) -#endif - -#if defined(JSON_HEDLEY_REQUIRE) - #undef JSON_HEDLEY_REQUIRE -#endif -#if defined(JSON_HEDLEY_REQUIRE_MSG) - #undef JSON_HEDLEY_REQUIRE_MSG -#endif -#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if) -# if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat") -# define JSON_HEDLEY_REQUIRE(expr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ - __attribute__((diagnose_if(!(expr), #expr, "error"))) \ - JSON_HEDLEY_DIAGNOSTIC_POP -# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ - __attribute__((diagnose_if(!(expr), msg, "error"))) \ - JSON_HEDLEY_DIAGNOSTIC_POP -# else -# define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error"))) -# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error"))) -# endif -#else -# define JSON_HEDLEY_REQUIRE(expr) -# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) -#endif - -#if defined(JSON_HEDLEY_FLAGS) - #undef JSON_HEDLEY_FLAGS -#endif -#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion")) - #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__)) -#else - #define JSON_HEDLEY_FLAGS -#endif - -#if defined(JSON_HEDLEY_FLAGS_CAST) - #undef JSON_HEDLEY_FLAGS_CAST -#endif -#if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0) -# define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("warning(disable:188)") \ - ((T) (expr)); \ - JSON_HEDLEY_DIAGNOSTIC_POP \ - })) -#else -# define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr) -#endif - -#if defined(JSON_HEDLEY_EMPTY_BASES) - #undef JSON_HEDLEY_EMPTY_BASES -#endif -#if \ - (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases) -#else - #define JSON_HEDLEY_EMPTY_BASES -#endif - -/* Remaining macros are deprecated. */ - -#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK) - #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK -#endif -#if defined(__clang__) - #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0) -#else - #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE) - #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE -#endif -#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) - -#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE) - #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE -#endif -#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) - -#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN) - #undef JSON_HEDLEY_CLANG_HAS_BUILTIN -#endif -#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin) - -#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE) - #undef JSON_HEDLEY_CLANG_HAS_FEATURE -#endif -#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature) - -#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION) - #undef JSON_HEDLEY_CLANG_HAS_EXTENSION -#endif -#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension) - -#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE) - #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE -#endif -#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) - -#if defined(JSON_HEDLEY_CLANG_HAS_WARNING) - #undef JSON_HEDLEY_CLANG_HAS_WARNING -#endif -#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning) - -#endif /* !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < X) */ - -// #include - - -#include - -// #include - - -namespace nlohmann -{ -namespace detail -{ -template struct make_void -{ - using type = void; -}; -template using void_t = typename make_void::type; -} // namespace detail -} // namespace nlohmann - - -// https://en.cppreference.com/w/cpp/experimental/is_detected -namespace nlohmann -{ -namespace detail -{ -struct nonesuch -{ - nonesuch() = delete; - ~nonesuch() = delete; - nonesuch(nonesuch const&) = delete; - nonesuch(nonesuch const&&) = delete; - void operator=(nonesuch const&) = delete; - void operator=(nonesuch&&) = delete; -}; - -template class Op, - class... Args> -struct detector -{ - using value_t = std::false_type; - using type = Default; -}; - -template class Op, class... Args> -struct detector>, Op, Args...> -{ - using value_t = std::true_type; - using type = Op; -}; - -template class Op, class... Args> -using is_detected = typename detector::value_t; - -template class Op, class... Args> -struct is_detected_lazy : is_detected { }; - -template class Op, class... Args> -using detected_t = typename detector::type; - -template class Op, class... Args> -using detected_or = detector; - -template class Op, class... Args> -using detected_or_t = typename detected_or::type; - -template class Op, class... Args> -using is_detected_exact = std::is_same>; - -template class Op, class... Args> -using is_detected_convertible = - std::is_convertible, To>; -} // namespace detail -} // namespace nlohmann - - -// This file contains all internal macro definitions -// You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them - -// exclude unsupported compilers -#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK) - #if defined(__clang__) - #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400 - #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers" - #endif - #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER)) - #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800 - #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers" - #endif - #endif -#endif - -// C++ language standard detection -// if the user manually specified the used c++ version this is skipped -#if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11) - #if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) - #define JSON_HAS_CPP_20 - #define JSON_HAS_CPP_17 - #define JSON_HAS_CPP_14 - #elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 - #define JSON_HAS_CPP_17 - #define JSON_HAS_CPP_14 - #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) - #define JSON_HAS_CPP_14 - #endif - // the cpp 11 flag is always specified because it is the minimal required version - #define JSON_HAS_CPP_11 -#endif - -// disable documentation warnings on clang -#if defined(__clang__) - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Wdocumentation" - #pragma clang diagnostic ignored "-Wdocumentation-unknown-command" -#endif - -// allow to disable exceptions -#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION) - #define JSON_THROW(exception) throw exception - #define JSON_TRY try - #define JSON_CATCH(exception) catch(exception) - #define JSON_INTERNAL_CATCH(exception) catch(exception) -#else - #include - #define JSON_THROW(exception) std::abort() - #define JSON_TRY if(true) - #define JSON_CATCH(exception) if(false) - #define JSON_INTERNAL_CATCH(exception) if(false) -#endif - -// override exception macros -#if defined(JSON_THROW_USER) - #undef JSON_THROW - #define JSON_THROW JSON_THROW_USER -#endif -#if defined(JSON_TRY_USER) - #undef JSON_TRY - #define JSON_TRY JSON_TRY_USER -#endif -#if defined(JSON_CATCH_USER) - #undef JSON_CATCH - #define JSON_CATCH JSON_CATCH_USER - #undef JSON_INTERNAL_CATCH - #define JSON_INTERNAL_CATCH JSON_CATCH_USER -#endif -#if defined(JSON_INTERNAL_CATCH_USER) - #undef JSON_INTERNAL_CATCH - #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER -#endif - -// allow to override assert -#if !defined(JSON_ASSERT) - #include // assert - #define JSON_ASSERT(x) assert(x) -#endif - -// allow to access some private functions (needed by the test suite) -#if defined(JSON_TESTS_PRIVATE) - #define JSON_PRIVATE_UNLESS_TESTED public -#else - #define JSON_PRIVATE_UNLESS_TESTED private -#endif - -/*! -@brief macro to briefly define a mapping between an enum and JSON -@def NLOHMANN_JSON_SERIALIZE_ENUM -@since version 3.4.0 -*/ -#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \ - template \ - inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \ - { \ - static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ - static const std::pair m[] = __VA_ARGS__; \ - auto it = std::find_if(std::begin(m), std::end(m), \ - [e](const std::pair& ej_pair) -> bool \ - { \ - return ej_pair.first == e; \ - }); \ - j = ((it != std::end(m)) ? it : std::begin(m))->second; \ - } \ - template \ - inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \ - { \ - static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ - static const std::pair m[] = __VA_ARGS__; \ - auto it = std::find_if(std::begin(m), std::end(m), \ - [&j](const std::pair& ej_pair) -> bool \ - { \ - return ej_pair.second == j; \ - }); \ - e = ((it != std::end(m)) ? it : std::begin(m))->first; \ - } - -// Ugly macros to avoid uglier copy-paste when specializing basic_json. They -// may be removed in the future once the class is split. - -#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \ - template class ObjectType, \ - template class ArrayType, \ - class StringType, class BooleanType, class NumberIntegerType, \ - class NumberUnsignedType, class NumberFloatType, \ - template class AllocatorType, \ - template class JSONSerializer, \ - class BinaryType> - -#define NLOHMANN_BASIC_JSON_TPL \ - basic_json - -// Macros to simplify conversion from/to types - -#define NLOHMANN_JSON_EXPAND( x ) x -#define NLOHMANN_JSON_GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, NAME,...) NAME -#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \ - NLOHMANN_JSON_PASTE64, \ - NLOHMANN_JSON_PASTE63, \ - NLOHMANN_JSON_PASTE62, \ - NLOHMANN_JSON_PASTE61, \ - NLOHMANN_JSON_PASTE60, \ - NLOHMANN_JSON_PASTE59, \ - NLOHMANN_JSON_PASTE58, \ - NLOHMANN_JSON_PASTE57, \ - NLOHMANN_JSON_PASTE56, \ - NLOHMANN_JSON_PASTE55, \ - NLOHMANN_JSON_PASTE54, \ - NLOHMANN_JSON_PASTE53, \ - NLOHMANN_JSON_PASTE52, \ - NLOHMANN_JSON_PASTE51, \ - NLOHMANN_JSON_PASTE50, \ - NLOHMANN_JSON_PASTE49, \ - NLOHMANN_JSON_PASTE48, \ - NLOHMANN_JSON_PASTE47, \ - NLOHMANN_JSON_PASTE46, \ - NLOHMANN_JSON_PASTE45, \ - NLOHMANN_JSON_PASTE44, \ - NLOHMANN_JSON_PASTE43, \ - NLOHMANN_JSON_PASTE42, \ - NLOHMANN_JSON_PASTE41, \ - NLOHMANN_JSON_PASTE40, \ - NLOHMANN_JSON_PASTE39, \ - NLOHMANN_JSON_PASTE38, \ - NLOHMANN_JSON_PASTE37, \ - NLOHMANN_JSON_PASTE36, \ - NLOHMANN_JSON_PASTE35, \ - NLOHMANN_JSON_PASTE34, \ - NLOHMANN_JSON_PASTE33, \ - NLOHMANN_JSON_PASTE32, \ - NLOHMANN_JSON_PASTE31, \ - NLOHMANN_JSON_PASTE30, \ - NLOHMANN_JSON_PASTE29, \ - NLOHMANN_JSON_PASTE28, \ - NLOHMANN_JSON_PASTE27, \ - NLOHMANN_JSON_PASTE26, \ - NLOHMANN_JSON_PASTE25, \ - NLOHMANN_JSON_PASTE24, \ - NLOHMANN_JSON_PASTE23, \ - NLOHMANN_JSON_PASTE22, \ - NLOHMANN_JSON_PASTE21, \ - NLOHMANN_JSON_PASTE20, \ - NLOHMANN_JSON_PASTE19, \ - NLOHMANN_JSON_PASTE18, \ - NLOHMANN_JSON_PASTE17, \ - NLOHMANN_JSON_PASTE16, \ - NLOHMANN_JSON_PASTE15, \ - NLOHMANN_JSON_PASTE14, \ - NLOHMANN_JSON_PASTE13, \ - NLOHMANN_JSON_PASTE12, \ - NLOHMANN_JSON_PASTE11, \ - NLOHMANN_JSON_PASTE10, \ - NLOHMANN_JSON_PASTE9, \ - NLOHMANN_JSON_PASTE8, \ - NLOHMANN_JSON_PASTE7, \ - NLOHMANN_JSON_PASTE6, \ - NLOHMANN_JSON_PASTE5, \ - NLOHMANN_JSON_PASTE4, \ - NLOHMANN_JSON_PASTE3, \ - NLOHMANN_JSON_PASTE2, \ - NLOHMANN_JSON_PASTE1)(__VA_ARGS__)) -#define NLOHMANN_JSON_PASTE2(func, v1) func(v1) -#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2) -#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3) -#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4) -#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5) -#define NLOHMANN_JSON_PASTE7(func, v1, v2, v3, v4, v5, v6) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE6(func, v2, v3, v4, v5, v6) -#define NLOHMANN_JSON_PASTE8(func, v1, v2, v3, v4, v5, v6, v7) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE7(func, v2, v3, v4, v5, v6, v7) -#define NLOHMANN_JSON_PASTE9(func, v1, v2, v3, v4, v5, v6, v7, v8) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE8(func, v2, v3, v4, v5, v6, v7, v8) -#define NLOHMANN_JSON_PASTE10(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE9(func, v2, v3, v4, v5, v6, v7, v8, v9) -#define NLOHMANN_JSON_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE10(func, v2, v3, v4, v5, v6, v7, v8, v9, v10) -#define NLOHMANN_JSON_PASTE12(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE11(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) -#define NLOHMANN_JSON_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE12(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) -#define NLOHMANN_JSON_PASTE14(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE13(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) -#define NLOHMANN_JSON_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE14(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) -#define NLOHMANN_JSON_PASTE16(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE15(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) -#define NLOHMANN_JSON_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE16(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) -#define NLOHMANN_JSON_PASTE18(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE17(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) -#define NLOHMANN_JSON_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE18(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) -#define NLOHMANN_JSON_PASTE20(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE19(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) -#define NLOHMANN_JSON_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE20(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) -#define NLOHMANN_JSON_PASTE22(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE21(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) -#define NLOHMANN_JSON_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE22(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) -#define NLOHMANN_JSON_PASTE24(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE23(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) -#define NLOHMANN_JSON_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE24(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) -#define NLOHMANN_JSON_PASTE26(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE25(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) -#define NLOHMANN_JSON_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE26(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) -#define NLOHMANN_JSON_PASTE28(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE27(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) -#define NLOHMANN_JSON_PASTE29(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE28(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) -#define NLOHMANN_JSON_PASTE30(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE29(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) -#define NLOHMANN_JSON_PASTE31(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE30(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) -#define NLOHMANN_JSON_PASTE32(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE31(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) -#define NLOHMANN_JSON_PASTE33(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE32(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) -#define NLOHMANN_JSON_PASTE34(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE33(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) -#define NLOHMANN_JSON_PASTE35(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE34(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) -#define NLOHMANN_JSON_PASTE36(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE35(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) -#define NLOHMANN_JSON_PASTE37(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE36(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) -#define NLOHMANN_JSON_PASTE38(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE37(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) -#define NLOHMANN_JSON_PASTE39(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE38(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) -#define NLOHMANN_JSON_PASTE40(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE39(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) -#define NLOHMANN_JSON_PASTE41(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE40(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) -#define NLOHMANN_JSON_PASTE42(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE41(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) -#define NLOHMANN_JSON_PASTE43(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE42(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) -#define NLOHMANN_JSON_PASTE44(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE43(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) -#define NLOHMANN_JSON_PASTE45(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE44(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) -#define NLOHMANN_JSON_PASTE46(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE45(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) -#define NLOHMANN_JSON_PASTE47(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE46(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) -#define NLOHMANN_JSON_PASTE48(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE47(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) -#define NLOHMANN_JSON_PASTE49(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE48(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) -#define NLOHMANN_JSON_PASTE50(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE49(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) -#define NLOHMANN_JSON_PASTE51(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE50(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) -#define NLOHMANN_JSON_PASTE52(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE51(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) -#define NLOHMANN_JSON_PASTE53(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE52(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) -#define NLOHMANN_JSON_PASTE54(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE53(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) -#define NLOHMANN_JSON_PASTE55(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE54(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) -#define NLOHMANN_JSON_PASTE56(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE55(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) -#define NLOHMANN_JSON_PASTE57(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE56(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) -#define NLOHMANN_JSON_PASTE58(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE57(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) -#define NLOHMANN_JSON_PASTE59(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE58(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) -#define NLOHMANN_JSON_PASTE60(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE59(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) -#define NLOHMANN_JSON_PASTE61(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE60(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) -#define NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE61(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) -#define NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE62(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) -#define NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE63(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) - -#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1; -#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1); - -/*! -@brief macro -@def NLOHMANN_DEFINE_TYPE_INTRUSIVE -@since version 3.9.0 -*/ -#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \ - friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ - friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } - -/*! -@brief macro -@def NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE -@since version 3.9.0 -*/ -#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \ - inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ - inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } - - -// inspired from https://stackoverflow.com/a/26745591 -// allows to call any std function as if (e.g. with begin): -// using std::begin; begin(x); -// -// it allows using the detected idiom to retrieve the return type -// of such an expression -#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \ - namespace detail { \ - using std::std_name; \ - \ - template \ - using result_of_##std_name = decltype(std_name(std::declval()...)); \ - } \ - \ - namespace detail2 { \ - struct std_name##_tag \ - { \ - }; \ - \ - template \ - std_name##_tag std_name(T&&...); \ - \ - template \ - using result_of_##std_name = decltype(std_name(std::declval()...)); \ - \ - template \ - struct would_call_std_##std_name \ - { \ - static constexpr auto const value = ::nlohmann::detail:: \ - is_detected_exact::value; \ - }; \ - } /* namespace detail2 */ \ - \ - template \ - struct would_call_std_##std_name : detail2::would_call_std_##std_name \ - { \ - } - -#ifndef JSON_USE_IMPLICIT_CONVERSIONS - #define JSON_USE_IMPLICIT_CONVERSIONS 1 -#endif - -#if JSON_USE_IMPLICIT_CONVERSIONS - #define JSON_EXPLICIT -#else - #define JSON_EXPLICIT explicit -#endif - -#ifndef JSON_DIAGNOSTICS - #define JSON_DIAGNOSTICS 0 -#endif - - -namespace nlohmann -{ -namespace detail -{ - -/*! -@brief replace all occurrences of a substring by another string - -@param[in,out] s the string to manipulate; changed so that all - occurrences of @a f are replaced with @a t -@param[in] f the substring to replace with @a t -@param[in] t the string to replace @a f - -@pre The search string @a f must not be empty. **This precondition is -enforced with an assertion.** - -@since version 2.0.0 -*/ -inline void replace_substring(std::string& s, const std::string& f, - const std::string& t) -{ - JSON_ASSERT(!f.empty()); - for (auto pos = s.find(f); // find first occurrence of f - pos != std::string::npos; // make sure f was found - s.replace(pos, f.size(), t), // replace with t, and - pos = s.find(f, pos + t.size())) // find next occurrence of f - {} -} - -/*! - * @brief string escaping as described in RFC 6901 (Sect. 4) - * @param[in] s string to escape - * @return escaped string - * - * Note the order of escaping "~" to "~0" and "/" to "~1" is important. - */ -inline std::string escape(std::string s) -{ - replace_substring(s, "~", "~0"); - replace_substring(s, "/", "~1"); - return s; -} - -/*! - * @brief string unescaping as described in RFC 6901 (Sect. 4) - * @param[in] s string to unescape - * @return unescaped string - * - * Note the order of escaping "~1" to "/" and "~0" to "~" is important. - */ -static void unescape(std::string& s) -{ - replace_substring(s, "~1", "/"); - replace_substring(s, "~0", "~"); -} - -} // namespace detail -} // namespace nlohmann - -// #include - - -#include // size_t - -namespace nlohmann -{ -namespace detail -{ -/// struct to capture the start position of the current token -struct position_t -{ - /// the total number of characters read - std::size_t chars_read_total = 0; - /// the number of characters read in the current line - std::size_t chars_read_current_line = 0; - /// the number of lines read - std::size_t lines_read = 0; - - /// conversion to size_t to preserve SAX interface - constexpr operator size_t() const - { - return chars_read_total; - } -}; - -} // namespace detail -} // namespace nlohmann - -// #include - - -namespace nlohmann -{ -namespace detail -{ -//////////////// -// exceptions // -//////////////// - -/*! -@brief general exception of the @ref basic_json class - -This class is an extension of `std::exception` objects with a member @a id for -exception ids. It is used as the base class for all exceptions thrown by the -@ref basic_json class. This class can hence be used as "wildcard" to catch -exceptions. - -Subclasses: -- @ref parse_error for exceptions indicating a parse error -- @ref invalid_iterator for exceptions indicating errors with iterators -- @ref type_error for exceptions indicating executing a member function with - a wrong type -- @ref out_of_range for exceptions indicating access out of the defined range -- @ref other_error for exceptions indicating other library errors - -@internal -@note To have nothrow-copy-constructible exceptions, we internally use - `std::runtime_error` which can cope with arbitrary-length error messages. - Intermediate strings are built with static functions and then passed to - the actual constructor. -@endinternal - -@liveexample{The following code shows how arbitrary library exceptions can be -caught.,exception} - -@since version 3.0.0 -*/ -class exception : public std::exception -{ - public: - /// returns the explanatory string - const char* what() const noexcept override - { - return m.what(); - } - - /// the id of the exception - const int id; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes) - - protected: - JSON_HEDLEY_NON_NULL(3) - exception(int id_, const char* what_arg) : id(id_), m(what_arg) {} // NOLINT(bugprone-throw-keyword-missing) - - static std::string name(const std::string& ename, int id_) - { - return "[json.exception." + ename + "." + std::to_string(id_) + "] "; - } - - template - static std::string diagnostics(const BasicJsonType& leaf_element) - { -#if JSON_DIAGNOSTICS - std::vector tokens; - for (const auto* current = &leaf_element; current->m_parent != nullptr; current = current->m_parent) - { - switch (current->m_parent->type()) - { - case value_t::array: - { - for (std::size_t i = 0; i < current->m_parent->m_value.array->size(); ++i) - { - if (¤t->m_parent->m_value.array->operator[](i) == current) - { - tokens.emplace_back(std::to_string(i)); - break; - } - } - break; - } - - case value_t::object: - { - for (const auto& element : *current->m_parent->m_value.object) - { - if (&element.second == current) - { - tokens.emplace_back(element.first.c_str()); - break; - } - } - break; - } - - case value_t::null: // LCOV_EXCL_LINE - case value_t::string: // LCOV_EXCL_LINE - case value_t::boolean: // LCOV_EXCL_LINE - case value_t::number_integer: // LCOV_EXCL_LINE - case value_t::number_unsigned: // LCOV_EXCL_LINE - case value_t::number_float: // LCOV_EXCL_LINE - case value_t::binary: // LCOV_EXCL_LINE - case value_t::discarded: // LCOV_EXCL_LINE - default: // LCOV_EXCL_LINE - break; // LCOV_EXCL_LINE - } - } - - if (tokens.empty()) - { - return ""; - } - - return "(" + std::accumulate(tokens.rbegin(), tokens.rend(), std::string{}, - [](const std::string & a, const std::string & b) - { - return a + "/" + detail::escape(b); - }) + ") "; -#else - static_cast(leaf_element); - return ""; -#endif - } - - private: - /// an exception object as storage for error messages - std::runtime_error m; -}; - -/*! -@brief exception indicating a parse error - -This exception is thrown by the library when a parse error occurs. Parse errors -can occur during the deserialization of JSON text, CBOR, MessagePack, as well -as when using JSON Patch. - -Member @a byte holds the byte index of the last read character in the input -file. - -Exceptions have ids 1xx. - -name / id | example message | description ------------------------------- | --------------- | ------------------------- -json.exception.parse_error.101 | parse error at 2: unexpected end of input; expected string literal | This error indicates a syntax error while deserializing a JSON text. The error message describes that an unexpected token (character) was encountered, and the member @a byte indicates the error position. -json.exception.parse_error.102 | parse error at 14: missing or wrong low surrogate | JSON uses the `\uxxxx` format to describe Unicode characters. Code points above above 0xFFFF are split into two `\uxxxx` entries ("surrogate pairs"). This error indicates that the surrogate pair is incomplete or contains an invalid code point. -json.exception.parse_error.103 | parse error: code points above 0x10FFFF are invalid | Unicode supports code points up to 0x10FFFF. Code points above 0x10FFFF are invalid. -json.exception.parse_error.104 | parse error: JSON patch must be an array of objects | [RFC 6902](https://tools.ietf.org/html/rfc6902) requires a JSON Patch document to be a JSON document that represents an array of objects. -json.exception.parse_error.105 | parse error: operation must have string member 'op' | An operation of a JSON Patch document must contain exactly one "op" member, whose value indicates the operation to perform. Its value must be one of "add", "remove", "replace", "move", "copy", or "test"; other values are errors. -json.exception.parse_error.106 | parse error: array index '01' must not begin with '0' | An array index in a JSON Pointer ([RFC 6901](https://tools.ietf.org/html/rfc6901)) may be `0` or any number without a leading `0`. -json.exception.parse_error.107 | parse error: JSON pointer must be empty or begin with '/' - was: 'foo' | A JSON Pointer must be a Unicode string containing a sequence of zero or more reference tokens, each prefixed by a `/` character. -json.exception.parse_error.108 | parse error: escape character '~' must be followed with '0' or '1' | In a JSON Pointer, only `~0` and `~1` are valid escape sequences. -json.exception.parse_error.109 | parse error: array index 'one' is not a number | A JSON Pointer array index must be a number. -json.exception.parse_error.110 | parse error at 1: cannot read 2 bytes from vector | When parsing CBOR or MessagePack, the byte vector ends before the complete value has been read. -json.exception.parse_error.112 | parse error at 1: error reading CBOR; last byte: 0xF8 | Not all types of CBOR or MessagePack are supported. This exception occurs if an unsupported byte was read. -json.exception.parse_error.113 | parse error at 2: expected a CBOR string; last byte: 0x98 | While parsing a map key, a value that is not a string has been read. -json.exception.parse_error.114 | parse error: Unsupported BSON record type 0x0F | The parsing of the corresponding BSON record type is not implemented (yet). -json.exception.parse_error.115 | parse error at byte 5: syntax error while parsing UBJSON high-precision number: invalid number text: 1A | A UBJSON high-precision number could not be parsed. - -@note For an input with n bytes, 1 is the index of the first character and n+1 - is the index of the terminating null byte or the end of file. This also - holds true when reading a byte vector (CBOR or MessagePack). - -@liveexample{The following code shows how a `parse_error` exception can be -caught.,parse_error} - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref invalid_iterator for exceptions indicating errors with iterators -@sa - @ref type_error for exceptions indicating executing a member function with - a wrong type -@sa - @ref out_of_range for exceptions indicating access out of the defined range -@sa - @ref other_error for exceptions indicating other library errors - -@since version 3.0.0 -*/ -class parse_error : public exception -{ - public: - /*! - @brief create a parse error exception - @param[in] id_ the id of the exception - @param[in] pos the position where the error occurred (or with - chars_read_total=0 if the position cannot be - determined) - @param[in] what_arg the explanatory string - @return parse_error object - */ - template - static parse_error create(int id_, const position_t& pos, const std::string& what_arg, const BasicJsonType& context) - { - std::string w = exception::name("parse_error", id_) + "parse error" + - position_string(pos) + ": " + exception::diagnostics(context) + what_arg; - return {id_, pos.chars_read_total, w.c_str()}; - } - - template - static parse_error create(int id_, std::size_t byte_, const std::string& what_arg, const BasicJsonType& context) - { - std::string w = exception::name("parse_error", id_) + "parse error" + - (byte_ != 0 ? (" at byte " + std::to_string(byte_)) : "") + - ": " + exception::diagnostics(context) + what_arg; - return {id_, byte_, w.c_str()}; - } - - /*! - @brief byte index of the parse error - - The byte index of the last read character in the input file. - - @note For an input with n bytes, 1 is the index of the first character and - n+1 is the index of the terminating null byte or the end of file. - This also holds true when reading a byte vector (CBOR or MessagePack). - */ - const std::size_t byte; - - private: - parse_error(int id_, std::size_t byte_, const char* what_arg) - : exception(id_, what_arg), byte(byte_) {} - - static std::string position_string(const position_t& pos) - { - return " at line " + std::to_string(pos.lines_read + 1) + - ", column " + std::to_string(pos.chars_read_current_line); - } -}; - -/*! -@brief exception indicating errors with iterators - -This exception is thrown if iterators passed to a library function do not match -the expected semantics. - -Exceptions have ids 2xx. - -name / id | example message | description ------------------------------------ | --------------- | ------------------------- -json.exception.invalid_iterator.201 | iterators are not compatible | The iterators passed to constructor @ref basic_json(InputIT first, InputIT last) are not compatible, meaning they do not belong to the same container. Therefore, the range (@a first, @a last) is invalid. -json.exception.invalid_iterator.202 | iterator does not fit current value | In an erase or insert function, the passed iterator @a pos does not belong to the JSON value for which the function was called. It hence does not define a valid position for the deletion/insertion. -json.exception.invalid_iterator.203 | iterators do not fit current value | Either iterator passed to function @ref erase(IteratorType first, IteratorType last) does not belong to the JSON value from which values shall be erased. It hence does not define a valid range to delete values from. -json.exception.invalid_iterator.204 | iterators out of range | When an iterator range for a primitive type (number, boolean, or string) is passed to a constructor or an erase function, this range has to be exactly (@ref begin(), @ref end()), because this is the only way the single stored value is expressed. All other ranges are invalid. -json.exception.invalid_iterator.205 | iterator out of range | When an iterator for a primitive type (number, boolean, or string) is passed to an erase function, the iterator has to be the @ref begin() iterator, because it is the only way to address the stored value. All other iterators are invalid. -json.exception.invalid_iterator.206 | cannot construct with iterators from null | The iterators passed to constructor @ref basic_json(InputIT first, InputIT last) belong to a JSON null value and hence to not define a valid range. -json.exception.invalid_iterator.207 | cannot use key() for non-object iterators | The key() member function can only be used on iterators belonging to a JSON object, because other types do not have a concept of a key. -json.exception.invalid_iterator.208 | cannot use operator[] for object iterators | The operator[] to specify a concrete offset cannot be used on iterators belonging to a JSON object, because JSON objects are unordered. -json.exception.invalid_iterator.209 | cannot use offsets with object iterators | The offset operators (+, -, +=, -=) cannot be used on iterators belonging to a JSON object, because JSON objects are unordered. -json.exception.invalid_iterator.210 | iterators do not fit | The iterator range passed to the insert function are not compatible, meaning they do not belong to the same container. Therefore, the range (@a first, @a last) is invalid. -json.exception.invalid_iterator.211 | passed iterators may not belong to container | The iterator range passed to the insert function must not be a subrange of the container to insert to. -json.exception.invalid_iterator.212 | cannot compare iterators of different containers | When two iterators are compared, they must belong to the same container. -json.exception.invalid_iterator.213 | cannot compare order of object iterators | The order of object iterators cannot be compared, because JSON objects are unordered. -json.exception.invalid_iterator.214 | cannot get value | Cannot get value for iterator: Either the iterator belongs to a null value or it is an iterator to a primitive type (number, boolean, or string), but the iterator is different to @ref begin(). - -@liveexample{The following code shows how an `invalid_iterator` exception can be -caught.,invalid_iterator} - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref parse_error for exceptions indicating a parse error -@sa - @ref type_error for exceptions indicating executing a member function with - a wrong type -@sa - @ref out_of_range for exceptions indicating access out of the defined range -@sa - @ref other_error for exceptions indicating other library errors - -@since version 3.0.0 -*/ -class invalid_iterator : public exception -{ - public: - template - static invalid_iterator create(int id_, const std::string& what_arg, const BasicJsonType& context) - { - std::string w = exception::name("invalid_iterator", id_) + exception::diagnostics(context) + what_arg; - return {id_, w.c_str()}; - } - - private: - JSON_HEDLEY_NON_NULL(3) - invalid_iterator(int id_, const char* what_arg) - : exception(id_, what_arg) {} -}; - -/*! -@brief exception indicating executing a member function with a wrong type - -This exception is thrown in case of a type error; that is, a library function is -executed on a JSON value whose type does not match the expected semantics. - -Exceptions have ids 3xx. - -name / id | example message | description ------------------------------ | --------------- | ------------------------- -json.exception.type_error.301 | cannot create object from initializer list | To create an object from an initializer list, the initializer list must consist only of a list of pairs whose first element is a string. When this constraint is violated, an array is created instead. -json.exception.type_error.302 | type must be object, but is array | During implicit or explicit value conversion, the JSON type must be compatible to the target type. For instance, a JSON string can only be converted into string types, but not into numbers or boolean types. -json.exception.type_error.303 | incompatible ReferenceType for get_ref, actual type is object | To retrieve a reference to a value stored in a @ref basic_json object with @ref get_ref, the type of the reference must match the value type. For instance, for a JSON array, the @a ReferenceType must be @ref array_t &. -json.exception.type_error.304 | cannot use at() with string | The @ref at() member functions can only be executed for certain JSON types. -json.exception.type_error.305 | cannot use operator[] with string | The @ref operator[] member functions can only be executed for certain JSON types. -json.exception.type_error.306 | cannot use value() with string | The @ref value() member functions can only be executed for certain JSON types. -json.exception.type_error.307 | cannot use erase() with string | The @ref erase() member functions can only be executed for certain JSON types. -json.exception.type_error.308 | cannot use push_back() with string | The @ref push_back() and @ref operator+= member functions can only be executed for certain JSON types. -json.exception.type_error.309 | cannot use insert() with | The @ref insert() member functions can only be executed for certain JSON types. -json.exception.type_error.310 | cannot use swap() with number | The @ref swap() member functions can only be executed for certain JSON types. -json.exception.type_error.311 | cannot use emplace_back() with string | The @ref emplace_back() member function can only be executed for certain JSON types. -json.exception.type_error.312 | cannot use update() with string | The @ref update() member functions can only be executed for certain JSON types. -json.exception.type_error.313 | invalid value to unflatten | The @ref unflatten function converts an object whose keys are JSON Pointers back into an arbitrary nested JSON value. The JSON Pointers must not overlap, because then the resulting value would not be well defined. -json.exception.type_error.314 | only objects can be unflattened | The @ref unflatten function only works for an object whose keys are JSON Pointers. -json.exception.type_error.315 | values in object must be primitive | The @ref unflatten function only works for an object whose keys are JSON Pointers and whose values are primitive. -json.exception.type_error.316 | invalid UTF-8 byte at index 10: 0x7E | The @ref dump function only works with UTF-8 encoded strings; that is, if you assign a `std::string` to a JSON value, make sure it is UTF-8 encoded. | -json.exception.type_error.317 | JSON value cannot be serialized to requested format | The dynamic type of the object cannot be represented in the requested serialization format (e.g. a raw `true` or `null` JSON object cannot be serialized to BSON) | - -@liveexample{The following code shows how a `type_error` exception can be -caught.,type_error} - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref parse_error for exceptions indicating a parse error -@sa - @ref invalid_iterator for exceptions indicating errors with iterators -@sa - @ref out_of_range for exceptions indicating access out of the defined range -@sa - @ref other_error for exceptions indicating other library errors - -@since version 3.0.0 -*/ -class type_error : public exception -{ - public: - template - static type_error create(int id_, const std::string& what_arg, const BasicJsonType& context) - { - std::string w = exception::name("type_error", id_) + exception::diagnostics(context) + what_arg; - return {id_, w.c_str()}; - } - - private: - JSON_HEDLEY_NON_NULL(3) - type_error(int id_, const char* what_arg) : exception(id_, what_arg) {} -}; - -/*! -@brief exception indicating access out of the defined range - -This exception is thrown in case a library function is called on an input -parameter that exceeds the expected range, for instance in case of array -indices or nonexisting object keys. - -Exceptions have ids 4xx. - -name / id | example message | description -------------------------------- | --------------- | ------------------------- -json.exception.out_of_range.401 | array index 3 is out of range | The provided array index @a i is larger than @a size-1. -json.exception.out_of_range.402 | array index '-' (3) is out of range | The special array index `-` in a JSON Pointer never describes a valid element of the array, but the index past the end. That is, it can only be used to add elements at this position, but not to read it. -json.exception.out_of_range.403 | key 'foo' not found | The provided key was not found in the JSON object. -json.exception.out_of_range.404 | unresolved reference token 'foo' | A reference token in a JSON Pointer could not be resolved. -json.exception.out_of_range.405 | JSON pointer has no parent | The JSON Patch operations 'remove' and 'add' can not be applied to the root element of the JSON value. -json.exception.out_of_range.406 | number overflow parsing '10E1000' | A parsed number could not be stored as without changing it to NaN or INF. -json.exception.out_of_range.407 | number overflow serializing '9223372036854775808' | UBJSON and BSON only support integer numbers up to 9223372036854775807. (until version 3.8.0) | -json.exception.out_of_range.408 | excessive array size: 8658170730974374167 | The size (following `#`) of an UBJSON array or object exceeds the maximal capacity. | -json.exception.out_of_range.409 | BSON key cannot contain code point U+0000 (at byte 2) | Key identifiers to be serialized to BSON cannot contain code point U+0000, since the key is stored as zero-terminated c-string | - -@liveexample{The following code shows how an `out_of_range` exception can be -caught.,out_of_range} - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref parse_error for exceptions indicating a parse error -@sa - @ref invalid_iterator for exceptions indicating errors with iterators -@sa - @ref type_error for exceptions indicating executing a member function with - a wrong type -@sa - @ref other_error for exceptions indicating other library errors - -@since version 3.0.0 -*/ -class out_of_range : public exception -{ - public: - template - static out_of_range create(int id_, const std::string& what_arg, const BasicJsonType& context) - { - std::string w = exception::name("out_of_range", id_) + exception::diagnostics(context) + what_arg; - return {id_, w.c_str()}; - } - - private: - JSON_HEDLEY_NON_NULL(3) - out_of_range(int id_, const char* what_arg) : exception(id_, what_arg) {} -}; - -/*! -@brief exception indicating other library errors - -This exception is thrown in case of errors that cannot be classified with the -other exception types. - -Exceptions have ids 5xx. - -name / id | example message | description ------------------------------- | --------------- | ------------------------- -json.exception.other_error.501 | unsuccessful: {"op":"test","path":"/baz", "value":"bar"} | A JSON Patch operation 'test' failed. The unsuccessful operation is also printed. - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref parse_error for exceptions indicating a parse error -@sa - @ref invalid_iterator for exceptions indicating errors with iterators -@sa - @ref type_error for exceptions indicating executing a member function with - a wrong type -@sa - @ref out_of_range for exceptions indicating access out of the defined range - -@liveexample{The following code shows how an `other_error` exception can be -caught.,other_error} - -@since version 3.0.0 -*/ -class other_error : public exception -{ - public: - template - static other_error create(int id_, const std::string& what_arg, const BasicJsonType& context) - { - std::string w = exception::name("other_error", id_) + exception::diagnostics(context) + what_arg; - return {id_, w.c_str()}; - } - - private: - JSON_HEDLEY_NON_NULL(3) - other_error(int id_, const char* what_arg) : exception(id_, what_arg) {} -}; -} // namespace detail -} // namespace nlohmann - -// #include - -// #include - - -#include // size_t -#include // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type -#include // index_sequence, make_index_sequence, index_sequence_for - -// #include - - -namespace nlohmann -{ -namespace detail -{ - -template -using uncvref_t = typename std::remove_cv::type>::type; - -#ifdef JSON_HAS_CPP_14 - -// the following utilities are natively available in C++14 -using std::enable_if_t; -using std::index_sequence; -using std::make_index_sequence; -using std::index_sequence_for; - -#else - -// alias templates to reduce boilerplate -template -using enable_if_t = typename std::enable_if::type; - -// The following code is taken from https://github.com/abseil/abseil-cpp/blob/10cb35e459f5ecca5b2ff107635da0bfa41011b4/absl/utility/utility.h -// which is part of Google Abseil (https://github.com/abseil/abseil-cpp), licensed under the Apache License 2.0. - -//// START OF CODE FROM GOOGLE ABSEIL - -// integer_sequence -// -// Class template representing a compile-time integer sequence. An instantiation -// of `integer_sequence` has a sequence of integers encoded in its -// type through its template arguments (which is a common need when -// working with C++11 variadic templates). `absl::integer_sequence` is designed -// to be a drop-in replacement for C++14's `std::integer_sequence`. -// -// Example: -// -// template< class T, T... Ints > -// void user_function(integer_sequence); -// -// int main() -// { -// // user_function's `T` will be deduced to `int` and `Ints...` -// // will be deduced to `0, 1, 2, 3, 4`. -// user_function(make_integer_sequence()); -// } -template -struct integer_sequence -{ - using value_type = T; - static constexpr std::size_t size() noexcept - { - return sizeof...(Ints); - } -}; - -// index_sequence -// -// A helper template for an `integer_sequence` of `size_t`, -// `absl::index_sequence` is designed to be a drop-in replacement for C++14's -// `std::index_sequence`. -template -using index_sequence = integer_sequence; - -namespace utility_internal -{ - -template -struct Extend; - -// Note that SeqSize == sizeof...(Ints). It's passed explicitly for efficiency. -template -struct Extend, SeqSize, 0> -{ - using type = integer_sequence < T, Ints..., (Ints + SeqSize)... >; -}; - -template -struct Extend, SeqSize, 1> -{ - using type = integer_sequence < T, Ints..., (Ints + SeqSize)..., 2 * SeqSize >; -}; - -// Recursion helper for 'make_integer_sequence'. -// 'Gen::type' is an alias for 'integer_sequence'. -template -struct Gen -{ - using type = - typename Extend < typename Gen < T, N / 2 >::type, N / 2, N % 2 >::type; -}; - -template -struct Gen -{ - using type = integer_sequence; -}; - -} // namespace utility_internal - -// Compile-time sequences of integers - -// make_integer_sequence -// -// This template alias is equivalent to -// `integer_sequence`, and is designed to be a drop-in -// replacement for C++14's `std::make_integer_sequence`. -template -using make_integer_sequence = typename utility_internal::Gen::type; - -// make_index_sequence -// -// This template alias is equivalent to `index_sequence<0, 1, ..., N-1>`, -// and is designed to be a drop-in replacement for C++14's -// `std::make_index_sequence`. -template -using make_index_sequence = make_integer_sequence; - -// index_sequence_for -// -// Converts a typename pack into an index sequence of the same length, and -// is designed to be a drop-in replacement for C++14's -// `std::index_sequence_for()` -template -using index_sequence_for = make_index_sequence; - -//// END OF CODE FROM GOOGLE ABSEIL - -#endif - -// dispatch utility (taken from ranges-v3) -template struct priority_tag : priority_tag < N - 1 > {}; -template<> struct priority_tag<0> {}; - -// taken from ranges-v3 -template -struct static_const -{ - static constexpr T value{}; -}; - -template -constexpr T static_const::value; - -} // namespace detail -} // namespace nlohmann - -// #include - - -namespace nlohmann -{ -namespace detail -{ -// dispatching helper struct -template struct identity_tag {}; -} // namespace detail -} // namespace nlohmann - -// #include - - -#include // numeric_limits -#include // false_type, is_constructible, is_integral, is_same, true_type -#include // declval -#include // tuple - -// #include - - -// #include - - -#include // random_access_iterator_tag - -// #include - -// #include - - -namespace nlohmann -{ -namespace detail -{ -template -struct iterator_types {}; - -template -struct iterator_types < - It, - void_t> -{ - using difference_type = typename It::difference_type; - using value_type = typename It::value_type; - using pointer = typename It::pointer; - using reference = typename It::reference; - using iterator_category = typename It::iterator_category; -}; - -// This is required as some compilers implement std::iterator_traits in a way that -// doesn't work with SFINAE. See https://github.com/nlohmann/json/issues/1341. -template -struct iterator_traits -{ -}; - -template -struct iterator_traits < T, enable_if_t < !std::is_pointer::value >> - : iterator_types -{ -}; - -template -struct iterator_traits::value>> -{ - using iterator_category = std::random_access_iterator_tag; - using value_type = T; - using difference_type = ptrdiff_t; - using pointer = T*; - using reference = T&; -}; -} // namespace detail -} // namespace nlohmann - -// #include - - -// #include - - -namespace nlohmann -{ -NLOHMANN_CAN_CALL_STD_FUNC_IMPL(begin); -} // namespace nlohmann - -// #include - - -// #include - - -namespace nlohmann -{ -NLOHMANN_CAN_CALL_STD_FUNC_IMPL(end); -} // namespace nlohmann - -// #include - -// #include - -// #include -#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_ -#define INCLUDE_NLOHMANN_JSON_FWD_HPP_ - -#include // int64_t, uint64_t -#include // map -#include // allocator -#include // string -#include // vector - -/*! -@brief namespace for Niels Lohmann -@see https://github.com/nlohmann -@since version 1.0.0 -*/ -namespace nlohmann -{ -/*! -@brief default JSONSerializer template argument - -This serializer ignores the template arguments and uses ADL -([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl)) -for serialization. -*/ -template -struct adl_serializer; - -template class ObjectType = - std::map, - template class ArrayType = std::vector, - class StringType = std::string, class BooleanType = bool, - class NumberIntegerType = std::int64_t, - class NumberUnsignedType = std::uint64_t, - class NumberFloatType = double, - template class AllocatorType = std::allocator, - template class JSONSerializer = - adl_serializer, - class BinaryType = std::vector> -class basic_json; - -/*! -@brief JSON Pointer - -A JSON pointer defines a string syntax for identifying a specific value -within a JSON document. It can be used with functions `at` and -`operator[]`. Furthermore, JSON pointers are the base for JSON patches. - -@sa [RFC 6901](https://tools.ietf.org/html/rfc6901) - -@since version 2.0.0 -*/ -template -class json_pointer; - -/*! -@brief default JSON class - -This type is the default specialization of the @ref basic_json class which -uses the standard template types. - -@since version 1.0.0 -*/ -using json = basic_json<>; - -template -struct ordered_map; - -/*! -@brief ordered JSON class - -This type preserves the insertion order of object keys. - -@since version 3.9.0 -*/ -using ordered_json = basic_json; - -} // namespace nlohmann - -#endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_ - - -namespace nlohmann -{ -/*! -@brief detail namespace with internal helper functions - -This namespace collects functions that should not be exposed, -implementations of some @ref basic_json methods, and meta-programming helpers. - -@since version 2.1.0 -*/ -namespace detail -{ -///////////// -// helpers // -///////////// - -// Note to maintainers: -// -// Every trait in this file expects a non CV-qualified type. -// The only exceptions are in the 'aliases for detected' section -// (i.e. those of the form: decltype(T::member_function(std::declval()))) -// -// In this case, T has to be properly CV-qualified to constraint the function arguments -// (e.g. to_json(BasicJsonType&, const T&)) - -template struct is_basic_json : std::false_type {}; - -NLOHMANN_BASIC_JSON_TPL_DECLARATION -struct is_basic_json : std::true_type {}; - -////////////////////// -// json_ref helpers // -////////////////////// - -template -class json_ref; - -template -struct is_json_ref : std::false_type {}; - -template -struct is_json_ref> : std::true_type {}; - -////////////////////////// -// aliases for detected // -////////////////////////// - -template -using mapped_type_t = typename T::mapped_type; - -template -using key_type_t = typename T::key_type; - -template -using value_type_t = typename T::value_type; - -template -using difference_type_t = typename T::difference_type; - -template -using pointer_t = typename T::pointer; - -template -using reference_t = typename T::reference; - -template -using iterator_category_t = typename T::iterator_category; - -template -using to_json_function = decltype(T::to_json(std::declval()...)); - -template -using from_json_function = decltype(T::from_json(std::declval()...)); - -template -using get_template_function = decltype(std::declval().template get()); - -// trait checking if JSONSerializer::from_json(json const&, udt&) exists -template -struct has_from_json : std::false_type {}; - -// trait checking if j.get is valid -// use this trait instead of std::is_constructible or std::is_convertible, -// both rely on, or make use of implicit conversions, and thus fail when T -// has several constructors/operator= (see https://github.com/nlohmann/json/issues/958) -template -struct is_getable -{ - static constexpr bool value = is_detected::value; -}; - -template -struct has_from_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> -{ - using serializer = typename BasicJsonType::template json_serializer; - - static constexpr bool value = - is_detected_exact::value; -}; - -// This trait checks if JSONSerializer::from_json(json const&) exists -// this overload is used for non-default-constructible user-defined-types -template -struct has_non_default_from_json : std::false_type {}; - -template -struct has_non_default_from_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> -{ - using serializer = typename BasicJsonType::template json_serializer; - - static constexpr bool value = - is_detected_exact::value; -}; - -// This trait checks if BasicJsonType::json_serializer::to_json exists -// Do not evaluate the trait when T is a basic_json type, to avoid template instantiation infinite recursion. -template -struct has_to_json : std::false_type {}; - -template -struct has_to_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> -{ - using serializer = typename BasicJsonType::template json_serializer; - - static constexpr bool value = - is_detected_exact::value; -}; - - -/////////////////// -// is_ functions // -/////////////////// - -// https://en.cppreference.com/w/cpp/types/conjunction -template struct conjunction : std::true_type { }; -template struct conjunction : B1 { }; -template -struct conjunction -: std::conditional, B1>::type {}; - -// https://en.cppreference.com/w/cpp/types/negation -template struct negation : std::integral_constant < bool, !B::value > { }; - -// Reimplementation of is_constructible and is_default_constructible, due to them being broken for -// std::pair and std::tuple until LWG 2367 fix (see https://cplusplus.github.io/LWG/lwg-defects.html#2367). -// This causes compile errors in e.g. clang 3.5 or gcc 4.9. -template -struct is_default_constructible : std::is_default_constructible {}; - -template -struct is_default_constructible> - : conjunction, is_default_constructible> {}; - -template -struct is_default_constructible> - : conjunction, is_default_constructible> {}; - -template -struct is_default_constructible> - : conjunction...> {}; - -template -struct is_default_constructible> - : conjunction...> {}; - - -template -struct is_constructible : std::is_constructible {}; - -template -struct is_constructible> : is_default_constructible> {}; - -template -struct is_constructible> : is_default_constructible> {}; - -template -struct is_constructible> : is_default_constructible> {}; - -template -struct is_constructible> : is_default_constructible> {}; - - -template -struct is_iterator_traits : std::false_type {}; - -template -struct is_iterator_traits> -{ - private: - using traits = iterator_traits; - - public: - static constexpr auto value = - is_detected::value && - is_detected::value && - is_detected::value && - is_detected::value && - is_detected::value; -}; - -template -struct is_range -{ - private: - using t_ref = typename std::add_lvalue_reference::type; - - using iterator = detected_t; - using sentinel = detected_t; - - // to be 100% correct, it should use https://en.cppreference.com/w/cpp/iterator/input_or_output_iterator - // and https://en.cppreference.com/w/cpp/iterator/sentinel_for - // but reimplementing these would be too much work, as a lot of other concepts are used underneath - static constexpr auto is_iterator_begin = - is_iterator_traits>::value; - - public: - static constexpr bool value = !std::is_same::value && !std::is_same::value && is_iterator_begin; -}; - -template -using iterator_t = enable_if_t::value, result_of_begin())>>; - -template -using range_value_t = value_type_t>>; - -// The following implementation of is_complete_type is taken from -// https://blogs.msdn.microsoft.com/vcblog/2015/12/02/partial-support-for-expression-sfinae-in-vs-2015-update-1/ -// and is written by Xiang Fan who agreed to using it in this library. - -template -struct is_complete_type : std::false_type {}; - -template -struct is_complete_type : std::true_type {}; - -template -struct is_compatible_object_type_impl : std::false_type {}; - -template -struct is_compatible_object_type_impl < - BasicJsonType, CompatibleObjectType, - enable_if_t < is_detected::value&& - is_detected::value >> -{ - using object_t = typename BasicJsonType::object_t; - - // macOS's is_constructible does not play well with nonesuch... - static constexpr bool value = - is_constructible::value && - is_constructible::value; -}; - -template -struct is_compatible_object_type - : is_compatible_object_type_impl {}; - -template -struct is_constructible_object_type_impl : std::false_type {}; - -template -struct is_constructible_object_type_impl < - BasicJsonType, ConstructibleObjectType, - enable_if_t < is_detected::value&& - is_detected::value >> -{ - using object_t = typename BasicJsonType::object_t; - - static constexpr bool value = - (is_default_constructible::value && - (std::is_move_assignable::value || - std::is_copy_assignable::value) && - (is_constructible::value && - std::is_same < - typename object_t::mapped_type, - typename ConstructibleObjectType::mapped_type >::value)) || - (has_from_json::value || - has_non_default_from_json < - BasicJsonType, - typename ConstructibleObjectType::mapped_type >::value); -}; - -template -struct is_constructible_object_type - : is_constructible_object_type_impl {}; - -template -struct is_compatible_string_type -{ - static constexpr auto value = - is_constructible::value; -}; - -template -struct is_constructible_string_type -{ - static constexpr auto value = - is_constructible::value; -}; - -template -struct is_compatible_array_type_impl : std::false_type {}; - -template -struct is_compatible_array_type_impl < - BasicJsonType, CompatibleArrayType, - enable_if_t < - is_detected::value&& - is_iterator_traits>>::value&& -// special case for types like std::filesystem::path whose iterator's value_type are themselves -// c.f. https://github.com/nlohmann/json/pull/3073 - !std::is_same>::value >> -{ - static constexpr bool value = - is_constructible>::value; -}; - -template -struct is_compatible_array_type - : is_compatible_array_type_impl {}; - -template -struct is_constructible_array_type_impl : std::false_type {}; - -template -struct is_constructible_array_type_impl < - BasicJsonType, ConstructibleArrayType, - enable_if_t::value >> - : std::true_type {}; - -template -struct is_constructible_array_type_impl < - BasicJsonType, ConstructibleArrayType, - enable_if_t < !std::is_same::value&& - !is_compatible_string_type::value&& - is_default_constructible::value&& -(std::is_move_assignable::value || - std::is_copy_assignable::value)&& -is_detected::value&& -is_iterator_traits>>::value&& -is_detected::value&& -// special case for types like std::filesystem::path whose iterator's value_type are themselves -// c.f. https://github.com/nlohmann/json/pull/3073 -!std::is_same>::value&& - is_complete_type < - detected_t>::value >> -{ - using value_type = range_value_t; - - static constexpr bool value = - std::is_same::value || - has_from_json::value || - has_non_default_from_json < - BasicJsonType, - value_type >::value; -}; - -template -struct is_constructible_array_type - : is_constructible_array_type_impl {}; - -template -struct is_compatible_integer_type_impl : std::false_type {}; - -template -struct is_compatible_integer_type_impl < - RealIntegerType, CompatibleNumberIntegerType, - enable_if_t < std::is_integral::value&& - std::is_integral::value&& - !std::is_same::value >> -{ - // is there an assert somewhere on overflows? - using RealLimits = std::numeric_limits; - using CompatibleLimits = std::numeric_limits; - - static constexpr auto value = - is_constructible::value && - CompatibleLimits::is_integer && - RealLimits::is_signed == CompatibleLimits::is_signed; -}; - -template -struct is_compatible_integer_type - : is_compatible_integer_type_impl {}; - -template -struct is_compatible_type_impl: std::false_type {}; - -template -struct is_compatible_type_impl < - BasicJsonType, CompatibleType, - enable_if_t::value >> -{ - static constexpr bool value = - has_to_json::value; -}; - -template -struct is_compatible_type - : is_compatible_type_impl {}; - -template -struct is_constructible_tuple : std::false_type {}; - -template -struct is_constructible_tuple> : conjunction...> {}; - -// a naive helper to check if a type is an ordered_map (exploits the fact that -// ordered_map inherits capacity() from std::vector) -template -struct is_ordered_map -{ - using one = char; - - struct two - { - char x[2]; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) - }; - - template static one test( decltype(&C::capacity) ) ; - template static two test(...); - - enum { value = sizeof(test(nullptr)) == sizeof(char) }; // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) -}; - -// to avoid useless casts (see https://github.com/nlohmann/json/issues/2893#issuecomment-889152324) -template < typename T, typename U, enable_if_t < !std::is_same::value, int > = 0 > -T conditional_static_cast(U value) -{ - return static_cast(value); -} - -template::value, int> = 0> -T conditional_static_cast(U value) -{ - return value; -} - -} // namespace detail -} // namespace nlohmann - -// #include - - -#ifdef JSON_HAS_CPP_17 - #include -#endif - -namespace nlohmann -{ -namespace detail -{ -template -void from_json(const BasicJsonType& j, typename std::nullptr_t& n) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_null())) - { - JSON_THROW(type_error::create(302, "type must be null, but is " + std::string(j.type_name()), j)); - } - n = nullptr; -} - -// overloads for basic_json template parameters -template < typename BasicJsonType, typename ArithmeticType, - enable_if_t < std::is_arithmetic::value&& - !std::is_same::value, - int > = 0 > -void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val) -{ - switch (static_cast(j)) - { - case value_t::number_unsigned: - { - val = static_cast(*j.template get_ptr()); - break; - } - case value_t::number_integer: - { - val = static_cast(*j.template get_ptr()); - break; - } - case value_t::number_float: - { - val = static_cast(*j.template get_ptr()); - break; - } - - case value_t::null: - case value_t::object: - case value_t::array: - case value_t::string: - case value_t::boolean: - case value_t::binary: - case value_t::discarded: - default: - JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name()), j)); - } -} - -template -void from_json(const BasicJsonType& j, typename BasicJsonType::boolean_t& b) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_boolean())) - { - JSON_THROW(type_error::create(302, "type must be boolean, but is " + std::string(j.type_name()), j)); - } - b = *j.template get_ptr(); -} - -template -void from_json(const BasicJsonType& j, typename BasicJsonType::string_t& s) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_string())) - { - JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()), j)); - } - s = *j.template get_ptr(); -} - -template < - typename BasicJsonType, typename ConstructibleStringType, - enable_if_t < - is_constructible_string_type::value&& - !std::is_same::value, - int > = 0 > -void from_json(const BasicJsonType& j, ConstructibleStringType& s) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_string())) - { - JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()), j)); - } - - s = *j.template get_ptr(); -} - -template -void from_json(const BasicJsonType& j, typename BasicJsonType::number_float_t& val) -{ - get_arithmetic_value(j, val); -} - -template -void from_json(const BasicJsonType& j, typename BasicJsonType::number_unsigned_t& val) -{ - get_arithmetic_value(j, val); -} - -template -void from_json(const BasicJsonType& j, typename BasicJsonType::number_integer_t& val) -{ - get_arithmetic_value(j, val); -} - -template::value, int> = 0> -void from_json(const BasicJsonType& j, EnumType& e) -{ - typename std::underlying_type::type val; - get_arithmetic_value(j, val); - e = static_cast(val); -} - -// forward_list doesn't have an insert method -template::value, int> = 0> -void from_json(const BasicJsonType& j, std::forward_list& l) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_array())) - { - JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j)); - } - l.clear(); - std::transform(j.rbegin(), j.rend(), - std::front_inserter(l), [](const BasicJsonType & i) - { - return i.template get(); - }); -} - -// valarray doesn't have an insert method -template::value, int> = 0> -void from_json(const BasicJsonType& j, std::valarray& l) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_array())) - { - JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j)); - } - l.resize(j.size()); - std::transform(j.begin(), j.end(), std::begin(l), - [](const BasicJsonType & elem) - { - return elem.template get(); - }); -} - -template -auto from_json(const BasicJsonType& j, T (&arr)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) --> decltype(j.template get(), void()) -{ - for (std::size_t i = 0; i < N; ++i) - { - arr[i] = j.at(i).template get(); - } -} - -template -void from_json_array_impl(const BasicJsonType& j, typename BasicJsonType::array_t& arr, priority_tag<3> /*unused*/) -{ - arr = *j.template get_ptr(); -} - -template -auto from_json_array_impl(const BasicJsonType& j, std::array& arr, - priority_tag<2> /*unused*/) --> decltype(j.template get(), void()) -{ - for (std::size_t i = 0; i < N; ++i) - { - arr[i] = j.at(i).template get(); - } -} - -template::value, - int> = 0> -auto from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, priority_tag<1> /*unused*/) --> decltype( - arr.reserve(std::declval()), - j.template get(), - void()) -{ - using std::end; - - ConstructibleArrayType ret; - ret.reserve(j.size()); - std::transform(j.begin(), j.end(), - std::inserter(ret, end(ret)), [](const BasicJsonType & i) - { - // get() returns *this, this won't call a from_json - // method when value_type is BasicJsonType - return i.template get(); - }); - arr = std::move(ret); -} - -template::value, - int> = 0> -void from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, - priority_tag<0> /*unused*/) -{ - using std::end; - - ConstructibleArrayType ret; - std::transform( - j.begin(), j.end(), std::inserter(ret, end(ret)), - [](const BasicJsonType & i) - { - // get() returns *this, this won't call a from_json - // method when value_type is BasicJsonType - return i.template get(); - }); - arr = std::move(ret); -} - -template < typename BasicJsonType, typename ConstructibleArrayType, - enable_if_t < - is_constructible_array_type::value&& - !is_constructible_object_type::value&& - !is_constructible_string_type::value&& - !std::is_same::value&& - !is_basic_json::value, - int > = 0 > -auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr) --> decltype(from_json_array_impl(j, arr, priority_tag<3> {}), -j.template get(), -void()) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_array())) - { - JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j)); - } - - from_json_array_impl(j, arr, priority_tag<3> {}); -} - -template < typename BasicJsonType, typename T, std::size_t... Idx > -std::array from_json_inplace_array_impl(BasicJsonType&& j, - identity_tag> /*unused*/, index_sequence /*unused*/) -{ - return { { std::forward(j).at(Idx).template get()... } }; -} - -template < typename BasicJsonType, typename T, std::size_t N > -auto from_json(BasicJsonType&& j, identity_tag> tag) --> decltype(from_json_inplace_array_impl(std::forward(j), tag, make_index_sequence {})) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_array())) - { - JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j)); - } - - return from_json_inplace_array_impl(std::forward(j), tag, make_index_sequence {}); -} - -template -void from_json(const BasicJsonType& j, typename BasicJsonType::binary_t& bin) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_binary())) - { - JSON_THROW(type_error::create(302, "type must be binary, but is " + std::string(j.type_name()), j)); - } - - bin = *j.template get_ptr(); -} - -template::value, int> = 0> -void from_json(const BasicJsonType& j, ConstructibleObjectType& obj) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_object())) - { - JSON_THROW(type_error::create(302, "type must be object, but is " + std::string(j.type_name()), j)); - } - - ConstructibleObjectType ret; - const auto* inner_object = j.template get_ptr(); - using value_type = typename ConstructibleObjectType::value_type; - std::transform( - inner_object->begin(), inner_object->end(), - std::inserter(ret, ret.begin()), - [](typename BasicJsonType::object_t::value_type const & p) - { - return value_type(p.first, p.second.template get()); - }); - obj = std::move(ret); -} - -// overload for arithmetic types, not chosen for basic_json template arguments -// (BooleanType, etc..); note: Is it really necessary to provide explicit -// overloads for boolean_t etc. in case of a custom BooleanType which is not -// an arithmetic type? -template < typename BasicJsonType, typename ArithmeticType, - enable_if_t < - std::is_arithmetic::value&& - !std::is_same::value&& - !std::is_same::value&& - !std::is_same::value&& - !std::is_same::value, - int > = 0 > -void from_json(const BasicJsonType& j, ArithmeticType& val) -{ - switch (static_cast(j)) - { - case value_t::number_unsigned: - { - val = static_cast(*j.template get_ptr()); - break; - } - case value_t::number_integer: - { - val = static_cast(*j.template get_ptr()); - break; - } - case value_t::number_float: - { - val = static_cast(*j.template get_ptr()); - break; - } - case value_t::boolean: - { - val = static_cast(*j.template get_ptr()); - break; - } - - case value_t::null: - case value_t::object: - case value_t::array: - case value_t::string: - case value_t::binary: - case value_t::discarded: - default: - JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name()), j)); - } -} - -template -std::tuple from_json_tuple_impl_base(BasicJsonType&& j, index_sequence /*unused*/) -{ - return std::make_tuple(std::forward(j).at(Idx).template get()...); -} - -template < typename BasicJsonType, class A1, class A2 > -std::pair from_json_tuple_impl(BasicJsonType&& j, identity_tag> /*unused*/, priority_tag<0> /*unused*/) -{ - return {std::forward(j).at(0).template get(), - std::forward(j).at(1).template get()}; -} - -template -void from_json_tuple_impl(BasicJsonType&& j, std::pair& p, priority_tag<1> /*unused*/) -{ - p = from_json_tuple_impl(std::forward(j), identity_tag> {}, priority_tag<0> {}); -} - -template -std::tuple from_json_tuple_impl(BasicJsonType&& j, identity_tag> /*unused*/, priority_tag<2> /*unused*/) -{ - return from_json_tuple_impl_base(std::forward(j), index_sequence_for {}); -} - -template -void from_json_tuple_impl(BasicJsonType&& j, std::tuple& t, priority_tag<3> /*unused*/) -{ - t = from_json_tuple_impl_base(std::forward(j), index_sequence_for {}); -} - -template -auto from_json(BasicJsonType&& j, TupleRelated&& t) --> decltype(from_json_tuple_impl(std::forward(j), std::forward(t), priority_tag<3> {})) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_array())) - { - JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j)); - } - - return from_json_tuple_impl(std::forward(j), std::forward(t), priority_tag<3> {}); -} - -template < typename BasicJsonType, typename Key, typename Value, typename Compare, typename Allocator, - typename = enable_if_t < !std::is_constructible < - typename BasicJsonType::string_t, Key >::value >> -void from_json(const BasicJsonType& j, std::map& m) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_array())) - { - JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j)); - } - m.clear(); - for (const auto& p : j) - { - if (JSON_HEDLEY_UNLIKELY(!p.is_array())) - { - JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()), j)); - } - m.emplace(p.at(0).template get(), p.at(1).template get()); - } -} - -template < typename BasicJsonType, typename Key, typename Value, typename Hash, typename KeyEqual, typename Allocator, - typename = enable_if_t < !std::is_constructible < - typename BasicJsonType::string_t, Key >::value >> -void from_json(const BasicJsonType& j, std::unordered_map& m) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_array())) - { - JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j)); - } - m.clear(); - for (const auto& p : j) - { - if (JSON_HEDLEY_UNLIKELY(!p.is_array())) - { - JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()), j)); - } - m.emplace(p.at(0).template get(), p.at(1).template get()); - } -} - -#ifdef JSON_HAS_CPP_17 -template -void from_json(const BasicJsonType& j, std::filesystem::path& p) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_string())) - { - JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()), j)); - } - p = *j.template get_ptr(); -} -#endif - -struct from_json_fn -{ - template - auto operator()(const BasicJsonType& j, T&& val) const - noexcept(noexcept(from_json(j, std::forward(val)))) - -> decltype(from_json(j, std::forward(val))) - { - return from_json(j, std::forward(val)); - } -}; -} // namespace detail - -/// namespace to hold default `from_json` function -/// to see why this is required: -/// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4381.html -namespace // NOLINT(cert-dcl59-cpp,fuchsia-header-anon-namespaces,google-build-namespaces) -{ -constexpr const auto& from_json = detail::static_const::value; // NOLINT(misc-definitions-in-headers) -} // namespace -} // namespace nlohmann - -// #include - - -#include // copy -#include // begin, end -#include // string -#include // tuple, get -#include // is_same, is_constructible, is_floating_point, is_enum, underlying_type -#include // move, forward, declval, pair -#include // valarray -#include // vector - -// #include - -// #include - - -#include // size_t -#include // input_iterator_tag -#include // string, to_string -#include // tuple_size, get, tuple_element -#include // move - -// #include - -// #include - - -namespace nlohmann -{ -namespace detail -{ -template -void int_to_string( string_type& target, std::size_t value ) -{ - // For ADL - using std::to_string; - target = to_string(value); -} -template class iteration_proxy_value -{ - public: - using difference_type = std::ptrdiff_t; - using value_type = iteration_proxy_value; - using pointer = value_type * ; - using reference = value_type & ; - using iterator_category = std::input_iterator_tag; - using string_type = typename std::remove_cv< typename std::remove_reference().key() ) >::type >::type; - - private: - /// the iterator - IteratorType anchor; - /// an index for arrays (used to create key names) - std::size_t array_index = 0; - /// last stringified array index - mutable std::size_t array_index_last = 0; - /// a string representation of the array index - mutable string_type array_index_str = "0"; - /// an empty string (to return a reference for primitive values) - const string_type empty_str{}; - - public: - explicit iteration_proxy_value(IteratorType it) noexcept - : anchor(std::move(it)) - {} - - /// dereference operator (needed for range-based for) - iteration_proxy_value& operator*() - { - return *this; - } - - /// increment operator (needed for range-based for) - iteration_proxy_value& operator++() - { - ++anchor; - ++array_index; - - return *this; - } - - /// equality operator (needed for InputIterator) - bool operator==(const iteration_proxy_value& o) const - { - return anchor == o.anchor; - } - - /// inequality operator (needed for range-based for) - bool operator!=(const iteration_proxy_value& o) const - { - return anchor != o.anchor; - } - - /// return key of the iterator - const string_type& key() const - { - JSON_ASSERT(anchor.m_object != nullptr); - - switch (anchor.m_object->type()) - { - // use integer array index as key - case value_t::array: - { - if (array_index != array_index_last) - { - int_to_string( array_index_str, array_index ); - array_index_last = array_index; - } - return array_index_str; - } - - // use key from the object - case value_t::object: - return anchor.key(); - - // use an empty key for all primitive types - case value_t::null: - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - return empty_str; - } - } - - /// return value of the iterator - typename IteratorType::reference value() const - { - return anchor.value(); - } -}; - -/// proxy class for the items() function -template class iteration_proxy -{ - private: - /// the container to iterate - typename IteratorType::reference container; - - public: - /// construct iteration proxy from a container - explicit iteration_proxy(typename IteratorType::reference cont) noexcept - : container(cont) {} - - /// return iterator begin (needed for range-based for) - iteration_proxy_value begin() noexcept - { - return iteration_proxy_value(container.begin()); - } - - /// return iterator end (needed for range-based for) - iteration_proxy_value end() noexcept - { - return iteration_proxy_value(container.end()); - } -}; -// Structured Bindings Support -// For further reference see https://blog.tartanllama.xyz/structured-bindings/ -// And see https://github.com/nlohmann/json/pull/1391 -template = 0> -auto get(const nlohmann::detail::iteration_proxy_value& i) -> decltype(i.key()) -{ - return i.key(); -} -// Structured Bindings Support -// For further reference see https://blog.tartanllama.xyz/structured-bindings/ -// And see https://github.com/nlohmann/json/pull/1391 -template = 0> -auto get(const nlohmann::detail::iteration_proxy_value& i) -> decltype(i.value()) -{ - return i.value(); -} -} // namespace detail -} // namespace nlohmann - -// The Addition to the STD Namespace is required to add -// Structured Bindings Support to the iteration_proxy_value class -// For further reference see https://blog.tartanllama.xyz/structured-bindings/ -// And see https://github.com/nlohmann/json/pull/1391 -namespace std -{ -#if defined(__clang__) - // Fix: https://github.com/nlohmann/json/issues/1401 - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Wmismatched-tags" -#endif -template -class tuple_size<::nlohmann::detail::iteration_proxy_value> - : public std::integral_constant {}; - -template -class tuple_element> -{ - public: - using type = decltype( - get(std::declval < - ::nlohmann::detail::iteration_proxy_value> ())); -}; -#if defined(__clang__) - #pragma clang diagnostic pop -#endif -} // namespace std - -// #include - -// #include - -// #include - - -#ifdef JSON_HAS_CPP_17 - #include -#endif - -namespace nlohmann -{ -namespace detail -{ -////////////////// -// constructors // -////////////////// - -/* - * Note all external_constructor<>::construct functions need to call - * j.m_value.destroy(j.m_type) to avoid a memory leak in case j contains an - * allocated value (e.g., a string). See bug issue - * https://github.com/nlohmann/json/issues/2865 for more information. - */ - -template struct external_constructor; - -template<> -struct external_constructor -{ - template - static void construct(BasicJsonType& j, typename BasicJsonType::boolean_t b) noexcept - { - j.m_value.destroy(j.m_type); - j.m_type = value_t::boolean; - j.m_value = b; - j.assert_invariant(); - } -}; - -template<> -struct external_constructor -{ - template - static void construct(BasicJsonType& j, const typename BasicJsonType::string_t& s) - { - j.m_value.destroy(j.m_type); - j.m_type = value_t::string; - j.m_value = s; - j.assert_invariant(); - } - - template - static void construct(BasicJsonType& j, typename BasicJsonType::string_t&& s) - { - j.m_value.destroy(j.m_type); - j.m_type = value_t::string; - j.m_value = std::move(s); - j.assert_invariant(); - } - - template < typename BasicJsonType, typename CompatibleStringType, - enable_if_t < !std::is_same::value, - int > = 0 > - static void construct(BasicJsonType& j, const CompatibleStringType& str) - { - j.m_value.destroy(j.m_type); - j.m_type = value_t::string; - j.m_value.string = j.template create(str); - j.assert_invariant(); - } -}; - -template<> -struct external_constructor -{ - template - static void construct(BasicJsonType& j, const typename BasicJsonType::binary_t& b) - { - j.m_value.destroy(j.m_type); - j.m_type = value_t::binary; - j.m_value = typename BasicJsonType::binary_t(b); - j.assert_invariant(); - } - - template - static void construct(BasicJsonType& j, typename BasicJsonType::binary_t&& b) - { - j.m_value.destroy(j.m_type); - j.m_type = value_t::binary; - j.m_value = typename BasicJsonType::binary_t(std::move(b)); - j.assert_invariant(); - } -}; - -template<> -struct external_constructor -{ - template - static void construct(BasicJsonType& j, typename BasicJsonType::number_float_t val) noexcept - { - j.m_value.destroy(j.m_type); - j.m_type = value_t::number_float; - j.m_value = val; - j.assert_invariant(); - } -}; - -template<> -struct external_constructor -{ - template - static void construct(BasicJsonType& j, typename BasicJsonType::number_unsigned_t val) noexcept - { - j.m_value.destroy(j.m_type); - j.m_type = value_t::number_unsigned; - j.m_value = val; - j.assert_invariant(); - } -}; - -template<> -struct external_constructor -{ - template - static void construct(BasicJsonType& j, typename BasicJsonType::number_integer_t val) noexcept - { - j.m_value.destroy(j.m_type); - j.m_type = value_t::number_integer; - j.m_value = val; - j.assert_invariant(); - } -}; - -template<> -struct external_constructor -{ - template - static void construct(BasicJsonType& j, const typename BasicJsonType::array_t& arr) - { - j.m_value.destroy(j.m_type); - j.m_type = value_t::array; - j.m_value = arr; - j.set_parents(); - j.assert_invariant(); - } - - template - static void construct(BasicJsonType& j, typename BasicJsonType::array_t&& arr) - { - j.m_value.destroy(j.m_type); - j.m_type = value_t::array; - j.m_value = std::move(arr); - j.set_parents(); - j.assert_invariant(); - } - - template < typename BasicJsonType, typename CompatibleArrayType, - enable_if_t < !std::is_same::value, - int > = 0 > - static void construct(BasicJsonType& j, const CompatibleArrayType& arr) - { - using std::begin; - using std::end; - - j.m_value.destroy(j.m_type); - j.m_type = value_t::array; - j.m_value.array = j.template create(begin(arr), end(arr)); - j.set_parents(); - j.assert_invariant(); - } - - template - static void construct(BasicJsonType& j, const std::vector& arr) - { - j.m_value.destroy(j.m_type); - j.m_type = value_t::array; - j.m_value = value_t::array; - j.m_value.array->reserve(arr.size()); - for (const bool x : arr) - { - j.m_value.array->push_back(x); - j.set_parent(j.m_value.array->back()); - } - j.assert_invariant(); - } - - template::value, int> = 0> - static void construct(BasicJsonType& j, const std::valarray& arr) - { - j.m_value.destroy(j.m_type); - j.m_type = value_t::array; - j.m_value = value_t::array; - j.m_value.array->resize(arr.size()); - if (arr.size() > 0) - { - std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin()); - } - j.set_parents(); - j.assert_invariant(); - } -}; - -template<> -struct external_constructor -{ - template - static void construct(BasicJsonType& j, const typename BasicJsonType::object_t& obj) - { - j.m_value.destroy(j.m_type); - j.m_type = value_t::object; - j.m_value = obj; - j.set_parents(); - j.assert_invariant(); - } - - template - static void construct(BasicJsonType& j, typename BasicJsonType::object_t&& obj) - { - j.m_value.destroy(j.m_type); - j.m_type = value_t::object; - j.m_value = std::move(obj); - j.set_parents(); - j.assert_invariant(); - } - - template < typename BasicJsonType, typename CompatibleObjectType, - enable_if_t < !std::is_same::value, int > = 0 > - static void construct(BasicJsonType& j, const CompatibleObjectType& obj) - { - using std::begin; - using std::end; - - j.m_value.destroy(j.m_type); - j.m_type = value_t::object; - j.m_value.object = j.template create(begin(obj), end(obj)); - j.set_parents(); - j.assert_invariant(); - } -}; - -///////////// -// to_json // -///////////// - -template::value, int> = 0> -void to_json(BasicJsonType& j, T b) noexcept -{ - external_constructor::construct(j, b); -} - -template::value, int> = 0> -void to_json(BasicJsonType& j, const CompatibleString& s) -{ - external_constructor::construct(j, s); -} - -template -void to_json(BasicJsonType& j, typename BasicJsonType::string_t&& s) -{ - external_constructor::construct(j, std::move(s)); -} - -template::value, int> = 0> -void to_json(BasicJsonType& j, FloatType val) noexcept -{ - external_constructor::construct(j, static_cast(val)); -} - -template::value, int> = 0> -void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noexcept -{ - external_constructor::construct(j, static_cast(val)); -} - -template::value, int> = 0> -void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noexcept -{ - external_constructor::construct(j, static_cast(val)); -} - -template::value, int> = 0> -void to_json(BasicJsonType& j, EnumType e) noexcept -{ - using underlying_type = typename std::underlying_type::type; - external_constructor::construct(j, static_cast(e)); -} - -template -void to_json(BasicJsonType& j, const std::vector& e) -{ - external_constructor::construct(j, e); -} - -template < typename BasicJsonType, typename CompatibleArrayType, - enable_if_t < is_compatible_array_type::value&& - !is_compatible_object_type::value&& - !is_compatible_string_type::value&& - !std::is_same::value&& - !is_basic_json::value, - int > = 0 > -void to_json(BasicJsonType& j, const CompatibleArrayType& arr) -{ - external_constructor::construct(j, arr); -} - -template -void to_json(BasicJsonType& j, const typename BasicJsonType::binary_t& bin) -{ - external_constructor::construct(j, bin); -} - -template::value, int> = 0> -void to_json(BasicJsonType& j, const std::valarray& arr) -{ - external_constructor::construct(j, std::move(arr)); -} - -template -void to_json(BasicJsonType& j, typename BasicJsonType::array_t&& arr) -{ - external_constructor::construct(j, std::move(arr)); -} - -template < typename BasicJsonType, typename CompatibleObjectType, - enable_if_t < is_compatible_object_type::value&& !is_basic_json::value, int > = 0 > -void to_json(BasicJsonType& j, const CompatibleObjectType& obj) -{ - external_constructor::construct(j, obj); -} - -template -void to_json(BasicJsonType& j, typename BasicJsonType::object_t&& obj) -{ - external_constructor::construct(j, std::move(obj)); -} - -template < - typename BasicJsonType, typename T, std::size_t N, - enable_if_t < !std::is_constructible::value, // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) - int > = 0 > -void to_json(BasicJsonType& j, const T(&arr)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) -{ - external_constructor::construct(j, arr); -} - -template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible::value&& std::is_constructible::value, int > = 0 > -void to_json(BasicJsonType& j, const std::pair& p) -{ - j = { p.first, p.second }; -} - -// for https://github.com/nlohmann/json/pull/1134 -template>::value, int> = 0> -void to_json(BasicJsonType& j, const T& b) -{ - j = { {b.key(), b.value()} }; -} - -template -void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequence /*unused*/) -{ - j = { std::get(t)... }; -} - -template::value, int > = 0> -void to_json(BasicJsonType& j, const T& t) -{ - to_json_tuple_impl(j, t, make_index_sequence::value> {}); -} - -#ifdef JSON_HAS_CPP_17 -template -void to_json(BasicJsonType& j, const std::filesystem::path& p) -{ - j = p.string(); -} -#endif - -struct to_json_fn -{ - template - auto operator()(BasicJsonType& j, T&& val) const noexcept(noexcept(to_json(j, std::forward(val)))) - -> decltype(to_json(j, std::forward(val)), void()) - { - return to_json(j, std::forward(val)); - } -}; -} // namespace detail - -/// namespace to hold default `to_json` function -/// to see why this is required: -/// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4381.html -namespace // NOLINT(cert-dcl59-cpp,fuchsia-header-anon-namespaces,google-build-namespaces) -{ -constexpr const auto& to_json = detail::static_const::value; // NOLINT(misc-definitions-in-headers) -} // namespace -} // namespace nlohmann - -// #include - -// #include - - -namespace nlohmann -{ - -template -struct adl_serializer -{ - /*! - @brief convert a JSON value to any value type - - This function is usually called by the `get()` function of the - @ref basic_json class (either explicit or via conversion operators). - - @note This function is chosen for default-constructible value types. - - @param[in] j JSON value to read from - @param[in,out] val value to write to - */ - template - static auto from_json(BasicJsonType && j, TargetType& val) noexcept( - noexcept(::nlohmann::from_json(std::forward(j), val))) - -> decltype(::nlohmann::from_json(std::forward(j), val), void()) - { - ::nlohmann::from_json(std::forward(j), val); - } - - /*! - @brief convert a JSON value to any value type - - This function is usually called by the `get()` function of the - @ref basic_json class (either explicit or via conversion operators). - - @note This function is chosen for value types which are not default-constructible. - - @param[in] j JSON value to read from - - @return copy of the JSON value, converted to @a ValueType - */ - template - static auto from_json(BasicJsonType && j) noexcept( - noexcept(::nlohmann::from_json(std::forward(j), detail::identity_tag {}))) - -> decltype(::nlohmann::from_json(std::forward(j), detail::identity_tag {})) - { - return ::nlohmann::from_json(std::forward(j), detail::identity_tag {}); - } - - /*! - @brief convert any value type to a JSON value - - This function is usually called by the constructors of the @ref basic_json - class. - - @param[in,out] j JSON value to write to - @param[in] val value to read from - */ - template - static auto to_json(BasicJsonType& j, TargetType && val) noexcept( - noexcept(::nlohmann::to_json(j, std::forward(val)))) - -> decltype(::nlohmann::to_json(j, std::forward(val)), void()) - { - ::nlohmann::to_json(j, std::forward(val)); - } -}; -} // namespace nlohmann - -// #include - - -#include // uint8_t, uint64_t -#include // tie -#include // move - -namespace nlohmann -{ - -/*! -@brief an internal type for a backed binary type - -This type extends the template parameter @a BinaryType provided to `basic_json` -with a subtype used by BSON and MessagePack. This type exists so that the user -does not have to specify a type themselves with a specific naming scheme in -order to override the binary type. - -@tparam BinaryType container to store bytes (`std::vector` by - default) - -@since version 3.8.0; changed type of subtypes to std::uint64_t in 3.10.0. -*/ -template -class byte_container_with_subtype : public BinaryType -{ - public: - /// the type of the underlying container - using container_type = BinaryType; - /// the type of the subtype - using subtype_type = std::uint64_t; - - byte_container_with_subtype() noexcept(noexcept(container_type())) - : container_type() - {} - - byte_container_with_subtype(const container_type& b) noexcept(noexcept(container_type(b))) - : container_type(b) - {} - - byte_container_with_subtype(container_type&& b) noexcept(noexcept(container_type(std::move(b)))) - : container_type(std::move(b)) - {} - - byte_container_with_subtype(const container_type& b, subtype_type subtype_) noexcept(noexcept(container_type(b))) - : container_type(b) - , m_subtype(subtype_) - , m_has_subtype(true) - {} - - byte_container_with_subtype(container_type&& b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b)))) - : container_type(std::move(b)) - , m_subtype(subtype_) - , m_has_subtype(true) - {} - - bool operator==(const byte_container_with_subtype& rhs) const - { - return std::tie(static_cast(*this), m_subtype, m_has_subtype) == - std::tie(static_cast(rhs), rhs.m_subtype, rhs.m_has_subtype); - } - - bool operator!=(const byte_container_with_subtype& rhs) const - { - return !(rhs == *this); - } - - /*! - @brief sets the binary subtype - - Sets the binary subtype of the value, also flags a binary JSON value as - having a subtype, which has implications for serialization. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @sa see @ref subtype() -- return the binary subtype - @sa see @ref clear_subtype() -- clears the binary subtype - @sa see @ref has_subtype() -- returns whether or not the binary value has a - subtype - - @since version 3.8.0 - */ - void set_subtype(subtype_type subtype_) noexcept - { - m_subtype = subtype_; - m_has_subtype = true; - } - - /*! - @brief return the binary subtype - - Returns the numerical subtype of the value if it has a subtype. If it does - not have a subtype, this function will return subtype_type(-1) as a sentinel - value. - - @return the numerical subtype of the binary value - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @sa see @ref set_subtype() -- sets the binary subtype - @sa see @ref clear_subtype() -- clears the binary subtype - @sa see @ref has_subtype() -- returns whether or not the binary value has a - subtype - - @since version 3.8.0; fixed return value to properly return - subtype_type(-1) as documented in version 3.10.0 - */ - constexpr subtype_type subtype() const noexcept - { - return m_has_subtype ? m_subtype : subtype_type(-1); - } - - /*! - @brief return whether the value has a subtype - - @return whether the value has a subtype - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @sa see @ref subtype() -- return the binary subtype - @sa see @ref set_subtype() -- sets the binary subtype - @sa see @ref clear_subtype() -- clears the binary subtype - - @since version 3.8.0 - */ - constexpr bool has_subtype() const noexcept - { - return m_has_subtype; - } - - /*! - @brief clears the binary subtype - - Clears the binary subtype and flags the value as not having a subtype, which - has implications for serialization; for instance MessagePack will prefer the - bin family over the ext family. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @sa see @ref subtype() -- return the binary subtype - @sa see @ref set_subtype() -- sets the binary subtype - @sa see @ref has_subtype() -- returns whether or not the binary value has a - subtype - - @since version 3.8.0 - */ - void clear_subtype() noexcept - { - m_subtype = 0; - m_has_subtype = false; - } - - private: - subtype_type m_subtype = 0; - bool m_has_subtype = false; -}; - -} // namespace nlohmann - -// #include - -// #include - -// #include - -// #include - - -#include // uint8_t -#include // size_t -#include // hash - -// #include - -// #include - - -namespace nlohmann -{ -namespace detail -{ - -// boost::hash_combine -inline std::size_t combine(std::size_t seed, std::size_t h) noexcept -{ - seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U); - return seed; -} - -/*! -@brief hash a JSON value - -The hash function tries to rely on std::hash where possible. Furthermore, the -type of the JSON value is taken into account to have different hash values for -null, 0, 0U, and false, etc. - -@tparam BasicJsonType basic_json specialization -@param j JSON value to hash -@return hash value of j -*/ -template -std::size_t hash(const BasicJsonType& j) -{ - using string_t = typename BasicJsonType::string_t; - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - - const auto type = static_cast(j.type()); - switch (j.type()) - { - case BasicJsonType::value_t::null: - case BasicJsonType::value_t::discarded: - { - return combine(type, 0); - } - - case BasicJsonType::value_t::object: - { - auto seed = combine(type, j.size()); - for (const auto& element : j.items()) - { - const auto h = std::hash {}(element.key()); - seed = combine(seed, h); - seed = combine(seed, hash(element.value())); - } - return seed; - } - - case BasicJsonType::value_t::array: - { - auto seed = combine(type, j.size()); - for (const auto& element : j) - { - seed = combine(seed, hash(element)); - } - return seed; - } - - case BasicJsonType::value_t::string: - { - const auto h = std::hash {}(j.template get_ref()); - return combine(type, h); - } - - case BasicJsonType::value_t::boolean: - { - const auto h = std::hash {}(j.template get()); - return combine(type, h); - } - - case BasicJsonType::value_t::number_integer: - { - const auto h = std::hash {}(j.template get()); - return combine(type, h); - } - - case BasicJsonType::value_t::number_unsigned: - { - const auto h = std::hash {}(j.template get()); - return combine(type, h); - } - - case BasicJsonType::value_t::number_float: - { - const auto h = std::hash {}(j.template get()); - return combine(type, h); - } - - case BasicJsonType::value_t::binary: - { - auto seed = combine(type, j.get_binary().size()); - const auto h = std::hash {}(j.get_binary().has_subtype()); - seed = combine(seed, h); - seed = combine(seed, static_cast(j.get_binary().subtype())); - for (const auto byte : j.get_binary()) - { - seed = combine(seed, std::hash {}(byte)); - } - return seed; - } - - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE - return 0; // LCOV_EXCL_LINE - } -} - -} // namespace detail -} // namespace nlohmann - -// #include - - -#include // generate_n -#include // array -#include // ldexp -#include // size_t -#include // uint8_t, uint16_t, uint32_t, uint64_t -#include // snprintf -#include // memcpy -#include // back_inserter -#include // numeric_limits -#include // char_traits, string -#include // make_pair, move -#include // vector - -// #include - -// #include - - -#include // array -#include // size_t -#include // strlen -#include // begin, end, iterator_traits, random_access_iterator_tag, distance, next -#include // shared_ptr, make_shared, addressof -#include // accumulate -#include // string, char_traits -#include // enable_if, is_base_of, is_pointer, is_integral, remove_pointer -#include // pair, declval - -#ifndef JSON_NO_IO - #include // FILE * - #include // istream -#endif // JSON_NO_IO - -// #include - -// #include - - -namespace nlohmann -{ -namespace detail -{ -/// the supported input formats -enum class input_format_t { json, cbor, msgpack, ubjson, bson }; - -//////////////////// -// input adapters // -//////////////////// - -#ifndef JSON_NO_IO -/*! -Input adapter for stdio file access. This adapter read only 1 byte and do not use any - buffer. This adapter is a very low level adapter. -*/ -class file_input_adapter -{ - public: - using char_type = char; - - JSON_HEDLEY_NON_NULL(2) - explicit file_input_adapter(std::FILE* f) noexcept - : m_file(f) - {} - - // make class move-only - file_input_adapter(const file_input_adapter&) = delete; - file_input_adapter(file_input_adapter&&) noexcept = default; - file_input_adapter& operator=(const file_input_adapter&) = delete; - file_input_adapter& operator=(file_input_adapter&&) = delete; - ~file_input_adapter() = default; - - std::char_traits::int_type get_character() noexcept - { - return std::fgetc(m_file); - } - - private: - /// the file pointer to read from - std::FILE* m_file; -}; - - -/*! -Input adapter for a (caching) istream. Ignores a UFT Byte Order Mark at -beginning of input. Does not support changing the underlying std::streambuf -in mid-input. Maintains underlying std::istream and std::streambuf to support -subsequent use of standard std::istream operations to process any input -characters following those used in parsing the JSON input. Clears the -std::istream flags; any input errors (e.g., EOF) will be detected by the first -subsequent call for input from the std::istream. -*/ -class input_stream_adapter -{ - public: - using char_type = char; - - ~input_stream_adapter() - { - // clear stream flags; we use underlying streambuf I/O, do not - // maintain ifstream flags, except eof - if (is != nullptr) - { - is->clear(is->rdstate() & std::ios::eofbit); - } - } - - explicit input_stream_adapter(std::istream& i) - : is(&i), sb(i.rdbuf()) - {} - - // delete because of pointer members - input_stream_adapter(const input_stream_adapter&) = delete; - input_stream_adapter& operator=(input_stream_adapter&) = delete; - input_stream_adapter& operator=(input_stream_adapter&&) = delete; - - input_stream_adapter(input_stream_adapter&& rhs) noexcept - : is(rhs.is), sb(rhs.sb) - { - rhs.is = nullptr; - rhs.sb = nullptr; - } - - // std::istream/std::streambuf use std::char_traits::to_int_type, to - // ensure that std::char_traits::eof() and the character 0xFF do not - // end up as the same value, eg. 0xFFFFFFFF. - std::char_traits::int_type get_character() - { - auto res = sb->sbumpc(); - // set eof manually, as we don't use the istream interface. - if (JSON_HEDLEY_UNLIKELY(res == std::char_traits::eof())) - { - is->clear(is->rdstate() | std::ios::eofbit); - } - return res; - } - - private: - /// the associated input stream - std::istream* is = nullptr; - std::streambuf* sb = nullptr; -}; -#endif // JSON_NO_IO - -// General-purpose iterator-based adapter. It might not be as fast as -// theoretically possible for some containers, but it is extremely versatile. -template -class iterator_input_adapter -{ - public: - using char_type = typename std::iterator_traits::value_type; - - iterator_input_adapter(IteratorType first, IteratorType last) - : current(std::move(first)), end(std::move(last)) - {} - - typename std::char_traits::int_type get_character() - { - if (JSON_HEDLEY_LIKELY(current != end)) - { - auto result = std::char_traits::to_int_type(*current); - std::advance(current, 1); - return result; - } - - return std::char_traits::eof(); - } - - private: - IteratorType current; - IteratorType end; - - template - friend struct wide_string_input_helper; - - bool empty() const - { - return current == end; - } -}; - - -template -struct wide_string_input_helper; - -template -struct wide_string_input_helper -{ - // UTF-32 - static void fill_buffer(BaseInputAdapter& input, - std::array::int_type, 4>& utf8_bytes, - size_t& utf8_bytes_index, - size_t& utf8_bytes_filled) - { - utf8_bytes_index = 0; - - if (JSON_HEDLEY_UNLIKELY(input.empty())) - { - utf8_bytes[0] = std::char_traits::eof(); - utf8_bytes_filled = 1; - } - else - { - // get the current character - const auto wc = input.get_character(); - - // UTF-32 to UTF-8 encoding - if (wc < 0x80) - { - utf8_bytes[0] = static_cast::int_type>(wc); - utf8_bytes_filled = 1; - } - else if (wc <= 0x7FF) - { - utf8_bytes[0] = static_cast::int_type>(0xC0u | ((static_cast(wc) >> 6u) & 0x1Fu)); - utf8_bytes[1] = static_cast::int_type>(0x80u | (static_cast(wc) & 0x3Fu)); - utf8_bytes_filled = 2; - } - else if (wc <= 0xFFFF) - { - utf8_bytes[0] = static_cast::int_type>(0xE0u | ((static_cast(wc) >> 12u) & 0x0Fu)); - utf8_bytes[1] = static_cast::int_type>(0x80u | ((static_cast(wc) >> 6u) & 0x3Fu)); - utf8_bytes[2] = static_cast::int_type>(0x80u | (static_cast(wc) & 0x3Fu)); - utf8_bytes_filled = 3; - } - else if (wc <= 0x10FFFF) - { - utf8_bytes[0] = static_cast::int_type>(0xF0u | ((static_cast(wc) >> 18u) & 0x07u)); - utf8_bytes[1] = static_cast::int_type>(0x80u | ((static_cast(wc) >> 12u) & 0x3Fu)); - utf8_bytes[2] = static_cast::int_type>(0x80u | ((static_cast(wc) >> 6u) & 0x3Fu)); - utf8_bytes[3] = static_cast::int_type>(0x80u | (static_cast(wc) & 0x3Fu)); - utf8_bytes_filled = 4; - } - else - { - // unknown character - utf8_bytes[0] = static_cast::int_type>(wc); - utf8_bytes_filled = 1; - } - } - } -}; - -template -struct wide_string_input_helper -{ - // UTF-16 - static void fill_buffer(BaseInputAdapter& input, - std::array::int_type, 4>& utf8_bytes, - size_t& utf8_bytes_index, - size_t& utf8_bytes_filled) - { - utf8_bytes_index = 0; - - if (JSON_HEDLEY_UNLIKELY(input.empty())) - { - utf8_bytes[0] = std::char_traits::eof(); - utf8_bytes_filled = 1; - } - else - { - // get the current character - const auto wc = input.get_character(); - - // UTF-16 to UTF-8 encoding - if (wc < 0x80) - { - utf8_bytes[0] = static_cast::int_type>(wc); - utf8_bytes_filled = 1; - } - else if (wc <= 0x7FF) - { - utf8_bytes[0] = static_cast::int_type>(0xC0u | ((static_cast(wc) >> 6u))); - utf8_bytes[1] = static_cast::int_type>(0x80u | (static_cast(wc) & 0x3Fu)); - utf8_bytes_filled = 2; - } - else if (0xD800 > wc || wc >= 0xE000) - { - utf8_bytes[0] = static_cast::int_type>(0xE0u | ((static_cast(wc) >> 12u))); - utf8_bytes[1] = static_cast::int_type>(0x80u | ((static_cast(wc) >> 6u) & 0x3Fu)); - utf8_bytes[2] = static_cast::int_type>(0x80u | (static_cast(wc) & 0x3Fu)); - utf8_bytes_filled = 3; - } - else - { - if (JSON_HEDLEY_UNLIKELY(!input.empty())) - { - const auto wc2 = static_cast(input.get_character()); - const auto charcode = 0x10000u + (((static_cast(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu)); - utf8_bytes[0] = static_cast::int_type>(0xF0u | (charcode >> 18u)); - utf8_bytes[1] = static_cast::int_type>(0x80u | ((charcode >> 12u) & 0x3Fu)); - utf8_bytes[2] = static_cast::int_type>(0x80u | ((charcode >> 6u) & 0x3Fu)); - utf8_bytes[3] = static_cast::int_type>(0x80u | (charcode & 0x3Fu)); - utf8_bytes_filled = 4; - } - else - { - utf8_bytes[0] = static_cast::int_type>(wc); - utf8_bytes_filled = 1; - } - } - } - } -}; - -// Wraps another input apdater to convert wide character types into individual bytes. -template -class wide_string_input_adapter -{ - public: - using char_type = char; - - wide_string_input_adapter(BaseInputAdapter base) - : base_adapter(base) {} - - typename std::char_traits::int_type get_character() noexcept - { - // check if buffer needs to be filled - if (utf8_bytes_index == utf8_bytes_filled) - { - fill_buffer(); - - JSON_ASSERT(utf8_bytes_filled > 0); - JSON_ASSERT(utf8_bytes_index == 0); - } - - // use buffer - JSON_ASSERT(utf8_bytes_filled > 0); - JSON_ASSERT(utf8_bytes_index < utf8_bytes_filled); - return utf8_bytes[utf8_bytes_index++]; - } - - private: - BaseInputAdapter base_adapter; - - template - void fill_buffer() - { - wide_string_input_helper::fill_buffer(base_adapter, utf8_bytes, utf8_bytes_index, utf8_bytes_filled); - } - - /// a buffer for UTF-8 bytes - std::array::int_type, 4> utf8_bytes = {{0, 0, 0, 0}}; - - /// index to the utf8_codes array for the next valid byte - std::size_t utf8_bytes_index = 0; - /// number of valid bytes in the utf8_codes array - std::size_t utf8_bytes_filled = 0; -}; - - -template -struct iterator_input_adapter_factory -{ - using iterator_type = IteratorType; - using char_type = typename std::iterator_traits::value_type; - using adapter_type = iterator_input_adapter; - - static adapter_type create(IteratorType first, IteratorType last) - { - return adapter_type(std::move(first), std::move(last)); - } -}; - -template -struct is_iterator_of_multibyte -{ - using value_type = typename std::iterator_traits::value_type; - enum - { - value = sizeof(value_type) > 1 - }; -}; - -template -struct iterator_input_adapter_factory::value>> -{ - using iterator_type = IteratorType; - using char_type = typename std::iterator_traits::value_type; - using base_adapter_type = iterator_input_adapter; - using adapter_type = wide_string_input_adapter; - - static adapter_type create(IteratorType first, IteratorType last) - { - return adapter_type(base_adapter_type(std::move(first), std::move(last))); - } -}; - -// General purpose iterator-based input -template -typename iterator_input_adapter_factory::adapter_type input_adapter(IteratorType first, IteratorType last) -{ - using factory_type = iterator_input_adapter_factory; - return factory_type::create(first, last); -} - -// Convenience shorthand from container to iterator -// Enables ADL on begin(container) and end(container) -// Encloses the using declarations in namespace for not to leak them to outside scope - -namespace container_input_adapter_factory_impl -{ - -using std::begin; -using std::end; - -template -struct container_input_adapter_factory {}; - -template -struct container_input_adapter_factory< ContainerType, - void_t()), end(std::declval()))>> - { - using adapter_type = decltype(input_adapter(begin(std::declval()), end(std::declval()))); - - static adapter_type create(const ContainerType& container) -{ - return input_adapter(begin(container), end(container)); -} - }; - -} // namespace container_input_adapter_factory_impl - -template -typename container_input_adapter_factory_impl::container_input_adapter_factory::adapter_type input_adapter(const ContainerType& container) -{ - return container_input_adapter_factory_impl::container_input_adapter_factory::create(container); -} - -#ifndef JSON_NO_IO -// Special cases with fast paths -inline file_input_adapter input_adapter(std::FILE* file) -{ - return file_input_adapter(file); -} - -inline input_stream_adapter input_adapter(std::istream& stream) -{ - return input_stream_adapter(stream); -} - -inline input_stream_adapter input_adapter(std::istream&& stream) -{ - return input_stream_adapter(stream); -} -#endif // JSON_NO_IO - -using contiguous_bytes_input_adapter = decltype(input_adapter(std::declval(), std::declval())); - -// Null-delimited strings, and the like. -template < typename CharT, - typename std::enable_if < - std::is_pointer::value&& - !std::is_array::value&& - std::is_integral::type>::value&& - sizeof(typename std::remove_pointer::type) == 1, - int >::type = 0 > -contiguous_bytes_input_adapter input_adapter(CharT b) -{ - auto length = std::strlen(reinterpret_cast(b)); - const auto* ptr = reinterpret_cast(b); - return input_adapter(ptr, ptr + length); -} - -template -auto input_adapter(T (&array)[N]) -> decltype(input_adapter(array, array + N)) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) -{ - return input_adapter(array, array + N); -} - -// This class only handles inputs of input_buffer_adapter type. -// It's required so that expressions like {ptr, len} can be implicitely casted -// to the correct adapter. -class span_input_adapter -{ - public: - template < typename CharT, - typename std::enable_if < - std::is_pointer::value&& - std::is_integral::type>::value&& - sizeof(typename std::remove_pointer::type) == 1, - int >::type = 0 > - span_input_adapter(CharT b, std::size_t l) - : ia(reinterpret_cast(b), reinterpret_cast(b) + l) {} - - template::iterator_category, std::random_access_iterator_tag>::value, - int>::type = 0> - span_input_adapter(IteratorType first, IteratorType last) - : ia(input_adapter(first, last)) {} - - contiguous_bytes_input_adapter&& get() - { - return std::move(ia); // NOLINT(hicpp-move-const-arg,performance-move-const-arg) - } - - private: - contiguous_bytes_input_adapter ia; -}; -} // namespace detail -} // namespace nlohmann - -// #include - - -#include -#include // string -#include // move -#include // vector - -// #include - -// #include - - -namespace nlohmann -{ - -/*! -@brief SAX interface - -This class describes the SAX interface used by @ref nlohmann::json::sax_parse. -Each function is called in different situations while the input is parsed. The -boolean return value informs the parser whether to continue processing the -input. -*/ -template -struct json_sax -{ - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using binary_t = typename BasicJsonType::binary_t; - - /*! - @brief a null value was read - @return whether parsing should proceed - */ - virtual bool null() = 0; - - /*! - @brief a boolean value was read - @param[in] val boolean value - @return whether parsing should proceed - */ - virtual bool boolean(bool val) = 0; - - /*! - @brief an integer number was read - @param[in] val integer value - @return whether parsing should proceed - */ - virtual bool number_integer(number_integer_t val) = 0; - - /*! - @brief an unsigned integer number was read - @param[in] val unsigned integer value - @return whether parsing should proceed - */ - virtual bool number_unsigned(number_unsigned_t val) = 0; - - /*! - @brief an floating-point number was read - @param[in] val floating-point value - @param[in] s raw token value - @return whether parsing should proceed - */ - virtual bool number_float(number_float_t val, const string_t& s) = 0; - - /*! - @brief a string was read - @param[in] val string value - @return whether parsing should proceed - @note It is safe to move the passed string. - */ - virtual bool string(string_t& val) = 0; - - /*! - @brief a binary string was read - @param[in] val binary value - @return whether parsing should proceed - @note It is safe to move the passed binary. - */ - virtual bool binary(binary_t& val) = 0; - - /*! - @brief the beginning of an object was read - @param[in] elements number of object elements or -1 if unknown - @return whether parsing should proceed - @note binary formats may report the number of elements - */ - virtual bool start_object(std::size_t elements) = 0; - - /*! - @brief an object key was read - @param[in] val object key - @return whether parsing should proceed - @note It is safe to move the passed string. - */ - virtual bool key(string_t& val) = 0; - - /*! - @brief the end of an object was read - @return whether parsing should proceed - */ - virtual bool end_object() = 0; - - /*! - @brief the beginning of an array was read - @param[in] elements number of array elements or -1 if unknown - @return whether parsing should proceed - @note binary formats may report the number of elements - */ - virtual bool start_array(std::size_t elements) = 0; - - /*! - @brief the end of an array was read - @return whether parsing should proceed - */ - virtual bool end_array() = 0; - - /*! - @brief a parse error occurred - @param[in] position the position in the input where the error occurs - @param[in] last_token the last read token - @param[in] ex an exception object describing the error - @return whether parsing should proceed (must return false) - */ - virtual bool parse_error(std::size_t position, - const std::string& last_token, - const detail::exception& ex) = 0; - - json_sax() = default; - json_sax(const json_sax&) = default; - json_sax(json_sax&&) noexcept = default; - json_sax& operator=(const json_sax&) = default; - json_sax& operator=(json_sax&&) noexcept = default; - virtual ~json_sax() = default; -}; - - -namespace detail -{ -/*! -@brief SAX implementation to create a JSON value from SAX events - -This class implements the @ref json_sax interface and processes the SAX events -to create a JSON value which makes it basically a DOM parser. The structure or -hierarchy of the JSON value is managed by the stack `ref_stack` which contains -a pointer to the respective array or object for each recursion depth. - -After successful parsing, the value that is passed by reference to the -constructor contains the parsed value. - -@tparam BasicJsonType the JSON type -*/ -template -class json_sax_dom_parser -{ - public: - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using binary_t = typename BasicJsonType::binary_t; - - /*! - @param[in,out] r reference to a JSON value that is manipulated while - parsing - @param[in] allow_exceptions_ whether parse errors yield exceptions - */ - explicit json_sax_dom_parser(BasicJsonType& r, const bool allow_exceptions_ = true) - : root(r), allow_exceptions(allow_exceptions_) - {} - - // make class move-only - json_sax_dom_parser(const json_sax_dom_parser&) = delete; - json_sax_dom_parser(json_sax_dom_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) - json_sax_dom_parser& operator=(const json_sax_dom_parser&) = delete; - json_sax_dom_parser& operator=(json_sax_dom_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) - ~json_sax_dom_parser() = default; - - bool null() - { - handle_value(nullptr); - return true; - } - - bool boolean(bool val) - { - handle_value(val); - return true; - } - - bool number_integer(number_integer_t val) - { - handle_value(val); - return true; - } - - bool number_unsigned(number_unsigned_t val) - { - handle_value(val); - return true; - } - - bool number_float(number_float_t val, const string_t& /*unused*/) - { - handle_value(val); - return true; - } - - bool string(string_t& val) - { - handle_value(val); - return true; - } - - bool binary(binary_t& val) - { - handle_value(std::move(val)); - return true; - } - - bool start_object(std::size_t len) - { - ref_stack.push_back(handle_value(BasicJsonType::value_t::object)); - - if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size())) - { - JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len), *ref_stack.back())); - } - - return true; - } - - bool key(string_t& val) - { - // add null at given key and store the reference for later - object_element = &(ref_stack.back()->m_value.object->operator[](val)); - return true; - } - - bool end_object() - { - ref_stack.back()->set_parents(); - ref_stack.pop_back(); - return true; - } - - bool start_array(std::size_t len) - { - ref_stack.push_back(handle_value(BasicJsonType::value_t::array)); - - if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size())) - { - JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len), *ref_stack.back())); - } - - return true; - } - - bool end_array() - { - ref_stack.back()->set_parents(); - ref_stack.pop_back(); - return true; - } - - template - bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, - const Exception& ex) - { - errored = true; - static_cast(ex); - if (allow_exceptions) - { - JSON_THROW(ex); - } - return false; - } - - constexpr bool is_errored() const - { - return errored; - } - - private: - /*! - @invariant If the ref stack is empty, then the passed value will be the new - root. - @invariant If the ref stack contains a value, then it is an array or an - object to which we can add elements - */ - template - JSON_HEDLEY_RETURNS_NON_NULL - BasicJsonType* handle_value(Value&& v) - { - if (ref_stack.empty()) - { - root = BasicJsonType(std::forward(v)); - return &root; - } - - JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object()); - - if (ref_stack.back()->is_array()) - { - ref_stack.back()->m_value.array->emplace_back(std::forward(v)); - return &(ref_stack.back()->m_value.array->back()); - } - - JSON_ASSERT(ref_stack.back()->is_object()); - JSON_ASSERT(object_element); - *object_element = BasicJsonType(std::forward(v)); - return object_element; - } - - /// the parsed JSON value - BasicJsonType& root; - /// stack to model hierarchy of values - std::vector ref_stack {}; - /// helper to hold the reference for the next object element - BasicJsonType* object_element = nullptr; - /// whether a syntax error occurred - bool errored = false; - /// whether to throw exceptions in case of errors - const bool allow_exceptions = true; -}; - -template -class json_sax_dom_callback_parser -{ - public: - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using binary_t = typename BasicJsonType::binary_t; - using parser_callback_t = typename BasicJsonType::parser_callback_t; - using parse_event_t = typename BasicJsonType::parse_event_t; - - json_sax_dom_callback_parser(BasicJsonType& r, - const parser_callback_t cb, - const bool allow_exceptions_ = true) - : root(r), callback(cb), allow_exceptions(allow_exceptions_) - { - keep_stack.push_back(true); - } - - // make class move-only - json_sax_dom_callback_parser(const json_sax_dom_callback_parser&) = delete; - json_sax_dom_callback_parser(json_sax_dom_callback_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) - json_sax_dom_callback_parser& operator=(const json_sax_dom_callback_parser&) = delete; - json_sax_dom_callback_parser& operator=(json_sax_dom_callback_parser&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) - ~json_sax_dom_callback_parser() = default; - - bool null() - { - handle_value(nullptr); - return true; - } - - bool boolean(bool val) - { - handle_value(val); - return true; - } - - bool number_integer(number_integer_t val) - { - handle_value(val); - return true; - } - - bool number_unsigned(number_unsigned_t val) - { - handle_value(val); - return true; - } - - bool number_float(number_float_t val, const string_t& /*unused*/) - { - handle_value(val); - return true; - } - - bool string(string_t& val) - { - handle_value(val); - return true; - } - - bool binary(binary_t& val) - { - handle_value(std::move(val)); - return true; - } - - bool start_object(std::size_t len) - { - // check callback for object start - const bool keep = callback(static_cast(ref_stack.size()), parse_event_t::object_start, discarded); - keep_stack.push_back(keep); - - auto val = handle_value(BasicJsonType::value_t::object, true); - ref_stack.push_back(val.second); - - // check object limit - if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size())) - { - JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len), *ref_stack.back())); - } - - return true; - } - - bool key(string_t& val) - { - BasicJsonType k = BasicJsonType(val); - - // check callback for key - const bool keep = callback(static_cast(ref_stack.size()), parse_event_t::key, k); - key_keep_stack.push_back(keep); - - // add discarded value at given key and store the reference for later - if (keep && ref_stack.back()) - { - object_element = &(ref_stack.back()->m_value.object->operator[](val) = discarded); - } - - return true; - } - - bool end_object() - { - if (ref_stack.back()) - { - if (!callback(static_cast(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back())) - { - // discard object - *ref_stack.back() = discarded; - } - else - { - ref_stack.back()->set_parents(); - } - } - - JSON_ASSERT(!ref_stack.empty()); - JSON_ASSERT(!keep_stack.empty()); - ref_stack.pop_back(); - keep_stack.pop_back(); - - if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured()) - { - // remove discarded value - for (auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it) - { - if (it->is_discarded()) - { - ref_stack.back()->erase(it); - break; - } - } - } - - return true; - } - - bool start_array(std::size_t len) - { - const bool keep = callback(static_cast(ref_stack.size()), parse_event_t::array_start, discarded); - keep_stack.push_back(keep); - - auto val = handle_value(BasicJsonType::value_t::array, true); - ref_stack.push_back(val.second); - - // check array limit - if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size())) - { - JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len), *ref_stack.back())); - } - - return true; - } - - bool end_array() - { - bool keep = true; - - if (ref_stack.back()) - { - keep = callback(static_cast(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back()); - if (keep) - { - ref_stack.back()->set_parents(); - } - else - { - // discard array - *ref_stack.back() = discarded; - } - } - - JSON_ASSERT(!ref_stack.empty()); - JSON_ASSERT(!keep_stack.empty()); - ref_stack.pop_back(); - keep_stack.pop_back(); - - // remove discarded value - if (!keep && !ref_stack.empty() && ref_stack.back()->is_array()) - { - ref_stack.back()->m_value.array->pop_back(); - } - - return true; - } - - template - bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, - const Exception& ex) - { - errored = true; - static_cast(ex); - if (allow_exceptions) - { - JSON_THROW(ex); - } - return false; - } - - constexpr bool is_errored() const - { - return errored; - } - - private: - /*! - @param[in] v value to add to the JSON value we build during parsing - @param[in] skip_callback whether we should skip calling the callback - function; this is required after start_array() and - start_object() SAX events, because otherwise we would call the - callback function with an empty array or object, respectively. - - @invariant If the ref stack is empty, then the passed value will be the new - root. - @invariant If the ref stack contains a value, then it is an array or an - object to which we can add elements - - @return pair of boolean (whether value should be kept) and pointer (to the - passed value in the ref_stack hierarchy; nullptr if not kept) - */ - template - std::pair handle_value(Value&& v, const bool skip_callback = false) - { - JSON_ASSERT(!keep_stack.empty()); - - // do not handle this value if we know it would be added to a discarded - // container - if (!keep_stack.back()) - { - return {false, nullptr}; - } - - // create value - auto value = BasicJsonType(std::forward(v)); - - // check callback - const bool keep = skip_callback || callback(static_cast(ref_stack.size()), parse_event_t::value, value); - - // do not handle this value if we just learnt it shall be discarded - if (!keep) - { - return {false, nullptr}; - } - - if (ref_stack.empty()) - { - root = std::move(value); - return {true, &root}; - } - - // skip this value if we already decided to skip the parent - // (https://github.com/nlohmann/json/issues/971#issuecomment-413678360) - if (!ref_stack.back()) - { - return {false, nullptr}; - } - - // we now only expect arrays and objects - JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object()); - - // array - if (ref_stack.back()->is_array()) - { - ref_stack.back()->m_value.array->emplace_back(std::move(value)); - return {true, &(ref_stack.back()->m_value.array->back())}; - } - - // object - JSON_ASSERT(ref_stack.back()->is_object()); - // check if we should store an element for the current key - JSON_ASSERT(!key_keep_stack.empty()); - const bool store_element = key_keep_stack.back(); - key_keep_stack.pop_back(); - - if (!store_element) - { - return {false, nullptr}; - } - - JSON_ASSERT(object_element); - *object_element = std::move(value); - return {true, object_element}; - } - - /// the parsed JSON value - BasicJsonType& root; - /// stack to model hierarchy of values - std::vector ref_stack {}; - /// stack to manage which values to keep - std::vector keep_stack {}; - /// stack to manage which object keys to keep - std::vector key_keep_stack {}; - /// helper to hold the reference for the next object element - BasicJsonType* object_element = nullptr; - /// whether a syntax error occurred - bool errored = false; - /// callback function - const parser_callback_t callback = nullptr; - /// whether to throw exceptions in case of errors - const bool allow_exceptions = true; - /// a discarded value for the callback - BasicJsonType discarded = BasicJsonType::value_t::discarded; -}; - -template -class json_sax_acceptor -{ - public: - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using binary_t = typename BasicJsonType::binary_t; - - bool null() - { - return true; - } - - bool boolean(bool /*unused*/) - { - return true; - } - - bool number_integer(number_integer_t /*unused*/) - { - return true; - } - - bool number_unsigned(number_unsigned_t /*unused*/) - { - return true; - } - - bool number_float(number_float_t /*unused*/, const string_t& /*unused*/) - { - return true; - } - - bool string(string_t& /*unused*/) - { - return true; - } - - bool binary(binary_t& /*unused*/) - { - return true; - } - - bool start_object(std::size_t /*unused*/ = std::size_t(-1)) - { - return true; - } - - bool key(string_t& /*unused*/) - { - return true; - } - - bool end_object() - { - return true; - } - - bool start_array(std::size_t /*unused*/ = std::size_t(-1)) - { - return true; - } - - bool end_array() - { - return true; - } - - bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, const detail::exception& /*unused*/) - { - return false; - } -}; -} // namespace detail - -} // namespace nlohmann - -// #include - - -#include // array -#include // localeconv -#include // size_t -#include // snprintf -#include // strtof, strtod, strtold, strtoll, strtoull -#include // initializer_list -#include // char_traits, string -#include // move -#include // vector - -// #include - -// #include - -// #include - - -namespace nlohmann -{ -namespace detail -{ -/////////// -// lexer // -/////////// - -template -class lexer_base -{ - public: - /// token types for the parser - enum class token_type - { - uninitialized, ///< indicating the scanner is uninitialized - literal_true, ///< the `true` literal - literal_false, ///< the `false` literal - literal_null, ///< the `null` literal - value_string, ///< a string -- use get_string() for actual value - value_unsigned, ///< an unsigned integer -- use get_number_unsigned() for actual value - value_integer, ///< a signed integer -- use get_number_integer() for actual value - value_float, ///< an floating point number -- use get_number_float() for actual value - begin_array, ///< the character for array begin `[` - begin_object, ///< the character for object begin `{` - end_array, ///< the character for array end `]` - end_object, ///< the character for object end `}` - name_separator, ///< the name separator `:` - value_separator, ///< the value separator `,` - parse_error, ///< indicating a parse error - end_of_input, ///< indicating the end of the input buffer - literal_or_value ///< a literal or the begin of a value (only for diagnostics) - }; - - /// return name of values of type token_type (only used for errors) - JSON_HEDLEY_RETURNS_NON_NULL - JSON_HEDLEY_CONST - static const char* token_type_name(const token_type t) noexcept - { - switch (t) - { - case token_type::uninitialized: - return ""; - case token_type::literal_true: - return "true literal"; - case token_type::literal_false: - return "false literal"; - case token_type::literal_null: - return "null literal"; - case token_type::value_string: - return "string literal"; - case token_type::value_unsigned: - case token_type::value_integer: - case token_type::value_float: - return "number literal"; - case token_type::begin_array: - return "'['"; - case token_type::begin_object: - return "'{'"; - case token_type::end_array: - return "']'"; - case token_type::end_object: - return "'}'"; - case token_type::name_separator: - return "':'"; - case token_type::value_separator: - return "','"; - case token_type::parse_error: - return ""; - case token_type::end_of_input: - return "end of input"; - case token_type::literal_or_value: - return "'[', '{', or a literal"; - // LCOV_EXCL_START - default: // catch non-enum values - return "unknown token"; - // LCOV_EXCL_STOP - } - } -}; -/*! -@brief lexical analysis - -This class organizes the lexical analysis during JSON deserialization. -*/ -template -class lexer : public lexer_base -{ - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using char_type = typename InputAdapterType::char_type; - using char_int_type = typename std::char_traits::int_type; - - public: - using token_type = typename lexer_base::token_type; - - explicit lexer(InputAdapterType&& adapter, bool ignore_comments_ = false) noexcept - : ia(std::move(adapter)) - , ignore_comments(ignore_comments_) - , decimal_point_char(static_cast(get_decimal_point())) - {} - - // delete because of pointer members - lexer(const lexer&) = delete; - lexer(lexer&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) - lexer& operator=(lexer&) = delete; - lexer& operator=(lexer&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) - ~lexer() = default; - - private: - ///////////////////// - // locales - ///////////////////// - - /// return the locale-dependent decimal point - JSON_HEDLEY_PURE - static char get_decimal_point() noexcept - { - const auto* loc = localeconv(); - JSON_ASSERT(loc != nullptr); - return (loc->decimal_point == nullptr) ? '.' : *(loc->decimal_point); - } - - ///////////////////// - // scan functions - ///////////////////// - - /*! - @brief get codepoint from 4 hex characters following `\u` - - For input "\u c1 c2 c3 c4" the codepoint is: - (c1 * 0x1000) + (c2 * 0x0100) + (c3 * 0x0010) + c4 - = (c1 << 12) + (c2 << 8) + (c3 << 4) + (c4 << 0) - - Furthermore, the possible characters '0'..'9', 'A'..'F', and 'a'..'f' - must be converted to the integers 0x0..0x9, 0xA..0xF, 0xA..0xF, resp. The - conversion is done by subtracting the offset (0x30, 0x37, and 0x57) - between the ASCII value of the character and the desired integer value. - - @return codepoint (0x0000..0xFFFF) or -1 in case of an error (e.g. EOF or - non-hex character) - */ - int get_codepoint() - { - // this function only makes sense after reading `\u` - JSON_ASSERT(current == 'u'); - int codepoint = 0; - - const auto factors = { 12u, 8u, 4u, 0u }; - for (const auto factor : factors) - { - get(); - - if (current >= '0' && current <= '9') - { - codepoint += static_cast((static_cast(current) - 0x30u) << factor); - } - else if (current >= 'A' && current <= 'F') - { - codepoint += static_cast((static_cast(current) - 0x37u) << factor); - } - else if (current >= 'a' && current <= 'f') - { - codepoint += static_cast((static_cast(current) - 0x57u) << factor); - } - else - { - return -1; - } - } - - JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF); - return codepoint; - } - - /*! - @brief check if the next byte(s) are inside a given range - - Adds the current byte and, for each passed range, reads a new byte and - checks if it is inside the range. If a violation was detected, set up an - error message and return false. Otherwise, return true. - - @param[in] ranges list of integers; interpreted as list of pairs of - inclusive lower and upper bound, respectively - - @pre The passed list @a ranges must have 2, 4, or 6 elements; that is, - 1, 2, or 3 pairs. This precondition is enforced by an assertion. - - @return true if and only if no range violation was detected - */ - bool next_byte_in_range(std::initializer_list ranges) - { - JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6); - add(current); - - for (auto range = ranges.begin(); range != ranges.end(); ++range) - { - get(); - if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range))) - { - add(current); - } - else - { - error_message = "invalid string: ill-formed UTF-8 byte"; - return false; - } - } - - return true; - } - - /*! - @brief scan a string literal - - This function scans a string according to Sect. 7 of RFC 8259. While - scanning, bytes are escaped and copied into buffer token_buffer. Then the - function returns successfully, token_buffer is *not* null-terminated (as it - may contain \0 bytes), and token_buffer.size() is the number of bytes in the - string. - - @return token_type::value_string if string could be successfully scanned, - token_type::parse_error otherwise - - @note In case of errors, variable error_message contains a textual - description. - */ - token_type scan_string() - { - // reset token_buffer (ignore opening quote) - reset(); - - // we entered the function by reading an open quote - JSON_ASSERT(current == '\"'); - - while (true) - { - // get next character - switch (get()) - { - // end of file while parsing string - case std::char_traits::eof(): - { - error_message = "invalid string: missing closing quote"; - return token_type::parse_error; - } - - // closing quote - case '\"': - { - return token_type::value_string; - } - - // escapes - case '\\': - { - switch (get()) - { - // quotation mark - case '\"': - add('\"'); - break; - // reverse solidus - case '\\': - add('\\'); - break; - // solidus - case '/': - add('/'); - break; - // backspace - case 'b': - add('\b'); - break; - // form feed - case 'f': - add('\f'); - break; - // line feed - case 'n': - add('\n'); - break; - // carriage return - case 'r': - add('\r'); - break; - // tab - case 't': - add('\t'); - break; - - // unicode escapes - case 'u': - { - const int codepoint1 = get_codepoint(); - int codepoint = codepoint1; // start with codepoint1 - - if (JSON_HEDLEY_UNLIKELY(codepoint1 == -1)) - { - error_message = "invalid string: '\\u' must be followed by 4 hex digits"; - return token_type::parse_error; - } - - // check if code point is a high surrogate - if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF) - { - // expect next \uxxxx entry - if (JSON_HEDLEY_LIKELY(get() == '\\' && get() == 'u')) - { - const int codepoint2 = get_codepoint(); - - if (JSON_HEDLEY_UNLIKELY(codepoint2 == -1)) - { - error_message = "invalid string: '\\u' must be followed by 4 hex digits"; - return token_type::parse_error; - } - - // check if codepoint2 is a low surrogate - if (JSON_HEDLEY_LIKELY(0xDC00 <= codepoint2 && codepoint2 <= 0xDFFF)) - { - // overwrite codepoint - codepoint = static_cast( - // high surrogate occupies the most significant 22 bits - (static_cast(codepoint1) << 10u) - // low surrogate occupies the least significant 15 bits - + static_cast(codepoint2) - // there is still the 0xD800, 0xDC00 and 0x10000 noise - // in the result so we have to subtract with: - // (0xD800 << 10) + DC00 - 0x10000 = 0x35FDC00 - - 0x35FDC00u); - } - else - { - error_message = "invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF"; - return token_type::parse_error; - } - } - else - { - error_message = "invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF"; - return token_type::parse_error; - } - } - else - { - if (JSON_HEDLEY_UNLIKELY(0xDC00 <= codepoint1 && codepoint1 <= 0xDFFF)) - { - error_message = "invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF"; - return token_type::parse_error; - } - } - - // result of the above calculation yields a proper codepoint - JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF); - - // translate codepoint into bytes - if (codepoint < 0x80) - { - // 1-byte characters: 0xxxxxxx (ASCII) - add(static_cast(codepoint)); - } - else if (codepoint <= 0x7FF) - { - // 2-byte characters: 110xxxxx 10xxxxxx - add(static_cast(0xC0u | (static_cast(codepoint) >> 6u))); - add(static_cast(0x80u | (static_cast(codepoint) & 0x3Fu))); - } - else if (codepoint <= 0xFFFF) - { - // 3-byte characters: 1110xxxx 10xxxxxx 10xxxxxx - add(static_cast(0xE0u | (static_cast(codepoint) >> 12u))); - add(static_cast(0x80u | ((static_cast(codepoint) >> 6u) & 0x3Fu))); - add(static_cast(0x80u | (static_cast(codepoint) & 0x3Fu))); - } - else - { - // 4-byte characters: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx - add(static_cast(0xF0u | (static_cast(codepoint) >> 18u))); - add(static_cast(0x80u | ((static_cast(codepoint) >> 12u) & 0x3Fu))); - add(static_cast(0x80u | ((static_cast(codepoint) >> 6u) & 0x3Fu))); - add(static_cast(0x80u | (static_cast(codepoint) & 0x3Fu))); - } - - break; - } - - // other characters after escape - default: - error_message = "invalid string: forbidden character after backslash"; - return token_type::parse_error; - } - - break; - } - - // invalid control characters - case 0x00: - { - error_message = "invalid string: control character U+0000 (NUL) must be escaped to \\u0000"; - return token_type::parse_error; - } - - case 0x01: - { - error_message = "invalid string: control character U+0001 (SOH) must be escaped to \\u0001"; - return token_type::parse_error; - } - - case 0x02: - { - error_message = "invalid string: control character U+0002 (STX) must be escaped to \\u0002"; - return token_type::parse_error; - } - - case 0x03: - { - error_message = "invalid string: control character U+0003 (ETX) must be escaped to \\u0003"; - return token_type::parse_error; - } - - case 0x04: - { - error_message = "invalid string: control character U+0004 (EOT) must be escaped to \\u0004"; - return token_type::parse_error; - } - - case 0x05: - { - error_message = "invalid string: control character U+0005 (ENQ) must be escaped to \\u0005"; - return token_type::parse_error; - } - - case 0x06: - { - error_message = "invalid string: control character U+0006 (ACK) must be escaped to \\u0006"; - return token_type::parse_error; - } - - case 0x07: - { - error_message = "invalid string: control character U+0007 (BEL) must be escaped to \\u0007"; - return token_type::parse_error; - } - - case 0x08: - { - error_message = "invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b"; - return token_type::parse_error; - } - - case 0x09: - { - error_message = "invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t"; - return token_type::parse_error; - } - - case 0x0A: - { - error_message = "invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n"; - return token_type::parse_error; - } - - case 0x0B: - { - error_message = "invalid string: control character U+000B (VT) must be escaped to \\u000B"; - return token_type::parse_error; - } - - case 0x0C: - { - error_message = "invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f"; - return token_type::parse_error; - } - - case 0x0D: - { - error_message = "invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r"; - return token_type::parse_error; - } - - case 0x0E: - { - error_message = "invalid string: control character U+000E (SO) must be escaped to \\u000E"; - return token_type::parse_error; - } - - case 0x0F: - { - error_message = "invalid string: control character U+000F (SI) must be escaped to \\u000F"; - return token_type::parse_error; - } - - case 0x10: - { - error_message = "invalid string: control character U+0010 (DLE) must be escaped to \\u0010"; - return token_type::parse_error; - } - - case 0x11: - { - error_message = "invalid string: control character U+0011 (DC1) must be escaped to \\u0011"; - return token_type::parse_error; - } - - case 0x12: - { - error_message = "invalid string: control character U+0012 (DC2) must be escaped to \\u0012"; - return token_type::parse_error; - } - - case 0x13: - { - error_message = "invalid string: control character U+0013 (DC3) must be escaped to \\u0013"; - return token_type::parse_error; - } - - case 0x14: - { - error_message = "invalid string: control character U+0014 (DC4) must be escaped to \\u0014"; - return token_type::parse_error; - } - - case 0x15: - { - error_message = "invalid string: control character U+0015 (NAK) must be escaped to \\u0015"; - return token_type::parse_error; - } - - case 0x16: - { - error_message = "invalid string: control character U+0016 (SYN) must be escaped to \\u0016"; - return token_type::parse_error; - } - - case 0x17: - { - error_message = "invalid string: control character U+0017 (ETB) must be escaped to \\u0017"; - return token_type::parse_error; - } - - case 0x18: - { - error_message = "invalid string: control character U+0018 (CAN) must be escaped to \\u0018"; - return token_type::parse_error; - } - - case 0x19: - { - error_message = "invalid string: control character U+0019 (EM) must be escaped to \\u0019"; - return token_type::parse_error; - } - - case 0x1A: - { - error_message = "invalid string: control character U+001A (SUB) must be escaped to \\u001A"; - return token_type::parse_error; - } - - case 0x1B: - { - error_message = "invalid string: control character U+001B (ESC) must be escaped to \\u001B"; - return token_type::parse_error; - } - - case 0x1C: - { - error_message = "invalid string: control character U+001C (FS) must be escaped to \\u001C"; - return token_type::parse_error; - } - - case 0x1D: - { - error_message = "invalid string: control character U+001D (GS) must be escaped to \\u001D"; - return token_type::parse_error; - } - - case 0x1E: - { - error_message = "invalid string: control character U+001E (RS) must be escaped to \\u001E"; - return token_type::parse_error; - } - - case 0x1F: - { - error_message = "invalid string: control character U+001F (US) must be escaped to \\u001F"; - return token_type::parse_error; - } - - // U+0020..U+007F (except U+0022 (quote) and U+005C (backspace)) - case 0x20: - case 0x21: - case 0x23: - case 0x24: - case 0x25: - case 0x26: - case 0x27: - case 0x28: - case 0x29: - case 0x2A: - case 0x2B: - case 0x2C: - case 0x2D: - case 0x2E: - case 0x2F: - case 0x30: - case 0x31: - case 0x32: - case 0x33: - case 0x34: - case 0x35: - case 0x36: - case 0x37: - case 0x38: - case 0x39: - case 0x3A: - case 0x3B: - case 0x3C: - case 0x3D: - case 0x3E: - case 0x3F: - case 0x40: - case 0x41: - case 0x42: - case 0x43: - case 0x44: - case 0x45: - case 0x46: - case 0x47: - case 0x48: - case 0x49: - case 0x4A: - case 0x4B: - case 0x4C: - case 0x4D: - case 0x4E: - case 0x4F: - case 0x50: - case 0x51: - case 0x52: - case 0x53: - case 0x54: - case 0x55: - case 0x56: - case 0x57: - case 0x58: - case 0x59: - case 0x5A: - case 0x5B: - case 0x5D: - case 0x5E: - case 0x5F: - case 0x60: - case 0x61: - case 0x62: - case 0x63: - case 0x64: - case 0x65: - case 0x66: - case 0x67: - case 0x68: - case 0x69: - case 0x6A: - case 0x6B: - case 0x6C: - case 0x6D: - case 0x6E: - case 0x6F: - case 0x70: - case 0x71: - case 0x72: - case 0x73: - case 0x74: - case 0x75: - case 0x76: - case 0x77: - case 0x78: - case 0x79: - case 0x7A: - case 0x7B: - case 0x7C: - case 0x7D: - case 0x7E: - case 0x7F: - { - add(current); - break; - } - - // U+0080..U+07FF: bytes C2..DF 80..BF - case 0xC2: - case 0xC3: - case 0xC4: - case 0xC5: - case 0xC6: - case 0xC7: - case 0xC8: - case 0xC9: - case 0xCA: - case 0xCB: - case 0xCC: - case 0xCD: - case 0xCE: - case 0xCF: - case 0xD0: - case 0xD1: - case 0xD2: - case 0xD3: - case 0xD4: - case 0xD5: - case 0xD6: - case 0xD7: - case 0xD8: - case 0xD9: - case 0xDA: - case 0xDB: - case 0xDC: - case 0xDD: - case 0xDE: - case 0xDF: - { - if (JSON_HEDLEY_UNLIKELY(!next_byte_in_range({0x80, 0xBF}))) - { - return token_type::parse_error; - } - break; - } - - // U+0800..U+0FFF: bytes E0 A0..BF 80..BF - case 0xE0: - { - if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF})))) - { - return token_type::parse_error; - } - break; - } - - // U+1000..U+CFFF: bytes E1..EC 80..BF 80..BF - // U+E000..U+FFFF: bytes EE..EF 80..BF 80..BF - case 0xE1: - case 0xE2: - case 0xE3: - case 0xE4: - case 0xE5: - case 0xE6: - case 0xE7: - case 0xE8: - case 0xE9: - case 0xEA: - case 0xEB: - case 0xEC: - case 0xEE: - case 0xEF: - { - if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0xBF, 0x80, 0xBF})))) - { - return token_type::parse_error; - } - break; - } - - // U+D000..U+D7FF: bytes ED 80..9F 80..BF - case 0xED: - { - if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0x9F, 0x80, 0xBF})))) - { - return token_type::parse_error; - } - break; - } - - // U+10000..U+3FFFF F0 90..BF 80..BF 80..BF - case 0xF0: - { - if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) - { - return token_type::parse_error; - } - break; - } - - // U+40000..U+FFFFF F1..F3 80..BF 80..BF 80..BF - case 0xF1: - case 0xF2: - case 0xF3: - { - if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) - { - return token_type::parse_error; - } - break; - } - - // U+100000..U+10FFFF F4 80..8F 80..BF 80..BF - case 0xF4: - { - if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF})))) - { - return token_type::parse_error; - } - break; - } - - // remaining bytes (80..C1 and F5..FF) are ill-formed - default: - { - error_message = "invalid string: ill-formed UTF-8 byte"; - return token_type::parse_error; - } - } - } - } - - /*! - * @brief scan a comment - * @return whether comment could be scanned successfully - */ - bool scan_comment() - { - switch (get()) - { - // single-line comments skip input until a newline or EOF is read - case '/': - { - while (true) - { - switch (get()) - { - case '\n': - case '\r': - case std::char_traits::eof(): - case '\0': - return true; - - default: - break; - } - } - } - - // multi-line comments skip input until */ is read - case '*': - { - while (true) - { - switch (get()) - { - case std::char_traits::eof(): - case '\0': - { - error_message = "invalid comment; missing closing '*/'"; - return false; - } - - case '*': - { - switch (get()) - { - case '/': - return true; - - default: - { - unget(); - continue; - } - } - } - - default: - continue; - } - } - } - - // unexpected character after reading '/' - default: - { - error_message = "invalid comment; expecting '/' or '*' after '/'"; - return false; - } - } - } - - JSON_HEDLEY_NON_NULL(2) - static void strtof(float& f, const char* str, char** endptr) noexcept - { - f = std::strtof(str, endptr); - } - - JSON_HEDLEY_NON_NULL(2) - static void strtof(double& f, const char* str, char** endptr) noexcept - { - f = std::strtod(str, endptr); - } - - JSON_HEDLEY_NON_NULL(2) - static void strtof(long double& f, const char* str, char** endptr) noexcept - { - f = std::strtold(str, endptr); - } - - /*! - @brief scan a number literal - - This function scans a string according to Sect. 6 of RFC 8259. - - The function is realized with a deterministic finite state machine derived - from the grammar described in RFC 8259. Starting in state "init", the - input is read and used to determined the next state. Only state "done" - accepts the number. State "error" is a trap state to model errors. In the - table below, "anything" means any character but the ones listed before. - - state | 0 | 1-9 | e E | + | - | . | anything - ---------|----------|----------|----------|---------|---------|----------|----------- - init | zero | any1 | [error] | [error] | minus | [error] | [error] - minus | zero | any1 | [error] | [error] | [error] | [error] | [error] - zero | done | done | exponent | done | done | decimal1 | done - any1 | any1 | any1 | exponent | done | done | decimal1 | done - decimal1 | decimal2 | decimal2 | [error] | [error] | [error] | [error] | [error] - decimal2 | decimal2 | decimal2 | exponent | done | done | done | done - exponent | any2 | any2 | [error] | sign | sign | [error] | [error] - sign | any2 | any2 | [error] | [error] | [error] | [error] | [error] - any2 | any2 | any2 | done | done | done | done | done - - The state machine is realized with one label per state (prefixed with - "scan_number_") and `goto` statements between them. The state machine - contains cycles, but any cycle can be left when EOF is read. Therefore, - the function is guaranteed to terminate. - - During scanning, the read bytes are stored in token_buffer. This string is - then converted to a signed integer, an unsigned integer, or a - floating-point number. - - @return token_type::value_unsigned, token_type::value_integer, or - token_type::value_float if number could be successfully scanned, - token_type::parse_error otherwise - - @note The scanner is independent of the current locale. Internally, the - locale's decimal point is used instead of `.` to work with the - locale-dependent converters. - */ - token_type scan_number() // lgtm [cpp/use-of-goto] - { - // reset token_buffer to store the number's bytes - reset(); - - // the type of the parsed number; initially set to unsigned; will be - // changed if minus sign, decimal point or exponent is read - token_type number_type = token_type::value_unsigned; - - // state (init): we just found out we need to scan a number - switch (current) - { - case '-': - { - add(current); - goto scan_number_minus; - } - - case '0': - { - add(current); - goto scan_number_zero; - } - - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - add(current); - goto scan_number_any1; - } - - // all other characters are rejected outside scan_number() - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE - } - -scan_number_minus: - // state: we just parsed a leading minus sign - number_type = token_type::value_integer; - switch (get()) - { - case '0': - { - add(current); - goto scan_number_zero; - } - - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - add(current); - goto scan_number_any1; - } - - default: - { - error_message = "invalid number; expected digit after '-'"; - return token_type::parse_error; - } - } - -scan_number_zero: - // state: we just parse a zero (maybe with a leading minus sign) - switch (get()) - { - case '.': - { - add(decimal_point_char); - goto scan_number_decimal1; - } - - case 'e': - case 'E': - { - add(current); - goto scan_number_exponent; - } - - default: - goto scan_number_done; - } - -scan_number_any1: - // state: we just parsed a number 0-9 (maybe with a leading minus sign) - switch (get()) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - add(current); - goto scan_number_any1; - } - - case '.': - { - add(decimal_point_char); - goto scan_number_decimal1; - } - - case 'e': - case 'E': - { - add(current); - goto scan_number_exponent; - } - - default: - goto scan_number_done; - } - -scan_number_decimal1: - // state: we just parsed a decimal point - number_type = token_type::value_float; - switch (get()) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - add(current); - goto scan_number_decimal2; - } - - default: - { - error_message = "invalid number; expected digit after '.'"; - return token_type::parse_error; - } - } - -scan_number_decimal2: - // we just parsed at least one number after a decimal point - switch (get()) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - add(current); - goto scan_number_decimal2; - } - - case 'e': - case 'E': - { - add(current); - goto scan_number_exponent; - } - - default: - goto scan_number_done; - } - -scan_number_exponent: - // we just parsed an exponent - number_type = token_type::value_float; - switch (get()) - { - case '+': - case '-': - { - add(current); - goto scan_number_sign; - } - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - add(current); - goto scan_number_any2; - } - - default: - { - error_message = - "invalid number; expected '+', '-', or digit after exponent"; - return token_type::parse_error; - } - } - -scan_number_sign: - // we just parsed an exponent sign - switch (get()) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - add(current); - goto scan_number_any2; - } - - default: - { - error_message = "invalid number; expected digit after exponent sign"; - return token_type::parse_error; - } - } - -scan_number_any2: - // we just parsed a number after the exponent or exponent sign - switch (get()) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - add(current); - goto scan_number_any2; - } - - default: - goto scan_number_done; - } - -scan_number_done: - // unget the character after the number (we only read it to know that - // we are done scanning a number) - unget(); - - char* endptr = nullptr; // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) - errno = 0; - - // try to parse integers first and fall back to floats - if (number_type == token_type::value_unsigned) - { - const auto x = std::strtoull(token_buffer.data(), &endptr, 10); - - // we checked the number format before - JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size()); - - if (errno == 0) - { - value_unsigned = static_cast(x); - if (value_unsigned == x) - { - return token_type::value_unsigned; - } - } - } - else if (number_type == token_type::value_integer) - { - const auto x = std::strtoll(token_buffer.data(), &endptr, 10); - - // we checked the number format before - JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size()); - - if (errno == 0) - { - value_integer = static_cast(x); - if (value_integer == x) - { - return token_type::value_integer; - } - } - } - - // this code is reached if we parse a floating-point number or if an - // integer conversion above failed - strtof(value_float, token_buffer.data(), &endptr); - - // we checked the number format before - JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size()); - - return token_type::value_float; - } - - /*! - @param[in] literal_text the literal text to expect - @param[in] length the length of the passed literal text - @param[in] return_type the token type to return on success - */ - JSON_HEDLEY_NON_NULL(2) - token_type scan_literal(const char_type* literal_text, const std::size_t length, - token_type return_type) - { - JSON_ASSERT(std::char_traits::to_char_type(current) == literal_text[0]); - for (std::size_t i = 1; i < length; ++i) - { - if (JSON_HEDLEY_UNLIKELY(std::char_traits::to_char_type(get()) != literal_text[i])) - { - error_message = "invalid literal"; - return token_type::parse_error; - } - } - return return_type; - } - - ///////////////////// - // input management - ///////////////////// - - /// reset token_buffer; current character is beginning of token - void reset() noexcept - { - token_buffer.clear(); - token_string.clear(); - token_string.push_back(std::char_traits::to_char_type(current)); - } - - /* - @brief get next character from the input - - This function provides the interface to the used input adapter. It does - not throw in case the input reached EOF, but returns a - `std::char_traits::eof()` in that case. Stores the scanned characters - for use in error messages. - - @return character read from the input - */ - char_int_type get() - { - ++position.chars_read_total; - ++position.chars_read_current_line; - - if (next_unget) - { - // just reset the next_unget variable and work with current - next_unget = false; - } - else - { - current = ia.get_character(); - } - - if (JSON_HEDLEY_LIKELY(current != std::char_traits::eof())) - { - token_string.push_back(std::char_traits::to_char_type(current)); - } - - if (current == '\n') - { - ++position.lines_read; - position.chars_read_current_line = 0; - } - - return current; - } - - /*! - @brief unget current character (read it again on next get) - - We implement unget by setting variable next_unget to true. The input is not - changed - we just simulate ungetting by modifying chars_read_total, - chars_read_current_line, and token_string. The next call to get() will - behave as if the unget character is read again. - */ - void unget() - { - next_unget = true; - - --position.chars_read_total; - - // in case we "unget" a newline, we have to also decrement the lines_read - if (position.chars_read_current_line == 0) - { - if (position.lines_read > 0) - { - --position.lines_read; - } - } - else - { - --position.chars_read_current_line; - } - - if (JSON_HEDLEY_LIKELY(current != std::char_traits::eof())) - { - JSON_ASSERT(!token_string.empty()); - token_string.pop_back(); - } - } - - /// add a character to token_buffer - void add(char_int_type c) - { - token_buffer.push_back(static_cast(c)); - } - - public: - ///////////////////// - // value getters - ///////////////////// - - /// return integer value - constexpr number_integer_t get_number_integer() const noexcept - { - return value_integer; - } - - /// return unsigned integer value - constexpr number_unsigned_t get_number_unsigned() const noexcept - { - return value_unsigned; - } - - /// return floating-point value - constexpr number_float_t get_number_float() const noexcept - { - return value_float; - } - - /// return current string value (implicitly resets the token; useful only once) - string_t& get_string() - { - return token_buffer; - } - - ///////////////////// - // diagnostics - ///////////////////// - - /// return position of last read token - constexpr position_t get_position() const noexcept - { - return position; - } - - /// return the last read token (for errors only). Will never contain EOF - /// (an arbitrary value that is not a valid char value, often -1), because - /// 255 may legitimately occur. May contain NUL, which should be escaped. - std::string get_token_string() const - { - // escape control characters - std::string result; - for (const auto c : token_string) - { - if (static_cast(c) <= '\x1F') - { - // escape control characters - std::array cs{{}}; - (std::snprintf)(cs.data(), cs.size(), "", static_cast(c)); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) - result += cs.data(); - } - else - { - // add character as is - result.push_back(static_cast(c)); - } - } - - return result; - } - - /// return syntax error message - JSON_HEDLEY_RETURNS_NON_NULL - constexpr const char* get_error_message() const noexcept - { - return error_message; - } - - ///////////////////// - // actual scanner - ///////////////////// - - /*! - @brief skip the UTF-8 byte order mark - @return true iff there is no BOM or the correct BOM has been skipped - */ - bool skip_bom() - { - if (get() == 0xEF) - { - // check if we completely parse the BOM - return get() == 0xBB && get() == 0xBF; - } - - // the first character is not the beginning of the BOM; unget it to - // process is later - unget(); - return true; - } - - void skip_whitespace() - { - do - { - get(); - } - while (current == ' ' || current == '\t' || current == '\n' || current == '\r'); - } - - token_type scan() - { - // initially, skip the BOM - if (position.chars_read_total == 0 && !skip_bom()) - { - error_message = "invalid BOM; must be 0xEF 0xBB 0xBF if given"; - return token_type::parse_error; - } - - // read next character and ignore whitespace - skip_whitespace(); - - // ignore comments - while (ignore_comments && current == '/') - { - if (!scan_comment()) - { - return token_type::parse_error; - } - - // skip following whitespace - skip_whitespace(); - } - - switch (current) - { - // structural characters - case '[': - return token_type::begin_array; - case ']': - return token_type::end_array; - case '{': - return token_type::begin_object; - case '}': - return token_type::end_object; - case ':': - return token_type::name_separator; - case ',': - return token_type::value_separator; - - // literals - case 't': - { - std::array true_literal = {{char_type('t'), char_type('r'), char_type('u'), char_type('e')}}; - return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true); - } - case 'f': - { - std::array false_literal = {{char_type('f'), char_type('a'), char_type('l'), char_type('s'), char_type('e')}}; - return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false); - } - case 'n': - { - std::array null_literal = {{char_type('n'), char_type('u'), char_type('l'), char_type('l')}}; - return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null); - } - - // string - case '\"': - return scan_string(); - - // number - case '-': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - return scan_number(); - - // end of input (the null byte is needed when parsing from - // string literals) - case '\0': - case std::char_traits::eof(): - return token_type::end_of_input; - - // error - default: - error_message = "invalid literal"; - return token_type::parse_error; - } - } - - private: - /// input adapter - InputAdapterType ia; - - /// whether comments should be ignored (true) or signaled as errors (false) - const bool ignore_comments = false; - - /// the current character - char_int_type current = std::char_traits::eof(); - - /// whether the next get() call should just return current - bool next_unget = false; - - /// the start position of the current token - position_t position {}; - - /// raw input token string (for error messages) - std::vector token_string {}; - - /// buffer for variable-length tokens (numbers, strings) - string_t token_buffer {}; - - /// a description of occurred lexer errors - const char* error_message = ""; - - // number values - number_integer_t value_integer = 0; - number_unsigned_t value_unsigned = 0; - number_float_t value_float = 0; - - /// the decimal point - const char_int_type decimal_point_char = '.'; -}; -} // namespace detail -} // namespace nlohmann - -// #include - -// #include - - -#include // size_t -#include // declval -#include // string - -// #include - -// #include - - -namespace nlohmann -{ -namespace detail -{ -template -using null_function_t = decltype(std::declval().null()); - -template -using boolean_function_t = - decltype(std::declval().boolean(std::declval())); - -template -using number_integer_function_t = - decltype(std::declval().number_integer(std::declval())); - -template -using number_unsigned_function_t = - decltype(std::declval().number_unsigned(std::declval())); - -template -using number_float_function_t = decltype(std::declval().number_float( - std::declval(), std::declval())); - -template -using string_function_t = - decltype(std::declval().string(std::declval())); - -template -using binary_function_t = - decltype(std::declval().binary(std::declval())); - -template -using start_object_function_t = - decltype(std::declval().start_object(std::declval())); - -template -using key_function_t = - decltype(std::declval().key(std::declval())); - -template -using end_object_function_t = decltype(std::declval().end_object()); - -template -using start_array_function_t = - decltype(std::declval().start_array(std::declval())); - -template -using end_array_function_t = decltype(std::declval().end_array()); - -template -using parse_error_function_t = decltype(std::declval().parse_error( - std::declval(), std::declval(), - std::declval())); - -template -struct is_sax -{ - private: - static_assert(is_basic_json::value, - "BasicJsonType must be of type basic_json<...>"); - - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using binary_t = typename BasicJsonType::binary_t; - using exception_t = typename BasicJsonType::exception; - - public: - static constexpr bool value = - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value; -}; - -template -struct is_sax_static_asserts -{ - private: - static_assert(is_basic_json::value, - "BasicJsonType must be of type basic_json<...>"); - - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using binary_t = typename BasicJsonType::binary_t; - using exception_t = typename BasicJsonType::exception; - - public: - static_assert(is_detected_exact::value, - "Missing/invalid function: bool null()"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool boolean(bool)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool boolean(bool)"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool number_integer(number_integer_t)"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool number_unsigned(number_unsigned_t)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool number_float(number_float_t, const string_t&)"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool string(string_t&)"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool binary(binary_t&)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool start_object(std::size_t)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool key(string_t&)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool end_object()"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool start_array(std::size_t)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool end_array()"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool parse_error(std::size_t, const " - "std::string&, const exception&)"); -}; -} // namespace detail -} // namespace nlohmann - -// #include - -// #include - - -namespace nlohmann -{ -namespace detail -{ - -/// how to treat CBOR tags -enum class cbor_tag_handler_t -{ - error, ///< throw a parse_error exception in case of a tag - ignore, ///< ignore tags - store ///< store tags as binary type -}; - -/*! -@brief determine system byte order - -@return true if and only if system's byte order is little endian - -@note from https://stackoverflow.com/a/1001328/266378 -*/ -static inline bool little_endianess(int num = 1) noexcept -{ - return *reinterpret_cast(&num) == 1; -} - - -/////////////////// -// binary reader // -/////////////////// - -/*! -@brief deserialization of CBOR, MessagePack, and UBJSON values -*/ -template> -class binary_reader -{ - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using binary_t = typename BasicJsonType::binary_t; - using json_sax_t = SAX; - using char_type = typename InputAdapterType::char_type; - using char_int_type = typename std::char_traits::int_type; - - public: - /*! - @brief create a binary reader - - @param[in] adapter input adapter to read from - */ - explicit binary_reader(InputAdapterType&& adapter) noexcept : ia(std::move(adapter)) - { - (void)detail::is_sax_static_asserts {}; - } - - // make class move-only - binary_reader(const binary_reader&) = delete; - binary_reader(binary_reader&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) - binary_reader& operator=(const binary_reader&) = delete; - binary_reader& operator=(binary_reader&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor) - ~binary_reader() = default; - - /*! - @param[in] format the binary format to parse - @param[in] sax_ a SAX event processor - @param[in] strict whether to expect the input to be consumed completed - @param[in] tag_handler how to treat CBOR tags - - @return whether parsing was successful - */ - JSON_HEDLEY_NON_NULL(3) - bool sax_parse(const input_format_t format, - json_sax_t* sax_, - const bool strict = true, - const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) - { - sax = sax_; - bool result = false; - - switch (format) - { - case input_format_t::bson: - result = parse_bson_internal(); - break; - - case input_format_t::cbor: - result = parse_cbor_internal(true, tag_handler); - break; - - case input_format_t::msgpack: - result = parse_msgpack_internal(); - break; - - case input_format_t::ubjson: - result = parse_ubjson_internal(); - break; - - case input_format_t::json: // LCOV_EXCL_LINE - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE - } - - // strict mode: next byte must be EOF - if (result && strict) - { - if (format == input_format_t::ubjson) - { - get_ignore_noop(); - } - else - { - get(); - } - - if (JSON_HEDLEY_UNLIKELY(current != std::char_traits::eof())) - { - return sax->parse_error(chars_read, get_token_string(), - parse_error::create(110, chars_read, exception_message(format, "expected end of input; last byte: 0x" + get_token_string(), "value"), BasicJsonType())); - } - } - - return result; - } - - private: - ////////// - // BSON // - ////////// - - /*! - @brief Reads in a BSON-object and passes it to the SAX-parser. - @return whether a valid BSON-value was passed to the SAX parser - */ - bool parse_bson_internal() - { - std::int32_t document_size{}; - get_number(input_format_t::bson, document_size); - - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1)))) - { - return false; - } - - if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_list(/*is_array*/false))) - { - return false; - } - - return sax->end_object(); - } - - /*! - @brief Parses a C-style string from the BSON input. - @param[in,out] result A reference to the string variable where the read - string is to be stored. - @return `true` if the \x00-byte indicating the end of the string was - encountered before the EOF; false` indicates an unexpected EOF. - */ - bool get_bson_cstr(string_t& result) - { - auto out = std::back_inserter(result); - while (true) - { - get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::bson, "cstring"))) - { - return false; - } - if (current == 0x00) - { - return true; - } - *out++ = static_cast(current); - } - } - - /*! - @brief Parses a zero-terminated string of length @a len from the BSON - input. - @param[in] len The length (including the zero-byte at the end) of the - string to be read. - @param[in,out] result A reference to the string variable where the read - string is to be stored. - @tparam NumberType The type of the length @a len - @pre len >= 1 - @return `true` if the string was successfully parsed - */ - template - bool get_bson_string(const NumberType len, string_t& result) - { - if (JSON_HEDLEY_UNLIKELY(len < 1)) - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, "string length must be at least 1, is " + std::to_string(len), "string"), BasicJsonType())); - } - - return get_string(input_format_t::bson, len - static_cast(1), result) && get() != std::char_traits::eof(); - } - - /*! - @brief Parses a byte array input of length @a len from the BSON input. - @param[in] len The length of the byte array to be read. - @param[in,out] result A reference to the binary variable where the read - array is to be stored. - @tparam NumberType The type of the length @a len - @pre len >= 0 - @return `true` if the byte array was successfully parsed - */ - template - bool get_bson_binary(const NumberType len, binary_t& result) - { - if (JSON_HEDLEY_UNLIKELY(len < 0)) - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, "byte array length cannot be negative, is " + std::to_string(len), "binary"), BasicJsonType())); - } - - // All BSON binary values have a subtype - std::uint8_t subtype{}; - get_number(input_format_t::bson, subtype); - result.set_subtype(subtype); - - return get_binary(input_format_t::bson, len, result); - } - - /*! - @brief Read a BSON document element of the given @a element_type. - @param[in] element_type The BSON element type, c.f. http://bsonspec.org/spec.html - @param[in] element_type_parse_position The position in the input stream, - where the `element_type` was read. - @warning Not all BSON element types are supported yet. An unsupported - @a element_type will give rise to a parse_error.114: - Unsupported BSON record type 0x... - @return whether a valid BSON-object/array was passed to the SAX parser - */ - bool parse_bson_element_internal(const char_int_type element_type, - const std::size_t element_type_parse_position) - { - switch (element_type) - { - case 0x01: // double - { - double number{}; - return get_number(input_format_t::bson, number) && sax->number_float(static_cast(number), ""); - } - - case 0x02: // string - { - std::int32_t len{}; - string_t value; - return get_number(input_format_t::bson, len) && get_bson_string(len, value) && sax->string(value); - } - - case 0x03: // object - { - return parse_bson_internal(); - } - - case 0x04: // array - { - return parse_bson_array(); - } - - case 0x05: // binary - { - std::int32_t len{}; - binary_t value; - return get_number(input_format_t::bson, len) && get_bson_binary(len, value) && sax->binary(value); - } - - case 0x08: // boolean - { - return sax->boolean(get() != 0); - } - - case 0x0A: // null - { - return sax->null(); - } - - case 0x10: // int32 - { - std::int32_t value{}; - return get_number(input_format_t::bson, value) && sax->number_integer(value); - } - - case 0x12: // int64 - { - std::int64_t value{}; - return get_number(input_format_t::bson, value) && sax->number_integer(value); - } - - default: // anything else not supported (yet) - { - std::array cr{{}}; - (std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast(element_type)); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) - return sax->parse_error(element_type_parse_position, std::string(cr.data()), parse_error::create(114, element_type_parse_position, "Unsupported BSON record type 0x" + std::string(cr.data()), BasicJsonType())); - } - } - } - - /*! - @brief Read a BSON element list (as specified in the BSON-spec) - - The same binary layout is used for objects and arrays, hence it must be - indicated with the argument @a is_array which one is expected - (true --> array, false --> object). - - @param[in] is_array Determines if the element list being read is to be - treated as an object (@a is_array == false), or as an - array (@a is_array == true). - @return whether a valid BSON-object/array was passed to the SAX parser - */ - bool parse_bson_element_list(const bool is_array) - { - string_t key; - - while (auto element_type = get()) - { - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::bson, "element list"))) - { - return false; - } - - const std::size_t element_type_parse_position = chars_read; - if (JSON_HEDLEY_UNLIKELY(!get_bson_cstr(key))) - { - return false; - } - - if (!is_array && !sax->key(key)) - { - return false; - } - - if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position))) - { - return false; - } - - // get_bson_cstr only appends - key.clear(); - } - - return true; - } - - /*! - @brief Reads an array from the BSON input and passes it to the SAX-parser. - @return whether a valid BSON-array was passed to the SAX parser - */ - bool parse_bson_array() - { - std::int32_t document_size{}; - get_number(input_format_t::bson, document_size); - - if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1)))) - { - return false; - } - - if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_list(/*is_array*/true))) - { - return false; - } - - return sax->end_array(); - } - - ////////// - // CBOR // - ////////// - - /*! - @param[in] get_char whether a new character should be retrieved from the - input (true) or whether the last read character should - be considered instead (false) - @param[in] tag_handler how CBOR tags should be treated - - @return whether a valid CBOR value was passed to the SAX parser - */ - bool parse_cbor_internal(const bool get_char, - const cbor_tag_handler_t tag_handler) - { - switch (get_char ? get() : current) - { - // EOF - case std::char_traits::eof(): - return unexpect_eof(input_format_t::cbor, "value"); - - // Integer 0x00..0x17 (0..23) - case 0x00: - case 0x01: - case 0x02: - case 0x03: - case 0x04: - case 0x05: - case 0x06: - case 0x07: - case 0x08: - case 0x09: - case 0x0A: - case 0x0B: - case 0x0C: - case 0x0D: - case 0x0E: - case 0x0F: - case 0x10: - case 0x11: - case 0x12: - case 0x13: - case 0x14: - case 0x15: - case 0x16: - case 0x17: - return sax->number_unsigned(static_cast(current)); - - case 0x18: // Unsigned integer (one-byte uint8_t follows) - { - std::uint8_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_unsigned(number); - } - - case 0x19: // Unsigned integer (two-byte uint16_t follows) - { - std::uint16_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_unsigned(number); - } - - case 0x1A: // Unsigned integer (four-byte uint32_t follows) - { - std::uint32_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_unsigned(number); - } - - case 0x1B: // Unsigned integer (eight-byte uint64_t follows) - { - std::uint64_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_unsigned(number); - } - - // Negative integer -1-0x00..-1-0x17 (-1..-24) - case 0x20: - case 0x21: - case 0x22: - case 0x23: - case 0x24: - case 0x25: - case 0x26: - case 0x27: - case 0x28: - case 0x29: - case 0x2A: - case 0x2B: - case 0x2C: - case 0x2D: - case 0x2E: - case 0x2F: - case 0x30: - case 0x31: - case 0x32: - case 0x33: - case 0x34: - case 0x35: - case 0x36: - case 0x37: - return sax->number_integer(static_cast(0x20 - 1 - current)); - - case 0x38: // Negative integer (one-byte uint8_t follows) - { - std::uint8_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast(-1) - number); - } - - case 0x39: // Negative integer -1-n (two-byte uint16_t follows) - { - std::uint16_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast(-1) - number); - } - - case 0x3A: // Negative integer -1-n (four-byte uint32_t follows) - { - std::uint32_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast(-1) - number); - } - - case 0x3B: // Negative integer -1-n (eight-byte uint64_t follows) - { - std::uint64_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast(-1) - - static_cast(number)); - } - - // Binary data (0x00..0x17 bytes follow) - case 0x40: - case 0x41: - case 0x42: - case 0x43: - case 0x44: - case 0x45: - case 0x46: - case 0x47: - case 0x48: - case 0x49: - case 0x4A: - case 0x4B: - case 0x4C: - case 0x4D: - case 0x4E: - case 0x4F: - case 0x50: - case 0x51: - case 0x52: - case 0x53: - case 0x54: - case 0x55: - case 0x56: - case 0x57: - case 0x58: // Binary data (one-byte uint8_t for n follows) - case 0x59: // Binary data (two-byte uint16_t for n follow) - case 0x5A: // Binary data (four-byte uint32_t for n follow) - case 0x5B: // Binary data (eight-byte uint64_t for n follow) - case 0x5F: // Binary data (indefinite length) - { - binary_t b; - return get_cbor_binary(b) && sax->binary(b); - } - - // UTF-8 string (0x00..0x17 bytes follow) - case 0x60: - case 0x61: - case 0x62: - case 0x63: - case 0x64: - case 0x65: - case 0x66: - case 0x67: - case 0x68: - case 0x69: - case 0x6A: - case 0x6B: - case 0x6C: - case 0x6D: - case 0x6E: - case 0x6F: - case 0x70: - case 0x71: - case 0x72: - case 0x73: - case 0x74: - case 0x75: - case 0x76: - case 0x77: - case 0x78: // UTF-8 string (one-byte uint8_t for n follows) - case 0x79: // UTF-8 string (two-byte uint16_t for n follow) - case 0x7A: // UTF-8 string (four-byte uint32_t for n follow) - case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow) - case 0x7F: // UTF-8 string (indefinite length) - { - string_t s; - return get_cbor_string(s) && sax->string(s); - } - - // array (0x00..0x17 data items follow) - case 0x80: - case 0x81: - case 0x82: - case 0x83: - case 0x84: - case 0x85: - case 0x86: - case 0x87: - case 0x88: - case 0x89: - case 0x8A: - case 0x8B: - case 0x8C: - case 0x8D: - case 0x8E: - case 0x8F: - case 0x90: - case 0x91: - case 0x92: - case 0x93: - case 0x94: - case 0x95: - case 0x96: - case 0x97: - return get_cbor_array(static_cast(static_cast(current) & 0x1Fu), tag_handler); - - case 0x98: // array (one-byte uint8_t for n follows) - { - std::uint8_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast(len), tag_handler); - } - - case 0x99: // array (two-byte uint16_t for n follow) - { - std::uint16_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast(len), tag_handler); - } - - case 0x9A: // array (four-byte uint32_t for n follow) - { - std::uint32_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast(len), tag_handler); - } - - case 0x9B: // array (eight-byte uint64_t for n follow) - { - std::uint64_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_array(detail::conditional_static_cast(len), tag_handler); - } - - case 0x9F: // array (indefinite length) - return get_cbor_array(std::size_t(-1), tag_handler); - - // map (0x00..0x17 pairs of data items follow) - case 0xA0: - case 0xA1: - case 0xA2: - case 0xA3: - case 0xA4: - case 0xA5: - case 0xA6: - case 0xA7: - case 0xA8: - case 0xA9: - case 0xAA: - case 0xAB: - case 0xAC: - case 0xAD: - case 0xAE: - case 0xAF: - case 0xB0: - case 0xB1: - case 0xB2: - case 0xB3: - case 0xB4: - case 0xB5: - case 0xB6: - case 0xB7: - return get_cbor_object(static_cast(static_cast(current) & 0x1Fu), tag_handler); - - case 0xB8: // map (one-byte uint8_t for n follows) - { - std::uint8_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast(len), tag_handler); - } - - case 0xB9: // map (two-byte uint16_t for n follow) - { - std::uint16_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast(len), tag_handler); - } - - case 0xBA: // map (four-byte uint32_t for n follow) - { - std::uint32_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast(len), tag_handler); - } - - case 0xBB: // map (eight-byte uint64_t for n follow) - { - std::uint64_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_object(detail::conditional_static_cast(len), tag_handler); - } - - case 0xBF: // map (indefinite length) - return get_cbor_object(std::size_t(-1), tag_handler); - - case 0xC6: // tagged item - case 0xC7: - case 0xC8: - case 0xC9: - case 0xCA: - case 0xCB: - case 0xCC: - case 0xCD: - case 0xCE: - case 0xCF: - case 0xD0: - case 0xD1: - case 0xD2: - case 0xD3: - case 0xD4: - case 0xD8: // tagged item (1 bytes follow) - case 0xD9: // tagged item (2 bytes follow) - case 0xDA: // tagged item (4 bytes follow) - case 0xDB: // tagged item (8 bytes follow) - { - switch (tag_handler) - { - case cbor_tag_handler_t::error: - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::cbor, "invalid byte: 0x" + last_token, "value"), BasicJsonType())); - } - - case cbor_tag_handler_t::ignore: - { - // ignore binary subtype - switch (current) - { - case 0xD8: - { - std::uint8_t subtype_to_ignore{}; - get_number(input_format_t::cbor, subtype_to_ignore); - break; - } - case 0xD9: - { - std::uint16_t subtype_to_ignore{}; - get_number(input_format_t::cbor, subtype_to_ignore); - break; - } - case 0xDA: - { - std::uint32_t subtype_to_ignore{}; - get_number(input_format_t::cbor, subtype_to_ignore); - break; - } - case 0xDB: - { - std::uint64_t subtype_to_ignore{}; - get_number(input_format_t::cbor, subtype_to_ignore); - break; - } - default: - break; - } - return parse_cbor_internal(true, tag_handler); - } - - case cbor_tag_handler_t::store: - { - binary_t b; - // use binary subtype and store in binary container - switch (current) - { - case 0xD8: - { - std::uint8_t subtype{}; - get_number(input_format_t::cbor, subtype); - b.set_subtype(detail::conditional_static_cast(subtype)); - break; - } - case 0xD9: - { - std::uint16_t subtype{}; - get_number(input_format_t::cbor, subtype); - b.set_subtype(detail::conditional_static_cast(subtype)); - break; - } - case 0xDA: - { - std::uint32_t subtype{}; - get_number(input_format_t::cbor, subtype); - b.set_subtype(detail::conditional_static_cast(subtype)); - break; - } - case 0xDB: - { - std::uint64_t subtype{}; - get_number(input_format_t::cbor, subtype); - b.set_subtype(detail::conditional_static_cast(subtype)); - break; - } - default: - return parse_cbor_internal(true, tag_handler); - } - get(); - return get_cbor_binary(b) && sax->binary(b); - } - - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE - return false; // LCOV_EXCL_LINE - } - } - - case 0xF4: // false - return sax->boolean(false); - - case 0xF5: // true - return sax->boolean(true); - - case 0xF6: // null - return sax->null(); - - case 0xF9: // Half-Precision Float (two-byte IEEE 754) - { - const auto byte1_raw = get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "number"))) - { - return false; - } - const auto byte2_raw = get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "number"))) - { - return false; - } - - const auto byte1 = static_cast(byte1_raw); - const auto byte2 = static_cast(byte2_raw); - - // code from RFC 7049, Appendix D, Figure 3: - // As half-precision floating-point numbers were only added - // to IEEE 754 in 2008, today's programming platforms often - // still only have limited support for them. It is very - // easy to include at least decoding support for them even - // without such support. An example of a small decoder for - // half-precision floating-point numbers in the C language - // is shown in Fig. 3. - const auto half = static_cast((byte1 << 8u) + byte2); - const double val = [&half] - { - const int exp = (half >> 10u) & 0x1Fu; - const unsigned int mant = half & 0x3FFu; - JSON_ASSERT(0 <= exp&& exp <= 32); - JSON_ASSERT(mant <= 1024); - switch (exp) - { - case 0: - return std::ldexp(mant, -24); - case 31: - return (mant == 0) - ? std::numeric_limits::infinity() - : std::numeric_limits::quiet_NaN(); - default: - return std::ldexp(mant + 1024, exp - 25); - } - }(); - return sax->number_float((half & 0x8000u) != 0 - ? static_cast(-val) - : static_cast(val), ""); - } - - case 0xFA: // Single-Precision Float (four-byte IEEE 754) - { - float number{}; - return get_number(input_format_t::cbor, number) && sax->number_float(static_cast(number), ""); - } - - case 0xFB: // Double-Precision Float (eight-byte IEEE 754) - { - double number{}; - return get_number(input_format_t::cbor, number) && sax->number_float(static_cast(number), ""); - } - - default: // anything else (0xFF is handled inside the other types) - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::cbor, "invalid byte: 0x" + last_token, "value"), BasicJsonType())); - } - } - } - - /*! - @brief reads a CBOR string - - This function first reads starting bytes to determine the expected - string length and then copies this number of bytes into a string. - Additionally, CBOR's strings with indefinite lengths are supported. - - @param[out] result created string - - @return whether string creation completed - */ - bool get_cbor_string(string_t& result) - { - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "string"))) - { - return false; - } - - switch (current) - { - // UTF-8 string (0x00..0x17 bytes follow) - case 0x60: - case 0x61: - case 0x62: - case 0x63: - case 0x64: - case 0x65: - case 0x66: - case 0x67: - case 0x68: - case 0x69: - case 0x6A: - case 0x6B: - case 0x6C: - case 0x6D: - case 0x6E: - case 0x6F: - case 0x70: - case 0x71: - case 0x72: - case 0x73: - case 0x74: - case 0x75: - case 0x76: - case 0x77: - { - return get_string(input_format_t::cbor, static_cast(current) & 0x1Fu, result); - } - - case 0x78: // UTF-8 string (one-byte uint8_t for n follows) - { - std::uint8_t len{}; - return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); - } - - case 0x79: // UTF-8 string (two-byte uint16_t for n follow) - { - std::uint16_t len{}; - return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); - } - - case 0x7A: // UTF-8 string (four-byte uint32_t for n follow) - { - std::uint32_t len{}; - return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); - } - - case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow) - { - std::uint64_t len{}; - return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); - } - - case 0x7F: // UTF-8 string (indefinite length) - { - while (get() != 0xFF) - { - string_t chunk; - if (!get_cbor_string(chunk)) - { - return false; - } - result.append(chunk); - } - return true; - } - - default: - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::cbor, "expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x" + last_token, "string"), BasicJsonType())); - } - } - } - - /*! - @brief reads a CBOR byte array - - This function first reads starting bytes to determine the expected - byte array length and then copies this number of bytes into the byte array. - Additionally, CBOR's byte arrays with indefinite lengths are supported. - - @param[out] result created byte array - - @return whether byte array creation completed - */ - bool get_cbor_binary(binary_t& result) - { - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "binary"))) - { - return false; - } - - switch (current) - { - // Binary data (0x00..0x17 bytes follow) - case 0x40: - case 0x41: - case 0x42: - case 0x43: - case 0x44: - case 0x45: - case 0x46: - case 0x47: - case 0x48: - case 0x49: - case 0x4A: - case 0x4B: - case 0x4C: - case 0x4D: - case 0x4E: - case 0x4F: - case 0x50: - case 0x51: - case 0x52: - case 0x53: - case 0x54: - case 0x55: - case 0x56: - case 0x57: - { - return get_binary(input_format_t::cbor, static_cast(current) & 0x1Fu, result); - } - - case 0x58: // Binary data (one-byte uint8_t for n follows) - { - std::uint8_t len{}; - return get_number(input_format_t::cbor, len) && - get_binary(input_format_t::cbor, len, result); - } - - case 0x59: // Binary data (two-byte uint16_t for n follow) - { - std::uint16_t len{}; - return get_number(input_format_t::cbor, len) && - get_binary(input_format_t::cbor, len, result); - } - - case 0x5A: // Binary data (four-byte uint32_t for n follow) - { - std::uint32_t len{}; - return get_number(input_format_t::cbor, len) && - get_binary(input_format_t::cbor, len, result); - } - - case 0x5B: // Binary data (eight-byte uint64_t for n follow) - { - std::uint64_t len{}; - return get_number(input_format_t::cbor, len) && - get_binary(input_format_t::cbor, len, result); - } - - case 0x5F: // Binary data (indefinite length) - { - while (get() != 0xFF) - { - binary_t chunk; - if (!get_cbor_binary(chunk)) - { - return false; - } - result.insert(result.end(), chunk.begin(), chunk.end()); - } - return true; - } - - default: - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::cbor, "expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x" + last_token, "binary"), BasicJsonType())); - } - } - } - - /*! - @param[in] len the length of the array or std::size_t(-1) for an - array of indefinite size - @param[in] tag_handler how CBOR tags should be treated - @return whether array creation completed - */ - bool get_cbor_array(const std::size_t len, - const cbor_tag_handler_t tag_handler) - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_array(len))) - { - return false; - } - - if (len != std::size_t(-1)) - { - for (std::size_t i = 0; i < len; ++i) - { - if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(true, tag_handler))) - { - return false; - } - } - } - else - { - while (get() != 0xFF) - { - if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(false, tag_handler))) - { - return false; - } - } - } - - return sax->end_array(); - } - - /*! - @param[in] len the length of the object or std::size_t(-1) for an - object of indefinite size - @param[in] tag_handler how CBOR tags should be treated - @return whether object creation completed - */ - bool get_cbor_object(const std::size_t len, - const cbor_tag_handler_t tag_handler) - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(len))) - { - return false; - } - - if (len != 0) - { - string_t key; - if (len != std::size_t(-1)) - { - for (std::size_t i = 0; i < len; ++i) - { - get(); - if (JSON_HEDLEY_UNLIKELY(!get_cbor_string(key) || !sax->key(key))) - { - return false; - } - - if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(true, tag_handler))) - { - return false; - } - key.clear(); - } - } - else - { - while (get() != 0xFF) - { - if (JSON_HEDLEY_UNLIKELY(!get_cbor_string(key) || !sax->key(key))) - { - return false; - } - - if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(true, tag_handler))) - { - return false; - } - key.clear(); - } - } - } - - return sax->end_object(); - } - - ///////////// - // MsgPack // - ///////////// - - /*! - @return whether a valid MessagePack value was passed to the SAX parser - */ - bool parse_msgpack_internal() - { - switch (get()) - { - // EOF - case std::char_traits::eof(): - return unexpect_eof(input_format_t::msgpack, "value"); - - // positive fixint - case 0x00: - case 0x01: - case 0x02: - case 0x03: - case 0x04: - case 0x05: - case 0x06: - case 0x07: - case 0x08: - case 0x09: - case 0x0A: - case 0x0B: - case 0x0C: - case 0x0D: - case 0x0E: - case 0x0F: - case 0x10: - case 0x11: - case 0x12: - case 0x13: - case 0x14: - case 0x15: - case 0x16: - case 0x17: - case 0x18: - case 0x19: - case 0x1A: - case 0x1B: - case 0x1C: - case 0x1D: - case 0x1E: - case 0x1F: - case 0x20: - case 0x21: - case 0x22: - case 0x23: - case 0x24: - case 0x25: - case 0x26: - case 0x27: - case 0x28: - case 0x29: - case 0x2A: - case 0x2B: - case 0x2C: - case 0x2D: - case 0x2E: - case 0x2F: - case 0x30: - case 0x31: - case 0x32: - case 0x33: - case 0x34: - case 0x35: - case 0x36: - case 0x37: - case 0x38: - case 0x39: - case 0x3A: - case 0x3B: - case 0x3C: - case 0x3D: - case 0x3E: - case 0x3F: - case 0x40: - case 0x41: - case 0x42: - case 0x43: - case 0x44: - case 0x45: - case 0x46: - case 0x47: - case 0x48: - case 0x49: - case 0x4A: - case 0x4B: - case 0x4C: - case 0x4D: - case 0x4E: - case 0x4F: - case 0x50: - case 0x51: - case 0x52: - case 0x53: - case 0x54: - case 0x55: - case 0x56: - case 0x57: - case 0x58: - case 0x59: - case 0x5A: - case 0x5B: - case 0x5C: - case 0x5D: - case 0x5E: - case 0x5F: - case 0x60: - case 0x61: - case 0x62: - case 0x63: - case 0x64: - case 0x65: - case 0x66: - case 0x67: - case 0x68: - case 0x69: - case 0x6A: - case 0x6B: - case 0x6C: - case 0x6D: - case 0x6E: - case 0x6F: - case 0x70: - case 0x71: - case 0x72: - case 0x73: - case 0x74: - case 0x75: - case 0x76: - case 0x77: - case 0x78: - case 0x79: - case 0x7A: - case 0x7B: - case 0x7C: - case 0x7D: - case 0x7E: - case 0x7F: - return sax->number_unsigned(static_cast(current)); - - // fixmap - case 0x80: - case 0x81: - case 0x82: - case 0x83: - case 0x84: - case 0x85: - case 0x86: - case 0x87: - case 0x88: - case 0x89: - case 0x8A: - case 0x8B: - case 0x8C: - case 0x8D: - case 0x8E: - case 0x8F: - return get_msgpack_object(static_cast(static_cast(current) & 0x0Fu)); - - // fixarray - case 0x90: - case 0x91: - case 0x92: - case 0x93: - case 0x94: - case 0x95: - case 0x96: - case 0x97: - case 0x98: - case 0x99: - case 0x9A: - case 0x9B: - case 0x9C: - case 0x9D: - case 0x9E: - case 0x9F: - return get_msgpack_array(static_cast(static_cast(current) & 0x0Fu)); - - // fixstr - case 0xA0: - case 0xA1: - case 0xA2: - case 0xA3: - case 0xA4: - case 0xA5: - case 0xA6: - case 0xA7: - case 0xA8: - case 0xA9: - case 0xAA: - case 0xAB: - case 0xAC: - case 0xAD: - case 0xAE: - case 0xAF: - case 0xB0: - case 0xB1: - case 0xB2: - case 0xB3: - case 0xB4: - case 0xB5: - case 0xB6: - case 0xB7: - case 0xB8: - case 0xB9: - case 0xBA: - case 0xBB: - case 0xBC: - case 0xBD: - case 0xBE: - case 0xBF: - case 0xD9: // str 8 - case 0xDA: // str 16 - case 0xDB: // str 32 - { - string_t s; - return get_msgpack_string(s) && sax->string(s); - } - - case 0xC0: // nil - return sax->null(); - - case 0xC2: // false - return sax->boolean(false); - - case 0xC3: // true - return sax->boolean(true); - - case 0xC4: // bin 8 - case 0xC5: // bin 16 - case 0xC6: // bin 32 - case 0xC7: // ext 8 - case 0xC8: // ext 16 - case 0xC9: // ext 32 - case 0xD4: // fixext 1 - case 0xD5: // fixext 2 - case 0xD6: // fixext 4 - case 0xD7: // fixext 8 - case 0xD8: // fixext 16 - { - binary_t b; - return get_msgpack_binary(b) && sax->binary(b); - } - - case 0xCA: // float 32 - { - float number{}; - return get_number(input_format_t::msgpack, number) && sax->number_float(static_cast(number), ""); - } - - case 0xCB: // float 64 - { - double number{}; - return get_number(input_format_t::msgpack, number) && sax->number_float(static_cast(number), ""); - } - - case 0xCC: // uint 8 - { - std::uint8_t number{}; - return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number); - } - - case 0xCD: // uint 16 - { - std::uint16_t number{}; - return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number); - } - - case 0xCE: // uint 32 - { - std::uint32_t number{}; - return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number); - } - - case 0xCF: // uint 64 - { - std::uint64_t number{}; - return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number); - } - - case 0xD0: // int 8 - { - std::int8_t number{}; - return get_number(input_format_t::msgpack, number) && sax->number_integer(number); - } - - case 0xD1: // int 16 - { - std::int16_t number{}; - return get_number(input_format_t::msgpack, number) && sax->number_integer(number); - } - - case 0xD2: // int 32 - { - std::int32_t number{}; - return get_number(input_format_t::msgpack, number) && sax->number_integer(number); - } - - case 0xD3: // int 64 - { - std::int64_t number{}; - return get_number(input_format_t::msgpack, number) && sax->number_integer(number); - } - - case 0xDC: // array 16 - { - std::uint16_t len{}; - return get_number(input_format_t::msgpack, len) && get_msgpack_array(static_cast(len)); - } - - case 0xDD: // array 32 - { - std::uint32_t len{}; - return get_number(input_format_t::msgpack, len) && get_msgpack_array(static_cast(len)); - } - - case 0xDE: // map 16 - { - std::uint16_t len{}; - return get_number(input_format_t::msgpack, len) && get_msgpack_object(static_cast(len)); - } - - case 0xDF: // map 32 - { - std::uint32_t len{}; - return get_number(input_format_t::msgpack, len) && get_msgpack_object(static_cast(len)); - } - - // negative fixint - case 0xE0: - case 0xE1: - case 0xE2: - case 0xE3: - case 0xE4: - case 0xE5: - case 0xE6: - case 0xE7: - case 0xE8: - case 0xE9: - case 0xEA: - case 0xEB: - case 0xEC: - case 0xED: - case 0xEE: - case 0xEF: - case 0xF0: - case 0xF1: - case 0xF2: - case 0xF3: - case 0xF4: - case 0xF5: - case 0xF6: - case 0xF7: - case 0xF8: - case 0xF9: - case 0xFA: - case 0xFB: - case 0xFC: - case 0xFD: - case 0xFE: - case 0xFF: - return sax->number_integer(static_cast(current)); - - default: // anything else - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::msgpack, "invalid byte: 0x" + last_token, "value"), BasicJsonType())); - } - } - } - - /*! - @brief reads a MessagePack string - - This function first reads starting bytes to determine the expected - string length and then copies this number of bytes into a string. - - @param[out] result created string - - @return whether string creation completed - */ - bool get_msgpack_string(string_t& result) - { - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::msgpack, "string"))) - { - return false; - } - - switch (current) - { - // fixstr - case 0xA0: - case 0xA1: - case 0xA2: - case 0xA3: - case 0xA4: - case 0xA5: - case 0xA6: - case 0xA7: - case 0xA8: - case 0xA9: - case 0xAA: - case 0xAB: - case 0xAC: - case 0xAD: - case 0xAE: - case 0xAF: - case 0xB0: - case 0xB1: - case 0xB2: - case 0xB3: - case 0xB4: - case 0xB5: - case 0xB6: - case 0xB7: - case 0xB8: - case 0xB9: - case 0xBA: - case 0xBB: - case 0xBC: - case 0xBD: - case 0xBE: - case 0xBF: - { - return get_string(input_format_t::msgpack, static_cast(current) & 0x1Fu, result); - } - - case 0xD9: // str 8 - { - std::uint8_t len{}; - return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result); - } - - case 0xDA: // str 16 - { - std::uint16_t len{}; - return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result); - } - - case 0xDB: // str 32 - { - std::uint32_t len{}; - return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result); - } - - default: - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::msgpack, "expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x" + last_token, "string"), BasicJsonType())); - } - } - } - - /*! - @brief reads a MessagePack byte array - - This function first reads starting bytes to determine the expected - byte array length and then copies this number of bytes into a byte array. - - @param[out] result created byte array - - @return whether byte array creation completed - */ - bool get_msgpack_binary(binary_t& result) - { - // helper function to set the subtype - auto assign_and_return_true = [&result](std::int8_t subtype) - { - result.set_subtype(static_cast(subtype)); - return true; - }; - - switch (current) - { - case 0xC4: // bin 8 - { - std::uint8_t len{}; - return get_number(input_format_t::msgpack, len) && - get_binary(input_format_t::msgpack, len, result); - } - - case 0xC5: // bin 16 - { - std::uint16_t len{}; - return get_number(input_format_t::msgpack, len) && - get_binary(input_format_t::msgpack, len, result); - } - - case 0xC6: // bin 32 - { - std::uint32_t len{}; - return get_number(input_format_t::msgpack, len) && - get_binary(input_format_t::msgpack, len, result); - } - - case 0xC7: // ext 8 - { - std::uint8_t len{}; - std::int8_t subtype{}; - return get_number(input_format_t::msgpack, len) && - get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, len, result) && - assign_and_return_true(subtype); - } - - case 0xC8: // ext 16 - { - std::uint16_t len{}; - std::int8_t subtype{}; - return get_number(input_format_t::msgpack, len) && - get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, len, result) && - assign_and_return_true(subtype); - } - - case 0xC9: // ext 32 - { - std::uint32_t len{}; - std::int8_t subtype{}; - return get_number(input_format_t::msgpack, len) && - get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, len, result) && - assign_and_return_true(subtype); - } - - case 0xD4: // fixext 1 - { - std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 1, result) && - assign_and_return_true(subtype); - } - - case 0xD5: // fixext 2 - { - std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 2, result) && - assign_and_return_true(subtype); - } - - case 0xD6: // fixext 4 - { - std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 4, result) && - assign_and_return_true(subtype); - } - - case 0xD7: // fixext 8 - { - std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 8, result) && - assign_and_return_true(subtype); - } - - case 0xD8: // fixext 16 - { - std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 16, result) && - assign_and_return_true(subtype); - } - - default: // LCOV_EXCL_LINE - return false; // LCOV_EXCL_LINE - } - } - - /*! - @param[in] len the length of the array - @return whether array creation completed - */ - bool get_msgpack_array(const std::size_t len) - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_array(len))) - { - return false; - } - - for (std::size_t i = 0; i < len; ++i) - { - if (JSON_HEDLEY_UNLIKELY(!parse_msgpack_internal())) - { - return false; - } - } - - return sax->end_array(); - } - - /*! - @param[in] len the length of the object - @return whether object creation completed - */ - bool get_msgpack_object(const std::size_t len) - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(len))) - { - return false; - } - - string_t key; - for (std::size_t i = 0; i < len; ++i) - { - get(); - if (JSON_HEDLEY_UNLIKELY(!get_msgpack_string(key) || !sax->key(key))) - { - return false; - } - - if (JSON_HEDLEY_UNLIKELY(!parse_msgpack_internal())) - { - return false; - } - key.clear(); - } - - return sax->end_object(); - } - - //////////// - // UBJSON // - //////////// - - /*! - @param[in] get_char whether a new character should be retrieved from the - input (true, default) or whether the last read - character should be considered instead - - @return whether a valid UBJSON value was passed to the SAX parser - */ - bool parse_ubjson_internal(const bool get_char = true) - { - return get_ubjson_value(get_char ? get_ignore_noop() : current); - } - - /*! - @brief reads a UBJSON string - - This function is either called after reading the 'S' byte explicitly - indicating a string, or in case of an object key where the 'S' byte can be - left out. - - @param[out] result created string - @param[in] get_char whether a new character should be retrieved from the - input (true, default) or whether the last read - character should be considered instead - - @return whether string creation completed - */ - bool get_ubjson_string(string_t& result, const bool get_char = true) - { - if (get_char) - { - get(); // TODO(niels): may we ignore N here? - } - - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "value"))) - { - return false; - } - - switch (current) - { - case 'U': - { - std::uint8_t len{}; - return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); - } - - case 'i': - { - std::int8_t len{}; - return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); - } - - case 'I': - { - std::int16_t len{}; - return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); - } - - case 'l': - { - std::int32_t len{}; - return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); - } - - case 'L': - { - std::int64_t len{}; - return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); - } - - default: - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "expected length type specification (U, i, I, l, L); last byte: 0x" + last_token, "string"), BasicJsonType())); - } - } - - /*! - @param[out] result determined size - @return whether size determination completed - */ - bool get_ubjson_size_value(std::size_t& result) - { - switch (get_ignore_noop()) - { - case 'U': - { - std::uint8_t number{}; - if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number))) - { - return false; - } - result = static_cast(number); - return true; - } - - case 'i': - { - std::int8_t number{}; - if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number))) - { - return false; - } - result = static_cast(number); // NOLINT(bugprone-signed-char-misuse,cert-str34-c): number is not a char - return true; - } - - case 'I': - { - std::int16_t number{}; - if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number))) - { - return false; - } - result = static_cast(number); - return true; - } - - case 'l': - { - std::int32_t number{}; - if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number))) - { - return false; - } - result = static_cast(number); - return true; - } - - case 'L': - { - std::int64_t number{}; - if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number))) - { - return false; - } - result = static_cast(number); - return true; - } - - default: - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token, "size"), BasicJsonType())); - } - } - } - - /*! - @brief determine the type and size for a container - - In the optimized UBJSON format, a type and a size can be provided to allow - for a more compact representation. - - @param[out] result pair of the size and the type - - @return whether pair creation completed - */ - bool get_ubjson_size_type(std::pair& result) - { - result.first = string_t::npos; // size - result.second = 0; // type - - get_ignore_noop(); - - if (current == '$') - { - result.second = get(); // must not ignore 'N', because 'N' maybe the type - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "type"))) - { - return false; - } - - get_ignore_noop(); - if (JSON_HEDLEY_UNLIKELY(current != '#')) - { - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "value"))) - { - return false; - } - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::ubjson, "expected '#' after type information; last byte: 0x" + last_token, "size"), BasicJsonType())); - } - - return get_ubjson_size_value(result.first); - } - - if (current == '#') - { - return get_ubjson_size_value(result.first); - } - - return true; - } - - /*! - @param prefix the previously read or set type prefix - @return whether value creation completed - */ - bool get_ubjson_value(const char_int_type prefix) - { - switch (prefix) - { - case std::char_traits::eof(): // EOF - return unexpect_eof(input_format_t::ubjson, "value"); - - case 'T': // true - return sax->boolean(true); - case 'F': // false - return sax->boolean(false); - - case 'Z': // null - return sax->null(); - - case 'U': - { - std::uint8_t number{}; - return get_number(input_format_t::ubjson, number) && sax->number_unsigned(number); - } - - case 'i': - { - std::int8_t number{}; - return get_number(input_format_t::ubjson, number) && sax->number_integer(number); - } - - case 'I': - { - std::int16_t number{}; - return get_number(input_format_t::ubjson, number) && sax->number_integer(number); - } - - case 'l': - { - std::int32_t number{}; - return get_number(input_format_t::ubjson, number) && sax->number_integer(number); - } - - case 'L': - { - std::int64_t number{}; - return get_number(input_format_t::ubjson, number) && sax->number_integer(number); - } - - case 'd': - { - float number{}; - return get_number(input_format_t::ubjson, number) && sax->number_float(static_cast(number), ""); - } - - case 'D': - { - double number{}; - return get_number(input_format_t::ubjson, number) && sax->number_float(static_cast(number), ""); - } - - case 'H': - { - return get_ubjson_high_precision_number(); - } - - case 'C': // char - { - get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "char"))) - { - return false; - } - if (JSON_HEDLEY_UNLIKELY(current > 127)) - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "byte after 'C' must be in range 0x00..0x7F; last byte: 0x" + last_token, "char"), BasicJsonType())); - } - string_t s(1, static_cast(current)); - return sax->string(s); - } - - case 'S': // string - { - string_t s; - return get_ubjson_string(s) && sax->string(s); - } - - case '[': // array - return get_ubjson_array(); - - case '{': // object - return get_ubjson_object(); - - default: // anything else - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::ubjson, "invalid byte: 0x" + last_token, "value"), BasicJsonType())); - } - } - } - - /*! - @return whether array creation completed - */ - bool get_ubjson_array() - { - std::pair size_and_type; - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_type(size_and_type))) - { - return false; - } - - if (size_and_type.first != string_t::npos) - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_array(size_and_type.first))) - { - return false; - } - - if (size_and_type.second != 0) - { - if (size_and_type.second != 'N') - { - for (std::size_t i = 0; i < size_and_type.first; ++i) - { - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_value(size_and_type.second))) - { - return false; - } - } - } - } - else - { - for (std::size_t i = 0; i < size_and_type.first; ++i) - { - if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal())) - { - return false; - } - } - } - } - else - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1)))) - { - return false; - } - - while (current != ']') - { - if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal(false))) - { - return false; - } - get_ignore_noop(); - } - } - - return sax->end_array(); - } - - /*! - @return whether object creation completed - */ - bool get_ubjson_object() - { - std::pair size_and_type; - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_type(size_and_type))) - { - return false; - } - - string_t key; - if (size_and_type.first != string_t::npos) - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(size_and_type.first))) - { - return false; - } - - if (size_and_type.second != 0) - { - for (std::size_t i = 0; i < size_and_type.first; ++i) - { - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_string(key) || !sax->key(key))) - { - return false; - } - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_value(size_and_type.second))) - { - return false; - } - key.clear(); - } - } - else - { - for (std::size_t i = 0; i < size_and_type.first; ++i) - { - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_string(key) || !sax->key(key))) - { - return false; - } - if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal())) - { - return false; - } - key.clear(); - } - } - } - else - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1)))) - { - return false; - } - - while (current != '}') - { - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_string(key, false) || !sax->key(key))) - { - return false; - } - if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal())) - { - return false; - } - get_ignore_noop(); - key.clear(); - } - } - - return sax->end_object(); - } - - // Note, no reader for UBJSON binary types is implemented because they do - // not exist - - bool get_ubjson_high_precision_number() - { - // get size of following number string - std::size_t size{}; - auto res = get_ubjson_size_value(size); - if (JSON_HEDLEY_UNLIKELY(!res)) - { - return res; - } - - // get number string - std::vector number_vector; - for (std::size_t i = 0; i < size; ++i) - { - get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "number"))) - { - return false; - } - number_vector.push_back(static_cast(current)); - } - - // parse number string - using ia_type = decltype(detail::input_adapter(number_vector)); - auto number_lexer = detail::lexer(detail::input_adapter(number_vector), false); - const auto result_number = number_lexer.scan(); - const auto number_string = number_lexer.get_token_string(); - const auto result_remainder = number_lexer.scan(); - - using token_type = typename detail::lexer_base::token_type; - - if (JSON_HEDLEY_UNLIKELY(result_remainder != token_type::end_of_input)) - { - return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read, exception_message(input_format_t::ubjson, "invalid number text: " + number_lexer.get_token_string(), "high-precision number"), BasicJsonType())); - } - - switch (result_number) - { - case token_type::value_integer: - return sax->number_integer(number_lexer.get_number_integer()); - case token_type::value_unsigned: - return sax->number_unsigned(number_lexer.get_number_unsigned()); - case token_type::value_float: - return sax->number_float(number_lexer.get_number_float(), std::move(number_string)); - case token_type::uninitialized: - case token_type::literal_true: - case token_type::literal_false: - case token_type::literal_null: - case token_type::value_string: - case token_type::begin_array: - case token_type::begin_object: - case token_type::end_array: - case token_type::end_object: - case token_type::name_separator: - case token_type::value_separator: - case token_type::parse_error: - case token_type::end_of_input: - case token_type::literal_or_value: - default: - return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read, exception_message(input_format_t::ubjson, "invalid number text: " + number_lexer.get_token_string(), "high-precision number"), BasicJsonType())); - } - } - - /////////////////////// - // Utility functions // - /////////////////////// - - /*! - @brief get next character from the input - - This function provides the interface to the used input adapter. It does - not throw in case the input reached EOF, but returns a -'ve valued - `std::char_traits::eof()` in that case. - - @return character read from the input - */ - char_int_type get() - { - ++chars_read; - return current = ia.get_character(); - } - - /*! - @return character read from the input after ignoring all 'N' entries - */ - char_int_type get_ignore_noop() - { - do - { - get(); - } - while (current == 'N'); - - return current; - } - - /* - @brief read a number from the input - - @tparam NumberType the type of the number - @param[in] format the current format (for diagnostics) - @param[out] result number of type @a NumberType - - @return whether conversion completed - - @note This function needs to respect the system's endianess, because - bytes in CBOR, MessagePack, and UBJSON are stored in network order - (big endian) and therefore need reordering on little endian systems. - */ - template - bool get_number(const input_format_t format, NumberType& result) - { - // step 1: read input into array with system's byte order - std::array vec{}; - for (std::size_t i = 0; i < sizeof(NumberType); ++i) - { - get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format, "number"))) - { - return false; - } - - // reverse byte order prior to conversion if necessary - if (is_little_endian != InputIsLittleEndian) - { - vec[sizeof(NumberType) - i - 1] = static_cast(current); - } - else - { - vec[i] = static_cast(current); // LCOV_EXCL_LINE - } - } - - // step 2: convert array into number of type T and return - std::memcpy(&result, vec.data(), sizeof(NumberType)); - return true; - } - - /*! - @brief create a string by reading characters from the input - - @tparam NumberType the type of the number - @param[in] format the current format (for diagnostics) - @param[in] len number of characters to read - @param[out] result string created by reading @a len bytes - - @return whether string creation completed - - @note We can not reserve @a len bytes for the result, because @a len - may be too large. Usually, @ref unexpect_eof() detects the end of - the input before we run out of string memory. - */ - template - bool get_string(const input_format_t format, - const NumberType len, - string_t& result) - { - bool success = true; - for (NumberType i = 0; i < len; i++) - { - get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format, "string"))) - { - success = false; - break; - } - result.push_back(static_cast(current)); - } - return success; - } - - /*! - @brief create a byte array by reading bytes from the input - - @tparam NumberType the type of the number - @param[in] format the current format (for diagnostics) - @param[in] len number of bytes to read - @param[out] result byte array created by reading @a len bytes - - @return whether byte array creation completed - - @note We can not reserve @a len bytes for the result, because @a len - may be too large. Usually, @ref unexpect_eof() detects the end of - the input before we run out of memory. - */ - template - bool get_binary(const input_format_t format, - const NumberType len, - binary_t& result) - { - bool success = true; - for (NumberType i = 0; i < len; i++) - { - get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format, "binary"))) - { - success = false; - break; - } - result.push_back(static_cast(current)); - } - return success; - } - - /*! - @param[in] format the current format (for diagnostics) - @param[in] context further context information (for diagnostics) - @return whether the last read character is not EOF - */ - JSON_HEDLEY_NON_NULL(3) - bool unexpect_eof(const input_format_t format, const char* context) const - { - if (JSON_HEDLEY_UNLIKELY(current == std::char_traits::eof())) - { - return sax->parse_error(chars_read, "", - parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context), BasicJsonType())); - } - return true; - } - - /*! - @return a string representation of the last read byte - */ - std::string get_token_string() const - { - std::array cr{{}}; - (std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast(current)); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) - return std::string{cr.data()}; - } - - /*! - @param[in] format the current format - @param[in] detail a detailed error message - @param[in] context further context information - @return a message string to use in the parse_error exceptions - */ - std::string exception_message(const input_format_t format, - const std::string& detail, - const std::string& context) const - { - std::string error_msg = "syntax error while parsing "; - - switch (format) - { - case input_format_t::cbor: - error_msg += "CBOR"; - break; - - case input_format_t::msgpack: - error_msg += "MessagePack"; - break; - - case input_format_t::ubjson: - error_msg += "UBJSON"; - break; - - case input_format_t::bson: - error_msg += "BSON"; - break; - - case input_format_t::json: // LCOV_EXCL_LINE - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE - } - - return error_msg + " " + context + ": " + detail; - } - - private: - /// input adapter - InputAdapterType ia; - - /// the current character - char_int_type current = std::char_traits::eof(); - - /// the number of characters read - std::size_t chars_read = 0; - - /// whether we can assume little endianess - const bool is_little_endian = little_endianess(); - - /// the SAX parser - json_sax_t* sax = nullptr; -}; -} // namespace detail -} // namespace nlohmann - -// #include - -// #include - -// #include - - -#include // isfinite -#include // uint8_t -#include // function -#include // string -#include // move -#include // vector - -// #include - -// #include - -// #include - -// #include - -// #include - -// #include - -// #include - - -namespace nlohmann -{ -namespace detail -{ -//////////// -// parser // -//////////// - -enum class parse_event_t : std::uint8_t -{ - /// the parser read `{` and started to process a JSON object - object_start, - /// the parser read `}` and finished processing a JSON object - object_end, - /// the parser read `[` and started to process a JSON array - array_start, - /// the parser read `]` and finished processing a JSON array - array_end, - /// the parser read a key of a value in an object - key, - /// the parser finished reading a JSON value - value -}; - -template -using parser_callback_t = - std::function; - -/*! -@brief syntax analysis - -This class implements a recursive descent parser. -*/ -template -class parser -{ - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using lexer_t = lexer; - using token_type = typename lexer_t::token_type; - - public: - /// a parser reading from an input adapter - explicit parser(InputAdapterType&& adapter, - const parser_callback_t cb = nullptr, - const bool allow_exceptions_ = true, - const bool skip_comments = false) - : callback(cb) - , m_lexer(std::move(adapter), skip_comments) - , allow_exceptions(allow_exceptions_) - { - // read first token - get_token(); - } - - /*! - @brief public parser interface - - @param[in] strict whether to expect the last token to be EOF - @param[in,out] result parsed JSON value - - @throw parse_error.101 in case of an unexpected token - @throw parse_error.102 if to_unicode fails or surrogate error - @throw parse_error.103 if to_unicode fails - */ - void parse(const bool strict, BasicJsonType& result) - { - if (callback) - { - json_sax_dom_callback_parser sdp(result, callback, allow_exceptions); - sax_parse_internal(&sdp); - - // in strict mode, input must be completely read - if (strict && (get_token() != token_type::end_of_input)) - { - sdp.parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), - exception_message(token_type::end_of_input, "value"), BasicJsonType())); - } - - // in case of an error, return discarded value - if (sdp.is_errored()) - { - result = value_t::discarded; - return; - } - - // set top-level value to null if it was discarded by the callback - // function - if (result.is_discarded()) - { - result = nullptr; - } - } - else - { - json_sax_dom_parser sdp(result, allow_exceptions); - sax_parse_internal(&sdp); - - // in strict mode, input must be completely read - if (strict && (get_token() != token_type::end_of_input)) - { - sdp.parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input, "value"), BasicJsonType())); - } - - // in case of an error, return discarded value - if (sdp.is_errored()) - { - result = value_t::discarded; - return; - } - } - - result.assert_invariant(); - } - - /*! - @brief public accept interface - - @param[in] strict whether to expect the last token to be EOF - @return whether the input is a proper JSON text - */ - bool accept(const bool strict = true) - { - json_sax_acceptor sax_acceptor; - return sax_parse(&sax_acceptor, strict); - } - - template - JSON_HEDLEY_NON_NULL(2) - bool sax_parse(SAX* sax, const bool strict = true) - { - (void)detail::is_sax_static_asserts {}; - const bool result = sax_parse_internal(sax); - - // strict mode: next byte must be EOF - if (result && strict && (get_token() != token_type::end_of_input)) - { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input, "value"), BasicJsonType())); - } - - return result; - } - - private: - template - JSON_HEDLEY_NON_NULL(2) - bool sax_parse_internal(SAX* sax) - { - // stack to remember the hierarchy of structured values we are parsing - // true = array; false = object - std::vector states; - // value to avoid a goto (see comment where set to true) - bool skip_to_state_evaluation = false; - - while (true) - { - if (!skip_to_state_evaluation) - { - // invariant: get_token() was called before each iteration - switch (last_token) - { - case token_type::begin_object: - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1)))) - { - return false; - } - - // closing } -> we are done - if (get_token() == token_type::end_object) - { - if (JSON_HEDLEY_UNLIKELY(!sax->end_object())) - { - return false; - } - break; - } - - // parse key - if (JSON_HEDLEY_UNLIKELY(last_token != token_type::value_string)) - { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"), BasicJsonType())); - } - if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.get_string()))) - { - return false; - } - - // parse separator (:) - if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) - { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator, "object separator"), BasicJsonType())); - } - - // remember we are now inside an object - states.push_back(false); - - // parse values - get_token(); - continue; - } - - case token_type::begin_array: - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1)))) - { - return false; - } - - // closing ] -> we are done - if (get_token() == token_type::end_array) - { - if (JSON_HEDLEY_UNLIKELY(!sax->end_array())) - { - return false; - } - break; - } - - // remember we are now inside an array - states.push_back(true); - - // parse values (no need to call get_token) - continue; - } - - case token_type::value_float: - { - const auto res = m_lexer.get_number_float(); - - if (JSON_HEDLEY_UNLIKELY(!std::isfinite(res))) - { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - out_of_range::create(406, "number overflow parsing '" + m_lexer.get_token_string() + "'", BasicJsonType())); - } - - if (JSON_HEDLEY_UNLIKELY(!sax->number_float(res, m_lexer.get_string()))) - { - return false; - } - - break; - } - - case token_type::literal_false: - { - if (JSON_HEDLEY_UNLIKELY(!sax->boolean(false))) - { - return false; - } - break; - } - - case token_type::literal_null: - { - if (JSON_HEDLEY_UNLIKELY(!sax->null())) - { - return false; - } - break; - } - - case token_type::literal_true: - { - if (JSON_HEDLEY_UNLIKELY(!sax->boolean(true))) - { - return false; - } - break; - } - - case token_type::value_integer: - { - if (JSON_HEDLEY_UNLIKELY(!sax->number_integer(m_lexer.get_number_integer()))) - { - return false; - } - break; - } - - case token_type::value_string: - { - if (JSON_HEDLEY_UNLIKELY(!sax->string(m_lexer.get_string()))) - { - return false; - } - break; - } - - case token_type::value_unsigned: - { - if (JSON_HEDLEY_UNLIKELY(!sax->number_unsigned(m_lexer.get_number_unsigned()))) - { - return false; - } - break; - } - - case token_type::parse_error: - { - // using "uninitialized" to avoid "expected" message - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized, "value"), BasicJsonType())); - } - - case token_type::uninitialized: - case token_type::end_array: - case token_type::end_object: - case token_type::name_separator: - case token_type::value_separator: - case token_type::end_of_input: - case token_type::literal_or_value: - default: // the last token was unexpected - { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value, "value"), BasicJsonType())); - } - } - } - else - { - skip_to_state_evaluation = false; - } - - // we reached this line after we successfully parsed a value - if (states.empty()) - { - // empty stack: we reached the end of the hierarchy: done - return true; - } - - if (states.back()) // array - { - // comma -> next value - if (get_token() == token_type::value_separator) - { - // parse a new value - get_token(); - continue; - } - - // closing ] - if (JSON_HEDLEY_LIKELY(last_token == token_type::end_array)) - { - if (JSON_HEDLEY_UNLIKELY(!sax->end_array())) - { - return false; - } - - // We are done with this array. Before we can parse a - // new value, we need to evaluate the new state first. - // By setting skip_to_state_evaluation to false, we - // are effectively jumping to the beginning of this if. - JSON_ASSERT(!states.empty()); - states.pop_back(); - skip_to_state_evaluation = true; - continue; - } - - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_array, "array"), BasicJsonType())); - } - - // states.back() is false -> object - - // comma -> next value - if (get_token() == token_type::value_separator) - { - // parse key - if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::value_string)) - { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"), BasicJsonType())); - } - - if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.get_string()))) - { - return false; - } - - // parse separator (:) - if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) - { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator, "object separator"), BasicJsonType())); - } - - // parse values - get_token(); - continue; - } - - // closing } - if (JSON_HEDLEY_LIKELY(last_token == token_type::end_object)) - { - if (JSON_HEDLEY_UNLIKELY(!sax->end_object())) - { - return false; - } - - // We are done with this object. Before we can parse a - // new value, we need to evaluate the new state first. - // By setting skip_to_state_evaluation to false, we - // are effectively jumping to the beginning of this if. - JSON_ASSERT(!states.empty()); - states.pop_back(); - skip_to_state_evaluation = true; - continue; - } - - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_object, "object"), BasicJsonType())); - } - } - - /// get next token from lexer - token_type get_token() - { - return last_token = m_lexer.scan(); - } - - std::string exception_message(const token_type expected, const std::string& context) - { - std::string error_msg = "syntax error "; - - if (!context.empty()) - { - error_msg += "while parsing " + context + " "; - } - - error_msg += "- "; - - if (last_token == token_type::parse_error) - { - error_msg += std::string(m_lexer.get_error_message()) + "; last read: '" + - m_lexer.get_token_string() + "'"; - } - else - { - error_msg += "unexpected " + std::string(lexer_t::token_type_name(last_token)); - } - - if (expected != token_type::uninitialized) - { - error_msg += "; expected " + std::string(lexer_t::token_type_name(expected)); - } - - return error_msg; - } - - private: - /// callback function - const parser_callback_t callback = nullptr; - /// the type of the last read token - token_type last_token = token_type::uninitialized; - /// the lexer - lexer_t m_lexer; - /// whether to throw exceptions in case of errors - const bool allow_exceptions = true; -}; - -} // namespace detail -} // namespace nlohmann - -// #include - - -// #include - - -#include // ptrdiff_t -#include // numeric_limits - -// #include - - -namespace nlohmann -{ -namespace detail -{ -/* -@brief an iterator for primitive JSON types - -This class models an iterator for primitive JSON types (boolean, number, -string). It's only purpose is to allow the iterator/const_iterator classes -to "iterate" over primitive values. Internally, the iterator is modeled by -a `difference_type` variable. Value begin_value (`0`) models the begin, -end_value (`1`) models past the end. -*/ -class primitive_iterator_t -{ - private: - using difference_type = std::ptrdiff_t; - static constexpr difference_type begin_value = 0; - static constexpr difference_type end_value = begin_value + 1; - - JSON_PRIVATE_UNLESS_TESTED: - /// iterator as signed integer type - difference_type m_it = (std::numeric_limits::min)(); - - public: - constexpr difference_type get_value() const noexcept - { - return m_it; - } - - /// set iterator to a defined beginning - void set_begin() noexcept - { - m_it = begin_value; - } - - /// set iterator to a defined past the end - void set_end() noexcept - { - m_it = end_value; - } - - /// return whether the iterator can be dereferenced - constexpr bool is_begin() const noexcept - { - return m_it == begin_value; - } - - /// return whether the iterator is at end - constexpr bool is_end() const noexcept - { - return m_it == end_value; - } - - friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept - { - return lhs.m_it == rhs.m_it; - } - - friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept - { - return lhs.m_it < rhs.m_it; - } - - primitive_iterator_t operator+(difference_type n) noexcept - { - auto result = *this; - result += n; - return result; - } - - friend constexpr difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept - { - return lhs.m_it - rhs.m_it; - } - - primitive_iterator_t& operator++() noexcept - { - ++m_it; - return *this; - } - - primitive_iterator_t const operator++(int) noexcept // NOLINT(readability-const-return-type) - { - auto result = *this; - ++m_it; - return result; - } - - primitive_iterator_t& operator--() noexcept - { - --m_it; - return *this; - } - - primitive_iterator_t const operator--(int) noexcept // NOLINT(readability-const-return-type) - { - auto result = *this; - --m_it; - return result; - } - - primitive_iterator_t& operator+=(difference_type n) noexcept - { - m_it += n; - return *this; - } - - primitive_iterator_t& operator-=(difference_type n) noexcept - { - m_it -= n; - return *this; - } -}; -} // namespace detail -} // namespace nlohmann - - -namespace nlohmann -{ -namespace detail -{ -/*! -@brief an iterator value - -@note This structure could easily be a union, but MSVC currently does not allow -unions members with complex constructors, see https://github.com/nlohmann/json/pull/105. -*/ -template struct internal_iterator -{ - /// iterator for JSON objects - typename BasicJsonType::object_t::iterator object_iterator {}; - /// iterator for JSON arrays - typename BasicJsonType::array_t::iterator array_iterator {}; - /// generic iterator for all other types - primitive_iterator_t primitive_iterator {}; -}; -} // namespace detail -} // namespace nlohmann - -// #include - - -#include // iterator, random_access_iterator_tag, bidirectional_iterator_tag, advance, next -#include // conditional, is_const, remove_const - -// #include - -// #include - -// #include - -// #include - -// #include - -// #include - -// #include - - -namespace nlohmann -{ -namespace detail -{ -// forward declare, to be able to friend it later on -template class iteration_proxy; -template class iteration_proxy_value; - -/*! -@brief a template for a bidirectional iterator for the @ref basic_json class -This class implements a both iterators (iterator and const_iterator) for the -@ref basic_json class. -@note An iterator is called *initialized* when a pointer to a JSON value has - been set (e.g., by a constructor or a copy assignment). If the iterator is - default-constructed, it is *uninitialized* and most methods are undefined. - **The library uses assertions to detect calls on uninitialized iterators.** -@requirement The class satisfies the following concept requirements: -- -[BidirectionalIterator](https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator): - The iterator that can be moved can be moved in both directions (i.e. - incremented and decremented). -@since version 1.0.0, simplified in version 2.0.9, change to bidirectional - iterators in version 3.0.0 (see https://github.com/nlohmann/json/issues/593) -*/ -template -class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-special-member-functions) -{ - /// the iterator with BasicJsonType of different const-ness - using other_iter_impl = iter_impl::value, typename std::remove_const::type, const BasicJsonType>::type>; - /// allow basic_json to access private members - friend other_iter_impl; - friend BasicJsonType; - friend iteration_proxy; - friend iteration_proxy_value; - - using object_t = typename BasicJsonType::object_t; - using array_t = typename BasicJsonType::array_t; - // make sure BasicJsonType is basic_json or const basic_json - static_assert(is_basic_json::type>::value, - "iter_impl only accepts (const) basic_json"); - - public: - - /// The std::iterator class template (used as a base class to provide typedefs) is deprecated in C++17. - /// The C++ Standard has never required user-defined iterators to derive from std::iterator. - /// A user-defined iterator should provide publicly accessible typedefs named - /// iterator_category, value_type, difference_type, pointer, and reference. - /// Note that value_type is required to be non-const, even for constant iterators. - using iterator_category = std::bidirectional_iterator_tag; - - /// the type of the values when the iterator is dereferenced - using value_type = typename BasicJsonType::value_type; - /// a type to represent differences between iterators - using difference_type = typename BasicJsonType::difference_type; - /// defines a pointer to the type iterated over (value_type) - using pointer = typename std::conditional::value, - typename BasicJsonType::const_pointer, - typename BasicJsonType::pointer>::type; - /// defines a reference to the type iterated over (value_type) - using reference = - typename std::conditional::value, - typename BasicJsonType::const_reference, - typename BasicJsonType::reference>::type; - - iter_impl() = default; - ~iter_impl() = default; - iter_impl(iter_impl&&) noexcept = default; - iter_impl& operator=(iter_impl&&) noexcept = default; - - /*! - @brief constructor for a given JSON instance - @param[in] object pointer to a JSON object for this iterator - @pre object != nullptr - @post The iterator is initialized; i.e. `m_object != nullptr`. - */ - explicit iter_impl(pointer object) noexcept : m_object(object) - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - { - m_it.object_iterator = typename object_t::iterator(); - break; - } - - case value_t::array: - { - m_it.array_iterator = typename array_t::iterator(); - break; - } - - case value_t::null: - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - { - m_it.primitive_iterator = primitive_iterator_t(); - break; - } - } - } - - /*! - @note The conventional copy constructor and copy assignment are implicitly - defined. Combined with the following converting constructor and - assignment, they support: (1) copy from iterator to iterator, (2) - copy from const iterator to const iterator, and (3) conversion from - iterator to const iterator. However conversion from const iterator - to iterator is not defined. - */ - - /*! - @brief const copy constructor - @param[in] other const iterator to copy from - @note This copy constructor had to be defined explicitly to circumvent a bug - occurring on msvc v19.0 compiler (VS 2015) debug build. For more - information refer to: https://github.com/nlohmann/json/issues/1608 - */ - iter_impl(const iter_impl& other) noexcept - : m_object(other.m_object), m_it(other.m_it) - {} - - /*! - @brief converting assignment - @param[in] other const iterator to copy from - @return const/non-const iterator - @note It is not checked whether @a other is initialized. - */ - iter_impl& operator=(const iter_impl& other) noexcept - { - if (&other != this) - { - m_object = other.m_object; - m_it = other.m_it; - } - return *this; - } - - /*! - @brief converting constructor - @param[in] other non-const iterator to copy from - @note It is not checked whether @a other is initialized. - */ - iter_impl(const iter_impl::type>& other) noexcept - : m_object(other.m_object), m_it(other.m_it) - {} - - /*! - @brief converting assignment - @param[in] other non-const iterator to copy from - @return const/non-const iterator - @note It is not checked whether @a other is initialized. - */ - iter_impl& operator=(const iter_impl::type>& other) noexcept // NOLINT(cert-oop54-cpp) - { - m_object = other.m_object; - m_it = other.m_it; - return *this; - } - - JSON_PRIVATE_UNLESS_TESTED: - /*! - @brief set the iterator to the first value - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - void set_begin() noexcept - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - { - m_it.object_iterator = m_object->m_value.object->begin(); - break; - } - - case value_t::array: - { - m_it.array_iterator = m_object->m_value.array->begin(); - break; - } - - case value_t::null: - { - // set to end so begin()==end() is true: null is empty - m_it.primitive_iterator.set_end(); - break; - } - - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - { - m_it.primitive_iterator.set_begin(); - break; - } - } - } - - /*! - @brief set the iterator past the last value - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - void set_end() noexcept - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - { - m_it.object_iterator = m_object->m_value.object->end(); - break; - } - - case value_t::array: - { - m_it.array_iterator = m_object->m_value.array->end(); - break; - } - - case value_t::null: - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - { - m_it.primitive_iterator.set_end(); - break; - } - } - } - - public: - /*! - @brief return a reference to the value pointed to by the iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - reference operator*() const - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - { - JSON_ASSERT(m_it.object_iterator != m_object->m_value.object->end()); - return m_it.object_iterator->second; - } - - case value_t::array: - { - JSON_ASSERT(m_it.array_iterator != m_object->m_value.array->end()); - return *m_it.array_iterator; - } - - case value_t::null: - JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object)); - - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - { - if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) - { - return *m_object; - } - - JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object)); - } - } - } - - /*! - @brief dereference the iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - pointer operator->() const - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - { - JSON_ASSERT(m_it.object_iterator != m_object->m_value.object->end()); - return &(m_it.object_iterator->second); - } - - case value_t::array: - { - JSON_ASSERT(m_it.array_iterator != m_object->m_value.array->end()); - return &*m_it.array_iterator; - } - - case value_t::null: - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - { - if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) - { - return m_object; - } - - JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object)); - } - } - } - - /*! - @brief post-increment (it++) - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - iter_impl const operator++(int) // NOLINT(readability-const-return-type) - { - auto result = *this; - ++(*this); - return result; - } - - /*! - @brief pre-increment (++it) - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - iter_impl& operator++() - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - { - std::advance(m_it.object_iterator, 1); - break; - } - - case value_t::array: - { - std::advance(m_it.array_iterator, 1); - break; - } - - case value_t::null: - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - { - ++m_it.primitive_iterator; - break; - } - } - - return *this; - } - - /*! - @brief post-decrement (it--) - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - iter_impl const operator--(int) // NOLINT(readability-const-return-type) - { - auto result = *this; - --(*this); - return result; - } - - /*! - @brief pre-decrement (--it) - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - iter_impl& operator--() - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - { - std::advance(m_it.object_iterator, -1); - break; - } - - case value_t::array: - { - std::advance(m_it.array_iterator, -1); - break; - } - - case value_t::null: - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - { - --m_it.primitive_iterator; - break; - } - } - - return *this; - } - - /*! - @brief comparison: equal - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - template < typename IterImpl, detail::enable_if_t < (std::is_same::value || std::is_same::value), std::nullptr_t > = nullptr > - bool operator==(const IterImpl& other) const - { - // if objects are not the same, the comparison is undefined - if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object)) - { - JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers", *m_object)); - } - - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - return (m_it.object_iterator == other.m_it.object_iterator); - - case value_t::array: - return (m_it.array_iterator == other.m_it.array_iterator); - - case value_t::null: - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - return (m_it.primitive_iterator == other.m_it.primitive_iterator); - } - } - - /*! - @brief comparison: not equal - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - template < typename IterImpl, detail::enable_if_t < (std::is_same::value || std::is_same::value), std::nullptr_t > = nullptr > - bool operator!=(const IterImpl& other) const - { - return !operator==(other); - } - - /*! - @brief comparison: smaller - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - bool operator<(const iter_impl& other) const - { - // if objects are not the same, the comparison is undefined - if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object)) - { - JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers", *m_object)); - } - - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - JSON_THROW(invalid_iterator::create(213, "cannot compare order of object iterators", *m_object)); - - case value_t::array: - return (m_it.array_iterator < other.m_it.array_iterator); - - case value_t::null: - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - return (m_it.primitive_iterator < other.m_it.primitive_iterator); - } - } - - /*! - @brief comparison: less than or equal - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - bool operator<=(const iter_impl& other) const - { - return !other.operator < (*this); - } - - /*! - @brief comparison: greater than - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - bool operator>(const iter_impl& other) const - { - return !operator<=(other); - } - - /*! - @brief comparison: greater than or equal - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - bool operator>=(const iter_impl& other) const - { - return !operator<(other); - } - - /*! - @brief add to iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - iter_impl& operator+=(difference_type i) - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators", *m_object)); - - case value_t::array: - { - std::advance(m_it.array_iterator, i); - break; - } - - case value_t::null: - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - { - m_it.primitive_iterator += i; - break; - } - } - - return *this; - } - - /*! - @brief subtract from iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - iter_impl& operator-=(difference_type i) - { - return operator+=(-i); - } - - /*! - @brief add to iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - iter_impl operator+(difference_type i) const - { - auto result = *this; - result += i; - return result; - } - - /*! - @brief addition of distance and iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - friend iter_impl operator+(difference_type i, const iter_impl& it) - { - auto result = it; - result += i; - return result; - } - - /*! - @brief subtract from iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - iter_impl operator-(difference_type i) const - { - auto result = *this; - result -= i; - return result; - } - - /*! - @brief return difference - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - difference_type operator-(const iter_impl& other) const - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators", *m_object)); - - case value_t::array: - return m_it.array_iterator - other.m_it.array_iterator; - - case value_t::null: - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - return m_it.primitive_iterator - other.m_it.primitive_iterator; - } - } - - /*! - @brief access to successor - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - reference operator[](difference_type n) const - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - JSON_THROW(invalid_iterator::create(208, "cannot use operator[] for object iterators", *m_object)); - - case value_t::array: - return *std::next(m_it.array_iterator, n); - - case value_t::null: - JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object)); - - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - { - if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.get_value() == -n)) - { - return *m_object; - } - - JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object)); - } - } - } - - /*! - @brief return the key of an object iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - const typename object_t::key_type& key() const - { - JSON_ASSERT(m_object != nullptr); - - if (JSON_HEDLEY_LIKELY(m_object->is_object())) - { - return m_it.object_iterator->first; - } - - JSON_THROW(invalid_iterator::create(207, "cannot use key() for non-object iterators", *m_object)); - } - - /*! - @brief return the value of an iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - reference value() const - { - return operator*(); - } - - JSON_PRIVATE_UNLESS_TESTED: - /// associated JSON instance - pointer m_object = nullptr; - /// the actual iterator of the associated instance - internal_iterator::type> m_it {}; -}; -} // namespace detail -} // namespace nlohmann - -// #include - -// #include - - -#include // ptrdiff_t -#include // reverse_iterator -#include // declval - -namespace nlohmann -{ -namespace detail -{ -////////////////////// -// reverse_iterator // -////////////////////// - -/*! -@brief a template for a reverse iterator class - -@tparam Base the base iterator type to reverse. Valid types are @ref -iterator (to create @ref reverse_iterator) and @ref const_iterator (to -create @ref const_reverse_iterator). - -@requirement The class satisfies the following concept requirements: -- -[BidirectionalIterator](https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator): - The iterator that can be moved can be moved in both directions (i.e. - incremented and decremented). -- [OutputIterator](https://en.cppreference.com/w/cpp/named_req/OutputIterator): - It is possible to write to the pointed-to element (only if @a Base is - @ref iterator). - -@since version 1.0.0 -*/ -template -class json_reverse_iterator : public std::reverse_iterator -{ - public: - using difference_type = std::ptrdiff_t; - /// shortcut to the reverse iterator adapter - using base_iterator = std::reverse_iterator; - /// the reference type for the pointed-to element - using reference = typename Base::reference; - - /// create reverse iterator from iterator - explicit json_reverse_iterator(const typename base_iterator::iterator_type& it) noexcept - : base_iterator(it) {} - - /// create reverse iterator from base class - explicit json_reverse_iterator(const base_iterator& it) noexcept : base_iterator(it) {} - - /// post-increment (it++) - json_reverse_iterator const operator++(int) // NOLINT(readability-const-return-type) - { - return static_cast(base_iterator::operator++(1)); - } - - /// pre-increment (++it) - json_reverse_iterator& operator++() - { - return static_cast(base_iterator::operator++()); - } - - /// post-decrement (it--) - json_reverse_iterator const operator--(int) // NOLINT(readability-const-return-type) - { - return static_cast(base_iterator::operator--(1)); - } - - /// pre-decrement (--it) - json_reverse_iterator& operator--() - { - return static_cast(base_iterator::operator--()); - } - - /// add to iterator - json_reverse_iterator& operator+=(difference_type i) - { - return static_cast(base_iterator::operator+=(i)); - } - - /// add to iterator - json_reverse_iterator operator+(difference_type i) const - { - return static_cast(base_iterator::operator+(i)); - } - - /// subtract from iterator - json_reverse_iterator operator-(difference_type i) const - { - return static_cast(base_iterator::operator-(i)); - } - - /// return difference - difference_type operator-(const json_reverse_iterator& other) const - { - return base_iterator(*this) - base_iterator(other); - } - - /// access to successor - reference operator[](difference_type n) const - { - return *(this->operator+(n)); - } - - /// return the key of an object iterator - auto key() const -> decltype(std::declval().key()) - { - auto it = --this->base(); - return it.key(); - } - - /// return the value of an iterator - reference value() const - { - auto it = --this->base(); - return it.operator * (); - } -}; -} // namespace detail -} // namespace nlohmann - -// #include - -// #include - - -#include // all_of -#include // isdigit -#include // max -#include // accumulate -#include // string -#include // move -#include // vector - -// #include - -// #include - -// #include - -// #include - - -namespace nlohmann -{ -template -class json_pointer -{ - // allow basic_json to access private members - NLOHMANN_BASIC_JSON_TPL_DECLARATION - friend class basic_json; - - public: - /*! - @brief create JSON pointer - - Create a JSON pointer according to the syntax described in - [Section 3 of RFC6901](https://tools.ietf.org/html/rfc6901#section-3). - - @param[in] s string representing the JSON pointer; if omitted, the empty - string is assumed which references the whole JSON value - - @throw parse_error.107 if the given JSON pointer @a s is nonempty and does - not begin with a slash (`/`); see example below - - @throw parse_error.108 if a tilde (`~`) in the given JSON pointer @a s is - not followed by `0` (representing `~`) or `1` (representing `/`); see - example below - - @liveexample{The example shows the construction several valid JSON pointers - as well as the exceptional behavior.,json_pointer} - - @since version 2.0.0 - */ - explicit json_pointer(const std::string& s = "") - : reference_tokens(split(s)) - {} - - /*! - @brief return a string representation of the JSON pointer - - @invariant For each JSON pointer `ptr`, it holds: - @code {.cpp} - ptr == json_pointer(ptr.to_string()); - @endcode - - @return a string representation of the JSON pointer - - @liveexample{The example shows the result of `to_string`.,json_pointer__to_string} - - @since version 2.0.0 - */ - std::string to_string() const - { - return std::accumulate(reference_tokens.begin(), reference_tokens.end(), - std::string{}, - [](const std::string & a, const std::string & b) - { - return a + "/" + detail::escape(b); - }); - } - - /// @copydoc to_string() - operator std::string() const - { - return to_string(); - } - - /*! - @brief append another JSON pointer at the end of this JSON pointer - - @param[in] ptr JSON pointer to append - @return JSON pointer with @a ptr appended - - @liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add} - - @complexity Linear in the length of @a ptr. - - @sa see @ref operator/=(std::string) to append a reference token - @sa see @ref operator/=(std::size_t) to append an array index - @sa see @ref operator/(const json_pointer&, const json_pointer&) for a binary operator - - @since version 3.6.0 - */ - json_pointer& operator/=(const json_pointer& ptr) - { - reference_tokens.insert(reference_tokens.end(), - ptr.reference_tokens.begin(), - ptr.reference_tokens.end()); - return *this; - } - - /*! - @brief append an unescaped reference token at the end of this JSON pointer - - @param[in] token reference token to append - @return JSON pointer with @a token appended without escaping @a token - - @liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add} - - @complexity Amortized constant. - - @sa see @ref operator/=(const json_pointer&) to append a JSON pointer - @sa see @ref operator/=(std::size_t) to append an array index - @sa see @ref operator/(const json_pointer&, std::size_t) for a binary operator - - @since version 3.6.0 - */ - json_pointer& operator/=(std::string token) - { - push_back(std::move(token)); - return *this; - } - - /*! - @brief append an array index at the end of this JSON pointer - - @param[in] array_idx array index to append - @return JSON pointer with @a array_idx appended - - @liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add} - - @complexity Amortized constant. - - @sa see @ref operator/=(const json_pointer&) to append a JSON pointer - @sa see @ref operator/=(std::string) to append a reference token - @sa see @ref operator/(const json_pointer&, std::string) for a binary operator - - @since version 3.6.0 - */ - json_pointer& operator/=(std::size_t array_idx) - { - return *this /= std::to_string(array_idx); - } - - /*! - @brief create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer - - @param[in] lhs JSON pointer - @param[in] rhs JSON pointer - @return a new JSON pointer with @a rhs appended to @a lhs - - @liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary} - - @complexity Linear in the length of @a lhs and @a rhs. - - @sa see @ref operator/=(const json_pointer&) to append a JSON pointer - - @since version 3.6.0 - */ - friend json_pointer operator/(const json_pointer& lhs, - const json_pointer& rhs) - { - return json_pointer(lhs) /= rhs; - } - - /*! - @brief create a new JSON pointer by appending the unescaped token at the end of the JSON pointer - - @param[in] ptr JSON pointer - @param[in] token reference token - @return a new JSON pointer with unescaped @a token appended to @a ptr - - @liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary} - - @complexity Linear in the length of @a ptr. - - @sa see @ref operator/=(std::string) to append a reference token - - @since version 3.6.0 - */ - friend json_pointer operator/(const json_pointer& ptr, std::string token) // NOLINT(performance-unnecessary-value-param) - { - return json_pointer(ptr) /= std::move(token); - } - - /*! - @brief create a new JSON pointer by appending the array-index-token at the end of the JSON pointer - - @param[in] ptr JSON pointer - @param[in] array_idx array index - @return a new JSON pointer with @a array_idx appended to @a ptr - - @liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary} - - @complexity Linear in the length of @a ptr. - - @sa see @ref operator/=(std::size_t) to append an array index - - @since version 3.6.0 - */ - friend json_pointer operator/(const json_pointer& ptr, std::size_t array_idx) - { - return json_pointer(ptr) /= array_idx; - } - - /*! - @brief returns the parent of this JSON pointer - - @return parent of this JSON pointer; in case this JSON pointer is the root, - the root itself is returned - - @complexity Linear in the length of the JSON pointer. - - @liveexample{The example shows the result of `parent_pointer` for different - JSON Pointers.,json_pointer__parent_pointer} - - @since version 3.6.0 - */ - json_pointer parent_pointer() const - { - if (empty()) - { - return *this; - } - - json_pointer res = *this; - res.pop_back(); - return res; - } - - /*! - @brief remove last reference token - - @pre not `empty()` - - @liveexample{The example shows the usage of `pop_back`.,json_pointer__pop_back} - - @complexity Constant. - - @throw out_of_range.405 if JSON pointer has no parent - - @since version 3.6.0 - */ - void pop_back() - { - if (JSON_HEDLEY_UNLIKELY(empty())) - { - JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent", BasicJsonType())); - } - - reference_tokens.pop_back(); - } - - /*! - @brief return last reference token - - @pre not `empty()` - @return last reference token - - @liveexample{The example shows the usage of `back`.,json_pointer__back} - - @complexity Constant. - - @throw out_of_range.405 if JSON pointer has no parent - - @since version 3.6.0 - */ - const std::string& back() const - { - if (JSON_HEDLEY_UNLIKELY(empty())) - { - JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent", BasicJsonType())); - } - - return reference_tokens.back(); - } - - /*! - @brief append an unescaped token at the end of the reference pointer - - @param[in] token token to add - - @complexity Amortized constant. - - @liveexample{The example shows the result of `push_back` for different - JSON Pointers.,json_pointer__push_back} - - @since version 3.6.0 - */ - void push_back(const std::string& token) - { - reference_tokens.push_back(token); - } - - /// @copydoc push_back(const std::string&) - void push_back(std::string&& token) - { - reference_tokens.push_back(std::move(token)); - } - - /*! - @brief return whether pointer points to the root document - - @return true iff the JSON pointer points to the root document - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @liveexample{The example shows the result of `empty` for different JSON - Pointers.,json_pointer__empty} - - @since version 3.6.0 - */ - bool empty() const noexcept - { - return reference_tokens.empty(); - } - - private: - /*! - @param[in] s reference token to be converted into an array index - - @return integer representation of @a s - - @throw parse_error.106 if an array index begins with '0' - @throw parse_error.109 if an array index begins not with a digit - @throw out_of_range.404 if string @a s could not be converted to an integer - @throw out_of_range.410 if an array index exceeds size_type - */ - static typename BasicJsonType::size_type array_index(const std::string& s) - { - using size_type = typename BasicJsonType::size_type; - - // error condition (cf. RFC 6901, Sect. 4) - if (JSON_HEDLEY_UNLIKELY(s.size() > 1 && s[0] == '0')) - { - JSON_THROW(detail::parse_error::create(106, 0, "array index '" + s + "' must not begin with '0'", BasicJsonType())); - } - - // error condition (cf. RFC 6901, Sect. 4) - if (JSON_HEDLEY_UNLIKELY(s.size() > 1 && !(s[0] >= '1' && s[0] <= '9'))) - { - JSON_THROW(detail::parse_error::create(109, 0, "array index '" + s + "' is not a number", BasicJsonType())); - } - - std::size_t processed_chars = 0; - unsigned long long res = 0; // NOLINT(runtime/int) - JSON_TRY - { - res = std::stoull(s, &processed_chars); - } - JSON_CATCH(std::out_of_range&) - { - JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + s + "'", BasicJsonType())); - } - - // check if the string was completely read - if (JSON_HEDLEY_UNLIKELY(processed_chars != s.size())) - { - JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + s + "'", BasicJsonType())); - } - - // only triggered on special platforms (like 32bit), see also - // https://github.com/nlohmann/json/pull/2203 - if (res >= static_cast((std::numeric_limits::max)())) // NOLINT(runtime/int) - { - JSON_THROW(detail::out_of_range::create(410, "array index " + s + " exceeds size_type", BasicJsonType())); // LCOV_EXCL_LINE - } - - return static_cast(res); - } - - JSON_PRIVATE_UNLESS_TESTED: - json_pointer top() const - { - if (JSON_HEDLEY_UNLIKELY(empty())) - { - JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent", BasicJsonType())); - } - - json_pointer result = *this; - result.reference_tokens = {reference_tokens[0]}; - return result; - } - - private: - /*! - @brief create and return a reference to the pointed to value - - @complexity Linear in the number of reference tokens. - - @throw parse_error.109 if array index is not a number - @throw type_error.313 if value cannot be unflattened - */ - BasicJsonType& get_and_create(BasicJsonType& j) const - { - auto* result = &j; - - // in case no reference tokens exist, return a reference to the JSON value - // j which will be overwritten by a primitive value - for (const auto& reference_token : reference_tokens) - { - switch (result->type()) - { - case detail::value_t::null: - { - if (reference_token == "0") - { - // start a new array if reference token is 0 - result = &result->operator[](0); - } - else - { - // start a new object otherwise - result = &result->operator[](reference_token); - } - break; - } - - case detail::value_t::object: - { - // create an entry in the object - result = &result->operator[](reference_token); - break; - } - - case detail::value_t::array: - { - // create an entry in the array - result = &result->operator[](array_index(reference_token)); - break; - } - - /* - The following code is only reached if there exists a reference - token _and_ the current value is primitive. In this case, we have - an error situation, because primitive values may only occur as - single value; that is, with an empty list of reference tokens. - */ - case detail::value_t::string: - case detail::value_t::boolean: - case detail::value_t::number_integer: - case detail::value_t::number_unsigned: - case detail::value_t::number_float: - case detail::value_t::binary: - case detail::value_t::discarded: - default: - JSON_THROW(detail::type_error::create(313, "invalid value to unflatten", j)); - } - } - - return *result; - } - - /*! - @brief return a reference to the pointed to value - - @note This version does not throw if a value is not present, but tries to - create nested values instead. For instance, calling this function - with pointer `"/this/that"` on a null value is equivalent to calling - `operator[]("this").operator[]("that")` on that value, effectively - changing the null value to an object. - - @param[in] ptr a JSON value - - @return reference to the JSON value pointed to by the JSON pointer - - @complexity Linear in the length of the JSON pointer. - - @throw parse_error.106 if an array index begins with '0' - @throw parse_error.109 if an array index was not a number - @throw out_of_range.404 if the JSON pointer can not be resolved - */ - BasicJsonType& get_unchecked(BasicJsonType* ptr) const - { - for (const auto& reference_token : reference_tokens) - { - // convert null values to arrays or objects before continuing - if (ptr->is_null()) - { - // check if reference token is a number - const bool nums = - std::all_of(reference_token.begin(), reference_token.end(), - [](const unsigned char x) - { - return std::isdigit(x); - }); - - // change value to array for numbers or "-" or to object otherwise - *ptr = (nums || reference_token == "-") - ? detail::value_t::array - : detail::value_t::object; - } - - switch (ptr->type()) - { - case detail::value_t::object: - { - // use unchecked object access - ptr = &ptr->operator[](reference_token); - break; - } - - case detail::value_t::array: - { - if (reference_token == "-") - { - // explicitly treat "-" as index beyond the end - ptr = &ptr->operator[](ptr->m_value.array->size()); - } - else - { - // convert array index to number; unchecked access - ptr = &ptr->operator[](array_index(reference_token)); - } - break; - } - - case detail::value_t::null: - case detail::value_t::string: - case detail::value_t::boolean: - case detail::value_t::number_integer: - case detail::value_t::number_unsigned: - case detail::value_t::number_float: - case detail::value_t::binary: - case detail::value_t::discarded: - default: - JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'", *ptr)); - } - } - - return *ptr; - } - - /*! - @throw parse_error.106 if an array index begins with '0' - @throw parse_error.109 if an array index was not a number - @throw out_of_range.402 if the array index '-' is used - @throw out_of_range.404 if the JSON pointer can not be resolved - */ - BasicJsonType& get_checked(BasicJsonType* ptr) const - { - for (const auto& reference_token : reference_tokens) - { - switch (ptr->type()) - { - case detail::value_t::object: - { - // note: at performs range check - ptr = &ptr->at(reference_token); - break; - } - - case detail::value_t::array: - { - if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) - { - // "-" always fails the range check - JSON_THROW(detail::out_of_range::create(402, - "array index '-' (" + std::to_string(ptr->m_value.array->size()) + - ") is out of range", *ptr)); - } - - // note: at performs range check - ptr = &ptr->at(array_index(reference_token)); - break; - } - - case detail::value_t::null: - case detail::value_t::string: - case detail::value_t::boolean: - case detail::value_t::number_integer: - case detail::value_t::number_unsigned: - case detail::value_t::number_float: - case detail::value_t::binary: - case detail::value_t::discarded: - default: - JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'", *ptr)); - } - } - - return *ptr; - } - - /*! - @brief return a const reference to the pointed to value - - @param[in] ptr a JSON value - - @return const reference to the JSON value pointed to by the JSON - pointer - - @throw parse_error.106 if an array index begins with '0' - @throw parse_error.109 if an array index was not a number - @throw out_of_range.402 if the array index '-' is used - @throw out_of_range.404 if the JSON pointer can not be resolved - */ - const BasicJsonType& get_unchecked(const BasicJsonType* ptr) const - { - for (const auto& reference_token : reference_tokens) - { - switch (ptr->type()) - { - case detail::value_t::object: - { - // use unchecked object access - ptr = &ptr->operator[](reference_token); - break; - } - - case detail::value_t::array: - { - if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) - { - // "-" cannot be used for const access - JSON_THROW(detail::out_of_range::create(402, "array index '-' (" + std::to_string(ptr->m_value.array->size()) + ") is out of range", *ptr)); - } - - // use unchecked array access - ptr = &ptr->operator[](array_index(reference_token)); - break; - } - - case detail::value_t::null: - case detail::value_t::string: - case detail::value_t::boolean: - case detail::value_t::number_integer: - case detail::value_t::number_unsigned: - case detail::value_t::number_float: - case detail::value_t::binary: - case detail::value_t::discarded: - default: - JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'", *ptr)); - } - } - - return *ptr; - } - - /*! - @throw parse_error.106 if an array index begins with '0' - @throw parse_error.109 if an array index was not a number - @throw out_of_range.402 if the array index '-' is used - @throw out_of_range.404 if the JSON pointer can not be resolved - */ - const BasicJsonType& get_checked(const BasicJsonType* ptr) const - { - for (const auto& reference_token : reference_tokens) - { - switch (ptr->type()) - { - case detail::value_t::object: - { - // note: at performs range check - ptr = &ptr->at(reference_token); - break; - } - - case detail::value_t::array: - { - if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) - { - // "-" always fails the range check - JSON_THROW(detail::out_of_range::create(402, - "array index '-' (" + std::to_string(ptr->m_value.array->size()) + - ") is out of range", *ptr)); - } - - // note: at performs range check - ptr = &ptr->at(array_index(reference_token)); - break; - } - - case detail::value_t::null: - case detail::value_t::string: - case detail::value_t::boolean: - case detail::value_t::number_integer: - case detail::value_t::number_unsigned: - case detail::value_t::number_float: - case detail::value_t::binary: - case detail::value_t::discarded: - default: - JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'", *ptr)); - } - } - - return *ptr; - } - - /*! - @throw parse_error.106 if an array index begins with '0' - @throw parse_error.109 if an array index was not a number - */ - bool contains(const BasicJsonType* ptr) const - { - for (const auto& reference_token : reference_tokens) - { - switch (ptr->type()) - { - case detail::value_t::object: - { - if (!ptr->contains(reference_token)) - { - // we did not find the key in the object - return false; - } - - ptr = &ptr->operator[](reference_token); - break; - } - - case detail::value_t::array: - { - if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) - { - // "-" always fails the range check - return false; - } - if (JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !("0" <= reference_token && reference_token <= "9"))) - { - // invalid char - return false; - } - if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1)) - { - if (JSON_HEDLEY_UNLIKELY(!('1' <= reference_token[0] && reference_token[0] <= '9'))) - { - // first char should be between '1' and '9' - return false; - } - for (std::size_t i = 1; i < reference_token.size(); i++) - { - if (JSON_HEDLEY_UNLIKELY(!('0' <= reference_token[i] && reference_token[i] <= '9'))) - { - // other char should be between '0' and '9' - return false; - } - } - } - - const auto idx = array_index(reference_token); - if (idx >= ptr->size()) - { - // index out of range - return false; - } - - ptr = &ptr->operator[](idx); - break; - } - - case detail::value_t::null: - case detail::value_t::string: - case detail::value_t::boolean: - case detail::value_t::number_integer: - case detail::value_t::number_unsigned: - case detail::value_t::number_float: - case detail::value_t::binary: - case detail::value_t::discarded: - default: - { - // we do not expect primitive values if there is still a - // reference token to process - return false; - } - } - } - - // no reference token left means we found a primitive value - return true; - } - - /*! - @brief split the string input to reference tokens - - @note This function is only called by the json_pointer constructor. - All exceptions below are documented there. - - @throw parse_error.107 if the pointer is not empty or begins with '/' - @throw parse_error.108 if character '~' is not followed by '0' or '1' - */ - static std::vector split(const std::string& reference_string) - { - std::vector result; - - // special case: empty reference string -> no reference tokens - if (reference_string.empty()) - { - return result; - } - - // check if nonempty reference string begins with slash - if (JSON_HEDLEY_UNLIKELY(reference_string[0] != '/')) - { - JSON_THROW(detail::parse_error::create(107, 1, "JSON pointer must be empty or begin with '/' - was: '" + reference_string + "'", BasicJsonType())); - } - - // extract the reference tokens: - // - slash: position of the last read slash (or end of string) - // - start: position after the previous slash - for ( - // search for the first slash after the first character - std::size_t slash = reference_string.find_first_of('/', 1), - // set the beginning of the first reference token - start = 1; - // we can stop if start == 0 (if slash == std::string::npos) - start != 0; - // set the beginning of the next reference token - // (will eventually be 0 if slash == std::string::npos) - start = (slash == std::string::npos) ? 0 : slash + 1, - // find next slash - slash = reference_string.find_first_of('/', start)) - { - // use the text between the beginning of the reference token - // (start) and the last slash (slash). - auto reference_token = reference_string.substr(start, slash - start); - - // check reference tokens are properly escaped - for (std::size_t pos = reference_token.find_first_of('~'); - pos != std::string::npos; - pos = reference_token.find_first_of('~', pos + 1)) - { - JSON_ASSERT(reference_token[pos] == '~'); - - // ~ must be followed by 0 or 1 - if (JSON_HEDLEY_UNLIKELY(pos == reference_token.size() - 1 || - (reference_token[pos + 1] != '0' && - reference_token[pos + 1] != '1'))) - { - JSON_THROW(detail::parse_error::create(108, 0, "escape character '~' must be followed with '0' or '1'", BasicJsonType())); - } - } - - // finally, store the reference token - detail::unescape(reference_token); - result.push_back(reference_token); - } - - return result; - } - - private: - /*! - @param[in] reference_string the reference string to the current value - @param[in] value the value to consider - @param[in,out] result the result object to insert values to - - @note Empty objects or arrays are flattened to `null`. - */ - static void flatten(const std::string& reference_string, - const BasicJsonType& value, - BasicJsonType& result) - { - switch (value.type()) - { - case detail::value_t::array: - { - if (value.m_value.array->empty()) - { - // flatten empty array as null - result[reference_string] = nullptr; - } - else - { - // iterate array and use index as reference string - for (std::size_t i = 0; i < value.m_value.array->size(); ++i) - { - flatten(reference_string + "/" + std::to_string(i), - value.m_value.array->operator[](i), result); - } - } - break; - } - - case detail::value_t::object: - { - if (value.m_value.object->empty()) - { - // flatten empty object as null - result[reference_string] = nullptr; - } - else - { - // iterate object and use keys as reference string - for (const auto& element : *value.m_value.object) - { - flatten(reference_string + "/" + detail::escape(element.first), element.second, result); - } - } - break; - } - - case detail::value_t::null: - case detail::value_t::string: - case detail::value_t::boolean: - case detail::value_t::number_integer: - case detail::value_t::number_unsigned: - case detail::value_t::number_float: - case detail::value_t::binary: - case detail::value_t::discarded: - default: - { - // add primitive value with its reference string - result[reference_string] = value; - break; - } - } - } - - /*! - @param[in] value flattened JSON - - @return unflattened JSON - - @throw parse_error.109 if array index is not a number - @throw type_error.314 if value is not an object - @throw type_error.315 if object values are not primitive - @throw type_error.313 if value cannot be unflattened - */ - static BasicJsonType - unflatten(const BasicJsonType& value) - { - if (JSON_HEDLEY_UNLIKELY(!value.is_object())) - { - JSON_THROW(detail::type_error::create(314, "only objects can be unflattened", value)); - } - - BasicJsonType result; - - // iterate the JSON object values - for (const auto& element : *value.m_value.object) - { - if (JSON_HEDLEY_UNLIKELY(!element.second.is_primitive())) - { - JSON_THROW(detail::type_error::create(315, "values in object must be primitive", element.second)); - } - - // assign value to reference pointed to by JSON pointer; Note that if - // the JSON pointer is "" (i.e., points to the whole value), function - // get_and_create returns a reference to result itself. An assignment - // will then create a primitive value. - json_pointer(element.first).get_and_create(result) = element.second; - } - - return result; - } - - /*! - @brief compares two JSON pointers for equality - - @param[in] lhs JSON pointer to compare - @param[in] rhs JSON pointer to compare - @return whether @a lhs is equal to @a rhs - - @complexity Linear in the length of the JSON pointer - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - */ - friend bool operator==(json_pointer const& lhs, - json_pointer const& rhs) noexcept - { - return lhs.reference_tokens == rhs.reference_tokens; - } - - /*! - @brief compares two JSON pointers for inequality - - @param[in] lhs JSON pointer to compare - @param[in] rhs JSON pointer to compare - @return whether @a lhs is not equal @a rhs - - @complexity Linear in the length of the JSON pointer - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - */ - friend bool operator!=(json_pointer const& lhs, - json_pointer const& rhs) noexcept - { - return !(lhs == rhs); - } - - /// the reference tokens - std::vector reference_tokens; -}; -} // namespace nlohmann - -// #include - - -#include -#include - -// #include - - -namespace nlohmann -{ -namespace detail -{ -template -class json_ref -{ - public: - using value_type = BasicJsonType; - - json_ref(value_type&& value) - : owned_value(std::move(value)) - {} - - json_ref(const value_type& value) - : value_ref(&value) - {} - - json_ref(std::initializer_list init) - : owned_value(init) - {} - - template < - class... Args, - enable_if_t::value, int> = 0 > - json_ref(Args && ... args) - : owned_value(std::forward(args)...) - {} - - // class should be movable only - json_ref(json_ref&&) noexcept = default; - json_ref(const json_ref&) = delete; - json_ref& operator=(const json_ref&) = delete; - json_ref& operator=(json_ref&&) = delete; - ~json_ref() = default; - - value_type moved_or_copied() const - { - if (value_ref == nullptr) - { - return std::move(owned_value); - } - return *value_ref; - } - - value_type const& operator*() const - { - return value_ref ? *value_ref : owned_value; - } - - value_type const* operator->() const - { - return &** this; - } - - private: - mutable value_type owned_value = nullptr; - value_type const* value_ref = nullptr; -}; -} // namespace detail -} // namespace nlohmann - -// #include - -// #include - -// #include - -// #include - -// #include - - -#include // reverse -#include // array -#include // isnan, isinf -#include // uint8_t, uint16_t, uint32_t, uint64_t -#include // memcpy -#include // numeric_limits -#include // string -#include // move - -// #include - -// #include - -// #include - - -#include // copy -#include // size_t -#include // back_inserter -#include // shared_ptr, make_shared -#include // basic_string -#include // vector - -#ifndef JSON_NO_IO - #include // streamsize - #include // basic_ostream -#endif // JSON_NO_IO - -// #include - - -namespace nlohmann -{ -namespace detail -{ -/// abstract output adapter interface -template struct output_adapter_protocol -{ - virtual void write_character(CharType c) = 0; - virtual void write_characters(const CharType* s, std::size_t length) = 0; - virtual ~output_adapter_protocol() = default; - - output_adapter_protocol() = default; - output_adapter_protocol(const output_adapter_protocol&) = default; - output_adapter_protocol(output_adapter_protocol&&) noexcept = default; - output_adapter_protocol& operator=(const output_adapter_protocol&) = default; - output_adapter_protocol& operator=(output_adapter_protocol&&) noexcept = default; -}; - -/// a type to simplify interfaces -template -using output_adapter_t = std::shared_ptr>; - -/// output adapter for byte vectors -template> -class output_vector_adapter : public output_adapter_protocol -{ - public: - explicit output_vector_adapter(std::vector& vec) noexcept - : v(vec) - {} - - void write_character(CharType c) override - { - v.push_back(c); - } - - JSON_HEDLEY_NON_NULL(2) - void write_characters(const CharType* s, std::size_t length) override - { - std::copy(s, s + length, std::back_inserter(v)); - } - - private: - std::vector& v; -}; - -#ifndef JSON_NO_IO -/// output adapter for output streams -template -class output_stream_adapter : public output_adapter_protocol -{ - public: - explicit output_stream_adapter(std::basic_ostream& s) noexcept - : stream(s) - {} - - void write_character(CharType c) override - { - stream.put(c); - } - - JSON_HEDLEY_NON_NULL(2) - void write_characters(const CharType* s, std::size_t length) override - { - stream.write(s, static_cast(length)); - } - - private: - std::basic_ostream& stream; -}; -#endif // JSON_NO_IO - -/// output adapter for basic_string -template> -class output_string_adapter : public output_adapter_protocol -{ - public: - explicit output_string_adapter(StringType& s) noexcept - : str(s) - {} - - void write_character(CharType c) override - { - str.push_back(c); - } - - JSON_HEDLEY_NON_NULL(2) - void write_characters(const CharType* s, std::size_t length) override - { - str.append(s, length); - } - - private: - StringType& str; -}; - -template> -class output_adapter -{ - public: - template> - output_adapter(std::vector& vec) - : oa(std::make_shared>(vec)) {} - -#ifndef JSON_NO_IO - output_adapter(std::basic_ostream& s) - : oa(std::make_shared>(s)) {} -#endif // JSON_NO_IO - - output_adapter(StringType& s) - : oa(std::make_shared>(s)) {} - - operator output_adapter_t() - { - return oa; - } - - private: - output_adapter_t oa = nullptr; -}; -} // namespace detail -} // namespace nlohmann - - -namespace nlohmann -{ -namespace detail -{ -/////////////////// -// binary writer // -/////////////////// - -/*! -@brief serialization to CBOR and MessagePack values -*/ -template -class binary_writer -{ - using string_t = typename BasicJsonType::string_t; - using binary_t = typename BasicJsonType::binary_t; - using number_float_t = typename BasicJsonType::number_float_t; - - public: - /*! - @brief create a binary writer - - @param[in] adapter output adapter to write to - */ - explicit binary_writer(output_adapter_t adapter) : oa(std::move(adapter)) - { - JSON_ASSERT(oa); - } - - /*! - @param[in] j JSON value to serialize - @pre j.type() == value_t::object - */ - void write_bson(const BasicJsonType& j) - { - switch (j.type()) - { - case value_t::object: - { - write_bson_object(*j.m_value.object); - break; - } - - case value_t::null: - case value_t::array: - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - { - JSON_THROW(type_error::create(317, "to serialize to BSON, top-level type must be object, but is " + std::string(j.type_name()), j)); - } - } - } - - /*! - @param[in] j JSON value to serialize - */ - void write_cbor(const BasicJsonType& j) - { - switch (j.type()) - { - case value_t::null: - { - oa->write_character(to_char_type(0xF6)); - break; - } - - case value_t::boolean: - { - oa->write_character(j.m_value.boolean - ? to_char_type(0xF5) - : to_char_type(0xF4)); - break; - } - - case value_t::number_integer: - { - if (j.m_value.number_integer >= 0) - { - // CBOR does not differentiate between positive signed - // integers and unsigned integers. Therefore, we used the - // code from the value_t::number_unsigned case here. - if (j.m_value.number_integer <= 0x17) - { - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_integer <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x18)); - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_integer <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x19)); - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_integer <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x1A)); - write_number(static_cast(j.m_value.number_integer)); - } - else - { - oa->write_character(to_char_type(0x1B)); - write_number(static_cast(j.m_value.number_integer)); - } - } - else - { - // The conversions below encode the sign in the first - // byte, and the value is converted to a positive number. - const auto positive_number = -1 - j.m_value.number_integer; - if (j.m_value.number_integer >= -24) - { - write_number(static_cast(0x20 + positive_number)); - } - else if (positive_number <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x38)); - write_number(static_cast(positive_number)); - } - else if (positive_number <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x39)); - write_number(static_cast(positive_number)); - } - else if (positive_number <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x3A)); - write_number(static_cast(positive_number)); - } - else - { - oa->write_character(to_char_type(0x3B)); - write_number(static_cast(positive_number)); - } - } - break; - } - - case value_t::number_unsigned: - { - if (j.m_value.number_unsigned <= 0x17) - { - write_number(static_cast(j.m_value.number_unsigned)); - } - else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x18)); - write_number(static_cast(j.m_value.number_unsigned)); - } - else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x19)); - write_number(static_cast(j.m_value.number_unsigned)); - } - else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x1A)); - write_number(static_cast(j.m_value.number_unsigned)); - } - else - { - oa->write_character(to_char_type(0x1B)); - write_number(static_cast(j.m_value.number_unsigned)); - } - break; - } - - case value_t::number_float: - { - if (std::isnan(j.m_value.number_float)) - { - // NaN is 0xf97e00 in CBOR - oa->write_character(to_char_type(0xF9)); - oa->write_character(to_char_type(0x7E)); - oa->write_character(to_char_type(0x00)); - } - else if (std::isinf(j.m_value.number_float)) - { - // Infinity is 0xf97c00, -Infinity is 0xf9fc00 - oa->write_character(to_char_type(0xf9)); - oa->write_character(j.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC)); - oa->write_character(to_char_type(0x00)); - } - else - { - write_compact_float(j.m_value.number_float, detail::input_format_t::cbor); - } - break; - } - - case value_t::string: - { - // step 1: write control byte and the string length - const auto N = j.m_value.string->size(); - if (N <= 0x17) - { - write_number(static_cast(0x60 + N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x78)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x79)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x7A)); - write_number(static_cast(N)); - } - // LCOV_EXCL_START - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x7B)); - write_number(static_cast(N)); - } - // LCOV_EXCL_STOP - - // step 2: write the string - oa->write_characters( - reinterpret_cast(j.m_value.string->c_str()), - j.m_value.string->size()); - break; - } - - case value_t::array: - { - // step 1: write control byte and the array size - const auto N = j.m_value.array->size(); - if (N <= 0x17) - { - write_number(static_cast(0x80 + N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x98)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x99)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x9A)); - write_number(static_cast(N)); - } - // LCOV_EXCL_START - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x9B)); - write_number(static_cast(N)); - } - // LCOV_EXCL_STOP - - // step 2: write each element - for (const auto& el : *j.m_value.array) - { - write_cbor(el); - } - break; - } - - case value_t::binary: - { - if (j.m_value.binary->has_subtype()) - { - if (j.m_value.binary->subtype() <= (std::numeric_limits::max)()) - { - write_number(static_cast(0xd8)); - write_number(static_cast(j.m_value.binary->subtype())); - } - else if (j.m_value.binary->subtype() <= (std::numeric_limits::max)()) - { - write_number(static_cast(0xd9)); - write_number(static_cast(j.m_value.binary->subtype())); - } - else if (j.m_value.binary->subtype() <= (std::numeric_limits::max)()) - { - write_number(static_cast(0xda)); - write_number(static_cast(j.m_value.binary->subtype())); - } - else if (j.m_value.binary->subtype() <= (std::numeric_limits::max)()) - { - write_number(static_cast(0xdb)); - write_number(static_cast(j.m_value.binary->subtype())); - } - } - - // step 1: write control byte and the binary array size - const auto N = j.m_value.binary->size(); - if (N <= 0x17) - { - write_number(static_cast(0x40 + N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x58)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x59)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x5A)); - write_number(static_cast(N)); - } - // LCOV_EXCL_START - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x5B)); - write_number(static_cast(N)); - } - // LCOV_EXCL_STOP - - // step 2: write each element - oa->write_characters( - reinterpret_cast(j.m_value.binary->data()), - N); - - break; - } - - case value_t::object: - { - // step 1: write control byte and the object size - const auto N = j.m_value.object->size(); - if (N <= 0x17) - { - write_number(static_cast(0xA0 + N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0xB8)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0xB9)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0xBA)); - write_number(static_cast(N)); - } - // LCOV_EXCL_START - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0xBB)); - write_number(static_cast(N)); - } - // LCOV_EXCL_STOP - - // step 2: write each element - for (const auto& el : *j.m_value.object) - { - write_cbor(el.first); - write_cbor(el.second); - } - break; - } - - case value_t::discarded: - default: - break; - } - } - - /*! - @param[in] j JSON value to serialize - */ - void write_msgpack(const BasicJsonType& j) - { - switch (j.type()) - { - case value_t::null: // nil - { - oa->write_character(to_char_type(0xC0)); - break; - } - - case value_t::boolean: // true and false - { - oa->write_character(j.m_value.boolean - ? to_char_type(0xC3) - : to_char_type(0xC2)); - break; - } - - case value_t::number_integer: - { - if (j.m_value.number_integer >= 0) - { - // MessagePack does not differentiate between positive - // signed integers and unsigned integers. Therefore, we used - // the code from the value_t::number_unsigned case here. - if (j.m_value.number_unsigned < 128) - { - // positive fixnum - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) - { - // uint 8 - oa->write_character(to_char_type(0xCC)); - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) - { - // uint 16 - oa->write_character(to_char_type(0xCD)); - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) - { - // uint 32 - oa->write_character(to_char_type(0xCE)); - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) - { - // uint 64 - oa->write_character(to_char_type(0xCF)); - write_number(static_cast(j.m_value.number_integer)); - } - } - else - { - if (j.m_value.number_integer >= -32) - { - // negative fixnum - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_integer >= (std::numeric_limits::min)() && - j.m_value.number_integer <= (std::numeric_limits::max)()) - { - // int 8 - oa->write_character(to_char_type(0xD0)); - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_integer >= (std::numeric_limits::min)() && - j.m_value.number_integer <= (std::numeric_limits::max)()) - { - // int 16 - oa->write_character(to_char_type(0xD1)); - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_integer >= (std::numeric_limits::min)() && - j.m_value.number_integer <= (std::numeric_limits::max)()) - { - // int 32 - oa->write_character(to_char_type(0xD2)); - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_integer >= (std::numeric_limits::min)() && - j.m_value.number_integer <= (std::numeric_limits::max)()) - { - // int 64 - oa->write_character(to_char_type(0xD3)); - write_number(static_cast(j.m_value.number_integer)); - } - } - break; - } - - case value_t::number_unsigned: - { - if (j.m_value.number_unsigned < 128) - { - // positive fixnum - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) - { - // uint 8 - oa->write_character(to_char_type(0xCC)); - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) - { - // uint 16 - oa->write_character(to_char_type(0xCD)); - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) - { - // uint 32 - oa->write_character(to_char_type(0xCE)); - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) - { - // uint 64 - oa->write_character(to_char_type(0xCF)); - write_number(static_cast(j.m_value.number_integer)); - } - break; - } - - case value_t::number_float: - { - write_compact_float(j.m_value.number_float, detail::input_format_t::msgpack); - break; - } - - case value_t::string: - { - // step 1: write control byte and the string length - const auto N = j.m_value.string->size(); - if (N <= 31) - { - // fixstr - write_number(static_cast(0xA0 | N)); - } - else if (N <= (std::numeric_limits::max)()) - { - // str 8 - oa->write_character(to_char_type(0xD9)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - // str 16 - oa->write_character(to_char_type(0xDA)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - // str 32 - oa->write_character(to_char_type(0xDB)); - write_number(static_cast(N)); - } - - // step 2: write the string - oa->write_characters( - reinterpret_cast(j.m_value.string->c_str()), - j.m_value.string->size()); - break; - } - - case value_t::array: - { - // step 1: write control byte and the array size - const auto N = j.m_value.array->size(); - if (N <= 15) - { - // fixarray - write_number(static_cast(0x90 | N)); - } - else if (N <= (std::numeric_limits::max)()) - { - // array 16 - oa->write_character(to_char_type(0xDC)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - // array 32 - oa->write_character(to_char_type(0xDD)); - write_number(static_cast(N)); - } - - // step 2: write each element - for (const auto& el : *j.m_value.array) - { - write_msgpack(el); - } - break; - } - - case value_t::binary: - { - // step 0: determine if the binary type has a set subtype to - // determine whether or not to use the ext or fixext types - const bool use_ext = j.m_value.binary->has_subtype(); - - // step 1: write control byte and the byte string length - const auto N = j.m_value.binary->size(); - if (N <= (std::numeric_limits::max)()) - { - std::uint8_t output_type{}; - bool fixed = true; - if (use_ext) - { - switch (N) - { - case 1: - output_type = 0xD4; // fixext 1 - break; - case 2: - output_type = 0xD5; // fixext 2 - break; - case 4: - output_type = 0xD6; // fixext 4 - break; - case 8: - output_type = 0xD7; // fixext 8 - break; - case 16: - output_type = 0xD8; // fixext 16 - break; - default: - output_type = 0xC7; // ext 8 - fixed = false; - break; - } - - } - else - { - output_type = 0xC4; // bin 8 - fixed = false; - } - - oa->write_character(to_char_type(output_type)); - if (!fixed) - { - write_number(static_cast(N)); - } - } - else if (N <= (std::numeric_limits::max)()) - { - std::uint8_t output_type = use_ext - ? 0xC8 // ext 16 - : 0xC5; // bin 16 - - oa->write_character(to_char_type(output_type)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - std::uint8_t output_type = use_ext - ? 0xC9 // ext 32 - : 0xC6; // bin 32 - - oa->write_character(to_char_type(output_type)); - write_number(static_cast(N)); - } - - // step 1.5: if this is an ext type, write the subtype - if (use_ext) - { - write_number(static_cast(j.m_value.binary->subtype())); - } - - // step 2: write the byte string - oa->write_characters( - reinterpret_cast(j.m_value.binary->data()), - N); - - break; - } - - case value_t::object: - { - // step 1: write control byte and the object size - const auto N = j.m_value.object->size(); - if (N <= 15) - { - // fixmap - write_number(static_cast(0x80 | (N & 0xF))); - } - else if (N <= (std::numeric_limits::max)()) - { - // map 16 - oa->write_character(to_char_type(0xDE)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - // map 32 - oa->write_character(to_char_type(0xDF)); - write_number(static_cast(N)); - } - - // step 2: write each element - for (const auto& el : *j.m_value.object) - { - write_msgpack(el.first); - write_msgpack(el.second); - } - break; - } - - case value_t::discarded: - default: - break; - } - } - - /*! - @param[in] j JSON value to serialize - @param[in] use_count whether to use '#' prefixes (optimized format) - @param[in] use_type whether to use '$' prefixes (optimized format) - @param[in] add_prefix whether prefixes need to be used for this value - */ - void write_ubjson(const BasicJsonType& j, const bool use_count, - const bool use_type, const bool add_prefix = true) - { - switch (j.type()) - { - case value_t::null: - { - if (add_prefix) - { - oa->write_character(to_char_type('Z')); - } - break; - } - - case value_t::boolean: - { - if (add_prefix) - { - oa->write_character(j.m_value.boolean - ? to_char_type('T') - : to_char_type('F')); - } - break; - } - - case value_t::number_integer: - { - write_number_with_ubjson_prefix(j.m_value.number_integer, add_prefix); - break; - } - - case value_t::number_unsigned: - { - write_number_with_ubjson_prefix(j.m_value.number_unsigned, add_prefix); - break; - } - - case value_t::number_float: - { - write_number_with_ubjson_prefix(j.m_value.number_float, add_prefix); - break; - } - - case value_t::string: - { - if (add_prefix) - { - oa->write_character(to_char_type('S')); - } - write_number_with_ubjson_prefix(j.m_value.string->size(), true); - oa->write_characters( - reinterpret_cast(j.m_value.string->c_str()), - j.m_value.string->size()); - break; - } - - case value_t::array: - { - if (add_prefix) - { - oa->write_character(to_char_type('[')); - } - - bool prefix_required = true; - if (use_type && !j.m_value.array->empty()) - { - JSON_ASSERT(use_count); - const CharType first_prefix = ubjson_prefix(j.front()); - const bool same_prefix = std::all_of(j.begin() + 1, j.end(), - [this, first_prefix](const BasicJsonType & v) - { - return ubjson_prefix(v) == first_prefix; - }); - - if (same_prefix) - { - prefix_required = false; - oa->write_character(to_char_type('$')); - oa->write_character(first_prefix); - } - } - - if (use_count) - { - oa->write_character(to_char_type('#')); - write_number_with_ubjson_prefix(j.m_value.array->size(), true); - } - - for (const auto& el : *j.m_value.array) - { - write_ubjson(el, use_count, use_type, prefix_required); - } - - if (!use_count) - { - oa->write_character(to_char_type(']')); - } - - break; - } - - case value_t::binary: - { - if (add_prefix) - { - oa->write_character(to_char_type('[')); - } - - if (use_type && !j.m_value.binary->empty()) - { - JSON_ASSERT(use_count); - oa->write_character(to_char_type('$')); - oa->write_character('U'); - } - - if (use_count) - { - oa->write_character(to_char_type('#')); - write_number_with_ubjson_prefix(j.m_value.binary->size(), true); - } - - if (use_type) - { - oa->write_characters( - reinterpret_cast(j.m_value.binary->data()), - j.m_value.binary->size()); - } - else - { - for (size_t i = 0; i < j.m_value.binary->size(); ++i) - { - oa->write_character(to_char_type('U')); - oa->write_character(j.m_value.binary->data()[i]); - } - } - - if (!use_count) - { - oa->write_character(to_char_type(']')); - } - - break; - } - - case value_t::object: - { - if (add_prefix) - { - oa->write_character(to_char_type('{')); - } - - bool prefix_required = true; - if (use_type && !j.m_value.object->empty()) - { - JSON_ASSERT(use_count); - const CharType first_prefix = ubjson_prefix(j.front()); - const bool same_prefix = std::all_of(j.begin(), j.end(), - [this, first_prefix](const BasicJsonType & v) - { - return ubjson_prefix(v) == first_prefix; - }); - - if (same_prefix) - { - prefix_required = false; - oa->write_character(to_char_type('$')); - oa->write_character(first_prefix); - } - } - - if (use_count) - { - oa->write_character(to_char_type('#')); - write_number_with_ubjson_prefix(j.m_value.object->size(), true); - } - - for (const auto& el : *j.m_value.object) - { - write_number_with_ubjson_prefix(el.first.size(), true); - oa->write_characters( - reinterpret_cast(el.first.c_str()), - el.first.size()); - write_ubjson(el.second, use_count, use_type, prefix_required); - } - - if (!use_count) - { - oa->write_character(to_char_type('}')); - } - - break; - } - - case value_t::discarded: - default: - break; - } - } - - private: - ////////// - // BSON // - ////////// - - /*! - @return The size of a BSON document entry header, including the id marker - and the entry name size (and its null-terminator). - */ - static std::size_t calc_bson_entry_header_size(const string_t& name, const BasicJsonType& j) - { - const auto it = name.find(static_cast(0)); - if (JSON_HEDLEY_UNLIKELY(it != BasicJsonType::string_t::npos)) - { - JSON_THROW(out_of_range::create(409, "BSON key cannot contain code point U+0000 (at byte " + std::to_string(it) + ")", j)); - static_cast(j); - } - - return /*id*/ 1ul + name.size() + /*zero-terminator*/1u; - } - - /*! - @brief Writes the given @a element_type and @a name to the output adapter - */ - void write_bson_entry_header(const string_t& name, - const std::uint8_t element_type) - { - oa->write_character(to_char_type(element_type)); // boolean - oa->write_characters( - reinterpret_cast(name.c_str()), - name.size() + 1u); - } - - /*! - @brief Writes a BSON element with key @a name and boolean value @a value - */ - void write_bson_boolean(const string_t& name, - const bool value) - { - write_bson_entry_header(name, 0x08); - oa->write_character(value ? to_char_type(0x01) : to_char_type(0x00)); - } - - /*! - @brief Writes a BSON element with key @a name and double value @a value - */ - void write_bson_double(const string_t& name, - const double value) - { - write_bson_entry_header(name, 0x01); - write_number(value); - } - - /*! - @return The size of the BSON-encoded string in @a value - */ - static std::size_t calc_bson_string_size(const string_t& value) - { - return sizeof(std::int32_t) + value.size() + 1ul; - } - - /*! - @brief Writes a BSON element with key @a name and string value @a value - */ - void write_bson_string(const string_t& name, - const string_t& value) - { - write_bson_entry_header(name, 0x02); - - write_number(static_cast(value.size() + 1ul)); - oa->write_characters( - reinterpret_cast(value.c_str()), - value.size() + 1); - } - - /*! - @brief Writes a BSON element with key @a name and null value - */ - void write_bson_null(const string_t& name) - { - write_bson_entry_header(name, 0x0A); - } - - /*! - @return The size of the BSON-encoded integer @a value - */ - static std::size_t calc_bson_integer_size(const std::int64_t value) - { - return (std::numeric_limits::min)() <= value && value <= (std::numeric_limits::max)() - ? sizeof(std::int32_t) - : sizeof(std::int64_t); - } - - /*! - @brief Writes a BSON element with key @a name and integer @a value - */ - void write_bson_integer(const string_t& name, - const std::int64_t value) - { - if ((std::numeric_limits::min)() <= value && value <= (std::numeric_limits::max)()) - { - write_bson_entry_header(name, 0x10); // int32 - write_number(static_cast(value)); - } - else - { - write_bson_entry_header(name, 0x12); // int64 - write_number(static_cast(value)); - } - } - - /*! - @return The size of the BSON-encoded unsigned integer in @a j - */ - static constexpr std::size_t calc_bson_unsigned_size(const std::uint64_t value) noexcept - { - return (value <= static_cast((std::numeric_limits::max)())) - ? sizeof(std::int32_t) - : sizeof(std::int64_t); - } - - /*! - @brief Writes a BSON element with key @a name and unsigned @a value - */ - void write_bson_unsigned(const string_t& name, - const BasicJsonType& j) - { - if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) - { - write_bson_entry_header(name, 0x10 /* int32 */); - write_number(static_cast(j.m_value.number_unsigned)); - } - else if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) - { - write_bson_entry_header(name, 0x12 /* int64 */); - write_number(static_cast(j.m_value.number_unsigned)); - } - else - { - JSON_THROW(out_of_range::create(407, "integer number " + std::to_string(j.m_value.number_unsigned) + " cannot be represented by BSON as it does not fit int64", j)); - } - } - - /*! - @brief Writes a BSON element with key @a name and object @a value - */ - void write_bson_object_entry(const string_t& name, - const typename BasicJsonType::object_t& value) - { - write_bson_entry_header(name, 0x03); // object - write_bson_object(value); - } - - /*! - @return The size of the BSON-encoded array @a value - */ - static std::size_t calc_bson_array_size(const typename BasicJsonType::array_t& value) - { - std::size_t array_index = 0ul; - - const std::size_t embedded_document_size = std::accumulate(std::begin(value), std::end(value), std::size_t(0), [&array_index](std::size_t result, const typename BasicJsonType::array_t::value_type & el) - { - return result + calc_bson_element_size(std::to_string(array_index++), el); - }); - - return sizeof(std::int32_t) + embedded_document_size + 1ul; - } - - /*! - @return The size of the BSON-encoded binary array @a value - */ - static std::size_t calc_bson_binary_size(const typename BasicJsonType::binary_t& value) - { - return sizeof(std::int32_t) + value.size() + 1ul; - } - - /*! - @brief Writes a BSON element with key @a name and array @a value - */ - void write_bson_array(const string_t& name, - const typename BasicJsonType::array_t& value) - { - write_bson_entry_header(name, 0x04); // array - write_number(static_cast(calc_bson_array_size(value))); - - std::size_t array_index = 0ul; - - for (const auto& el : value) - { - write_bson_element(std::to_string(array_index++), el); - } - - oa->write_character(to_char_type(0x00)); - } - - /*! - @brief Writes a BSON element with key @a name and binary value @a value - */ - void write_bson_binary(const string_t& name, - const binary_t& value) - { - write_bson_entry_header(name, 0x05); - - write_number(static_cast(value.size())); - write_number(value.has_subtype() ? static_cast(value.subtype()) : std::uint8_t(0x00)); - - oa->write_characters(reinterpret_cast(value.data()), value.size()); - } - - /*! - @brief Calculates the size necessary to serialize the JSON value @a j with its @a name - @return The calculated size for the BSON document entry for @a j with the given @a name. - */ - static std::size_t calc_bson_element_size(const string_t& name, - const BasicJsonType& j) - { - const auto header_size = calc_bson_entry_header_size(name, j); - switch (j.type()) - { - case value_t::object: - return header_size + calc_bson_object_size(*j.m_value.object); - - case value_t::array: - return header_size + calc_bson_array_size(*j.m_value.array); - - case value_t::binary: - return header_size + calc_bson_binary_size(*j.m_value.binary); - - case value_t::boolean: - return header_size + 1ul; - - case value_t::number_float: - return header_size + 8ul; - - case value_t::number_integer: - return header_size + calc_bson_integer_size(j.m_value.number_integer); - - case value_t::number_unsigned: - return header_size + calc_bson_unsigned_size(j.m_value.number_unsigned); - - case value_t::string: - return header_size + calc_bson_string_size(*j.m_value.string); - - case value_t::null: - return header_size + 0ul; - - // LCOV_EXCL_START - case value_t::discarded: - default: - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) - return 0ul; - // LCOV_EXCL_STOP - } - } - - /*! - @brief Serializes the JSON value @a j to BSON and associates it with the - key @a name. - @param name The name to associate with the JSON entity @a j within the - current BSON document - */ - void write_bson_element(const string_t& name, - const BasicJsonType& j) - { - switch (j.type()) - { - case value_t::object: - return write_bson_object_entry(name, *j.m_value.object); - - case value_t::array: - return write_bson_array(name, *j.m_value.array); - - case value_t::binary: - return write_bson_binary(name, *j.m_value.binary); - - case value_t::boolean: - return write_bson_boolean(name, j.m_value.boolean); - - case value_t::number_float: - return write_bson_double(name, j.m_value.number_float); - - case value_t::number_integer: - return write_bson_integer(name, j.m_value.number_integer); - - case value_t::number_unsigned: - return write_bson_unsigned(name, j); - - case value_t::string: - return write_bson_string(name, *j.m_value.string); - - case value_t::null: - return write_bson_null(name); - - // LCOV_EXCL_START - case value_t::discarded: - default: - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) - return; - // LCOV_EXCL_STOP - } - } - - /*! - @brief Calculates the size of the BSON serialization of the given - JSON-object @a j. - @param[in] value JSON value to serialize - @pre value.type() == value_t::object - */ - static std::size_t calc_bson_object_size(const typename BasicJsonType::object_t& value) - { - std::size_t document_size = std::accumulate(value.begin(), value.end(), std::size_t(0), - [](size_t result, const typename BasicJsonType::object_t::value_type & el) - { - return result += calc_bson_element_size(el.first, el.second); - }); - - return sizeof(std::int32_t) + document_size + 1ul; - } - - /*! - @param[in] value JSON value to serialize - @pre value.type() == value_t::object - */ - void write_bson_object(const typename BasicJsonType::object_t& value) - { - write_number(static_cast(calc_bson_object_size(value))); - - for (const auto& el : value) - { - write_bson_element(el.first, el.second); - } - - oa->write_character(to_char_type(0x00)); - } - - ////////// - // CBOR // - ////////// - - static constexpr CharType get_cbor_float_prefix(float /*unused*/) - { - return to_char_type(0xFA); // Single-Precision Float - } - - static constexpr CharType get_cbor_float_prefix(double /*unused*/) - { - return to_char_type(0xFB); // Double-Precision Float - } - - ///////////// - // MsgPack // - ///////////// - - static constexpr CharType get_msgpack_float_prefix(float /*unused*/) - { - return to_char_type(0xCA); // float 32 - } - - static constexpr CharType get_msgpack_float_prefix(double /*unused*/) - { - return to_char_type(0xCB); // float 64 - } - - //////////// - // UBJSON // - //////////// - - // UBJSON: write number (floating point) - template::value, int>::type = 0> - void write_number_with_ubjson_prefix(const NumberType n, - const bool add_prefix) - { - if (add_prefix) - { - oa->write_character(get_ubjson_float_prefix(n)); - } - write_number(n); - } - - // UBJSON: write number (unsigned integer) - template::value, int>::type = 0> - void write_number_with_ubjson_prefix(const NumberType n, - const bool add_prefix) - { - if (n <= static_cast((std::numeric_limits::max)())) - { - if (add_prefix) - { - oa->write_character(to_char_type('i')); // int8 - } - write_number(static_cast(n)); - } - else if (n <= (std::numeric_limits::max)()) - { - if (add_prefix) - { - oa->write_character(to_char_type('U')); // uint8 - } - write_number(static_cast(n)); - } - else if (n <= static_cast((std::numeric_limits::max)())) - { - if (add_prefix) - { - oa->write_character(to_char_type('I')); // int16 - } - write_number(static_cast(n)); - } - else if (n <= static_cast((std::numeric_limits::max)())) - { - if (add_prefix) - { - oa->write_character(to_char_type('l')); // int32 - } - write_number(static_cast(n)); - } - else if (n <= static_cast((std::numeric_limits::max)())) - { - if (add_prefix) - { - oa->write_character(to_char_type('L')); // int64 - } - write_number(static_cast(n)); - } - else - { - if (add_prefix) - { - oa->write_character(to_char_type('H')); // high-precision number - } - - const auto number = BasicJsonType(n).dump(); - write_number_with_ubjson_prefix(number.size(), true); - for (std::size_t i = 0; i < number.size(); ++i) - { - oa->write_character(to_char_type(static_cast(number[i]))); - } - } - } - - // UBJSON: write number (signed integer) - template < typename NumberType, typename std::enable_if < - std::is_signed::value&& - !std::is_floating_point::value, int >::type = 0 > - void write_number_with_ubjson_prefix(const NumberType n, - const bool add_prefix) - { - if ((std::numeric_limits::min)() <= n && n <= (std::numeric_limits::max)()) - { - if (add_prefix) - { - oa->write_character(to_char_type('i')); // int8 - } - write_number(static_cast(n)); - } - else if (static_cast((std::numeric_limits::min)()) <= n && n <= static_cast((std::numeric_limits::max)())) - { - if (add_prefix) - { - oa->write_character(to_char_type('U')); // uint8 - } - write_number(static_cast(n)); - } - else if ((std::numeric_limits::min)() <= n && n <= (std::numeric_limits::max)()) - { - if (add_prefix) - { - oa->write_character(to_char_type('I')); // int16 - } - write_number(static_cast(n)); - } - else if ((std::numeric_limits::min)() <= n && n <= (std::numeric_limits::max)()) - { - if (add_prefix) - { - oa->write_character(to_char_type('l')); // int32 - } - write_number(static_cast(n)); - } - else if ((std::numeric_limits::min)() <= n && n <= (std::numeric_limits::max)()) - { - if (add_prefix) - { - oa->write_character(to_char_type('L')); // int64 - } - write_number(static_cast(n)); - } - // LCOV_EXCL_START - else - { - if (add_prefix) - { - oa->write_character(to_char_type('H')); // high-precision number - } - - const auto number = BasicJsonType(n).dump(); - write_number_with_ubjson_prefix(number.size(), true); - for (std::size_t i = 0; i < number.size(); ++i) - { - oa->write_character(to_char_type(static_cast(number[i]))); - } - } - // LCOV_EXCL_STOP - } - - /*! - @brief determine the type prefix of container values - */ - CharType ubjson_prefix(const BasicJsonType& j) const noexcept - { - switch (j.type()) - { - case value_t::null: - return 'Z'; - - case value_t::boolean: - return j.m_value.boolean ? 'T' : 'F'; - - case value_t::number_integer: - { - if ((std::numeric_limits::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits::max)()) - { - return 'i'; - } - if ((std::numeric_limits::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits::max)()) - { - return 'U'; - } - if ((std::numeric_limits::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits::max)()) - { - return 'I'; - } - if ((std::numeric_limits::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits::max)()) - { - return 'l'; - } - if ((std::numeric_limits::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits::max)()) - { - return 'L'; - } - // anything else is treated as high-precision number - return 'H'; // LCOV_EXCL_LINE - } - - case value_t::number_unsigned: - { - if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) - { - return 'i'; - } - if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) - { - return 'U'; - } - if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) - { - return 'I'; - } - if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) - { - return 'l'; - } - if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) - { - return 'L'; - } - // anything else is treated as high-precision number - return 'H'; // LCOV_EXCL_LINE - } - - case value_t::number_float: - return get_ubjson_float_prefix(j.m_value.number_float); - - case value_t::string: - return 'S'; - - case value_t::array: // fallthrough - case value_t::binary: - return '['; - - case value_t::object: - return '{'; - - case value_t::discarded: - default: // discarded values - return 'N'; - } - } - - static constexpr CharType get_ubjson_float_prefix(float /*unused*/) - { - return 'd'; // float 32 - } - - static constexpr CharType get_ubjson_float_prefix(double /*unused*/) - { - return 'D'; // float 64 - } - - /////////////////////// - // Utility functions // - /////////////////////// - - /* - @brief write a number to output input - @param[in] n number of type @a NumberType - @tparam NumberType the type of the number - @tparam OutputIsLittleEndian Set to true if output data is - required to be little endian - - @note This function needs to respect the system's endianess, because bytes - in CBOR, MessagePack, and UBJSON are stored in network order (big - endian) and therefore need reordering on little endian systems. - */ - template - void write_number(const NumberType n) - { - // step 1: write number to array of length NumberType - std::array vec{}; - std::memcpy(vec.data(), &n, sizeof(NumberType)); - - // step 2: write array to output (with possible reordering) - if (is_little_endian != OutputIsLittleEndian) - { - // reverse byte order prior to conversion if necessary - std::reverse(vec.begin(), vec.end()); - } - - oa->write_characters(vec.data(), sizeof(NumberType)); - } - - void write_compact_float(const number_float_t n, detail::input_format_t format) - { -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wfloat-equal" -#endif - if (static_cast(n) >= static_cast(std::numeric_limits::lowest()) && - static_cast(n) <= static_cast((std::numeric_limits::max)()) && - static_cast(static_cast(n)) == static_cast(n)) - { - oa->write_character(format == detail::input_format_t::cbor - ? get_cbor_float_prefix(static_cast(n)) - : get_msgpack_float_prefix(static_cast(n))); - write_number(static_cast(n)); - } - else - { - oa->write_character(format == detail::input_format_t::cbor - ? get_cbor_float_prefix(n) - : get_msgpack_float_prefix(n)); - write_number(n); - } -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif - } - - public: - // The following to_char_type functions are implement the conversion - // between uint8_t and CharType. In case CharType is not unsigned, - // such a conversion is required to allow values greater than 128. - // See for a discussion. - template < typename C = CharType, - enable_if_t < std::is_signed::value && std::is_signed::value > * = nullptr > - static constexpr CharType to_char_type(std::uint8_t x) noexcept - { - return *reinterpret_cast(&x); - } - - template < typename C = CharType, - enable_if_t < std::is_signed::value && std::is_unsigned::value > * = nullptr > - static CharType to_char_type(std::uint8_t x) noexcept - { - static_assert(sizeof(std::uint8_t) == sizeof(CharType), "size of CharType must be equal to std::uint8_t"); - static_assert(std::is_trivial::value, "CharType must be trivial"); - CharType result; - std::memcpy(&result, &x, sizeof(x)); - return result; - } - - template::value>* = nullptr> - static constexpr CharType to_char_type(std::uint8_t x) noexcept - { - return x; - } - - template < typename InputCharType, typename C = CharType, - enable_if_t < - std::is_signed::value && - std::is_signed::value && - std::is_same::type>::value - > * = nullptr > - static constexpr CharType to_char_type(InputCharType x) noexcept - { - return x; - } - - private: - /// whether we can assume little endianess - const bool is_little_endian = little_endianess(); - - /// the output - output_adapter_t oa = nullptr; -}; -} // namespace detail -} // namespace nlohmann - -// #include - -// #include - - -#include // reverse, remove, fill, find, none_of -#include // array -#include // localeconv, lconv -#include // labs, isfinite, isnan, signbit -#include // size_t, ptrdiff_t -#include // uint8_t -#include // snprintf -#include // numeric_limits -#include // string, char_traits -#include // setfill, setw -#include // stringstream -#include // is_same -#include // move - -// #include - - -#include // array -#include // signbit, isfinite -#include // intN_t, uintN_t -#include // memcpy, memmove -#include // numeric_limits -#include // conditional - -// #include - - -namespace nlohmann -{ -namespace detail -{ - -/*! -@brief implements the Grisu2 algorithm for binary to decimal floating-point -conversion. - -This implementation is a slightly modified version of the reference -implementation which may be obtained from -http://florian.loitsch.com/publications (bench.tar.gz). - -The code is distributed under the MIT license, Copyright (c) 2009 Florian Loitsch. - -For a detailed description of the algorithm see: - -[1] Loitsch, "Printing Floating-Point Numbers Quickly and Accurately with - Integers", Proceedings of the ACM SIGPLAN 2010 Conference on Programming - Language Design and Implementation, PLDI 2010 -[2] Burger, Dybvig, "Printing Floating-Point Numbers Quickly and Accurately", - Proceedings of the ACM SIGPLAN 1996 Conference on Programming Language - Design and Implementation, PLDI 1996 -*/ -namespace dtoa_impl -{ - -template -Target reinterpret_bits(const Source source) -{ - static_assert(sizeof(Target) == sizeof(Source), "size mismatch"); - - Target target; - std::memcpy(&target, &source, sizeof(Source)); - return target; -} - -struct diyfp // f * 2^e -{ - static constexpr int kPrecision = 64; // = q - - std::uint64_t f = 0; - int e = 0; - - constexpr diyfp(std::uint64_t f_, int e_) noexcept : f(f_), e(e_) {} - - /*! - @brief returns x - y - @pre x.e == y.e and x.f >= y.f - */ - static diyfp sub(const diyfp& x, const diyfp& y) noexcept - { - JSON_ASSERT(x.e == y.e); - JSON_ASSERT(x.f >= y.f); - - return {x.f - y.f, x.e}; - } - - /*! - @brief returns x * y - @note The result is rounded. (Only the upper q bits are returned.) - */ - static diyfp mul(const diyfp& x, const diyfp& y) noexcept - { - static_assert(kPrecision == 64, "internal error"); - - // Computes: - // f = round((x.f * y.f) / 2^q) - // e = x.e + y.e + q - - // Emulate the 64-bit * 64-bit multiplication: - // - // p = u * v - // = (u_lo + 2^32 u_hi) (v_lo + 2^32 v_hi) - // = (u_lo v_lo ) + 2^32 ((u_lo v_hi ) + (u_hi v_lo )) + 2^64 (u_hi v_hi ) - // = (p0 ) + 2^32 ((p1 ) + (p2 )) + 2^64 (p3 ) - // = (p0_lo + 2^32 p0_hi) + 2^32 ((p1_lo + 2^32 p1_hi) + (p2_lo + 2^32 p2_hi)) + 2^64 (p3 ) - // = (p0_lo ) + 2^32 (p0_hi + p1_lo + p2_lo ) + 2^64 (p1_hi + p2_hi + p3) - // = (p0_lo ) + 2^32 (Q ) + 2^64 (H ) - // = (p0_lo ) + 2^32 (Q_lo + 2^32 Q_hi ) + 2^64 (H ) - // - // (Since Q might be larger than 2^32 - 1) - // - // = (p0_lo + 2^32 Q_lo) + 2^64 (Q_hi + H) - // - // (Q_hi + H does not overflow a 64-bit int) - // - // = p_lo + 2^64 p_hi - - const std::uint64_t u_lo = x.f & 0xFFFFFFFFu; - const std::uint64_t u_hi = x.f >> 32u; - const std::uint64_t v_lo = y.f & 0xFFFFFFFFu; - const std::uint64_t v_hi = y.f >> 32u; - - const std::uint64_t p0 = u_lo * v_lo; - const std::uint64_t p1 = u_lo * v_hi; - const std::uint64_t p2 = u_hi * v_lo; - const std::uint64_t p3 = u_hi * v_hi; - - const std::uint64_t p0_hi = p0 >> 32u; - const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu; - const std::uint64_t p1_hi = p1 >> 32u; - const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu; - const std::uint64_t p2_hi = p2 >> 32u; - - std::uint64_t Q = p0_hi + p1_lo + p2_lo; - - // The full product might now be computed as - // - // p_hi = p3 + p2_hi + p1_hi + (Q >> 32) - // p_lo = p0_lo + (Q << 32) - // - // But in this particular case here, the full p_lo is not required. - // Effectively we only need to add the highest bit in p_lo to p_hi (and - // Q_hi + 1 does not overflow). - - Q += std::uint64_t{1} << (64u - 32u - 1u); // round, ties up - - const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u); - - return {h, x.e + y.e + 64}; - } - - /*! - @brief normalize x such that the significand is >= 2^(q-1) - @pre x.f != 0 - */ - static diyfp normalize(diyfp x) noexcept - { - JSON_ASSERT(x.f != 0); - - while ((x.f >> 63u) == 0) - { - x.f <<= 1u; - x.e--; - } - - return x; - } - - /*! - @brief normalize x such that the result has the exponent E - @pre e >= x.e and the upper e - x.e bits of x.f must be zero. - */ - static diyfp normalize_to(const diyfp& x, const int target_exponent) noexcept - { - const int delta = x.e - target_exponent; - - JSON_ASSERT(delta >= 0); - JSON_ASSERT(((x.f << delta) >> delta) == x.f); - - return {x.f << delta, target_exponent}; - } -}; - -struct boundaries -{ - diyfp w; - diyfp minus; - diyfp plus; -}; - -/*! -Compute the (normalized) diyfp representing the input number 'value' and its -boundaries. - -@pre value must be finite and positive -*/ -template -boundaries compute_boundaries(FloatType value) -{ - JSON_ASSERT(std::isfinite(value)); - JSON_ASSERT(value > 0); - - // Convert the IEEE representation into a diyfp. - // - // If v is denormal: - // value = 0.F * 2^(1 - bias) = ( F) * 2^(1 - bias - (p-1)) - // If v is normalized: - // value = 1.F * 2^(E - bias) = (2^(p-1) + F) * 2^(E - bias - (p-1)) - - static_assert(std::numeric_limits::is_iec559, - "internal error: dtoa_short requires an IEEE-754 floating-point implementation"); - - constexpr int kPrecision = std::numeric_limits::digits; // = p (includes the hidden bit) - constexpr int kBias = std::numeric_limits::max_exponent - 1 + (kPrecision - 1); - constexpr int kMinExp = 1 - kBias; - constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1); // = 2^(p-1) - - using bits_type = typename std::conditional::type; - - const auto bits = static_cast(reinterpret_bits(value)); - const std::uint64_t E = bits >> (kPrecision - 1); - const std::uint64_t F = bits & (kHiddenBit - 1); - - const bool is_denormal = E == 0; - const diyfp v = is_denormal - ? diyfp(F, kMinExp) - : diyfp(F + kHiddenBit, static_cast(E) - kBias); - - // Compute the boundaries m- and m+ of the floating-point value - // v = f * 2^e. - // - // Determine v- and v+, the floating-point predecessor and successor if v, - // respectively. - // - // v- = v - 2^e if f != 2^(p-1) or e == e_min (A) - // = v - 2^(e-1) if f == 2^(p-1) and e > e_min (B) - // - // v+ = v + 2^e - // - // Let m- = (v- + v) / 2 and m+ = (v + v+) / 2. All real numbers _strictly_ - // between m- and m+ round to v, regardless of how the input rounding - // algorithm breaks ties. - // - // ---+-------------+-------------+-------------+-------------+--- (A) - // v- m- v m+ v+ - // - // -----------------+------+------+-------------+-------------+--- (B) - // v- m- v m+ v+ - - const bool lower_boundary_is_closer = F == 0 && E > 1; - const diyfp m_plus = diyfp(2 * v.f + 1, v.e - 1); - const diyfp m_minus = lower_boundary_is_closer - ? diyfp(4 * v.f - 1, v.e - 2) // (B) - : diyfp(2 * v.f - 1, v.e - 1); // (A) - - // Determine the normalized w+ = m+. - const diyfp w_plus = diyfp::normalize(m_plus); - - // Determine w- = m- such that e_(w-) = e_(w+). - const diyfp w_minus = diyfp::normalize_to(m_minus, w_plus.e); - - return {diyfp::normalize(v), w_minus, w_plus}; -} - -// Given normalized diyfp w, Grisu needs to find a (normalized) cached -// power-of-ten c, such that the exponent of the product c * w = f * 2^e lies -// within a certain range [alpha, gamma] (Definition 3.2 from [1]) -// -// alpha <= e = e_c + e_w + q <= gamma -// -// or -// -// f_c * f_w * 2^alpha <= f_c 2^(e_c) * f_w 2^(e_w) * 2^q -// <= f_c * f_w * 2^gamma -// -// Since c and w are normalized, i.e. 2^(q-1) <= f < 2^q, this implies -// -// 2^(q-1) * 2^(q-1) * 2^alpha <= c * w * 2^q < 2^q * 2^q * 2^gamma -// -// or -// -// 2^(q - 2 + alpha) <= c * w < 2^(q + gamma) -// -// The choice of (alpha,gamma) determines the size of the table and the form of -// the digit generation procedure. Using (alpha,gamma)=(-60,-32) works out well -// in practice: -// -// The idea is to cut the number c * w = f * 2^e into two parts, which can be -// processed independently: An integral part p1, and a fractional part p2: -// -// f * 2^e = ( (f div 2^-e) * 2^-e + (f mod 2^-e) ) * 2^e -// = (f div 2^-e) + (f mod 2^-e) * 2^e -// = p1 + p2 * 2^e -// -// The conversion of p1 into decimal form requires a series of divisions and -// modulos by (a power of) 10. These operations are faster for 32-bit than for -// 64-bit integers, so p1 should ideally fit into a 32-bit integer. This can be -// achieved by choosing -// -// -e >= 32 or e <= -32 := gamma -// -// In order to convert the fractional part -// -// p2 * 2^e = p2 / 2^-e = d[-1] / 10^1 + d[-2] / 10^2 + ... -// -// into decimal form, the fraction is repeatedly multiplied by 10 and the digits -// d[-i] are extracted in order: -// -// (10 * p2) div 2^-e = d[-1] -// (10 * p2) mod 2^-e = d[-2] / 10^1 + ... -// -// The multiplication by 10 must not overflow. It is sufficient to choose -// -// 10 * p2 < 16 * p2 = 2^4 * p2 <= 2^64. -// -// Since p2 = f mod 2^-e < 2^-e, -// -// -e <= 60 or e >= -60 := alpha - -constexpr int kAlpha = -60; -constexpr int kGamma = -32; - -struct cached_power // c = f * 2^e ~= 10^k -{ - std::uint64_t f; - int e; - int k; -}; - -/*! -For a normalized diyfp w = f * 2^e, this function returns a (normalized) cached -power-of-ten c = f_c * 2^e_c, such that the exponent of the product w * c -satisfies (Definition 3.2 from [1]) - - alpha <= e_c + e + q <= gamma. -*/ -inline cached_power get_cached_power_for_binary_exponent(int e) -{ - // Now - // - // alpha <= e_c + e + q <= gamma (1) - // ==> f_c * 2^alpha <= c * 2^e * 2^q - // - // and since the c's are normalized, 2^(q-1) <= f_c, - // - // ==> 2^(q - 1 + alpha) <= c * 2^(e + q) - // ==> 2^(alpha - e - 1) <= c - // - // If c were an exact power of ten, i.e. c = 10^k, one may determine k as - // - // k = ceil( log_10( 2^(alpha - e - 1) ) ) - // = ceil( (alpha - e - 1) * log_10(2) ) - // - // From the paper: - // "In theory the result of the procedure could be wrong since c is rounded, - // and the computation itself is approximated [...]. In practice, however, - // this simple function is sufficient." - // - // For IEEE double precision floating-point numbers converted into - // normalized diyfp's w = f * 2^e, with q = 64, - // - // e >= -1022 (min IEEE exponent) - // -52 (p - 1) - // -52 (p - 1, possibly normalize denormal IEEE numbers) - // -11 (normalize the diyfp) - // = -1137 - // - // and - // - // e <= +1023 (max IEEE exponent) - // -52 (p - 1) - // -11 (normalize the diyfp) - // = 960 - // - // This binary exponent range [-1137,960] results in a decimal exponent - // range [-307,324]. One does not need to store a cached power for each - // k in this range. For each such k it suffices to find a cached power - // such that the exponent of the product lies in [alpha,gamma]. - // This implies that the difference of the decimal exponents of adjacent - // table entries must be less than or equal to - // - // floor( (gamma - alpha) * log_10(2) ) = 8. - // - // (A smaller distance gamma-alpha would require a larger table.) - - // NB: - // Actually this function returns c, such that -60 <= e_c + e + 64 <= -34. - - constexpr int kCachedPowersMinDecExp = -300; - constexpr int kCachedPowersDecStep = 8; - - static constexpr std::array kCachedPowers = - { - { - { 0xAB70FE17C79AC6CA, -1060, -300 }, - { 0xFF77B1FCBEBCDC4F, -1034, -292 }, - { 0xBE5691EF416BD60C, -1007, -284 }, - { 0x8DD01FAD907FFC3C, -980, -276 }, - { 0xD3515C2831559A83, -954, -268 }, - { 0x9D71AC8FADA6C9B5, -927, -260 }, - { 0xEA9C227723EE8BCB, -901, -252 }, - { 0xAECC49914078536D, -874, -244 }, - { 0x823C12795DB6CE57, -847, -236 }, - { 0xC21094364DFB5637, -821, -228 }, - { 0x9096EA6F3848984F, -794, -220 }, - { 0xD77485CB25823AC7, -768, -212 }, - { 0xA086CFCD97BF97F4, -741, -204 }, - { 0xEF340A98172AACE5, -715, -196 }, - { 0xB23867FB2A35B28E, -688, -188 }, - { 0x84C8D4DFD2C63F3B, -661, -180 }, - { 0xC5DD44271AD3CDBA, -635, -172 }, - { 0x936B9FCEBB25C996, -608, -164 }, - { 0xDBAC6C247D62A584, -582, -156 }, - { 0xA3AB66580D5FDAF6, -555, -148 }, - { 0xF3E2F893DEC3F126, -529, -140 }, - { 0xB5B5ADA8AAFF80B8, -502, -132 }, - { 0x87625F056C7C4A8B, -475, -124 }, - { 0xC9BCFF6034C13053, -449, -116 }, - { 0x964E858C91BA2655, -422, -108 }, - { 0xDFF9772470297EBD, -396, -100 }, - { 0xA6DFBD9FB8E5B88F, -369, -92 }, - { 0xF8A95FCF88747D94, -343, -84 }, - { 0xB94470938FA89BCF, -316, -76 }, - { 0x8A08F0F8BF0F156B, -289, -68 }, - { 0xCDB02555653131B6, -263, -60 }, - { 0x993FE2C6D07B7FAC, -236, -52 }, - { 0xE45C10C42A2B3B06, -210, -44 }, - { 0xAA242499697392D3, -183, -36 }, - { 0xFD87B5F28300CA0E, -157, -28 }, - { 0xBCE5086492111AEB, -130, -20 }, - { 0x8CBCCC096F5088CC, -103, -12 }, - { 0xD1B71758E219652C, -77, -4 }, - { 0x9C40000000000000, -50, 4 }, - { 0xE8D4A51000000000, -24, 12 }, - { 0xAD78EBC5AC620000, 3, 20 }, - { 0x813F3978F8940984, 30, 28 }, - { 0xC097CE7BC90715B3, 56, 36 }, - { 0x8F7E32CE7BEA5C70, 83, 44 }, - { 0xD5D238A4ABE98068, 109, 52 }, - { 0x9F4F2726179A2245, 136, 60 }, - { 0xED63A231D4C4FB27, 162, 68 }, - { 0xB0DE65388CC8ADA8, 189, 76 }, - { 0x83C7088E1AAB65DB, 216, 84 }, - { 0xC45D1DF942711D9A, 242, 92 }, - { 0x924D692CA61BE758, 269, 100 }, - { 0xDA01EE641A708DEA, 295, 108 }, - { 0xA26DA3999AEF774A, 322, 116 }, - { 0xF209787BB47D6B85, 348, 124 }, - { 0xB454E4A179DD1877, 375, 132 }, - { 0x865B86925B9BC5C2, 402, 140 }, - { 0xC83553C5C8965D3D, 428, 148 }, - { 0x952AB45CFA97A0B3, 455, 156 }, - { 0xDE469FBD99A05FE3, 481, 164 }, - { 0xA59BC234DB398C25, 508, 172 }, - { 0xF6C69A72A3989F5C, 534, 180 }, - { 0xB7DCBF5354E9BECE, 561, 188 }, - { 0x88FCF317F22241E2, 588, 196 }, - { 0xCC20CE9BD35C78A5, 614, 204 }, - { 0x98165AF37B2153DF, 641, 212 }, - { 0xE2A0B5DC971F303A, 667, 220 }, - { 0xA8D9D1535CE3B396, 694, 228 }, - { 0xFB9B7CD9A4A7443C, 720, 236 }, - { 0xBB764C4CA7A44410, 747, 244 }, - { 0x8BAB8EEFB6409C1A, 774, 252 }, - { 0xD01FEF10A657842C, 800, 260 }, - { 0x9B10A4E5E9913129, 827, 268 }, - { 0xE7109BFBA19C0C9D, 853, 276 }, - { 0xAC2820D9623BF429, 880, 284 }, - { 0x80444B5E7AA7CF85, 907, 292 }, - { 0xBF21E44003ACDD2D, 933, 300 }, - { 0x8E679C2F5E44FF8F, 960, 308 }, - { 0xD433179D9C8CB841, 986, 316 }, - { 0x9E19DB92B4E31BA9, 1013, 324 }, - } - }; - - // This computation gives exactly the same results for k as - // k = ceil((kAlpha - e - 1) * 0.30102999566398114) - // for |e| <= 1500, but doesn't require floating-point operations. - // NB: log_10(2) ~= 78913 / 2^18 - JSON_ASSERT(e >= -1500); - JSON_ASSERT(e <= 1500); - const int f = kAlpha - e - 1; - const int k = (f * 78913) / (1 << 18) + static_cast(f > 0); - - const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep; - JSON_ASSERT(index >= 0); - JSON_ASSERT(static_cast(index) < kCachedPowers.size()); - - const cached_power cached = kCachedPowers[static_cast(index)]; - JSON_ASSERT(kAlpha <= cached.e + e + 64); - JSON_ASSERT(kGamma >= cached.e + e + 64); - - return cached; -} - -/*! -For n != 0, returns k, such that pow10 := 10^(k-1) <= n < 10^k. -For n == 0, returns 1 and sets pow10 := 1. -*/ -inline int find_largest_pow10(const std::uint32_t n, std::uint32_t& pow10) -{ - // LCOV_EXCL_START - if (n >= 1000000000) - { - pow10 = 1000000000; - return 10; - } - // LCOV_EXCL_STOP - if (n >= 100000000) - { - pow10 = 100000000; - return 9; - } - if (n >= 10000000) - { - pow10 = 10000000; - return 8; - } - if (n >= 1000000) - { - pow10 = 1000000; - return 7; - } - if (n >= 100000) - { - pow10 = 100000; - return 6; - } - if (n >= 10000) - { - pow10 = 10000; - return 5; - } - if (n >= 1000) - { - pow10 = 1000; - return 4; - } - if (n >= 100) - { - pow10 = 100; - return 3; - } - if (n >= 10) - { - pow10 = 10; - return 2; - } - - pow10 = 1; - return 1; -} - -inline void grisu2_round(char* buf, int len, std::uint64_t dist, std::uint64_t delta, - std::uint64_t rest, std::uint64_t ten_k) -{ - JSON_ASSERT(len >= 1); - JSON_ASSERT(dist <= delta); - JSON_ASSERT(rest <= delta); - JSON_ASSERT(ten_k > 0); - - // <--------------------------- delta ----> - // <---- dist ---------> - // --------------[------------------+-------------------]-------------- - // M- w M+ - // - // ten_k - // <------> - // <---- rest ----> - // --------------[------------------+----+--------------]-------------- - // w V - // = buf * 10^k - // - // ten_k represents a unit-in-the-last-place in the decimal representation - // stored in buf. - // Decrement buf by ten_k while this takes buf closer to w. - - // The tests are written in this order to avoid overflow in unsigned - // integer arithmetic. - - while (rest < dist - && delta - rest >= ten_k - && (rest + ten_k < dist || dist - rest > rest + ten_k - dist)) - { - JSON_ASSERT(buf[len - 1] != '0'); - buf[len - 1]--; - rest += ten_k; - } -} - -/*! -Generates V = buffer * 10^decimal_exponent, such that M- <= V <= M+. -M- and M+ must be normalized and share the same exponent -60 <= e <= -32. -*/ -inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent, - diyfp M_minus, diyfp w, diyfp M_plus) -{ - static_assert(kAlpha >= -60, "internal error"); - static_assert(kGamma <= -32, "internal error"); - - // Generates the digits (and the exponent) of a decimal floating-point - // number V = buffer * 10^decimal_exponent in the range [M-, M+]. The diyfp's - // w, M- and M+ share the same exponent e, which satisfies alpha <= e <= gamma. - // - // <--------------------------- delta ----> - // <---- dist ---------> - // --------------[------------------+-------------------]-------------- - // M- w M+ - // - // Grisu2 generates the digits of M+ from left to right and stops as soon as - // V is in [M-,M+]. - - JSON_ASSERT(M_plus.e >= kAlpha); - JSON_ASSERT(M_plus.e <= kGamma); - - std::uint64_t delta = diyfp::sub(M_plus, M_minus).f; // (significand of (M+ - M-), implicit exponent is e) - std::uint64_t dist = diyfp::sub(M_plus, w ).f; // (significand of (M+ - w ), implicit exponent is e) - - // Split M+ = f * 2^e into two parts p1 and p2 (note: e < 0): - // - // M+ = f * 2^e - // = ((f div 2^-e) * 2^-e + (f mod 2^-e)) * 2^e - // = ((p1 ) * 2^-e + (p2 )) * 2^e - // = p1 + p2 * 2^e - - const diyfp one(std::uint64_t{1} << -M_plus.e, M_plus.e); - - auto p1 = static_cast(M_plus.f >> -one.e); // p1 = f div 2^-e (Since -e >= 32, p1 fits into a 32-bit int.) - std::uint64_t p2 = M_plus.f & (one.f - 1); // p2 = f mod 2^-e - - // 1) - // - // Generate the digits of the integral part p1 = d[n-1]...d[1]d[0] - - JSON_ASSERT(p1 > 0); - - std::uint32_t pow10{}; - const int k = find_largest_pow10(p1, pow10); - - // 10^(k-1) <= p1 < 10^k, pow10 = 10^(k-1) - // - // p1 = (p1 div 10^(k-1)) * 10^(k-1) + (p1 mod 10^(k-1)) - // = (d[k-1] ) * 10^(k-1) + (p1 mod 10^(k-1)) - // - // M+ = p1 + p2 * 2^e - // = d[k-1] * 10^(k-1) + (p1 mod 10^(k-1)) + p2 * 2^e - // = d[k-1] * 10^(k-1) + ((p1 mod 10^(k-1)) * 2^-e + p2) * 2^e - // = d[k-1] * 10^(k-1) + ( rest) * 2^e - // - // Now generate the digits d[n] of p1 from left to right (n = k-1,...,0) - // - // p1 = d[k-1]...d[n] * 10^n + d[n-1]...d[0] - // - // but stop as soon as - // - // rest * 2^e = (d[n-1]...d[0] * 2^-e + p2) * 2^e <= delta * 2^e - - int n = k; - while (n > 0) - { - // Invariants: - // M+ = buffer * 10^n + (p1 + p2 * 2^e) (buffer = 0 for n = k) - // pow10 = 10^(n-1) <= p1 < 10^n - // - const std::uint32_t d = p1 / pow10; // d = p1 div 10^(n-1) - const std::uint32_t r = p1 % pow10; // r = p1 mod 10^(n-1) - // - // M+ = buffer * 10^n + (d * 10^(n-1) + r) + p2 * 2^e - // = (buffer * 10 + d) * 10^(n-1) + (r + p2 * 2^e) - // - JSON_ASSERT(d <= 9); - buffer[length++] = static_cast('0' + d); // buffer := buffer * 10 + d - // - // M+ = buffer * 10^(n-1) + (r + p2 * 2^e) - // - p1 = r; - n--; - // - // M+ = buffer * 10^n + (p1 + p2 * 2^e) - // pow10 = 10^n - // - - // Now check if enough digits have been generated. - // Compute - // - // p1 + p2 * 2^e = (p1 * 2^-e + p2) * 2^e = rest * 2^e - // - // Note: - // Since rest and delta share the same exponent e, it suffices to - // compare the significands. - const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2; - if (rest <= delta) - { - // V = buffer * 10^n, with M- <= V <= M+. - - decimal_exponent += n; - - // We may now just stop. But instead look if the buffer could be - // decremented to bring V closer to w. - // - // pow10 = 10^n is now 1 ulp in the decimal representation V. - // The rounding procedure works with diyfp's with an implicit - // exponent of e. - // - // 10^n = (10^n * 2^-e) * 2^e = ulp * 2^e - // - const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e; - grisu2_round(buffer, length, dist, delta, rest, ten_n); - - return; - } - - pow10 /= 10; - // - // pow10 = 10^(n-1) <= p1 < 10^n - // Invariants restored. - } - - // 2) - // - // The digits of the integral part have been generated: - // - // M+ = d[k-1]...d[1]d[0] + p2 * 2^e - // = buffer + p2 * 2^e - // - // Now generate the digits of the fractional part p2 * 2^e. - // - // Note: - // No decimal point is generated: the exponent is adjusted instead. - // - // p2 actually represents the fraction - // - // p2 * 2^e - // = p2 / 2^-e - // = d[-1] / 10^1 + d[-2] / 10^2 + ... - // - // Now generate the digits d[-m] of p1 from left to right (m = 1,2,...) - // - // p2 * 2^e = d[-1]d[-2]...d[-m] * 10^-m - // + 10^-m * (d[-m-1] / 10^1 + d[-m-2] / 10^2 + ...) - // - // using - // - // 10^m * p2 = ((10^m * p2) div 2^-e) * 2^-e + ((10^m * p2) mod 2^-e) - // = ( d) * 2^-e + ( r) - // - // or - // 10^m * p2 * 2^e = d + r * 2^e - // - // i.e. - // - // M+ = buffer + p2 * 2^e - // = buffer + 10^-m * (d + r * 2^e) - // = (buffer * 10^m + d) * 10^-m + 10^-m * r * 2^e - // - // and stop as soon as 10^-m * r * 2^e <= delta * 2^e - - JSON_ASSERT(p2 > delta); - - int m = 0; - for (;;) - { - // Invariant: - // M+ = buffer * 10^-m + 10^-m * (d[-m-1] / 10 + d[-m-2] / 10^2 + ...) * 2^e - // = buffer * 10^-m + 10^-m * (p2 ) * 2^e - // = buffer * 10^-m + 10^-m * (1/10 * (10 * p2) ) * 2^e - // = buffer * 10^-m + 10^-m * (1/10 * ((10*p2 div 2^-e) * 2^-e + (10*p2 mod 2^-e)) * 2^e - // - JSON_ASSERT(p2 <= (std::numeric_limits::max)() / 10); - p2 *= 10; - const std::uint64_t d = p2 >> -one.e; // d = (10 * p2) div 2^-e - const std::uint64_t r = p2 & (one.f - 1); // r = (10 * p2) mod 2^-e - // - // M+ = buffer * 10^-m + 10^-m * (1/10 * (d * 2^-e + r) * 2^e - // = buffer * 10^-m + 10^-m * (1/10 * (d + r * 2^e)) - // = (buffer * 10 + d) * 10^(-m-1) + 10^(-m-1) * r * 2^e - // - JSON_ASSERT(d <= 9); - buffer[length++] = static_cast('0' + d); // buffer := buffer * 10 + d - // - // M+ = buffer * 10^(-m-1) + 10^(-m-1) * r * 2^e - // - p2 = r; - m++; - // - // M+ = buffer * 10^-m + 10^-m * p2 * 2^e - // Invariant restored. - - // Check if enough digits have been generated. - // - // 10^-m * p2 * 2^e <= delta * 2^e - // p2 * 2^e <= 10^m * delta * 2^e - // p2 <= 10^m * delta - delta *= 10; - dist *= 10; - if (p2 <= delta) - { - break; - } - } - - // V = buffer * 10^-m, with M- <= V <= M+. - - decimal_exponent -= m; - - // 1 ulp in the decimal representation is now 10^-m. - // Since delta and dist are now scaled by 10^m, we need to do the - // same with ulp in order to keep the units in sync. - // - // 10^m * 10^-m = 1 = 2^-e * 2^e = ten_m * 2^e - // - const std::uint64_t ten_m = one.f; - grisu2_round(buffer, length, dist, delta, p2, ten_m); - - // By construction this algorithm generates the shortest possible decimal - // number (Loitsch, Theorem 6.2) which rounds back to w. - // For an input number of precision p, at least - // - // N = 1 + ceil(p * log_10(2)) - // - // decimal digits are sufficient to identify all binary floating-point - // numbers (Matula, "In-and-Out conversions"). - // This implies that the algorithm does not produce more than N decimal - // digits. - // - // N = 17 for p = 53 (IEEE double precision) - // N = 9 for p = 24 (IEEE single precision) -} - -/*! -v = buf * 10^decimal_exponent -len is the length of the buffer (number of decimal digits) -The buffer must be large enough, i.e. >= max_digits10. -*/ -JSON_HEDLEY_NON_NULL(1) -inline void grisu2(char* buf, int& len, int& decimal_exponent, - diyfp m_minus, diyfp v, diyfp m_plus) -{ - JSON_ASSERT(m_plus.e == m_minus.e); - JSON_ASSERT(m_plus.e == v.e); - - // --------(-----------------------+-----------------------)-------- (A) - // m- v m+ - // - // --------------------(-----------+-----------------------)-------- (B) - // m- v m+ - // - // First scale v (and m- and m+) such that the exponent is in the range - // [alpha, gamma]. - - const cached_power cached = get_cached_power_for_binary_exponent(m_plus.e); - - const diyfp c_minus_k(cached.f, cached.e); // = c ~= 10^-k - - // The exponent of the products is = v.e + c_minus_k.e + q and is in the range [alpha,gamma] - const diyfp w = diyfp::mul(v, c_minus_k); - const diyfp w_minus = diyfp::mul(m_minus, c_minus_k); - const diyfp w_plus = diyfp::mul(m_plus, c_minus_k); - - // ----(---+---)---------------(---+---)---------------(---+---)---- - // w- w w+ - // = c*m- = c*v = c*m+ - // - // diyfp::mul rounds its result and c_minus_k is approximated too. w, w- and - // w+ are now off by a small amount. - // In fact: - // - // w - v * 10^k < 1 ulp - // - // To account for this inaccuracy, add resp. subtract 1 ulp. - // - // --------+---[---------------(---+---)---------------]---+-------- - // w- M- w M+ w+ - // - // Now any number in [M-, M+] (bounds included) will round to w when input, - // regardless of how the input rounding algorithm breaks ties. - // - // And digit_gen generates the shortest possible such number in [M-, M+]. - // Note that this does not mean that Grisu2 always generates the shortest - // possible number in the interval (m-, m+). - const diyfp M_minus(w_minus.f + 1, w_minus.e); - const diyfp M_plus (w_plus.f - 1, w_plus.e ); - - decimal_exponent = -cached.k; // = -(-k) = k - - grisu2_digit_gen(buf, len, decimal_exponent, M_minus, w, M_plus); -} - -/*! -v = buf * 10^decimal_exponent -len is the length of the buffer (number of decimal digits) -The buffer must be large enough, i.e. >= max_digits10. -*/ -template -JSON_HEDLEY_NON_NULL(1) -void grisu2(char* buf, int& len, int& decimal_exponent, FloatType value) -{ - static_assert(diyfp::kPrecision >= std::numeric_limits::digits + 3, - "internal error: not enough precision"); - - JSON_ASSERT(std::isfinite(value)); - JSON_ASSERT(value > 0); - - // If the neighbors (and boundaries) of 'value' are always computed for double-precision - // numbers, all float's can be recovered using strtod (and strtof). However, the resulting - // decimal representations are not exactly "short". - // - // The documentation for 'std::to_chars' (https://en.cppreference.com/w/cpp/utility/to_chars) - // says "value is converted to a string as if by std::sprintf in the default ("C") locale" - // and since sprintf promotes float's to double's, I think this is exactly what 'std::to_chars' - // does. - // On the other hand, the documentation for 'std::to_chars' requires that "parsing the - // representation using the corresponding std::from_chars function recovers value exactly". That - // indicates that single precision floating-point numbers should be recovered using - // 'std::strtof'. - // - // NB: If the neighbors are computed for single-precision numbers, there is a single float - // (7.0385307e-26f) which can't be recovered using strtod. The resulting double precision - // value is off by 1 ulp. -#if 0 - const boundaries w = compute_boundaries(static_cast(value)); -#else - const boundaries w = compute_boundaries(value); -#endif - - grisu2(buf, len, decimal_exponent, w.minus, w.w, w.plus); -} - -/*! -@brief appends a decimal representation of e to buf -@return a pointer to the element following the exponent. -@pre -1000 < e < 1000 -*/ -JSON_HEDLEY_NON_NULL(1) -JSON_HEDLEY_RETURNS_NON_NULL -inline char* append_exponent(char* buf, int e) -{ - JSON_ASSERT(e > -1000); - JSON_ASSERT(e < 1000); - - if (e < 0) - { - e = -e; - *buf++ = '-'; - } - else - { - *buf++ = '+'; - } - - auto k = static_cast(e); - if (k < 10) - { - // Always print at least two digits in the exponent. - // This is for compatibility with printf("%g"). - *buf++ = '0'; - *buf++ = static_cast('0' + k); - } - else if (k < 100) - { - *buf++ = static_cast('0' + k / 10); - k %= 10; - *buf++ = static_cast('0' + k); - } - else - { - *buf++ = static_cast('0' + k / 100); - k %= 100; - *buf++ = static_cast('0' + k / 10); - k %= 10; - *buf++ = static_cast('0' + k); - } - - return buf; -} - -/*! -@brief prettify v = buf * 10^decimal_exponent - -If v is in the range [10^min_exp, 10^max_exp) it will be printed in fixed-point -notation. Otherwise it will be printed in exponential notation. - -@pre min_exp < 0 -@pre max_exp > 0 -*/ -JSON_HEDLEY_NON_NULL(1) -JSON_HEDLEY_RETURNS_NON_NULL -inline char* format_buffer(char* buf, int len, int decimal_exponent, - int min_exp, int max_exp) -{ - JSON_ASSERT(min_exp < 0); - JSON_ASSERT(max_exp > 0); - - const int k = len; - const int n = len + decimal_exponent; - - // v = buf * 10^(n-k) - // k is the length of the buffer (number of decimal digits) - // n is the position of the decimal point relative to the start of the buffer. - - if (k <= n && n <= max_exp) - { - // digits[000] - // len <= max_exp + 2 - - std::memset(buf + k, '0', static_cast(n) - static_cast(k)); - // Make it look like a floating-point number (#362, #378) - buf[n + 0] = '.'; - buf[n + 1] = '0'; - return buf + (static_cast(n) + 2); - } - - if (0 < n && n <= max_exp) - { - // dig.its - // len <= max_digits10 + 1 - - JSON_ASSERT(k > n); - - std::memmove(buf + (static_cast(n) + 1), buf + n, static_cast(k) - static_cast(n)); - buf[n] = '.'; - return buf + (static_cast(k) + 1U); - } - - if (min_exp < n && n <= 0) - { - // 0.[000]digits - // len <= 2 + (-min_exp - 1) + max_digits10 - - std::memmove(buf + (2 + static_cast(-n)), buf, static_cast(k)); - buf[0] = '0'; - buf[1] = '.'; - std::memset(buf + 2, '0', static_cast(-n)); - return buf + (2U + static_cast(-n) + static_cast(k)); - } - - if (k == 1) - { - // dE+123 - // len <= 1 + 5 - - buf += 1; - } - else - { - // d.igitsE+123 - // len <= max_digits10 + 1 + 5 - - std::memmove(buf + 2, buf + 1, static_cast(k) - 1); - buf[1] = '.'; - buf += 1 + static_cast(k); - } - - *buf++ = 'e'; - return append_exponent(buf, n - 1); -} - -} // namespace dtoa_impl - -/*! -@brief generates a decimal representation of the floating-point number value in [first, last). - -The format of the resulting decimal representation is similar to printf's %g -format. Returns an iterator pointing past-the-end of the decimal representation. - -@note The input number must be finite, i.e. NaN's and Inf's are not supported. -@note The buffer must be large enough. -@note The result is NOT null-terminated. -*/ -template -JSON_HEDLEY_NON_NULL(1, 2) -JSON_HEDLEY_RETURNS_NON_NULL -char* to_chars(char* first, const char* last, FloatType value) -{ - static_cast(last); // maybe unused - fix warning - JSON_ASSERT(std::isfinite(value)); - - // Use signbit(value) instead of (value < 0) since signbit works for -0. - if (std::signbit(value)) - { - value = -value; - *first++ = '-'; - } - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wfloat-equal" -#endif - if (value == 0) // +-0 - { - *first++ = '0'; - // Make it look like a floating-point number (#362, #378) - *first++ = '.'; - *first++ = '0'; - return first; - } -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif - - JSON_ASSERT(last - first >= std::numeric_limits::max_digits10); - - // Compute v = buffer * 10^decimal_exponent. - // The decimal digits are stored in the buffer, which needs to be interpreted - // as an unsigned decimal integer. - // len is the length of the buffer, i.e. the number of decimal digits. - int len = 0; - int decimal_exponent = 0; - dtoa_impl::grisu2(first, len, decimal_exponent, value); - - JSON_ASSERT(len <= std::numeric_limits::max_digits10); - - // Format the buffer like printf("%.*g", prec, value) - constexpr int kMinExp = -4; - // Use digits10 here to increase compatibility with version 2. - constexpr int kMaxExp = std::numeric_limits::digits10; - - JSON_ASSERT(last - first >= kMaxExp + 2); - JSON_ASSERT(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits::max_digits10); - JSON_ASSERT(last - first >= std::numeric_limits::max_digits10 + 6); - - return dtoa_impl::format_buffer(first, len, decimal_exponent, kMinExp, kMaxExp); -} - -} // namespace detail -} // namespace nlohmann - -// #include - -// #include - -// #include - -// #include - -// #include - -// #include - - -namespace nlohmann -{ -namespace detail -{ -/////////////////// -// serialization // -/////////////////// - -/// how to treat decoding errors -enum class error_handler_t -{ - strict, ///< throw a type_error exception in case of invalid UTF-8 - replace, ///< replace invalid UTF-8 sequences with U+FFFD - ignore ///< ignore invalid UTF-8 sequences -}; - -template -class serializer -{ - using string_t = typename BasicJsonType::string_t; - using number_float_t = typename BasicJsonType::number_float_t; - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using binary_char_t = typename BasicJsonType::binary_t::value_type; - static constexpr std::uint8_t UTF8_ACCEPT = 0; - static constexpr std::uint8_t UTF8_REJECT = 1; - - public: - /*! - @param[in] s output stream to serialize to - @param[in] ichar indentation character to use - @param[in] error_handler_ how to react on decoding errors - */ - serializer(output_adapter_t s, const char ichar, - error_handler_t error_handler_ = error_handler_t::strict) - : o(std::move(s)) - , loc(std::localeconv()) - , thousands_sep(loc->thousands_sep == nullptr ? '\0' : std::char_traits::to_char_type(* (loc->thousands_sep))) - , decimal_point(loc->decimal_point == nullptr ? '\0' : std::char_traits::to_char_type(* (loc->decimal_point))) - , indent_char(ichar) - , indent_string(512, indent_char) - , error_handler(error_handler_) - {} - - // delete because of pointer members - serializer(const serializer&) = delete; - serializer& operator=(const serializer&) = delete; - serializer(serializer&&) = delete; - serializer& operator=(serializer&&) = delete; - ~serializer() = default; - - /*! - @brief internal implementation of the serialization function - - This function is called by the public member function dump and organizes - the serialization internally. The indentation level is propagated as - additional parameter. In case of arrays and objects, the function is - called recursively. - - - strings and object keys are escaped using `escape_string()` - - integer numbers are converted implicitly via `operator<<` - - floating-point numbers are converted to a string using `"%g"` format - - binary values are serialized as objects containing the subtype and the - byte array - - @param[in] val value to serialize - @param[in] pretty_print whether the output shall be pretty-printed - @param[in] ensure_ascii If @a ensure_ascii is true, all non-ASCII characters - in the output are escaped with `\uXXXX` sequences, and the result consists - of ASCII characters only. - @param[in] indent_step the indent level - @param[in] current_indent the current indent level (only used internally) - */ - void dump(const BasicJsonType& val, - const bool pretty_print, - const bool ensure_ascii, - const unsigned int indent_step, - const unsigned int current_indent = 0) - { - switch (val.m_type) - { - case value_t::object: - { - if (val.m_value.object->empty()) - { - o->write_characters("{}", 2); - return; - } - - if (pretty_print) - { - o->write_characters("{\n", 2); - - // variable to hold indentation for recursive calls - const auto new_indent = current_indent + indent_step; - if (JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent)) - { - indent_string.resize(indent_string.size() * 2, ' '); - } - - // first n-1 elements - auto i = val.m_value.object->cbegin(); - for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i) - { - o->write_characters(indent_string.c_str(), new_indent); - o->write_character('\"'); - dump_escaped(i->first, ensure_ascii); - o->write_characters("\": ", 3); - dump(i->second, true, ensure_ascii, indent_step, new_indent); - o->write_characters(",\n", 2); - } - - // last element - JSON_ASSERT(i != val.m_value.object->cend()); - JSON_ASSERT(std::next(i) == val.m_value.object->cend()); - o->write_characters(indent_string.c_str(), new_indent); - o->write_character('\"'); - dump_escaped(i->first, ensure_ascii); - o->write_characters("\": ", 3); - dump(i->second, true, ensure_ascii, indent_step, new_indent); - - o->write_character('\n'); - o->write_characters(indent_string.c_str(), current_indent); - o->write_character('}'); - } - else - { - o->write_character('{'); - - // first n-1 elements - auto i = val.m_value.object->cbegin(); - for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i) - { - o->write_character('\"'); - dump_escaped(i->first, ensure_ascii); - o->write_characters("\":", 2); - dump(i->second, false, ensure_ascii, indent_step, current_indent); - o->write_character(','); - } - - // last element - JSON_ASSERT(i != val.m_value.object->cend()); - JSON_ASSERT(std::next(i) == val.m_value.object->cend()); - o->write_character('\"'); - dump_escaped(i->first, ensure_ascii); - o->write_characters("\":", 2); - dump(i->second, false, ensure_ascii, indent_step, current_indent); - - o->write_character('}'); - } - - return; - } - - case value_t::array: - { - if (val.m_value.array->empty()) - { - o->write_characters("[]", 2); - return; - } - - if (pretty_print) - { - o->write_characters("[\n", 2); - - // variable to hold indentation for recursive calls - const auto new_indent = current_indent + indent_step; - if (JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent)) - { - indent_string.resize(indent_string.size() * 2, ' '); - } - - // first n-1 elements - for (auto i = val.m_value.array->cbegin(); - i != val.m_value.array->cend() - 1; ++i) - { - o->write_characters(indent_string.c_str(), new_indent); - dump(*i, true, ensure_ascii, indent_step, new_indent); - o->write_characters(",\n", 2); - } - - // last element - JSON_ASSERT(!val.m_value.array->empty()); - o->write_characters(indent_string.c_str(), new_indent); - dump(val.m_value.array->back(), true, ensure_ascii, indent_step, new_indent); - - o->write_character('\n'); - o->write_characters(indent_string.c_str(), current_indent); - o->write_character(']'); - } - else - { - o->write_character('['); - - // first n-1 elements - for (auto i = val.m_value.array->cbegin(); - i != val.m_value.array->cend() - 1; ++i) - { - dump(*i, false, ensure_ascii, indent_step, current_indent); - o->write_character(','); - } - - // last element - JSON_ASSERT(!val.m_value.array->empty()); - dump(val.m_value.array->back(), false, ensure_ascii, indent_step, current_indent); - - o->write_character(']'); - } - - return; - } - - case value_t::string: - { - o->write_character('\"'); - dump_escaped(*val.m_value.string, ensure_ascii); - o->write_character('\"'); - return; - } - - case value_t::binary: - { - if (pretty_print) - { - o->write_characters("{\n", 2); - - // variable to hold indentation for recursive calls - const auto new_indent = current_indent + indent_step; - if (JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent)) - { - indent_string.resize(indent_string.size() * 2, ' '); - } - - o->write_characters(indent_string.c_str(), new_indent); - - o->write_characters("\"bytes\": [", 10); - - if (!val.m_value.binary->empty()) - { - for (auto i = val.m_value.binary->cbegin(); - i != val.m_value.binary->cend() - 1; ++i) - { - dump_integer(*i); - o->write_characters(", ", 2); - } - dump_integer(val.m_value.binary->back()); - } - - o->write_characters("],\n", 3); - o->write_characters(indent_string.c_str(), new_indent); - - o->write_characters("\"subtype\": ", 11); - if (val.m_value.binary->has_subtype()) - { - dump_integer(val.m_value.binary->subtype()); - } - else - { - o->write_characters("null", 4); - } - o->write_character('\n'); - o->write_characters(indent_string.c_str(), current_indent); - o->write_character('}'); - } - else - { - o->write_characters("{\"bytes\":[", 10); - - if (!val.m_value.binary->empty()) - { - for (auto i = val.m_value.binary->cbegin(); - i != val.m_value.binary->cend() - 1; ++i) - { - dump_integer(*i); - o->write_character(','); - } - dump_integer(val.m_value.binary->back()); - } - - o->write_characters("],\"subtype\":", 12); - if (val.m_value.binary->has_subtype()) - { - dump_integer(val.m_value.binary->subtype()); - o->write_character('}'); - } - else - { - o->write_characters("null}", 5); - } - } - return; - } - - case value_t::boolean: - { - if (val.m_value.boolean) - { - o->write_characters("true", 4); - } - else - { - o->write_characters("false", 5); - } - return; - } - - case value_t::number_integer: - { - dump_integer(val.m_value.number_integer); - return; - } - - case value_t::number_unsigned: - { - dump_integer(val.m_value.number_unsigned); - return; - } - - case value_t::number_float: - { - dump_float(val.m_value.number_float); - return; - } - - case value_t::discarded: - { - o->write_characters("", 11); - return; - } - - case value_t::null: - { - o->write_characters("null", 4); - return; - } - - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE - } - } - - JSON_PRIVATE_UNLESS_TESTED: - /*! - @brief dump escaped string - - Escape a string by replacing certain special characters by a sequence of an - escape character (backslash) and another character and other control - characters by a sequence of "\u" followed by a four-digit hex - representation. The escaped string is written to output stream @a o. - - @param[in] s the string to escape - @param[in] ensure_ascii whether to escape non-ASCII characters with - \uXXXX sequences - - @complexity Linear in the length of string @a s. - */ - void dump_escaped(const string_t& s, const bool ensure_ascii) - { - std::uint32_t codepoint{}; - std::uint8_t state = UTF8_ACCEPT; - std::size_t bytes = 0; // number of bytes written to string_buffer - - // number of bytes written at the point of the last valid byte - std::size_t bytes_after_last_accept = 0; - std::size_t undumped_chars = 0; - - for (std::size_t i = 0; i < s.size(); ++i) - { - const auto byte = static_cast(s[i]); - - switch (decode(state, codepoint, byte)) - { - case UTF8_ACCEPT: // decode found a new code point - { - switch (codepoint) - { - case 0x08: // backspace - { - string_buffer[bytes++] = '\\'; - string_buffer[bytes++] = 'b'; - break; - } - - case 0x09: // horizontal tab - { - string_buffer[bytes++] = '\\'; - string_buffer[bytes++] = 't'; - break; - } - - case 0x0A: // newline - { - string_buffer[bytes++] = '\\'; - string_buffer[bytes++] = 'n'; - break; - } - - case 0x0C: // formfeed - { - string_buffer[bytes++] = '\\'; - string_buffer[bytes++] = 'f'; - break; - } - - case 0x0D: // carriage return - { - string_buffer[bytes++] = '\\'; - string_buffer[bytes++] = 'r'; - break; - } - - case 0x22: // quotation mark - { - string_buffer[bytes++] = '\\'; - string_buffer[bytes++] = '\"'; - break; - } - - case 0x5C: // reverse solidus - { - string_buffer[bytes++] = '\\'; - string_buffer[bytes++] = '\\'; - break; - } - - default: - { - // escape control characters (0x00..0x1F) or, if - // ensure_ascii parameter is used, non-ASCII characters - if ((codepoint <= 0x1F) || (ensure_ascii && (codepoint >= 0x7F))) - { - if (codepoint <= 0xFFFF) - { - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg) - (std::snprintf)(string_buffer.data() + bytes, 7, "\\u%04x", - static_cast(codepoint)); - bytes += 6; - } - else - { - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg) - (std::snprintf)(string_buffer.data() + bytes, 13, "\\u%04x\\u%04x", - static_cast(0xD7C0u + (codepoint >> 10u)), - static_cast(0xDC00u + (codepoint & 0x3FFu))); - bytes += 12; - } - } - else - { - // copy byte to buffer (all previous bytes - // been copied have in default case above) - string_buffer[bytes++] = s[i]; - } - break; - } - } - - // write buffer and reset index; there must be 13 bytes - // left, as this is the maximal number of bytes to be - // written ("\uxxxx\uxxxx\0") for one code point - if (string_buffer.size() - bytes < 13) - { - o->write_characters(string_buffer.data(), bytes); - bytes = 0; - } - - // remember the byte position of this accept - bytes_after_last_accept = bytes; - undumped_chars = 0; - break; - } - - case UTF8_REJECT: // decode found invalid UTF-8 byte - { - switch (error_handler) - { - case error_handler_t::strict: - { - std::stringstream ss; - ss << std::uppercase << std::setfill('0') << std::setw(2) << std::hex << (byte | 0); - JSON_THROW(type_error::create(316, "invalid UTF-8 byte at index " + std::to_string(i) + ": 0x" + ss.str(), BasicJsonType())); - } - - case error_handler_t::ignore: - case error_handler_t::replace: - { - // in case we saw this character the first time, we - // would like to read it again, because the byte - // may be OK for itself, but just not OK for the - // previous sequence - if (undumped_chars > 0) - { - --i; - } - - // reset length buffer to the last accepted index; - // thus removing/ignoring the invalid characters - bytes = bytes_after_last_accept; - - if (error_handler == error_handler_t::replace) - { - // add a replacement character - if (ensure_ascii) - { - string_buffer[bytes++] = '\\'; - string_buffer[bytes++] = 'u'; - string_buffer[bytes++] = 'f'; - string_buffer[bytes++] = 'f'; - string_buffer[bytes++] = 'f'; - string_buffer[bytes++] = 'd'; - } - else - { - string_buffer[bytes++] = detail::binary_writer::to_char_type('\xEF'); - string_buffer[bytes++] = detail::binary_writer::to_char_type('\xBF'); - string_buffer[bytes++] = detail::binary_writer::to_char_type('\xBD'); - } - - // write buffer and reset index; there must be 13 bytes - // left, as this is the maximal number of bytes to be - // written ("\uxxxx\uxxxx\0") for one code point - if (string_buffer.size() - bytes < 13) - { - o->write_characters(string_buffer.data(), bytes); - bytes = 0; - } - - bytes_after_last_accept = bytes; - } - - undumped_chars = 0; - - // continue processing the string - state = UTF8_ACCEPT; - break; - } - - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE - } - break; - } - - default: // decode found yet incomplete multi-byte code point - { - if (!ensure_ascii) - { - // code point will not be escaped - copy byte to buffer - string_buffer[bytes++] = s[i]; - } - ++undumped_chars; - break; - } - } - } - - // we finished processing the string - if (JSON_HEDLEY_LIKELY(state == UTF8_ACCEPT)) - { - // write buffer - if (bytes > 0) - { - o->write_characters(string_buffer.data(), bytes); - } - } - else - { - // we finish reading, but do not accept: string was incomplete - switch (error_handler) - { - case error_handler_t::strict: - { - std::stringstream ss; - ss << std::uppercase << std::setfill('0') << std::setw(2) << std::hex << (static_cast(s.back()) | 0); - JSON_THROW(type_error::create(316, "incomplete UTF-8 string; last byte: 0x" + ss.str(), BasicJsonType())); - } - - case error_handler_t::ignore: - { - // write all accepted bytes - o->write_characters(string_buffer.data(), bytes_after_last_accept); - break; - } - - case error_handler_t::replace: - { - // write all accepted bytes - o->write_characters(string_buffer.data(), bytes_after_last_accept); - // add a replacement character - if (ensure_ascii) - { - o->write_characters("\\ufffd", 6); - } - else - { - o->write_characters("\xEF\xBF\xBD", 3); - } - break; - } - - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE - } - } - } - - private: - /*! - @brief count digits - - Count the number of decimal (base 10) digits for an input unsigned integer. - - @param[in] x unsigned integer number to count its digits - @return number of decimal digits - */ - inline unsigned int count_digits(number_unsigned_t x) noexcept - { - unsigned int n_digits = 1; - for (;;) - { - if (x < 10) - { - return n_digits; - } - if (x < 100) - { - return n_digits + 1; - } - if (x < 1000) - { - return n_digits + 2; - } - if (x < 10000) - { - return n_digits + 3; - } - x = x / 10000u; - n_digits += 4; - } - } - - /*! - @brief dump an integer - - Dump a given integer to output stream @a o. Works internally with - @a number_buffer. - - @param[in] x integer number (signed or unsigned) to dump - @tparam NumberType either @a number_integer_t or @a number_unsigned_t - */ - template < typename NumberType, detail::enable_if_t < - std::is_integral::value || - std::is_same::value || - std::is_same::value || - std::is_same::value, - int > = 0 > - void dump_integer(NumberType x) - { - static constexpr std::array, 100> digits_to_99 - { - { - {{'0', '0'}}, {{'0', '1'}}, {{'0', '2'}}, {{'0', '3'}}, {{'0', '4'}}, {{'0', '5'}}, {{'0', '6'}}, {{'0', '7'}}, {{'0', '8'}}, {{'0', '9'}}, - {{'1', '0'}}, {{'1', '1'}}, {{'1', '2'}}, {{'1', '3'}}, {{'1', '4'}}, {{'1', '5'}}, {{'1', '6'}}, {{'1', '7'}}, {{'1', '8'}}, {{'1', '9'}}, - {{'2', '0'}}, {{'2', '1'}}, {{'2', '2'}}, {{'2', '3'}}, {{'2', '4'}}, {{'2', '5'}}, {{'2', '6'}}, {{'2', '7'}}, {{'2', '8'}}, {{'2', '9'}}, - {{'3', '0'}}, {{'3', '1'}}, {{'3', '2'}}, {{'3', '3'}}, {{'3', '4'}}, {{'3', '5'}}, {{'3', '6'}}, {{'3', '7'}}, {{'3', '8'}}, {{'3', '9'}}, - {{'4', '0'}}, {{'4', '1'}}, {{'4', '2'}}, {{'4', '3'}}, {{'4', '4'}}, {{'4', '5'}}, {{'4', '6'}}, {{'4', '7'}}, {{'4', '8'}}, {{'4', '9'}}, - {{'5', '0'}}, {{'5', '1'}}, {{'5', '2'}}, {{'5', '3'}}, {{'5', '4'}}, {{'5', '5'}}, {{'5', '6'}}, {{'5', '7'}}, {{'5', '8'}}, {{'5', '9'}}, - {{'6', '0'}}, {{'6', '1'}}, {{'6', '2'}}, {{'6', '3'}}, {{'6', '4'}}, {{'6', '5'}}, {{'6', '6'}}, {{'6', '7'}}, {{'6', '8'}}, {{'6', '9'}}, - {{'7', '0'}}, {{'7', '1'}}, {{'7', '2'}}, {{'7', '3'}}, {{'7', '4'}}, {{'7', '5'}}, {{'7', '6'}}, {{'7', '7'}}, {{'7', '8'}}, {{'7', '9'}}, - {{'8', '0'}}, {{'8', '1'}}, {{'8', '2'}}, {{'8', '3'}}, {{'8', '4'}}, {{'8', '5'}}, {{'8', '6'}}, {{'8', '7'}}, {{'8', '8'}}, {{'8', '9'}}, - {{'9', '0'}}, {{'9', '1'}}, {{'9', '2'}}, {{'9', '3'}}, {{'9', '4'}}, {{'9', '5'}}, {{'9', '6'}}, {{'9', '7'}}, {{'9', '8'}}, {{'9', '9'}}, - } - }; - - // special case for "0" - if (x == 0) - { - o->write_character('0'); - return; - } - - // use a pointer to fill the buffer - auto buffer_ptr = number_buffer.begin(); // NOLINT(llvm-qualified-auto,readability-qualified-auto,cppcoreguidelines-pro-type-vararg,hicpp-vararg) - - const bool is_negative = std::is_signed::value && !(x >= 0); // see issue #755 - number_unsigned_t abs_value; - - unsigned int n_chars{}; - - if (is_negative) - { - *buffer_ptr = '-'; - abs_value = remove_sign(static_cast(x)); - - // account one more byte for the minus sign - n_chars = 1 + count_digits(abs_value); - } - else - { - abs_value = static_cast(x); - n_chars = count_digits(abs_value); - } - - // spare 1 byte for '\0' - JSON_ASSERT(n_chars < number_buffer.size() - 1); - - // jump to the end to generate the string from backward - // so we later avoid reversing the result - buffer_ptr += n_chars; - - // Fast int2ascii implementation inspired by "Fastware" talk by Andrei Alexandrescu - // See: https://www.youtube.com/watch?v=o4-CwDo2zpg - while (abs_value >= 100) - { - const auto digits_index = static_cast((abs_value % 100)); - abs_value /= 100; - *(--buffer_ptr) = digits_to_99[digits_index][1]; - *(--buffer_ptr) = digits_to_99[digits_index][0]; - } - - if (abs_value >= 10) - { - const auto digits_index = static_cast(abs_value); - *(--buffer_ptr) = digits_to_99[digits_index][1]; - *(--buffer_ptr) = digits_to_99[digits_index][0]; - } - else - { - *(--buffer_ptr) = static_cast('0' + abs_value); - } - - o->write_characters(number_buffer.data(), n_chars); - } - - /*! - @brief dump a floating-point number - - Dump a given floating-point number to output stream @a o. Works internally - with @a number_buffer. - - @param[in] x floating-point number to dump - */ - void dump_float(number_float_t x) - { - // NaN / inf - if (!std::isfinite(x)) - { - o->write_characters("null", 4); - return; - } - - // If number_float_t is an IEEE-754 single or double precision number, - // use the Grisu2 algorithm to produce short numbers which are - // guaranteed to round-trip, using strtof and strtod, resp. - // - // NB: The test below works if == . - static constexpr bool is_ieee_single_or_double - = (std::numeric_limits::is_iec559 && std::numeric_limits::digits == 24 && std::numeric_limits::max_exponent == 128) || - (std::numeric_limits::is_iec559 && std::numeric_limits::digits == 53 && std::numeric_limits::max_exponent == 1024); - - dump_float(x, std::integral_constant()); - } - - void dump_float(number_float_t x, std::true_type /*is_ieee_single_or_double*/) - { - auto* begin = number_buffer.data(); - auto* end = ::nlohmann::detail::to_chars(begin, begin + number_buffer.size(), x); - - o->write_characters(begin, static_cast(end - begin)); - } - - void dump_float(number_float_t x, std::false_type /*is_ieee_single_or_double*/) - { - // get number of digits for a float -> text -> float round-trip - static constexpr auto d = std::numeric_limits::max_digits10; - - // the actual conversion - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg) - std::ptrdiff_t len = (std::snprintf)(number_buffer.data(), number_buffer.size(), "%.*g", d, x); - - // negative value indicates an error - JSON_ASSERT(len > 0); - // check if buffer was large enough - JSON_ASSERT(static_cast(len) < number_buffer.size()); - - // erase thousands separator - if (thousands_sep != '\0') - { - // NOLINTNEXTLINE(readability-qualified-auto,llvm-qualified-auto): std::remove returns an iterator, see https://github.com/nlohmann/json/issues/3081 - const auto end = std::remove(number_buffer.begin(), number_buffer.begin() + len, thousands_sep); - std::fill(end, number_buffer.end(), '\0'); - JSON_ASSERT((end - number_buffer.begin()) <= len); - len = (end - number_buffer.begin()); - } - - // convert decimal point to '.' - if (decimal_point != '\0' && decimal_point != '.') - { - // NOLINTNEXTLINE(readability-qualified-auto,llvm-qualified-auto): std::find returns an iterator, see https://github.com/nlohmann/json/issues/3081 - const auto dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point); - if (dec_pos != number_buffer.end()) - { - *dec_pos = '.'; - } - } - - o->write_characters(number_buffer.data(), static_cast(len)); - - // determine if need to append ".0" - const bool value_is_int_like = - std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1, - [](char c) - { - return c == '.' || c == 'e'; - }); - - if (value_is_int_like) - { - o->write_characters(".0", 2); - } - } - - /*! - @brief check whether a string is UTF-8 encoded - - The function checks each byte of a string whether it is UTF-8 encoded. The - result of the check is stored in the @a state parameter. The function must - be called initially with state 0 (accept). State 1 means the string must - be rejected, because the current byte is not allowed. If the string is - completely processed, but the state is non-zero, the string ended - prematurely; that is, the last byte indicated more bytes should have - followed. - - @param[in,out] state the state of the decoding - @param[in,out] codep codepoint (valid only if resulting state is UTF8_ACCEPT) - @param[in] byte next byte to decode - @return new state - - @note The function has been edited: a std::array is used. - - @copyright Copyright (c) 2008-2009 Bjoern Hoehrmann - @sa http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ - */ - static std::uint8_t decode(std::uint8_t& state, std::uint32_t& codep, const std::uint8_t byte) noexcept - { - static const std::array utf8d = - { - { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 00..1F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 20..3F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 40..5F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 60..7F - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, // 80..9F - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // A0..BF - 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // C0..DF - 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3, // E0..EF - 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, // F0..FF - 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1, // s0..s0 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, // s1..s2 - 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, // s3..s4 - 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, // s5..s6 - 1, 3, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // s7..s8 - } - }; - - JSON_ASSERT(byte < utf8d.size()); - const std::uint8_t type = utf8d[byte]; - - codep = (state != UTF8_ACCEPT) - ? (byte & 0x3fu) | (codep << 6u) - : (0xFFu >> type) & (byte); - - std::size_t index = 256u + static_cast(state) * 16u + static_cast(type); - JSON_ASSERT(index < 400); - state = utf8d[index]; - return state; - } - - /* - * Overload to make the compiler happy while it is instantiating - * dump_integer for number_unsigned_t. - * Must never be called. - */ - number_unsigned_t remove_sign(number_unsigned_t x) - { - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE - return x; // LCOV_EXCL_LINE - } - - /* - * Helper function for dump_integer - * - * This function takes a negative signed integer and returns its absolute - * value as unsigned integer. The plus/minus shuffling is necessary as we can - * not directly remove the sign of an arbitrary signed integer as the - * absolute values of INT_MIN and INT_MAX are usually not the same. See - * #1708 for details. - */ - inline number_unsigned_t remove_sign(number_integer_t x) noexcept - { - JSON_ASSERT(x < 0 && x < (std::numeric_limits::max)()); // NOLINT(misc-redundant-expression) - return static_cast(-(x + 1)) + 1; - } - - private: - /// the output of the serializer - output_adapter_t o = nullptr; - - /// a (hopefully) large enough character buffer - std::array number_buffer{{}}; - - /// the locale - const std::lconv* loc = nullptr; - /// the locale's thousand separator character - const char thousands_sep = '\0'; - /// the locale's decimal point character - const char decimal_point = '\0'; - - /// string buffer - std::array string_buffer{{}}; - - /// the indentation character - const char indent_char; - /// the indentation string - string_t indent_string; - - /// error_handler how to react on decoding errors - const error_handler_t error_handler; -}; -} // namespace detail -} // namespace nlohmann - -// #include - -// #include - -// #include - - -#include // less -#include // initializer_list -#include // input_iterator_tag, iterator_traits -#include // allocator -#include // for out_of_range -#include // enable_if, is_convertible -#include // pair -#include // vector - -// #include - - -namespace nlohmann -{ - -/// ordered_map: a minimal map-like container that preserves insertion order -/// for use within nlohmann::basic_json -template , - class Allocator = std::allocator>> - struct ordered_map : std::vector, Allocator> -{ - using key_type = Key; - using mapped_type = T; - using Container = std::vector, Allocator>; - using typename Container::iterator; - using typename Container::const_iterator; - using typename Container::size_type; - using typename Container::value_type; - - // Explicit constructors instead of `using Container::Container` - // otherwise older compilers choke on it (GCC <= 5.5, xcode <= 9.4) - ordered_map(const Allocator& alloc = Allocator()) : Container{alloc} {} - template - ordered_map(It first, It last, const Allocator& alloc = Allocator()) - : Container{first, last, alloc} {} - ordered_map(std::initializer_list init, const Allocator& alloc = Allocator() ) - : Container{init, alloc} {} - - std::pair emplace(const key_type& key, T&& t) - { - for (auto it = this->begin(); it != this->end(); ++it) - { - if (it->first == key) - { - return {it, false}; - } - } - Container::emplace_back(key, t); - return {--this->end(), true}; - } - - T& operator[](const Key& key) - { - return emplace(key, T{}).first->second; - } - - const T& operator[](const Key& key) const - { - return at(key); - } - - T& at(const Key& key) - { - for (auto it = this->begin(); it != this->end(); ++it) - { - if (it->first == key) - { - return it->second; - } - } - - JSON_THROW(std::out_of_range("key not found")); - } - - const T& at(const Key& key) const - { - for (auto it = this->begin(); it != this->end(); ++it) - { - if (it->first == key) - { - return it->second; - } - } - - JSON_THROW(std::out_of_range("key not found")); - } - - size_type erase(const Key& key) - { - for (auto it = this->begin(); it != this->end(); ++it) - { - if (it->first == key) - { - // Since we cannot move const Keys, re-construct them in place - for (auto next = it; ++next != this->end(); ++it) - { - it->~value_type(); // Destroy but keep allocation - new (&*it) value_type{std::move(*next)}; - } - Container::pop_back(); - return 1; - } - } - return 0; - } - - iterator erase(iterator pos) - { - auto it = pos; - - // Since we cannot move const Keys, re-construct them in place - for (auto next = it; ++next != this->end(); ++it) - { - it->~value_type(); // Destroy but keep allocation - new (&*it) value_type{std::move(*next)}; - } - Container::pop_back(); - return pos; - } - - size_type count(const Key& key) const - { - for (auto it = this->begin(); it != this->end(); ++it) - { - if (it->first == key) - { - return 1; - } - } - return 0; - } - - iterator find(const Key& key) - { - for (auto it = this->begin(); it != this->end(); ++it) - { - if (it->first == key) - { - return it; - } - } - return Container::end(); - } - - const_iterator find(const Key& key) const - { - for (auto it = this->begin(); it != this->end(); ++it) - { - if (it->first == key) - { - return it; - } - } - return Container::end(); - } - - std::pair insert( value_type&& value ) - { - return emplace(value.first, std::move(value.second)); - } - - std::pair insert( const value_type& value ) - { - for (auto it = this->begin(); it != this->end(); ++it) - { - if (it->first == value.first) - { - return {it, false}; - } - } - Container::push_back(value); - return {--this->end(), true}; - } - - template - using require_input_iter = typename std::enable_if::iterator_category, - std::input_iterator_tag>::value>::type; - - template> - void insert(InputIt first, InputIt last) - { - for (auto it = first; it != last; ++it) - { - insert(*it); - } - } -}; - -} // namespace nlohmann - - -#if defined(JSON_HAS_CPP_17) - #include -#endif - -/*! -@brief namespace for Niels Lohmann -@see https://github.com/nlohmann -@since version 1.0.0 -*/ -namespace nlohmann -{ - -/*! -@brief a class to store JSON values - -@tparam ObjectType type for JSON objects (`std::map` by default; will be used -in @ref object_t) -@tparam ArrayType type for JSON arrays (`std::vector` by default; will be used -in @ref array_t) -@tparam StringType type for JSON strings and object keys (`std::string` by -default; will be used in @ref string_t) -@tparam BooleanType type for JSON booleans (`bool` by default; will be used -in @ref boolean_t) -@tparam NumberIntegerType type for JSON integer numbers (`int64_t` by -default; will be used in @ref number_integer_t) -@tparam NumberUnsignedType type for JSON unsigned integer numbers (@c -`uint64_t` by default; will be used in @ref number_unsigned_t) -@tparam NumberFloatType type for JSON floating-point numbers (`double` by -default; will be used in @ref number_float_t) -@tparam BinaryType type for packed binary data for compatibility with binary -serialization formats (`std::vector` by default; will be used in -@ref binary_t) -@tparam AllocatorType type of the allocator to use (`std::allocator` by -default) -@tparam JSONSerializer the serializer to resolve internal calls to `to_json()` -and `from_json()` (@ref adl_serializer by default) - -@requirement The class satisfies the following concept requirements: -- Basic - - [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible): - JSON values can be default constructed. The result will be a JSON null - value. - - [MoveConstructible](https://en.cppreference.com/w/cpp/named_req/MoveConstructible): - A JSON value can be constructed from an rvalue argument. - - [CopyConstructible](https://en.cppreference.com/w/cpp/named_req/CopyConstructible): - A JSON value can be copy-constructed from an lvalue expression. - - [MoveAssignable](https://en.cppreference.com/w/cpp/named_req/MoveAssignable): - A JSON value van be assigned from an rvalue argument. - - [CopyAssignable](https://en.cppreference.com/w/cpp/named_req/CopyAssignable): - A JSON value can be copy-assigned from an lvalue expression. - - [Destructible](https://en.cppreference.com/w/cpp/named_req/Destructible): - JSON values can be destructed. -- Layout - - [StandardLayoutType](https://en.cppreference.com/w/cpp/named_req/StandardLayoutType): - JSON values have - [standard layout](https://en.cppreference.com/w/cpp/language/data_members#Standard_layout): - All non-static data members are private and standard layout types, the - class has no virtual functions or (virtual) base classes. -- Library-wide - - [EqualityComparable](https://en.cppreference.com/w/cpp/named_req/EqualityComparable): - JSON values can be compared with `==`, see @ref - operator==(const_reference,const_reference). - - [LessThanComparable](https://en.cppreference.com/w/cpp/named_req/LessThanComparable): - JSON values can be compared with `<`, see @ref - operator<(const_reference,const_reference). - - [Swappable](https://en.cppreference.com/w/cpp/named_req/Swappable): - Any JSON lvalue or rvalue of can be swapped with any lvalue or rvalue of - other compatible types, using unqualified function call @ref swap(). - - [NullablePointer](https://en.cppreference.com/w/cpp/named_req/NullablePointer): - JSON values can be compared against `std::nullptr_t` objects which are used - to model the `null` value. -- Container - - [Container](https://en.cppreference.com/w/cpp/named_req/Container): - JSON values can be used like STL containers and provide iterator access. - - [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer); - JSON values can be used like STL containers and provide reverse iterator - access. - -@invariant The member variables @a m_value and @a m_type have the following -relationship: -- If `m_type == value_t::object`, then `m_value.object != nullptr`. -- If `m_type == value_t::array`, then `m_value.array != nullptr`. -- If `m_type == value_t::string`, then `m_value.string != nullptr`. -The invariants are checked by member function assert_invariant(). - -@internal -@note ObjectType trick from https://stackoverflow.com/a/9860911 -@endinternal - -@see [RFC 8259: The JavaScript Object Notation (JSON) Data Interchange -Format](https://tools.ietf.org/html/rfc8259) - -@since version 1.0.0 - -@nosubgrouping -*/ -NLOHMANN_BASIC_JSON_TPL_DECLARATION -class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-special-member-functions) -{ - private: - template friend struct detail::external_constructor; - friend ::nlohmann::json_pointer; - - template - friend class ::nlohmann::detail::parser; - friend ::nlohmann::detail::serializer; - template - friend class ::nlohmann::detail::iter_impl; - template - friend class ::nlohmann::detail::binary_writer; - template - friend class ::nlohmann::detail::binary_reader; - template - friend class ::nlohmann::detail::json_sax_dom_parser; - template - friend class ::nlohmann::detail::json_sax_dom_callback_parser; - friend class ::nlohmann::detail::exception; - - /// workaround type for MSVC - using basic_json_t = NLOHMANN_BASIC_JSON_TPL; - - JSON_PRIVATE_UNLESS_TESTED: - // convenience aliases for types residing in namespace detail; - using lexer = ::nlohmann::detail::lexer_base; - - template - static ::nlohmann::detail::parser parser( - InputAdapterType adapter, - detail::parser_callback_tcb = nullptr, - const bool allow_exceptions = true, - const bool ignore_comments = false - ) - { - return ::nlohmann::detail::parser(std::move(adapter), - std::move(cb), allow_exceptions, ignore_comments); - } - - private: - using primitive_iterator_t = ::nlohmann::detail::primitive_iterator_t; - template - using internal_iterator = ::nlohmann::detail::internal_iterator; - template - using iter_impl = ::nlohmann::detail::iter_impl; - template - using iteration_proxy = ::nlohmann::detail::iteration_proxy; - template using json_reverse_iterator = ::nlohmann::detail::json_reverse_iterator; - - template - using output_adapter_t = ::nlohmann::detail::output_adapter_t; - - template - using binary_reader = ::nlohmann::detail::binary_reader; - template using binary_writer = ::nlohmann::detail::binary_writer; - - JSON_PRIVATE_UNLESS_TESTED: - using serializer = ::nlohmann::detail::serializer; - - public: - using value_t = detail::value_t; - /// JSON Pointer, see @ref nlohmann::json_pointer - using json_pointer = ::nlohmann::json_pointer; - template - using json_serializer = JSONSerializer; - /// how to treat decoding errors - using error_handler_t = detail::error_handler_t; - /// how to treat CBOR tags - using cbor_tag_handler_t = detail::cbor_tag_handler_t; - /// helper type for initializer lists of basic_json values - using initializer_list_t = std::initializer_list>; - - using input_format_t = detail::input_format_t; - /// SAX interface type, see @ref nlohmann::json_sax - using json_sax_t = json_sax; - - //////////////// - // exceptions // - //////////////// - - /// @name exceptions - /// Classes to implement user-defined exceptions. - /// @{ - - /// @copydoc detail::exception - using exception = detail::exception; - /// @copydoc detail::parse_error - using parse_error = detail::parse_error; - /// @copydoc detail::invalid_iterator - using invalid_iterator = detail::invalid_iterator; - /// @copydoc detail::type_error - using type_error = detail::type_error; - /// @copydoc detail::out_of_range - using out_of_range = detail::out_of_range; - /// @copydoc detail::other_error - using other_error = detail::other_error; - - /// @} - - - ///////////////////// - // container types // - ///////////////////// - - /// @name container types - /// The canonic container types to use @ref basic_json like any other STL - /// container. - /// @{ - - /// the type of elements in a basic_json container - using value_type = basic_json; - - /// the type of an element reference - using reference = value_type&; - /// the type of an element const reference - using const_reference = const value_type&; - - /// a type to represent differences between iterators - using difference_type = std::ptrdiff_t; - /// a type to represent container sizes - using size_type = std::size_t; - - /// the allocator type - using allocator_type = AllocatorType; - - /// the type of an element pointer - using pointer = typename std::allocator_traits::pointer; - /// the type of an element const pointer - using const_pointer = typename std::allocator_traits::const_pointer; - - /// an iterator for a basic_json container - using iterator = iter_impl; - /// a const iterator for a basic_json container - using const_iterator = iter_impl; - /// a reverse iterator for a basic_json container - using reverse_iterator = json_reverse_iterator; - /// a const reverse iterator for a basic_json container - using const_reverse_iterator = json_reverse_iterator; - - /// @} - - - /*! - @brief returns the allocator associated with the container - */ - static allocator_type get_allocator() - { - return allocator_type(); - } - - /*! - @brief returns version information on the library - - This function returns a JSON object with information about the library, - including the version number and information on the platform and compiler. - - @return JSON object holding version information - key | description - ----------- | --------------- - `compiler` | Information on the used compiler. It is an object with the following keys: `c++` (the used C++ standard), `family` (the compiler family; possible values are `clang`, `icc`, `gcc`, `ilecpp`, `msvc`, `pgcpp`, `sunpro`, and `unknown`), and `version` (the compiler version). - `copyright` | The copyright line for the library as string. - `name` | The name of the library as string. - `platform` | The used platform as string. Possible values are `win32`, `linux`, `apple`, `unix`, and `unknown`. - `url` | The URL of the project as string. - `version` | The version of the library. It is an object with the following keys: `major`, `minor`, and `patch` as defined by [Semantic Versioning](http://semver.org), and `string` (the version string). - - @liveexample{The following code shows an example output of the `meta()` - function.,meta} - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes to any JSON value. - - @complexity Constant. - - @since 2.1.0 - */ - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json meta() - { - basic_json result; - - result["copyright"] = "(C) 2013-2021 Niels Lohmann"; - result["name"] = "JSON for Modern C++"; - result["url"] = "https://github.com/nlohmann/json"; - result["version"]["string"] = - std::to_string(NLOHMANN_JSON_VERSION_MAJOR) + "." + - std::to_string(NLOHMANN_JSON_VERSION_MINOR) + "." + - std::to_string(NLOHMANN_JSON_VERSION_PATCH); - result["version"]["major"] = NLOHMANN_JSON_VERSION_MAJOR; - result["version"]["minor"] = NLOHMANN_JSON_VERSION_MINOR; - result["version"]["patch"] = NLOHMANN_JSON_VERSION_PATCH; - -#ifdef _WIN32 - result["platform"] = "win32"; -#elif defined __linux__ - result["platform"] = "linux"; -#elif defined __APPLE__ - result["platform"] = "apple"; -#elif defined __unix__ - result["platform"] = "unix"; -#else - result["platform"] = "unknown"; -#endif - -#if defined(__ICC) || defined(__INTEL_COMPILER) - result["compiler"] = {{"family", "icc"}, {"version", __INTEL_COMPILER}}; -#elif defined(__clang__) - result["compiler"] = {{"family", "clang"}, {"version", __clang_version__}}; -#elif defined(__GNUC__) || defined(__GNUG__) - result["compiler"] = {{"family", "gcc"}, {"version", std::to_string(__GNUC__) + "." + std::to_string(__GNUC_MINOR__) + "." + std::to_string(__GNUC_PATCHLEVEL__)}}; -#elif defined(__HP_cc) || defined(__HP_aCC) - result["compiler"] = "hp" -#elif defined(__IBMCPP__) - result["compiler"] = {{"family", "ilecpp"}, {"version", __IBMCPP__}}; -#elif defined(_MSC_VER) - result["compiler"] = {{"family", "msvc"}, {"version", _MSC_VER}}; -#elif defined(__PGI) - result["compiler"] = {{"family", "pgcpp"}, {"version", __PGI}}; -#elif defined(__SUNPRO_CC) - result["compiler"] = {{"family", "sunpro"}, {"version", __SUNPRO_CC}}; -#else - result["compiler"] = {{"family", "unknown"}, {"version", "unknown"}}; -#endif - -#ifdef __cplusplus - result["compiler"]["c++"] = std::to_string(__cplusplus); -#else - result["compiler"]["c++"] = "unknown"; -#endif - return result; - } - - - /////////////////////////// - // JSON value data types // - /////////////////////////// - - /// @name JSON value data types - /// The data types to store a JSON value. These types are derived from - /// the template arguments passed to class @ref basic_json. - /// @{ - -#if defined(JSON_HAS_CPP_14) - // Use transparent comparator if possible, combined with perfect forwarding - // on find() and count() calls prevents unnecessary string construction. - using object_comparator_t = std::less<>; -#else - using object_comparator_t = std::less; -#endif - - /*! - @brief a type for an object - - [RFC 8259](https://tools.ietf.org/html/rfc8259) describes JSON objects as follows: - > An object is an unordered collection of zero or more name/value pairs, - > where a name is a string and a value is a string, number, boolean, null, - > object, or array. - - To store objects in C++, a type is defined by the template parameters - described below. - - @tparam ObjectType the container to store objects (e.g., `std::map` or - `std::unordered_map`) - @tparam StringType the type of the keys or names (e.g., `std::string`). - The comparison function `std::less` is used to order elements - inside the container. - @tparam AllocatorType the allocator to use for objects (e.g., - `std::allocator`) - - #### Default type - - With the default values for @a ObjectType (`std::map`), @a StringType - (`std::string`), and @a AllocatorType (`std::allocator`), the default - value for @a object_t is: - - @code {.cpp} - std::map< - std::string, // key_type - basic_json, // value_type - std::less, // key_compare - std::allocator> // allocator_type - > - @endcode - - #### Behavior - - The choice of @a object_t influences the behavior of the JSON class. With - the default type, objects have the following behavior: - - - When all names are unique, objects will be interoperable in the sense - that all software implementations receiving that object will agree on - the name-value mappings. - - When the names within an object are not unique, it is unspecified which - one of the values for a given key will be chosen. For instance, - `{"key": 2, "key": 1}` could be equal to either `{"key": 1}` or - `{"key": 2}`. - - Internally, name/value pairs are stored in lexicographical order of the - names. Objects will also be serialized (see @ref dump) in this order. - For instance, `{"b": 1, "a": 2}` and `{"a": 2, "b": 1}` will be stored - and serialized as `{"a": 2, "b": 1}`. - - When comparing objects, the order of the name/value pairs is irrelevant. - This makes objects interoperable in the sense that they will not be - affected by these differences. For instance, `{"b": 1, "a": 2}` and - `{"a": 2, "b": 1}` will be treated as equal. - - #### Limits - - [RFC 8259](https://tools.ietf.org/html/rfc8259) specifies: - > An implementation may set limits on the maximum depth of nesting. - - In this class, the object's limit of nesting is not explicitly constrained. - However, a maximum depth of nesting may be introduced by the compiler or - runtime environment. A theoretical limit can be queried by calling the - @ref max_size function of a JSON object. - - #### Storage - - Objects are stored as pointers in a @ref basic_json type. That is, for any - access to object values, a pointer of type `object_t*` must be - dereferenced. - - @sa see @ref array_t -- type for an array value - - @since version 1.0.0 - - @note The order name/value pairs are added to the object is *not* - preserved by the library. Therefore, iterating an object may return - name/value pairs in a different order than they were originally stored. In - fact, keys will be traversed in alphabetical order as `std::map` with - `std::less` is used by default. Please note this behavior conforms to [RFC - 8259](https://tools.ietf.org/html/rfc8259), because any order implements the - specified "unordered" nature of JSON objects. - */ - using object_t = ObjectType>>; - - /*! - @brief a type for an array - - [RFC 8259](https://tools.ietf.org/html/rfc8259) describes JSON arrays as follows: - > An array is an ordered sequence of zero or more values. - - To store objects in C++, a type is defined by the template parameters - explained below. - - @tparam ArrayType container type to store arrays (e.g., `std::vector` or - `std::list`) - @tparam AllocatorType allocator to use for arrays (e.g., `std::allocator`) - - #### Default type - - With the default values for @a ArrayType (`std::vector`) and @a - AllocatorType (`std::allocator`), the default value for @a array_t is: - - @code {.cpp} - std::vector< - basic_json, // value_type - std::allocator // allocator_type - > - @endcode - - #### Limits - - [RFC 8259](https://tools.ietf.org/html/rfc8259) specifies: - > An implementation may set limits on the maximum depth of nesting. - - In this class, the array's limit of nesting is not explicitly constrained. - However, a maximum depth of nesting may be introduced by the compiler or - runtime environment. A theoretical limit can be queried by calling the - @ref max_size function of a JSON array. - - #### Storage - - Arrays are stored as pointers in a @ref basic_json type. That is, for any - access to array values, a pointer of type `array_t*` must be dereferenced. - - @sa see @ref object_t -- type for an object value - - @since version 1.0.0 - */ - using array_t = ArrayType>; - - /*! - @brief a type for a string - - [RFC 8259](https://tools.ietf.org/html/rfc8259) describes JSON strings as follows: - > A string is a sequence of zero or more Unicode characters. - - To store objects in C++, a type is defined by the template parameter - described below. Unicode values are split by the JSON class into - byte-sized characters during deserialization. - - @tparam StringType the container to store strings (e.g., `std::string`). - Note this container is used for keys/names in objects, see @ref object_t. - - #### Default type - - With the default values for @a StringType (`std::string`), the default - value for @a string_t is: - - @code {.cpp} - std::string - @endcode - - #### Encoding - - Strings are stored in UTF-8 encoding. Therefore, functions like - `std::string::size()` or `std::string::length()` return the number of - bytes in the string rather than the number of characters or glyphs. - - #### String comparison - - [RFC 8259](https://tools.ietf.org/html/rfc8259) states: - > Software implementations are typically required to test names of object - > members for equality. Implementations that transform the textual - > representation into sequences of Unicode code units and then perform the - > comparison numerically, code unit by code unit, are interoperable in the - > sense that implementations will agree in all cases on equality or - > inequality of two strings. For example, implementations that compare - > strings with escaped characters unconverted may incorrectly find that - > `"a\\b"` and `"a\u005Cb"` are not equal. - - This implementation is interoperable as it does compare strings code unit - by code unit. - - #### Storage - - String values are stored as pointers in a @ref basic_json type. That is, - for any access to string values, a pointer of type `string_t*` must be - dereferenced. - - @since version 1.0.0 - */ - using string_t = StringType; - - /*! - @brief a type for a boolean - - [RFC 8259](https://tools.ietf.org/html/rfc8259) implicitly describes a boolean as a - type which differentiates the two literals `true` and `false`. - - To store objects in C++, a type is defined by the template parameter @a - BooleanType which chooses the type to use. - - #### Default type - - With the default values for @a BooleanType (`bool`), the default value for - @a boolean_t is: - - @code {.cpp} - bool - @endcode - - #### Storage - - Boolean values are stored directly inside a @ref basic_json type. - - @since version 1.0.0 - */ - using boolean_t = BooleanType; - - /*! - @brief a type for a number (integer) - - [RFC 8259](https://tools.ietf.org/html/rfc8259) describes numbers as follows: - > The representation of numbers is similar to that used in most - > programming languages. A number is represented in base 10 using decimal - > digits. It contains an integer component that may be prefixed with an - > optional minus sign, which may be followed by a fraction part and/or an - > exponent part. Leading zeros are not allowed. (...) Numeric values that - > cannot be represented in the grammar below (such as Infinity and NaN) - > are not permitted. - - This description includes both integer and floating-point numbers. - However, C++ allows more precise storage if it is known whether the number - is a signed integer, an unsigned integer or a floating-point number. - Therefore, three different types, @ref number_integer_t, @ref - number_unsigned_t and @ref number_float_t are used. - - To store integer numbers in C++, a type is defined by the template - parameter @a NumberIntegerType which chooses the type to use. - - #### Default type - - With the default values for @a NumberIntegerType (`int64_t`), the default - value for @a number_integer_t is: - - @code {.cpp} - int64_t - @endcode - - #### Default behavior - - - The restrictions about leading zeros is not enforced in C++. Instead, - leading zeros in integer literals lead to an interpretation as octal - number. Internally, the value will be stored as decimal number. For - instance, the C++ integer literal `010` will be serialized to `8`. - During deserialization, leading zeros yield an error. - - Not-a-number (NaN) values will be serialized to `null`. - - #### Limits - - [RFC 8259](https://tools.ietf.org/html/rfc8259) specifies: - > An implementation may set limits on the range and precision of numbers. - - When the default type is used, the maximal integer number that can be - stored is `9223372036854775807` (INT64_MAX) and the minimal integer number - that can be stored is `-9223372036854775808` (INT64_MIN). Integer numbers - that are out of range will yield over/underflow when used in a - constructor. During deserialization, too large or small integer numbers - will be automatically be stored as @ref number_unsigned_t or @ref - number_float_t. - - [RFC 8259](https://tools.ietf.org/html/rfc8259) further states: - > Note that when such software is used, numbers that are integers and are - > in the range \f$[-2^{53}+1, 2^{53}-1]\f$ are interoperable in the sense - > that implementations will agree exactly on their numeric values. - - As this range is a subrange of the exactly supported range [INT64_MIN, - INT64_MAX], this class's integer type is interoperable. - - #### Storage - - Integer number values are stored directly inside a @ref basic_json type. - - @sa see @ref number_float_t -- type for number values (floating-point) - - @sa see @ref number_unsigned_t -- type for number values (unsigned integer) - - @since version 1.0.0 - */ - using number_integer_t = NumberIntegerType; - - /*! - @brief a type for a number (unsigned) - - [RFC 8259](https://tools.ietf.org/html/rfc8259) describes numbers as follows: - > The representation of numbers is similar to that used in most - > programming languages. A number is represented in base 10 using decimal - > digits. It contains an integer component that may be prefixed with an - > optional minus sign, which may be followed by a fraction part and/or an - > exponent part. Leading zeros are not allowed. (...) Numeric values that - > cannot be represented in the grammar below (such as Infinity and NaN) - > are not permitted. - - This description includes both integer and floating-point numbers. - However, C++ allows more precise storage if it is known whether the number - is a signed integer, an unsigned integer or a floating-point number. - Therefore, three different types, @ref number_integer_t, @ref - number_unsigned_t and @ref number_float_t are used. - - To store unsigned integer numbers in C++, a type is defined by the - template parameter @a NumberUnsignedType which chooses the type to use. - - #### Default type - - With the default values for @a NumberUnsignedType (`uint64_t`), the - default value for @a number_unsigned_t is: - - @code {.cpp} - uint64_t - @endcode - - #### Default behavior - - - The restrictions about leading zeros is not enforced in C++. Instead, - leading zeros in integer literals lead to an interpretation as octal - number. Internally, the value will be stored as decimal number. For - instance, the C++ integer literal `010` will be serialized to `8`. - During deserialization, leading zeros yield an error. - - Not-a-number (NaN) values will be serialized to `null`. - - #### Limits - - [RFC 8259](https://tools.ietf.org/html/rfc8259) specifies: - > An implementation may set limits on the range and precision of numbers. - - When the default type is used, the maximal integer number that can be - stored is `18446744073709551615` (UINT64_MAX) and the minimal integer - number that can be stored is `0`. Integer numbers that are out of range - will yield over/underflow when used in a constructor. During - deserialization, too large or small integer numbers will be automatically - be stored as @ref number_integer_t or @ref number_float_t. - - [RFC 8259](https://tools.ietf.org/html/rfc8259) further states: - > Note that when such software is used, numbers that are integers and are - > in the range \f$[-2^{53}+1, 2^{53}-1]\f$ are interoperable in the sense - > that implementations will agree exactly on their numeric values. - - As this range is a subrange (when considered in conjunction with the - number_integer_t type) of the exactly supported range [0, UINT64_MAX], - this class's integer type is interoperable. - - #### Storage - - Integer number values are stored directly inside a @ref basic_json type. - - @sa see @ref number_float_t -- type for number values (floating-point) - @sa see @ref number_integer_t -- type for number values (integer) - - @since version 2.0.0 - */ - using number_unsigned_t = NumberUnsignedType; - - /*! - @brief a type for a number (floating-point) - - [RFC 8259](https://tools.ietf.org/html/rfc8259) describes numbers as follows: - > The representation of numbers is similar to that used in most - > programming languages. A number is represented in base 10 using decimal - > digits. It contains an integer component that may be prefixed with an - > optional minus sign, which may be followed by a fraction part and/or an - > exponent part. Leading zeros are not allowed. (...) Numeric values that - > cannot be represented in the grammar below (such as Infinity and NaN) - > are not permitted. - - This description includes both integer and floating-point numbers. - However, C++ allows more precise storage if it is known whether the number - is a signed integer, an unsigned integer or a floating-point number. - Therefore, three different types, @ref number_integer_t, @ref - number_unsigned_t and @ref number_float_t are used. - - To store floating-point numbers in C++, a type is defined by the template - parameter @a NumberFloatType which chooses the type to use. - - #### Default type - - With the default values for @a NumberFloatType (`double`), the default - value for @a number_float_t is: - - @code {.cpp} - double - @endcode - - #### Default behavior - - - The restrictions about leading zeros is not enforced in C++. Instead, - leading zeros in floating-point literals will be ignored. Internally, - the value will be stored as decimal number. For instance, the C++ - floating-point literal `01.2` will be serialized to `1.2`. During - deserialization, leading zeros yield an error. - - Not-a-number (NaN) values will be serialized to `null`. - - #### Limits - - [RFC 8259](https://tools.ietf.org/html/rfc8259) states: - > This specification allows implementations to set limits on the range and - > precision of numbers accepted. Since software that implements IEEE - > 754-2008 binary64 (double precision) numbers is generally available and - > widely used, good interoperability can be achieved by implementations - > that expect no more precision or range than these provide, in the sense - > that implementations will approximate JSON numbers within the expected - > precision. - - This implementation does exactly follow this approach, as it uses double - precision floating-point numbers. Note values smaller than - `-1.79769313486232e+308` and values greater than `1.79769313486232e+308` - will be stored as NaN internally and be serialized to `null`. - - #### Storage - - Floating-point number values are stored directly inside a @ref basic_json - type. - - @sa see @ref number_integer_t -- type for number values (integer) - - @sa see @ref number_unsigned_t -- type for number values (unsigned integer) - - @since version 1.0.0 - */ - using number_float_t = NumberFloatType; - - /*! - @brief a type for a packed binary type - - This type is a type designed to carry binary data that appears in various - serialized formats, such as CBOR's Major Type 2, MessagePack's bin, and - BSON's generic binary subtype. This type is NOT a part of standard JSON and - exists solely for compatibility with these binary types. As such, it is - simply defined as an ordered sequence of zero or more byte values. - - Additionally, as an implementation detail, the subtype of the binary data is - carried around as a `std::uint8_t`, which is compatible with both of the - binary data formats that use binary subtyping, (though the specific - numbering is incompatible with each other, and it is up to the user to - translate between them). - - [CBOR's RFC 7049](https://tools.ietf.org/html/rfc7049) describes this type - as: - > Major type 2: a byte string. The string's length in bytes is represented - > following the rules for positive integers (major type 0). - - [MessagePack's documentation on the bin type - family](https://github.com/msgpack/msgpack/blob/master/spec.md#bin-format-family) - describes this type as: - > Bin format family stores an byte array in 2, 3, or 5 bytes of extra bytes - > in addition to the size of the byte array. - - [BSON's specifications](http://bsonspec.org/spec.html) describe several - binary types; however, this type is intended to represent the generic binary - type which has the description: - > Generic binary subtype - This is the most commonly used binary subtype and - > should be the 'default' for drivers and tools. - - None of these impose any limitations on the internal representation other - than the basic unit of storage be some type of array whose parts are - decomposable into bytes. - - The default representation of this binary format is a - `std::vector`, which is a very common way to represent a byte - array in modern C++. - - #### Default type - - The default values for @a BinaryType is `std::vector` - - #### Storage - - Binary Arrays are stored as pointers in a @ref basic_json type. That is, - for any access to array values, a pointer of the type `binary_t*` must be - dereferenced. - - #### Notes on subtypes - - - CBOR - - Binary values are represented as byte strings. Subtypes are serialized - as tagged values. - - MessagePack - - If a subtype is given and the binary array contains exactly 1, 2, 4, 8, - or 16 elements, the fixext family (fixext1, fixext2, fixext4, fixext8) - is used. For other sizes, the ext family (ext8, ext16, ext32) is used. - The subtype is then added as singed 8-bit integer. - - If no subtype is given, the bin family (bin8, bin16, bin32) is used. - - BSON - - If a subtype is given, it is used and added as unsigned 8-bit integer. - - If no subtype is given, the generic binary subtype 0x00 is used. - - @sa see @ref binary -- create a binary array - - @since version 3.8.0 - */ - using binary_t = nlohmann::byte_container_with_subtype; - /// @} - - private: - - /// helper for exception-safe object creation - template - JSON_HEDLEY_RETURNS_NON_NULL - static T* create(Args&& ... args) - { - AllocatorType alloc; - using AllocatorTraits = std::allocator_traits>; - - auto deleter = [&](T * obj) - { - AllocatorTraits::deallocate(alloc, obj, 1); - }; - std::unique_ptr obj(AllocatorTraits::allocate(alloc, 1), deleter); - AllocatorTraits::construct(alloc, obj.get(), std::forward(args)...); - JSON_ASSERT(obj != nullptr); - return obj.release(); - } - - //////////////////////// - // JSON value storage // - //////////////////////// - - JSON_PRIVATE_UNLESS_TESTED: - /*! - @brief a JSON value - - The actual storage for a JSON value of the @ref basic_json class. This - union combines the different storage types for the JSON value types - defined in @ref value_t. - - JSON type | value_t type | used type - --------- | --------------- | ------------------------ - object | object | pointer to @ref object_t - array | array | pointer to @ref array_t - string | string | pointer to @ref string_t - boolean | boolean | @ref boolean_t - number | number_integer | @ref number_integer_t - number | number_unsigned | @ref number_unsigned_t - number | number_float | @ref number_float_t - binary | binary | pointer to @ref binary_t - null | null | *no value is stored* - - @note Variable-length types (objects, arrays, and strings) are stored as - pointers. The size of the union should not exceed 64 bits if the default - value types are used. - - @since version 1.0.0 - */ - union json_value - { - /// object (stored with pointer to save storage) - object_t* object; - /// array (stored with pointer to save storage) - array_t* array; - /// string (stored with pointer to save storage) - string_t* string; - /// binary (stored with pointer to save storage) - binary_t* binary; - /// boolean - boolean_t boolean; - /// number (integer) - number_integer_t number_integer; - /// number (unsigned integer) - number_unsigned_t number_unsigned; - /// number (floating-point) - number_float_t number_float; - - /// default constructor (for null values) - json_value() = default; - /// constructor for booleans - json_value(boolean_t v) noexcept : boolean(v) {} - /// constructor for numbers (integer) - json_value(number_integer_t v) noexcept : number_integer(v) {} - /// constructor for numbers (unsigned) - json_value(number_unsigned_t v) noexcept : number_unsigned(v) {} - /// constructor for numbers (floating-point) - json_value(number_float_t v) noexcept : number_float(v) {} - /// constructor for empty values of a given type - json_value(value_t t) - { - switch (t) - { - case value_t::object: - { - object = create(); - break; - } - - case value_t::array: - { - array = create(); - break; - } - - case value_t::string: - { - string = create(""); - break; - } - - case value_t::binary: - { - binary = create(); - break; - } - - case value_t::boolean: - { - boolean = boolean_t(false); - break; - } - - case value_t::number_integer: - { - number_integer = number_integer_t(0); - break; - } - - case value_t::number_unsigned: - { - number_unsigned = number_unsigned_t(0); - break; - } - - case value_t::number_float: - { - number_float = number_float_t(0.0); - break; - } - - case value_t::null: - { - object = nullptr; // silence warning, see #821 - break; - } - - case value_t::discarded: - default: - { - object = nullptr; // silence warning, see #821 - if (JSON_HEDLEY_UNLIKELY(t == value_t::null)) - { - JSON_THROW(other_error::create(500, "961c151d2e87f2686a955a9be24d316f1362bf21 3.10.4", basic_json())); // LCOV_EXCL_LINE - } - break; - } - } - } - - /// constructor for strings - json_value(const string_t& value) : string(create(value)) {} - - /// constructor for rvalue strings - json_value(string_t&& value) : string(create(std::move(value))) {} - - /// constructor for objects - json_value(const object_t& value) : object(create(value)) {} - - /// constructor for rvalue objects - json_value(object_t&& value) : object(create(std::move(value))) {} - - /// constructor for arrays - json_value(const array_t& value) : array(create(value)) {} - - /// constructor for rvalue arrays - json_value(array_t&& value) : array(create(std::move(value))) {} - - /// constructor for binary arrays - json_value(const typename binary_t::container_type& value) : binary(create(value)) {} - - /// constructor for rvalue binary arrays - json_value(typename binary_t::container_type&& value) : binary(create(std::move(value))) {} - - /// constructor for binary arrays (internal type) - json_value(const binary_t& value) : binary(create(value)) {} - - /// constructor for rvalue binary arrays (internal type) - json_value(binary_t&& value) : binary(create(std::move(value))) {} - - void destroy(value_t t) - { - if (t == value_t::array || t == value_t::object) - { - // flatten the current json_value to a heap-allocated stack - std::vector stack; - - // move the top-level items to stack - if (t == value_t::array) - { - stack.reserve(array->size()); - std::move(array->begin(), array->end(), std::back_inserter(stack)); - } - else - { - stack.reserve(object->size()); - for (auto&& it : *object) - { - stack.push_back(std::move(it.second)); - } - } - - while (!stack.empty()) - { - // move the last item to local variable to be processed - basic_json current_item(std::move(stack.back())); - stack.pop_back(); - - // if current_item is array/object, move - // its children to the stack to be processed later - if (current_item.is_array()) - { - std::move(current_item.m_value.array->begin(), current_item.m_value.array->end(), std::back_inserter(stack)); - - current_item.m_value.array->clear(); - } - else if (current_item.is_object()) - { - for (auto&& it : *current_item.m_value.object) - { - stack.push_back(std::move(it.second)); - } - - current_item.m_value.object->clear(); - } - - // it's now safe that current_item get destructed - // since it doesn't have any children - } - } - - switch (t) - { - case value_t::object: - { - AllocatorType alloc; - std::allocator_traits::destroy(alloc, object); - std::allocator_traits::deallocate(alloc, object, 1); - break; - } - - case value_t::array: - { - AllocatorType alloc; - std::allocator_traits::destroy(alloc, array); - std::allocator_traits::deallocate(alloc, array, 1); - break; - } - - case value_t::string: - { - AllocatorType alloc; - std::allocator_traits::destroy(alloc, string); - std::allocator_traits::deallocate(alloc, string, 1); - break; - } - - case value_t::binary: - { - AllocatorType alloc; - std::allocator_traits::destroy(alloc, binary); - std::allocator_traits::deallocate(alloc, binary, 1); - break; - } - - case value_t::null: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::discarded: - default: - { - break; - } - } - } - }; - - private: - /*! - @brief checks the class invariants - - This function asserts the class invariants. It needs to be called at the - end of every constructor to make sure that created objects respect the - invariant. Furthermore, it has to be called each time the type of a JSON - value is changed, because the invariant expresses a relationship between - @a m_type and @a m_value. - - Furthermore, the parent relation is checked for arrays and objects: If - @a check_parents true and the value is an array or object, then the - container's elements must have the current value as parent. - - @param[in] check_parents whether the parent relation should be checked. - The value is true by default and should only be set to false - during destruction of objects when the invariant does not - need to hold. - */ - void assert_invariant(bool check_parents = true) const noexcept - { - JSON_ASSERT(m_type != value_t::object || m_value.object != nullptr); - JSON_ASSERT(m_type != value_t::array || m_value.array != nullptr); - JSON_ASSERT(m_type != value_t::string || m_value.string != nullptr); - JSON_ASSERT(m_type != value_t::binary || m_value.binary != nullptr); - -#if JSON_DIAGNOSTICS - JSON_TRY - { - // cppcheck-suppress assertWithSideEffect - JSON_ASSERT(!check_parents || !is_structured() || std::all_of(begin(), end(), [this](const basic_json & j) - { - return j.m_parent == this; - })); - } - JSON_CATCH(...) {} // LCOV_EXCL_LINE -#endif - static_cast(check_parents); - } - - void set_parents() - { -#if JSON_DIAGNOSTICS - switch (m_type) - { - case value_t::array: - { - for (auto& element : *m_value.array) - { - element.m_parent = this; - } - break; - } - - case value_t::object: - { - for (auto& element : *m_value.object) - { - element.second.m_parent = this; - } - break; - } - - case value_t::null: - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - break; - } -#endif - } - - iterator set_parents(iterator it, typename iterator::difference_type count) - { -#if JSON_DIAGNOSTICS - for (typename iterator::difference_type i = 0; i < count; ++i) - { - (it + i)->m_parent = this; - } -#else - static_cast(count); -#endif - return it; - } - - reference set_parent(reference j, std::size_t old_capacity = std::size_t(-1)) - { -#if JSON_DIAGNOSTICS - if (old_capacity != std::size_t(-1)) - { - // see https://github.com/nlohmann/json/issues/2838 - JSON_ASSERT(type() == value_t::array); - if (JSON_HEDLEY_UNLIKELY(m_value.array->capacity() != old_capacity)) - { - // capacity has changed: update all parents - set_parents(); - return j; - } - } - - // ordered_json uses a vector internally, so pointers could have - // been invalidated; see https://github.com/nlohmann/json/issues/2962 -#ifdef JSON_HEDLEY_MSVC_VERSION -#pragma warning(push ) -#pragma warning(disable : 4127) // ignore warning to replace if with if constexpr -#endif - if (detail::is_ordered_map::value) - { - set_parents(); - return j; - } -#ifdef JSON_HEDLEY_MSVC_VERSION -#pragma warning( pop ) -#endif - - j.m_parent = this; -#else - static_cast(j); - static_cast(old_capacity); -#endif - return j; - } - - public: - ////////////////////////// - // JSON parser callback // - ////////////////////////// - - /*! - @brief parser event types - - The parser callback distinguishes the following events: - - `object_start`: the parser read `{` and started to process a JSON object - - `key`: the parser read a key of a value in an object - - `object_end`: the parser read `}` and finished processing a JSON object - - `array_start`: the parser read `[` and started to process a JSON array - - `array_end`: the parser read `]` and finished processing a JSON array - - `value`: the parser finished reading a JSON value - - @image html callback_events.png "Example when certain parse events are triggered" - - @sa see @ref parser_callback_t for more information and examples - */ - using parse_event_t = detail::parse_event_t; - - /*! - @brief per-element parser callback type - - With a parser callback function, the result of parsing a JSON text can be - influenced. When passed to @ref parse, it is called on certain events - (passed as @ref parse_event_t via parameter @a event) with a set recursion - depth @a depth and context JSON value @a parsed. The return value of the - callback function is a boolean indicating whether the element that emitted - the callback shall be kept or not. - - We distinguish six scenarios (determined by the event type) in which the - callback function can be called. The following table describes the values - of the parameters @a depth, @a event, and @a parsed. - - parameter @a event | description | parameter @a depth | parameter @a parsed - ------------------ | ----------- | ------------------ | ------------------- - parse_event_t::object_start | the parser read `{` and started to process a JSON object | depth of the parent of the JSON object | a JSON value with type discarded - parse_event_t::key | the parser read a key of a value in an object | depth of the currently parsed JSON object | a JSON string containing the key - parse_event_t::object_end | the parser read `}` and finished processing a JSON object | depth of the parent of the JSON object | the parsed JSON object - parse_event_t::array_start | the parser read `[` and started to process a JSON array | depth of the parent of the JSON array | a JSON value with type discarded - parse_event_t::array_end | the parser read `]` and finished processing a JSON array | depth of the parent of the JSON array | the parsed JSON array - parse_event_t::value | the parser finished reading a JSON value | depth of the value | the parsed JSON value - - @image html callback_events.png "Example when certain parse events are triggered" - - Discarding a value (i.e., returning `false`) has different effects - depending on the context in which function was called: - - - Discarded values in structured types are skipped. That is, the parser - will behave as if the discarded value was never read. - - In case a value outside a structured type is skipped, it is replaced - with `null`. This case happens if the top-level element is skipped. - - @param[in] depth the depth of the recursion during parsing - - @param[in] event an event of type parse_event_t indicating the context in - the callback function has been called - - @param[in,out] parsed the current intermediate parse result; note that - writing to this value has no effect for parse_event_t::key events - - @return Whether the JSON value which called the function during parsing - should be kept (`true`) or not (`false`). In the latter case, it is either - skipped completely or replaced by an empty discarded object. - - @sa see @ref parse for examples - - @since version 1.0.0 - */ - using parser_callback_t = detail::parser_callback_t; - - ////////////////// - // constructors // - ////////////////// - - /// @name constructors and destructors - /// Constructors of class @ref basic_json, copy/move constructor, copy - /// assignment, static functions creating objects, and the destructor. - /// @{ - - /*! - @brief create an empty value with a given type - - Create an empty JSON value with a given type. The value will be default - initialized with an empty value which depends on the type: - - Value type | initial value - ----------- | ------------- - null | `null` - boolean | `false` - string | `""` - number | `0` - object | `{}` - array | `[]` - binary | empty array - - @param[in] v the type of the value to create - - @complexity Constant. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes to any JSON value. - - @liveexample{The following code shows the constructor for different @ref - value_t values,basic_json__value_t} - - @sa see @ref clear() -- restores the postcondition of this constructor - - @since version 1.0.0 - */ - basic_json(const value_t v) - : m_type(v), m_value(v) - { - assert_invariant(); - } - - /*! - @brief create a null object - - Create a `null` JSON value. It either takes a null pointer as parameter - (explicitly creating `null`) or no parameter (implicitly creating `null`). - The passed null pointer itself is not read -- it is only used to choose - the right constructor. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this constructor never throws - exceptions. - - @liveexample{The following code shows the constructor with and without a - null pointer parameter.,basic_json__nullptr_t} - - @since version 1.0.0 - */ - basic_json(std::nullptr_t = nullptr) noexcept - : basic_json(value_t::null) - { - assert_invariant(); - } - - /*! - @brief create a JSON value - - This is a "catch all" constructor for all compatible JSON types; that is, - types for which a `to_json()` method exists. The constructor forwards the - parameter @a val to that method (to `json_serializer::to_json` method - with `U = uncvref_t`, to be exact). - - Template type @a CompatibleType includes, but is not limited to, the - following types: - - **arrays**: @ref array_t and all kinds of compatible containers such as - `std::vector`, `std::deque`, `std::list`, `std::forward_list`, - `std::array`, `std::valarray`, `std::set`, `std::unordered_set`, - `std::multiset`, and `std::unordered_multiset` with a `value_type` from - which a @ref basic_json value can be constructed. - - **objects**: @ref object_t and all kinds of compatible associative - containers such as `std::map`, `std::unordered_map`, `std::multimap`, - and `std::unordered_multimap` with a `key_type` compatible to - @ref string_t and a `value_type` from which a @ref basic_json value can - be constructed. - - **strings**: @ref string_t, string literals, and all compatible string - containers can be used. - - **numbers**: @ref number_integer_t, @ref number_unsigned_t, - @ref number_float_t, and all convertible number types such as `int`, - `size_t`, `int64_t`, `float` or `double` can be used. - - **boolean**: @ref boolean_t / `bool` can be used. - - **binary**: @ref binary_t / `std::vector` may be used, - unfortunately because string literals cannot be distinguished from binary - character arrays by the C++ type system, all types compatible with `const - char*` will be directed to the string constructor instead. This is both - for backwards compatibility, and due to the fact that a binary type is not - a standard JSON type. - - See the examples below. - - @tparam CompatibleType a type such that: - - @a CompatibleType is not derived from `std::istream`, - - @a CompatibleType is not @ref basic_json (to avoid hijacking copy/move - constructors), - - @a CompatibleType is not a different @ref basic_json type (i.e. with different template arguments) - - @a CompatibleType is not a @ref basic_json nested type (e.g., - @ref json_pointer, @ref iterator, etc ...) - - `json_serializer` has a `to_json(basic_json_t&, CompatibleType&&)` method - - @tparam U = `uncvref_t` - - @param[in] val the value to be forwarded to the respective constructor - - @complexity Usually linear in the size of the passed @a val, also - depending on the implementation of the called `to_json()` - method. - - @exceptionsafety Depends on the called constructor. For types directly - supported by the library (i.e., all types for which no `to_json()` function - was provided), strong guarantee holds: if an exception is thrown, there are - no changes to any JSON value. - - @liveexample{The following code shows the constructor with several - compatible types.,basic_json__CompatibleType} - - @since version 2.1.0 - */ - template < typename CompatibleType, - typename U = detail::uncvref_t, - detail::enable_if_t < - !detail::is_basic_json::value && detail::is_compatible_type::value, int > = 0 > - basic_json(CompatibleType && val) noexcept(noexcept( // NOLINT(bugprone-forwarding-reference-overload,bugprone-exception-escape) - JSONSerializer::to_json(std::declval(), - std::forward(val)))) - { - JSONSerializer::to_json(*this, std::forward(val)); - set_parents(); - assert_invariant(); - } - - /*! - @brief create a JSON value from an existing one - - This is a constructor for existing @ref basic_json types. - It does not hijack copy/move constructors, since the parameter has different - template arguments than the current ones. - - The constructor tries to convert the internal @ref m_value of the parameter. - - @tparam BasicJsonType a type such that: - - @a BasicJsonType is a @ref basic_json type. - - @a BasicJsonType has different template arguments than @ref basic_json_t. - - @param[in] val the @ref basic_json value to be converted. - - @complexity Usually linear in the size of the passed @a val, also - depending on the implementation of the called `to_json()` - method. - - @exceptionsafety Depends on the called constructor. For types directly - supported by the library (i.e., all types for which no `to_json()` function - was provided), strong guarantee holds: if an exception is thrown, there are - no changes to any JSON value. - - @since version 3.2.0 - */ - template < typename BasicJsonType, - detail::enable_if_t < - detail::is_basic_json::value&& !std::is_same::value, int > = 0 > - basic_json(const BasicJsonType& val) - { - using other_boolean_t = typename BasicJsonType::boolean_t; - using other_number_float_t = typename BasicJsonType::number_float_t; - using other_number_integer_t = typename BasicJsonType::number_integer_t; - using other_number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using other_string_t = typename BasicJsonType::string_t; - using other_object_t = typename BasicJsonType::object_t; - using other_array_t = typename BasicJsonType::array_t; - using other_binary_t = typename BasicJsonType::binary_t; - - switch (val.type()) - { - case value_t::boolean: - JSONSerializer::to_json(*this, val.template get()); - break; - case value_t::number_float: - JSONSerializer::to_json(*this, val.template get()); - break; - case value_t::number_integer: - JSONSerializer::to_json(*this, val.template get()); - break; - case value_t::number_unsigned: - JSONSerializer::to_json(*this, val.template get()); - break; - case value_t::string: - JSONSerializer::to_json(*this, val.template get_ref()); - break; - case value_t::object: - JSONSerializer::to_json(*this, val.template get_ref()); - break; - case value_t::array: - JSONSerializer::to_json(*this, val.template get_ref()); - break; - case value_t::binary: - JSONSerializer::to_json(*this, val.template get_ref()); - break; - case value_t::null: - *this = nullptr; - break; - case value_t::discarded: - m_type = value_t::discarded; - break; - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE - } - set_parents(); - assert_invariant(); - } - - /*! - @brief create a container (array or object) from an initializer list - - Creates a JSON value of type array or object from the passed initializer - list @a init. In case @a type_deduction is `true` (default), the type of - the JSON value to be created is deducted from the initializer list @a init - according to the following rules: - - 1. If the list is empty, an empty JSON object value `{}` is created. - 2. If the list consists of pairs whose first element is a string, a JSON - object value is created where the first elements of the pairs are - treated as keys and the second elements are as values. - 3. In all other cases, an array is created. - - The rules aim to create the best fit between a C++ initializer list and - JSON values. The rationale is as follows: - - 1. The empty initializer list is written as `{}` which is exactly an empty - JSON object. - 2. C++ has no way of describing mapped types other than to list a list of - pairs. As JSON requires that keys must be of type string, rule 2 is the - weakest constraint one can pose on initializer lists to interpret them - as an object. - 3. In all other cases, the initializer list could not be interpreted as - JSON object type, so interpreting it as JSON array type is safe. - - With the rules described above, the following JSON values cannot be - expressed by an initializer list: - - - the empty array (`[]`): use @ref array(initializer_list_t) - with an empty initializer list in this case - - arrays whose elements satisfy rule 2: use @ref - array(initializer_list_t) with the same initializer list - in this case - - @note When used without parentheses around an empty initializer list, @ref - basic_json() is called instead of this function, yielding the JSON null - value. - - @param[in] init initializer list with JSON values - - @param[in] type_deduction internal parameter; when set to `true`, the type - of the JSON value is deducted from the initializer list @a init; when set - to `false`, the type provided via @a manual_type is forced. This mode is - used by the functions @ref array(initializer_list_t) and - @ref object(initializer_list_t). - - @param[in] manual_type internal parameter; when @a type_deduction is set - to `false`, the created JSON value will use the provided type (only @ref - value_t::array and @ref value_t::object are valid); when @a type_deduction - is set to `true`, this parameter has no effect - - @throw type_error.301 if @a type_deduction is `false`, @a manual_type is - `value_t::object`, but @a init contains an element which is not a pair - whose first element is a string. In this case, the constructor could not - create an object. If @a type_deduction would have be `true`, an array - would have been created. See @ref object(initializer_list_t) - for an example. - - @complexity Linear in the size of the initializer list @a init. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes to any JSON value. - - @liveexample{The example below shows how JSON values are created from - initializer lists.,basic_json__list_init_t} - - @sa see @ref array(initializer_list_t) -- create a JSON array - value from an initializer list - @sa see @ref object(initializer_list_t) -- create a JSON object - value from an initializer list - - @since version 1.0.0 - */ - basic_json(initializer_list_t init, - bool type_deduction = true, - value_t manual_type = value_t::array) - { - // check if each element is an array with two elements whose first - // element is a string - bool is_an_object = std::all_of(init.begin(), init.end(), - [](const detail::json_ref& element_ref) - { - return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[0].is_string(); - }); - - // adjust type if type deduction is not wanted - if (!type_deduction) - { - // if array is wanted, do not create an object though possible - if (manual_type == value_t::array) - { - is_an_object = false; - } - - // if object is wanted but impossible, throw an exception - if (JSON_HEDLEY_UNLIKELY(manual_type == value_t::object && !is_an_object)) - { - JSON_THROW(type_error::create(301, "cannot create object from initializer list", basic_json())); - } - } - - if (is_an_object) - { - // the initializer list is a list of pairs -> create object - m_type = value_t::object; - m_value = value_t::object; - - for (auto& element_ref : init) - { - auto element = element_ref.moved_or_copied(); - m_value.object->emplace( - std::move(*((*element.m_value.array)[0].m_value.string)), - std::move((*element.m_value.array)[1])); - } - } - else - { - // the initializer list describes an array -> create array - m_type = value_t::array; - m_value.array = create(init.begin(), init.end()); - } - - set_parents(); - assert_invariant(); - } - - /*! - @brief explicitly create a binary array (without subtype) - - Creates a JSON binary array value from a given binary container. Binary - values are part of various binary formats, such as CBOR, MessagePack, and - BSON. This constructor is used to create a value for serialization to those - formats. - - @note Note, this function exists because of the difficulty in correctly - specifying the correct template overload in the standard value ctor, as both - JSON arrays and JSON binary arrays are backed with some form of a - `std::vector`. Because JSON binary arrays are a non-standard extension it - was decided that it would be best to prevent automatic initialization of a - binary array type, for backwards compatibility and so it does not happen on - accident. - - @param[in] init container containing bytes to use as binary type - - @return JSON binary array value - - @complexity Linear in the size of @a init. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes to any JSON value. - - @since version 3.8.0 - */ - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json binary(const typename binary_t::container_type& init) - { - auto res = basic_json(); - res.m_type = value_t::binary; - res.m_value = init; - return res; - } - - /*! - @brief explicitly create a binary array (with subtype) - - Creates a JSON binary array value from a given binary container. Binary - values are part of various binary formats, such as CBOR, MessagePack, and - BSON. This constructor is used to create a value for serialization to those - formats. - - @note Note, this function exists because of the difficulty in correctly - specifying the correct template overload in the standard value ctor, as both - JSON arrays and JSON binary arrays are backed with some form of a - `std::vector`. Because JSON binary arrays are a non-standard extension it - was decided that it would be best to prevent automatic initialization of a - binary array type, for backwards compatibility and so it does not happen on - accident. - - @param[in] init container containing bytes to use as binary type - @param[in] subtype subtype to use in MessagePack and BSON - - @return JSON binary array value - - @complexity Linear in the size of @a init. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes to any JSON value. - - @since version 3.8.0 - */ - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json binary(const typename binary_t::container_type& init, typename binary_t::subtype_type subtype) - { - auto res = basic_json(); - res.m_type = value_t::binary; - res.m_value = binary_t(init, subtype); - return res; - } - - /// @copydoc binary(const typename binary_t::container_type&) - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json binary(typename binary_t::container_type&& init) - { - auto res = basic_json(); - res.m_type = value_t::binary; - res.m_value = std::move(init); - return res; - } - - /// @copydoc binary(const typename binary_t::container_type&, typename binary_t::subtype_type) - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json binary(typename binary_t::container_type&& init, typename binary_t::subtype_type subtype) - { - auto res = basic_json(); - res.m_type = value_t::binary; - res.m_value = binary_t(std::move(init), subtype); - return res; - } - - /*! - @brief explicitly create an array from an initializer list - - Creates a JSON array value from a given initializer list. That is, given a - list of values `a, b, c`, creates the JSON value `[a, b, c]`. If the - initializer list is empty, the empty array `[]` is created. - - @note This function is only needed to express two edge cases that cannot - be realized with the initializer list constructor (@ref - basic_json(initializer_list_t, bool, value_t)). These cases - are: - 1. creating an array whose elements are all pairs whose first element is a - string -- in this case, the initializer list constructor would create an - object, taking the first elements as keys - 2. creating an empty array -- passing the empty initializer list to the - initializer list constructor yields an empty object - - @param[in] init initializer list with JSON values to create an array from - (optional) - - @return JSON array value - - @complexity Linear in the size of @a init. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes to any JSON value. - - @liveexample{The following code shows an example for the `array` - function.,array} - - @sa see @ref basic_json(initializer_list_t, bool, value_t) -- - create a JSON value from an initializer list - @sa see @ref object(initializer_list_t) -- create a JSON object - value from an initializer list - - @since version 1.0.0 - */ - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json array(initializer_list_t init = {}) - { - return basic_json(init, false, value_t::array); - } - - /*! - @brief explicitly create an object from an initializer list - - Creates a JSON object value from a given initializer list. The initializer - lists elements must be pairs, and their first elements must be strings. If - the initializer list is empty, the empty object `{}` is created. - - @note This function is only added for symmetry reasons. In contrast to the - related function @ref array(initializer_list_t), there are - no cases which can only be expressed by this function. That is, any - initializer list @a init can also be passed to the initializer list - constructor @ref basic_json(initializer_list_t, bool, value_t). - - @param[in] init initializer list to create an object from (optional) - - @return JSON object value - - @throw type_error.301 if @a init is not a list of pairs whose first - elements are strings. In this case, no object can be created. When such a - value is passed to @ref basic_json(initializer_list_t, bool, value_t), - an array would have been created from the passed initializer list @a init. - See example below. - - @complexity Linear in the size of @a init. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes to any JSON value. - - @liveexample{The following code shows an example for the `object` - function.,object} - - @sa see @ref basic_json(initializer_list_t, bool, value_t) -- - create a JSON value from an initializer list - @sa see @ref array(initializer_list_t) -- create a JSON array - value from an initializer list - - @since version 1.0.0 - */ - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json object(initializer_list_t init = {}) - { - return basic_json(init, false, value_t::object); - } - - /*! - @brief construct an array with count copies of given value - - Constructs a JSON array value by creating @a cnt copies of a passed value. - In case @a cnt is `0`, an empty array is created. - - @param[in] cnt the number of JSON copies of @a val to create - @param[in] val the JSON value to copy - - @post `std::distance(begin(),end()) == cnt` holds. - - @complexity Linear in @a cnt. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes to any JSON value. - - @liveexample{The following code shows examples for the @ref - basic_json(size_type\, const basic_json&) - constructor.,basic_json__size_type_basic_json} - - @since version 1.0.0 - */ - basic_json(size_type cnt, const basic_json& val) - : m_type(value_t::array) - { - m_value.array = create(cnt, val); - set_parents(); - assert_invariant(); - } - - /*! - @brief construct a JSON container given an iterator range - - Constructs the JSON value with the contents of the range `[first, last)`. - The semantics depends on the different types a JSON value can have: - - In case of a null type, invalid_iterator.206 is thrown. - - In case of other primitive types (number, boolean, or string), @a first - must be `begin()` and @a last must be `end()`. In this case, the value is - copied. Otherwise, invalid_iterator.204 is thrown. - - In case of structured types (array, object), the constructor behaves as - similar versions for `std::vector` or `std::map`; that is, a JSON array - or object is constructed from the values in the range. - - @tparam InputIT an input iterator type (@ref iterator or @ref - const_iterator) - - @param[in] first begin of the range to copy from (included) - @param[in] last end of the range to copy from (excluded) - - @pre Iterators @a first and @a last must be initialized. **This - precondition is enforced with an assertion (see warning).** If - assertions are switched off, a violation of this precondition yields - undefined behavior. - - @pre Range `[first, last)` is valid. Usually, this precondition cannot be - checked efficiently. Only certain edge cases are detected; see the - description of the exceptions below. A violation of this precondition - yields undefined behavior. - - @warning A precondition is enforced with a runtime assertion that will - result in calling `std::abort` if this precondition is not met. - Assertions can be disabled by defining `NDEBUG` at compile time. - See https://en.cppreference.com/w/cpp/error/assert for more - information. - - @throw invalid_iterator.201 if iterators @a first and @a last are not - compatible (i.e., do not belong to the same JSON value). In this case, - the range `[first, last)` is undefined. - @throw invalid_iterator.204 if iterators @a first and @a last belong to a - primitive type (number, boolean, or string), but @a first does not point - to the first element any more. In this case, the range `[first, last)` is - undefined. See example code below. - @throw invalid_iterator.206 if iterators @a first and @a last belong to a - null value. In this case, the range `[first, last)` is undefined. - - @complexity Linear in distance between @a first and @a last. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes to any JSON value. - - @liveexample{The example below shows several ways to create JSON values by - specifying a subrange with iterators.,basic_json__InputIt_InputIt} - - @since version 1.0.0 - */ - template < class InputIT, typename std::enable_if < - std::is_same::value || - std::is_same::value, int >::type = 0 > - basic_json(InputIT first, InputIT last) - { - JSON_ASSERT(first.m_object != nullptr); - JSON_ASSERT(last.m_object != nullptr); - - // make sure iterator fits the current value - if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) - { - JSON_THROW(invalid_iterator::create(201, "iterators are not compatible", basic_json())); - } - - // copy type from first iterator - m_type = first.m_object->m_type; - - // check if iterator range is complete for primitive values - switch (m_type) - { - case value_t::boolean: - case value_t::number_float: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::string: - { - if (JSON_HEDLEY_UNLIKELY(!first.m_it.primitive_iterator.is_begin() - || !last.m_it.primitive_iterator.is_end())) - { - JSON_THROW(invalid_iterator::create(204, "iterators out of range", *first.m_object)); - } - break; - } - - case value_t::null: - case value_t::object: - case value_t::array: - case value_t::binary: - case value_t::discarded: - default: - break; - } - - switch (m_type) - { - case value_t::number_integer: - { - m_value.number_integer = first.m_object->m_value.number_integer; - break; - } - - case value_t::number_unsigned: - { - m_value.number_unsigned = first.m_object->m_value.number_unsigned; - break; - } - - case value_t::number_float: - { - m_value.number_float = first.m_object->m_value.number_float; - break; - } - - case value_t::boolean: - { - m_value.boolean = first.m_object->m_value.boolean; - break; - } - - case value_t::string: - { - m_value = *first.m_object->m_value.string; - break; - } - - case value_t::object: - { - m_value.object = create(first.m_it.object_iterator, - last.m_it.object_iterator); - break; - } - - case value_t::array: - { - m_value.array = create(first.m_it.array_iterator, - last.m_it.array_iterator); - break; - } - - case value_t::binary: - { - m_value = *first.m_object->m_value.binary; - break; - } - - case value_t::null: - case value_t::discarded: - default: - JSON_THROW(invalid_iterator::create(206, "cannot construct with iterators from " + std::string(first.m_object->type_name()), *first.m_object)); - } - - set_parents(); - assert_invariant(); - } - - - /////////////////////////////////////// - // other constructors and destructor // - /////////////////////////////////////// - - template, - std::is_same>::value, int> = 0 > - basic_json(const JsonRef& ref) : basic_json(ref.moved_or_copied()) {} - - /*! - @brief copy constructor - - Creates a copy of a given JSON value. - - @param[in] other the JSON value to copy - - @post `*this == other` - - @complexity Linear in the size of @a other. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes to any JSON value. - - @requirement This function helps `basic_json` satisfying the - [Container](https://en.cppreference.com/w/cpp/named_req/Container) - requirements: - - The complexity is linear. - - As postcondition, it holds: `other == basic_json(other)`. - - @liveexample{The following code shows an example for the copy - constructor.,basic_json__basic_json} - - @since version 1.0.0 - */ - basic_json(const basic_json& other) - : m_type(other.m_type) - { - // check of passed value is valid - other.assert_invariant(); - - switch (m_type) - { - case value_t::object: - { - m_value = *other.m_value.object; - break; - } - - case value_t::array: - { - m_value = *other.m_value.array; - break; - } - - case value_t::string: - { - m_value = *other.m_value.string; - break; - } - - case value_t::boolean: - { - m_value = other.m_value.boolean; - break; - } - - case value_t::number_integer: - { - m_value = other.m_value.number_integer; - break; - } - - case value_t::number_unsigned: - { - m_value = other.m_value.number_unsigned; - break; - } - - case value_t::number_float: - { - m_value = other.m_value.number_float; - break; - } - - case value_t::binary: - { - m_value = *other.m_value.binary; - break; - } - - case value_t::null: - case value_t::discarded: - default: - break; - } - - set_parents(); - assert_invariant(); - } - - /*! - @brief move constructor - - Move constructor. Constructs a JSON value with the contents of the given - value @a other using move semantics. It "steals" the resources from @a - other and leaves it as JSON null value. - - @param[in,out] other value to move to this object - - @post `*this` has the same value as @a other before the call. - @post @a other is a JSON null value. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this constructor never throws - exceptions. - - @requirement This function helps `basic_json` satisfying the - [MoveConstructible](https://en.cppreference.com/w/cpp/named_req/MoveConstructible) - requirements. - - @liveexample{The code below shows the move constructor explicitly called - via std::move.,basic_json__moveconstructor} - - @since version 1.0.0 - */ - basic_json(basic_json&& other) noexcept - : m_type(std::move(other.m_type)), - m_value(std::move(other.m_value)) - { - // check that passed value is valid - other.assert_invariant(false); - - // invalidate payload - other.m_type = value_t::null; - other.m_value = {}; - - set_parents(); - assert_invariant(); - } - - /*! - @brief copy assignment - - Copy assignment operator. Copies a JSON value via the "copy and swap" - strategy: It is expressed in terms of the copy constructor, destructor, - and the `swap()` member function. - - @param[in] other value to copy from - - @complexity Linear. - - @requirement This function helps `basic_json` satisfying the - [Container](https://en.cppreference.com/w/cpp/named_req/Container) - requirements: - - The complexity is linear. - - @liveexample{The code below shows and example for the copy assignment. It - creates a copy of value `a` which is then swapped with `b`. Finally\, the - copy of `a` (which is the null value after the swap) is - destroyed.,basic_json__copyassignment} - - @since version 1.0.0 - */ - basic_json& operator=(basic_json other) noexcept ( - std::is_nothrow_move_constructible::value&& - std::is_nothrow_move_assignable::value&& - std::is_nothrow_move_constructible::value&& - std::is_nothrow_move_assignable::value - ) - { - // check that passed value is valid - other.assert_invariant(); - - using std::swap; - swap(m_type, other.m_type); - swap(m_value, other.m_value); - - set_parents(); - assert_invariant(); - return *this; - } - - /*! - @brief destructor - - Destroys the JSON value and frees all allocated memory. - - @complexity Linear. - - @requirement This function helps `basic_json` satisfying the - [Container](https://en.cppreference.com/w/cpp/named_req/Container) - requirements: - - The complexity is linear. - - All stored elements are destroyed and all memory is freed. - - @since version 1.0.0 - */ - ~basic_json() noexcept - { - assert_invariant(false); - m_value.destroy(m_type); - } - - /// @} - - public: - /////////////////////// - // object inspection // - /////////////////////// - - /// @name object inspection - /// Functions to inspect the type of a JSON value. - /// @{ - - /*! - @brief serialization - - Serialization function for JSON values. The function tries to mimic - Python's `json.dumps()` function, and currently supports its @a indent - and @a ensure_ascii parameters. - - @param[in] indent If indent is nonnegative, then array elements and object - members will be pretty-printed with that indent level. An indent level of - `0` will only insert newlines. `-1` (the default) selects the most compact - representation. - @param[in] indent_char The character to use for indentation if @a indent is - greater than `0`. The default is ` ` (space). - @param[in] ensure_ascii If @a ensure_ascii is true, all non-ASCII characters - in the output are escaped with `\uXXXX` sequences, and the result consists - of ASCII characters only. - @param[in] error_handler how to react on decoding errors; there are three - possible values: `strict` (throws and exception in case a decoding error - occurs; default), `replace` (replace invalid UTF-8 sequences with U+FFFD), - and `ignore` (ignore invalid UTF-8 sequences during serialization; all - bytes are copied to the output unchanged). - - @return string containing the serialization of the JSON value - - @throw type_error.316 if a string stored inside the JSON value is not - UTF-8 encoded and @a error_handler is set to strict - - @note Binary values are serialized as object containing two keys: - - "bytes": an array of bytes as integers - - "subtype": the subtype as integer or "null" if the binary has no subtype - - @complexity Linear. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes in the JSON value. - - @liveexample{The following example shows the effect of different @a indent\, - @a indent_char\, and @a ensure_ascii parameters to the result of the - serialization.,dump} - - @see https://docs.python.org/2/library/json.html#json.dump - - @since version 1.0.0; indentation character @a indent_char, option - @a ensure_ascii and exceptions added in version 3.0.0; error - handlers added in version 3.4.0; serialization of binary values added - in version 3.8.0. - */ - string_t dump(const int indent = -1, - const char indent_char = ' ', - const bool ensure_ascii = false, - const error_handler_t error_handler = error_handler_t::strict) const - { - string_t result; - serializer s(detail::output_adapter(result), indent_char, error_handler); - - if (indent >= 0) - { - s.dump(*this, true, ensure_ascii, static_cast(indent)); - } - else - { - s.dump(*this, false, ensure_ascii, 0); - } - - return result; - } - - /*! - @brief return the type of the JSON value (explicit) - - Return the type of the JSON value as a value from the @ref value_t - enumeration. - - @return the type of the JSON value - Value type | return value - ------------------------- | ------------------------- - null | value_t::null - boolean | value_t::boolean - string | value_t::string - number (integer) | value_t::number_integer - number (unsigned integer) | value_t::number_unsigned - number (floating-point) | value_t::number_float - object | value_t::object - array | value_t::array - binary | value_t::binary - discarded | value_t::discarded - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `type()` for all JSON - types.,type} - - @sa see @ref operator value_t() -- return the type of the JSON value (implicit) - @sa see @ref type_name() -- return the type as string - - @since version 1.0.0 - */ - constexpr value_t type() const noexcept - { - return m_type; - } - - /*! - @brief return whether type is primitive - - This function returns true if and only if the JSON type is primitive - (string, number, boolean, or null). - - @return `true` if type is primitive (string, number, boolean, or null), - `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_primitive()` for all JSON - types.,is_primitive} - - @sa see @ref is_structured() -- returns whether JSON value is structured - @sa see @ref is_null() -- returns whether JSON value is `null` - @sa see @ref is_string() -- returns whether JSON value is a string - @sa see @ref is_boolean() -- returns whether JSON value is a boolean - @sa see @ref is_number() -- returns whether JSON value is a number - @sa see @ref is_binary() -- returns whether JSON value is a binary array - - @since version 1.0.0 - */ - constexpr bool is_primitive() const noexcept - { - return is_null() || is_string() || is_boolean() || is_number() || is_binary(); - } - - /*! - @brief return whether type is structured - - This function returns true if and only if the JSON type is structured - (array or object). - - @return `true` if type is structured (array or object), `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_structured()` for all JSON - types.,is_structured} - - @sa see @ref is_primitive() -- returns whether value is primitive - @sa see @ref is_array() -- returns whether value is an array - @sa see @ref is_object() -- returns whether value is an object - - @since version 1.0.0 - */ - constexpr bool is_structured() const noexcept - { - return is_array() || is_object(); - } - - /*! - @brief return whether value is null - - This function returns true if and only if the JSON value is null. - - @return `true` if type is null, `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_null()` for all JSON - types.,is_null} - - @since version 1.0.0 - */ - constexpr bool is_null() const noexcept - { - return m_type == value_t::null; - } - - /*! - @brief return whether value is a boolean - - This function returns true if and only if the JSON value is a boolean. - - @return `true` if type is boolean, `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_boolean()` for all JSON - types.,is_boolean} - - @since version 1.0.0 - */ - constexpr bool is_boolean() const noexcept - { - return m_type == value_t::boolean; - } - - /*! - @brief return whether value is a number - - This function returns true if and only if the JSON value is a number. This - includes both integer (signed and unsigned) and floating-point values. - - @return `true` if type is number (regardless whether integer, unsigned - integer or floating-type), `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_number()` for all JSON - types.,is_number} - - @sa see @ref is_number_integer() -- check if value is an integer or unsigned - integer number - @sa see @ref is_number_unsigned() -- check if value is an unsigned integer - number - @sa see @ref is_number_float() -- check if value is a floating-point number - - @since version 1.0.0 - */ - constexpr bool is_number() const noexcept - { - return is_number_integer() || is_number_float(); - } - - /*! - @brief return whether value is an integer number - - This function returns true if and only if the JSON value is a signed or - unsigned integer number. This excludes floating-point values. - - @return `true` if type is an integer or unsigned integer number, `false` - otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_number_integer()` for all - JSON types.,is_number_integer} - - @sa see @ref is_number() -- check if value is a number - @sa see @ref is_number_unsigned() -- check if value is an unsigned integer - number - @sa see @ref is_number_float() -- check if value is a floating-point number - - @since version 1.0.0 - */ - constexpr bool is_number_integer() const noexcept - { - return m_type == value_t::number_integer || m_type == value_t::number_unsigned; - } - - /*! - @brief return whether value is an unsigned integer number - - This function returns true if and only if the JSON value is an unsigned - integer number. This excludes floating-point and signed integer values. - - @return `true` if type is an unsigned integer number, `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_number_unsigned()` for all - JSON types.,is_number_unsigned} - - @sa see @ref is_number() -- check if value is a number - @sa see @ref is_number_integer() -- check if value is an integer or unsigned - integer number - @sa see @ref is_number_float() -- check if value is a floating-point number - - @since version 2.0.0 - */ - constexpr bool is_number_unsigned() const noexcept - { - return m_type == value_t::number_unsigned; - } - - /*! - @brief return whether value is a floating-point number - - This function returns true if and only if the JSON value is a - floating-point number. This excludes signed and unsigned integer values. - - @return `true` if type is a floating-point number, `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_number_float()` for all - JSON types.,is_number_float} - - @sa see @ref is_number() -- check if value is number - @sa see @ref is_number_integer() -- check if value is an integer number - @sa see @ref is_number_unsigned() -- check if value is an unsigned integer - number - - @since version 1.0.0 - */ - constexpr bool is_number_float() const noexcept - { - return m_type == value_t::number_float; - } - - /*! - @brief return whether value is an object - - This function returns true if and only if the JSON value is an object. - - @return `true` if type is object, `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_object()` for all JSON - types.,is_object} - - @since version 1.0.0 - */ - constexpr bool is_object() const noexcept - { - return m_type == value_t::object; - } - - /*! - @brief return whether value is an array - - This function returns true if and only if the JSON value is an array. - - @return `true` if type is array, `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_array()` for all JSON - types.,is_array} - - @since version 1.0.0 - */ - constexpr bool is_array() const noexcept - { - return m_type == value_t::array; - } - - /*! - @brief return whether value is a string - - This function returns true if and only if the JSON value is a string. - - @return `true` if type is string, `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_string()` for all JSON - types.,is_string} - - @since version 1.0.0 - */ - constexpr bool is_string() const noexcept - { - return m_type == value_t::string; - } - - /*! - @brief return whether value is a binary array - - This function returns true if and only if the JSON value is a binary array. - - @return `true` if type is binary array, `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_binary()` for all JSON - types.,is_binary} - - @since version 3.8.0 - */ - constexpr bool is_binary() const noexcept - { - return m_type == value_t::binary; - } - - /*! - @brief return whether value is discarded - - This function returns true if and only if the JSON value was discarded - during parsing with a callback function (see @ref parser_callback_t). - - @note This function will always be `false` for JSON values after parsing. - That is, discarded values can only occur during parsing, but will be - removed when inside a structured value or replaced by null in other cases. - - @return `true` if type is discarded, `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_discarded()` for all JSON - types.,is_discarded} - - @since version 1.0.0 - */ - constexpr bool is_discarded() const noexcept - { - return m_type == value_t::discarded; - } - - /*! - @brief return the type of the JSON value (implicit) - - Implicitly return the type of the JSON value as a value from the @ref - value_t enumeration. - - @return the type of the JSON value - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies the @ref value_t operator for - all JSON types.,operator__value_t} - - @sa see @ref type() -- return the type of the JSON value (explicit) - @sa see @ref type_name() -- return the type as string - - @since version 1.0.0 - */ - constexpr operator value_t() const noexcept - { - return m_type; - } - - /// @} - - private: - ////////////////// - // value access // - ////////////////// - - /// get a boolean (explicit) - boolean_t get_impl(boolean_t* /*unused*/) const - { - if (JSON_HEDLEY_LIKELY(is_boolean())) - { - return m_value.boolean; - } - - JSON_THROW(type_error::create(302, "type must be boolean, but is " + std::string(type_name()), *this)); - } - - /// get a pointer to the value (object) - object_t* get_impl_ptr(object_t* /*unused*/) noexcept - { - return is_object() ? m_value.object : nullptr; - } - - /// get a pointer to the value (object) - constexpr const object_t* get_impl_ptr(const object_t* /*unused*/) const noexcept - { - return is_object() ? m_value.object : nullptr; - } - - /// get a pointer to the value (array) - array_t* get_impl_ptr(array_t* /*unused*/) noexcept - { - return is_array() ? m_value.array : nullptr; - } - - /// get a pointer to the value (array) - constexpr const array_t* get_impl_ptr(const array_t* /*unused*/) const noexcept - { - return is_array() ? m_value.array : nullptr; - } - - /// get a pointer to the value (string) - string_t* get_impl_ptr(string_t* /*unused*/) noexcept - { - return is_string() ? m_value.string : nullptr; - } - - /// get a pointer to the value (string) - constexpr const string_t* get_impl_ptr(const string_t* /*unused*/) const noexcept - { - return is_string() ? m_value.string : nullptr; - } - - /// get a pointer to the value (boolean) - boolean_t* get_impl_ptr(boolean_t* /*unused*/) noexcept - { - return is_boolean() ? &m_value.boolean : nullptr; - } - - /// get a pointer to the value (boolean) - constexpr const boolean_t* get_impl_ptr(const boolean_t* /*unused*/) const noexcept - { - return is_boolean() ? &m_value.boolean : nullptr; - } - - /// get a pointer to the value (integer number) - number_integer_t* get_impl_ptr(number_integer_t* /*unused*/) noexcept - { - return is_number_integer() ? &m_value.number_integer : nullptr; - } - - /// get a pointer to the value (integer number) - constexpr const number_integer_t* get_impl_ptr(const number_integer_t* /*unused*/) const noexcept - { - return is_number_integer() ? &m_value.number_integer : nullptr; - } - - /// get a pointer to the value (unsigned number) - number_unsigned_t* get_impl_ptr(number_unsigned_t* /*unused*/) noexcept - { - return is_number_unsigned() ? &m_value.number_unsigned : nullptr; - } - - /// get a pointer to the value (unsigned number) - constexpr const number_unsigned_t* get_impl_ptr(const number_unsigned_t* /*unused*/) const noexcept - { - return is_number_unsigned() ? &m_value.number_unsigned : nullptr; - } - - /// get a pointer to the value (floating-point number) - number_float_t* get_impl_ptr(number_float_t* /*unused*/) noexcept - { - return is_number_float() ? &m_value.number_float : nullptr; - } - - /// get a pointer to the value (floating-point number) - constexpr const number_float_t* get_impl_ptr(const number_float_t* /*unused*/) const noexcept - { - return is_number_float() ? &m_value.number_float : nullptr; - } - - /// get a pointer to the value (binary) - binary_t* get_impl_ptr(binary_t* /*unused*/) noexcept - { - return is_binary() ? m_value.binary : nullptr; - } - - /// get a pointer to the value (binary) - constexpr const binary_t* get_impl_ptr(const binary_t* /*unused*/) const noexcept - { - return is_binary() ? m_value.binary : nullptr; - } - - /*! - @brief helper function to implement get_ref() - - This function helps to implement get_ref() without code duplication for - const and non-const overloads - - @tparam ThisType will be deduced as `basic_json` or `const basic_json` - - @throw type_error.303 if ReferenceType does not match underlying value - type of the current JSON - */ - template - static ReferenceType get_ref_impl(ThisType& obj) - { - // delegate the call to get_ptr<>() - auto* ptr = obj.template get_ptr::type>(); - - if (JSON_HEDLEY_LIKELY(ptr != nullptr)) - { - return *ptr; - } - - JSON_THROW(type_error::create(303, "incompatible ReferenceType for get_ref, actual type is " + std::string(obj.type_name()), obj)); - } - - public: - /// @name value access - /// Direct access to the stored value of a JSON value. - /// @{ - - /*! - @brief get a pointer value (implicit) - - Implicit pointer access to the internally stored JSON value. No copies are - made. - - @warning Writing data to the pointee of the result yields an undefined - state. - - @tparam PointerType pointer type; must be a pointer to @ref array_t, @ref - object_t, @ref string_t, @ref boolean_t, @ref number_integer_t, - @ref number_unsigned_t, or @ref number_float_t. Enforced by a static - assertion. - - @return pointer to the internally stored JSON value if the requested - pointer type @a PointerType fits to the JSON value; `nullptr` otherwise - - @complexity Constant. - - @liveexample{The example below shows how pointers to internal values of a - JSON value can be requested. Note that no type conversions are made and a - `nullptr` is returned if the value and the requested pointer type does not - match.,get_ptr} - - @since version 1.0.0 - */ - template::value, int>::type = 0> - auto get_ptr() noexcept -> decltype(std::declval().get_impl_ptr(std::declval())) - { - // delegate the call to get_impl_ptr<>() - return get_impl_ptr(static_cast(nullptr)); - } - - /*! - @brief get a pointer value (implicit) - @copydoc get_ptr() - */ - template < typename PointerType, typename std::enable_if < - std::is_pointer::value&& - std::is_const::type>::value, int >::type = 0 > - constexpr auto get_ptr() const noexcept -> decltype(std::declval().get_impl_ptr(std::declval())) - { - // delegate the call to get_impl_ptr<>() const - return get_impl_ptr(static_cast(nullptr)); - } - - private: - /*! - @brief get a value (explicit) - - Explicit type conversion between the JSON value and a compatible value - which is [CopyConstructible](https://en.cppreference.com/w/cpp/named_req/CopyConstructible) - and [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible). - The value is converted by calling the @ref json_serializer - `from_json()` method. - - The function is equivalent to executing - @code {.cpp} - ValueType ret; - JSONSerializer::from_json(*this, ret); - return ret; - @endcode - - This overloads is chosen if: - - @a ValueType is not @ref basic_json, - - @ref json_serializer has a `from_json()` method of the form - `void from_json(const basic_json&, ValueType&)`, and - - @ref json_serializer does not have a `from_json()` method of - the form `ValueType from_json(const basic_json&)` - - @tparam ValueType the returned value type - - @return copy of the JSON value, converted to @a ValueType - - @throw what @ref json_serializer `from_json()` method throws - - @liveexample{The example below shows several conversions from JSON values - to other types. There a few things to note: (1) Floating-point numbers can - be converted to integers\, (2) A JSON array can be converted to a standard - `std::vector`\, (3) A JSON object can be converted to C++ - associative containers such as `std::unordered_map`.,get__ValueType_const} - - @since version 2.1.0 - */ - template < typename ValueType, - detail::enable_if_t < - detail::is_default_constructible::value&& - detail::has_from_json::value, - int > = 0 > - ValueType get_impl(detail::priority_tag<0> /*unused*/) const noexcept(noexcept( - JSONSerializer::from_json(std::declval(), std::declval()))) - { - auto ret = ValueType(); - JSONSerializer::from_json(*this, ret); - return ret; - } - - /*! - @brief get a value (explicit); special case - - Explicit type conversion between the JSON value and a compatible value - which is **not** [CopyConstructible](https://en.cppreference.com/w/cpp/named_req/CopyConstructible) - and **not** [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible). - The value is converted by calling the @ref json_serializer - `from_json()` method. - - The function is equivalent to executing - @code {.cpp} - return JSONSerializer::from_json(*this); - @endcode - - This overloads is chosen if: - - @a ValueType is not @ref basic_json and - - @ref json_serializer has a `from_json()` method of the form - `ValueType from_json(const basic_json&)` - - @note If @ref json_serializer has both overloads of - `from_json()`, this one is chosen. - - @tparam ValueType the returned value type - - @return copy of the JSON value, converted to @a ValueType - - @throw what @ref json_serializer `from_json()` method throws - - @since version 2.1.0 - */ - template < typename ValueType, - detail::enable_if_t < - detail::has_non_default_from_json::value, - int > = 0 > - ValueType get_impl(detail::priority_tag<1> /*unused*/) const noexcept(noexcept( - JSONSerializer::from_json(std::declval()))) - { - return JSONSerializer::from_json(*this); - } - - /*! - @brief get special-case overload - - This overloads converts the current @ref basic_json in a different - @ref basic_json type - - @tparam BasicJsonType == @ref basic_json - - @return a copy of *this, converted into @a BasicJsonType - - @complexity Depending on the implementation of the called `from_json()` - method. - - @since version 3.2.0 - */ - template < typename BasicJsonType, - detail::enable_if_t < - detail::is_basic_json::value, - int > = 0 > - BasicJsonType get_impl(detail::priority_tag<2> /*unused*/) const - { - return *this; - } - - /*! - @brief get special-case overload - - This overloads avoids a lot of template boilerplate, it can be seen as the - identity method - - @tparam BasicJsonType == @ref basic_json - - @return a copy of *this - - @complexity Constant. - - @since version 2.1.0 - */ - template::value, - int> = 0> - basic_json get_impl(detail::priority_tag<3> /*unused*/) const - { - return *this; - } - - /*! - @brief get a pointer value (explicit) - @copydoc get() - */ - template::value, - int> = 0> - constexpr auto get_impl(detail::priority_tag<4> /*unused*/) const noexcept - -> decltype(std::declval().template get_ptr()) - { - // delegate the call to get_ptr - return get_ptr(); - } - - public: - /*! - @brief get a (pointer) value (explicit) - - Performs explicit type conversion between the JSON value and a compatible value if required. - - - If the requested type is a pointer to the internally stored JSON value that pointer is returned. - No copies are made. - - - If the requested type is the current @ref basic_json, or a different @ref basic_json convertible - from the current @ref basic_json. - - - Otherwise the value is converted by calling the @ref json_serializer `from_json()` - method. - - @tparam ValueTypeCV the provided value type - @tparam ValueType the returned value type - - @return copy of the JSON value, converted to @tparam ValueType if necessary - - @throw what @ref json_serializer `from_json()` method throws if conversion is required - - @since version 2.1.0 - */ - template < typename ValueTypeCV, typename ValueType = detail::uncvref_t> -#if defined(JSON_HAS_CPP_14) - constexpr -#endif - auto get() const noexcept( - noexcept(std::declval().template get_impl(detail::priority_tag<4> {}))) - -> decltype(std::declval().template get_impl(detail::priority_tag<4> {})) - { - // we cannot static_assert on ValueTypeCV being non-const, because - // there is support for get(), which is why we - // still need the uncvref - static_assert(!std::is_reference::value, - "get() cannot be used with reference types, you might want to use get_ref()"); - return get_impl(detail::priority_tag<4> {}); - } - - /*! - @brief get a pointer value (explicit) - - Explicit pointer access to the internally stored JSON value. No copies are - made. - - @warning The pointer becomes invalid if the underlying JSON object - changes. - - @tparam PointerType pointer type; must be a pointer to @ref array_t, @ref - object_t, @ref string_t, @ref boolean_t, @ref number_integer_t, - @ref number_unsigned_t, or @ref number_float_t. - - @return pointer to the internally stored JSON value if the requested - pointer type @a PointerType fits to the JSON value; `nullptr` otherwise - - @complexity Constant. - - @liveexample{The example below shows how pointers to internal values of a - JSON value can be requested. Note that no type conversions are made and a - `nullptr` is returned if the value and the requested pointer type does not - match.,get__PointerType} - - @sa see @ref get_ptr() for explicit pointer-member access - - @since version 1.0.0 - */ - template::value, int>::type = 0> - auto get() noexcept -> decltype(std::declval().template get_ptr()) - { - // delegate the call to get_ptr - return get_ptr(); - } - - /*! - @brief get a value (explicit) - - Explicit type conversion between the JSON value and a compatible value. - The value is filled into the input parameter by calling the @ref json_serializer - `from_json()` method. - - The function is equivalent to executing - @code {.cpp} - ValueType v; - JSONSerializer::from_json(*this, v); - @endcode - - This overloads is chosen if: - - @a ValueType is not @ref basic_json, - - @ref json_serializer has a `from_json()` method of the form - `void from_json(const basic_json&, ValueType&)`, and - - @tparam ValueType the input parameter type. - - @return the input parameter, allowing chaining calls. - - @throw what @ref json_serializer `from_json()` method throws - - @liveexample{The example below shows several conversions from JSON values - to other types. There a few things to note: (1) Floating-point numbers can - be converted to integers\, (2) A JSON array can be converted to a standard - `std::vector`\, (3) A JSON object can be converted to C++ - associative containers such as `std::unordered_map`.,get_to} - - @since version 3.3.0 - */ - template < typename ValueType, - detail::enable_if_t < - !detail::is_basic_json::value&& - detail::has_from_json::value, - int > = 0 > - ValueType & get_to(ValueType& v) const noexcept(noexcept( - JSONSerializer::from_json(std::declval(), v))) - { - JSONSerializer::from_json(*this, v); - return v; - } - - // specialization to allow to call get_to with a basic_json value - // see https://github.com/nlohmann/json/issues/2175 - template::value, - int> = 0> - ValueType & get_to(ValueType& v) const - { - v = *this; - return v; - } - - template < - typename T, std::size_t N, - typename Array = T (&)[N], // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) - detail::enable_if_t < - detail::has_from_json::value, int > = 0 > - Array get_to(T (&v)[N]) const // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) - noexcept(noexcept(JSONSerializer::from_json( - std::declval(), v))) - { - JSONSerializer::from_json(*this, v); - return v; - } - - /*! - @brief get a reference value (implicit) - - Implicit reference access to the internally stored JSON value. No copies - are made. - - @warning Writing data to the referee of the result yields an undefined - state. - - @tparam ReferenceType reference type; must be a reference to @ref array_t, - @ref object_t, @ref string_t, @ref boolean_t, @ref number_integer_t, or - @ref number_float_t. Enforced by static assertion. - - @return reference to the internally stored JSON value if the requested - reference type @a ReferenceType fits to the JSON value; throws - type_error.303 otherwise - - @throw type_error.303 in case passed type @a ReferenceType is incompatible - with the stored JSON value; see example below - - @complexity Constant. - - @liveexample{The example shows several calls to `get_ref()`.,get_ref} - - @since version 1.1.0 - */ - template::value, int>::type = 0> - ReferenceType get_ref() - { - // delegate call to get_ref_impl - return get_ref_impl(*this); - } - - /*! - @brief get a reference value (implicit) - @copydoc get_ref() - */ - template < typename ReferenceType, typename std::enable_if < - std::is_reference::value&& - std::is_const::type>::value, int >::type = 0 > - ReferenceType get_ref() const - { - // delegate call to get_ref_impl - return get_ref_impl(*this); - } - - /*! - @brief get a value (implicit) - - Implicit type conversion between the JSON value and a compatible value. - The call is realized by calling @ref get() const. - - @tparam ValueType non-pointer type compatible to the JSON value, for - instance `int` for JSON integer numbers, `bool` for JSON booleans, or - `std::vector` types for JSON arrays. The character type of @ref string_t - as well as an initializer list of this type is excluded to avoid - ambiguities as these types implicitly convert to `std::string`. - - @return copy of the JSON value, converted to type @a ValueType - - @throw type_error.302 in case passed type @a ValueType is incompatible - to the JSON value type (e.g., the JSON value is of type boolean, but a - string is requested); see example below - - @complexity Linear in the size of the JSON value. - - @liveexample{The example below shows several conversions from JSON values - to other types. There a few things to note: (1) Floating-point numbers can - be converted to integers\, (2) A JSON array can be converted to a standard - `std::vector`\, (3) A JSON object can be converted to C++ - associative containers such as `std::unordered_map`.,operator__ValueType} - - @since version 1.0.0 - */ - template < typename ValueType, typename std::enable_if < - detail::conjunction < - detail::negation>, - detail::negation>>, - detail::negation>, - detail::negation>, - detail::negation>>, - -#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914)) - detail::negation>, -#endif - detail::is_detected_lazy - >::value, int >::type = 0 > - JSON_EXPLICIT operator ValueType() const - { - // delegate the call to get<>() const - return get(); - } - - /*! - @return reference to the binary value - - @throw type_error.302 if the value is not binary - - @sa see @ref is_binary() to check if the value is binary - - @since version 3.8.0 - */ - binary_t& get_binary() - { - if (!is_binary()) - { - JSON_THROW(type_error::create(302, "type must be binary, but is " + std::string(type_name()), *this)); - } - - return *get_ptr(); - } - - /// @copydoc get_binary() - const binary_t& get_binary() const - { - if (!is_binary()) - { - JSON_THROW(type_error::create(302, "type must be binary, but is " + std::string(type_name()), *this)); - } - - return *get_ptr(); - } - - /// @} - - - //////////////////// - // element access // - //////////////////// - - /// @name element access - /// Access to the JSON value. - /// @{ - - /*! - @brief access specified array element with bounds checking - - Returns a reference to the element at specified location @a idx, with - bounds checking. - - @param[in] idx index of the element to access - - @return reference to the element at index @a idx - - @throw type_error.304 if the JSON value is not an array; in this case, - calling `at` with an index makes no sense. See example below. - @throw out_of_range.401 if the index @a idx is out of range of the array; - that is, `idx >= size()`. See example below. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes in the JSON value. - - @complexity Constant. - - @since version 1.0.0 - - @liveexample{The example below shows how array elements can be read and - written using `at()`. It also demonstrates the different exceptions that - can be thrown.,at__size_type} - */ - reference at(size_type idx) - { - // at only works for arrays - if (JSON_HEDLEY_LIKELY(is_array())) - { - JSON_TRY - { - return set_parent(m_value.array->at(idx)); - } - JSON_CATCH (std::out_of_range&) - { - // create better exception explanation - JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range", *this)); - } - } - else - { - JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name()), *this)); - } - } - - /*! - @brief access specified array element with bounds checking - - Returns a const reference to the element at specified location @a idx, - with bounds checking. - - @param[in] idx index of the element to access - - @return const reference to the element at index @a idx - - @throw type_error.304 if the JSON value is not an array; in this case, - calling `at` with an index makes no sense. See example below. - @throw out_of_range.401 if the index @a idx is out of range of the array; - that is, `idx >= size()`. See example below. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes in the JSON value. - - @complexity Constant. - - @since version 1.0.0 - - @liveexample{The example below shows how array elements can be read using - `at()`. It also demonstrates the different exceptions that can be thrown., - at__size_type_const} - */ - const_reference at(size_type idx) const - { - // at only works for arrays - if (JSON_HEDLEY_LIKELY(is_array())) - { - JSON_TRY - { - return m_value.array->at(idx); - } - JSON_CATCH (std::out_of_range&) - { - // create better exception explanation - JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range", *this)); - } - } - else - { - JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name()), *this)); - } - } - - /*! - @brief access specified object element with bounds checking - - Returns a reference to the element at with specified key @a key, with - bounds checking. - - @param[in] key key of the element to access - - @return reference to the element at key @a key - - @throw type_error.304 if the JSON value is not an object; in this case, - calling `at` with a key makes no sense. See example below. - @throw out_of_range.403 if the key @a key is is not stored in the object; - that is, `find(key) == end()`. See example below. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes in the JSON value. - - @complexity Logarithmic in the size of the container. - - @sa see @ref operator[](const typename object_t::key_type&) for unchecked - access by reference - @sa see @ref value() for access by value with a default value - - @since version 1.0.0 - - @liveexample{The example below shows how object elements can be read and - written using `at()`. It also demonstrates the different exceptions that - can be thrown.,at__object_t_key_type} - */ - reference at(const typename object_t::key_type& key) - { - // at only works for objects - if (JSON_HEDLEY_LIKELY(is_object())) - { - JSON_TRY - { - return set_parent(m_value.object->at(key)); - } - JSON_CATCH (std::out_of_range&) - { - // create better exception explanation - JSON_THROW(out_of_range::create(403, "key '" + key + "' not found", *this)); - } - } - else - { - JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name()), *this)); - } - } - - /*! - @brief access specified object element with bounds checking - - Returns a const reference to the element at with specified key @a key, - with bounds checking. - - @param[in] key key of the element to access - - @return const reference to the element at key @a key - - @throw type_error.304 if the JSON value is not an object; in this case, - calling `at` with a key makes no sense. See example below. - @throw out_of_range.403 if the key @a key is is not stored in the object; - that is, `find(key) == end()`. See example below. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes in the JSON value. - - @complexity Logarithmic in the size of the container. - - @sa see @ref operator[](const typename object_t::key_type&) for unchecked - access by reference - @sa see @ref value() for access by value with a default value - - @since version 1.0.0 - - @liveexample{The example below shows how object elements can be read using - `at()`. It also demonstrates the different exceptions that can be thrown., - at__object_t_key_type_const} - */ - const_reference at(const typename object_t::key_type& key) const - { - // at only works for objects - if (JSON_HEDLEY_LIKELY(is_object())) - { - JSON_TRY - { - return m_value.object->at(key); - } - JSON_CATCH (std::out_of_range&) - { - // create better exception explanation - JSON_THROW(out_of_range::create(403, "key '" + key + "' not found", *this)); - } - } - else - { - JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name()), *this)); - } - } - - /*! - @brief access specified array element - - Returns a reference to the element at specified location @a idx. - - @note If @a idx is beyond the range of the array (i.e., `idx >= size()`), - then the array is silently filled up with `null` values to make `idx` a - valid reference to the last stored element. - - @param[in] idx index of the element to access - - @return reference to the element at index @a idx - - @throw type_error.305 if the JSON value is not an array or null; in that - cases, using the [] operator with an index makes no sense. - - @complexity Constant if @a idx is in the range of the array. Otherwise - linear in `idx - size()`. - - @liveexample{The example below shows how array elements can be read and - written using `[]` operator. Note the addition of `null` - values.,operatorarray__size_type} - - @since version 1.0.0 - */ - reference operator[](size_type idx) - { - // implicitly convert null value to an empty array - if (is_null()) - { - m_type = value_t::array; - m_value.array = create(); - assert_invariant(); - } - - // operator[] only works for arrays - if (JSON_HEDLEY_LIKELY(is_array())) - { - // fill up array with null values if given idx is outside range - if (idx >= m_value.array->size()) - { -#if JSON_DIAGNOSTICS - // remember array size & capacity before resizing - const auto old_size = m_value.array->size(); - const auto old_capacity = m_value.array->capacity(); -#endif - m_value.array->resize(idx + 1); - -#if JSON_DIAGNOSTICS - if (JSON_HEDLEY_UNLIKELY(m_value.array->capacity() != old_capacity)) - { - // capacity has changed: update all parents - set_parents(); - } - else - { - // set parent for values added above - set_parents(begin() + static_cast(old_size), static_cast(idx + 1 - old_size)); - } -#endif - assert_invariant(); - } - - return m_value.array->operator[](idx); - } - - JSON_THROW(type_error::create(305, "cannot use operator[] with a numeric argument with " + std::string(type_name()), *this)); - } - - /*! - @brief access specified array element - - Returns a const reference to the element at specified location @a idx. - - @param[in] idx index of the element to access - - @return const reference to the element at index @a idx - - @throw type_error.305 if the JSON value is not an array; in that case, - using the [] operator with an index makes no sense. - - @complexity Constant. - - @liveexample{The example below shows how array elements can be read using - the `[]` operator.,operatorarray__size_type_const} - - @since version 1.0.0 - */ - const_reference operator[](size_type idx) const - { - // const operator[] only works for arrays - if (JSON_HEDLEY_LIKELY(is_array())) - { - return m_value.array->operator[](idx); - } - - JSON_THROW(type_error::create(305, "cannot use operator[] with a numeric argument with " + std::string(type_name()), *this)); - } - - /*! - @brief access specified object element - - Returns a reference to the element at with specified key @a key. - - @note If @a key is not found in the object, then it is silently added to - the object and filled with a `null` value to make `key` a valid reference. - In case the value was `null` before, it is converted to an object. - - @param[in] key key of the element to access - - @return reference to the element at key @a key - - @throw type_error.305 if the JSON value is not an object or null; in that - cases, using the [] operator with a key makes no sense. - - @complexity Logarithmic in the size of the container. - - @liveexample{The example below shows how object elements can be read and - written using the `[]` operator.,operatorarray__key_type} - - @sa see @ref at(const typename object_t::key_type&) for access by reference - with range checking - @sa see @ref value() for access by value with a default value - - @since version 1.0.0 - */ - reference operator[](const typename object_t::key_type& key) - { - // implicitly convert null value to an empty object - if (is_null()) - { - m_type = value_t::object; - m_value.object = create(); - assert_invariant(); - } - - // operator[] only works for objects - if (JSON_HEDLEY_LIKELY(is_object())) - { - return set_parent(m_value.object->operator[](key)); - } - - JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()), *this)); - } - - /*! - @brief read-only access specified object element - - Returns a const reference to the element at with specified key @a key. No - bounds checking is performed. - - @warning If the element with key @a key does not exist, the behavior is - undefined. - - @param[in] key key of the element to access - - @return const reference to the element at key @a key - - @pre The element with key @a key must exist. **This precondition is - enforced with an assertion.** - - @throw type_error.305 if the JSON value is not an object; in that case, - using the [] operator with a key makes no sense. - - @complexity Logarithmic in the size of the container. - - @liveexample{The example below shows how object elements can be read using - the `[]` operator.,operatorarray__key_type_const} - - @sa see @ref at(const typename object_t::key_type&) for access by reference - with range checking - @sa see @ref value() for access by value with a default value - - @since version 1.0.0 - */ - const_reference operator[](const typename object_t::key_type& key) const - { - // const operator[] only works for objects - if (JSON_HEDLEY_LIKELY(is_object())) - { - JSON_ASSERT(m_value.object->find(key) != m_value.object->end()); - return m_value.object->find(key)->second; - } - - JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()), *this)); - } - - /*! - @brief access specified object element - - Returns a reference to the element at with specified key @a key. - - @note If @a key is not found in the object, then it is silently added to - the object and filled with a `null` value to make `key` a valid reference. - In case the value was `null` before, it is converted to an object. - - @param[in] key key of the element to access - - @return reference to the element at key @a key - - @throw type_error.305 if the JSON value is not an object or null; in that - cases, using the [] operator with a key makes no sense. - - @complexity Logarithmic in the size of the container. - - @liveexample{The example below shows how object elements can be read and - written using the `[]` operator.,operatorarray__key_type} - - @sa see @ref at(const typename object_t::key_type&) for access by reference - with range checking - @sa see @ref value() for access by value with a default value - - @since version 1.1.0 - */ - template - JSON_HEDLEY_NON_NULL(2) - reference operator[](T* key) - { - // implicitly convert null to object - if (is_null()) - { - m_type = value_t::object; - m_value = value_t::object; - assert_invariant(); - } - - // at only works for objects - if (JSON_HEDLEY_LIKELY(is_object())) - { - return set_parent(m_value.object->operator[](key)); - } - - JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()), *this)); - } - - /*! - @brief read-only access specified object element - - Returns a const reference to the element at with specified key @a key. No - bounds checking is performed. - - @warning If the element with key @a key does not exist, the behavior is - undefined. - - @param[in] key key of the element to access - - @return const reference to the element at key @a key - - @pre The element with key @a key must exist. **This precondition is - enforced with an assertion.** - - @throw type_error.305 if the JSON value is not an object; in that case, - using the [] operator with a key makes no sense. - - @complexity Logarithmic in the size of the container. - - @liveexample{The example below shows how object elements can be read using - the `[]` operator.,operatorarray__key_type_const} - - @sa see @ref at(const typename object_t::key_type&) for access by reference - with range checking - @sa see @ref value() for access by value with a default value - - @since version 1.1.0 - */ - template - JSON_HEDLEY_NON_NULL(2) - const_reference operator[](T* key) const - { - // at only works for objects - if (JSON_HEDLEY_LIKELY(is_object())) - { - JSON_ASSERT(m_value.object->find(key) != m_value.object->end()); - return m_value.object->find(key)->second; - } - - JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()), *this)); - } - - /*! - @brief access specified object element with default value - - Returns either a copy of an object's element at the specified key @a key - or a given default value if no element with key @a key exists. - - The function is basically equivalent to executing - @code {.cpp} - try { - return at(key); - } catch(out_of_range) { - return default_value; - } - @endcode - - @note Unlike @ref at(const typename object_t::key_type&), this function - does not throw if the given key @a key was not found. - - @note Unlike @ref operator[](const typename object_t::key_type& key), this - function does not implicitly add an element to the position defined by @a - key. This function is furthermore also applicable to const objects. - - @param[in] key key of the element to access - @param[in] default_value the value to return if @a key is not found - - @tparam ValueType type compatible to JSON values, for instance `int` for - JSON integer numbers, `bool` for JSON booleans, or `std::vector` types for - JSON arrays. Note the type of the expected value at @a key and the default - value @a default_value must be compatible. - - @return copy of the element at key @a key or @a default_value if @a key - is not found - - @throw type_error.302 if @a default_value does not match the type of the - value at @a key - @throw type_error.306 if the JSON value is not an object; in that case, - using `value()` with a key makes no sense. - - @complexity Logarithmic in the size of the container. - - @liveexample{The example below shows how object elements can be queried - with a default value.,basic_json__value} - - @sa see @ref at(const typename object_t::key_type&) for access by reference - with range checking - @sa see @ref operator[](const typename object_t::key_type&) for unchecked - access by reference - - @since version 1.0.0 - */ - // using std::is_convertible in a std::enable_if will fail when using explicit conversions - template < class ValueType, typename std::enable_if < - detail::is_getable::value - && !std::is_same::value, int >::type = 0 > - ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const - { - // at only works for objects - if (JSON_HEDLEY_LIKELY(is_object())) - { - // if key is found, return value and given default value otherwise - const auto it = find(key); - if (it != end()) - { - return it->template get(); - } - - return default_value; - } - - JSON_THROW(type_error::create(306, "cannot use value() with " + std::string(type_name()), *this)); - } - - /*! - @brief overload for a default value of type const char* - @copydoc basic_json::value(const typename object_t::key_type&, const ValueType&) const - */ - string_t value(const typename object_t::key_type& key, const char* default_value) const - { - return value(key, string_t(default_value)); - } - - /*! - @brief access specified object element via JSON Pointer with default value - - Returns either a copy of an object's element at the specified key @a key - or a given default value if no element with key @a key exists. - - The function is basically equivalent to executing - @code {.cpp} - try { - return at(ptr); - } catch(out_of_range) { - return default_value; - } - @endcode - - @note Unlike @ref at(const json_pointer&), this function does not throw - if the given key @a key was not found. - - @param[in] ptr a JSON pointer to the element to access - @param[in] default_value the value to return if @a ptr found no value - - @tparam ValueType type compatible to JSON values, for instance `int` for - JSON integer numbers, `bool` for JSON booleans, or `std::vector` types for - JSON arrays. Note the type of the expected value at @a key and the default - value @a default_value must be compatible. - - @return copy of the element at key @a key or @a default_value if @a key - is not found - - @throw type_error.302 if @a default_value does not match the type of the - value at @a ptr - @throw type_error.306 if the JSON value is not an object; in that case, - using `value()` with a key makes no sense. - - @complexity Logarithmic in the size of the container. - - @liveexample{The example below shows how object elements can be queried - with a default value.,basic_json__value_ptr} - - @sa see @ref operator[](const json_pointer&) for unchecked access by reference - - @since version 2.0.2 - */ - template::value, int>::type = 0> - ValueType value(const json_pointer& ptr, const ValueType& default_value) const - { - // at only works for objects - if (JSON_HEDLEY_LIKELY(is_object())) - { - // if pointer resolves a value, return it or use default value - JSON_TRY - { - return ptr.get_checked(this).template get(); - } - JSON_INTERNAL_CATCH (out_of_range&) - { - return default_value; - } - } - - JSON_THROW(type_error::create(306, "cannot use value() with " + std::string(type_name()), *this)); - } - - /*! - @brief overload for a default value of type const char* - @copydoc basic_json::value(const json_pointer&, ValueType) const - */ - JSON_HEDLEY_NON_NULL(3) - string_t value(const json_pointer& ptr, const char* default_value) const - { - return value(ptr, string_t(default_value)); - } - - /*! - @brief access the first element - - Returns a reference to the first element in the container. For a JSON - container `c`, the expression `c.front()` is equivalent to `*c.begin()`. - - @return In case of a structured type (array or object), a reference to the - first element is returned. In case of number, string, boolean, or binary - values, a reference to the value is returned. - - @complexity Constant. - - @pre The JSON value must not be `null` (would throw `std::out_of_range`) - or an empty array or object (undefined behavior, **guarded by - assertions**). - @post The JSON value remains unchanged. - - @throw invalid_iterator.214 when called on `null` value - - @liveexample{The following code shows an example for `front()`.,front} - - @sa see @ref back() -- access the last element - - @since version 1.0.0 - */ - reference front() - { - return *begin(); - } - - /*! - @copydoc basic_json::front() - */ - const_reference front() const - { - return *cbegin(); - } - - /*! - @brief access the last element - - Returns a reference to the last element in the container. For a JSON - container `c`, the expression `c.back()` is equivalent to - @code {.cpp} - auto tmp = c.end(); - --tmp; - return *tmp; - @endcode - - @return In case of a structured type (array or object), a reference to the - last element is returned. In case of number, string, boolean, or binary - values, a reference to the value is returned. - - @complexity Constant. - - @pre The JSON value must not be `null` (would throw `std::out_of_range`) - or an empty array or object (undefined behavior, **guarded by - assertions**). - @post The JSON value remains unchanged. - - @throw invalid_iterator.214 when called on a `null` value. See example - below. - - @liveexample{The following code shows an example for `back()`.,back} - - @sa see @ref front() -- access the first element - - @since version 1.0.0 - */ - reference back() - { - auto tmp = end(); - --tmp; - return *tmp; - } - - /*! - @copydoc basic_json::back() - */ - const_reference back() const - { - auto tmp = cend(); - --tmp; - return *tmp; - } - - /*! - @brief remove element given an iterator - - Removes the element specified by iterator @a pos. The iterator @a pos must - be valid and dereferenceable. Thus the `end()` iterator (which is valid, - but is not dereferenceable) cannot be used as a value for @a pos. - - If called on a primitive type other than `null`, the resulting JSON value - will be `null`. - - @param[in] pos iterator to the element to remove - @return Iterator following the last removed element. If the iterator @a - pos refers to the last element, the `end()` iterator is returned. - - @tparam IteratorType an @ref iterator or @ref const_iterator - - @post Invalidates iterators and references at or after the point of the - erase, including the `end()` iterator. - - @throw type_error.307 if called on a `null` value; example: `"cannot use - erase() with null"` - @throw invalid_iterator.202 if called on an iterator which does not belong - to the current JSON value; example: `"iterator does not fit current - value"` - @throw invalid_iterator.205 if called on a primitive type with invalid - iterator (i.e., any iterator which is not `begin()`); example: `"iterator - out of range"` - - @complexity The complexity depends on the type: - - objects: amortized constant - - arrays: linear in distance between @a pos and the end of the container - - strings and binary: linear in the length of the member - - other types: constant - - @liveexample{The example shows the result of `erase()` for different JSON - types.,erase__IteratorType} - - @sa see @ref erase(IteratorType, IteratorType) -- removes the elements in - the given range - @sa see @ref erase(const typename object_t::key_type&) -- removes the element - from an object at the given key - @sa see @ref erase(const size_type) -- removes the element from an array at - the given index - - @since version 1.0.0 - */ - template < class IteratorType, typename std::enable_if < - std::is_same::value || - std::is_same::value, int >::type - = 0 > - IteratorType erase(IteratorType pos) - { - // make sure iterator fits the current value - if (JSON_HEDLEY_UNLIKELY(this != pos.m_object)) - { - JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", *this)); - } - - IteratorType result = end(); - - switch (m_type) - { - case value_t::boolean: - case value_t::number_float: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::string: - case value_t::binary: - { - if (JSON_HEDLEY_UNLIKELY(!pos.m_it.primitive_iterator.is_begin())) - { - JSON_THROW(invalid_iterator::create(205, "iterator out of range", *this)); - } - - if (is_string()) - { - AllocatorType alloc; - std::allocator_traits::destroy(alloc, m_value.string); - std::allocator_traits::deallocate(alloc, m_value.string, 1); - m_value.string = nullptr; - } - else if (is_binary()) - { - AllocatorType alloc; - std::allocator_traits::destroy(alloc, m_value.binary); - std::allocator_traits::deallocate(alloc, m_value.binary, 1); - m_value.binary = nullptr; - } - - m_type = value_t::null; - assert_invariant(); - break; - } - - case value_t::object: - { - result.m_it.object_iterator = m_value.object->erase(pos.m_it.object_iterator); - break; - } - - case value_t::array: - { - result.m_it.array_iterator = m_value.array->erase(pos.m_it.array_iterator); - break; - } - - case value_t::null: - case value_t::discarded: - default: - JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name()), *this)); - } - - return result; - } - - /*! - @brief remove elements given an iterator range - - Removes the element specified by the range `[first; last)`. The iterator - @a first does not need to be dereferenceable if `first == last`: erasing - an empty range is a no-op. - - If called on a primitive type other than `null`, the resulting JSON value - will be `null`. - - @param[in] first iterator to the beginning of the range to remove - @param[in] last iterator past the end of the range to remove - @return Iterator following the last removed element. If the iterator @a - second refers to the last element, the `end()` iterator is returned. - - @tparam IteratorType an @ref iterator or @ref const_iterator - - @post Invalidates iterators and references at or after the point of the - erase, including the `end()` iterator. - - @throw type_error.307 if called on a `null` value; example: `"cannot use - erase() with null"` - @throw invalid_iterator.203 if called on iterators which does not belong - to the current JSON value; example: `"iterators do not fit current value"` - @throw invalid_iterator.204 if called on a primitive type with invalid - iterators (i.e., if `first != begin()` and `last != end()`); example: - `"iterators out of range"` - - @complexity The complexity depends on the type: - - objects: `log(size()) + std::distance(first, last)` - - arrays: linear in the distance between @a first and @a last, plus linear - in the distance between @a last and end of the container - - strings and binary: linear in the length of the member - - other types: constant - - @liveexample{The example shows the result of `erase()` for different JSON - types.,erase__IteratorType_IteratorType} - - @sa see @ref erase(IteratorType) -- removes the element at a given position - @sa see @ref erase(const typename object_t::key_type&) -- removes the element - from an object at the given key - @sa see @ref erase(const size_type) -- removes the element from an array at - the given index - - @since version 1.0.0 - */ - template < class IteratorType, typename std::enable_if < - std::is_same::value || - std::is_same::value, int >::type - = 0 > - IteratorType erase(IteratorType first, IteratorType last) - { - // make sure iterator fits the current value - if (JSON_HEDLEY_UNLIKELY(this != first.m_object || this != last.m_object)) - { - JSON_THROW(invalid_iterator::create(203, "iterators do not fit current value", *this)); - } - - IteratorType result = end(); - - switch (m_type) - { - case value_t::boolean: - case value_t::number_float: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::string: - case value_t::binary: - { - if (JSON_HEDLEY_LIKELY(!first.m_it.primitive_iterator.is_begin() - || !last.m_it.primitive_iterator.is_end())) - { - JSON_THROW(invalid_iterator::create(204, "iterators out of range", *this)); - } - - if (is_string()) - { - AllocatorType alloc; - std::allocator_traits::destroy(alloc, m_value.string); - std::allocator_traits::deallocate(alloc, m_value.string, 1); - m_value.string = nullptr; - } - else if (is_binary()) - { - AllocatorType alloc; - std::allocator_traits::destroy(alloc, m_value.binary); - std::allocator_traits::deallocate(alloc, m_value.binary, 1); - m_value.binary = nullptr; - } - - m_type = value_t::null; - assert_invariant(); - break; - } - - case value_t::object: - { - result.m_it.object_iterator = m_value.object->erase(first.m_it.object_iterator, - last.m_it.object_iterator); - break; - } - - case value_t::array: - { - result.m_it.array_iterator = m_value.array->erase(first.m_it.array_iterator, - last.m_it.array_iterator); - break; - } - - case value_t::null: - case value_t::discarded: - default: - JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name()), *this)); - } - - return result; - } - - /*! - @brief remove element from a JSON object given a key - - Removes elements from a JSON object with the key value @a key. - - @param[in] key value of the elements to remove - - @return Number of elements removed. If @a ObjectType is the default - `std::map` type, the return value will always be `0` (@a key was not - found) or `1` (@a key was found). - - @post References and iterators to the erased elements are invalidated. - Other references and iterators are not affected. - - @throw type_error.307 when called on a type other than JSON object; - example: `"cannot use erase() with null"` - - @complexity `log(size()) + count(key)` - - @liveexample{The example shows the effect of `erase()`.,erase__key_type} - - @sa see @ref erase(IteratorType) -- removes the element at a given position - @sa see @ref erase(IteratorType, IteratorType) -- removes the elements in - the given range - @sa see @ref erase(const size_type) -- removes the element from an array at - the given index - - @since version 1.0.0 - */ - size_type erase(const typename object_t::key_type& key) - { - // this erase only works for objects - if (JSON_HEDLEY_LIKELY(is_object())) - { - return m_value.object->erase(key); - } - - JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name()), *this)); - } - - /*! - @brief remove element from a JSON array given an index - - Removes element from a JSON array at the index @a idx. - - @param[in] idx index of the element to remove - - @throw type_error.307 when called on a type other than JSON object; - example: `"cannot use erase() with null"` - @throw out_of_range.401 when `idx >= size()`; example: `"array index 17 - is out of range"` - - @complexity Linear in distance between @a idx and the end of the container. - - @liveexample{The example shows the effect of `erase()`.,erase__size_type} - - @sa see @ref erase(IteratorType) -- removes the element at a given position - @sa see @ref erase(IteratorType, IteratorType) -- removes the elements in - the given range - @sa see @ref erase(const typename object_t::key_type&) -- removes the element - from an object at the given key - - @since version 1.0.0 - */ - void erase(const size_type idx) - { - // this erase only works for arrays - if (JSON_HEDLEY_LIKELY(is_array())) - { - if (JSON_HEDLEY_UNLIKELY(idx >= size())) - { - JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range", *this)); - } - - m_value.array->erase(m_value.array->begin() + static_cast(idx)); - } - else - { - JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name()), *this)); - } - } - - /// @} - - - //////////// - // lookup // - //////////// - - /// @name lookup - /// @{ - - /*! - @brief find an element in a JSON object - - Finds an element in a JSON object with key equivalent to @a key. If the - element is not found or the JSON value is not an object, end() is - returned. - - @note This method always returns @ref end() when executed on a JSON type - that is not an object. - - @param[in] key key value of the element to search for. - - @return Iterator to an element with key equivalent to @a key. If no such - element is found or the JSON value is not an object, past-the-end (see - @ref end()) iterator is returned. - - @complexity Logarithmic in the size of the JSON object. - - @liveexample{The example shows how `find()` is used.,find__key_type} - - @sa see @ref contains(KeyT&&) const -- checks whether a key exists - - @since version 1.0.0 - */ - template - iterator find(KeyT&& key) - { - auto result = end(); - - if (is_object()) - { - result.m_it.object_iterator = m_value.object->find(std::forward(key)); - } - - return result; - } - - /*! - @brief find an element in a JSON object - @copydoc find(KeyT&&) - */ - template - const_iterator find(KeyT&& key) const - { - auto result = cend(); - - if (is_object()) - { - result.m_it.object_iterator = m_value.object->find(std::forward(key)); - } - - return result; - } - - /*! - @brief returns the number of occurrences of a key in a JSON object - - Returns the number of elements with key @a key. If ObjectType is the - default `std::map` type, the return value will always be `0` (@a key was - not found) or `1` (@a key was found). - - @note This method always returns `0` when executed on a JSON type that is - not an object. - - @param[in] key key value of the element to count - - @return Number of elements with key @a key. If the JSON value is not an - object, the return value will be `0`. - - @complexity Logarithmic in the size of the JSON object. - - @liveexample{The example shows how `count()` is used.,count} - - @since version 1.0.0 - */ - template - size_type count(KeyT&& key) const - { - // return 0 for all nonobject types - return is_object() ? m_value.object->count(std::forward(key)) : 0; - } - - /*! - @brief check the existence of an element in a JSON object - - Check whether an element exists in a JSON object with key equivalent to - @a key. If the element is not found or the JSON value is not an object, - false is returned. - - @note This method always returns false when executed on a JSON type - that is not an object. - - @param[in] key key value to check its existence. - - @return true if an element with specified @a key exists. If no such - element with such key is found or the JSON value is not an object, - false is returned. - - @complexity Logarithmic in the size of the JSON object. - - @liveexample{The following code shows an example for `contains()`.,contains} - - @sa see @ref find(KeyT&&) -- returns an iterator to an object element - @sa see @ref contains(const json_pointer&) const -- checks the existence for a JSON pointer - - @since version 3.6.0 - */ - template < typename KeyT, typename std::enable_if < - !std::is_same::type, json_pointer>::value, int >::type = 0 > - bool contains(KeyT && key) const - { - return is_object() && m_value.object->find(std::forward(key)) != m_value.object->end(); - } - - /*! - @brief check the existence of an element in a JSON object given a JSON pointer - - Check whether the given JSON pointer @a ptr can be resolved in the current - JSON value. - - @note This method can be executed on any JSON value type. - - @param[in] ptr JSON pointer to check its existence. - - @return true if the JSON pointer can be resolved to a stored value, false - otherwise. - - @post If `j.contains(ptr)` returns true, it is safe to call `j[ptr]`. - - @throw parse_error.106 if an array index begins with '0' - @throw parse_error.109 if an array index was not a number - - @complexity Logarithmic in the size of the JSON object. - - @liveexample{The following code shows an example for `contains()`.,contains_json_pointer} - - @sa see @ref contains(KeyT &&) const -- checks the existence of a key - - @since version 3.7.0 - */ - bool contains(const json_pointer& ptr) const - { - return ptr.contains(this); - } - - /// @} - - - /////////////// - // iterators // - /////////////// - - /// @name iterators - /// @{ - - /*! - @brief returns an iterator to the first element - - Returns an iterator to the first element. - - @image html range-begin-end.svg "Illustration from cppreference.com" - - @return iterator to the first element - - @complexity Constant. - - @requirement This function helps `basic_json` satisfying the - [Container](https://en.cppreference.com/w/cpp/named_req/Container) - requirements: - - The complexity is constant. - - @liveexample{The following code shows an example for `begin()`.,begin} - - @sa see @ref cbegin() -- returns a const iterator to the beginning - @sa see @ref end() -- returns an iterator to the end - @sa see @ref cend() -- returns a const iterator to the end - - @since version 1.0.0 - */ - iterator begin() noexcept - { - iterator result(this); - result.set_begin(); - return result; - } - - /*! - @copydoc basic_json::cbegin() - */ - const_iterator begin() const noexcept - { - return cbegin(); - } - - /*! - @brief returns a const iterator to the first element - - Returns a const iterator to the first element. - - @image html range-begin-end.svg "Illustration from cppreference.com" - - @return const iterator to the first element - - @complexity Constant. - - @requirement This function helps `basic_json` satisfying the - [Container](https://en.cppreference.com/w/cpp/named_req/Container) - requirements: - - The complexity is constant. - - Has the semantics of `const_cast(*this).begin()`. - - @liveexample{The following code shows an example for `cbegin()`.,cbegin} - - @sa see @ref begin() -- returns an iterator to the beginning - @sa see @ref end() -- returns an iterator to the end - @sa see @ref cend() -- returns a const iterator to the end - - @since version 1.0.0 - */ - const_iterator cbegin() const noexcept - { - const_iterator result(this); - result.set_begin(); - return result; - } - - /*! - @brief returns an iterator to one past the last element - - Returns an iterator to one past the last element. - - @image html range-begin-end.svg "Illustration from cppreference.com" - - @return iterator one past the last element - - @complexity Constant. - - @requirement This function helps `basic_json` satisfying the - [Container](https://en.cppreference.com/w/cpp/named_req/Container) - requirements: - - The complexity is constant. - - @liveexample{The following code shows an example for `end()`.,end} - - @sa see @ref cend() -- returns a const iterator to the end - @sa see @ref begin() -- returns an iterator to the beginning - @sa see @ref cbegin() -- returns a const iterator to the beginning - - @since version 1.0.0 - */ - iterator end() noexcept - { - iterator result(this); - result.set_end(); - return result; - } - - /*! - @copydoc basic_json::cend() - */ - const_iterator end() const noexcept - { - return cend(); - } - - /*! - @brief returns a const iterator to one past the last element - - Returns a const iterator to one past the last element. - - @image html range-begin-end.svg "Illustration from cppreference.com" - - @return const iterator one past the last element - - @complexity Constant. - - @requirement This function helps `basic_json` satisfying the - [Container](https://en.cppreference.com/w/cpp/named_req/Container) - requirements: - - The complexity is constant. - - Has the semantics of `const_cast(*this).end()`. - - @liveexample{The following code shows an example for `cend()`.,cend} - - @sa see @ref end() -- returns an iterator to the end - @sa see @ref begin() -- returns an iterator to the beginning - @sa see @ref cbegin() -- returns a const iterator to the beginning - - @since version 1.0.0 - */ - const_iterator cend() const noexcept - { - const_iterator result(this); - result.set_end(); - return result; - } - - /*! - @brief returns an iterator to the reverse-beginning - - Returns an iterator to the reverse-beginning; that is, the last element. - - @image html range-rbegin-rend.svg "Illustration from cppreference.com" - - @complexity Constant. - - @requirement This function helps `basic_json` satisfying the - [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer) - requirements: - - The complexity is constant. - - Has the semantics of `reverse_iterator(end())`. - - @liveexample{The following code shows an example for `rbegin()`.,rbegin} - - @sa see @ref crbegin() -- returns a const reverse iterator to the beginning - @sa see @ref rend() -- returns a reverse iterator to the end - @sa see @ref crend() -- returns a const reverse iterator to the end - - @since version 1.0.0 - */ - reverse_iterator rbegin() noexcept - { - return reverse_iterator(end()); - } - - /*! - @copydoc basic_json::crbegin() - */ - const_reverse_iterator rbegin() const noexcept - { - return crbegin(); - } - - /*! - @brief returns an iterator to the reverse-end - - Returns an iterator to the reverse-end; that is, one before the first - element. - - @image html range-rbegin-rend.svg "Illustration from cppreference.com" - - @complexity Constant. - - @requirement This function helps `basic_json` satisfying the - [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer) - requirements: - - The complexity is constant. - - Has the semantics of `reverse_iterator(begin())`. - - @liveexample{The following code shows an example for `rend()`.,rend} - - @sa see @ref crend() -- returns a const reverse iterator to the end - @sa see @ref rbegin() -- returns a reverse iterator to the beginning - @sa see @ref crbegin() -- returns a const reverse iterator to the beginning - - @since version 1.0.0 - */ - reverse_iterator rend() noexcept - { - return reverse_iterator(begin()); - } - - /*! - @copydoc basic_json::crend() - */ - const_reverse_iterator rend() const noexcept - { - return crend(); - } - - /*! - @brief returns a const reverse iterator to the last element - - Returns a const iterator to the reverse-beginning; that is, the last - element. - - @image html range-rbegin-rend.svg "Illustration from cppreference.com" - - @complexity Constant. - - @requirement This function helps `basic_json` satisfying the - [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer) - requirements: - - The complexity is constant. - - Has the semantics of `const_cast(*this).rbegin()`. - - @liveexample{The following code shows an example for `crbegin()`.,crbegin} - - @sa see @ref rbegin() -- returns a reverse iterator to the beginning - @sa see @ref rend() -- returns a reverse iterator to the end - @sa see @ref crend() -- returns a const reverse iterator to the end - - @since version 1.0.0 - */ - const_reverse_iterator crbegin() const noexcept - { - return const_reverse_iterator(cend()); - } - - /*! - @brief returns a const reverse iterator to one before the first - - Returns a const reverse iterator to the reverse-end; that is, one before - the first element. - - @image html range-rbegin-rend.svg "Illustration from cppreference.com" - - @complexity Constant. - - @requirement This function helps `basic_json` satisfying the - [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer) - requirements: - - The complexity is constant. - - Has the semantics of `const_cast(*this).rend()`. - - @liveexample{The following code shows an example for `crend()`.,crend} - - @sa see @ref rend() -- returns a reverse iterator to the end - @sa see @ref rbegin() -- returns a reverse iterator to the beginning - @sa see @ref crbegin() -- returns a const reverse iterator to the beginning - - @since version 1.0.0 - */ - const_reverse_iterator crend() const noexcept - { - return const_reverse_iterator(cbegin()); - } - - public: - /*! - @brief wrapper to access iterator member functions in range-based for - - This function allows to access @ref iterator::key() and @ref - iterator::value() during range-based for loops. In these loops, a - reference to the JSON values is returned, so there is no access to the - underlying iterator. - - For loop without iterator_wrapper: - - @code{cpp} - for (auto it = j_object.begin(); it != j_object.end(); ++it) - { - std::cout << "key: " << it.key() << ", value:" << it.value() << '\n'; - } - @endcode - - Range-based for loop without iterator proxy: - - @code{cpp} - for (auto it : j_object) - { - // "it" is of type json::reference and has no key() member - std::cout << "value: " << it << '\n'; - } - @endcode - - Range-based for loop with iterator proxy: - - @code{cpp} - for (auto it : json::iterator_wrapper(j_object)) - { - std::cout << "key: " << it.key() << ", value:" << it.value() << '\n'; - } - @endcode - - @note When iterating over an array, `key()` will return the index of the - element as string (see example). - - @param[in] ref reference to a JSON value - @return iteration proxy object wrapping @a ref with an interface to use in - range-based for loops - - @liveexample{The following code shows how the wrapper is used,iterator_wrapper} - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes in the JSON value. - - @complexity Constant. - - @note The name of this function is not yet final and may change in the - future. - - @deprecated This stream operator is deprecated and will be removed in - future 4.0.0 of the library. Please use @ref items() instead; - that is, replace `json::iterator_wrapper(j)` with `j.items()`. - */ - JSON_HEDLEY_DEPRECATED_FOR(3.1.0, items()) - static iteration_proxy iterator_wrapper(reference ref) noexcept - { - return ref.items(); - } - - /*! - @copydoc iterator_wrapper(reference) - */ - JSON_HEDLEY_DEPRECATED_FOR(3.1.0, items()) - static iteration_proxy iterator_wrapper(const_reference ref) noexcept - { - return ref.items(); - } - - /*! - @brief helper to access iterator member functions in range-based for - - This function allows to access @ref iterator::key() and @ref - iterator::value() during range-based for loops. In these loops, a - reference to the JSON values is returned, so there is no access to the - underlying iterator. - - For loop without `items()` function: - - @code{cpp} - for (auto it = j_object.begin(); it != j_object.end(); ++it) - { - std::cout << "key: " << it.key() << ", value:" << it.value() << '\n'; - } - @endcode - - Range-based for loop without `items()` function: - - @code{cpp} - for (auto it : j_object) - { - // "it" is of type json::reference and has no key() member - std::cout << "value: " << it << '\n'; - } - @endcode - - Range-based for loop with `items()` function: - - @code{cpp} - for (auto& el : j_object.items()) - { - std::cout << "key: " << el.key() << ", value:" << el.value() << '\n'; - } - @endcode - - The `items()` function also allows to use - [structured bindings](https://en.cppreference.com/w/cpp/language/structured_binding) - (C++17): - - @code{cpp} - for (auto& [key, val] : j_object.items()) - { - std::cout << "key: " << key << ", value:" << val << '\n'; - } - @endcode - - @note When iterating over an array, `key()` will return the index of the - element as string (see example). For primitive types (e.g., numbers), - `key()` returns an empty string. - - @warning Using `items()` on temporary objects is dangerous. Make sure the - object's lifetime exeeds the iteration. See - for more - information. - - @return iteration proxy object wrapping @a ref with an interface to use in - range-based for loops - - @liveexample{The following code shows how the function is used.,items} - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes in the JSON value. - - @complexity Constant. - - @since version 3.1.0, structured bindings support since 3.5.0. - */ - iteration_proxy items() noexcept - { - return iteration_proxy(*this); - } - - /*! - @copydoc items() - */ - iteration_proxy items() const noexcept - { - return iteration_proxy(*this); - } - - /// @} - - - ////////////// - // capacity // - ////////////// - - /// @name capacity - /// @{ - - /*! - @brief checks whether the container is empty. - - Checks if a JSON value has no elements (i.e. whether its @ref size is `0`). - - @return The return value depends on the different types and is - defined as follows: - Value type | return value - ----------- | ------------- - null | `true` - boolean | `false` - string | `false` - number | `false` - binary | `false` - object | result of function `object_t::empty()` - array | result of function `array_t::empty()` - - @liveexample{The following code uses `empty()` to check if a JSON - object contains any elements.,empty} - - @complexity Constant, as long as @ref array_t and @ref object_t satisfy - the Container concept; that is, their `empty()` functions have constant - complexity. - - @iterators No changes. - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @note This function does not return whether a string stored as JSON value - is empty - it returns whether the JSON container itself is empty which is - false in the case of a string. - - @requirement This function helps `basic_json` satisfying the - [Container](https://en.cppreference.com/w/cpp/named_req/Container) - requirements: - - The complexity is constant. - - Has the semantics of `begin() == end()`. - - @sa see @ref size() -- returns the number of elements - - @since version 1.0.0 - */ - bool empty() const noexcept - { - switch (m_type) - { - case value_t::null: - { - // null values are empty - return true; - } - - case value_t::array: - { - // delegate call to array_t::empty() - return m_value.array->empty(); - } - - case value_t::object: - { - // delegate call to object_t::empty() - return m_value.object->empty(); - } - - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - { - // all other types are nonempty - return false; - } - } - } - - /*! - @brief returns the number of elements - - Returns the number of elements in a JSON value. - - @return The return value depends on the different types and is - defined as follows: - Value type | return value - ----------- | ------------- - null | `0` - boolean | `1` - string | `1` - number | `1` - binary | `1` - object | result of function object_t::size() - array | result of function array_t::size() - - @liveexample{The following code calls `size()` on the different value - types.,size} - - @complexity Constant, as long as @ref array_t and @ref object_t satisfy - the Container concept; that is, their size() functions have constant - complexity. - - @iterators No changes. - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @note This function does not return the length of a string stored as JSON - value - it returns the number of elements in the JSON value which is 1 in - the case of a string. - - @requirement This function helps `basic_json` satisfying the - [Container](https://en.cppreference.com/w/cpp/named_req/Container) - requirements: - - The complexity is constant. - - Has the semantics of `std::distance(begin(), end())`. - - @sa see @ref empty() -- checks whether the container is empty - @sa see @ref max_size() -- returns the maximal number of elements - - @since version 1.0.0 - */ - size_type size() const noexcept - { - switch (m_type) - { - case value_t::null: - { - // null values are empty - return 0; - } - - case value_t::array: - { - // delegate call to array_t::size() - return m_value.array->size(); - } - - case value_t::object: - { - // delegate call to object_t::size() - return m_value.object->size(); - } - - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - { - // all other types have size 1 - return 1; - } - } - } - - /*! - @brief returns the maximum possible number of elements - - Returns the maximum number of elements a JSON value is able to hold due to - system or library implementation limitations, i.e. `std::distance(begin(), - end())` for the JSON value. - - @return The return value depends on the different types and is - defined as follows: - Value type | return value - ----------- | ------------- - null | `0` (same as `size()`) - boolean | `1` (same as `size()`) - string | `1` (same as `size()`) - number | `1` (same as `size()`) - binary | `1` (same as `size()`) - object | result of function `object_t::max_size()` - array | result of function `array_t::max_size()` - - @liveexample{The following code calls `max_size()` on the different value - types. Note the output is implementation specific.,max_size} - - @complexity Constant, as long as @ref array_t and @ref object_t satisfy - the Container concept; that is, their `max_size()` functions have constant - complexity. - - @iterators No changes. - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @requirement This function helps `basic_json` satisfying the - [Container](https://en.cppreference.com/w/cpp/named_req/Container) - requirements: - - The complexity is constant. - - Has the semantics of returning `b.size()` where `b` is the largest - possible JSON value. - - @sa see @ref size() -- returns the number of elements - - @since version 1.0.0 - */ - size_type max_size() const noexcept - { - switch (m_type) - { - case value_t::array: - { - // delegate call to array_t::max_size() - return m_value.array->max_size(); - } - - case value_t::object: - { - // delegate call to object_t::max_size() - return m_value.object->max_size(); - } - - case value_t::null: - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - { - // all other types have max_size() == size() - return size(); - } - } - } - - /// @} - - - /////////////// - // modifiers // - /////////////// - - /// @name modifiers - /// @{ - - /*! - @brief clears the contents - - Clears the content of a JSON value and resets it to the default value as - if @ref basic_json(value_t) would have been called with the current value - type from @ref type(): - - Value type | initial value - ----------- | ------------- - null | `null` - boolean | `false` - string | `""` - number | `0` - binary | An empty byte vector - object | `{}` - array | `[]` - - @post Has the same effect as calling - @code {.cpp} - *this = basic_json(type()); - @endcode - - @liveexample{The example below shows the effect of `clear()` to different - JSON types.,clear} - - @complexity Linear in the size of the JSON value. - - @iterators All iterators, pointers and references related to this container - are invalidated. - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @sa see @ref basic_json(value_t) -- constructor that creates an object with the - same value than calling `clear()` - - @since version 1.0.0 - */ - void clear() noexcept - { - switch (m_type) - { - case value_t::number_integer: - { - m_value.number_integer = 0; - break; - } - - case value_t::number_unsigned: - { - m_value.number_unsigned = 0; - break; - } - - case value_t::number_float: - { - m_value.number_float = 0.0; - break; - } - - case value_t::boolean: - { - m_value.boolean = false; - break; - } - - case value_t::string: - { - m_value.string->clear(); - break; - } - - case value_t::binary: - { - m_value.binary->clear(); - break; - } - - case value_t::array: - { - m_value.array->clear(); - break; - } - - case value_t::object: - { - m_value.object->clear(); - break; - } - - case value_t::null: - case value_t::discarded: - default: - break; - } - } - - /*! - @brief add an object to an array - - Appends the given element @a val to the end of the JSON value. If the - function is called on a JSON null value, an empty array is created before - appending @a val. - - @param[in] val the value to add to the JSON array - - @throw type_error.308 when called on a type other than JSON array or - null; example: `"cannot use push_back() with number"` - - @complexity Amortized constant. - - @liveexample{The example shows how `push_back()` and `+=` can be used to - add elements to a JSON array. Note how the `null` value was silently - converted to a JSON array.,push_back} - - @since version 1.0.0 - */ - void push_back(basic_json&& val) - { - // push_back only works for null objects or arrays - if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_array()))) - { - JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()), *this)); - } - - // transform null object into an array - if (is_null()) - { - m_type = value_t::array; - m_value = value_t::array; - assert_invariant(); - } - - // add element to array (move semantics) - const auto old_capacity = m_value.array->capacity(); - m_value.array->push_back(std::move(val)); - set_parent(m_value.array->back(), old_capacity); - // if val is moved from, basic_json move constructor marks it null so we do not call the destructor - } - - /*! - @brief add an object to an array - @copydoc push_back(basic_json&&) - */ - reference operator+=(basic_json&& val) - { - push_back(std::move(val)); - return *this; - } - - /*! - @brief add an object to an array - @copydoc push_back(basic_json&&) - */ - void push_back(const basic_json& val) - { - // push_back only works for null objects or arrays - if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_array()))) - { - JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()), *this)); - } - - // transform null object into an array - if (is_null()) - { - m_type = value_t::array; - m_value = value_t::array; - assert_invariant(); - } - - // add element to array - const auto old_capacity = m_value.array->capacity(); - m_value.array->push_back(val); - set_parent(m_value.array->back(), old_capacity); - } - - /*! - @brief add an object to an array - @copydoc push_back(basic_json&&) - */ - reference operator+=(const basic_json& val) - { - push_back(val); - return *this; - } - - /*! - @brief add an object to an object - - Inserts the given element @a val to the JSON object. If the function is - called on a JSON null value, an empty object is created before inserting - @a val. - - @param[in] val the value to add to the JSON object - - @throw type_error.308 when called on a type other than JSON object or - null; example: `"cannot use push_back() with number"` - - @complexity Logarithmic in the size of the container, O(log(`size()`)). - - @liveexample{The example shows how `push_back()` and `+=` can be used to - add elements to a JSON object. Note how the `null` value was silently - converted to a JSON object.,push_back__object_t__value} - - @since version 1.0.0 - */ - void push_back(const typename object_t::value_type& val) - { - // push_back only works for null objects or objects - if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_object()))) - { - JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()), *this)); - } - - // transform null object into an object - if (is_null()) - { - m_type = value_t::object; - m_value = value_t::object; - assert_invariant(); - } - - // add element to object - auto res = m_value.object->insert(val); - set_parent(res.first->second); - } - - /*! - @brief add an object to an object - @copydoc push_back(const typename object_t::value_type&) - */ - reference operator+=(const typename object_t::value_type& val) - { - push_back(val); - return *this; - } - - /*! - @brief add an object to an object - - This function allows to use `push_back` with an initializer list. In case - - 1. the current value is an object, - 2. the initializer list @a init contains only two elements, and - 3. the first element of @a init is a string, - - @a init is converted into an object element and added using - @ref push_back(const typename object_t::value_type&). Otherwise, @a init - is converted to a JSON value and added using @ref push_back(basic_json&&). - - @param[in] init an initializer list - - @complexity Linear in the size of the initializer list @a init. - - @note This function is required to resolve an ambiguous overload error, - because pairs like `{"key", "value"}` can be both interpreted as - `object_t::value_type` or `std::initializer_list`, see - https://github.com/nlohmann/json/issues/235 for more information. - - @liveexample{The example shows how initializer lists are treated as - objects when possible.,push_back__initializer_list} - */ - void push_back(initializer_list_t init) - { - if (is_object() && init.size() == 2 && (*init.begin())->is_string()) - { - basic_json&& key = init.begin()->moved_or_copied(); - push_back(typename object_t::value_type( - std::move(key.get_ref()), (init.begin() + 1)->moved_or_copied())); - } - else - { - push_back(basic_json(init)); - } - } - - /*! - @brief add an object to an object - @copydoc push_back(initializer_list_t) - */ - reference operator+=(initializer_list_t init) - { - push_back(init); - return *this; - } - - /*! - @brief add an object to an array - - Creates a JSON value from the passed parameters @a args to the end of the - JSON value. If the function is called on a JSON null value, an empty array - is created before appending the value created from @a args. - - @param[in] args arguments to forward to a constructor of @ref basic_json - @tparam Args compatible types to create a @ref basic_json object - - @return reference to the inserted element - - @throw type_error.311 when called on a type other than JSON array or - null; example: `"cannot use emplace_back() with number"` - - @complexity Amortized constant. - - @liveexample{The example shows how `push_back()` can be used to add - elements to a JSON array. Note how the `null` value was silently converted - to a JSON array.,emplace_back} - - @since version 2.0.8, returns reference since 3.7.0 - */ - template - reference emplace_back(Args&& ... args) - { - // emplace_back only works for null objects or arrays - if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_array()))) - { - JSON_THROW(type_error::create(311, "cannot use emplace_back() with " + std::string(type_name()), *this)); - } - - // transform null object into an array - if (is_null()) - { - m_type = value_t::array; - m_value = value_t::array; - assert_invariant(); - } - - // add element to array (perfect forwarding) - const auto old_capacity = m_value.array->capacity(); - m_value.array->emplace_back(std::forward(args)...); - return set_parent(m_value.array->back(), old_capacity); - } - - /*! - @brief add an object to an object if key does not exist - - Inserts a new element into a JSON object constructed in-place with the - given @a args if there is no element with the key in the container. If the - function is called on a JSON null value, an empty object is created before - appending the value created from @a args. - - @param[in] args arguments to forward to a constructor of @ref basic_json - @tparam Args compatible types to create a @ref basic_json object - - @return a pair consisting of an iterator to the inserted element, or the - already-existing element if no insertion happened, and a bool - denoting whether the insertion took place. - - @throw type_error.311 when called on a type other than JSON object or - null; example: `"cannot use emplace() with number"` - - @complexity Logarithmic in the size of the container, O(log(`size()`)). - - @liveexample{The example shows how `emplace()` can be used to add elements - to a JSON object. Note how the `null` value was silently converted to a - JSON object. Further note how no value is added if there was already one - value stored with the same key.,emplace} - - @since version 2.0.8 - */ - template - std::pair emplace(Args&& ... args) - { - // emplace only works for null objects or arrays - if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_object()))) - { - JSON_THROW(type_error::create(311, "cannot use emplace() with " + std::string(type_name()), *this)); - } - - // transform null object into an object - if (is_null()) - { - m_type = value_t::object; - m_value = value_t::object; - assert_invariant(); - } - - // add element to array (perfect forwarding) - auto res = m_value.object->emplace(std::forward(args)...); - set_parent(res.first->second); - - // create result iterator and set iterator to the result of emplace - auto it = begin(); - it.m_it.object_iterator = res.first; - - // return pair of iterator and boolean - return {it, res.second}; - } - - /// Helper for insertion of an iterator - /// @note: This uses std::distance to support GCC 4.8, - /// see https://github.com/nlohmann/json/pull/1257 - template - iterator insert_iterator(const_iterator pos, Args&& ... args) - { - iterator result(this); - JSON_ASSERT(m_value.array != nullptr); - - auto insert_pos = std::distance(m_value.array->begin(), pos.m_it.array_iterator); - m_value.array->insert(pos.m_it.array_iterator, std::forward(args)...); - result.m_it.array_iterator = m_value.array->begin() + insert_pos; - - // This could have been written as: - // result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, cnt, val); - // but the return value of insert is missing in GCC 4.8, so it is written this way instead. - - set_parents(); - return result; - } - - /*! - @brief inserts element - - Inserts element @a val before iterator @a pos. - - @param[in] pos iterator before which the content will be inserted; may be - the end() iterator - @param[in] val element to insert - @return iterator pointing to the inserted @a val. - - @throw type_error.309 if called on JSON values other than arrays; - example: `"cannot use insert() with string"` - @throw invalid_iterator.202 if @a pos is not an iterator of *this; - example: `"iterator does not fit current value"` - - @complexity Constant plus linear in the distance between @a pos and end of - the container. - - @liveexample{The example shows how `insert()` is used.,insert} - - @since version 1.0.0 - */ - iterator insert(const_iterator pos, const basic_json& val) - { - // insert only works for arrays - if (JSON_HEDLEY_LIKELY(is_array())) - { - // check if iterator pos fits to this JSON value - if (JSON_HEDLEY_UNLIKELY(pos.m_object != this)) - { - JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", *this)); - } - - // insert to array and return iterator - return insert_iterator(pos, val); - } - - JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()), *this)); - } - - /*! - @brief inserts element - @copydoc insert(const_iterator, const basic_json&) - */ - iterator insert(const_iterator pos, basic_json&& val) - { - return insert(pos, val); - } - - /*! - @brief inserts elements - - Inserts @a cnt copies of @a val before iterator @a pos. - - @param[in] pos iterator before which the content will be inserted; may be - the end() iterator - @param[in] cnt number of copies of @a val to insert - @param[in] val element to insert - @return iterator pointing to the first element inserted, or @a pos if - `cnt==0` - - @throw type_error.309 if called on JSON values other than arrays; example: - `"cannot use insert() with string"` - @throw invalid_iterator.202 if @a pos is not an iterator of *this; - example: `"iterator does not fit current value"` - - @complexity Linear in @a cnt plus linear in the distance between @a pos - and end of the container. - - @liveexample{The example shows how `insert()` is used.,insert__count} - - @since version 1.0.0 - */ - iterator insert(const_iterator pos, size_type cnt, const basic_json& val) - { - // insert only works for arrays - if (JSON_HEDLEY_LIKELY(is_array())) - { - // check if iterator pos fits to this JSON value - if (JSON_HEDLEY_UNLIKELY(pos.m_object != this)) - { - JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", *this)); - } - - // insert to array and return iterator - return insert_iterator(pos, cnt, val); - } - - JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()), *this)); - } - - /*! - @brief inserts elements - - Inserts elements from range `[first, last)` before iterator @a pos. - - @param[in] pos iterator before which the content will be inserted; may be - the end() iterator - @param[in] first begin of the range of elements to insert - @param[in] last end of the range of elements to insert - - @throw type_error.309 if called on JSON values other than arrays; example: - `"cannot use insert() with string"` - @throw invalid_iterator.202 if @a pos is not an iterator of *this; - example: `"iterator does not fit current value"` - @throw invalid_iterator.210 if @a first and @a last do not belong to the - same JSON value; example: `"iterators do not fit"` - @throw invalid_iterator.211 if @a first or @a last are iterators into - container for which insert is called; example: `"passed iterators may not - belong to container"` - - @return iterator pointing to the first element inserted, or @a pos if - `first==last` - - @complexity Linear in `std::distance(first, last)` plus linear in the - distance between @a pos and end of the container. - - @liveexample{The example shows how `insert()` is used.,insert__range} - - @since version 1.0.0 - */ - iterator insert(const_iterator pos, const_iterator first, const_iterator last) - { - // insert only works for arrays - if (JSON_HEDLEY_UNLIKELY(!is_array())) - { - JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()), *this)); - } - - // check if iterator pos fits to this JSON value - if (JSON_HEDLEY_UNLIKELY(pos.m_object != this)) - { - JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", *this)); - } - - // check if range iterators belong to the same JSON object - if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) - { - JSON_THROW(invalid_iterator::create(210, "iterators do not fit", *this)); - } - - if (JSON_HEDLEY_UNLIKELY(first.m_object == this)) - { - JSON_THROW(invalid_iterator::create(211, "passed iterators may not belong to container", *this)); - } - - // insert to array and return iterator - return insert_iterator(pos, first.m_it.array_iterator, last.m_it.array_iterator); - } - - /*! - @brief inserts elements - - Inserts elements from initializer list @a ilist before iterator @a pos. - - @param[in] pos iterator before which the content will be inserted; may be - the end() iterator - @param[in] ilist initializer list to insert the values from - - @throw type_error.309 if called on JSON values other than arrays; example: - `"cannot use insert() with string"` - @throw invalid_iterator.202 if @a pos is not an iterator of *this; - example: `"iterator does not fit current value"` - - @return iterator pointing to the first element inserted, or @a pos if - `ilist` is empty - - @complexity Linear in `ilist.size()` plus linear in the distance between - @a pos and end of the container. - - @liveexample{The example shows how `insert()` is used.,insert__ilist} - - @since version 1.0.0 - */ - iterator insert(const_iterator pos, initializer_list_t ilist) - { - // insert only works for arrays - if (JSON_HEDLEY_UNLIKELY(!is_array())) - { - JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()), *this)); - } - - // check if iterator pos fits to this JSON value - if (JSON_HEDLEY_UNLIKELY(pos.m_object != this)) - { - JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", *this)); - } - - // insert to array and return iterator - return insert_iterator(pos, ilist.begin(), ilist.end()); - } - - /*! - @brief inserts elements - - Inserts elements from range `[first, last)`. - - @param[in] first begin of the range of elements to insert - @param[in] last end of the range of elements to insert - - @throw type_error.309 if called on JSON values other than objects; example: - `"cannot use insert() with string"` - @throw invalid_iterator.202 if iterator @a first or @a last does does not - point to an object; example: `"iterators first and last must point to - objects"` - @throw invalid_iterator.210 if @a first and @a last do not belong to the - same JSON value; example: `"iterators do not fit"` - - @complexity Logarithmic: `O(N*log(size() + N))`, where `N` is the number - of elements to insert. - - @liveexample{The example shows how `insert()` is used.,insert__range_object} - - @since version 3.0.0 - */ - void insert(const_iterator first, const_iterator last) - { - // insert only works for objects - if (JSON_HEDLEY_UNLIKELY(!is_object())) - { - JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()), *this)); - } - - // check if range iterators belong to the same JSON object - if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) - { - JSON_THROW(invalid_iterator::create(210, "iterators do not fit", *this)); - } - - // passed iterators must belong to objects - if (JSON_HEDLEY_UNLIKELY(!first.m_object->is_object())) - { - JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects", *this)); - } - - m_value.object->insert(first.m_it.object_iterator, last.m_it.object_iterator); - } - - /*! - @brief updates a JSON object from another object, overwriting existing keys - - Inserts all values from JSON object @a j and overwrites existing keys. - - @param[in] j JSON object to read values from - @param[in] merge_objects when true, existing keys are not overwritten, but - contents of objects are merged recursively - (default: false) - - @throw type_error.312 if called on JSON values other than objects; example: - `"cannot use update() with string"` - - @complexity O(N*log(size() + N)), where N is the number of elements to - insert. - - @liveexample{The example shows how `update()` is used.,update} - - @sa https://docs.python.org/3.6/library/stdtypes.html#dict.update - - @since version 3.0.0, `merge_objects` parameter added in 3.10.4. - */ - void update(const_reference j, bool merge_objects = false) - { - update(j.begin(), j.end(), merge_objects); - } - - /*! - @brief updates a JSON object from another object, overwriting existing keys - - Inserts all values from from range `[first, last)` and overwrites existing - keys. - - @param[in] first begin of the range of elements to insert - @param[in] last end of the range of elements to insert - @param[in] merge_objects when true, existing keys are not overwritten, but - contents of objects are merged recursively - (default: false) - - @throw type_error.312 if called on JSON values other than objects; example: - `"cannot use update() with string"` - @throw type_error.312 if iterator @a first or @a last does does not - point to an object; example: `"cannot use update() with string"` - @throw invalid_iterator.210 if @a first and @a last do not belong to the - same JSON value; example: `"iterators do not fit"` - - @complexity O(N*log(size() + N)), where N is the number of elements to - insert. - - @liveexample{The example shows how `update()` is used__range.,update} - - @sa https://docs.python.org/3.6/library/stdtypes.html#dict.update - - @since version 3.0.0, `merge_objects` parameter added in 3.10.4. - */ - void update(const_iterator first, const_iterator last, bool merge_objects = false) - { - // implicitly convert null value to an empty object - if (is_null()) - { - m_type = value_t::object; - m_value.object = create(); - assert_invariant(); - } - - if (JSON_HEDLEY_UNLIKELY(!is_object())) - { - JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name()), *this)); - } - - // check if range iterators belong to the same JSON object - if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) - { - JSON_THROW(invalid_iterator::create(210, "iterators do not fit", *this)); - } - - // passed iterators must belong to objects - if (JSON_HEDLEY_UNLIKELY(!first.m_object->is_object())) - { - JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(first.m_object->type_name()), *first.m_object)); - } - - for (auto it = first; it != last; ++it) - { - if (merge_objects && it.value().is_object()) - { - auto it2 = m_value.object->find(it.key()); - if (it2 != m_value.object->end()) - { - it2->second.update(it.value(), true); - continue; - } - } - m_value.object->operator[](it.key()) = it.value(); -#if JSON_DIAGNOSTICS - m_value.object->operator[](it.key()).m_parent = this; -#endif - } - } - - /*! - @brief exchanges the values - - Exchanges the contents of the JSON value with those of @a other. Does not - invoke any move, copy, or swap operations on individual elements. All - iterators and references remain valid. The past-the-end iterator is - invalidated. - - @param[in,out] other JSON value to exchange the contents with - - @complexity Constant. - - @liveexample{The example below shows how JSON values can be swapped with - `swap()`.,swap__reference} - - @since version 1.0.0 - */ - void swap(reference other) noexcept ( - std::is_nothrow_move_constructible::value&& - std::is_nothrow_move_assignable::value&& - std::is_nothrow_move_constructible::value&& - std::is_nothrow_move_assignable::value - ) - { - std::swap(m_type, other.m_type); - std::swap(m_value, other.m_value); - - set_parents(); - other.set_parents(); - assert_invariant(); - } - - /*! - @brief exchanges the values - - Exchanges the contents of the JSON value from @a left with those of @a right. Does not - invoke any move, copy, or swap operations on individual elements. All - iterators and references remain valid. The past-the-end iterator is - invalidated. implemented as a friend function callable via ADL. - - @param[in,out] left JSON value to exchange the contents with - @param[in,out] right JSON value to exchange the contents with - - @complexity Constant. - - @liveexample{The example below shows how JSON values can be swapped with - `swap()`.,swap__reference} - - @since version 1.0.0 - */ - friend void swap(reference left, reference right) noexcept ( - std::is_nothrow_move_constructible::value&& - std::is_nothrow_move_assignable::value&& - std::is_nothrow_move_constructible::value&& - std::is_nothrow_move_assignable::value - ) - { - left.swap(right); - } - - /*! - @brief exchanges the values - - Exchanges the contents of a JSON array with those of @a other. Does not - invoke any move, copy, or swap operations on individual elements. All - iterators and references remain valid. The past-the-end iterator is - invalidated. - - @param[in,out] other array to exchange the contents with - - @throw type_error.310 when JSON value is not an array; example: `"cannot - use swap() with string"` - - @complexity Constant. - - @liveexample{The example below shows how arrays can be swapped with - `swap()`.,swap__array_t} - - @since version 1.0.0 - */ - void swap(array_t& other) // NOLINT(bugprone-exception-escape) - { - // swap only works for arrays - if (JSON_HEDLEY_LIKELY(is_array())) - { - std::swap(*(m_value.array), other); - } - else - { - JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()), *this)); - } - } - - /*! - @brief exchanges the values - - Exchanges the contents of a JSON object with those of @a other. Does not - invoke any move, copy, or swap operations on individual elements. All - iterators and references remain valid. The past-the-end iterator is - invalidated. - - @param[in,out] other object to exchange the contents with - - @throw type_error.310 when JSON value is not an object; example: - `"cannot use swap() with string"` - - @complexity Constant. - - @liveexample{The example below shows how objects can be swapped with - `swap()`.,swap__object_t} - - @since version 1.0.0 - */ - void swap(object_t& other) // NOLINT(bugprone-exception-escape) - { - // swap only works for objects - if (JSON_HEDLEY_LIKELY(is_object())) - { - std::swap(*(m_value.object), other); - } - else - { - JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()), *this)); - } - } - - /*! - @brief exchanges the values - - Exchanges the contents of a JSON string with those of @a other. Does not - invoke any move, copy, or swap operations on individual elements. All - iterators and references remain valid. The past-the-end iterator is - invalidated. - - @param[in,out] other string to exchange the contents with - - @throw type_error.310 when JSON value is not a string; example: `"cannot - use swap() with boolean"` - - @complexity Constant. - - @liveexample{The example below shows how strings can be swapped with - `swap()`.,swap__string_t} - - @since version 1.0.0 - */ - void swap(string_t& other) // NOLINT(bugprone-exception-escape) - { - // swap only works for strings - if (JSON_HEDLEY_LIKELY(is_string())) - { - std::swap(*(m_value.string), other); - } - else - { - JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()), *this)); - } - } - - /*! - @brief exchanges the values - - Exchanges the contents of a JSON string with those of @a other. Does not - invoke any move, copy, or swap operations on individual elements. All - iterators and references remain valid. The past-the-end iterator is - invalidated. - - @param[in,out] other binary to exchange the contents with - - @throw type_error.310 when JSON value is not a string; example: `"cannot - use swap() with boolean"` - - @complexity Constant. - - @liveexample{The example below shows how strings can be swapped with - `swap()`.,swap__binary_t} - - @since version 3.8.0 - */ - void swap(binary_t& other) // NOLINT(bugprone-exception-escape) - { - // swap only works for strings - if (JSON_HEDLEY_LIKELY(is_binary())) - { - std::swap(*(m_value.binary), other); - } - else - { - JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()), *this)); - } - } - - /// @copydoc swap(binary_t&) - void swap(typename binary_t::container_type& other) // NOLINT(bugprone-exception-escape) - { - // swap only works for strings - if (JSON_HEDLEY_LIKELY(is_binary())) - { - std::swap(*(m_value.binary), other); - } - else - { - JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()), *this)); - } - } - - /// @} - - public: - ////////////////////////////////////////// - // lexicographical comparison operators // - ////////////////////////////////////////// - - /// @name lexicographical comparison operators - /// @{ - - /*! - @brief comparison: equal - - Compares two JSON values for equality according to the following rules: - - Two JSON values are equal if (1) they are from the same type and (2) - their stored values are the same according to their respective - `operator==`. - - Integer and floating-point numbers are automatically converted before - comparison. Note that two NaN values are always treated as unequal. - - Two JSON null values are equal. - - @note Floating-point inside JSON values numbers are compared with - `json::number_float_t::operator==` which is `double::operator==` by - default. To compare floating-point while respecting an epsilon, an alternative - [comparison function](https://github.com/mariokonrad/marnav/blob/master/include/marnav/math/floatingpoint.hpp#L34-#L39) - could be used, for instance - @code {.cpp} - template::value, T>::type> - inline bool is_same(T a, T b, T epsilon = std::numeric_limits::epsilon()) noexcept - { - return std::abs(a - b) <= epsilon; - } - @endcode - Or you can self-defined operator equal function like this: - @code {.cpp} - bool my_equal(const_reference lhs, const_reference rhs) { - const auto lhs_type lhs.type(); - const auto rhs_type rhs.type(); - if (lhs_type == rhs_type) { - switch(lhs_type) - // self_defined case - case value_t::number_float: - return std::abs(lhs - rhs) <= std::numeric_limits::epsilon(); - // other cases remain the same with the original - ... - } - ... - } - @endcode - - @note NaN values never compare equal to themselves or to other NaN values. - - @param[in] lhs first JSON value to consider - @param[in] rhs second JSON value to consider - @return whether the values @a lhs and @a rhs are equal - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @complexity Linear. - - @liveexample{The example demonstrates comparing several JSON - types.,operator__equal} - - @since version 1.0.0 - */ - friend bool operator==(const_reference lhs, const_reference rhs) noexcept - { -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wfloat-equal" -#endif - const auto lhs_type = lhs.type(); - const auto rhs_type = rhs.type(); - - if (lhs_type == rhs_type) - { - switch (lhs_type) - { - case value_t::array: - return *lhs.m_value.array == *rhs.m_value.array; - - case value_t::object: - return *lhs.m_value.object == *rhs.m_value.object; - - case value_t::null: - return true; - - case value_t::string: - return *lhs.m_value.string == *rhs.m_value.string; - - case value_t::boolean: - return lhs.m_value.boolean == rhs.m_value.boolean; - - case value_t::number_integer: - return lhs.m_value.number_integer == rhs.m_value.number_integer; - - case value_t::number_unsigned: - return lhs.m_value.number_unsigned == rhs.m_value.number_unsigned; - - case value_t::number_float: - return lhs.m_value.number_float == rhs.m_value.number_float; - - case value_t::binary: - return *lhs.m_value.binary == *rhs.m_value.binary; - - case value_t::discarded: - default: - return false; - } - } - else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) - { - return static_cast(lhs.m_value.number_integer) == rhs.m_value.number_float; - } - else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) - { - return lhs.m_value.number_float == static_cast(rhs.m_value.number_integer); - } - else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) - { - return static_cast(lhs.m_value.number_unsigned) == rhs.m_value.number_float; - } - else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) - { - return lhs.m_value.number_float == static_cast(rhs.m_value.number_unsigned); - } - else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) - { - return static_cast(lhs.m_value.number_unsigned) == rhs.m_value.number_integer; - } - else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) - { - return lhs.m_value.number_integer == static_cast(rhs.m_value.number_unsigned); - } - - return false; -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif - } - - /*! - @brief comparison: equal - @copydoc operator==(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator==(const_reference lhs, ScalarType rhs) noexcept - { - return lhs == basic_json(rhs); - } - - /*! - @brief comparison: equal - @copydoc operator==(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator==(ScalarType lhs, const_reference rhs) noexcept - { - return basic_json(lhs) == rhs; - } - - /*! - @brief comparison: not equal - - Compares two JSON values for inequality by calculating `not (lhs == rhs)`. - - @param[in] lhs first JSON value to consider - @param[in] rhs second JSON value to consider - @return whether the values @a lhs and @a rhs are not equal - - @complexity Linear. - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @liveexample{The example demonstrates comparing several JSON - types.,operator__notequal} - - @since version 1.0.0 - */ - friend bool operator!=(const_reference lhs, const_reference rhs) noexcept - { - return !(lhs == rhs); - } - - /*! - @brief comparison: not equal - @copydoc operator!=(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator!=(const_reference lhs, ScalarType rhs) noexcept - { - return lhs != basic_json(rhs); - } - - /*! - @brief comparison: not equal - @copydoc operator!=(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator!=(ScalarType lhs, const_reference rhs) noexcept - { - return basic_json(lhs) != rhs; - } - - /*! - @brief comparison: less than - - Compares whether one JSON value @a lhs is less than another JSON value @a - rhs according to the following rules: - - If @a lhs and @a rhs have the same type, the values are compared using - the default `<` operator. - - Integer and floating-point numbers are automatically converted before - comparison - - In case @a lhs and @a rhs have different types, the values are ignored - and the order of the types is considered, see - @ref operator<(const value_t, const value_t). - - @param[in] lhs first JSON value to consider - @param[in] rhs second JSON value to consider - @return whether @a lhs is less than @a rhs - - @complexity Linear. - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @liveexample{The example demonstrates comparing several JSON - types.,operator__less} - - @since version 1.0.0 - */ - friend bool operator<(const_reference lhs, const_reference rhs) noexcept - { - const auto lhs_type = lhs.type(); - const auto rhs_type = rhs.type(); - - if (lhs_type == rhs_type) - { - switch (lhs_type) - { - case value_t::array: - // note parentheses are necessary, see - // https://github.com/nlohmann/json/issues/1530 - return (*lhs.m_value.array) < (*rhs.m_value.array); - - case value_t::object: - return (*lhs.m_value.object) < (*rhs.m_value.object); - - case value_t::null: - return false; - - case value_t::string: - return (*lhs.m_value.string) < (*rhs.m_value.string); - - case value_t::boolean: - return (lhs.m_value.boolean) < (rhs.m_value.boolean); - - case value_t::number_integer: - return (lhs.m_value.number_integer) < (rhs.m_value.number_integer); - - case value_t::number_unsigned: - return (lhs.m_value.number_unsigned) < (rhs.m_value.number_unsigned); - - case value_t::number_float: - return (lhs.m_value.number_float) < (rhs.m_value.number_float); - - case value_t::binary: - return (*lhs.m_value.binary) < (*rhs.m_value.binary); - - case value_t::discarded: - default: - return false; - } - } - else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) - { - return static_cast(lhs.m_value.number_integer) < rhs.m_value.number_float; - } - else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) - { - return lhs.m_value.number_float < static_cast(rhs.m_value.number_integer); - } - else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) - { - return static_cast(lhs.m_value.number_unsigned) < rhs.m_value.number_float; - } - else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) - { - return lhs.m_value.number_float < static_cast(rhs.m_value.number_unsigned); - } - else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) - { - return lhs.m_value.number_integer < static_cast(rhs.m_value.number_unsigned); - } - else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) - { - return static_cast(lhs.m_value.number_unsigned) < rhs.m_value.number_integer; - } - - // We only reach this line if we cannot compare values. In that case, - // we compare types. Note we have to call the operator explicitly, - // because MSVC has problems otherwise. - return operator<(lhs_type, rhs_type); - } - - /*! - @brief comparison: less than - @copydoc operator<(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator<(const_reference lhs, ScalarType rhs) noexcept - { - return lhs < basic_json(rhs); - } - - /*! - @brief comparison: less than - @copydoc operator<(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator<(ScalarType lhs, const_reference rhs) noexcept - { - return basic_json(lhs) < rhs; - } - - /*! - @brief comparison: less than or equal - - Compares whether one JSON value @a lhs is less than or equal to another - JSON value by calculating `not (rhs < lhs)`. - - @param[in] lhs first JSON value to consider - @param[in] rhs second JSON value to consider - @return whether @a lhs is less than or equal to @a rhs - - @complexity Linear. - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @liveexample{The example demonstrates comparing several JSON - types.,operator__greater} - - @since version 1.0.0 - */ - friend bool operator<=(const_reference lhs, const_reference rhs) noexcept - { - return !(rhs < lhs); - } - - /*! - @brief comparison: less than or equal - @copydoc operator<=(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator<=(const_reference lhs, ScalarType rhs) noexcept - { - return lhs <= basic_json(rhs); - } - - /*! - @brief comparison: less than or equal - @copydoc operator<=(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator<=(ScalarType lhs, const_reference rhs) noexcept - { - return basic_json(lhs) <= rhs; - } - - /*! - @brief comparison: greater than - - Compares whether one JSON value @a lhs is greater than another - JSON value by calculating `not (lhs <= rhs)`. - - @param[in] lhs first JSON value to consider - @param[in] rhs second JSON value to consider - @return whether @a lhs is greater than to @a rhs - - @complexity Linear. - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @liveexample{The example demonstrates comparing several JSON - types.,operator__lessequal} - - @since version 1.0.0 - */ - friend bool operator>(const_reference lhs, const_reference rhs) noexcept - { - return !(lhs <= rhs); - } - - /*! - @brief comparison: greater than - @copydoc operator>(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator>(const_reference lhs, ScalarType rhs) noexcept - { - return lhs > basic_json(rhs); - } - - /*! - @brief comparison: greater than - @copydoc operator>(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator>(ScalarType lhs, const_reference rhs) noexcept - { - return basic_json(lhs) > rhs; - } - - /*! - @brief comparison: greater than or equal - - Compares whether one JSON value @a lhs is greater than or equal to another - JSON value by calculating `not (lhs < rhs)`. - - @param[in] lhs first JSON value to consider - @param[in] rhs second JSON value to consider - @return whether @a lhs is greater than or equal to @a rhs - - @complexity Linear. - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @liveexample{The example demonstrates comparing several JSON - types.,operator__greaterequal} - - @since version 1.0.0 - */ - friend bool operator>=(const_reference lhs, const_reference rhs) noexcept - { - return !(lhs < rhs); - } - - /*! - @brief comparison: greater than or equal - @copydoc operator>=(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator>=(const_reference lhs, ScalarType rhs) noexcept - { - return lhs >= basic_json(rhs); - } - - /*! - @brief comparison: greater than or equal - @copydoc operator>=(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator>=(ScalarType lhs, const_reference rhs) noexcept - { - return basic_json(lhs) >= rhs; - } - - /// @} - - /////////////////// - // serialization // - /////////////////// - - /// @name serialization - /// @{ -#ifndef JSON_NO_IO - /*! - @brief serialize to stream - - Serialize the given JSON value @a j to the output stream @a o. The JSON - value will be serialized using the @ref dump member function. - - - The indentation of the output can be controlled with the member variable - `width` of the output stream @a o. For instance, using the manipulator - `std::setw(4)` on @a o sets the indentation level to `4` and the - serialization result is the same as calling `dump(4)`. - - - The indentation character can be controlled with the member variable - `fill` of the output stream @a o. For instance, the manipulator - `std::setfill('\\t')` sets indentation to use a tab character rather than - the default space character. - - @param[in,out] o stream to serialize to - @param[in] j JSON value to serialize - - @return the stream @a o - - @throw type_error.316 if a string stored inside the JSON value is not - UTF-8 encoded - - @complexity Linear. - - @liveexample{The example below shows the serialization with different - parameters to `width` to adjust the indentation level.,operator_serialize} - - @since version 1.0.0; indentation character added in version 3.0.0 - */ - friend std::ostream& operator<<(std::ostream& o, const basic_json& j) - { - // read width member and use it as indentation parameter if nonzero - const bool pretty_print = o.width() > 0; - const auto indentation = pretty_print ? o.width() : 0; - - // reset width to 0 for subsequent calls to this stream - o.width(0); - - // do the actual serialization - serializer s(detail::output_adapter(o), o.fill()); - s.dump(j, pretty_print, false, static_cast(indentation)); - return o; - } - - /*! - @brief serialize to stream - @deprecated This stream operator is deprecated and will be removed in - future 4.0.0 of the library. Please use - @ref operator<<(std::ostream&, const basic_json&) - instead; that is, replace calls like `j >> o;` with `o << j;`. - @since version 1.0.0; deprecated since version 3.0.0 - */ - JSON_HEDLEY_DEPRECATED_FOR(3.0.0, operator<<(std::ostream&, const basic_json&)) - friend std::ostream& operator>>(const basic_json& j, std::ostream& o) - { - return o << j; - } -#endif // JSON_NO_IO - /// @} - - - ///////////////////// - // deserialization // - ///////////////////// - - /// @name deserialization - /// @{ - - /*! - @brief deserialize from a compatible input - - @tparam InputType A compatible input, for instance - - an std::istream object - - a FILE pointer - - a C-style array of characters - - a pointer to a null-terminated string of single byte characters - - an object obj for which begin(obj) and end(obj) produces a valid pair of - iterators. - - @param[in] i input to read from - @param[in] cb a parser callback function of type @ref parser_callback_t - which is used to control the deserialization by filtering unwanted values - (optional) - @param[in] allow_exceptions whether to throw exceptions in case of a - parse error (optional, true by default) - @param[in] ignore_comments whether comments should be ignored and treated - like whitespace (true) or yield a parse error (true); (optional, false by - default) - - @return deserialized JSON value; in case of a parse error and - @a allow_exceptions set to `false`, the return value will be - value_t::discarded. - - @throw parse_error.101 if a parse error occurs; example: `""unexpected end - of input; expected string literal""` - @throw parse_error.102 if to_unicode fails or surrogate error - @throw parse_error.103 if to_unicode fails - - @complexity Linear in the length of the input. The parser is a predictive - LL(1) parser. The complexity can be higher if the parser callback function - @a cb or reading from the input @a i has a super-linear complexity. - - @note A UTF-8 byte order mark is silently ignored. - - @liveexample{The example below demonstrates the `parse()` function reading - from an array.,parse__array__parser_callback_t} - - @liveexample{The example below demonstrates the `parse()` function with - and without callback function.,parse__string__parser_callback_t} - - @liveexample{The example below demonstrates the `parse()` function with - and without callback function.,parse__istream__parser_callback_t} - - @liveexample{The example below demonstrates the `parse()` function reading - from a contiguous container.,parse__contiguouscontainer__parser_callback_t} - - @since version 2.0.3 (contiguous containers); version 3.9.0 allowed to - ignore comments. - */ - template - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json parse(InputType&& i, - const parser_callback_t cb = nullptr, - const bool allow_exceptions = true, - const bool ignore_comments = false) - { - basic_json result; - parser(detail::input_adapter(std::forward(i)), cb, allow_exceptions, ignore_comments).parse(true, result); - return result; - } - - /*! - @brief deserialize from a pair of character iterators - - The value_type of the iterator must be a integral type with size of 1, 2 or - 4 bytes, which will be interpreted respectively as UTF-8, UTF-16 and UTF-32. - - @param[in] first iterator to start of character range - @param[in] last iterator to end of character range - @param[in] cb a parser callback function of type @ref parser_callback_t - which is used to control the deserialization by filtering unwanted values - (optional) - @param[in] allow_exceptions whether to throw exceptions in case of a - parse error (optional, true by default) - @param[in] ignore_comments whether comments should be ignored and treated - like whitespace (true) or yield a parse error (true); (optional, false by - default) - - @return deserialized JSON value; in case of a parse error and - @a allow_exceptions set to `false`, the return value will be - value_t::discarded. - - @throw parse_error.101 if a parse error occurs; example: `""unexpected end - of input; expected string literal""` - @throw parse_error.102 if to_unicode fails or surrogate error - @throw parse_error.103 if to_unicode fails - */ - template - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json parse(IteratorType first, - IteratorType last, - const parser_callback_t cb = nullptr, - const bool allow_exceptions = true, - const bool ignore_comments = false) - { - basic_json result; - parser(detail::input_adapter(std::move(first), std::move(last)), cb, allow_exceptions, ignore_comments).parse(true, result); - return result; - } - - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, parse(ptr, ptr + len)) - static basic_json parse(detail::span_input_adapter&& i, - const parser_callback_t cb = nullptr, - const bool allow_exceptions = true, - const bool ignore_comments = false) - { - basic_json result; - parser(i.get(), cb, allow_exceptions, ignore_comments).parse(true, result); - return result; - } - - /*! - @brief check if the input is valid JSON - - Unlike the @ref parse(InputType&&, const parser_callback_t,const bool) - function, this function neither throws an exception in case of invalid JSON - input (i.e., a parse error) nor creates diagnostic information. - - @tparam InputType A compatible input, for instance - - an std::istream object - - a FILE pointer - - a C-style array of characters - - a pointer to a null-terminated string of single byte characters - - an object obj for which begin(obj) and end(obj) produces a valid pair of - iterators. - - @param[in] i input to read from - @param[in] ignore_comments whether comments should be ignored and treated - like whitespace (true) or yield a parse error (true); (optional, false by - default) - - @return Whether the input read from @a i is valid JSON. - - @complexity Linear in the length of the input. The parser is a predictive - LL(1) parser. - - @note A UTF-8 byte order mark is silently ignored. - - @liveexample{The example below demonstrates the `accept()` function reading - from a string.,accept__string} - */ - template - static bool accept(InputType&& i, - const bool ignore_comments = false) - { - return parser(detail::input_adapter(std::forward(i)), nullptr, false, ignore_comments).accept(true); - } - - template - static bool accept(IteratorType first, IteratorType last, - const bool ignore_comments = false) - { - return parser(detail::input_adapter(std::move(first), std::move(last)), nullptr, false, ignore_comments).accept(true); - } - - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, accept(ptr, ptr + len)) - static bool accept(detail::span_input_adapter&& i, - const bool ignore_comments = false) - { - return parser(i.get(), nullptr, false, ignore_comments).accept(true); - } - - /*! - @brief generate SAX events - - The SAX event lister must follow the interface of @ref json_sax. - - This function reads from a compatible input. Examples are: - - an std::istream object - - a FILE pointer - - a C-style array of characters - - a pointer to a null-terminated string of single byte characters - - an object obj for which begin(obj) and end(obj) produces a valid pair of - iterators. - - @param[in] i input to read from - @param[in,out] sax SAX event listener - @param[in] format the format to parse (JSON, CBOR, MessagePack, or UBJSON) - @param[in] strict whether the input has to be consumed completely - @param[in] ignore_comments whether comments should be ignored and treated - like whitespace (true) or yield a parse error (true); (optional, false by - default); only applies to the JSON file format. - - @return return value of the last processed SAX event - - @throw parse_error.101 if a parse error occurs; example: `""unexpected end - of input; expected string literal""` - @throw parse_error.102 if to_unicode fails or surrogate error - @throw parse_error.103 if to_unicode fails - - @complexity Linear in the length of the input. The parser is a predictive - LL(1) parser. The complexity can be higher if the SAX consumer @a sax has - a super-linear complexity. - - @note A UTF-8 byte order mark is silently ignored. - - @liveexample{The example below demonstrates the `sax_parse()` function - reading from string and processing the events with a user-defined SAX - event consumer.,sax_parse} - - @since version 3.2.0 - */ - template - JSON_HEDLEY_NON_NULL(2) - static bool sax_parse(InputType&& i, SAX* sax, - input_format_t format = input_format_t::json, - const bool strict = true, - const bool ignore_comments = false) - { - auto ia = detail::input_adapter(std::forward(i)); - return format == input_format_t::json - ? parser(std::move(ia), nullptr, true, ignore_comments).sax_parse(sax, strict) - : detail::binary_reader(std::move(ia)).sax_parse(format, sax, strict); - } - - template - JSON_HEDLEY_NON_NULL(3) - static bool sax_parse(IteratorType first, IteratorType last, SAX* sax, - input_format_t format = input_format_t::json, - const bool strict = true, - const bool ignore_comments = false) - { - auto ia = detail::input_adapter(std::move(first), std::move(last)); - return format == input_format_t::json - ? parser(std::move(ia), nullptr, true, ignore_comments).sax_parse(sax, strict) - : detail::binary_reader(std::move(ia)).sax_parse(format, sax, strict); - } - - template - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, sax_parse(ptr, ptr + len, ...)) - JSON_HEDLEY_NON_NULL(2) - static bool sax_parse(detail::span_input_adapter&& i, SAX* sax, - input_format_t format = input_format_t::json, - const bool strict = true, - const bool ignore_comments = false) - { - auto ia = i.get(); - return format == input_format_t::json - // NOLINTNEXTLINE(hicpp-move-const-arg,performance-move-const-arg) - ? parser(std::move(ia), nullptr, true, ignore_comments).sax_parse(sax, strict) - // NOLINTNEXTLINE(hicpp-move-const-arg,performance-move-const-arg) - : detail::binary_reader(std::move(ia)).sax_parse(format, sax, strict); - } -#ifndef JSON_NO_IO - /*! - @brief deserialize from stream - @deprecated This stream operator is deprecated and will be removed in - version 4.0.0 of the library. Please use - @ref operator>>(std::istream&, basic_json&) - instead; that is, replace calls like `j << i;` with `i >> j;`. - @since version 1.0.0; deprecated since version 3.0.0 - */ - JSON_HEDLEY_DEPRECATED_FOR(3.0.0, operator>>(std::istream&, basic_json&)) - friend std::istream& operator<<(basic_json& j, std::istream& i) - { - return operator>>(i, j); - } - - /*! - @brief deserialize from stream - - Deserializes an input stream to a JSON value. - - @param[in,out] i input stream to read a serialized JSON value from - @param[in,out] j JSON value to write the deserialized input to - - @throw parse_error.101 in case of an unexpected token - @throw parse_error.102 if to_unicode fails or surrogate error - @throw parse_error.103 if to_unicode fails - - @complexity Linear in the length of the input. The parser is a predictive - LL(1) parser. - - @note A UTF-8 byte order mark is silently ignored. - - @liveexample{The example below shows how a JSON value is constructed by - reading a serialization from a stream.,operator_deserialize} - - @sa parse(std::istream&, const parser_callback_t) for a variant with a - parser callback function to filter values while parsing - - @since version 1.0.0 - */ - friend std::istream& operator>>(std::istream& i, basic_json& j) - { - parser(detail::input_adapter(i)).parse(false, j); - return i; - } -#endif // JSON_NO_IO - /// @} - - /////////////////////////// - // convenience functions // - /////////////////////////// - - /*! - @brief return the type as string - - Returns the type name as string to be used in error messages - usually to - indicate that a function was called on a wrong JSON type. - - @return a string representation of a the @a m_type member: - Value type | return value - ----------- | ------------- - null | `"null"` - boolean | `"boolean"` - string | `"string"` - number | `"number"` (for all number types) - object | `"object"` - array | `"array"` - binary | `"binary"` - discarded | `"discarded"` - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @complexity Constant. - - @liveexample{The following code exemplifies `type_name()` for all JSON - types.,type_name} - - @sa see @ref type() -- return the type of the JSON value - @sa see @ref operator value_t() -- return the type of the JSON value (implicit) - - @since version 1.0.0, public since 2.1.0, `const char*` and `noexcept` - since 3.0.0 - */ - JSON_HEDLEY_RETURNS_NON_NULL - const char* type_name() const noexcept - { - { - switch (m_type) - { - case value_t::null: - return "null"; - case value_t::object: - return "object"; - case value_t::array: - return "array"; - case value_t::string: - return "string"; - case value_t::boolean: - return "boolean"; - case value_t::binary: - return "binary"; - case value_t::discarded: - return "discarded"; - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - default: - return "number"; - } - } - } - - - JSON_PRIVATE_UNLESS_TESTED: - ////////////////////// - // member variables // - ////////////////////// - - /// the type of the current element - value_t m_type = value_t::null; - - /// the value of the current element - json_value m_value = {}; - -#if JSON_DIAGNOSTICS - /// a pointer to a parent value (for debugging purposes) - basic_json* m_parent = nullptr; -#endif - - ////////////////////////////////////////// - // binary serialization/deserialization // - ////////////////////////////////////////// - - /// @name binary serialization/deserialization support - /// @{ - - public: - /*! - @brief create a CBOR serialization of a given JSON value - - Serializes a given JSON value @a j to a byte vector using the CBOR (Concise - Binary Object Representation) serialization format. CBOR is a binary - serialization format which aims to be more compact than JSON itself, yet - more efficient to parse. - - The library uses the following mapping from JSON values types to - CBOR types according to the CBOR specification (RFC 7049): - - JSON value type | value/range | CBOR type | first byte - --------------- | ------------------------------------------ | ---------------------------------- | --------------- - null | `null` | Null | 0xF6 - boolean | `true` | True | 0xF5 - boolean | `false` | False | 0xF4 - number_integer | -9223372036854775808..-2147483649 | Negative integer (8 bytes follow) | 0x3B - number_integer | -2147483648..-32769 | Negative integer (4 bytes follow) | 0x3A - number_integer | -32768..-129 | Negative integer (2 bytes follow) | 0x39 - number_integer | -128..-25 | Negative integer (1 byte follow) | 0x38 - number_integer | -24..-1 | Negative integer | 0x20..0x37 - number_integer | 0..23 | Integer | 0x00..0x17 - number_integer | 24..255 | Unsigned integer (1 byte follow) | 0x18 - number_integer | 256..65535 | Unsigned integer (2 bytes follow) | 0x19 - number_integer | 65536..4294967295 | Unsigned integer (4 bytes follow) | 0x1A - number_integer | 4294967296..18446744073709551615 | Unsigned integer (8 bytes follow) | 0x1B - number_unsigned | 0..23 | Integer | 0x00..0x17 - number_unsigned | 24..255 | Unsigned integer (1 byte follow) | 0x18 - number_unsigned | 256..65535 | Unsigned integer (2 bytes follow) | 0x19 - number_unsigned | 65536..4294967295 | Unsigned integer (4 bytes follow) | 0x1A - number_unsigned | 4294967296..18446744073709551615 | Unsigned integer (8 bytes follow) | 0x1B - number_float | *any value representable by a float* | Single-Precision Float | 0xFA - number_float | *any value NOT representable by a float* | Double-Precision Float | 0xFB - string | *length*: 0..23 | UTF-8 string | 0x60..0x77 - string | *length*: 23..255 | UTF-8 string (1 byte follow) | 0x78 - string | *length*: 256..65535 | UTF-8 string (2 bytes follow) | 0x79 - string | *length*: 65536..4294967295 | UTF-8 string (4 bytes follow) | 0x7A - string | *length*: 4294967296..18446744073709551615 | UTF-8 string (8 bytes follow) | 0x7B - array | *size*: 0..23 | array | 0x80..0x97 - array | *size*: 23..255 | array (1 byte follow) | 0x98 - array | *size*: 256..65535 | array (2 bytes follow) | 0x99 - array | *size*: 65536..4294967295 | array (4 bytes follow) | 0x9A - array | *size*: 4294967296..18446744073709551615 | array (8 bytes follow) | 0x9B - object | *size*: 0..23 | map | 0xA0..0xB7 - object | *size*: 23..255 | map (1 byte follow) | 0xB8 - object | *size*: 256..65535 | map (2 bytes follow) | 0xB9 - object | *size*: 65536..4294967295 | map (4 bytes follow) | 0xBA - object | *size*: 4294967296..18446744073709551615 | map (8 bytes follow) | 0xBB - binary | *size*: 0..23 | byte string | 0x40..0x57 - binary | *size*: 23..255 | byte string (1 byte follow) | 0x58 - binary | *size*: 256..65535 | byte string (2 bytes follow) | 0x59 - binary | *size*: 65536..4294967295 | byte string (4 bytes follow) | 0x5A - binary | *size*: 4294967296..18446744073709551615 | byte string (8 bytes follow) | 0x5B - - Binary values with subtype are mapped to tagged values (0xD8..0xDB) - depending on the subtype, followed by a byte string, see "binary" cells - in the table above. - - @note The mapping is **complete** in the sense that any JSON value type - can be converted to a CBOR value. - - @note If NaN or Infinity are stored inside a JSON number, they are - serialized properly. This behavior differs from the @ref dump() - function which serializes NaN or Infinity to `null`. - - @note The following CBOR types are not used in the conversion: - - UTF-8 strings terminated by "break" (0x7F) - - arrays terminated by "break" (0x9F) - - maps terminated by "break" (0xBF) - - byte strings terminated by "break" (0x5F) - - date/time (0xC0..0xC1) - - bignum (0xC2..0xC3) - - decimal fraction (0xC4) - - bigfloat (0xC5) - - expected conversions (0xD5..0xD7) - - simple values (0xE0..0xF3, 0xF8) - - undefined (0xF7) - - half-precision floats (0xF9) - - break (0xFF) - - @param[in] j JSON value to serialize - @return CBOR serialization as byte vector - - @complexity Linear in the size of the JSON value @a j. - - @liveexample{The example shows the serialization of a JSON value to a byte - vector in CBOR format.,to_cbor} - - @sa http://cbor.io - @sa see @ref from_cbor(InputType&&, const bool, const bool, const cbor_tag_handler_t) for the - analogous deserialization - @sa see @ref to_msgpack(const basic_json&) for the related MessagePack format - @sa see @ref to_ubjson(const basic_json&, const bool, const bool) for the - related UBJSON format - - @since version 2.0.9; compact representation of floating-point numbers - since version 3.8.0 - */ - static std::vector to_cbor(const basic_json& j) - { - std::vector result; - to_cbor(j, result); - return result; - } - - static void to_cbor(const basic_json& j, detail::output_adapter o) - { - binary_writer(o).write_cbor(j); - } - - static void to_cbor(const basic_json& j, detail::output_adapter o) - { - binary_writer(o).write_cbor(j); - } - - /*! - @brief create a MessagePack serialization of a given JSON value - - Serializes a given JSON value @a j to a byte vector using the MessagePack - serialization format. MessagePack is a binary serialization format which - aims to be more compact than JSON itself, yet more efficient to parse. - - The library uses the following mapping from JSON values types to - MessagePack types according to the MessagePack specification: - - JSON value type | value/range | MessagePack type | first byte - --------------- | --------------------------------- | ---------------- | ---------- - null | `null` | nil | 0xC0 - boolean | `true` | true | 0xC3 - boolean | `false` | false | 0xC2 - number_integer | -9223372036854775808..-2147483649 | int64 | 0xD3 - number_integer | -2147483648..-32769 | int32 | 0xD2 - number_integer | -32768..-129 | int16 | 0xD1 - number_integer | -128..-33 | int8 | 0xD0 - number_integer | -32..-1 | negative fixint | 0xE0..0xFF - number_integer | 0..127 | positive fixint | 0x00..0x7F - number_integer | 128..255 | uint 8 | 0xCC - number_integer | 256..65535 | uint 16 | 0xCD - number_integer | 65536..4294967295 | uint 32 | 0xCE - number_integer | 4294967296..18446744073709551615 | uint 64 | 0xCF - number_unsigned | 0..127 | positive fixint | 0x00..0x7F - number_unsigned | 128..255 | uint 8 | 0xCC - number_unsigned | 256..65535 | uint 16 | 0xCD - number_unsigned | 65536..4294967295 | uint 32 | 0xCE - number_unsigned | 4294967296..18446744073709551615 | uint 64 | 0xCF - number_float | *any value representable by a float* | float 32 | 0xCA - number_float | *any value NOT representable by a float* | float 64 | 0xCB - string | *length*: 0..31 | fixstr | 0xA0..0xBF - string | *length*: 32..255 | str 8 | 0xD9 - string | *length*: 256..65535 | str 16 | 0xDA - string | *length*: 65536..4294967295 | str 32 | 0xDB - array | *size*: 0..15 | fixarray | 0x90..0x9F - array | *size*: 16..65535 | array 16 | 0xDC - array | *size*: 65536..4294967295 | array 32 | 0xDD - object | *size*: 0..15 | fix map | 0x80..0x8F - object | *size*: 16..65535 | map 16 | 0xDE - object | *size*: 65536..4294967295 | map 32 | 0xDF - binary | *size*: 0..255 | bin 8 | 0xC4 - binary | *size*: 256..65535 | bin 16 | 0xC5 - binary | *size*: 65536..4294967295 | bin 32 | 0xC6 - - @note The mapping is **complete** in the sense that any JSON value type - can be converted to a MessagePack value. - - @note The following values can **not** be converted to a MessagePack value: - - strings with more than 4294967295 bytes - - byte strings with more than 4294967295 bytes - - arrays with more than 4294967295 elements - - objects with more than 4294967295 elements - - @note Any MessagePack output created @ref to_msgpack can be successfully - parsed by @ref from_msgpack. - - @note If NaN or Infinity are stored inside a JSON number, they are - serialized properly. This behavior differs from the @ref dump() - function which serializes NaN or Infinity to `null`. - - @param[in] j JSON value to serialize - @return MessagePack serialization as byte vector - - @complexity Linear in the size of the JSON value @a j. - - @liveexample{The example shows the serialization of a JSON value to a byte - vector in MessagePack format.,to_msgpack} - - @sa http://msgpack.org - @sa see @ref from_msgpack for the analogous deserialization - @sa see @ref to_cbor(const basic_json& for the related CBOR format - @sa see @ref to_ubjson(const basic_json&, const bool, const bool) for the - related UBJSON format - - @since version 2.0.9 - */ - static std::vector to_msgpack(const basic_json& j) - { - std::vector result; - to_msgpack(j, result); - return result; - } - - static void to_msgpack(const basic_json& j, detail::output_adapter o) - { - binary_writer(o).write_msgpack(j); - } - - static void to_msgpack(const basic_json& j, detail::output_adapter o) - { - binary_writer(o).write_msgpack(j); - } - - /*! - @brief create a UBJSON serialization of a given JSON value - - Serializes a given JSON value @a j to a byte vector using the UBJSON - (Universal Binary JSON) serialization format. UBJSON aims to be more compact - than JSON itself, yet more efficient to parse. - - The library uses the following mapping from JSON values types to - UBJSON types according to the UBJSON specification: - - JSON value type | value/range | UBJSON type | marker - --------------- | --------------------------------- | ----------- | ------ - null | `null` | null | `Z` - boolean | `true` | true | `T` - boolean | `false` | false | `F` - number_integer | -9223372036854775808..-2147483649 | int64 | `L` - number_integer | -2147483648..-32769 | int32 | `l` - number_integer | -32768..-129 | int16 | `I` - number_integer | -128..127 | int8 | `i` - number_integer | 128..255 | uint8 | `U` - number_integer | 256..32767 | int16 | `I` - number_integer | 32768..2147483647 | int32 | `l` - number_integer | 2147483648..9223372036854775807 | int64 | `L` - number_unsigned | 0..127 | int8 | `i` - number_unsigned | 128..255 | uint8 | `U` - number_unsigned | 256..32767 | int16 | `I` - number_unsigned | 32768..2147483647 | int32 | `l` - number_unsigned | 2147483648..9223372036854775807 | int64 | `L` - number_unsigned | 2147483649..18446744073709551615 | high-precision | `H` - number_float | *any value* | float64 | `D` - string | *with shortest length indicator* | string | `S` - array | *see notes on optimized format* | array | `[` - object | *see notes on optimized format* | map | `{` - - @note The mapping is **complete** in the sense that any JSON value type - can be converted to a UBJSON value. - - @note The following values can **not** be converted to a UBJSON value: - - strings with more than 9223372036854775807 bytes (theoretical) - - @note The following markers are not used in the conversion: - - `Z`: no-op values are not created. - - `C`: single-byte strings are serialized with `S` markers. - - @note Any UBJSON output created @ref to_ubjson can be successfully parsed - by @ref from_ubjson. - - @note If NaN or Infinity are stored inside a JSON number, they are - serialized properly. This behavior differs from the @ref dump() - function which serializes NaN or Infinity to `null`. - - @note The optimized formats for containers are supported: Parameter - @a use_size adds size information to the beginning of a container and - removes the closing marker. Parameter @a use_type further checks - whether all elements of a container have the same type and adds the - type marker to the beginning of the container. The @a use_type - parameter must only be used together with @a use_size = true. Note - that @a use_size = true alone may result in larger representations - - the benefit of this parameter is that the receiving side is - immediately informed on the number of elements of the container. - - @note If the JSON data contains the binary type, the value stored is a list - of integers, as suggested by the UBJSON documentation. In particular, - this means that serialization and the deserialization of a JSON - containing binary values into UBJSON and back will result in a - different JSON object. - - @param[in] j JSON value to serialize - @param[in] use_size whether to add size annotations to container types - @param[in] use_type whether to add type annotations to container types - (must be combined with @a use_size = true) - @return UBJSON serialization as byte vector - - @complexity Linear in the size of the JSON value @a j. - - @liveexample{The example shows the serialization of a JSON value to a byte - vector in UBJSON format.,to_ubjson} - - @sa http://ubjson.org - @sa see @ref from_ubjson(InputType&&, const bool, const bool) for the - analogous deserialization - @sa see @ref to_cbor(const basic_json& for the related CBOR format - @sa see @ref to_msgpack(const basic_json&) for the related MessagePack format - - @since version 3.1.0 - */ - static std::vector to_ubjson(const basic_json& j, - const bool use_size = false, - const bool use_type = false) - { - std::vector result; - to_ubjson(j, result, use_size, use_type); - return result; - } - - static void to_ubjson(const basic_json& j, detail::output_adapter o, - const bool use_size = false, const bool use_type = false) - { - binary_writer(o).write_ubjson(j, use_size, use_type); - } - - static void to_ubjson(const basic_json& j, detail::output_adapter o, - const bool use_size = false, const bool use_type = false) - { - binary_writer(o).write_ubjson(j, use_size, use_type); - } - - - /*! - @brief Serializes the given JSON object `j` to BSON and returns a vector - containing the corresponding BSON-representation. - - BSON (Binary JSON) is a binary format in which zero or more ordered key/value pairs are - stored as a single entity (a so-called document). - - The library uses the following mapping from JSON values types to BSON types: - - JSON value type | value/range | BSON type | marker - --------------- | --------------------------------- | ----------- | ------ - null | `null` | null | 0x0A - boolean | `true`, `false` | boolean | 0x08 - number_integer | -9223372036854775808..-2147483649 | int64 | 0x12 - number_integer | -2147483648..2147483647 | int32 | 0x10 - number_integer | 2147483648..9223372036854775807 | int64 | 0x12 - number_unsigned | 0..2147483647 | int32 | 0x10 - number_unsigned | 2147483648..9223372036854775807 | int64 | 0x12 - number_unsigned | 9223372036854775808..18446744073709551615| -- | -- - number_float | *any value* | double | 0x01 - string | *any value* | string | 0x02 - array | *any value* | document | 0x04 - object | *any value* | document | 0x03 - binary | *any value* | binary | 0x05 - - @warning The mapping is **incomplete**, since only JSON-objects (and things - contained therein) can be serialized to BSON. - Also, integers larger than 9223372036854775807 cannot be serialized to BSON, - and the keys may not contain U+0000, since they are serialized a - zero-terminated c-strings. - - @throw out_of_range.407 if `j.is_number_unsigned() && j.get() > 9223372036854775807` - @throw out_of_range.409 if a key in `j` contains a NULL (U+0000) - @throw type_error.317 if `!j.is_object()` - - @pre The input `j` is required to be an object: `j.is_object() == true`. - - @note Any BSON output created via @ref to_bson can be successfully parsed - by @ref from_bson. - - @param[in] j JSON value to serialize - @return BSON serialization as byte vector - - @complexity Linear in the size of the JSON value @a j. - - @liveexample{The example shows the serialization of a JSON value to a byte - vector in BSON format.,to_bson} - - @sa http://bsonspec.org/spec.html - @sa see @ref from_bson(detail::input_adapter&&, const bool strict) for the - analogous deserialization - @sa see @ref to_ubjson(const basic_json&, const bool, const bool) for the - related UBJSON format - @sa see @ref to_cbor(const basic_json&) for the related CBOR format - @sa see @ref to_msgpack(const basic_json&) for the related MessagePack format - */ - static std::vector to_bson(const basic_json& j) - { - std::vector result; - to_bson(j, result); - return result; - } - - /*! - @brief Serializes the given JSON object `j` to BSON and forwards the - corresponding BSON-representation to the given output_adapter `o`. - @param j The JSON object to convert to BSON. - @param o The output adapter that receives the binary BSON representation. - @pre The input `j` shall be an object: `j.is_object() == true` - @sa see @ref to_bson(const basic_json&) - */ - static void to_bson(const basic_json& j, detail::output_adapter o) - { - binary_writer(o).write_bson(j); - } - - /*! - @copydoc to_bson(const basic_json&, detail::output_adapter) - */ - static void to_bson(const basic_json& j, detail::output_adapter o) - { - binary_writer(o).write_bson(j); - } - - - /*! - @brief create a JSON value from an input in CBOR format - - Deserializes a given input @a i to a JSON value using the CBOR (Concise - Binary Object Representation) serialization format. - - The library maps CBOR types to JSON value types as follows: - - CBOR type | JSON value type | first byte - ---------------------- | --------------- | ---------- - Integer | number_unsigned | 0x00..0x17 - Unsigned integer | number_unsigned | 0x18 - Unsigned integer | number_unsigned | 0x19 - Unsigned integer | number_unsigned | 0x1A - Unsigned integer | number_unsigned | 0x1B - Negative integer | number_integer | 0x20..0x37 - Negative integer | number_integer | 0x38 - Negative integer | number_integer | 0x39 - Negative integer | number_integer | 0x3A - Negative integer | number_integer | 0x3B - Byte string | binary | 0x40..0x57 - Byte string | binary | 0x58 - Byte string | binary | 0x59 - Byte string | binary | 0x5A - Byte string | binary | 0x5B - UTF-8 string | string | 0x60..0x77 - UTF-8 string | string | 0x78 - UTF-8 string | string | 0x79 - UTF-8 string | string | 0x7A - UTF-8 string | string | 0x7B - UTF-8 string | string | 0x7F - array | array | 0x80..0x97 - array | array | 0x98 - array | array | 0x99 - array | array | 0x9A - array | array | 0x9B - array | array | 0x9F - map | object | 0xA0..0xB7 - map | object | 0xB8 - map | object | 0xB9 - map | object | 0xBA - map | object | 0xBB - map | object | 0xBF - False | `false` | 0xF4 - True | `true` | 0xF5 - Null | `null` | 0xF6 - Half-Precision Float | number_float | 0xF9 - Single-Precision Float | number_float | 0xFA - Double-Precision Float | number_float | 0xFB - - @warning The mapping is **incomplete** in the sense that not all CBOR - types can be converted to a JSON value. The following CBOR types - are not supported and will yield parse errors (parse_error.112): - - date/time (0xC0..0xC1) - - bignum (0xC2..0xC3) - - decimal fraction (0xC4) - - bigfloat (0xC5) - - expected conversions (0xD5..0xD7) - - simple values (0xE0..0xF3, 0xF8) - - undefined (0xF7) - - @warning CBOR allows map keys of any type, whereas JSON only allows - strings as keys in object values. Therefore, CBOR maps with keys - other than UTF-8 strings are rejected (parse_error.113). - - @note Any CBOR output created @ref to_cbor can be successfully parsed by - @ref from_cbor. - - @param[in] i an input in CBOR format convertible to an input adapter - @param[in] strict whether to expect the input to be consumed until EOF - (true by default) - @param[in] allow_exceptions whether to throw exceptions in case of a - parse error (optional, true by default) - @param[in] tag_handler how to treat CBOR tags (optional, error by default) - - @return deserialized JSON value; in case of a parse error and - @a allow_exceptions set to `false`, the return value will be - value_t::discarded. - - @throw parse_error.110 if the given input ends prematurely or the end of - file was not reached when @a strict was set to true - @throw parse_error.112 if unsupported features from CBOR were - used in the given input @a v or if the input is not valid CBOR - @throw parse_error.113 if a string was expected as map key, but not found - - @complexity Linear in the size of the input @a i. - - @liveexample{The example shows the deserialization of a byte vector in CBOR - format to a JSON value.,from_cbor} - - @sa http://cbor.io - @sa see @ref to_cbor(const basic_json&) for the analogous serialization - @sa see @ref from_msgpack(InputType&&, const bool, const bool) for the - related MessagePack format - @sa see @ref from_ubjson(InputType&&, const bool, const bool) for the - related UBJSON format - - @since version 2.0.9; parameter @a start_index since 2.1.1; changed to - consume input adapters, removed start_index parameter, and added - @a strict parameter since 3.0.0; added @a allow_exceptions parameter - since 3.2.0; added @a tag_handler parameter since 3.9.0. - */ - template - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json from_cbor(InputType&& i, - const bool strict = true, - const bool allow_exceptions = true, - const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = detail::input_adapter(std::forward(i)); - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler); - return res ? result : basic_json(value_t::discarded); - } - - /*! - @copydoc from_cbor(InputType&&, const bool, const bool, const cbor_tag_handler_t) - */ - template - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json from_cbor(IteratorType first, IteratorType last, - const bool strict = true, - const bool allow_exceptions = true, - const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = detail::input_adapter(std::move(first), std::move(last)); - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler); - return res ? result : basic_json(value_t::discarded); - } - - template - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len)) - static basic_json from_cbor(const T* ptr, std::size_t len, - const bool strict = true, - const bool allow_exceptions = true, - const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) - { - return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler); - } - - - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len)) - static basic_json from_cbor(detail::span_input_adapter&& i, - const bool strict = true, - const bool allow_exceptions = true, - const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = i.get(); - // NOLINTNEXTLINE(hicpp-move-const-arg,performance-move-const-arg) - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler); - return res ? result : basic_json(value_t::discarded); - } - - /*! - @brief create a JSON value from an input in MessagePack format - - Deserializes a given input @a i to a JSON value using the MessagePack - serialization format. - - The library maps MessagePack types to JSON value types as follows: - - MessagePack type | JSON value type | first byte - ---------------- | --------------- | ---------- - positive fixint | number_unsigned | 0x00..0x7F - fixmap | object | 0x80..0x8F - fixarray | array | 0x90..0x9F - fixstr | string | 0xA0..0xBF - nil | `null` | 0xC0 - false | `false` | 0xC2 - true | `true` | 0xC3 - float 32 | number_float | 0xCA - float 64 | number_float | 0xCB - uint 8 | number_unsigned | 0xCC - uint 16 | number_unsigned | 0xCD - uint 32 | number_unsigned | 0xCE - uint 64 | number_unsigned | 0xCF - int 8 | number_integer | 0xD0 - int 16 | number_integer | 0xD1 - int 32 | number_integer | 0xD2 - int 64 | number_integer | 0xD3 - str 8 | string | 0xD9 - str 16 | string | 0xDA - str 32 | string | 0xDB - array 16 | array | 0xDC - array 32 | array | 0xDD - map 16 | object | 0xDE - map 32 | object | 0xDF - bin 8 | binary | 0xC4 - bin 16 | binary | 0xC5 - bin 32 | binary | 0xC6 - ext 8 | binary | 0xC7 - ext 16 | binary | 0xC8 - ext 32 | binary | 0xC9 - fixext 1 | binary | 0xD4 - fixext 2 | binary | 0xD5 - fixext 4 | binary | 0xD6 - fixext 8 | binary | 0xD7 - fixext 16 | binary | 0xD8 - negative fixint | number_integer | 0xE0-0xFF - - @note Any MessagePack output created @ref to_msgpack can be successfully - parsed by @ref from_msgpack. - - @param[in] i an input in MessagePack format convertible to an input - adapter - @param[in] strict whether to expect the input to be consumed until EOF - (true by default) - @param[in] allow_exceptions whether to throw exceptions in case of a - parse error (optional, true by default) - - @return deserialized JSON value; in case of a parse error and - @a allow_exceptions set to `false`, the return value will be - value_t::discarded. - - @throw parse_error.110 if the given input ends prematurely or the end of - file was not reached when @a strict was set to true - @throw parse_error.112 if unsupported features from MessagePack were - used in the given input @a i or if the input is not valid MessagePack - @throw parse_error.113 if a string was expected as map key, but not found - - @complexity Linear in the size of the input @a i. - - @liveexample{The example shows the deserialization of a byte vector in - MessagePack format to a JSON value.,from_msgpack} - - @sa http://msgpack.org - @sa see @ref to_msgpack(const basic_json&) for the analogous serialization - @sa see @ref from_cbor(InputType&&, const bool, const bool, const cbor_tag_handler_t) for the - related CBOR format - @sa see @ref from_ubjson(InputType&&, const bool, const bool) for - the related UBJSON format - @sa see @ref from_bson(InputType&&, const bool, const bool) for - the related BSON format - - @since version 2.0.9; parameter @a start_index since 2.1.1; changed to - consume input adapters, removed start_index parameter, and added - @a strict parameter since 3.0.0; added @a allow_exceptions parameter - since 3.2.0 - */ - template - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json from_msgpack(InputType&& i, - const bool strict = true, - const bool allow_exceptions = true) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = detail::input_adapter(std::forward(i)); - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::msgpack, &sdp, strict); - return res ? result : basic_json(value_t::discarded); - } - - /*! - @copydoc from_msgpack(InputType&&, const bool, const bool) - */ - template - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json from_msgpack(IteratorType first, IteratorType last, - const bool strict = true, - const bool allow_exceptions = true) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = detail::input_adapter(std::move(first), std::move(last)); - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::msgpack, &sdp, strict); - return res ? result : basic_json(value_t::discarded); - } - - - template - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len)) - static basic_json from_msgpack(const T* ptr, std::size_t len, - const bool strict = true, - const bool allow_exceptions = true) - { - return from_msgpack(ptr, ptr + len, strict, allow_exceptions); - } - - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len)) - static basic_json from_msgpack(detail::span_input_adapter&& i, - const bool strict = true, - const bool allow_exceptions = true) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = i.get(); - // NOLINTNEXTLINE(hicpp-move-const-arg,performance-move-const-arg) - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::msgpack, &sdp, strict); - return res ? result : basic_json(value_t::discarded); - } - - - /*! - @brief create a JSON value from an input in UBJSON format - - Deserializes a given input @a i to a JSON value using the UBJSON (Universal - Binary JSON) serialization format. - - The library maps UBJSON types to JSON value types as follows: - - UBJSON type | JSON value type | marker - ----------- | --------------------------------------- | ------ - no-op | *no value, next value is read* | `N` - null | `null` | `Z` - false | `false` | `F` - true | `true` | `T` - float32 | number_float | `d` - float64 | number_float | `D` - uint8 | number_unsigned | `U` - int8 | number_integer | `i` - int16 | number_integer | `I` - int32 | number_integer | `l` - int64 | number_integer | `L` - high-precision number | number_integer, number_unsigned, or number_float - depends on number string | 'H' - string | string | `S` - char | string | `C` - array | array (optimized values are supported) | `[` - object | object (optimized values are supported) | `{` - - @note The mapping is **complete** in the sense that any UBJSON value can - be converted to a JSON value. - - @param[in] i an input in UBJSON format convertible to an input adapter - @param[in] strict whether to expect the input to be consumed until EOF - (true by default) - @param[in] allow_exceptions whether to throw exceptions in case of a - parse error (optional, true by default) - - @return deserialized JSON value; in case of a parse error and - @a allow_exceptions set to `false`, the return value will be - value_t::discarded. - - @throw parse_error.110 if the given input ends prematurely or the end of - file was not reached when @a strict was set to true - @throw parse_error.112 if a parse error occurs - @throw parse_error.113 if a string could not be parsed successfully - - @complexity Linear in the size of the input @a i. - - @liveexample{The example shows the deserialization of a byte vector in - UBJSON format to a JSON value.,from_ubjson} - - @sa http://ubjson.org - @sa see @ref to_ubjson(const basic_json&, const bool, const bool) for the - analogous serialization - @sa see @ref from_cbor(InputType&&, const bool, const bool, const cbor_tag_handler_t) for the - related CBOR format - @sa see @ref from_msgpack(InputType&&, const bool, const bool) for - the related MessagePack format - @sa see @ref from_bson(InputType&&, const bool, const bool) for - the related BSON format - - @since version 3.1.0; added @a allow_exceptions parameter since 3.2.0 - */ - template - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json from_ubjson(InputType&& i, - const bool strict = true, - const bool allow_exceptions = true) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = detail::input_adapter(std::forward(i)); - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::ubjson, &sdp, strict); - return res ? result : basic_json(value_t::discarded); - } - - /*! - @copydoc from_ubjson(InputType&&, const bool, const bool) - */ - template - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json from_ubjson(IteratorType first, IteratorType last, - const bool strict = true, - const bool allow_exceptions = true) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = detail::input_adapter(std::move(first), std::move(last)); - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::ubjson, &sdp, strict); - return res ? result : basic_json(value_t::discarded); - } - - template - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len)) - static basic_json from_ubjson(const T* ptr, std::size_t len, - const bool strict = true, - const bool allow_exceptions = true) - { - return from_ubjson(ptr, ptr + len, strict, allow_exceptions); - } - - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len)) - static basic_json from_ubjson(detail::span_input_adapter&& i, - const bool strict = true, - const bool allow_exceptions = true) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = i.get(); - // NOLINTNEXTLINE(hicpp-move-const-arg,performance-move-const-arg) - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::ubjson, &sdp, strict); - return res ? result : basic_json(value_t::discarded); - } - - - /*! - @brief Create a JSON value from an input in BSON format - - Deserializes a given input @a i to a JSON value using the BSON (Binary JSON) - serialization format. - - The library maps BSON record types to JSON value types as follows: - - BSON type | BSON marker byte | JSON value type - --------------- | ---------------- | --------------------------- - double | 0x01 | number_float - string | 0x02 | string - document | 0x03 | object - array | 0x04 | array - binary | 0x05 | binary - undefined | 0x06 | still unsupported - ObjectId | 0x07 | still unsupported - boolean | 0x08 | boolean - UTC Date-Time | 0x09 | still unsupported - null | 0x0A | null - Regular Expr. | 0x0B | still unsupported - DB Pointer | 0x0C | still unsupported - JavaScript Code | 0x0D | still unsupported - Symbol | 0x0E | still unsupported - JavaScript Code | 0x0F | still unsupported - int32 | 0x10 | number_integer - Timestamp | 0x11 | still unsupported - 128-bit decimal float | 0x13 | still unsupported - Max Key | 0x7F | still unsupported - Min Key | 0xFF | still unsupported - - @warning The mapping is **incomplete**. The unsupported mappings - are indicated in the table above. - - @param[in] i an input in BSON format convertible to an input adapter - @param[in] strict whether to expect the input to be consumed until EOF - (true by default) - @param[in] allow_exceptions whether to throw exceptions in case of a - parse error (optional, true by default) - - @return deserialized JSON value; in case of a parse error and - @a allow_exceptions set to `false`, the return value will be - value_t::discarded. - - @throw parse_error.114 if an unsupported BSON record type is encountered - - @complexity Linear in the size of the input @a i. - - @liveexample{The example shows the deserialization of a byte vector in - BSON format to a JSON value.,from_bson} - - @sa http://bsonspec.org/spec.html - @sa see @ref to_bson(const basic_json&) for the analogous serialization - @sa see @ref from_cbor(InputType&&, const bool, const bool, const cbor_tag_handler_t) for the - related CBOR format - @sa see @ref from_msgpack(InputType&&, const bool, const bool) for - the related MessagePack format - @sa see @ref from_ubjson(InputType&&, const bool, const bool) for the - related UBJSON format - */ - template - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json from_bson(InputType&& i, - const bool strict = true, - const bool allow_exceptions = true) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = detail::input_adapter(std::forward(i)); - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::bson, &sdp, strict); - return res ? result : basic_json(value_t::discarded); - } - - /*! - @copydoc from_bson(InputType&&, const bool, const bool) - */ - template - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json from_bson(IteratorType first, IteratorType last, - const bool strict = true, - const bool allow_exceptions = true) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = detail::input_adapter(std::move(first), std::move(last)); - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::bson, &sdp, strict); - return res ? result : basic_json(value_t::discarded); - } - - template - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_bson(ptr, ptr + len)) - static basic_json from_bson(const T* ptr, std::size_t len, - const bool strict = true, - const bool allow_exceptions = true) - { - return from_bson(ptr, ptr + len, strict, allow_exceptions); - } - - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_bson(ptr, ptr + len)) - static basic_json from_bson(detail::span_input_adapter&& i, - const bool strict = true, - const bool allow_exceptions = true) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = i.get(); - // NOLINTNEXTLINE(hicpp-move-const-arg,performance-move-const-arg) - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::bson, &sdp, strict); - return res ? result : basic_json(value_t::discarded); - } - /// @} - - ////////////////////////// - // JSON Pointer support // - ////////////////////////// - - /// @name JSON Pointer functions - /// @{ - - /*! - @brief access specified element via JSON Pointer - - Uses a JSON pointer to retrieve a reference to the respective JSON value. - No bound checking is performed. Similar to @ref operator[](const typename - object_t::key_type&), `null` values are created in arrays and objects if - necessary. - - In particular: - - If the JSON pointer points to an object key that does not exist, it - is created an filled with a `null` value before a reference to it - is returned. - - If the JSON pointer points to an array index that does not exist, it - is created an filled with a `null` value before a reference to it - is returned. All indices between the current maximum and the given - index are also filled with `null`. - - The special value `-` is treated as a synonym for the index past the - end. - - @param[in] ptr a JSON pointer - - @return reference to the element pointed to by @a ptr - - @complexity Constant. - - @throw parse_error.106 if an array index begins with '0' - @throw parse_error.109 if an array index was not a number - @throw out_of_range.404 if the JSON pointer can not be resolved - - @liveexample{The behavior is shown in the example.,operatorjson_pointer} - - @since version 2.0.0 - */ - reference operator[](const json_pointer& ptr) - { - return ptr.get_unchecked(this); - } - - /*! - @brief access specified element via JSON Pointer - - Uses a JSON pointer to retrieve a reference to the respective JSON value. - No bound checking is performed. The function does not change the JSON - value; no `null` values are created. In particular, the special value - `-` yields an exception. - - @param[in] ptr JSON pointer to the desired element - - @return const reference to the element pointed to by @a ptr - - @complexity Constant. - - @throw parse_error.106 if an array index begins with '0' - @throw parse_error.109 if an array index was not a number - @throw out_of_range.402 if the array index '-' is used - @throw out_of_range.404 if the JSON pointer can not be resolved - - @liveexample{The behavior is shown in the example.,operatorjson_pointer_const} - - @since version 2.0.0 - */ - const_reference operator[](const json_pointer& ptr) const - { - return ptr.get_unchecked(this); - } - - /*! - @brief access specified element via JSON Pointer - - Returns a reference to the element at with specified JSON pointer @a ptr, - with bounds checking. - - @param[in] ptr JSON pointer to the desired element - - @return reference to the element pointed to by @a ptr - - @throw parse_error.106 if an array index in the passed JSON pointer @a ptr - begins with '0'. See example below. - - @throw parse_error.109 if an array index in the passed JSON pointer @a ptr - is not a number. See example below. - - @throw out_of_range.401 if an array index in the passed JSON pointer @a ptr - is out of range. See example below. - - @throw out_of_range.402 if the array index '-' is used in the passed JSON - pointer @a ptr. As `at` provides checked access (and no elements are - implicitly inserted), the index '-' is always invalid. See example below. - - @throw out_of_range.403 if the JSON pointer describes a key of an object - which cannot be found. See example below. - - @throw out_of_range.404 if the JSON pointer @a ptr can not be resolved. - See example below. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes in the JSON value. - - @complexity Constant. - - @since version 2.0.0 - - @liveexample{The behavior is shown in the example.,at_json_pointer} - */ - reference at(const json_pointer& ptr) - { - return ptr.get_checked(this); - } - - /*! - @brief access specified element via JSON Pointer - - Returns a const reference to the element at with specified JSON pointer @a - ptr, with bounds checking. - - @param[in] ptr JSON pointer to the desired element - - @return reference to the element pointed to by @a ptr - - @throw parse_error.106 if an array index in the passed JSON pointer @a ptr - begins with '0'. See example below. - - @throw parse_error.109 if an array index in the passed JSON pointer @a ptr - is not a number. See example below. - - @throw out_of_range.401 if an array index in the passed JSON pointer @a ptr - is out of range. See example below. - - @throw out_of_range.402 if the array index '-' is used in the passed JSON - pointer @a ptr. As `at` provides checked access (and no elements are - implicitly inserted), the index '-' is always invalid. See example below. - - @throw out_of_range.403 if the JSON pointer describes a key of an object - which cannot be found. See example below. - - @throw out_of_range.404 if the JSON pointer @a ptr can not be resolved. - See example below. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes in the JSON value. - - @complexity Constant. - - @since version 2.0.0 - - @liveexample{The behavior is shown in the example.,at_json_pointer_const} - */ - const_reference at(const json_pointer& ptr) const - { - return ptr.get_checked(this); - } - - /*! - @brief return flattened JSON value - - The function creates a JSON object whose keys are JSON pointers (see [RFC - 6901](https://tools.ietf.org/html/rfc6901)) and whose values are all - primitive. The original JSON value can be restored using the @ref - unflatten() function. - - @return an object that maps JSON pointers to primitive values - - @note Empty objects and arrays are flattened to `null` and will not be - reconstructed correctly by the @ref unflatten() function. - - @complexity Linear in the size the JSON value. - - @liveexample{The following code shows how a JSON object is flattened to an - object whose keys consist of JSON pointers.,flatten} - - @sa see @ref unflatten() for the reverse function - - @since version 2.0.0 - */ - basic_json flatten() const - { - basic_json result(value_t::object); - json_pointer::flatten("", *this, result); - return result; - } - - /*! - @brief unflatten a previously flattened JSON value - - The function restores the arbitrary nesting of a JSON value that has been - flattened before using the @ref flatten() function. The JSON value must - meet certain constraints: - 1. The value must be an object. - 2. The keys must be JSON pointers (see - [RFC 6901](https://tools.ietf.org/html/rfc6901)) - 3. The mapped values must be primitive JSON types. - - @return the original JSON from a flattened version - - @note Empty objects and arrays are flattened by @ref flatten() to `null` - values and can not unflattened to their original type. Apart from - this example, for a JSON value `j`, the following is always true: - `j == j.flatten().unflatten()`. - - @complexity Linear in the size the JSON value. - - @throw type_error.314 if value is not an object - @throw type_error.315 if object values are not primitive - - @liveexample{The following code shows how a flattened JSON object is - unflattened into the original nested JSON object.,unflatten} - - @sa see @ref flatten() for the reverse function - - @since version 2.0.0 - */ - basic_json unflatten() const - { - return json_pointer::unflatten(*this); - } - - /// @} - - ////////////////////////// - // JSON Patch functions // - ////////////////////////// - - /// @name JSON Patch functions - /// @{ - - /*! - @brief applies a JSON patch - - [JSON Patch](http://jsonpatch.com) defines a JSON document structure for - expressing a sequence of operations to apply to a JSON) document. With - this function, a JSON Patch is applied to the current JSON value by - executing all operations from the patch. - - @param[in] json_patch JSON patch document - @return patched document - - @note The application of a patch is atomic: Either all operations succeed - and the patched document is returned or an exception is thrown. In - any case, the original value is not changed: the patch is applied - to a copy of the value. - - @throw parse_error.104 if the JSON patch does not consist of an array of - objects - - @throw parse_error.105 if the JSON patch is malformed (e.g., mandatory - attributes are missing); example: `"operation add must have member path"` - - @throw out_of_range.401 if an array index is out of range. - - @throw out_of_range.403 if a JSON pointer inside the patch could not be - resolved successfully in the current JSON value; example: `"key baz not - found"` - - @throw out_of_range.405 if JSON pointer has no parent ("add", "remove", - "move") - - @throw other_error.501 if "test" operation was unsuccessful - - @complexity Linear in the size of the JSON value and the length of the - JSON patch. As usually only a fraction of the JSON value is affected by - the patch, the complexity can usually be neglected. - - @liveexample{The following code shows how a JSON patch is applied to a - value.,patch} - - @sa see @ref diff -- create a JSON patch by comparing two JSON values - - @sa [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902) - @sa [RFC 6901 (JSON Pointer)](https://tools.ietf.org/html/rfc6901) - - @since version 2.0.0 - */ - basic_json patch(const basic_json& json_patch) const - { - // make a working copy to apply the patch to - basic_json result = *this; - - // the valid JSON Patch operations - enum class patch_operations {add, remove, replace, move, copy, test, invalid}; - - const auto get_op = [](const std::string & op) - { - if (op == "add") - { - return patch_operations::add; - } - if (op == "remove") - { - return patch_operations::remove; - } - if (op == "replace") - { - return patch_operations::replace; - } - if (op == "move") - { - return patch_operations::move; - } - if (op == "copy") - { - return patch_operations::copy; - } - if (op == "test") - { - return patch_operations::test; - } - - return patch_operations::invalid; - }; - - // wrapper for "add" operation; add value at ptr - const auto operation_add = [&result](json_pointer & ptr, basic_json val) - { - // adding to the root of the target document means replacing it - if (ptr.empty()) - { - result = val; - return; - } - - // make sure the top element of the pointer exists - json_pointer top_pointer = ptr.top(); - if (top_pointer != ptr) - { - result.at(top_pointer); - } - - // get reference to parent of JSON pointer ptr - const auto last_path = ptr.back(); - ptr.pop_back(); - basic_json& parent = result[ptr]; - - switch (parent.m_type) - { - case value_t::null: - case value_t::object: - { - // use operator[] to add value - parent[last_path] = val; - break; - } - - case value_t::array: - { - if (last_path == "-") - { - // special case: append to back - parent.push_back(val); - } - else - { - const auto idx = json_pointer::array_index(last_path); - if (JSON_HEDLEY_UNLIKELY(idx > parent.size())) - { - // avoid undefined behavior - JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range", parent)); - } - - // default case: insert add offset - parent.insert(parent.begin() + static_cast(idx), val); - } - break; - } - - // if there exists a parent it cannot be primitive - case value_t::string: // LCOV_EXCL_LINE - case value_t::boolean: // LCOV_EXCL_LINE - case value_t::number_integer: // LCOV_EXCL_LINE - case value_t::number_unsigned: // LCOV_EXCL_LINE - case value_t::number_float: // LCOV_EXCL_LINE - case value_t::binary: // LCOV_EXCL_LINE - case value_t::discarded: // LCOV_EXCL_LINE - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE - } - }; - - // wrapper for "remove" operation; remove value at ptr - const auto operation_remove = [this, &result](json_pointer & ptr) - { - // get reference to parent of JSON pointer ptr - const auto last_path = ptr.back(); - ptr.pop_back(); - basic_json& parent = result.at(ptr); - - // remove child - if (parent.is_object()) - { - // perform range check - auto it = parent.find(last_path); - if (JSON_HEDLEY_LIKELY(it != parent.end())) - { - parent.erase(it); - } - else - { - JSON_THROW(out_of_range::create(403, "key '" + last_path + "' not found", *this)); - } - } - else if (parent.is_array()) - { - // note erase performs range check - parent.erase(json_pointer::array_index(last_path)); - } - }; - - // type check: top level value must be an array - if (JSON_HEDLEY_UNLIKELY(!json_patch.is_array())) - { - JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects", json_patch)); - } - - // iterate and apply the operations - for (const auto& val : json_patch) - { - // wrapper to get a value for an operation - const auto get_value = [&val](const std::string & op, - const std::string & member, - bool string_type) -> basic_json & - { - // find value - auto it = val.m_value.object->find(member); - - // context-sensitive error message - const auto error_msg = (op == "op") ? "operation" : "operation '" + op + "'"; - - // check if desired value is present - if (JSON_HEDLEY_UNLIKELY(it == val.m_value.object->end())) - { - // NOLINTNEXTLINE(performance-inefficient-string-concatenation) - JSON_THROW(parse_error::create(105, 0, error_msg + " must have member '" + member + "'", val)); - } - - // check if result is of type string - if (JSON_HEDLEY_UNLIKELY(string_type && !it->second.is_string())) - { - // NOLINTNEXTLINE(performance-inefficient-string-concatenation) - JSON_THROW(parse_error::create(105, 0, error_msg + " must have string member '" + member + "'", val)); - } - - // no error: return value - return it->second; - }; - - // type check: every element of the array must be an object - if (JSON_HEDLEY_UNLIKELY(!val.is_object())) - { - JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects", val)); - } - - // collect mandatory members - const auto op = get_value("op", "op", true).template get(); - const auto path = get_value(op, "path", true).template get(); - json_pointer ptr(path); - - switch (get_op(op)) - { - case patch_operations::add: - { - operation_add(ptr, get_value("add", "value", false)); - break; - } - - case patch_operations::remove: - { - operation_remove(ptr); - break; - } - - case patch_operations::replace: - { - // the "path" location must exist - use at() - result.at(ptr) = get_value("replace", "value", false); - break; - } - - case patch_operations::move: - { - const auto from_path = get_value("move", "from", true).template get(); - json_pointer from_ptr(from_path); - - // the "from" location must exist - use at() - basic_json v = result.at(from_ptr); - - // The move operation is functionally identical to a - // "remove" operation on the "from" location, followed - // immediately by an "add" operation at the target - // location with the value that was just removed. - operation_remove(from_ptr); - operation_add(ptr, v); - break; - } - - case patch_operations::copy: - { - const auto from_path = get_value("copy", "from", true).template get(); - const json_pointer from_ptr(from_path); - - // the "from" location must exist - use at() - basic_json v = result.at(from_ptr); - - // The copy is functionally identical to an "add" - // operation at the target location using the value - // specified in the "from" member. - operation_add(ptr, v); - break; - } - - case patch_operations::test: - { - bool success = false; - JSON_TRY - { - // check if "value" matches the one at "path" - // the "path" location must exist - use at() - success = (result.at(ptr) == get_value("test", "value", false)); - } - JSON_INTERNAL_CATCH (out_of_range&) - { - // ignore out of range errors: success remains false - } - - // throw an exception if test fails - if (JSON_HEDLEY_UNLIKELY(!success)) - { - JSON_THROW(other_error::create(501, "unsuccessful: " + val.dump(), val)); - } - - break; - } - - case patch_operations::invalid: - default: - { - // op must be "add", "remove", "replace", "move", "copy", or - // "test" - JSON_THROW(parse_error::create(105, 0, "operation value '" + op + "' is invalid", val)); - } - } - } - - return result; - } - - /*! - @brief creates a diff as a JSON patch - - Creates a [JSON Patch](http://jsonpatch.com) so that value @a source can - be changed into the value @a target by calling @ref patch function. - - @invariant For two JSON values @a source and @a target, the following code - yields always `true`: - @code {.cpp} - source.patch(diff(source, target)) == target; - @endcode - - @note Currently, only `remove`, `add`, and `replace` operations are - generated. - - @param[in] source JSON value to compare from - @param[in] target JSON value to compare against - @param[in] path helper value to create JSON pointers - - @return a JSON patch to convert the @a source to @a target - - @complexity Linear in the lengths of @a source and @a target. - - @liveexample{The following code shows how a JSON patch is created as a - diff for two JSON values.,diff} - - @sa see @ref patch -- apply a JSON patch - @sa see @ref merge_patch -- apply a JSON Merge Patch - - @sa [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902) - - @since version 2.0.0 - */ - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json diff(const basic_json& source, const basic_json& target, - const std::string& path = "") - { - // the patch - basic_json result(value_t::array); - - // if the values are the same, return empty patch - if (source == target) - { - return result; - } - - if (source.type() != target.type()) - { - // different types: replace value - result.push_back( - { - {"op", "replace"}, {"path", path}, {"value", target} - }); - return result; - } - - switch (source.type()) - { - case value_t::array: - { - // first pass: traverse common elements - std::size_t i = 0; - while (i < source.size() && i < target.size()) - { - // recursive call to compare array values at index i - auto temp_diff = diff(source[i], target[i], path + "/" + std::to_string(i)); - result.insert(result.end(), temp_diff.begin(), temp_diff.end()); - ++i; - } - - // i now reached the end of at least one array - // in a second pass, traverse the remaining elements - - // remove my remaining elements - const auto end_index = static_cast(result.size()); - while (i < source.size()) - { - // add operations in reverse order to avoid invalid - // indices - result.insert(result.begin() + end_index, object( - { - {"op", "remove"}, - {"path", path + "/" + std::to_string(i)} - })); - ++i; - } - - // add other remaining elements - while (i < target.size()) - { - result.push_back( - { - {"op", "add"}, - {"path", path + "/-"}, - {"value", target[i]} - }); - ++i; - } - - break; - } - - case value_t::object: - { - // first pass: traverse this object's elements - for (auto it = source.cbegin(); it != source.cend(); ++it) - { - // escape the key name to be used in a JSON patch - const auto path_key = path + "/" + detail::escape(it.key()); - - if (target.find(it.key()) != target.end()) - { - // recursive call to compare object values at key it - auto temp_diff = diff(it.value(), target[it.key()], path_key); - result.insert(result.end(), temp_diff.begin(), temp_diff.end()); - } - else - { - // found a key that is not in o -> remove it - result.push_back(object( - { - {"op", "remove"}, {"path", path_key} - })); - } - } - - // second pass: traverse other object's elements - for (auto it = target.cbegin(); it != target.cend(); ++it) - { - if (source.find(it.key()) == source.end()) - { - // found a key that is not in this -> add it - const auto path_key = path + "/" + detail::escape(it.key()); - result.push_back( - { - {"op", "add"}, {"path", path_key}, - {"value", it.value()} - }); - } - } - - break; - } - - case value_t::null: - case value_t::string: - case value_t::boolean: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::number_float: - case value_t::binary: - case value_t::discarded: - default: - { - // both primitive type: replace value - result.push_back( - { - {"op", "replace"}, {"path", path}, {"value", target} - }); - break; - } - } - - return result; - } - - /// @} - - //////////////////////////////// - // JSON Merge Patch functions // - //////////////////////////////// - - /// @name JSON Merge Patch functions - /// @{ - - /*! - @brief applies a JSON Merge Patch - - The merge patch format is primarily intended for use with the HTTP PATCH - method as a means of describing a set of modifications to a target - resource's content. This function applies a merge patch to the current - JSON value. - - The function implements the following algorithm from Section 2 of - [RFC 7396 (JSON Merge Patch)](https://tools.ietf.org/html/rfc7396): - - ``` - define MergePatch(Target, Patch): - if Patch is an Object: - if Target is not an Object: - Target = {} // Ignore the contents and set it to an empty Object - for each Name/Value pair in Patch: - if Value is null: - if Name exists in Target: - remove the Name/Value pair from Target - else: - Target[Name] = MergePatch(Target[Name], Value) - return Target - else: - return Patch - ``` - - Thereby, `Target` is the current object; that is, the patch is applied to - the current value. - - @param[in] apply_patch the patch to apply - - @complexity Linear in the lengths of @a patch. - - @liveexample{The following code shows how a JSON Merge Patch is applied to - a JSON document.,merge_patch} - - @sa see @ref patch -- apply a JSON patch - @sa [RFC 7396 (JSON Merge Patch)](https://tools.ietf.org/html/rfc7396) - - @since version 3.0.0 - */ - void merge_patch(const basic_json& apply_patch) - { - if (apply_patch.is_object()) - { - if (!is_object()) - { - *this = object(); - } - for (auto it = apply_patch.begin(); it != apply_patch.end(); ++it) - { - if (it.value().is_null()) - { - erase(it.key()); - } - else - { - operator[](it.key()).merge_patch(it.value()); - } - } - } - else - { - *this = apply_patch; - } - } - - /// @} -}; - -/*! -@brief user-defined to_string function for JSON values - -This function implements a user-defined to_string for JSON objects. - -@param[in] j a JSON object -@return a std::string object -*/ - -NLOHMANN_BASIC_JSON_TPL_DECLARATION -std::string to_string(const NLOHMANN_BASIC_JSON_TPL& j) -{ - return j.dump(); -} -} // namespace nlohmann - -/////////////////////// -// nonmember support // -/////////////////////// - -// specialization of std::swap, and std::hash -namespace std -{ - -/// hash value for JSON objects -template<> -struct hash -{ - /*! - @brief return a hash value for a JSON object - - @since version 1.0.0 - */ - std::size_t operator()(const nlohmann::json& j) const - { - return nlohmann::detail::hash(j); - } -}; - -/// specialization for std::less -/// @note: do not remove the space after '<', -/// see https://github.com/nlohmann/json/pull/679 -template<> -struct less<::nlohmann::detail::value_t> -{ - /*! - @brief compare two value_t enum values - @since version 3.0.0 - */ - bool operator()(nlohmann::detail::value_t lhs, - nlohmann::detail::value_t rhs) const noexcept - { - return nlohmann::detail::operator<(lhs, rhs); - } -}; - -// C++20 prohibit function specialization in the std namespace. -#ifndef JSON_HAS_CPP_20 - -/*! -@brief exchanges the values of two JSON objects - -@since version 1.0.0 -*/ -template<> -inline void swap(nlohmann::json& j1, nlohmann::json& j2) noexcept( // NOLINT(readability-inconsistent-declaration-parameter-name) - is_nothrow_move_constructible::value&& // NOLINT(misc-redundant-expression) - is_nothrow_move_assignable::value - ) -{ - j1.swap(j2); -} - -#endif - -} // namespace std - -/*! -@brief user-defined string literal for JSON values - -This operator implements a user-defined string literal for JSON objects. It -can be used by adding `"_json"` to a string literal and returns a JSON object -if no parse error occurred. - -@param[in] s a string representation of a JSON object -@param[in] n the length of string @a s -@return a JSON object - -@since version 1.0.0 -*/ -JSON_HEDLEY_NON_NULL(1) -inline nlohmann::json operator "" _json(const char* s, std::size_t n) -{ - return nlohmann::json::parse(s, s + n); -} - -/*! -@brief user-defined string literal for JSON pointer - -This operator implements a user-defined string literal for JSON Pointers. It -can be used by adding `"_json_pointer"` to a string literal and returns a JSON pointer -object if no parse error occurred. - -@param[in] s a string representation of a JSON Pointer -@param[in] n the length of string @a s -@return a JSON pointer object - -@since version 2.0.0 -*/ -JSON_HEDLEY_NON_NULL(1) -inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t n) -{ - return nlohmann::json::json_pointer(std::string(s, n)); -} - -// #include - - -// restore clang diagnostic settings -#if defined(__clang__) - #pragma clang diagnostic pop -#endif - -// clean up -#undef JSON_ASSERT -#undef JSON_INTERNAL_CATCH -#undef JSON_CATCH -#undef JSON_THROW -#undef JSON_TRY -#undef JSON_PRIVATE_UNLESS_TESTED -#undef JSON_HAS_CPP_11 -#undef JSON_HAS_CPP_14 -#undef JSON_HAS_CPP_17 -#undef JSON_HAS_CPP_20 -#undef NLOHMANN_BASIC_JSON_TPL_DECLARATION -#undef NLOHMANN_BASIC_JSON_TPL -#undef JSON_EXPLICIT -#undef NLOHMANN_CAN_CALL_STD_FUNC_IMPL - -// #include - - -#undef JSON_HEDLEY_ALWAYS_INLINE -#undef JSON_HEDLEY_ARM_VERSION -#undef JSON_HEDLEY_ARM_VERSION_CHECK -#undef JSON_HEDLEY_ARRAY_PARAM -#undef JSON_HEDLEY_ASSUME -#undef JSON_HEDLEY_BEGIN_C_DECLS -#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE -#undef JSON_HEDLEY_CLANG_HAS_BUILTIN -#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE -#undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE -#undef JSON_HEDLEY_CLANG_HAS_EXTENSION -#undef JSON_HEDLEY_CLANG_HAS_FEATURE -#undef JSON_HEDLEY_CLANG_HAS_WARNING -#undef JSON_HEDLEY_COMPCERT_VERSION -#undef JSON_HEDLEY_COMPCERT_VERSION_CHECK -#undef JSON_HEDLEY_CONCAT -#undef JSON_HEDLEY_CONCAT3 -#undef JSON_HEDLEY_CONCAT3_EX -#undef JSON_HEDLEY_CONCAT_EX -#undef JSON_HEDLEY_CONST -#undef JSON_HEDLEY_CONSTEXPR -#undef JSON_HEDLEY_CONST_CAST -#undef JSON_HEDLEY_CPP_CAST -#undef JSON_HEDLEY_CRAY_VERSION -#undef JSON_HEDLEY_CRAY_VERSION_CHECK -#undef JSON_HEDLEY_C_DECL -#undef JSON_HEDLEY_DEPRECATED -#undef JSON_HEDLEY_DEPRECATED_FOR -#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL -#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ -#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED -#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES -#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS -#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION -#undef JSON_HEDLEY_DIAGNOSTIC_POP -#undef JSON_HEDLEY_DIAGNOSTIC_PUSH -#undef JSON_HEDLEY_DMC_VERSION -#undef JSON_HEDLEY_DMC_VERSION_CHECK -#undef JSON_HEDLEY_EMPTY_BASES -#undef JSON_HEDLEY_EMSCRIPTEN_VERSION -#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK -#undef JSON_HEDLEY_END_C_DECLS -#undef JSON_HEDLEY_FLAGS -#undef JSON_HEDLEY_FLAGS_CAST -#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE -#undef JSON_HEDLEY_GCC_HAS_BUILTIN -#undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE -#undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE -#undef JSON_HEDLEY_GCC_HAS_EXTENSION -#undef JSON_HEDLEY_GCC_HAS_FEATURE -#undef JSON_HEDLEY_GCC_HAS_WARNING -#undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK -#undef JSON_HEDLEY_GCC_VERSION -#undef JSON_HEDLEY_GCC_VERSION_CHECK -#undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE -#undef JSON_HEDLEY_GNUC_HAS_BUILTIN -#undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE -#undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE -#undef JSON_HEDLEY_GNUC_HAS_EXTENSION -#undef JSON_HEDLEY_GNUC_HAS_FEATURE -#undef JSON_HEDLEY_GNUC_HAS_WARNING -#undef JSON_HEDLEY_GNUC_VERSION -#undef JSON_HEDLEY_GNUC_VERSION_CHECK -#undef JSON_HEDLEY_HAS_ATTRIBUTE -#undef JSON_HEDLEY_HAS_BUILTIN -#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE -#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS -#undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE -#undef JSON_HEDLEY_HAS_EXTENSION -#undef JSON_HEDLEY_HAS_FEATURE -#undef JSON_HEDLEY_HAS_WARNING -#undef JSON_HEDLEY_IAR_VERSION -#undef JSON_HEDLEY_IAR_VERSION_CHECK -#undef JSON_HEDLEY_IBM_VERSION -#undef JSON_HEDLEY_IBM_VERSION_CHECK -#undef JSON_HEDLEY_IMPORT -#undef JSON_HEDLEY_INLINE -#undef JSON_HEDLEY_INTEL_CL_VERSION -#undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK -#undef JSON_HEDLEY_INTEL_VERSION -#undef JSON_HEDLEY_INTEL_VERSION_CHECK -#undef JSON_HEDLEY_IS_CONSTANT -#undef JSON_HEDLEY_IS_CONSTEXPR_ -#undef JSON_HEDLEY_LIKELY -#undef JSON_HEDLEY_MALLOC -#undef JSON_HEDLEY_MCST_LCC_VERSION -#undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK -#undef JSON_HEDLEY_MESSAGE -#undef JSON_HEDLEY_MSVC_VERSION -#undef JSON_HEDLEY_MSVC_VERSION_CHECK -#undef JSON_HEDLEY_NEVER_INLINE -#undef JSON_HEDLEY_NON_NULL -#undef JSON_HEDLEY_NO_ESCAPE -#undef JSON_HEDLEY_NO_RETURN -#undef JSON_HEDLEY_NO_THROW -#undef JSON_HEDLEY_NULL -#undef JSON_HEDLEY_PELLES_VERSION -#undef JSON_HEDLEY_PELLES_VERSION_CHECK -#undef JSON_HEDLEY_PGI_VERSION -#undef JSON_HEDLEY_PGI_VERSION_CHECK -#undef JSON_HEDLEY_PREDICT -#undef JSON_HEDLEY_PRINTF_FORMAT -#undef JSON_HEDLEY_PRIVATE -#undef JSON_HEDLEY_PUBLIC -#undef JSON_HEDLEY_PURE -#undef JSON_HEDLEY_REINTERPRET_CAST -#undef JSON_HEDLEY_REQUIRE -#undef JSON_HEDLEY_REQUIRE_CONSTEXPR -#undef JSON_HEDLEY_REQUIRE_MSG -#undef JSON_HEDLEY_RESTRICT -#undef JSON_HEDLEY_RETURNS_NON_NULL -#undef JSON_HEDLEY_SENTINEL -#undef JSON_HEDLEY_STATIC_ASSERT -#undef JSON_HEDLEY_STATIC_CAST -#undef JSON_HEDLEY_STRINGIFY -#undef JSON_HEDLEY_STRINGIFY_EX -#undef JSON_HEDLEY_SUNPRO_VERSION -#undef JSON_HEDLEY_SUNPRO_VERSION_CHECK -#undef JSON_HEDLEY_TINYC_VERSION -#undef JSON_HEDLEY_TINYC_VERSION_CHECK -#undef JSON_HEDLEY_TI_ARMCL_VERSION -#undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK -#undef JSON_HEDLEY_TI_CL2000_VERSION -#undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK -#undef JSON_HEDLEY_TI_CL430_VERSION -#undef JSON_HEDLEY_TI_CL430_VERSION_CHECK -#undef JSON_HEDLEY_TI_CL6X_VERSION -#undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK -#undef JSON_HEDLEY_TI_CL7X_VERSION -#undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK -#undef JSON_HEDLEY_TI_CLPRU_VERSION -#undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK -#undef JSON_HEDLEY_TI_VERSION -#undef JSON_HEDLEY_TI_VERSION_CHECK -#undef JSON_HEDLEY_UNAVAILABLE -#undef JSON_HEDLEY_UNLIKELY -#undef JSON_HEDLEY_UNPREDICTABLE -#undef JSON_HEDLEY_UNREACHABLE -#undef JSON_HEDLEY_UNREACHABLE_RETURN -#undef JSON_HEDLEY_VERSION -#undef JSON_HEDLEY_VERSION_DECODE_MAJOR -#undef JSON_HEDLEY_VERSION_DECODE_MINOR -#undef JSON_HEDLEY_VERSION_DECODE_REVISION -#undef JSON_HEDLEY_VERSION_ENCODE -#undef JSON_HEDLEY_WARNING -#undef JSON_HEDLEY_WARN_UNUSED_RESULT -#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG -#undef JSON_HEDLEY_FALL_THROUGH - - - -#endif // INCLUDE_NLOHMANN_JSON_HPP_ diff --git a/extern/tfn/widget.h b/extern/tfn/widget.h deleted file mode 100644 index c3acd79..0000000 --- a/extern/tfn/widget.h +++ /dev/null @@ -1,699 +0,0 @@ -// ======================================================================== // -// Copyright Qi Wu, since 2019 // -// Copyright SCI Institute, University of Utah, 2018 // -// ======================================================================== // -#pragma once - -#ifndef _USE_MATH_DEFINES -#define _USE_MATH_DEFINES -#endif - -#define GLFW_INCLUDE_NONE -#include - -#include "core.h" -#include "default.h" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace tfn { - -class TFN_MODULE_INTERFACE TransferFunctionWidget -{ - private: - using setter = std::function; - - private: - /* Variables Controlled by Users */ - setter _setter_cb; - vec2f valueRange; //< the current value range controlled by the user - vec2f defaultRange; //< the default value range being displayed on the GUI - - /* The 2d palette texture on the GPU for displaying the color map preview in the UI. */ - GLuint tfn_palette; - - // all available transfer functions - std::vector tfns_names; - std::vector tfns; - - using ColorPoint = tfn::TransferFunctionCore::ColorControl; - using AlphaPoint = tfn::TransferFunctionCore::AlphaControl; - using GaussianPoint = tfn::TransferFunctionCore::GaussianObject; - - // properties of currently selected transfer function - int tfn_selection{-1}; - std::vector* current_colorpoints{}; - std::vector* current_alphapoints{}; - vec2i current_tfn_editable{1, 1}; - - std::vector uneditable_alphapoints; - - // flag indicating transfer function has changed in UI - bool tfn_changed{true}; - bool tfn_applied{true}; - - // scaling factor for generated alphas - float global_alpha_scale{1.f}; - - // domain (value range) of transfer function - vec2f value_range{-1.f, 1.f}; - vec2f value_range_default{-1.f, 1.f}; - vec2f value_range_percentage{0.f, 100.f}; - - // The filename input text buffer - std::vector tfn_text_buffer; - - public: - ~TransferFunctionWidget(); - TransferFunctionWidget(const setter &); - - /* Setup the default data value range for the transfer function */ - void set_default_value_range(const float &a, const float &b); - - /* Draw the transfer function editor widget, returns true if the transfer function changed */ - bool build(bool *p_open = NULL, bool do_not_render_textures = false); - - /* Construct the ImGui GUI */ - void build_gui(); - - /* Render the transfer function to a 1D texture that can be applied to volume data */ - void render(int tfn_w = 256, int tfn_h = 1); - - /* Load the transfer function in the file passed and set it active */ - void load(const std::string &fileName); - - /* Save the current transfer function out to the file */ - void save(const std::string &fileName) const; - - /* Create a new TFN profile */ - // void add_tfn(const tfn::TransferFunctionCore& core, const std::string &name); - void add_tfn(const list4f &, const list2f &, const std::string &name); - - private: - /* Change selection */ - void select_tfn(int selection); - /** Load all the pre-defined transfer function maps */ - void set_default_tfns(); - /** Draw the Tfn Editor in a window */ - void draw_tfn_editor(const float margin, const float height); - tfn::vec4f draw_tfn_editor__preview_texture(void *_draw_list, const tfn::vec3f &, const tfn::vec2f &, const tfn::vec4f &); - tfn::vec4f draw_tfn_editor__color_control_points(void *_draw_list, const tfn::vec3f &, const tfn::vec2f &, const tfn::vec4f &, const float &); - tfn::vec4f draw_tfn_editor__alpha_control_points(void *_draw_list, const tfn::vec3f &, const tfn::vec2f &, const tfn::vec4f &, const float &); - tfn::vec4f draw_tfn_editor__interaction_blocks(void *_draw_list, const tfn::vec3f &, const tfn::vec2f &, const tfn::vec4f &, const float &, const float &); -}; - -inline void TransferFunctionWidget::select_tfn(int selection) -{ - if (tfn_selection != selection) - { - tfn_selection = selection; - - auto& tfn = tfns[tfn_selection]; - - current_colorpoints = tfn.colorControlVector(); - current_tfn_editable.x = (tfn.colorControlCount() > 128) ? 0 : 1; - - // in this case we have to use the raw RGBA table - if (tfn.alphaControlCount() == 0 || tfn.gaussianObjectCount() > 0) - { - uneditable_alphapoints.resize(tfn.resolution()); - const auto *table = (vec4f *)tfn.data(); - for (int i = 0; i < uneditable_alphapoints.size(); ++i) { - uneditable_alphapoints[i] = vec2f((float)i / (uneditable_alphapoints.size() - 1), table[i].w); - } - current_alphapoints = &uneditable_alphapoints; - current_tfn_editable.y = 0; - } - else { - current_alphapoints = tfn.alphaControlVector(); - current_tfn_editable.y = (tfn.alphaControlCount() > 128) ? 0 : 1; - } - - tfn_changed = true; - } -} - -inline TransferFunctionWidget::~TransferFunctionWidget() -{ - if (tfn_palette) glDeleteTextures(1, &tfn_palette); -} - -inline TransferFunctionWidget::TransferFunctionWidget(const setter &fcn) - : tfn_changed(true), tfn_palette(0), tfn_text_buffer(512, '\0'), _setter_cb(fcn), valueRange{0.f, 0.f}, defaultRange{0.f, 0.f} -{ - set_default_tfns(); - select_tfn(0); -} - -// inline void TransferFunctionWidget::add_tfn(const tfn::TransferFunctionCore& core, const std::string &name) -// { -// auto it = std::find(tfns_names.begin(), tfns_names.end(), name); -// if (it == tfns_names.end()) { -// tfns.push_back(core); -// tfns.back().updateColorMap(); -// tfns_names.push_back(name); -// select_tfn((int)(tfns.size() - 1)); // Remember to update other constructors also -// } else { -// select_tfn((int)std::distance(tfns_names.begin(), it)); -// } -// } - -inline void TransferFunctionWidget::add_tfn(const list4f &ct, const list2f &ot, const std::string &name) -{ - auto it = std::find(tfns_names.begin(), tfns_names.end(), name); - - if (it == tfns_names.end()) { - tfns.emplace_back(); - auto& tfn = tfns.back(); - - for (size_t i = 0; i < ct.size(); ++i) { - tfn.addColorControl(ct[i].x, ct[i].y, ct[i].z, ct[i].w); - } - - for (size_t i = 0; i < ot.size(); ++i) { - tfn.addAlphaControl(vec2f{ot[i].x, ot[i].y}); - } - - tfn.updateColorMap(); - - tfns_names.push_back(name); - - select_tfn((int)(tfns.size() - 1)); // Remember to update other constructors also - } else { - select_tfn((int)std::distance(tfns_names.begin(), it)); - } -} - -inline void TransferFunctionWidget::set_default_value_range(const float &a, const float &b) -{ - if (b >= a) { - valueRange.x = defaultRange.x = a; - valueRange.y = defaultRange.y = b; - tfn_changed = true; - } -} - -inline tfn::vec4f TransferFunctionWidget::draw_tfn_editor__preview_texture(void *_draw_list, - const tfn::vec3f &margin, /* left, right, spacing*/ - const tfn::vec2f &size, - const tfn::vec4f &cursor) -{ - auto draw_list = (ImDrawList *)_draw_list; - ImGui::SetCursorScreenPos(ImVec2(cursor.x + margin.x, cursor.y)); - ImGui::Image(reinterpret_cast(tfn_palette), (const ImVec2 &)size); - ImGui::SetCursorScreenPos((const ImVec2 &)cursor); - // TODO: more generic way of drawing arbitary splats - for (int i = 0; i < current_alphapoints->size() - 1; ++i) { - std::vector polyline; - polyline.emplace_back(cursor.x + margin.x + (*current_alphapoints)[i].pos.x * size.x, cursor.y + size.y); - polyline.emplace_back(cursor.x + margin.x + (*current_alphapoints)[i].pos.x * size.x, cursor.y + (1.f - (*current_alphapoints)[i].pos.y) * size.y); - polyline.emplace_back(cursor.x + margin.x + (*current_alphapoints)[i + 1].pos.x * size.x + 1, cursor.y + (1.f - (*current_alphapoints)[i + 1].pos.y) * size.y); - polyline.emplace_back(cursor.x + margin.x + (*current_alphapoints)[i + 1].pos.x * size.x + 1, cursor.y + size.y); -#ifdef IMGUI_VERSION_NUM - draw_list->AddConvexPolyFilled(polyline.data(), (int)polyline.size(), 0xFFD8D8D8 /*, true*/); -#else - draw_list->AddConvexPolyFilled(polyline.data(), (int)polyline.size(), 0xFFD8D8D8, true); -#endif - } - tfn::vec4f new_cursor = { - cursor.x, - cursor.y + size.y + margin.z, - cursor.z, - cursor.w - size.y, - }; - ImGui::SetCursorScreenPos((const ImVec2 &)new_cursor); - return new_cursor; -} - -inline tfn::vec4f TransferFunctionWidget::draw_tfn_editor__color_control_points(void *_draw_list, - const tfn::vec3f &margin, /* left, right, spacing*/ - const tfn::vec2f &size, - const tfn::vec4f &cursor, - const float &color_len) -{ - auto draw_list = (ImDrawList *)_draw_list; - // draw circle background - draw_list->AddRectFilled( - ImVec2(cursor.x + margin.x, cursor.y - margin.z), - ImVec2(cursor.x + margin.x + size.x, cursor.y - margin.x + 2.5f * color_len), - 0xFF474646 - ); - // draw circles - for (int i = (int)current_colorpoints->size() - 1; i >= 0; --i) { - const ImVec2 pos(cursor.x + size.x * (*current_colorpoints)[i].position + margin.x, cursor.y); - ImGui::SetCursorScreenPos(ImVec2(cursor.x, cursor.y)); - // white background - draw_list->AddTriangleFilled( - ImVec2(pos.x - 0.5f * color_len, pos.y), ImVec2(pos.x + 0.5f * color_len, pos.y), ImVec2(pos.x, pos.y - color_len), 0xFFD8D8D8); - draw_list->AddCircleFilled(ImVec2(pos.x, pos.y + 0.5f * color_len), color_len, 0xFFD8D8D8); - // draw picker - ImVec4 picked_color = ImColor((*current_colorpoints)[i].color.x, (*current_colorpoints)[i].color.y, (*current_colorpoints)[i].color.z, 1.f); - ImGui::SetCursorScreenPos(ImVec2(pos.x - color_len, pos.y + 1.5f * color_len)); - if (ImGui::ColorEdit4(("##ColorPicker" + std::to_string(i)).c_str(), - (float *)&picked_color, - ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_AlphaPreview - | ImGuiColorEditFlags_NoOptions | ImGuiColorEditFlags_NoTooltip)) { - (*current_colorpoints)[i].color.x = picked_color.x; - (*current_colorpoints)[i].color.y = picked_color.y; - (*current_colorpoints)[i].color.z = picked_color.z; - tfn_changed = true; - } - if (ImGui::IsItemHovered()) { - // convert float color to char - int cr = static_cast(picked_color.x * 255); - int cg = static_cast(picked_color.y * 255); - int cb = static_cast(picked_color.z * 255); - // setup tooltip - ImGui::BeginTooltip(); - ImVec2 sz(ImGui::GetFontSize() * 4 + ImGui::GetStyle().FramePadding.y * 2, ImGui::GetFontSize() * 4 + ImGui::GetStyle().FramePadding.y * 2); - ImGui::ColorButton("##PreviewColor", picked_color, ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaPreview, sz); - ImGui::SameLine(); - ImGui::Text( - "Left click to edit\n" - "HEX: #%02X%02X%02X\n" - "RGB: [%3d,%3d,%3d]\n(%.2f, %.2f, %.2f)", - cr, - cg, - cb, - cr, - cg, - cb, - picked_color.x, - picked_color.y, - picked_color.z); - ImGui::EndTooltip(); - } - } - for (int i = 0; i < current_colorpoints->size(); ++i) { - const ImVec2 pos(cursor.x + size.x * (*current_colorpoints)[i].position + margin.x, cursor.y); - // draw button - ImGui::SetCursorScreenPos(ImVec2(pos.x - color_len, pos.y - 0.5f * color_len)); - ImGui::InvisibleButton(("##ColorControl-" + std::to_string(i)).c_str(), ImVec2(2.f * color_len, 2.f * color_len)); - // dark highlight - ImGui::SetCursorScreenPos(ImVec2(pos.x - color_len, pos.y)); - draw_list->AddCircleFilled(ImVec2(pos.x, pos.y + 0.5f * color_len), 0.5f * color_len, ImGui::IsItemHovered() ? 0xFF051C33 : 0xFFBCBCBC); - // delete color point - if (ImGui::IsMouseDoubleClicked(1) && ImGui::IsItemHovered()) { - if (i > 0 && i < current_colorpoints->size() - 1) { - current_colorpoints->erase(current_colorpoints->begin() + i); - tfn_changed = true; - } - } - // drag color control point - else if (ImGui::IsItemActive()) { - ImVec2 delta = ImGui::GetIO().MouseDelta; - if (i > 0 && i < current_colorpoints->size() - 1) { - (*current_colorpoints)[i].position += delta.x / size.x; - (*current_colorpoints)[i].position = clamp((*current_colorpoints)[i].position, (*current_colorpoints)[i - 1].position, (*current_colorpoints)[i + 1].position); - } - tfn_changed = true; - } - } - return vec4f(); -} - -inline tfn::vec4f TransferFunctionWidget::draw_tfn_editor__alpha_control_points(/**/ - void *_draw_list, - const tfn::vec3f &margin, /* left, right, spacing*/ - const tfn::vec2f &size, - const tfn::vec4f &cursor, - const float &alpha_len) -{ - auto draw_list = (ImDrawList *)_draw_list; - // draw circles - for (int i = 0; i < current_alphapoints->size(); ++i) { - const ImVec2 pos(cursor.x + size.x * (*current_alphapoints)[i].pos.x + margin.x, cursor.y - size.y * (*current_alphapoints)[i].pos.y - margin.z); - ImGui::SetCursorScreenPos(ImVec2(pos.x - alpha_len, pos.y - alpha_len)); - ImGui::InvisibleButton(("##AlphaControl-" + std::to_string(i)).c_str(), ImVec2(2.f * alpha_len, 2.f * alpha_len)); - ImGui::SetCursorScreenPos(ImVec2(cursor.x, cursor.y)); - // dark bounding box - draw_list->AddCircleFilled(pos, alpha_len, 0xFF565656); - // white background - draw_list->AddCircleFilled(pos, 0.8f * alpha_len, 0xFFD8D8D8); - // highlight - draw_list->AddCircleFilled(pos, 0.6f * alpha_len, ImGui::IsItemHovered() ? 0xFF051c33 : 0xFFD8D8D8); - // delete alpha point - if (ImGui::IsMouseDoubleClicked(1) && ImGui::IsItemHovered()) { - if (i > 0 && i < current_alphapoints->size() - 1) { - current_alphapoints->erase(current_alphapoints->begin() + i); - tfn_changed = true; - } - } - // drag alpha control point - else if (ImGui::IsItemActive()) { - ImVec2 delta = ImGui::GetIO().MouseDelta; - (*current_alphapoints)[i].pos.y -= delta.y / size.y; - (*current_alphapoints)[i].pos.y = clamp((*current_alphapoints)[i].pos.y, 0.0f, 1.0f); - if (i > 0 && i < current_alphapoints->size() - 1) { - (*current_alphapoints)[i].pos.x += delta.x / size.x; - (*current_alphapoints)[i].pos.x = clamp((*current_alphapoints)[i].pos.x, (*current_alphapoints)[i - 1].pos.x, (*current_alphapoints)[i + 1].pos.x); - } - tfn_changed = true; - } - } - return vec4f(); -} - -inline tfn::vec4f TransferFunctionWidget::draw_tfn_editor__interaction_blocks(/**/ - void *_draw_list, - const tfn::vec3f &margin, /* left, right, spacing */ - const tfn::vec2f &size, - const tfn::vec4f &cursor, - const float &color_len, - const float &alpha_len) -{ - const float mouse_x = ImGui::GetMousePos().x; - const float mouse_y = ImGui::GetMousePos().y; - const float scroll_x = ImGui::GetScrollX(); - const float scroll_y = ImGui::GetScrollY(); - auto draw_list = (ImDrawList *)_draw_list; - ImGui::SetCursorScreenPos(ImVec2(cursor.x + margin.x, cursor.y - margin.z)); - ImGui::InvisibleButton("##tfn_palette_color", ImVec2(size.x, 2.5f * color_len)); - // add color point - if (current_tfn_editable.x && ImGui::IsMouseDoubleClicked(0) && ImGui::IsItemHovered()) { - const float p = clamp((mouse_x - cursor.x - margin.x - scroll_x) / (float)size.x, 0.f, 1.f); - int il, ir; - std::tie(il, ir) = find_interval(current_colorpoints, p); - const float pr = (*current_colorpoints)[ir].position; - const float pl = (*current_colorpoints)[il].position; - const float r = lerp((*current_colorpoints)[il].color.x, (*current_colorpoints)[ir].color.x, pl, pr, p); - const float g = lerp((*current_colorpoints)[il].color.y, (*current_colorpoints)[ir].color.y, pl, pr, p); - const float b = lerp((*current_colorpoints)[il].color.z, (*current_colorpoints)[ir].color.z, pl, pr, p); - ColorPoint pt; - pt.position = p, pt.color.x = r, pt.color.y = g, pt.color.z = b; - current_colorpoints->insert(current_colorpoints->begin() + ir, pt); - tfn_changed = true; - } - // draw background interaction - ImGui::SetCursorScreenPos(ImVec2(cursor.x + margin.x, cursor.y - size.y - margin.z)); - if (size.x > 0 && size.y > 0) ImGui::InvisibleButton("##tfn_palette_alpha", ImVec2(size.x, size.y)); - // add alpha point - if (current_tfn_editable.y && ImGui::IsMouseDoubleClicked(0) && ImGui::IsItemHovered()) { - const float x = clamp((mouse_x - cursor.x - margin.x - scroll_x) / (float)size.x, 0.f, 1.f); - const float y = clamp(-(mouse_y - cursor.y + margin.x - scroll_y) / (float)size.y, 0.f, 1.f); - int il, ir; - std::tie(il, ir) = find_interval(current_alphapoints, x); - AlphaPoint pt; - pt.pos.x = x, pt.pos.y = y; - current_alphapoints->insert(current_alphapoints->begin() + ir, pt); - tfn_changed = true; - } - return vec4f(); -} - -inline void TransferFunctionWidget::draw_tfn_editor(const float margin, const float height) -{ - // style - ImDrawList *draw_list = ImGui::GetWindowDrawList(); - const float canvas_x = ImGui::GetCursorScreenPos().x; - float canvas_y = ImGui::GetCursorScreenPos().y; - const float width = ImGui::GetContentRegionAvail().x - 2.f * margin; - const float color_len = 10.f; - const float alpha_len = 10.f; - // debug - const tfn::vec3f m{margin, margin, margin}; - const tfn::vec2f s{width, height}; - tfn::vec4f c = {canvas_x, canvas_y, ImGui::GetContentRegionAvail().x, ImGui::GetContentRegionAvail().y}; - // draw preview texture - c = draw_tfn_editor__preview_texture(draw_list, m, s, c); - canvas_y = c.y; - // draw color control points - ImGui::SetCursorScreenPos(ImVec2(canvas_x, canvas_y)); - if (current_tfn_editable.x) { - draw_tfn_editor__color_control_points(draw_list, m, s, c, color_len); - } - // draw alpha control points - ImGui::SetCursorScreenPos(ImVec2(canvas_x, canvas_y)); - if (current_tfn_editable.y) { - draw_tfn_editor__alpha_control_points(draw_list, m, s, c, alpha_len); - } - // draw background interaction - draw_tfn_editor__interaction_blocks(draw_list, m, s, c, color_len, alpha_len); - // update cursors - canvas_y += 4.f * color_len + margin; - ImGui::SetCursorScreenPos(ImVec2(canvas_x, canvas_y)); -} - -inline bool TransferFunctionWidget::build(bool *p_open, bool do_not_render_textures) -{ - // ImGui::ShowTestWindow(); - - ImGui::SetNextWindowSizeConstraints(ImVec2(400, 250), ImVec2(FLT_MAX, FLT_MAX)); - - if (!ImGui::Begin("Transfer Function Widget", p_open)) { - ImGui::End(); - return false; - } - - build_gui(); - - ImGui::End(); - - if (!do_not_render_textures) - render(); - - return true; -} - -void TransferFunctionWidget::build_gui() -{ - //------------ Styling ------------------------------ - const float margin = 10.f; - - //------------ Basic Controls ----------------------- - ImGui::Spacing(); - ImGui::SetCursorPosX(margin); - ImGui::BeginGroup(); - { - // /* title */ - // ImGui::Text("1D Transfer Function Editor"); - // ImGui::SameLine(); - // { - // ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 2.f); - // ImGui::Button("help"); - // if (ImGui::IsItemHovered()) { - // ImGui::SetTooltip( - // "Double right click a control point to delete it\n" - // "Single left click and drag a control point to move it\n" - // "Double left click on an empty area to add a control point\n"); - // } - // ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 2.f); - // } - // ImGui::Spacing(); - - /* load a transfer function from file */ - ImGui::InputText("", tfn_text_buffer.data(), tfn_text_buffer.size() - 1); - ImGui::SameLine(); - if (ImGui::Button("load tfn")) { - try { - std::string s = tfn_text_buffer.data(); - s.erase(s.find_last_not_of(" \n\r\t") + 1); - s.erase(0, s.find_first_not_of(" \n\r\t")); - load(s.c_str()); - } catch (const std::runtime_error &error) { - std::cerr << "\033[1;33m" << "Error: " << error.what() << "\033[0m" << std::endl; - } - - tfn_text_buffer = std::vector(512, '\0'); - } - - // save function is not implemented - ImGui::SameLine(); - if (ImGui::Button("save")) { - save(tfn_text_buffer.data()); - tfn_text_buffer = std::vector(512, '\0'); - } - - /* Built-in color lists */ - { - static int curr_tfn = tfn_selection; - static std::string curr_names = ""; - curr_names = ""; - for (auto &n : tfns_names) { - curr_names += n + '\0'; - } - if (ImGui::Combo(" color tables", &curr_tfn, curr_names.c_str())) { - select_tfn(curr_tfn); - } - } - - /* Display transfer function value range */ - static vec2f value_range_percentage(0.f, 100.f); - if (defaultRange.y > defaultRange.x) { - ImGui::Text(" default value range (%.6f, %.6f)", defaultRange.x, defaultRange.y); - ImGui::Text(" current value range (%.6f, %.6f)", valueRange.x, valueRange.y); - if (ImGui::DragFloat2(" value range %", (float *)&value_range_percentage, 1.f, 0.f, 100.f, "%.3f")) { - tfn_changed = true; - valueRange.x = (defaultRange.y - defaultRange.x) * value_range_percentage.x * 0.01f + defaultRange.x; - valueRange.y = (defaultRange.y - defaultRange.x) * value_range_percentage.y * 0.01f + defaultRange.x; - } - } - } - - ImGui::EndGroup(); - - //------------ Transfer Function Editor ------------- - - ImGui::Spacing(); - draw_tfn_editor(11.f, ImGui::GetContentRegionAvail().y - 60.f); - - //------------ End Transfer Function Editor --------- -} - -inline void renderTFNTexture(GLuint &tex, int width, int height) -{ - GLint prev_binding = 0; - glGetIntegerv(GL_TEXTURE_BINDING_2D, &prev_binding); - glGenTextures(1, &tex); - glBindTexture(GL_TEXTURE_2D, tex); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - if (prev_binding) { - glBindTexture(GL_TEXTURE_2D, prev_binding); - } -} - -inline void TransferFunctionWidget::render(int tfn_w, int tfn_h) -{ - // Upload to GL if the transfer function has changed - if (!tfn_palette) { - renderTFNTexture(tfn_palette, tfn_w, tfn_h); - } else { - /* ... */ - } - - // Update texture color - if (tfn_changed) { - // Backup old states - GLint prev_binding = 0; - glGetIntegerv(GL_TEXTURE_BINDING_2D, &prev_binding); - - // Sample the palette then upload the data - std::vector palette(tfn_w * tfn_h * 4, 0); - std::vector colors(tfn_w, 1.f); - std::vector alpha(tfn_w, 1.f); - const float step = 1.0f / (float)(tfn_w - 1); - for (int i = 0; i < tfn_w; ++i) { - const float p = clamp(i * step, 0.0f, 1.0f); - int ir, il; - /* color */ - { - std::tie(il, ir) = find_interval(current_colorpoints, p); - float pl = current_colorpoints->at(il).position; - float pr = current_colorpoints->at(ir).position; - const float r = lerp(current_colorpoints->at(il).color.x, current_colorpoints->at(ir).color.x, pl, pr, p); - const float g = lerp(current_colorpoints->at(il).color.y, current_colorpoints->at(ir).color.y, pl, pr, p); - const float b = lerp(current_colorpoints->at(il).color.z, current_colorpoints->at(ir).color.z, pl, pr, p); - colors[i].x = r; - colors[i].y = g; - colors[i].z = b; - /* palette */ - palette[i * 4 + 0] = static_cast(r * 255.f); - palette[i * 4 + 1] = static_cast(g * 255.f); - palette[i * 4 + 2] = static_cast(b * 255.f); - palette[i * 4 + 3] = 255; - } - /* alpha */ - { - std::tie(il, ir) = find_interval(current_alphapoints, p); - float pl = current_alphapoints->at(il).pos.x; - float pr = current_alphapoints->at(ir).pos.x; - const float a = lerp(current_alphapoints->at(il).pos.y, current_alphapoints->at(ir).pos.y, pl, pr, p); - alpha[i].x = p; - alpha[i].y = a; - } - } - - // Render palette again - glBindTexture(GL_TEXTURE_2D, tfn_palette); - glTexImage2D(GL_TEXTURE_2D, - 0, - GL_RGBA8, - tfn_w, - tfn_h, - 0, - GL_RGBA, - GL_UNSIGNED_BYTE, - static_cast(palette.data())); // We need to resize texture of texture is resized - if (prev_binding) { // Restore previous binded texture - glBindTexture(GL_TEXTURE_2D, prev_binding); - } - - this->_setter_cb(colors, alpha, valueRange); - tfn_changed = false; - } -} - -inline void TransferFunctionWidget::load(const std::string &filename) -{ - TransferFunctionCore tfn; - try { - std::ifstream file(filename); - std::string text((std::istreambuf_iterator(file)), std::istreambuf_iterator()); - json root = json::parse(text, nullptr, true, true); - if (root.contains("view")) - loadTransferFunction(root["view"]["volume"]["transferFunction"], tfn); - else - loadTransferFunction(root["transferFunction"], tfn); - } - catch (...) { - std::cout << "failed to load file: " << filename << std::endl; - return; - } - - tfns.push_back(std::move(tfn)); - tfns_names.push_back(filename); - select_tfn((int)tfns.size() - 1); -} - -inline void tfn::TransferFunctionWidget::save(const std::string &filename) const -{ - const auto& tfn = tfns[tfn_selection]; - - json root = {{"transferFunction", {}}}; - saveTransferFunction(tfn, root["transferFunction"]); - std::ofstream ofs(filename, std::ofstream::out); - ofs << root.dump(); - ofs.close(); -} - -inline void TransferFunctionWidget::set_default_tfns() -{ - for (auto &ct : _predef_color_table_) { - - tfns.emplace_back(); - - auto& tfn = tfns.back(); - - for (size_t i = 0; i < ct.second.size() / 4; ++i) { - tfn.addColorControl(ct.second[i * 4], ct.second[i * 4 + 1], ct.second[i * 4 + 2], ct.second[i * 4 + 3]); - } - - tfn.addAlphaControl(vec2f(0.00f, 0.00f)); - tfn.addAlphaControl(vec2f(0.25f, 0.25f)); - tfn.addAlphaControl(vec2f(0.50f, 0.50f)); - tfn.addAlphaControl(vec2f(0.75f, 0.75f)); - tfn.addAlphaControl(vec2f(1.00f, 1.00f)); - tfn.updateColorMap(); - - tfns_names.push_back(ct.first); - } -}; - -} // namespace tfn diff --git a/extern/tfnmodule b/extern/tfnmodule new file mode 160000 index 0000000..009a45b --- /dev/null +++ b/extern/tfnmodule @@ -0,0 +1 @@ +Subproject commit 009a45bc8e05e53ca69eb9a150c02db921dab6a7 diff --git a/extern/tinyexr/.clang-format b/extern/tinyexr/.clang-format deleted file mode 100644 index 74210b0..0000000 --- a/extern/tinyexr/.clang-format +++ /dev/null @@ -1,7 +0,0 @@ ---- -BasedOnStyle: Google -IndentWidth: 2 -TabWidth: 2 -UseTab: Never -BreakBeforeBraces: Attach -Standard: Cpp03 diff --git a/extern/tinyexr/.gitignore b/extern/tinyexr/.gitignore deleted file mode 100644 index 70595f4..0000000 --- a/extern/tinyexr/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -output.exr -test_tinyexr diff --git a/extern/tinyexr/LICENSE-miniz b/extern/tinyexr/LICENSE-miniz deleted file mode 100644 index b6ff45a..0000000 --- a/extern/tinyexr/LICENSE-miniz +++ /dev/null @@ -1,22 +0,0 @@ -Copyright 2013-2014 RAD Game Tools and Valve Software -Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC - -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/extern/tinyexr/README.md b/extern/tinyexr/README.md deleted file mode 100644 index 507ec54..0000000 --- a/extern/tinyexr/README.md +++ /dev/null @@ -1,605 +0,0 @@ -# Tiny OpenEXR image library. - -[![Total alerts](https://img.shields.io/lgtm/alerts/g/syoyo/tinyexr.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/syoyo/tinyexr/alerts/) - -![Example](https://github.com/syoyo/tinyexr/blob/master/asakusa.png?raw=true) - -[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/k07ftfe4ph057qau/branch/master?svg=true)](https://ci.appveyor.com/project/syoyo/tinyexr/branch/master) - -[![Travis build Status](https://travis-ci.org/syoyo/tinyexr.svg)](https://travis-ci.org/syoyo/tinyexr) - -[![Coverity Scan Build Status](https://scan.coverity.com/projects/5827/badge.svg)](https://scan.coverity.com/projects/5827) - -`tinyexr` is a small, single header-only library to load and save OpenEXR (.exr) images. -`tinyexr` is written in portable C++ (no library dependency except for STL), thus `tinyexr` is good to embed into your application. -To use `tinyexr`, simply copy `tinyexr.h`, `miniz.c` and `miniz.h`(for zlib. You can use system-installed zlib instead of miniz. Controlled with `TINYEXR_USE_MINIZ` compile flag) into your project. - -# Features - -Current status of `tinyexr` is: - -- OpenEXR v1 image - - [x] Scanline format - - [x] Tiled format - - [x] Tile format with no LoD (load). - - [x] Tile format with LoD (load). - - [x] Tile format with no LoD (save). - - [x] Tile format with LoD (save). - - [x] Custom attributes -- OpenEXR v2 image - - [ ] Multipart format - - [x] Load multi-part image - - [x] Save multi-part image - - [ ] Load multi-part deep image - - [ ] Save multi-part deep image -- OpenEXR v2 deep image - - [x] Loading scanline + ZIPS + HALF or FLOAT pixel type. -- Compression - - [x] NONE - - [x] RLE - - [x] ZIP - - [x] ZIPS - - [x] PIZ - - [x] ZFP (tinyexr extension) - - [ ] B44? - - [ ] B44A? - - [ ] PIX24? -- Line order. - - [x] Increasing, decreasing (load) - - [ ] Random? - - [x] Increasing (save) - - [ ] decreasing (save) -- Pixel format (UINT, FLOAT). - - [x] UINT, FLOAT (load) - - [x] UINT, FLOAT (deep load) - - [x] UINT, FLOAT (save) - - [ ] UINT, FLOAT (deep save) -- Support for big endian machine. - - [x] Loading scanline image - - [x] Saving scanline image - - [x] Loading multi-part channel EXR (not tested) - - [x] Saving multi-part channel EXR (not tested) - - [ ] Loading deep image - - [ ] Saving deep image -- Optimization - - [x] C++11 thread loading - - [ ] C++11 thread saving - - [ ] ISPC? - - [x] OpenMP multi-threading in EXR loading. - - [x] OpenMP multi-threading in EXR saving. - - [ ] OpenMP multi-threading in deep image loading. - - [ ] OpenMP multi-threading in deep image saving. -* C interface. - * You can easily write language bindings (e.g. golang) - -# Supported platform - -* [x] x86-64 - * [x] Windows 7 or later - * [x] Linux(posix) system - * [x] macOS -* [x] AARCH64 - * [x] aarch64 linux(e.g. Raspberry Pi) - * [x] Android - * [x] iOS - * [x] macOS -* [ ] RISC-V(Should work) -* [x] Big endian machine(not maintained, but should work) - * SPARC, PowerPC, ... -* [x] WebAssembly(JavaScript) - * Loader only(See ![js](experimental/js/)) -* [x] Python binding - * Loader only https://pypi.org/project/pytinyexr/ - -# Requirements - -* C++ compiler(C++11 recommended. C++03 may work) - -# Use case - -## New TinyEXR (v0.9.5+) - -* Godot. Multi-platform 2D and 3D game engine https://godotengine.org/ -* Filament. PBR engine(used in a converter tool). https://github.com/google/filament -* PyEXR. Loading OpenEXR (.exr) images using Python. https://github.com/ialhashim/PyEXR -* The-Forge. The Forge Cross-Platform Rendering Framework PC, Linux, Ray Tracing, macOS / iOS, Android, XBOX, PS4 https://github.com/ConfettiFX/The-Forge -* Your project here! - -## Older TinyEXR (v0.9.0) - -* mallie https://github.com/lighttransport/mallie -* Cinder 0.9.0 https://libcinder.org/notes/v0.9.0 -* Piccante (develop branch) http://piccantelib.net/ -* Your project here! - -## Examples - -* [examples/deepview/](examples/deepview) Deep image view -* [examples/rgbe2exr/](examples/rgbe2exr) .hdr to EXR converter -* [examples/exr2rgbe/](examples/exr2rgbe) EXR to .hdr converter -* [examples/ldr2exr/](examples/exr2rgbe) LDR to EXR converter -* [examples/exr2ldr/](examples/exr2ldr) EXR to LDR converter -* [examples/exr2fptiff/](examples/exr2fptiff) EXR to 32bit floating point TIFF converter - * for 32bit floating point TIFF to EXR convert, see https://github.com/syoyo/tinydngloader/tree/master/examples/fptiff2exr -* [examples/cube2longlat/](examples/cube2longlat) Cubemap to longlat (equirectangler) converter - -## Experimental - -* [experimental/js/](experimental/js) JavaScript port using Emscripten - -## Usage - -NOTE: **API is still subject to change**. See the source code for details. - -Include `tinyexr.h` with `TINYEXR_IMPLEMENTATION` flag (do this only for **one** .cc file). - -```cpp -//Please include your own zlib-compatible API header before -//including `tinyexr.h` when you disable `TINYEXR_USE_MINIZ` -//#define TINYEXR_USE_MINIZ 0 -//#include "zlib.h" -#define TINYEXR_IMPLEMENTATION -#include "tinyexr.h" -``` - -### Compile flags - -* `TINYEXR_USE_MINIZ` Use miniz (default = 1). Please include `zlib.h` header before `tinyexr.h` if you disable miniz support(e.g. use system's zlib). -* `TINYEXR_USE_PIZ` Enable PIZ compression support (default = 1) -* `TINYEXR_USE_ZFP` Enable ZFP compression supoort (TinyEXR extension, default = 0) -* `TINYEXR_USE_THREAD` Enable threaded loading using C++11 thread (Requires C++11 compiler, default = 0) -* `TINYEXR_USE_OPENMP` Enable OpenMP threading support (default = 1 if `_OPENMP` is defined) - * Use `TINYEXR_USE_OPENMP=0` to force disable OpenMP code path even if OpenMP is available/enabled in the compiler. - -### Quickly reading RGB(A) EXR file. - -```cpp - const char* input = "asakusa.exr"; - float* out; // width * height * RGBA - int width; - int height; - const char* err = NULL; // or nullptr in C++11 - - int ret = LoadEXR(&out, &width, &height, input, &err); - - if (ret != TINYEXR_SUCCESS) { - if (err) { - fprintf(stderr, "ERR : %s\n", err); - FreeEXRErrorMessage(err); // release memory of error message. - } - } else { - ... - free(out); // release memory of image data - } - -``` - -### Reading layered RGB(A) EXR file. - -If you want to read EXR image with layer info (channel has a name with delimiter `.`), please use `LoadEXRWithLayer` API. - -You need to know layer name in advance (e.g. through `EXRLayers` API). - -```cpp - const char* input = ...; - const char* layer_name = "diffuse"; // or use EXRLayers to get list of layer names in .exr - float* out; // width * height * RGBA - int width; - int height; - const char* err = NULL; // or nullptr in C++11 - - // will read `diffuse.R`, `diffuse.G`, `diffuse.B`, (`diffuse.A`) channels - int ret = LoadEXRWithLayer(&out, &width, &height, input, layer_name, &err); - - if (ret != TINYEXR_SUCCESS) { - if (err) { - fprintf(stderr, "ERR : %s\n", err); - FreeEXRErrorMessage(err); // release memory of error message. - } - } else { - ... - free(out); // release memory of image data - } - -``` - -### Loading Singlepart EXR from a file. - -Scanline and tiled format are supported. - -```cpp - // 1. Read EXR version. - EXRVersion exr_version; - - int ret = ParseEXRVersionFromFile(&exr_version, argv[1]); - if (ret != 0) { - fprintf(stderr, "Invalid EXR file: %s\n", argv[1]); - return -1; - } - - if (exr_version.multipart) { - // must be multipart flag is false. - return -1; - } - - // 2. Read EXR header - EXRHeader exr_header; - InitEXRHeader(&exr_header); - - const char* err = NULL; // or `nullptr` in C++11 or later. - ret = ParseEXRHeaderFromFile(&exr_header, &exr_version, argv[1], &err); - if (ret != 0) { - fprintf(stderr, "Parse EXR err: %s\n", err); - FreeEXRErrorMessage(err); // free's buffer for an error message - return ret; - } - - // // Read HALF channel as FLOAT. - // for (int i = 0; i < exr_header.num_channels; i++) { - // if (exr_header.pixel_types[i] == TINYEXR_PIXELTYPE_HALF) { - // exr_header.requested_pixel_types[i] = TINYEXR_PIXELTYPE_FLOAT; - // } - // } - - EXRImage exr_image; - InitEXRImage(&exr_image); - - ret = LoadEXRImageFromFile(&exr_image, &exr_header, argv[1], &err); - if (ret != 0) { - fprintf(stderr, "Load EXR err: %s\n", err); - FreeEXRHeader(&exr_header); - FreeEXRErrorMessage(err); // free's buffer for an error message - return ret; - } - - // 3. Access image data - // `exr_image.images` will be filled when EXR is scanline format. - // `exr_image.tiled` will be filled when EXR is tiled format. - - // 4. Free image data - FreeEXRImage(&exr_image); - FreeEXRHeader(&exr_header); -``` - -### Loading Multipart EXR from a file. - -Scanline and tiled format are supported. - -```cpp - // 1. Read EXR version. - EXRVersion exr_version; - - int ret = ParseEXRVersionFromFile(&exr_version, argv[1]); - if (ret != 0) { - fprintf(stderr, "Invalid EXR file: %s\n", argv[1]); - return -1; - } - - if (!exr_version.multipart) { - // must be multipart flag is true. - return -1; - } - - // 2. Read EXR headers in the EXR. - EXRHeader **exr_headers; // list of EXRHeader pointers. - int num_exr_headers; - const char *err = NULL; // or nullptr in C++11 or later - - // Memory for EXRHeader is allocated inside of ParseEXRMultipartHeaderFromFile, - ret = ParseEXRMultipartHeaderFromFile(&exr_headers, &num_exr_headers, &exr_version, argv[1], &err); - if (ret != 0) { - fprintf(stderr, "Parse EXR err: %s\n", err); - FreeEXRErrorMessage(err); // free's buffer for an error message - return ret; - } - - printf("num parts = %d\n", num_exr_headers); - - - // 3. Load images. - - // Prepare array of EXRImage. - std::vector images(num_exr_headers); - for (int i =0; i < num_exr_headers; i++) { - InitEXRImage(&images[i]); - } - - ret = LoadEXRMultipartImageFromFile(&images.at(0), const_cast(exr_headers), num_exr_headers, argv[1], &err); - if (ret != 0) { - fprintf(stderr, "Parse EXR err: %s\n", err); - FreeEXRErrorMessage(err); // free's buffer for an error message - return ret; - } - - printf("Loaded %d part images\n", num_exr_headers); - - // 4. Access image data - // `exr_image.images` will be filled when EXR is scanline format. - // `exr_image.tiled` will be filled when EXR is tiled format. - - // 5. Free images - for (int i =0; i < num_exr_headers; i++) { - FreeEXRImage(&images.at(i)); - } - - // 6. Free headers. - for (int i =0; i < num_exr_headers; i++) { - FreeEXRHeader(exr_headers[i]); - free(exr_headers[i]); - } - free(exr_headers); -``` - - -Saving Scanline EXR file. - -```cpp - // See `examples/rgbe2exr/` for more details. - bool SaveEXR(const float* rgb, int width, int height, const char* outfilename) { - - EXRHeader header; - InitEXRHeader(&header); - - EXRImage image; - InitEXRImage(&image); - - image.num_channels = 3; - - std::vector images[3]; - images[0].resize(width * height); - images[1].resize(width * height); - images[2].resize(width * height); - - // Split RGBRGBRGB... into R, G and B layer - for (int i = 0; i < width * height; i++) { - images[0][i] = rgb[3*i+0]; - images[1][i] = rgb[3*i+1]; - images[2][i] = rgb[3*i+2]; - } - - float* image_ptr[3]; - image_ptr[0] = &(images[2].at(0)); // B - image_ptr[1] = &(images[1].at(0)); // G - image_ptr[2] = &(images[0].at(0)); // R - - image.images = (unsigned char**)image_ptr; - image.width = width; - image.height = height; - - header.num_channels = 3; - header.channels = (EXRChannelInfo *)malloc(sizeof(EXRChannelInfo) * header.num_channels); - // Must be (A)BGR order, since most of EXR viewers expect this channel order. - strncpy(header.channels[0].name, "B", 255); header.channels[0].name[strlen("B")] = '\0'; - strncpy(header.channels[1].name, "G", 255); header.channels[1].name[strlen("G")] = '\0'; - strncpy(header.channels[2].name, "R", 255); header.channels[2].name[strlen("R")] = '\0'; - - header.pixel_types = (int *)malloc(sizeof(int) * header.num_channels); - header.requested_pixel_types = (int *)malloc(sizeof(int) * header.num_channels); - for (int i = 0; i < header.num_channels; i++) { - header.pixel_types[i] = TINYEXR_PIXELTYPE_FLOAT; // pixel type of input image - header.requested_pixel_types[i] = TINYEXR_PIXELTYPE_HALF; // pixel type of output image to be stored in .EXR - } - - const char* err = NULL; // or nullptr in C++11 or later. - int ret = SaveEXRImageToFile(&image, &header, outfilename, &err); - if (ret != TINYEXR_SUCCESS) { - fprintf(stderr, "Save EXR err: %s\n", err); - FreeEXRErrorMessage(err); // free's buffer for an error message - return ret; - } - printf("Saved exr file. [ %s ] \n", outfilename); - - free(rgb); - - free(header.channels); - free(header.pixel_types); - free(header.requested_pixel_types); - - } -``` - - -Reading deep image EXR file. -See `example/deepview` for actual usage. - -```cpp - const char* input = "deepimage.exr"; - const char* err = NULL; // or nullptr - DeepImage deepImage; - - int ret = LoadDeepEXR(&deepImage, input, &err); - - // access to each sample in the deep pixel. - for (int y = 0; y < deepImage.height; y++) { - int sampleNum = deepImage.offset_table[y][deepImage.width-1]; - for (int x = 0; x < deepImage.width-1; x++) { - int s_start = deepImage.offset_table[y][x]; - int s_end = deepImage.offset_table[y][x+1]; - if (s_start >= sampleNum) { - continue; - } - s_end = (s_end < sampleNum) ? s_end : sampleNum; - for (int s = s_start; s < s_end; s++) { - float val = deepImage.image[depthChan][y][s]; - ... - } - } - } - -``` - -### deepview - -`examples/deepview` is simple deep image viewer in OpenGL. - -![DeepViewExample](https://github.com/syoyo/tinyexr/blob/master/examples/deepview/deepview_screencast.gif?raw=true) - -## TinyEXR extension - -### ZFP - -#### NOTE - -TinyEXR adds ZFP compression as an experimemtal support (Linux and MacOSX only). - -ZFP only supports FLOAT format pixel, and its image width and height must be the multiple of 4, since ZFP compresses pixels with 4x4 pixel block. - -#### Setup - -Checkout zfp repo as an submodule. - - $ git submodule update --init - -#### Build - -Then build ZFP - - $ cd deps/ZFP - $ mkdir -p lib # Create `lib` directory if not exist - $ make - -Set `1` to `TINYEXT_USE_ZFP` define in `tinyexr.h` - -Build your app with linking `deps/ZFP/lib/libzfp.a` - -#### ZFP attribute - -For ZFP EXR image, the following attribute must exist in its EXR image. - -* `zfpCompressionType` (uchar). - * 0 = fixed rate compression - * 1 = precision based variable rate compression - * 2 = accuracy based variable rate compression - -And the one of following attributes must exist in EXR, depending on the `zfpCompressionType` value. - -* `zfpCompressionRate` (double) - * Specifies compression rate for fixed rate compression. -* `zfpCompressionPrecision` (int32) - * Specifies the number of bits for precision based variable rate compression. -* `zfpCompressionTolerance` (double) - * Specifies the tolerance value for accuracy based variable rate compression. - -#### Note on ZFP compression. - -At least ZFP code itself works well on big endian machine. - -## Unit tests - -See `test/unit` directory. - -## TODO - -Contribution is welcome! - -- [ ] Compression - - [ ] B44? - - [ ] B44A? - - [ ] PIX24? -- [ ] Custom attributes - - [x] Normal image (EXR 1.x) - - [ ] Deep image (EXR 2.x) -- [ ] JavaScript library (experimental, using Emscripten) - - [x] LoadEXRFromMemory - - [ ] SaveMultiChannelEXR - - [ ] Deep image save/load -- [ ] Write from/to memory buffer. - - [ ] Deep image save/load -- [ ] Tile format. - - [x] Tile format with no LoD (load). - - [ ] Tile format with LoD (load). - - [ ] Tile format with no LoD (save). - - [ ] Tile format with LoD (save). -- [ ] Support for custom compression type. - - [x] zfp compression (Not in OpenEXR spec, though) - - [ ] zstd? -- [x] Multi-channel. -- [ ] Multi-part (EXR2.0) - - [x] Load multi-part image - - [ ] Load multi-part deep image -- [ ] Line order. - - [x] Increasing, decreasing (load) - - [ ] Random? - - [ ] Increasing, decreasing (save) -- [ ] Pixel format (UINT, FLOAT). - - [x] UINT, FLOAT (load) - - [x] UINT, FLOAT (deep load) - - [x] UINT, FLOAT (save) - - [ ] UINT, FLOAT (deep save) -- [ ] Support for big endian machine. - - [ ] Loading multi-part channel EXR - - [ ] Saving multi-part channel EXR - - [ ] Loading deep image - - [ ] Saving deep image -- [ ] Optimization - - [ ] ISPC? - - [x] OpenMP multi-threading in EXR loading. - - [x] OpenMP multi-threading in EXR saving. - - [ ] OpenMP multi-threading in deep image loading. - - [ ] OpenMP multi-threading in deep image saving. - -## Python bindings - -`pytinyexr` is available: https://pypi.org/project/pytinyexr/ (loading only as of 0.9.1) - -## Similar or related projects - -* miniexr: https://github.com/aras-p/miniexr (Write OpenEXR) -* stb_image_resize.h: https://github.com/nothings/stb (Good for HDR image resizing) - -## License - -3-clause BSD - -`tinyexr` uses miniz, which is developed by Rich Geldreich , and licensed under public domain. - -`tinyexr` tools uses stb, which is licensed under public domain: https://github.com/nothings/stb -`tinyexr` uses some code from OpenEXR, which is licensed under 3-clause BSD license. - -## Author(s) - -Syoyo Fujita (syoyo@lighttransport.com) - -## Contributor(s) - -* Matt Ebb (http://mattebb.com): deep image example. Thanks! -* Matt Pharr (http://pharr.org/matt/): Testing tinyexr with OpenEXR(IlmImf). Thanks! -* Andrew Bell (https://github.com/andrewfb) & Richard Eakin (https://github.com/richardeakin): Improving TinyEXR API. Thanks! -* Mike Wong (https://github.com/mwkm): ZIPS compression support in loading. Thanks! - ---- - -## Miniz - -Miniz is a lossless, high performance data compression library in a single source file that implements the zlib (RFC 1950) and Deflate (RFC 1951) compressed data format specification standards. It supports the most commonly used functions exported by the zlib library, but is a completely independent implementation so zlib's licensing requirements do not apply. Miniz also contains simple to use functions for writing .PNG format image files and reading/writing/appending .ZIP format archives. Miniz's compression speed has been tuned to be comparable to zlib's, and it also has a specialized real-time compressor function designed to compare well against fastlz/minilzo. - -## Usage - -Please use the files from the [releases page](https://github.com/richgel999/miniz/releases) in your projects. Do not use the git checkout directly! The different source and header files are [amalgamated](https://www.sqlite.org/amalgamation.html) into one `miniz.c`/`miniz.h` pair in a build step (`amalgamate.sh`). Include `miniz.c` and `miniz.h` in your project to use Miniz. - -## Features - -* MIT licensed -* A portable, single source and header file library written in plain C. Tested with GCC, clang and Visual Studio. -* Easily tuned and trimmed down by defines -* A drop-in replacement for zlib's most used API's (tested in several open source projects that use zlib, such as libpng and libzip). -* Fills a single threaded performance vs. compression ratio gap between several popular real-time compressors and zlib. For example, at level 1, miniz.c compresses around 5-9% better than minilzo, but is approx. 35% slower. At levels 2-9, miniz.c is designed to compare favorably against zlib's ratio and speed. See the miniz performance comparison page for example timings. -* Not a block based compressor: miniz.c fully supports stream based processing using a coroutine-style implementation. The zlib-style API functions can be called a single byte at a time if that's all you've got. -* Easy to use. The low-level compressor (tdefl) and decompressor (tinfl) have simple state structs which can be saved/restored as needed with simple memcpy's. The low-level codec API's don't use the heap in any way. -* Entire inflater (including optional zlib header parsing and Adler-32 checking) is implemented in a single function as a coroutine, which is separately available in a small (~550 line) source file: miniz_tinfl.c -* A fairly complete (but totally optional) set of .ZIP archive manipulation and extraction API's. The archive functionality is intended to solve common problems encountered in embedded, mobile, or game development situations. (The archive API's are purposely just powerful enough to write an entire archiver given a bit of additional higher-level logic.) - -## Known Problems - -* No support for encrypted archives. Not sure how useful this stuff is in practice. -* Minimal documentation. The assumption is that the user is already familiar with the basic zlib API. I need to write an API wiki - for now I've tried to place key comments before each enum/API, and I've included 6 examples that demonstrate how to use the module's major features. - -## Special Thanks - -Thanks to Alex Evans for the PNG writer function. Also, thanks to Paul Holden and Thorsten Scheuermann for feedback and testing, Matt Pritchard for all his encouragement, and Sean Barrett's various public domain libraries for inspiration (and encouraging me to write miniz.c in C, which was much more enjoyable and less painful than I thought it would be considering I've been programming in C++ for so long). - -Thanks to Bruce Dawson for reporting a problem with the level_and_flags archive API parameter (which is fixed in v1.12) and general feedback, and Janez Zemva for indirectly encouraging me into writing more examples. - -## Patents - -I was recently asked if miniz avoids patent issues. miniz purposely uses the same core algorithms as the ones used by zlib. The compressor uses vanilla hash chaining as described [here](https://datatracker.ietf.org/doc/html/rfc1951#section-4). Also see the [gzip FAQ](https://web.archive.org/web/20160308045258/http://www.gzip.org/#faq11). In my opinion, if miniz falls prey to a patent attack then zlib/gzip are likely to be at serious risk too. diff --git a/extern/tinyexr/miniz.c b/extern/tinyexr/miniz.c deleted file mode 100644 index 4b1cef5..0000000 --- a/extern/tinyexr/miniz.c +++ /dev/null @@ -1,7833 +0,0 @@ -#include "miniz.h" -/************************************************************************** - * - * Copyright 2013-2014 RAD Game Tools and Valve Software - * Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - **************************************************************************/ - - - -typedef unsigned char mz_validate_uint16[sizeof(mz_uint16) == 2 ? 1 : -1]; -typedef unsigned char mz_validate_uint32[sizeof(mz_uint32) == 4 ? 1 : -1]; -typedef unsigned char mz_validate_uint64[sizeof(mz_uint64) == 8 ? 1 : -1]; - -#ifdef __cplusplus -extern "C" { -#endif - -/* ------------------- zlib-style API's */ - -mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len) -{ - mz_uint32 i, s1 = (mz_uint32)(adler & 0xffff), s2 = (mz_uint32)(adler >> 16); - size_t block_len = buf_len % 5552; - if (!ptr) - return MZ_ADLER32_INIT; - while (buf_len) - { - for (i = 0; i + 7 < block_len; i += 8, ptr += 8) - { - s1 += ptr[0], s2 += s1; - s1 += ptr[1], s2 += s1; - s1 += ptr[2], s2 += s1; - s1 += ptr[3], s2 += s1; - s1 += ptr[4], s2 += s1; - s1 += ptr[5], s2 += s1; - s1 += ptr[6], s2 += s1; - s1 += ptr[7], s2 += s1; - } - for (; i < block_len; ++i) - s1 += *ptr++, s2 += s1; - s1 %= 65521U, s2 %= 65521U; - buf_len -= block_len; - block_len = 5552; - } - return (s2 << 16) + s1; -} - -/* Karl Malbrain's compact CRC-32. See "A compact CCITT crc16 and crc32 C implementation that balances processor cache usage against speed": http://www.geocities.com/malbrain/ */ -#if 0 - mz_ulong mz_crc32(mz_ulong crc, const mz_uint8 *ptr, size_t buf_len) - { - static const mz_uint32 s_crc32[16] = { 0, 0x1db71064, 0x3b6e20c8, 0x26d930ac, 0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c, - 0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c, 0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c }; - mz_uint32 crcu32 = (mz_uint32)crc; - if (!ptr) - return MZ_CRC32_INIT; - crcu32 = ~crcu32; - while (buf_len--) - { - mz_uint8 b = *ptr++; - crcu32 = (crcu32 >> 4) ^ s_crc32[(crcu32 & 0xF) ^ (b & 0xF)]; - crcu32 = (crcu32 >> 4) ^ s_crc32[(crcu32 & 0xF) ^ (b >> 4)]; - } - return ~crcu32; - } -#elif defined(USE_EXTERNAL_MZCRC) -/* If USE_EXTERNAL_CRC is defined, an external module will export the - * mz_crc32() symbol for us to use, e.g. an SSE-accelerated version. - * Depending on the impl, it may be necessary to ~ the input/output crc values. - */ -mz_ulong mz_crc32(mz_ulong crc, const mz_uint8 *ptr, size_t buf_len); -#else -/* Faster, but larger CPU cache footprint. - */ -mz_ulong mz_crc32(mz_ulong crc, const mz_uint8 *ptr, size_t buf_len) -{ - static const mz_uint32 s_crc_table[256] = - { - 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, - 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, - 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, - 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, - 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, - 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, - 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC, - 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, - 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, - 0xB6662D3D, 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, - 0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, - 0x086D3D2D, 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, - 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, - 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, 0x4DB26158, 0x3AB551CE, - 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, - 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, - 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, - 0xCE61E49F, 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, - 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, - 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, - 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, 0x8708A3D2, 0x1E01F268, - 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, - 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, - 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, - 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, - 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, - 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, - 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, - 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, - 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, - 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 0x88085AE6, - 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, - 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, - 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, - 0x47B2CF7F, 0x30B5FFE9, 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, - 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, - 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D - }; - - mz_uint32 crc32 = (mz_uint32)crc ^ 0xFFFFFFFF; - const mz_uint8 *pByte_buf = (const mz_uint8 *)ptr; - - while (buf_len >= 4) - { - crc32 = (crc32 >> 8) ^ s_crc_table[(crc32 ^ pByte_buf[0]) & 0xFF]; - crc32 = (crc32 >> 8) ^ s_crc_table[(crc32 ^ pByte_buf[1]) & 0xFF]; - crc32 = (crc32 >> 8) ^ s_crc_table[(crc32 ^ pByte_buf[2]) & 0xFF]; - crc32 = (crc32 >> 8) ^ s_crc_table[(crc32 ^ pByte_buf[3]) & 0xFF]; - pByte_buf += 4; - buf_len -= 4; - } - - while (buf_len) - { - crc32 = (crc32 >> 8) ^ s_crc_table[(crc32 ^ pByte_buf[0]) & 0xFF]; - ++pByte_buf; - --buf_len; - } - - return ~crc32; -} -#endif - -void mz_free(void *p) -{ - MZ_FREE(p); -} - -MINIZ_EXPORT void *miniz_def_alloc_func(void *opaque, size_t items, size_t size) -{ - (void)opaque, (void)items, (void)size; - return MZ_MALLOC(items * size); -} -MINIZ_EXPORT void miniz_def_free_func(void *opaque, void *address) -{ - (void)opaque, (void)address; - MZ_FREE(address); -} -MINIZ_EXPORT void *miniz_def_realloc_func(void *opaque, void *address, size_t items, size_t size) -{ - (void)opaque, (void)address, (void)items, (void)size; - return MZ_REALLOC(address, items * size); -} - -const char *mz_version(void) -{ - return MZ_VERSION; -} - -#ifndef MINIZ_NO_ZLIB_APIS - -#ifndef MINIZ_NO_DEFLATE_APIS - -int mz_deflateInit(mz_streamp pStream, int level) -{ - return mz_deflateInit2(pStream, level, MZ_DEFLATED, MZ_DEFAULT_WINDOW_BITS, 9, MZ_DEFAULT_STRATEGY); -} - -int mz_deflateInit2(mz_streamp pStream, int level, int method, int window_bits, int mem_level, int strategy) -{ - tdefl_compressor *pComp; - mz_uint comp_flags = TDEFL_COMPUTE_ADLER32 | tdefl_create_comp_flags_from_zip_params(level, window_bits, strategy); - - if (!pStream) - return MZ_STREAM_ERROR; - if ((method != MZ_DEFLATED) || ((mem_level < 1) || (mem_level > 9)) || ((window_bits != MZ_DEFAULT_WINDOW_BITS) && (-window_bits != MZ_DEFAULT_WINDOW_BITS))) - return MZ_PARAM_ERROR; - - pStream->data_type = 0; - pStream->adler = MZ_ADLER32_INIT; - pStream->msg = NULL; - pStream->reserved = 0; - pStream->total_in = 0; - pStream->total_out = 0; - if (!pStream->zalloc) - pStream->zalloc = miniz_def_alloc_func; - if (!pStream->zfree) - pStream->zfree = miniz_def_free_func; - - pComp = (tdefl_compressor *)pStream->zalloc(pStream->opaque, 1, sizeof(tdefl_compressor)); - if (!pComp) - return MZ_MEM_ERROR; - - pStream->state = (struct mz_internal_state *)pComp; - - if (tdefl_init(pComp, NULL, NULL, comp_flags) != TDEFL_STATUS_OKAY) - { - mz_deflateEnd(pStream); - return MZ_PARAM_ERROR; - } - - return MZ_OK; -} - -int mz_deflateReset(mz_streamp pStream) -{ - if ((!pStream) || (!pStream->state) || (!pStream->zalloc) || (!pStream->zfree)) - return MZ_STREAM_ERROR; - pStream->total_in = pStream->total_out = 0; - tdefl_init((tdefl_compressor *)pStream->state, NULL, NULL, ((tdefl_compressor *)pStream->state)->m_flags); - return MZ_OK; -} - -int mz_deflate(mz_streamp pStream, int flush) -{ - size_t in_bytes, out_bytes; - mz_ulong orig_total_in, orig_total_out; - int mz_status = MZ_OK; - - if ((!pStream) || (!pStream->state) || (flush < 0) || (flush > MZ_FINISH) || (!pStream->next_out)) - return MZ_STREAM_ERROR; - if (!pStream->avail_out) - return MZ_BUF_ERROR; - - if (flush == MZ_PARTIAL_FLUSH) - flush = MZ_SYNC_FLUSH; - - if (((tdefl_compressor *)pStream->state)->m_prev_return_status == TDEFL_STATUS_DONE) - return (flush == MZ_FINISH) ? MZ_STREAM_END : MZ_BUF_ERROR; - - orig_total_in = pStream->total_in; - orig_total_out = pStream->total_out; - for (;;) - { - tdefl_status defl_status; - in_bytes = pStream->avail_in; - out_bytes = pStream->avail_out; - - defl_status = tdefl_compress((tdefl_compressor *)pStream->state, pStream->next_in, &in_bytes, pStream->next_out, &out_bytes, (tdefl_flush)flush); - pStream->next_in += (mz_uint)in_bytes; - pStream->avail_in -= (mz_uint)in_bytes; - pStream->total_in += (mz_uint)in_bytes; - pStream->adler = tdefl_get_adler32((tdefl_compressor *)pStream->state); - - pStream->next_out += (mz_uint)out_bytes; - pStream->avail_out -= (mz_uint)out_bytes; - pStream->total_out += (mz_uint)out_bytes; - - if (defl_status < 0) - { - mz_status = MZ_STREAM_ERROR; - break; - } - else if (defl_status == TDEFL_STATUS_DONE) - { - mz_status = MZ_STREAM_END; - break; - } - else if (!pStream->avail_out) - break; - else if ((!pStream->avail_in) && (flush != MZ_FINISH)) - { - if ((flush) || (pStream->total_in != orig_total_in) || (pStream->total_out != orig_total_out)) - break; - return MZ_BUF_ERROR; /* Can't make forward progress without some input. - */ - } - } - return mz_status; -} - -int mz_deflateEnd(mz_streamp pStream) -{ - if (!pStream) - return MZ_STREAM_ERROR; - if (pStream->state) - { - pStream->zfree(pStream->opaque, pStream->state); - pStream->state = NULL; - } - return MZ_OK; -} - -mz_ulong mz_deflateBound(mz_streamp pStream, mz_ulong source_len) -{ - (void)pStream; - /* This is really over conservative. (And lame, but it's actually pretty tricky to compute a true upper bound given the way tdefl's blocking works.) */ - return MZ_MAX(128 + (source_len * 110) / 100, 128 + source_len + ((source_len / (31 * 1024)) + 1) * 5); -} - -int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len, int level) -{ - int status; - mz_stream stream; - memset(&stream, 0, sizeof(stream)); - - /* In case mz_ulong is 64-bits (argh I hate longs). */ - if ((mz_uint64)(source_len | *pDest_len) > 0xFFFFFFFFU) - return MZ_PARAM_ERROR; - - stream.next_in = pSource; - stream.avail_in = (mz_uint32)source_len; - stream.next_out = pDest; - stream.avail_out = (mz_uint32)*pDest_len; - - status = mz_deflateInit(&stream, level); - if (status != MZ_OK) - return status; - - status = mz_deflate(&stream, MZ_FINISH); - if (status != MZ_STREAM_END) - { - mz_deflateEnd(&stream); - return (status == MZ_OK) ? MZ_BUF_ERROR : status; - } - - *pDest_len = stream.total_out; - return mz_deflateEnd(&stream); -} - -int mz_compress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len) -{ - return mz_compress2(pDest, pDest_len, pSource, source_len, MZ_DEFAULT_COMPRESSION); -} - -mz_ulong mz_compressBound(mz_ulong source_len) -{ - return mz_deflateBound(NULL, source_len); -} - -#endif /*#ifndef MINIZ_NO_DEFLATE_APIS*/ - -#ifndef MINIZ_NO_INFLATE_APIS - -typedef struct -{ - tinfl_decompressor m_decomp; - mz_uint m_dict_ofs, m_dict_avail, m_first_call, m_has_flushed; - int m_window_bits; - mz_uint8 m_dict[TINFL_LZ_DICT_SIZE]; - tinfl_status m_last_status; -} inflate_state; - -int mz_inflateInit2(mz_streamp pStream, int window_bits) -{ - inflate_state *pDecomp; - if (!pStream) - return MZ_STREAM_ERROR; - if ((window_bits != MZ_DEFAULT_WINDOW_BITS) && (-window_bits != MZ_DEFAULT_WINDOW_BITS)) - return MZ_PARAM_ERROR; - - pStream->data_type = 0; - pStream->adler = 0; - pStream->msg = NULL; - pStream->total_in = 0; - pStream->total_out = 0; - pStream->reserved = 0; - if (!pStream->zalloc) - pStream->zalloc = miniz_def_alloc_func; - if (!pStream->zfree) - pStream->zfree = miniz_def_free_func; - - pDecomp = (inflate_state *)pStream->zalloc(pStream->opaque, 1, sizeof(inflate_state)); - if (!pDecomp) - return MZ_MEM_ERROR; - - pStream->state = (struct mz_internal_state *)pDecomp; - - tinfl_init(&pDecomp->m_decomp); - pDecomp->m_dict_ofs = 0; - pDecomp->m_dict_avail = 0; - pDecomp->m_last_status = TINFL_STATUS_NEEDS_MORE_INPUT; - pDecomp->m_first_call = 1; - pDecomp->m_has_flushed = 0; - pDecomp->m_window_bits = window_bits; - - return MZ_OK; -} - -int mz_inflateInit(mz_streamp pStream) -{ - return mz_inflateInit2(pStream, MZ_DEFAULT_WINDOW_BITS); -} - -int mz_inflateReset(mz_streamp pStream) -{ - inflate_state *pDecomp; - if (!pStream) - return MZ_STREAM_ERROR; - - pStream->data_type = 0; - pStream->adler = 0; - pStream->msg = NULL; - pStream->total_in = 0; - pStream->total_out = 0; - pStream->reserved = 0; - - pDecomp = (inflate_state *)pStream->state; - - tinfl_init(&pDecomp->m_decomp); - pDecomp->m_dict_ofs = 0; - pDecomp->m_dict_avail = 0; - pDecomp->m_last_status = TINFL_STATUS_NEEDS_MORE_INPUT; - pDecomp->m_first_call = 1; - pDecomp->m_has_flushed = 0; - /* pDecomp->m_window_bits = window_bits */; - - return MZ_OK; -} - -int mz_inflate(mz_streamp pStream, int flush) -{ - inflate_state *pState; - mz_uint n, first_call, decomp_flags = TINFL_FLAG_COMPUTE_ADLER32; - size_t in_bytes, out_bytes, orig_avail_in; - tinfl_status status; - - if ((!pStream) || (!pStream->state)) - return MZ_STREAM_ERROR; - if (flush == MZ_PARTIAL_FLUSH) - flush = MZ_SYNC_FLUSH; - if ((flush) && (flush != MZ_SYNC_FLUSH) && (flush != MZ_FINISH)) - return MZ_STREAM_ERROR; - - pState = (inflate_state *)pStream->state; - if (pState->m_window_bits > 0) - decomp_flags |= TINFL_FLAG_PARSE_ZLIB_HEADER; - orig_avail_in = pStream->avail_in; - - first_call = pState->m_first_call; - pState->m_first_call = 0; - if (pState->m_last_status < 0) - return MZ_DATA_ERROR; - - if (pState->m_has_flushed && (flush != MZ_FINISH)) - return MZ_STREAM_ERROR; - pState->m_has_flushed |= (flush == MZ_FINISH); - - if ((flush == MZ_FINISH) && (first_call)) - { - /* MZ_FINISH on the first call implies that the input and output buffers are large enough to hold the entire compressed/decompressed file. */ - decomp_flags |= TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF; - in_bytes = pStream->avail_in; - out_bytes = pStream->avail_out; - status = tinfl_decompress(&pState->m_decomp, pStream->next_in, &in_bytes, pStream->next_out, pStream->next_out, &out_bytes, decomp_flags); - pState->m_last_status = status; - pStream->next_in += (mz_uint)in_bytes; - pStream->avail_in -= (mz_uint)in_bytes; - pStream->total_in += (mz_uint)in_bytes; - pStream->adler = tinfl_get_adler32(&pState->m_decomp); - pStream->next_out += (mz_uint)out_bytes; - pStream->avail_out -= (mz_uint)out_bytes; - pStream->total_out += (mz_uint)out_bytes; - - if (status < 0) - return MZ_DATA_ERROR; - else if (status != TINFL_STATUS_DONE) - { - pState->m_last_status = TINFL_STATUS_FAILED; - return MZ_BUF_ERROR; - } - return MZ_STREAM_END; - } - /* flush != MZ_FINISH then we must assume there's more input. */ - if (flush != MZ_FINISH) - decomp_flags |= TINFL_FLAG_HAS_MORE_INPUT; - - if (pState->m_dict_avail) - { - n = MZ_MIN(pState->m_dict_avail, pStream->avail_out); - memcpy(pStream->next_out, pState->m_dict + pState->m_dict_ofs, n); - pStream->next_out += n; - pStream->avail_out -= n; - pStream->total_out += n; - pState->m_dict_avail -= n; - pState->m_dict_ofs = (pState->m_dict_ofs + n) & (TINFL_LZ_DICT_SIZE - 1); - return ((pState->m_last_status == TINFL_STATUS_DONE) && (!pState->m_dict_avail)) ? MZ_STREAM_END : MZ_OK; - } - - for (;;) - { - in_bytes = pStream->avail_in; - out_bytes = TINFL_LZ_DICT_SIZE - pState->m_dict_ofs; - - status = tinfl_decompress(&pState->m_decomp, pStream->next_in, &in_bytes, pState->m_dict, pState->m_dict + pState->m_dict_ofs, &out_bytes, decomp_flags); - pState->m_last_status = status; - - pStream->next_in += (mz_uint)in_bytes; - pStream->avail_in -= (mz_uint)in_bytes; - pStream->total_in += (mz_uint)in_bytes; - pStream->adler = tinfl_get_adler32(&pState->m_decomp); - - pState->m_dict_avail = (mz_uint)out_bytes; - - n = MZ_MIN(pState->m_dict_avail, pStream->avail_out); - memcpy(pStream->next_out, pState->m_dict + pState->m_dict_ofs, n); - pStream->next_out += n; - pStream->avail_out -= n; - pStream->total_out += n; - pState->m_dict_avail -= n; - pState->m_dict_ofs = (pState->m_dict_ofs + n) & (TINFL_LZ_DICT_SIZE - 1); - - if (status < 0) - return MZ_DATA_ERROR; /* Stream is corrupted (there could be some uncompressed data left in the output dictionary - oh well). */ - else if ((status == TINFL_STATUS_NEEDS_MORE_INPUT) && (!orig_avail_in)) - return MZ_BUF_ERROR; /* Signal caller that we can't make forward progress without supplying more input or by setting flush to MZ_FINISH. */ - else if (flush == MZ_FINISH) - { - /* The output buffer MUST be large to hold the remaining uncompressed data when flush==MZ_FINISH. */ - if (status == TINFL_STATUS_DONE) - return pState->m_dict_avail ? MZ_BUF_ERROR : MZ_STREAM_END; - /* status here must be TINFL_STATUS_HAS_MORE_OUTPUT, which means there's at least 1 more byte on the way. If there's no more room left in the output buffer then something is wrong. */ - else if (!pStream->avail_out) - return MZ_BUF_ERROR; - } - else if ((status == TINFL_STATUS_DONE) || (!pStream->avail_in) || (!pStream->avail_out) || (pState->m_dict_avail)) - break; - } - - return ((status == TINFL_STATUS_DONE) && (!pState->m_dict_avail)) ? MZ_STREAM_END : MZ_OK; -} - -int mz_inflateEnd(mz_streamp pStream) -{ - if (!pStream) - return MZ_STREAM_ERROR; - if (pStream->state) - { - pStream->zfree(pStream->opaque, pStream->state); - pStream->state = NULL; - } - return MZ_OK; -} -int mz_uncompress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong *pSource_len) -{ - mz_stream stream; - int status; - memset(&stream, 0, sizeof(stream)); - - /* In case mz_ulong is 64-bits (argh I hate longs). */ - if ((mz_uint64)(*pSource_len | *pDest_len) > 0xFFFFFFFFU) - return MZ_PARAM_ERROR; - - stream.next_in = pSource; - stream.avail_in = (mz_uint32)*pSource_len; - stream.next_out = pDest; - stream.avail_out = (mz_uint32)*pDest_len; - - status = mz_inflateInit(&stream); - if (status != MZ_OK) - return status; - - status = mz_inflate(&stream, MZ_FINISH); - *pSource_len = *pSource_len - stream.avail_in; - if (status != MZ_STREAM_END) - { - mz_inflateEnd(&stream); - return ((status == MZ_BUF_ERROR) && (!stream.avail_in)) ? MZ_DATA_ERROR : status; - } - *pDest_len = stream.total_out; - - return mz_inflateEnd(&stream); -} - -int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len) -{ - return mz_uncompress2(pDest, pDest_len, pSource, &source_len); -} - -#endif /*#ifndef MINIZ_NO_INFLATE_APIS*/ - -const char *mz_error(int err) -{ - static struct - { - int m_err; - const char *m_pDesc; - } s_error_descs[] = - { - { MZ_OK, "" }, { MZ_STREAM_END, "stream end" }, { MZ_NEED_DICT, "need dictionary" }, { MZ_ERRNO, "file error" }, { MZ_STREAM_ERROR, "stream error" }, { MZ_DATA_ERROR, "data error" }, { MZ_MEM_ERROR, "out of memory" }, { MZ_BUF_ERROR, "buf error" }, { MZ_VERSION_ERROR, "version error" }, { MZ_PARAM_ERROR, "parameter error" } - }; - mz_uint i; - for (i = 0; i < sizeof(s_error_descs) / sizeof(s_error_descs[0]); ++i) - if (s_error_descs[i].m_err == err) - return s_error_descs[i].m_pDesc; - return NULL; -} - -#endif /*MINIZ_NO_ZLIB_APIS */ - -#ifdef __cplusplus -} -#endif - -/* - This is free and unencumbered software released into the public domain. - - Anyone is free to copy, modify, publish, use, compile, sell, or - distribute this software, either in source code form or as a compiled - binary, for any purpose, commercial or non-commercial, and by any - means. - - In jurisdictions that recognize copyright laws, the author or authors - of this software dedicate any and all copyright interest in the - software to the public domain. We make this dedication for the benefit - of the public at large and to the detriment of our heirs and - successors. We intend this dedication to be an overt act of - relinquishment in perpetuity of all present and future rights to this - software under copyright law. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR - OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - OTHER DEALINGS IN THE SOFTWARE. - - For more information, please refer to -*/ -/************************************************************************** - * - * Copyright 2013-2014 RAD Game Tools and Valve Software - * Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - **************************************************************************/ - - - -#ifndef MINIZ_NO_DEFLATE_APIS - -#ifdef __cplusplus -extern "C" { -#endif - -/* ------------------- Low-level Compression (independent from all decompression API's) */ - -/* Purposely making these tables static for faster init and thread safety. */ -static const mz_uint16 s_tdefl_len_sym[256] = - { - 257, 258, 259, 260, 261, 262, 263, 264, 265, 265, 266, 266, 267, 267, 268, 268, 269, 269, 269, 269, 270, 270, 270, 270, 271, 271, 271, 271, 272, 272, 272, 272, - 273, 273, 273, 273, 273, 273, 273, 273, 274, 274, 274, 274, 274, 274, 274, 274, 275, 275, 275, 275, 275, 275, 275, 275, 276, 276, 276, 276, 276, 276, 276, 276, - 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, - 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, - 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, - 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, - 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, - 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 285 - }; - -static const mz_uint8 s_tdefl_len_extra[256] = - { - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0 - }; - -static const mz_uint8 s_tdefl_small_dist_sym[512] = - { - 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, - 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17 - }; - -static const mz_uint8 s_tdefl_small_dist_extra[512] = - { - 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7 - }; - -static const mz_uint8 s_tdefl_large_dist_sym[128] = - { - 0, 0, 18, 19, 20, 20, 21, 21, 22, 22, 22, 22, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, - 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, - 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 - }; - -static const mz_uint8 s_tdefl_large_dist_extra[128] = - { - 0, 0, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13 - }; - -/* Radix sorts tdefl_sym_freq[] array by 16-bit key m_key. Returns ptr to sorted values. */ -typedef struct -{ - mz_uint16 m_key, m_sym_index; -} tdefl_sym_freq; -static tdefl_sym_freq *tdefl_radix_sort_syms(mz_uint num_syms, tdefl_sym_freq *pSyms0, tdefl_sym_freq *pSyms1) -{ - mz_uint32 total_passes = 2, pass_shift, pass, i, hist[256 * 2]; - tdefl_sym_freq *pCur_syms = pSyms0, *pNew_syms = pSyms1; - MZ_CLEAR_ARR(hist); - for (i = 0; i < num_syms; i++) - { - mz_uint freq = pSyms0[i].m_key; - hist[freq & 0xFF]++; - hist[256 + ((freq >> 8) & 0xFF)]++; - } - while ((total_passes > 1) && (num_syms == hist[(total_passes - 1) * 256])) - total_passes--; - for (pass_shift = 0, pass = 0; pass < total_passes; pass++, pass_shift += 8) - { - const mz_uint32 *pHist = &hist[pass << 8]; - mz_uint offsets[256], cur_ofs = 0; - for (i = 0; i < 256; i++) - { - offsets[i] = cur_ofs; - cur_ofs += pHist[i]; - } - for (i = 0; i < num_syms; i++) - pNew_syms[offsets[(pCur_syms[i].m_key >> pass_shift) & 0xFF]++] = pCur_syms[i]; - { - tdefl_sym_freq *t = pCur_syms; - pCur_syms = pNew_syms; - pNew_syms = t; - } - } - return pCur_syms; -} - -/* tdefl_calculate_minimum_redundancy() originally written by: Alistair Moffat, alistair@cs.mu.oz.au, Jyrki Katajainen, jyrki@diku.dk, November 1996. */ -static void tdefl_calculate_minimum_redundancy(tdefl_sym_freq *A, int n) -{ - int root, leaf, next, avbl, used, dpth; - if (n == 0) - return; - else if (n == 1) - { - A[0].m_key = 1; - return; - } - A[0].m_key += A[1].m_key; - root = 0; - leaf = 2; - for (next = 1; next < n - 1; next++) - { - if (leaf >= n || A[root].m_key < A[leaf].m_key) - { - A[next].m_key = A[root].m_key; - A[root++].m_key = (mz_uint16)next; - } - else - A[next].m_key = A[leaf++].m_key; - if (leaf >= n || (root < next && A[root].m_key < A[leaf].m_key)) - { - A[next].m_key = (mz_uint16)(A[next].m_key + A[root].m_key); - A[root++].m_key = (mz_uint16)next; - } - else - A[next].m_key = (mz_uint16)(A[next].m_key + A[leaf++].m_key); - } - A[n - 2].m_key = 0; - for (next = n - 3; next >= 0; next--) - A[next].m_key = A[A[next].m_key].m_key + 1; - avbl = 1; - used = dpth = 0; - root = n - 2; - next = n - 1; - while (avbl > 0) - { - while (root >= 0 && (int)A[root].m_key == dpth) - { - used++; - root--; - } - while (avbl > used) - { - A[next--].m_key = (mz_uint16)(dpth); - avbl--; - } - avbl = 2 * used; - dpth++; - used = 0; - } -} - -/* Limits canonical Huffman code table's max code size. */ -enum -{ - TDEFL_MAX_SUPPORTED_HUFF_CODESIZE = 32 -}; -static void tdefl_huffman_enforce_max_code_size(int *pNum_codes, int code_list_len, int max_code_size) -{ - int i; - mz_uint32 total = 0; - if (code_list_len <= 1) - return; - for (i = max_code_size + 1; i <= TDEFL_MAX_SUPPORTED_HUFF_CODESIZE; i++) - pNum_codes[max_code_size] += pNum_codes[i]; - for (i = max_code_size; i > 0; i--) - total += (((mz_uint32)pNum_codes[i]) << (max_code_size - i)); - while (total != (1UL << max_code_size)) - { - pNum_codes[max_code_size]--; - for (i = max_code_size - 1; i > 0; i--) - if (pNum_codes[i]) - { - pNum_codes[i]--; - pNum_codes[i + 1] += 2; - break; - } - total--; - } -} - -static void tdefl_optimize_huffman_table(tdefl_compressor *d, int table_num, int table_len, int code_size_limit, int static_table) -{ - int i, j, l, num_codes[1 + TDEFL_MAX_SUPPORTED_HUFF_CODESIZE]; - mz_uint next_code[TDEFL_MAX_SUPPORTED_HUFF_CODESIZE + 1]; - MZ_CLEAR_ARR(num_codes); - if (static_table) - { - for (i = 0; i < table_len; i++) - num_codes[d->m_huff_code_sizes[table_num][i]]++; - } - else - { - tdefl_sym_freq syms0[TDEFL_MAX_HUFF_SYMBOLS], syms1[TDEFL_MAX_HUFF_SYMBOLS], *pSyms; - int num_used_syms = 0; - const mz_uint16 *pSym_count = &d->m_huff_count[table_num][0]; - for (i = 0; i < table_len; i++) - if (pSym_count[i]) - { - syms0[num_used_syms].m_key = (mz_uint16)pSym_count[i]; - syms0[num_used_syms++].m_sym_index = (mz_uint16)i; - } - - pSyms = tdefl_radix_sort_syms(num_used_syms, syms0, syms1); - tdefl_calculate_minimum_redundancy(pSyms, num_used_syms); - - for (i = 0; i < num_used_syms; i++) - num_codes[pSyms[i].m_key]++; - - tdefl_huffman_enforce_max_code_size(num_codes, num_used_syms, code_size_limit); - - MZ_CLEAR_ARR(d->m_huff_code_sizes[table_num]); - MZ_CLEAR_ARR(d->m_huff_codes[table_num]); - for (i = 1, j = num_used_syms; i <= code_size_limit; i++) - for (l = num_codes[i]; l > 0; l--) - d->m_huff_code_sizes[table_num][pSyms[--j].m_sym_index] = (mz_uint8)(i); - } - - next_code[1] = 0; - for (j = 0, i = 2; i <= code_size_limit; i++) - next_code[i] = j = ((j + num_codes[i - 1]) << 1); - - for (i = 0; i < table_len; i++) - { - mz_uint rev_code = 0, code, code_size; - if ((code_size = d->m_huff_code_sizes[table_num][i]) == 0) - continue; - code = next_code[code_size]++; - for (l = code_size; l > 0; l--, code >>= 1) - rev_code = (rev_code << 1) | (code & 1); - d->m_huff_codes[table_num][i] = (mz_uint16)rev_code; - } -} - -#define TDEFL_PUT_BITS(b, l) \ - do \ - { \ - mz_uint bits = b; \ - mz_uint len = l; \ - MZ_ASSERT(bits <= ((1U << len) - 1U)); \ - d->m_bit_buffer |= (bits << d->m_bits_in); \ - d->m_bits_in += len; \ - while (d->m_bits_in >= 8) \ - { \ - if (d->m_pOutput_buf < d->m_pOutput_buf_end) \ - *d->m_pOutput_buf++ = (mz_uint8)(d->m_bit_buffer); \ - d->m_bit_buffer >>= 8; \ - d->m_bits_in -= 8; \ - } \ - } \ - MZ_MACRO_END - -#define TDEFL_RLE_PREV_CODE_SIZE() \ - { \ - if (rle_repeat_count) \ - { \ - if (rle_repeat_count < 3) \ - { \ - d->m_huff_count[2][prev_code_size] = (mz_uint16)(d->m_huff_count[2][prev_code_size] + rle_repeat_count); \ - while (rle_repeat_count--) \ - packed_code_sizes[num_packed_code_sizes++] = prev_code_size; \ - } \ - else \ - { \ - d->m_huff_count[2][16] = (mz_uint16)(d->m_huff_count[2][16] + 1); \ - packed_code_sizes[num_packed_code_sizes++] = 16; \ - packed_code_sizes[num_packed_code_sizes++] = (mz_uint8)(rle_repeat_count - 3); \ - } \ - rle_repeat_count = 0; \ - } \ - } - -#define TDEFL_RLE_ZERO_CODE_SIZE() \ - { \ - if (rle_z_count) \ - { \ - if (rle_z_count < 3) \ - { \ - d->m_huff_count[2][0] = (mz_uint16)(d->m_huff_count[2][0] + rle_z_count); \ - while (rle_z_count--) \ - packed_code_sizes[num_packed_code_sizes++] = 0; \ - } \ - else if (rle_z_count <= 10) \ - { \ - d->m_huff_count[2][17] = (mz_uint16)(d->m_huff_count[2][17] + 1); \ - packed_code_sizes[num_packed_code_sizes++] = 17; \ - packed_code_sizes[num_packed_code_sizes++] = (mz_uint8)(rle_z_count - 3); \ - } \ - else \ - { \ - d->m_huff_count[2][18] = (mz_uint16)(d->m_huff_count[2][18] + 1); \ - packed_code_sizes[num_packed_code_sizes++] = 18; \ - packed_code_sizes[num_packed_code_sizes++] = (mz_uint8)(rle_z_count - 11); \ - } \ - rle_z_count = 0; \ - } \ - } - -static const mz_uint8 s_tdefl_packed_code_size_syms_swizzle[] = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 }; - -static void tdefl_start_dynamic_block(tdefl_compressor *d) -{ - int num_lit_codes, num_dist_codes, num_bit_lengths; - mz_uint i, total_code_sizes_to_pack, num_packed_code_sizes, rle_z_count, rle_repeat_count, packed_code_sizes_index; - mz_uint8 code_sizes_to_pack[TDEFL_MAX_HUFF_SYMBOLS_0 + TDEFL_MAX_HUFF_SYMBOLS_1], packed_code_sizes[TDEFL_MAX_HUFF_SYMBOLS_0 + TDEFL_MAX_HUFF_SYMBOLS_1], prev_code_size = 0xFF; - - d->m_huff_count[0][256] = 1; - - tdefl_optimize_huffman_table(d, 0, TDEFL_MAX_HUFF_SYMBOLS_0, 15, MZ_FALSE); - tdefl_optimize_huffman_table(d, 1, TDEFL_MAX_HUFF_SYMBOLS_1, 15, MZ_FALSE); - - for (num_lit_codes = 286; num_lit_codes > 257; num_lit_codes--) - if (d->m_huff_code_sizes[0][num_lit_codes - 1]) - break; - for (num_dist_codes = 30; num_dist_codes > 1; num_dist_codes--) - if (d->m_huff_code_sizes[1][num_dist_codes - 1]) - break; - - memcpy(code_sizes_to_pack, &d->m_huff_code_sizes[0][0], num_lit_codes); - memcpy(code_sizes_to_pack + num_lit_codes, &d->m_huff_code_sizes[1][0], num_dist_codes); - total_code_sizes_to_pack = num_lit_codes + num_dist_codes; - num_packed_code_sizes = 0; - rle_z_count = 0; - rle_repeat_count = 0; - - memset(&d->m_huff_count[2][0], 0, sizeof(d->m_huff_count[2][0]) * TDEFL_MAX_HUFF_SYMBOLS_2); - for (i = 0; i < total_code_sizes_to_pack; i++) - { - mz_uint8 code_size = code_sizes_to_pack[i]; - if (!code_size) - { - TDEFL_RLE_PREV_CODE_SIZE(); - if (++rle_z_count == 138) - { - TDEFL_RLE_ZERO_CODE_SIZE(); - } - } - else - { - TDEFL_RLE_ZERO_CODE_SIZE(); - if (code_size != prev_code_size) - { - TDEFL_RLE_PREV_CODE_SIZE(); - d->m_huff_count[2][code_size] = (mz_uint16)(d->m_huff_count[2][code_size] + 1); - packed_code_sizes[num_packed_code_sizes++] = code_size; - } - else if (++rle_repeat_count == 6) - { - TDEFL_RLE_PREV_CODE_SIZE(); - } - } - prev_code_size = code_size; - } - if (rle_repeat_count) - { - TDEFL_RLE_PREV_CODE_SIZE(); - } - else - { - TDEFL_RLE_ZERO_CODE_SIZE(); - } - - tdefl_optimize_huffman_table(d, 2, TDEFL_MAX_HUFF_SYMBOLS_2, 7, MZ_FALSE); - - TDEFL_PUT_BITS(2, 2); - - TDEFL_PUT_BITS(num_lit_codes - 257, 5); - TDEFL_PUT_BITS(num_dist_codes - 1, 5); - - for (num_bit_lengths = 18; num_bit_lengths >= 0; num_bit_lengths--) - if (d->m_huff_code_sizes[2][s_tdefl_packed_code_size_syms_swizzle[num_bit_lengths]]) - break; - num_bit_lengths = MZ_MAX(4, (num_bit_lengths + 1)); - TDEFL_PUT_BITS(num_bit_lengths - 4, 4); - for (i = 0; (int)i < num_bit_lengths; i++) - TDEFL_PUT_BITS(d->m_huff_code_sizes[2][s_tdefl_packed_code_size_syms_swizzle[i]], 3); - - for (packed_code_sizes_index = 0; packed_code_sizes_index < num_packed_code_sizes;) - { - mz_uint code = packed_code_sizes[packed_code_sizes_index++]; - MZ_ASSERT(code < TDEFL_MAX_HUFF_SYMBOLS_2); - TDEFL_PUT_BITS(d->m_huff_codes[2][code], d->m_huff_code_sizes[2][code]); - if (code >= 16) - TDEFL_PUT_BITS(packed_code_sizes[packed_code_sizes_index++], "\02\03\07"[code - 16]); - } -} - -static void tdefl_start_static_block(tdefl_compressor *d) -{ - mz_uint i; - mz_uint8 *p = &d->m_huff_code_sizes[0][0]; - - for (i = 0; i <= 143; ++i) - *p++ = 8; - for (; i <= 255; ++i) - *p++ = 9; - for (; i <= 279; ++i) - *p++ = 7; - for (; i <= 287; ++i) - *p++ = 8; - - memset(d->m_huff_code_sizes[1], 5, 32); - - tdefl_optimize_huffman_table(d, 0, 288, 15, MZ_TRUE); - tdefl_optimize_huffman_table(d, 1, 32, 15, MZ_TRUE); - - TDEFL_PUT_BITS(1, 2); -} - -static const mz_uint mz_bitmasks[17] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF, 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF }; - -#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN && MINIZ_HAS_64BIT_REGISTERS -static mz_bool tdefl_compress_lz_codes(tdefl_compressor *d) -{ - mz_uint flags; - mz_uint8 *pLZ_codes; - mz_uint8 *pOutput_buf = d->m_pOutput_buf; - mz_uint8 *pLZ_code_buf_end = d->m_pLZ_code_buf; - mz_uint64 bit_buffer = d->m_bit_buffer; - mz_uint bits_in = d->m_bits_in; - -#define TDEFL_PUT_BITS_FAST(b, l) \ - { \ - bit_buffer |= (((mz_uint64)(b)) << bits_in); \ - bits_in += (l); \ - } - - flags = 1; - for (pLZ_codes = d->m_lz_code_buf; pLZ_codes < pLZ_code_buf_end; flags >>= 1) - { - if (flags == 1) - flags = *pLZ_codes++ | 0x100; - - if (flags & 1) - { - mz_uint s0, s1, n0, n1, sym, num_extra_bits; - mz_uint match_len = pLZ_codes[0]; - mz_uint match_dist = (pLZ_codes[1] | (pLZ_codes[2] << 8)); - pLZ_codes += 3; - - MZ_ASSERT(d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]); - TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][s_tdefl_len_sym[match_len]], d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]); - TDEFL_PUT_BITS_FAST(match_len & mz_bitmasks[s_tdefl_len_extra[match_len]], s_tdefl_len_extra[match_len]); - - /* This sequence coaxes MSVC into using cmov's vs. jmp's. */ - s0 = s_tdefl_small_dist_sym[match_dist & 511]; - n0 = s_tdefl_small_dist_extra[match_dist & 511]; - s1 = s_tdefl_large_dist_sym[match_dist >> 8]; - n1 = s_tdefl_large_dist_extra[match_dist >> 8]; - sym = (match_dist < 512) ? s0 : s1; - num_extra_bits = (match_dist < 512) ? n0 : n1; - - MZ_ASSERT(d->m_huff_code_sizes[1][sym]); - TDEFL_PUT_BITS_FAST(d->m_huff_codes[1][sym], d->m_huff_code_sizes[1][sym]); - TDEFL_PUT_BITS_FAST(match_dist & mz_bitmasks[num_extra_bits], num_extra_bits); - } - else - { - mz_uint lit = *pLZ_codes++; - MZ_ASSERT(d->m_huff_code_sizes[0][lit]); - TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]); - - if (((flags & 2) == 0) && (pLZ_codes < pLZ_code_buf_end)) - { - flags >>= 1; - lit = *pLZ_codes++; - MZ_ASSERT(d->m_huff_code_sizes[0][lit]); - TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]); - - if (((flags & 2) == 0) && (pLZ_codes < pLZ_code_buf_end)) - { - flags >>= 1; - lit = *pLZ_codes++; - MZ_ASSERT(d->m_huff_code_sizes[0][lit]); - TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]); - } - } - } - - if (pOutput_buf >= d->m_pOutput_buf_end) - return MZ_FALSE; - - memcpy(pOutput_buf, &bit_buffer, sizeof(mz_uint64)); - pOutput_buf += (bits_in >> 3); - bit_buffer >>= (bits_in & ~7); - bits_in &= 7; - } - -#undef TDEFL_PUT_BITS_FAST - - d->m_pOutput_buf = pOutput_buf; - d->m_bits_in = 0; - d->m_bit_buffer = 0; - - while (bits_in) - { - mz_uint32 n = MZ_MIN(bits_in, 16); - TDEFL_PUT_BITS((mz_uint)bit_buffer & mz_bitmasks[n], n); - bit_buffer >>= n; - bits_in -= n; - } - - TDEFL_PUT_BITS(d->m_huff_codes[0][256], d->m_huff_code_sizes[0][256]); - - return (d->m_pOutput_buf < d->m_pOutput_buf_end); -} -#else -static mz_bool tdefl_compress_lz_codes(tdefl_compressor *d) -{ - mz_uint flags; - mz_uint8 *pLZ_codes; - - flags = 1; - for (pLZ_codes = d->m_lz_code_buf; pLZ_codes < d->m_pLZ_code_buf; flags >>= 1) - { - if (flags == 1) - flags = *pLZ_codes++ | 0x100; - if (flags & 1) - { - mz_uint sym, num_extra_bits; - mz_uint match_len = pLZ_codes[0], match_dist = (pLZ_codes[1] | (pLZ_codes[2] << 8)); - pLZ_codes += 3; - - MZ_ASSERT(d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]); - TDEFL_PUT_BITS(d->m_huff_codes[0][s_tdefl_len_sym[match_len]], d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]); - TDEFL_PUT_BITS(match_len & mz_bitmasks[s_tdefl_len_extra[match_len]], s_tdefl_len_extra[match_len]); - - if (match_dist < 512) - { - sym = s_tdefl_small_dist_sym[match_dist]; - num_extra_bits = s_tdefl_small_dist_extra[match_dist]; - } - else - { - sym = s_tdefl_large_dist_sym[match_dist >> 8]; - num_extra_bits = s_tdefl_large_dist_extra[match_dist >> 8]; - } - MZ_ASSERT(d->m_huff_code_sizes[1][sym]); - TDEFL_PUT_BITS(d->m_huff_codes[1][sym], d->m_huff_code_sizes[1][sym]); - TDEFL_PUT_BITS(match_dist & mz_bitmasks[num_extra_bits], num_extra_bits); - } - else - { - mz_uint lit = *pLZ_codes++; - MZ_ASSERT(d->m_huff_code_sizes[0][lit]); - TDEFL_PUT_BITS(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]); - } - } - - TDEFL_PUT_BITS(d->m_huff_codes[0][256], d->m_huff_code_sizes[0][256]); - - return (d->m_pOutput_buf < d->m_pOutput_buf_end); -} -#endif /* MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN && MINIZ_HAS_64BIT_REGISTERS */ - -static mz_bool tdefl_compress_block(tdefl_compressor *d, mz_bool static_block) -{ - if (static_block) - tdefl_start_static_block(d); - else - tdefl_start_dynamic_block(d); - return tdefl_compress_lz_codes(d); -} - -extern const mz_uint s_tdefl_num_probes[11]; - -static int tdefl_flush_block(tdefl_compressor *d, int flush) -{ - mz_uint saved_bit_buf, saved_bits_in; - mz_uint8 *pSaved_output_buf; - mz_bool comp_block_succeeded = MZ_FALSE; - int n, use_raw_block = ((d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS) != 0) && (d->m_lookahead_pos - d->m_lz_code_buf_dict_pos) <= d->m_dict_size; - mz_uint8 *pOutput_buf_start = ((d->m_pPut_buf_func == NULL) && ((*d->m_pOut_buf_size - d->m_out_buf_ofs) >= TDEFL_OUT_BUF_SIZE)) ? ((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs) : d->m_output_buf; - - d->m_pOutput_buf = pOutput_buf_start; - d->m_pOutput_buf_end = d->m_pOutput_buf + TDEFL_OUT_BUF_SIZE - 16; - - MZ_ASSERT(!d->m_output_flush_remaining); - d->m_output_flush_ofs = 0; - d->m_output_flush_remaining = 0; - - *d->m_pLZ_flags = (mz_uint8)(*d->m_pLZ_flags >> d->m_num_flags_left); - d->m_pLZ_code_buf -= (d->m_num_flags_left == 8); - - if ((d->m_flags & TDEFL_WRITE_ZLIB_HEADER) && (!d->m_block_index)) - { - const mz_uint8 cmf = 0x78; - mz_uint8 flg, flevel = 3; - mz_uint header, i, mz_un = sizeof(s_tdefl_num_probes) / sizeof(mz_uint); - - /* Determine compression level by reversing the process in tdefl_create_comp_flags_from_zip_params() */ - for (i = 0; i < mz_un; i++) - if (s_tdefl_num_probes[i] == (d->m_flags & 0xFFF)) break; - - if (i < 2) - flevel = 0; - else if (i < 6) - flevel = 1; - else if (i == 6) - flevel = 2; - - header = cmf << 8 | (flevel << 6); - header += 31 - (header % 31); - flg = header & 0xFF; - - TDEFL_PUT_BITS(cmf, 8); - TDEFL_PUT_BITS(flg, 8); - } - - TDEFL_PUT_BITS(flush == TDEFL_FINISH, 1); - - pSaved_output_buf = d->m_pOutput_buf; - saved_bit_buf = d->m_bit_buffer; - saved_bits_in = d->m_bits_in; - - if (!use_raw_block) - comp_block_succeeded = tdefl_compress_block(d, (d->m_flags & TDEFL_FORCE_ALL_STATIC_BLOCKS) || (d->m_total_lz_bytes < 48)); - - /* If the block gets expanded, forget the current contents of the output buffer and send a raw block instead. */ - if (((use_raw_block) || ((d->m_total_lz_bytes) && ((d->m_pOutput_buf - pSaved_output_buf + 1U) >= d->m_total_lz_bytes))) && - ((d->m_lookahead_pos - d->m_lz_code_buf_dict_pos) <= d->m_dict_size)) - { - mz_uint i; - d->m_pOutput_buf = pSaved_output_buf; - d->m_bit_buffer = saved_bit_buf, d->m_bits_in = saved_bits_in; - TDEFL_PUT_BITS(0, 2); - if (d->m_bits_in) - { - TDEFL_PUT_BITS(0, 8 - d->m_bits_in); - } - for (i = 2; i; --i, d->m_total_lz_bytes ^= 0xFFFF) - { - TDEFL_PUT_BITS(d->m_total_lz_bytes & 0xFFFF, 16); - } - for (i = 0; i < d->m_total_lz_bytes; ++i) - { - TDEFL_PUT_BITS(d->m_dict[(d->m_lz_code_buf_dict_pos + i) & TDEFL_LZ_DICT_SIZE_MASK], 8); - } - } - /* Check for the extremely unlikely (if not impossible) case of the compressed block not fitting into the output buffer when using dynamic codes. */ - else if (!comp_block_succeeded) - { - d->m_pOutput_buf = pSaved_output_buf; - d->m_bit_buffer = saved_bit_buf, d->m_bits_in = saved_bits_in; - tdefl_compress_block(d, MZ_TRUE); - } - - if (flush) - { - if (flush == TDEFL_FINISH) - { - if (d->m_bits_in) - { - TDEFL_PUT_BITS(0, 8 - d->m_bits_in); - } - if (d->m_flags & TDEFL_WRITE_ZLIB_HEADER) - { - mz_uint i, a = d->m_adler32; - for (i = 0; i < 4; i++) - { - TDEFL_PUT_BITS((a >> 24) & 0xFF, 8); - a <<= 8; - } - } - } - else - { - mz_uint i, z = 0; - TDEFL_PUT_BITS(0, 3); - if (d->m_bits_in) - { - TDEFL_PUT_BITS(0, 8 - d->m_bits_in); - } - for (i = 2; i; --i, z ^= 0xFFFF) - { - TDEFL_PUT_BITS(z & 0xFFFF, 16); - } - } - } - - MZ_ASSERT(d->m_pOutput_buf < d->m_pOutput_buf_end); - - memset(&d->m_huff_count[0][0], 0, sizeof(d->m_huff_count[0][0]) * TDEFL_MAX_HUFF_SYMBOLS_0); - memset(&d->m_huff_count[1][0], 0, sizeof(d->m_huff_count[1][0]) * TDEFL_MAX_HUFF_SYMBOLS_1); - - d->m_pLZ_code_buf = d->m_lz_code_buf + 1; - d->m_pLZ_flags = d->m_lz_code_buf; - d->m_num_flags_left = 8; - d->m_lz_code_buf_dict_pos += d->m_total_lz_bytes; - d->m_total_lz_bytes = 0; - d->m_block_index++; - - if ((n = (int)(d->m_pOutput_buf - pOutput_buf_start)) != 0) - { - if (d->m_pPut_buf_func) - { - *d->m_pIn_buf_size = d->m_pSrc - (const mz_uint8 *)d->m_pIn_buf; - if (!(*d->m_pPut_buf_func)(d->m_output_buf, n, d->m_pPut_buf_user)) - return (d->m_prev_return_status = TDEFL_STATUS_PUT_BUF_FAILED); - } - else if (pOutput_buf_start == d->m_output_buf) - { - int bytes_to_copy = (int)MZ_MIN((size_t)n, (size_t)(*d->m_pOut_buf_size - d->m_out_buf_ofs)); - memcpy((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs, d->m_output_buf, bytes_to_copy); - d->m_out_buf_ofs += bytes_to_copy; - if ((n -= bytes_to_copy) != 0) - { - d->m_output_flush_ofs = bytes_to_copy; - d->m_output_flush_remaining = n; - } - } - else - { - d->m_out_buf_ofs += n; - } - } - - return d->m_output_flush_remaining; -} - -#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES -#ifdef MINIZ_UNALIGNED_USE_MEMCPY -static mz_uint16 TDEFL_READ_UNALIGNED_WORD(const mz_uint8* p) -{ - mz_uint16 ret; - memcpy(&ret, p, sizeof(mz_uint16)); - return ret; -} -static mz_uint16 TDEFL_READ_UNALIGNED_WORD2(const mz_uint16* p) -{ - mz_uint16 ret; - memcpy(&ret, p, sizeof(mz_uint16)); - return ret; -} -#else -#define TDEFL_READ_UNALIGNED_WORD(p) *(const mz_uint16 *)(p) -#define TDEFL_READ_UNALIGNED_WORD2(p) *(const mz_uint16 *)(p) -#endif -static MZ_FORCEINLINE void tdefl_find_match(tdefl_compressor *d, mz_uint lookahead_pos, mz_uint max_dist, mz_uint max_match_len, mz_uint *pMatch_dist, mz_uint *pMatch_len) -{ - mz_uint dist, pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK, match_len = *pMatch_len, probe_pos = pos, next_probe_pos, probe_len; - mz_uint num_probes_left = d->m_max_probes[match_len >= 32]; - const mz_uint16 *s = (const mz_uint16 *)(d->m_dict + pos), *p, *q; - mz_uint16 c01 = TDEFL_READ_UNALIGNED_WORD(&d->m_dict[pos + match_len - 1]), s01 = TDEFL_READ_UNALIGNED_WORD2(s); - MZ_ASSERT(max_match_len <= TDEFL_MAX_MATCH_LEN); - if (max_match_len <= match_len) - return; - for (;;) - { - for (;;) - { - if (--num_probes_left == 0) - return; -#define TDEFL_PROBE \ - next_probe_pos = d->m_next[probe_pos]; \ - if ((!next_probe_pos) || ((dist = (mz_uint16)(lookahead_pos - next_probe_pos)) > max_dist)) \ - return; \ - probe_pos = next_probe_pos & TDEFL_LZ_DICT_SIZE_MASK; \ - if (TDEFL_READ_UNALIGNED_WORD(&d->m_dict[probe_pos + match_len - 1]) == c01) \ - break; - TDEFL_PROBE; - TDEFL_PROBE; - TDEFL_PROBE; - } - if (!dist) - break; - q = (const mz_uint16 *)(d->m_dict + probe_pos); - if (TDEFL_READ_UNALIGNED_WORD2(q) != s01) - continue; - p = s; - probe_len = 32; - do - { - } while ((TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) && (TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) && - (TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) && (TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) && (--probe_len > 0)); - if (!probe_len) - { - *pMatch_dist = dist; - *pMatch_len = MZ_MIN(max_match_len, (mz_uint)TDEFL_MAX_MATCH_LEN); - break; - } - else if ((probe_len = ((mz_uint)(p - s) * 2) + (mz_uint)(*(const mz_uint8 *)p == *(const mz_uint8 *)q)) > match_len) - { - *pMatch_dist = dist; - if ((*pMatch_len = match_len = MZ_MIN(max_match_len, probe_len)) == max_match_len) - break; - c01 = TDEFL_READ_UNALIGNED_WORD(&d->m_dict[pos + match_len - 1]); - } - } -} -#else -static MZ_FORCEINLINE void tdefl_find_match(tdefl_compressor *d, mz_uint lookahead_pos, mz_uint max_dist, mz_uint max_match_len, mz_uint *pMatch_dist, mz_uint *pMatch_len) -{ - mz_uint dist, pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK, match_len = *pMatch_len, probe_pos = pos, next_probe_pos, probe_len; - mz_uint num_probes_left = d->m_max_probes[match_len >= 32]; - const mz_uint8 *s = d->m_dict + pos, *p, *q; - mz_uint8 c0 = d->m_dict[pos + match_len], c1 = d->m_dict[pos + match_len - 1]; - MZ_ASSERT(max_match_len <= TDEFL_MAX_MATCH_LEN); - if (max_match_len <= match_len) - return; - for (;;) - { - for (;;) - { - if (--num_probes_left == 0) - return; -#define TDEFL_PROBE \ - next_probe_pos = d->m_next[probe_pos]; \ - if ((!next_probe_pos) || ((dist = (mz_uint16)(lookahead_pos - next_probe_pos)) > max_dist)) \ - return; \ - probe_pos = next_probe_pos & TDEFL_LZ_DICT_SIZE_MASK; \ - if ((d->m_dict[probe_pos + match_len] == c0) && (d->m_dict[probe_pos + match_len - 1] == c1)) \ - break; - TDEFL_PROBE; - TDEFL_PROBE; - TDEFL_PROBE; - } - if (!dist) - break; - p = s; - q = d->m_dict + probe_pos; - for (probe_len = 0; probe_len < max_match_len; probe_len++) - if (*p++ != *q++) - break; - if (probe_len > match_len) - { - *pMatch_dist = dist; - if ((*pMatch_len = match_len = probe_len) == max_match_len) - return; - c0 = d->m_dict[pos + match_len]; - c1 = d->m_dict[pos + match_len - 1]; - } - } -} -#endif /* #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES */ - -#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN -#ifdef MINIZ_UNALIGNED_USE_MEMCPY -static mz_uint32 TDEFL_READ_UNALIGNED_WORD32(const mz_uint8* p) -{ - mz_uint32 ret; - memcpy(&ret, p, sizeof(mz_uint32)); - return ret; -} -#else -#define TDEFL_READ_UNALIGNED_WORD32(p) *(const mz_uint32 *)(p) -#endif -static mz_bool tdefl_compress_fast(tdefl_compressor *d) -{ - /* Faster, minimally featured LZRW1-style match+parse loop with better register utilization. Intended for applications where raw throughput is valued more highly than ratio. */ - mz_uint lookahead_pos = d->m_lookahead_pos, lookahead_size = d->m_lookahead_size, dict_size = d->m_dict_size, total_lz_bytes = d->m_total_lz_bytes, num_flags_left = d->m_num_flags_left; - mz_uint8 *pLZ_code_buf = d->m_pLZ_code_buf, *pLZ_flags = d->m_pLZ_flags; - mz_uint cur_pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK; - - while ((d->m_src_buf_left) || ((d->m_flush) && (lookahead_size))) - { - const mz_uint TDEFL_COMP_FAST_LOOKAHEAD_SIZE = 4096; - mz_uint dst_pos = (lookahead_pos + lookahead_size) & TDEFL_LZ_DICT_SIZE_MASK; - mz_uint num_bytes_to_process = (mz_uint)MZ_MIN(d->m_src_buf_left, TDEFL_COMP_FAST_LOOKAHEAD_SIZE - lookahead_size); - d->m_src_buf_left -= num_bytes_to_process; - lookahead_size += num_bytes_to_process; - - while (num_bytes_to_process) - { - mz_uint32 n = MZ_MIN(TDEFL_LZ_DICT_SIZE - dst_pos, num_bytes_to_process); - memcpy(d->m_dict + dst_pos, d->m_pSrc, n); - if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1)) - memcpy(d->m_dict + TDEFL_LZ_DICT_SIZE + dst_pos, d->m_pSrc, MZ_MIN(n, (TDEFL_MAX_MATCH_LEN - 1) - dst_pos)); - d->m_pSrc += n; - dst_pos = (dst_pos + n) & TDEFL_LZ_DICT_SIZE_MASK; - num_bytes_to_process -= n; - } - - dict_size = MZ_MIN(TDEFL_LZ_DICT_SIZE - lookahead_size, dict_size); - if ((!d->m_flush) && (lookahead_size < TDEFL_COMP_FAST_LOOKAHEAD_SIZE)) - break; - - while (lookahead_size >= 4) - { - mz_uint cur_match_dist, cur_match_len = 1; - mz_uint8 *pCur_dict = d->m_dict + cur_pos; - mz_uint first_trigram = TDEFL_READ_UNALIGNED_WORD32(pCur_dict) & 0xFFFFFF; - mz_uint hash = (first_trigram ^ (first_trigram >> (24 - (TDEFL_LZ_HASH_BITS - 8)))) & TDEFL_LEVEL1_HASH_SIZE_MASK; - mz_uint probe_pos = d->m_hash[hash]; - d->m_hash[hash] = (mz_uint16)lookahead_pos; - - if (((cur_match_dist = (mz_uint16)(lookahead_pos - probe_pos)) <= dict_size) && ((TDEFL_READ_UNALIGNED_WORD32(d->m_dict + (probe_pos &= TDEFL_LZ_DICT_SIZE_MASK)) & 0xFFFFFF) == first_trigram)) - { - const mz_uint16 *p = (const mz_uint16 *)pCur_dict; - const mz_uint16 *q = (const mz_uint16 *)(d->m_dict + probe_pos); - mz_uint32 probe_len = 32; - do - { - } while ((TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) && (TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) && - (TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) && (TDEFL_READ_UNALIGNED_WORD2(++p) == TDEFL_READ_UNALIGNED_WORD2(++q)) && (--probe_len > 0)); - cur_match_len = ((mz_uint)(p - (const mz_uint16 *)pCur_dict) * 2) + (mz_uint)(*(const mz_uint8 *)p == *(const mz_uint8 *)q); - if (!probe_len) - cur_match_len = cur_match_dist ? TDEFL_MAX_MATCH_LEN : 0; - - if ((cur_match_len < TDEFL_MIN_MATCH_LEN) || ((cur_match_len == TDEFL_MIN_MATCH_LEN) && (cur_match_dist >= 8U * 1024U))) - { - cur_match_len = 1; - *pLZ_code_buf++ = (mz_uint8)first_trigram; - *pLZ_flags = (mz_uint8)(*pLZ_flags >> 1); - d->m_huff_count[0][(mz_uint8)first_trigram]++; - } - else - { - mz_uint32 s0, s1; - cur_match_len = MZ_MIN(cur_match_len, lookahead_size); - - MZ_ASSERT((cur_match_len >= TDEFL_MIN_MATCH_LEN) && (cur_match_dist >= 1) && (cur_match_dist <= TDEFL_LZ_DICT_SIZE)); - - cur_match_dist--; - - pLZ_code_buf[0] = (mz_uint8)(cur_match_len - TDEFL_MIN_MATCH_LEN); -#ifdef MINIZ_UNALIGNED_USE_MEMCPY - memcpy(&pLZ_code_buf[1], &cur_match_dist, sizeof(cur_match_dist)); -#else - *(mz_uint16 *)(&pLZ_code_buf[1]) = (mz_uint16)cur_match_dist; -#endif - pLZ_code_buf += 3; - *pLZ_flags = (mz_uint8)((*pLZ_flags >> 1) | 0x80); - - s0 = s_tdefl_small_dist_sym[cur_match_dist & 511]; - s1 = s_tdefl_large_dist_sym[cur_match_dist >> 8]; - d->m_huff_count[1][(cur_match_dist < 512) ? s0 : s1]++; - - d->m_huff_count[0][s_tdefl_len_sym[cur_match_len - TDEFL_MIN_MATCH_LEN]]++; - } - } - else - { - *pLZ_code_buf++ = (mz_uint8)first_trigram; - *pLZ_flags = (mz_uint8)(*pLZ_flags >> 1); - d->m_huff_count[0][(mz_uint8)first_trigram]++; - } - - if (--num_flags_left == 0) - { - num_flags_left = 8; - pLZ_flags = pLZ_code_buf++; - } - - total_lz_bytes += cur_match_len; - lookahead_pos += cur_match_len; - dict_size = MZ_MIN(dict_size + cur_match_len, (mz_uint)TDEFL_LZ_DICT_SIZE); - cur_pos = (cur_pos + cur_match_len) & TDEFL_LZ_DICT_SIZE_MASK; - MZ_ASSERT(lookahead_size >= cur_match_len); - lookahead_size -= cur_match_len; - - if (pLZ_code_buf > &d->m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE - 8]) - { - int n; - d->m_lookahead_pos = lookahead_pos; - d->m_lookahead_size = lookahead_size; - d->m_dict_size = dict_size; - d->m_total_lz_bytes = total_lz_bytes; - d->m_pLZ_code_buf = pLZ_code_buf; - d->m_pLZ_flags = pLZ_flags; - d->m_num_flags_left = num_flags_left; - if ((n = tdefl_flush_block(d, 0)) != 0) - return (n < 0) ? MZ_FALSE : MZ_TRUE; - total_lz_bytes = d->m_total_lz_bytes; - pLZ_code_buf = d->m_pLZ_code_buf; - pLZ_flags = d->m_pLZ_flags; - num_flags_left = d->m_num_flags_left; - } - } - - while (lookahead_size) - { - mz_uint8 lit = d->m_dict[cur_pos]; - - total_lz_bytes++; - *pLZ_code_buf++ = lit; - *pLZ_flags = (mz_uint8)(*pLZ_flags >> 1); - if (--num_flags_left == 0) - { - num_flags_left = 8; - pLZ_flags = pLZ_code_buf++; - } - - d->m_huff_count[0][lit]++; - - lookahead_pos++; - dict_size = MZ_MIN(dict_size + 1, (mz_uint)TDEFL_LZ_DICT_SIZE); - cur_pos = (cur_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK; - lookahead_size--; - - if (pLZ_code_buf > &d->m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE - 8]) - { - int n; - d->m_lookahead_pos = lookahead_pos; - d->m_lookahead_size = lookahead_size; - d->m_dict_size = dict_size; - d->m_total_lz_bytes = total_lz_bytes; - d->m_pLZ_code_buf = pLZ_code_buf; - d->m_pLZ_flags = pLZ_flags; - d->m_num_flags_left = num_flags_left; - if ((n = tdefl_flush_block(d, 0)) != 0) - return (n < 0) ? MZ_FALSE : MZ_TRUE; - total_lz_bytes = d->m_total_lz_bytes; - pLZ_code_buf = d->m_pLZ_code_buf; - pLZ_flags = d->m_pLZ_flags; - num_flags_left = d->m_num_flags_left; - } - } - } - - d->m_lookahead_pos = lookahead_pos; - d->m_lookahead_size = lookahead_size; - d->m_dict_size = dict_size; - d->m_total_lz_bytes = total_lz_bytes; - d->m_pLZ_code_buf = pLZ_code_buf; - d->m_pLZ_flags = pLZ_flags; - d->m_num_flags_left = num_flags_left; - return MZ_TRUE; -} -#endif /* MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN */ - -static MZ_FORCEINLINE void tdefl_record_literal(tdefl_compressor *d, mz_uint8 lit) -{ - d->m_total_lz_bytes++; - *d->m_pLZ_code_buf++ = lit; - *d->m_pLZ_flags = (mz_uint8)(*d->m_pLZ_flags >> 1); - if (--d->m_num_flags_left == 0) - { - d->m_num_flags_left = 8; - d->m_pLZ_flags = d->m_pLZ_code_buf++; - } - d->m_huff_count[0][lit]++; -} - -static MZ_FORCEINLINE void tdefl_record_match(tdefl_compressor *d, mz_uint match_len, mz_uint match_dist) -{ - mz_uint32 s0, s1; - - MZ_ASSERT((match_len >= TDEFL_MIN_MATCH_LEN) && (match_dist >= 1) && (match_dist <= TDEFL_LZ_DICT_SIZE)); - - d->m_total_lz_bytes += match_len; - - d->m_pLZ_code_buf[0] = (mz_uint8)(match_len - TDEFL_MIN_MATCH_LEN); - - match_dist -= 1; - d->m_pLZ_code_buf[1] = (mz_uint8)(match_dist & 0xFF); - d->m_pLZ_code_buf[2] = (mz_uint8)(match_dist >> 8); - d->m_pLZ_code_buf += 3; - - *d->m_pLZ_flags = (mz_uint8)((*d->m_pLZ_flags >> 1) | 0x80); - if (--d->m_num_flags_left == 0) - { - d->m_num_flags_left = 8; - d->m_pLZ_flags = d->m_pLZ_code_buf++; - } - - s0 = s_tdefl_small_dist_sym[match_dist & 511]; - s1 = s_tdefl_large_dist_sym[(match_dist >> 8) & 127]; - d->m_huff_count[1][(match_dist < 512) ? s0 : s1]++; - d->m_huff_count[0][s_tdefl_len_sym[match_len - TDEFL_MIN_MATCH_LEN]]++; -} - -static mz_bool tdefl_compress_normal(tdefl_compressor *d) -{ - const mz_uint8 *pSrc = d->m_pSrc; - size_t src_buf_left = d->m_src_buf_left; - tdefl_flush flush = d->m_flush; - - while ((src_buf_left) || ((flush) && (d->m_lookahead_size))) - { - mz_uint len_to_move, cur_match_dist, cur_match_len, cur_pos; - /* Update dictionary and hash chains. Keeps the lookahead size equal to TDEFL_MAX_MATCH_LEN. */ - if ((d->m_lookahead_size + d->m_dict_size) >= (TDEFL_MIN_MATCH_LEN - 1)) - { - mz_uint dst_pos = (d->m_lookahead_pos + d->m_lookahead_size) & TDEFL_LZ_DICT_SIZE_MASK, ins_pos = d->m_lookahead_pos + d->m_lookahead_size - 2; - mz_uint hash = (d->m_dict[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] << TDEFL_LZ_HASH_SHIFT) ^ d->m_dict[(ins_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK]; - mz_uint num_bytes_to_process = (mz_uint)MZ_MIN(src_buf_left, TDEFL_MAX_MATCH_LEN - d->m_lookahead_size); - const mz_uint8 *pSrc_end = pSrc ? pSrc + num_bytes_to_process : NULL; - src_buf_left -= num_bytes_to_process; - d->m_lookahead_size += num_bytes_to_process; - while (pSrc != pSrc_end) - { - mz_uint8 c = *pSrc++; - d->m_dict[dst_pos] = c; - if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1)) - d->m_dict[TDEFL_LZ_DICT_SIZE + dst_pos] = c; - hash = ((hash << TDEFL_LZ_HASH_SHIFT) ^ c) & (TDEFL_LZ_HASH_SIZE - 1); - d->m_next[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] = d->m_hash[hash]; - d->m_hash[hash] = (mz_uint16)(ins_pos); - dst_pos = (dst_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK; - ins_pos++; - } - } - else - { - while ((src_buf_left) && (d->m_lookahead_size < TDEFL_MAX_MATCH_LEN)) - { - mz_uint8 c = *pSrc++; - mz_uint dst_pos = (d->m_lookahead_pos + d->m_lookahead_size) & TDEFL_LZ_DICT_SIZE_MASK; - src_buf_left--; - d->m_dict[dst_pos] = c; - if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1)) - d->m_dict[TDEFL_LZ_DICT_SIZE + dst_pos] = c; - if ((++d->m_lookahead_size + d->m_dict_size) >= TDEFL_MIN_MATCH_LEN) - { - mz_uint ins_pos = d->m_lookahead_pos + (d->m_lookahead_size - 1) - 2; - mz_uint hash = ((d->m_dict[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] << (TDEFL_LZ_HASH_SHIFT * 2)) ^ (d->m_dict[(ins_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK] << TDEFL_LZ_HASH_SHIFT) ^ c) & (TDEFL_LZ_HASH_SIZE - 1); - d->m_next[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] = d->m_hash[hash]; - d->m_hash[hash] = (mz_uint16)(ins_pos); - } - } - } - d->m_dict_size = MZ_MIN(TDEFL_LZ_DICT_SIZE - d->m_lookahead_size, d->m_dict_size); - if ((!flush) && (d->m_lookahead_size < TDEFL_MAX_MATCH_LEN)) - break; - - /* Simple lazy/greedy parsing state machine. */ - len_to_move = 1; - cur_match_dist = 0; - cur_match_len = d->m_saved_match_len ? d->m_saved_match_len : (TDEFL_MIN_MATCH_LEN - 1); - cur_pos = d->m_lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK; - if (d->m_flags & (TDEFL_RLE_MATCHES | TDEFL_FORCE_ALL_RAW_BLOCKS)) - { - if ((d->m_dict_size) && (!(d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS))) - { - mz_uint8 c = d->m_dict[(cur_pos - 1) & TDEFL_LZ_DICT_SIZE_MASK]; - cur_match_len = 0; - while (cur_match_len < d->m_lookahead_size) - { - if (d->m_dict[cur_pos + cur_match_len] != c) - break; - cur_match_len++; - } - if (cur_match_len < TDEFL_MIN_MATCH_LEN) - cur_match_len = 0; - else - cur_match_dist = 1; - } - } - else - { - tdefl_find_match(d, d->m_lookahead_pos, d->m_dict_size, d->m_lookahead_size, &cur_match_dist, &cur_match_len); - } - if (((cur_match_len == TDEFL_MIN_MATCH_LEN) && (cur_match_dist >= 8U * 1024U)) || (cur_pos == cur_match_dist) || ((d->m_flags & TDEFL_FILTER_MATCHES) && (cur_match_len <= 5))) - { - cur_match_dist = cur_match_len = 0; - } - if (d->m_saved_match_len) - { - if (cur_match_len > d->m_saved_match_len) - { - tdefl_record_literal(d, (mz_uint8)d->m_saved_lit); - if (cur_match_len >= 128) - { - tdefl_record_match(d, cur_match_len, cur_match_dist); - d->m_saved_match_len = 0; - len_to_move = cur_match_len; - } - else - { - d->m_saved_lit = d->m_dict[cur_pos]; - d->m_saved_match_dist = cur_match_dist; - d->m_saved_match_len = cur_match_len; - } - } - else - { - tdefl_record_match(d, d->m_saved_match_len, d->m_saved_match_dist); - len_to_move = d->m_saved_match_len - 1; - d->m_saved_match_len = 0; - } - } - else if (!cur_match_dist) - tdefl_record_literal(d, d->m_dict[MZ_MIN(cur_pos, sizeof(d->m_dict) - 1)]); - else if ((d->m_greedy_parsing) || (d->m_flags & TDEFL_RLE_MATCHES) || (cur_match_len >= 128)) - { - tdefl_record_match(d, cur_match_len, cur_match_dist); - len_to_move = cur_match_len; - } - else - { - d->m_saved_lit = d->m_dict[MZ_MIN(cur_pos, sizeof(d->m_dict) - 1)]; - d->m_saved_match_dist = cur_match_dist; - d->m_saved_match_len = cur_match_len; - } - /* Move the lookahead forward by len_to_move bytes. */ - d->m_lookahead_pos += len_to_move; - MZ_ASSERT(d->m_lookahead_size >= len_to_move); - d->m_lookahead_size -= len_to_move; - d->m_dict_size = MZ_MIN(d->m_dict_size + len_to_move, (mz_uint)TDEFL_LZ_DICT_SIZE); - /* Check if it's time to flush the current LZ codes to the internal output buffer. */ - if ((d->m_pLZ_code_buf > &d->m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE - 8]) || - ((d->m_total_lz_bytes > 31 * 1024) && (((((mz_uint)(d->m_pLZ_code_buf - d->m_lz_code_buf) * 115) >> 7) >= d->m_total_lz_bytes) || (d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS)))) - { - int n; - d->m_pSrc = pSrc; - d->m_src_buf_left = src_buf_left; - if ((n = tdefl_flush_block(d, 0)) != 0) - return (n < 0) ? MZ_FALSE : MZ_TRUE; - } - } - - d->m_pSrc = pSrc; - d->m_src_buf_left = src_buf_left; - return MZ_TRUE; -} - -static tdefl_status tdefl_flush_output_buffer(tdefl_compressor *d) -{ - if (d->m_pIn_buf_size) - { - *d->m_pIn_buf_size = d->m_pSrc - (const mz_uint8 *)d->m_pIn_buf; - } - - if (d->m_pOut_buf_size) - { - size_t n = MZ_MIN(*d->m_pOut_buf_size - d->m_out_buf_ofs, d->m_output_flush_remaining); - memcpy((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs, d->m_output_buf + d->m_output_flush_ofs, n); - d->m_output_flush_ofs += (mz_uint)n; - d->m_output_flush_remaining -= (mz_uint)n; - d->m_out_buf_ofs += n; - - *d->m_pOut_buf_size = d->m_out_buf_ofs; - } - - return (d->m_finished && !d->m_output_flush_remaining) ? TDEFL_STATUS_DONE : TDEFL_STATUS_OKAY; -} - -tdefl_status tdefl_compress(tdefl_compressor *d, const void *pIn_buf, size_t *pIn_buf_size, void *pOut_buf, size_t *pOut_buf_size, tdefl_flush flush) -{ - if (!d) - { - if (pIn_buf_size) - *pIn_buf_size = 0; - if (pOut_buf_size) - *pOut_buf_size = 0; - return TDEFL_STATUS_BAD_PARAM; - } - - d->m_pIn_buf = pIn_buf; - d->m_pIn_buf_size = pIn_buf_size; - d->m_pOut_buf = pOut_buf; - d->m_pOut_buf_size = pOut_buf_size; - d->m_pSrc = (const mz_uint8 *)(pIn_buf); - d->m_src_buf_left = pIn_buf_size ? *pIn_buf_size : 0; - d->m_out_buf_ofs = 0; - d->m_flush = flush; - - if (((d->m_pPut_buf_func != NULL) == ((pOut_buf != NULL) || (pOut_buf_size != NULL))) || (d->m_prev_return_status != TDEFL_STATUS_OKAY) || - (d->m_wants_to_finish && (flush != TDEFL_FINISH)) || (pIn_buf_size && *pIn_buf_size && !pIn_buf) || (pOut_buf_size && *pOut_buf_size && !pOut_buf)) - { - if (pIn_buf_size) - *pIn_buf_size = 0; - if (pOut_buf_size) - *pOut_buf_size = 0; - return (d->m_prev_return_status = TDEFL_STATUS_BAD_PARAM); - } - d->m_wants_to_finish |= (flush == TDEFL_FINISH); - - if ((d->m_output_flush_remaining) || (d->m_finished)) - return (d->m_prev_return_status = tdefl_flush_output_buffer(d)); - -#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN - if (((d->m_flags & TDEFL_MAX_PROBES_MASK) == 1) && - ((d->m_flags & TDEFL_GREEDY_PARSING_FLAG) != 0) && - ((d->m_flags & (TDEFL_FILTER_MATCHES | TDEFL_FORCE_ALL_RAW_BLOCKS | TDEFL_RLE_MATCHES)) == 0)) - { - if (!tdefl_compress_fast(d)) - return d->m_prev_return_status; - } - else -#endif /* #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN */ - { - if (!tdefl_compress_normal(d)) - return d->m_prev_return_status; - } - - if ((d->m_flags & (TDEFL_WRITE_ZLIB_HEADER | TDEFL_COMPUTE_ADLER32)) && (pIn_buf)) - d->m_adler32 = (mz_uint32)mz_adler32(d->m_adler32, (const mz_uint8 *)pIn_buf, d->m_pSrc - (const mz_uint8 *)pIn_buf); - - if ((flush) && (!d->m_lookahead_size) && (!d->m_src_buf_left) && (!d->m_output_flush_remaining)) - { - if (tdefl_flush_block(d, flush) < 0) - return d->m_prev_return_status; - d->m_finished = (flush == TDEFL_FINISH); - if (flush == TDEFL_FULL_FLUSH) - { - MZ_CLEAR_ARR(d->m_hash); - MZ_CLEAR_ARR(d->m_next); - d->m_dict_size = 0; - } - } - - return (d->m_prev_return_status = tdefl_flush_output_buffer(d)); -} - -tdefl_status tdefl_compress_buffer(tdefl_compressor *d, const void *pIn_buf, size_t in_buf_size, tdefl_flush flush) -{ - MZ_ASSERT(d->m_pPut_buf_func); - return tdefl_compress(d, pIn_buf, &in_buf_size, NULL, NULL, flush); -} - -tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags) -{ - d->m_pPut_buf_func = pPut_buf_func; - d->m_pPut_buf_user = pPut_buf_user; - d->m_flags = (mz_uint)(flags); - d->m_max_probes[0] = 1 + ((flags & 0xFFF) + 2) / 3; - d->m_greedy_parsing = (flags & TDEFL_GREEDY_PARSING_FLAG) != 0; - d->m_max_probes[1] = 1 + (((flags & 0xFFF) >> 2) + 2) / 3; - if (!(flags & TDEFL_NONDETERMINISTIC_PARSING_FLAG)) - MZ_CLEAR_ARR(d->m_hash); - d->m_lookahead_pos = d->m_lookahead_size = d->m_dict_size = d->m_total_lz_bytes = d->m_lz_code_buf_dict_pos = d->m_bits_in = 0; - d->m_output_flush_ofs = d->m_output_flush_remaining = d->m_finished = d->m_block_index = d->m_bit_buffer = d->m_wants_to_finish = 0; - d->m_pLZ_code_buf = d->m_lz_code_buf + 1; - d->m_pLZ_flags = d->m_lz_code_buf; - *d->m_pLZ_flags = 0; - d->m_num_flags_left = 8; - d->m_pOutput_buf = d->m_output_buf; - d->m_pOutput_buf_end = d->m_output_buf; - d->m_prev_return_status = TDEFL_STATUS_OKAY; - d->m_saved_match_dist = d->m_saved_match_len = d->m_saved_lit = 0; - d->m_adler32 = 1; - d->m_pIn_buf = NULL; - d->m_pOut_buf = NULL; - d->m_pIn_buf_size = NULL; - d->m_pOut_buf_size = NULL; - d->m_flush = TDEFL_NO_FLUSH; - d->m_pSrc = NULL; - d->m_src_buf_left = 0; - d->m_out_buf_ofs = 0; - if (!(flags & TDEFL_NONDETERMINISTIC_PARSING_FLAG)) - MZ_CLEAR_ARR(d->m_dict); - memset(&d->m_huff_count[0][0], 0, sizeof(d->m_huff_count[0][0]) * TDEFL_MAX_HUFF_SYMBOLS_0); - memset(&d->m_huff_count[1][0], 0, sizeof(d->m_huff_count[1][0]) * TDEFL_MAX_HUFF_SYMBOLS_1); - return TDEFL_STATUS_OKAY; -} - -tdefl_status tdefl_get_prev_return_status(tdefl_compressor *d) -{ - return d->m_prev_return_status; -} - -mz_uint32 tdefl_get_adler32(tdefl_compressor *d) -{ - return d->m_adler32; -} - -mz_bool tdefl_compress_mem_to_output(const void *pBuf, size_t buf_len, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags) -{ - tdefl_compressor *pComp; - mz_bool succeeded; - if (((buf_len) && (!pBuf)) || (!pPut_buf_func)) - return MZ_FALSE; - pComp = (tdefl_compressor *)MZ_MALLOC(sizeof(tdefl_compressor)); - if (!pComp) - return MZ_FALSE; - succeeded = (tdefl_init(pComp, pPut_buf_func, pPut_buf_user, flags) == TDEFL_STATUS_OKAY); - succeeded = succeeded && (tdefl_compress_buffer(pComp, pBuf, buf_len, TDEFL_FINISH) == TDEFL_STATUS_DONE); - MZ_FREE(pComp); - return succeeded; -} - -typedef struct -{ - size_t m_size, m_capacity; - mz_uint8 *m_pBuf; - mz_bool m_expandable; -} tdefl_output_buffer; - -static mz_bool tdefl_output_buffer_putter(const void *pBuf, int len, void *pUser) -{ - tdefl_output_buffer *p = (tdefl_output_buffer *)pUser; - size_t new_size = p->m_size + len; - if (new_size > p->m_capacity) - { - size_t new_capacity = p->m_capacity; - mz_uint8 *pNew_buf; - if (!p->m_expandable) - return MZ_FALSE; - do - { - new_capacity = MZ_MAX(128U, new_capacity << 1U); - } while (new_size > new_capacity); - pNew_buf = (mz_uint8 *)MZ_REALLOC(p->m_pBuf, new_capacity); - if (!pNew_buf) - return MZ_FALSE; - p->m_pBuf = pNew_buf; - p->m_capacity = new_capacity; - } - memcpy((mz_uint8 *)p->m_pBuf + p->m_size, pBuf, len); - p->m_size = new_size; - return MZ_TRUE; -} - -void *tdefl_compress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags) -{ - tdefl_output_buffer out_buf; - MZ_CLEAR_OBJ(out_buf); - if (!pOut_len) - return MZ_FALSE; - else - *pOut_len = 0; - out_buf.m_expandable = MZ_TRUE; - if (!tdefl_compress_mem_to_output(pSrc_buf, src_buf_len, tdefl_output_buffer_putter, &out_buf, flags)) - return NULL; - *pOut_len = out_buf.m_size; - return out_buf.m_pBuf; -} - -size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags) -{ - tdefl_output_buffer out_buf; - MZ_CLEAR_OBJ(out_buf); - if (!pOut_buf) - return 0; - out_buf.m_pBuf = (mz_uint8 *)pOut_buf; - out_buf.m_capacity = out_buf_len; - if (!tdefl_compress_mem_to_output(pSrc_buf, src_buf_len, tdefl_output_buffer_putter, &out_buf, flags)) - return 0; - return out_buf.m_size; -} - -const mz_uint s_tdefl_num_probes[11] = { 0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500 }; - -/* level may actually range from [0,10] (10 is a "hidden" max level, where we want a bit more compression and it's fine if throughput to fall off a cliff on some files). */ -mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, int strategy) -{ - mz_uint comp_flags = s_tdefl_num_probes[(level >= 0) ? MZ_MIN(10, level) : MZ_DEFAULT_LEVEL] | ((level <= 3) ? TDEFL_GREEDY_PARSING_FLAG : 0); - if (window_bits > 0) - comp_flags |= TDEFL_WRITE_ZLIB_HEADER; - - if (!level) - comp_flags |= TDEFL_FORCE_ALL_RAW_BLOCKS; - else if (strategy == MZ_FILTERED) - comp_flags |= TDEFL_FILTER_MATCHES; - else if (strategy == MZ_HUFFMAN_ONLY) - comp_flags &= ~TDEFL_MAX_PROBES_MASK; - else if (strategy == MZ_FIXED) - comp_flags |= TDEFL_FORCE_ALL_STATIC_BLOCKS; - else if (strategy == MZ_RLE) - comp_flags |= TDEFL_RLE_MATCHES; - - return comp_flags; -} - -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4204) /* nonstandard extension used : non-constant aggregate initializer (also supported by GNU C and C99, so no big deal) */ -#endif - -/* Simple PNG writer function by Alex Evans, 2011. Released into the public domain: https://gist.github.com/908299, more context at - http://altdevblogaday.org/2011/04/06/a-smaller-jpg-encoder/. - This is actually a modification of Alex's original code so PNG files generated by this function pass pngcheck. */ -void *tdefl_write_image_to_png_file_in_memory_ex(const void *pImage, int w, int h, int num_chans, size_t *pLen_out, mz_uint level, mz_bool flip) -{ - /* Using a local copy of this array here in case MINIZ_NO_ZLIB_APIS was defined. */ - static const mz_uint s_tdefl_png_num_probes[11] = { 0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500 }; - tdefl_compressor *pComp = (tdefl_compressor *)MZ_MALLOC(sizeof(tdefl_compressor)); - tdefl_output_buffer out_buf; - int i, bpl = w * num_chans, y, z; - mz_uint32 c; - *pLen_out = 0; - if (!pComp) - return NULL; - MZ_CLEAR_OBJ(out_buf); - out_buf.m_expandable = MZ_TRUE; - out_buf.m_capacity = 57 + MZ_MAX(64, (1 + bpl) * h); - if (NULL == (out_buf.m_pBuf = (mz_uint8 *)MZ_MALLOC(out_buf.m_capacity))) - { - MZ_FREE(pComp); - return NULL; - } - /* write dummy header */ - for (z = 41; z; --z) - tdefl_output_buffer_putter(&z, 1, &out_buf); - /* compress image data */ - tdefl_init(pComp, tdefl_output_buffer_putter, &out_buf, s_tdefl_png_num_probes[MZ_MIN(10, level)] | TDEFL_WRITE_ZLIB_HEADER); - for (y = 0; y < h; ++y) - { - tdefl_compress_buffer(pComp, &z, 1, TDEFL_NO_FLUSH); - tdefl_compress_buffer(pComp, (mz_uint8 *)pImage + (flip ? (h - 1 - y) : y) * bpl, bpl, TDEFL_NO_FLUSH); - } - if (tdefl_compress_buffer(pComp, NULL, 0, TDEFL_FINISH) != TDEFL_STATUS_DONE) - { - MZ_FREE(pComp); - MZ_FREE(out_buf.m_pBuf); - return NULL; - } - /* write real header */ - *pLen_out = out_buf.m_size - 41; - { - static const mz_uint8 chans[] = { 0x00, 0x00, 0x04, 0x02, 0x06 }; - mz_uint8 pnghdr[41] = { 0x89, 0x50, 0x4e, 0x47, 0x0d, - 0x0a, 0x1a, 0x0a, 0x00, 0x00, - 0x00, 0x0d, 0x49, 0x48, 0x44, - 0x52, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x08, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x49, 0x44, 0x41, - 0x54 }; - pnghdr[18] = (mz_uint8)(w >> 8); - pnghdr[19] = (mz_uint8)w; - pnghdr[22] = (mz_uint8)(h >> 8); - pnghdr[23] = (mz_uint8)h; - pnghdr[25] = chans[num_chans]; - pnghdr[33] = (mz_uint8)(*pLen_out >> 24); - pnghdr[34] = (mz_uint8)(*pLen_out >> 16); - pnghdr[35] = (mz_uint8)(*pLen_out >> 8); - pnghdr[36] = (mz_uint8)*pLen_out; - c = (mz_uint32)mz_crc32(MZ_CRC32_INIT, pnghdr + 12, 17); - for (i = 0; i < 4; ++i, c <<= 8) - ((mz_uint8 *)(pnghdr + 29))[i] = (mz_uint8)(c >> 24); - memcpy(out_buf.m_pBuf, pnghdr, 41); - } - /* write footer (IDAT CRC-32, followed by IEND chunk) */ - if (!tdefl_output_buffer_putter("\0\0\0\0\0\0\0\0\x49\x45\x4e\x44\xae\x42\x60\x82", 16, &out_buf)) - { - *pLen_out = 0; - MZ_FREE(pComp); - MZ_FREE(out_buf.m_pBuf); - return NULL; - } - c = (mz_uint32)mz_crc32(MZ_CRC32_INIT, out_buf.m_pBuf + 41 - 4, *pLen_out + 4); - for (i = 0; i < 4; ++i, c <<= 8) - (out_buf.m_pBuf + out_buf.m_size - 16)[i] = (mz_uint8)(c >> 24); - /* compute final size of file, grab compressed data buffer and return */ - *pLen_out += 57; - MZ_FREE(pComp); - return out_buf.m_pBuf; -} -void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int num_chans, size_t *pLen_out) -{ - /* Level 6 corresponds to TDEFL_DEFAULT_MAX_PROBES or MZ_DEFAULT_LEVEL (but we can't depend on MZ_DEFAULT_LEVEL being available in case the zlib API's where #defined out) */ - return tdefl_write_image_to_png_file_in_memory_ex(pImage, w, h, num_chans, pLen_out, 6, MZ_FALSE); -} - -#ifndef MINIZ_NO_MALLOC -/* Allocate the tdefl_compressor and tinfl_decompressor structures in C so that */ -/* non-C language bindings to tdefL_ and tinfl_ API don't need to worry about */ -/* structure size and allocation mechanism. */ -tdefl_compressor *tdefl_compressor_alloc(void) -{ - return (tdefl_compressor *)MZ_MALLOC(sizeof(tdefl_compressor)); -} - -void tdefl_compressor_free(tdefl_compressor *pComp) -{ - MZ_FREE(pComp); -} -#endif - -#ifdef _MSC_VER -#pragma warning(pop) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /*#ifndef MINIZ_NO_DEFLATE_APIS*/ - /************************************************************************** - * - * Copyright 2013-2014 RAD Game Tools and Valve Software - * Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - **************************************************************************/ - - - -#ifndef MINIZ_NO_INFLATE_APIS - -#ifdef __cplusplus -extern "C" { -#endif - -/* ------------------- Low-level Decompression (completely independent from all compression API's) */ - -#define TINFL_MEMCPY(d, s, l) memcpy(d, s, l) -#define TINFL_MEMSET(p, c, l) memset(p, c, l) - -#define TINFL_CR_BEGIN \ - switch (r->m_state) \ - { \ - case 0: -#define TINFL_CR_RETURN(state_index, result) \ - do \ - { \ - status = result; \ - r->m_state = state_index; \ - goto common_exit; \ - case state_index:; \ - } \ - MZ_MACRO_END -#define TINFL_CR_RETURN_FOREVER(state_index, result) \ - do \ - { \ - for (;;) \ - { \ - TINFL_CR_RETURN(state_index, result); \ - } \ - } \ - MZ_MACRO_END -#define TINFL_CR_FINISH } - -#define TINFL_GET_BYTE(state_index, c) \ - do \ - { \ - while (pIn_buf_cur >= pIn_buf_end) \ - { \ - TINFL_CR_RETURN(state_index, (decomp_flags & TINFL_FLAG_HAS_MORE_INPUT) ? TINFL_STATUS_NEEDS_MORE_INPUT : TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS); \ - } \ - c = *pIn_buf_cur++; \ - } \ - MZ_MACRO_END - -#define TINFL_NEED_BITS(state_index, n) \ - do \ - { \ - mz_uint c; \ - TINFL_GET_BYTE(state_index, c); \ - bit_buf |= (((tinfl_bit_buf_t)c) << num_bits); \ - num_bits += 8; \ - } while (num_bits < (mz_uint)(n)) -#define TINFL_SKIP_BITS(state_index, n) \ - do \ - { \ - if (num_bits < (mz_uint)(n)) \ - { \ - TINFL_NEED_BITS(state_index, n); \ - } \ - bit_buf >>= (n); \ - num_bits -= (n); \ - } \ - MZ_MACRO_END -#define TINFL_GET_BITS(state_index, b, n) \ - do \ - { \ - if (num_bits < (mz_uint)(n)) \ - { \ - TINFL_NEED_BITS(state_index, n); \ - } \ - b = bit_buf & ((1 << (n)) - 1); \ - bit_buf >>= (n); \ - num_bits -= (n); \ - } \ - MZ_MACRO_END - -/* TINFL_HUFF_BITBUF_FILL() is only used rarely, when the number of bytes remaining in the input buffer falls below 2. */ -/* It reads just enough bytes from the input stream that are needed to decode the next Huffman code (and absolutely no more). It works by trying to fully decode a */ -/* Huffman code by using whatever bits are currently present in the bit buffer. If this fails, it reads another byte, and tries again until it succeeds or until the */ -/* bit buffer contains >=15 bits (deflate's max. Huffman code size). */ -#define TINFL_HUFF_BITBUF_FILL(state_index, pLookUp, pTree) \ - do \ - { \ - temp = pLookUp[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]; \ - if (temp >= 0) \ - { \ - code_len = temp >> 9; \ - if ((code_len) && (num_bits >= code_len)) \ - break; \ - } \ - else if (num_bits > TINFL_FAST_LOOKUP_BITS) \ - { \ - code_len = TINFL_FAST_LOOKUP_BITS; \ - do \ - { \ - temp = pTree[~temp + ((bit_buf >> code_len++) & 1)]; \ - } while ((temp < 0) && (num_bits >= (code_len + 1))); \ - if (temp >= 0) \ - break; \ - } \ - TINFL_GET_BYTE(state_index, c); \ - bit_buf |= (((tinfl_bit_buf_t)c) << num_bits); \ - num_bits += 8; \ - } while (num_bits < 15); - -/* TINFL_HUFF_DECODE() decodes the next Huffman coded symbol. It's more complex than you would initially expect because the zlib API expects the decompressor to never read */ -/* beyond the final byte of the deflate stream. (In other words, when this macro wants to read another byte from the input, it REALLY needs another byte in order to fully */ -/* decode the next Huffman code.) Handling this properly is particularly important on raw deflate (non-zlib) streams, which aren't followed by a byte aligned adler-32. */ -/* The slow path is only executed at the very end of the input buffer. */ -/* v1.16: The original macro handled the case at the very end of the passed-in input buffer, but we also need to handle the case where the user passes in 1+zillion bytes */ -/* following the deflate data and our non-conservative read-ahead path won't kick in here on this code. This is much trickier. */ -#define TINFL_HUFF_DECODE(state_index, sym, pLookUp, pTree) \ - do \ - { \ - int temp; \ - mz_uint code_len, c; \ - if (num_bits < 15) \ - { \ - if ((pIn_buf_end - pIn_buf_cur) < 2) \ - { \ - TINFL_HUFF_BITBUF_FILL(state_index, pLookUp, pTree); \ - } \ - else \ - { \ - bit_buf |= (((tinfl_bit_buf_t)pIn_buf_cur[0]) << num_bits) | (((tinfl_bit_buf_t)pIn_buf_cur[1]) << (num_bits + 8)); \ - pIn_buf_cur += 2; \ - num_bits += 16; \ - } \ - } \ - if ((temp = pLookUp[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= 0) \ - code_len = temp >> 9, temp &= 511; \ - else \ - { \ - code_len = TINFL_FAST_LOOKUP_BITS; \ - do \ - { \ - temp = pTree[~temp + ((bit_buf >> code_len++) & 1)]; \ - } while (temp < 0); \ - } \ - sym = temp; \ - bit_buf >>= code_len; \ - num_bits -= code_len; \ - } \ - MZ_MACRO_END - -static void tinfl_clear_tree(tinfl_decompressor *r) -{ - if (r->m_type == 0) - MZ_CLEAR_ARR(r->m_tree_0); - else if (r->m_type == 1) - MZ_CLEAR_ARR(r->m_tree_1); - else - MZ_CLEAR_ARR(r->m_tree_2); -} - -tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_next, size_t *pIn_buf_size, mz_uint8 *pOut_buf_start, mz_uint8 *pOut_buf_next, size_t *pOut_buf_size, const mz_uint32 decomp_flags) -{ - static const mz_uint16 s_length_base[31] = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0 }; - static const mz_uint8 s_length_extra[31] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 0, 0 }; - static const mz_uint16 s_dist_base[32] = { 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 0, 0 }; - static const mz_uint8 s_dist_extra[32] = { 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13 }; - static const mz_uint8 s_length_dezigzag[19] = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 }; - static const mz_uint16 s_min_table_sizes[3] = { 257, 1, 4 }; - - mz_int16 *pTrees[3]; - mz_uint8 *pCode_sizes[3]; - - tinfl_status status = TINFL_STATUS_FAILED; - mz_uint32 num_bits, dist, counter, num_extra; - tinfl_bit_buf_t bit_buf; - const mz_uint8 *pIn_buf_cur = pIn_buf_next, *const pIn_buf_end = pIn_buf_next + *pIn_buf_size; - mz_uint8 *pOut_buf_cur = pOut_buf_next, *const pOut_buf_end = pOut_buf_next ? pOut_buf_next + *pOut_buf_size : NULL; - size_t out_buf_size_mask = (decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF) ? (size_t)-1 : ((pOut_buf_next - pOut_buf_start) + *pOut_buf_size) - 1, dist_from_out_buf_start; - - /* Ensure the output buffer's size is a power of 2, unless the output buffer is large enough to hold the entire output file (in which case it doesn't matter). */ - if (((out_buf_size_mask + 1) & out_buf_size_mask) || (pOut_buf_next < pOut_buf_start)) - { - *pIn_buf_size = *pOut_buf_size = 0; - return TINFL_STATUS_BAD_PARAM; - } - - pTrees[0] = r->m_tree_0; - pTrees[1] = r->m_tree_1; - pTrees[2] = r->m_tree_2; - pCode_sizes[0] = r->m_code_size_0; - pCode_sizes[1] = r->m_code_size_1; - pCode_sizes[2] = r->m_code_size_2; - - num_bits = r->m_num_bits; - bit_buf = r->m_bit_buf; - dist = r->m_dist; - counter = r->m_counter; - num_extra = r->m_num_extra; - dist_from_out_buf_start = r->m_dist_from_out_buf_start; - TINFL_CR_BEGIN - - bit_buf = num_bits = dist = counter = num_extra = r->m_zhdr0 = r->m_zhdr1 = 0; - r->m_z_adler32 = r->m_check_adler32 = 1; - if (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER) - { - TINFL_GET_BYTE(1, r->m_zhdr0); - TINFL_GET_BYTE(2, r->m_zhdr1); - counter = (((r->m_zhdr0 * 256 + r->m_zhdr1) % 31 != 0) || (r->m_zhdr1 & 32) || ((r->m_zhdr0 & 15) != 8)); - if (!(decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF)) - counter |= (((1U << (8U + (r->m_zhdr0 >> 4))) > 32768U) || ((out_buf_size_mask + 1) < (size_t)((size_t)1 << (8U + (r->m_zhdr0 >> 4))))); - if (counter) - { - TINFL_CR_RETURN_FOREVER(36, TINFL_STATUS_FAILED); - } - } - - do - { - TINFL_GET_BITS(3, r->m_final, 3); - r->m_type = r->m_final >> 1; - if (r->m_type == 0) - { - TINFL_SKIP_BITS(5, num_bits & 7); - for (counter = 0; counter < 4; ++counter) - { - if (num_bits) - TINFL_GET_BITS(6, r->m_raw_header[counter], 8); - else - TINFL_GET_BYTE(7, r->m_raw_header[counter]); - } - if ((counter = (r->m_raw_header[0] | (r->m_raw_header[1] << 8))) != (mz_uint)(0xFFFF ^ (r->m_raw_header[2] | (r->m_raw_header[3] << 8)))) - { - TINFL_CR_RETURN_FOREVER(39, TINFL_STATUS_FAILED); - } - while ((counter) && (num_bits)) - { - TINFL_GET_BITS(51, dist, 8); - while (pOut_buf_cur >= pOut_buf_end) - { - TINFL_CR_RETURN(52, TINFL_STATUS_HAS_MORE_OUTPUT); - } - *pOut_buf_cur++ = (mz_uint8)dist; - counter--; - } - while (counter) - { - size_t n; - while (pOut_buf_cur >= pOut_buf_end) - { - TINFL_CR_RETURN(9, TINFL_STATUS_HAS_MORE_OUTPUT); - } - while (pIn_buf_cur >= pIn_buf_end) - { - TINFL_CR_RETURN(38, (decomp_flags & TINFL_FLAG_HAS_MORE_INPUT) ? TINFL_STATUS_NEEDS_MORE_INPUT : TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS); - } - n = MZ_MIN(MZ_MIN((size_t)(pOut_buf_end - pOut_buf_cur), (size_t)(pIn_buf_end - pIn_buf_cur)), counter); - TINFL_MEMCPY(pOut_buf_cur, pIn_buf_cur, n); - pIn_buf_cur += n; - pOut_buf_cur += n; - counter -= (mz_uint)n; - } - } - else if (r->m_type == 3) - { - TINFL_CR_RETURN_FOREVER(10, TINFL_STATUS_FAILED); - } - else - { - if (r->m_type == 1) - { - mz_uint8 *p = r->m_code_size_0; - mz_uint i; - r->m_table_sizes[0] = 288; - r->m_table_sizes[1] = 32; - TINFL_MEMSET(r->m_code_size_1, 5, 32); - for (i = 0; i <= 143; ++i) - *p++ = 8; - for (; i <= 255; ++i) - *p++ = 9; - for (; i <= 279; ++i) - *p++ = 7; - for (; i <= 287; ++i) - *p++ = 8; - } - else - { - for (counter = 0; counter < 3; counter++) - { - TINFL_GET_BITS(11, r->m_table_sizes[counter], "\05\05\04"[counter]); - r->m_table_sizes[counter] += s_min_table_sizes[counter]; - } - MZ_CLEAR_ARR(r->m_code_size_2); - for (counter = 0; counter < r->m_table_sizes[2]; counter++) - { - mz_uint s; - TINFL_GET_BITS(14, s, 3); - r->m_code_size_2[s_length_dezigzag[counter]] = (mz_uint8)s; - } - r->m_table_sizes[2] = 19; - } - for (; (int)r->m_type >= 0; r->m_type--) - { - int tree_next, tree_cur; - mz_int16 *pLookUp; - mz_int16 *pTree; - mz_uint8 *pCode_size; - mz_uint i, j, used_syms, total, sym_index, next_code[17], total_syms[16]; - pLookUp = r->m_look_up[r->m_type]; - pTree = pTrees[r->m_type]; - pCode_size = pCode_sizes[r->m_type]; - MZ_CLEAR_ARR(total_syms); - TINFL_MEMSET(pLookUp, 0, sizeof(r->m_look_up[0])); - tinfl_clear_tree(r); - for (i = 0; i < r->m_table_sizes[r->m_type]; ++i) - total_syms[pCode_size[i]]++; - used_syms = 0, total = 0; - next_code[0] = next_code[1] = 0; - for (i = 1; i <= 15; ++i) - { - used_syms += total_syms[i]; - next_code[i + 1] = (total = ((total + total_syms[i]) << 1)); - } - if ((65536 != total) && (used_syms > 1)) - { - TINFL_CR_RETURN_FOREVER(35, TINFL_STATUS_FAILED); - } - for (tree_next = -1, sym_index = 0; sym_index < r->m_table_sizes[r->m_type]; ++sym_index) - { - mz_uint rev_code = 0, l, cur_code, code_size = pCode_size[sym_index]; - if (!code_size) - continue; - cur_code = next_code[code_size]++; - for (l = code_size; l > 0; l--, cur_code >>= 1) - rev_code = (rev_code << 1) | (cur_code & 1); - if (code_size <= TINFL_FAST_LOOKUP_BITS) - { - mz_int16 k = (mz_int16)((code_size << 9) | sym_index); - while (rev_code < TINFL_FAST_LOOKUP_SIZE) - { - pLookUp[rev_code] = k; - rev_code += (1 << code_size); - } - continue; - } - if (0 == (tree_cur = pLookUp[rev_code & (TINFL_FAST_LOOKUP_SIZE - 1)])) - { - pLookUp[rev_code & (TINFL_FAST_LOOKUP_SIZE - 1)] = (mz_int16)tree_next; - tree_cur = tree_next; - tree_next -= 2; - } - rev_code >>= (TINFL_FAST_LOOKUP_BITS - 1); - for (j = code_size; j > (TINFL_FAST_LOOKUP_BITS + 1); j--) - { - tree_cur -= ((rev_code >>= 1) & 1); - if (!pTree[-tree_cur - 1]) - { - pTree[-tree_cur - 1] = (mz_int16)tree_next; - tree_cur = tree_next; - tree_next -= 2; - } - else - tree_cur = pTree[-tree_cur - 1]; - } - tree_cur -= ((rev_code >>= 1) & 1); - pTree[-tree_cur - 1] = (mz_int16)sym_index; - } - if (r->m_type == 2) - { - for (counter = 0; counter < (r->m_table_sizes[0] + r->m_table_sizes[1]);) - { - mz_uint s; - TINFL_HUFF_DECODE(16, dist, r->m_look_up[2], r->m_tree_2); - if (dist < 16) - { - r->m_len_codes[counter++] = (mz_uint8)dist; - continue; - } - if ((dist == 16) && (!counter)) - { - TINFL_CR_RETURN_FOREVER(17, TINFL_STATUS_FAILED); - } - num_extra = "\02\03\07"[dist - 16]; - TINFL_GET_BITS(18, s, num_extra); - s += "\03\03\013"[dist - 16]; - TINFL_MEMSET(r->m_len_codes + counter, (dist == 16) ? r->m_len_codes[counter - 1] : 0, s); - counter += s; - } - if ((r->m_table_sizes[0] + r->m_table_sizes[1]) != counter) - { - TINFL_CR_RETURN_FOREVER(21, TINFL_STATUS_FAILED); - } - TINFL_MEMCPY(r->m_code_size_0, r->m_len_codes, r->m_table_sizes[0]); - TINFL_MEMCPY(r->m_code_size_1, r->m_len_codes + r->m_table_sizes[0], r->m_table_sizes[1]); - } - } - for (;;) - { - mz_uint8 *pSrc; - for (;;) - { - if (((pIn_buf_end - pIn_buf_cur) < 4) || ((pOut_buf_end - pOut_buf_cur) < 2)) - { - TINFL_HUFF_DECODE(23, counter, r->m_look_up[0], r->m_tree_0); - if (counter >= 256) - break; - while (pOut_buf_cur >= pOut_buf_end) - { - TINFL_CR_RETURN(24, TINFL_STATUS_HAS_MORE_OUTPUT); - } - *pOut_buf_cur++ = (mz_uint8)counter; - } - else - { - int sym2; - mz_uint code_len; -#if TINFL_USE_64BIT_BITBUF - if (num_bits < 30) - { - bit_buf |= (((tinfl_bit_buf_t)MZ_READ_LE32(pIn_buf_cur)) << num_bits); - pIn_buf_cur += 4; - num_bits += 32; - } -#else - if (num_bits < 15) - { - bit_buf |= (((tinfl_bit_buf_t)MZ_READ_LE16(pIn_buf_cur)) << num_bits); - pIn_buf_cur += 2; - num_bits += 16; - } -#endif - if ((sym2 = r->m_look_up[0][bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= 0) - code_len = sym2 >> 9; - else - { - code_len = TINFL_FAST_LOOKUP_BITS; - do - { - sym2 = r->m_tree_0[~sym2 + ((bit_buf >> code_len++) & 1)]; - } while (sym2 < 0); - } - counter = sym2; - bit_buf >>= code_len; - num_bits -= code_len; - if (counter & 256) - break; - -#if !TINFL_USE_64BIT_BITBUF - if (num_bits < 15) - { - bit_buf |= (((tinfl_bit_buf_t)MZ_READ_LE16(pIn_buf_cur)) << num_bits); - pIn_buf_cur += 2; - num_bits += 16; - } -#endif - if ((sym2 = r->m_look_up[0][bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= 0) - code_len = sym2 >> 9; - else - { - code_len = TINFL_FAST_LOOKUP_BITS; - do - { - sym2 = r->m_tree_0[~sym2 + ((bit_buf >> code_len++) & 1)]; - } while (sym2 < 0); - } - bit_buf >>= code_len; - num_bits -= code_len; - - pOut_buf_cur[0] = (mz_uint8)counter; - if (sym2 & 256) - { - pOut_buf_cur++; - counter = sym2; - break; - } - pOut_buf_cur[1] = (mz_uint8)sym2; - pOut_buf_cur += 2; - } - } - if ((counter &= 511) == 256) - break; - - num_extra = s_length_extra[counter - 257]; - counter = s_length_base[counter - 257]; - if (num_extra) - { - mz_uint extra_bits; - TINFL_GET_BITS(25, extra_bits, num_extra); - counter += extra_bits; - } - - TINFL_HUFF_DECODE(26, dist, r->m_look_up[1], r->m_tree_1); - num_extra = s_dist_extra[dist]; - dist = s_dist_base[dist]; - if (num_extra) - { - mz_uint extra_bits; - TINFL_GET_BITS(27, extra_bits, num_extra); - dist += extra_bits; - } - - dist_from_out_buf_start = pOut_buf_cur - pOut_buf_start; - if ((dist == 0 || dist > dist_from_out_buf_start || dist_from_out_buf_start == 0) && (decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF)) - { - TINFL_CR_RETURN_FOREVER(37, TINFL_STATUS_FAILED); - } - - pSrc = pOut_buf_start + ((dist_from_out_buf_start - dist) & out_buf_size_mask); - - if ((MZ_MAX(pOut_buf_cur, pSrc) + counter) > pOut_buf_end) - { - while (counter--) - { - while (pOut_buf_cur >= pOut_buf_end) - { - TINFL_CR_RETURN(53, TINFL_STATUS_HAS_MORE_OUTPUT); - } - *pOut_buf_cur++ = pOut_buf_start[(dist_from_out_buf_start++ - dist) & out_buf_size_mask]; - } - continue; - } -#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES - else if ((counter >= 9) && (counter <= dist)) - { - const mz_uint8 *pSrc_end = pSrc + (counter & ~7); - do - { -#ifdef MINIZ_UNALIGNED_USE_MEMCPY - memcpy(pOut_buf_cur, pSrc, sizeof(mz_uint32)*2); -#else - ((mz_uint32 *)pOut_buf_cur)[0] = ((const mz_uint32 *)pSrc)[0]; - ((mz_uint32 *)pOut_buf_cur)[1] = ((const mz_uint32 *)pSrc)[1]; -#endif - pOut_buf_cur += 8; - } while ((pSrc += 8) < pSrc_end); - if ((counter &= 7) < 3) - { - if (counter) - { - pOut_buf_cur[0] = pSrc[0]; - if (counter > 1) - pOut_buf_cur[1] = pSrc[1]; - pOut_buf_cur += counter; - } - continue; - } - } -#endif - while(counter>2) - { - pOut_buf_cur[0] = pSrc[0]; - pOut_buf_cur[1] = pSrc[1]; - pOut_buf_cur[2] = pSrc[2]; - pOut_buf_cur += 3; - pSrc += 3; - counter -= 3; - } - if (counter > 0) - { - pOut_buf_cur[0] = pSrc[0]; - if (counter > 1) - pOut_buf_cur[1] = pSrc[1]; - pOut_buf_cur += counter; - } - } - } - } while (!(r->m_final & 1)); - - /* Ensure byte alignment and put back any bytes from the bitbuf if we've looked ahead too far on gzip, or other Deflate streams followed by arbitrary data. */ - /* I'm being super conservative here. A number of simplifications can be made to the byte alignment part, and the Adler32 check shouldn't ever need to worry about reading from the bitbuf now. */ - TINFL_SKIP_BITS(32, num_bits & 7); - while ((pIn_buf_cur > pIn_buf_next) && (num_bits >= 8)) - { - --pIn_buf_cur; - num_bits -= 8; - } - bit_buf &= ~(~(tinfl_bit_buf_t)0 << num_bits); - MZ_ASSERT(!num_bits); /* if this assert fires then we've read beyond the end of non-deflate/zlib streams with following data (such as gzip streams). */ - - if (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER) - { - for (counter = 0; counter < 4; ++counter) - { - mz_uint s; - if (num_bits) - TINFL_GET_BITS(41, s, 8); - else - TINFL_GET_BYTE(42, s); - r->m_z_adler32 = (r->m_z_adler32 << 8) | s; - } - } - TINFL_CR_RETURN_FOREVER(34, TINFL_STATUS_DONE); - - TINFL_CR_FINISH - -common_exit: - /* As long as we aren't telling the caller that we NEED more input to make forward progress: */ - /* Put back any bytes from the bitbuf in case we've looked ahead too far on gzip, or other Deflate streams followed by arbitrary data. */ - /* We need to be very careful here to NOT push back any bytes we definitely know we need to make forward progress, though, or we'll lock the caller up into an inf loop. */ - if ((status != TINFL_STATUS_NEEDS_MORE_INPUT) && (status != TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS)) - { - while ((pIn_buf_cur > pIn_buf_next) && (num_bits >= 8)) - { - --pIn_buf_cur; - num_bits -= 8; - } - } - r->m_num_bits = num_bits; - r->m_bit_buf = bit_buf & ~(~(tinfl_bit_buf_t)0 << num_bits); - r->m_dist = dist; - r->m_counter = counter; - r->m_num_extra = num_extra; - r->m_dist_from_out_buf_start = dist_from_out_buf_start; - *pIn_buf_size = pIn_buf_cur - pIn_buf_next; - *pOut_buf_size = pOut_buf_cur - pOut_buf_next; - if ((decomp_flags & (TINFL_FLAG_PARSE_ZLIB_HEADER | TINFL_FLAG_COMPUTE_ADLER32)) && (status >= 0)) - { - const mz_uint8 *ptr = pOut_buf_next; - size_t buf_len = *pOut_buf_size; - mz_uint32 i, s1 = r->m_check_adler32 & 0xffff, s2 = r->m_check_adler32 >> 16; - size_t block_len = buf_len % 5552; - while (buf_len) - { - for (i = 0; i + 7 < block_len; i += 8, ptr += 8) - { - s1 += ptr[0], s2 += s1; - s1 += ptr[1], s2 += s1; - s1 += ptr[2], s2 += s1; - s1 += ptr[3], s2 += s1; - s1 += ptr[4], s2 += s1; - s1 += ptr[5], s2 += s1; - s1 += ptr[6], s2 += s1; - s1 += ptr[7], s2 += s1; - } - for (; i < block_len; ++i) - s1 += *ptr++, s2 += s1; - s1 %= 65521U, s2 %= 65521U; - buf_len -= block_len; - block_len = 5552; - } - r->m_check_adler32 = (s2 << 16) + s1; - if ((status == TINFL_STATUS_DONE) && (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER) && (r->m_check_adler32 != r->m_z_adler32)) - status = TINFL_STATUS_ADLER32_MISMATCH; - } - return status; -} - -/* Higher level helper functions. */ -void *tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags) -{ - tinfl_decompressor decomp; - void *pBuf = NULL, *pNew_buf; - size_t src_buf_ofs = 0, out_buf_capacity = 0; - *pOut_len = 0; - tinfl_init(&decomp); - for (;;) - { - size_t src_buf_size = src_buf_len - src_buf_ofs, dst_buf_size = out_buf_capacity - *pOut_len, new_out_buf_capacity; - tinfl_status status = tinfl_decompress(&decomp, (const mz_uint8 *)pSrc_buf + src_buf_ofs, &src_buf_size, (mz_uint8 *)pBuf, pBuf ? (mz_uint8 *)pBuf + *pOut_len : NULL, &dst_buf_size, - (flags & ~TINFL_FLAG_HAS_MORE_INPUT) | TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF); - if ((status < 0) || (status == TINFL_STATUS_NEEDS_MORE_INPUT)) - { - MZ_FREE(pBuf); - *pOut_len = 0; - return NULL; - } - src_buf_ofs += src_buf_size; - *pOut_len += dst_buf_size; - if (status == TINFL_STATUS_DONE) - break; - new_out_buf_capacity = out_buf_capacity * 2; - if (new_out_buf_capacity < 128) - new_out_buf_capacity = 128; - pNew_buf = MZ_REALLOC(pBuf, new_out_buf_capacity); - if (!pNew_buf) - { - MZ_FREE(pBuf); - *pOut_len = 0; - return NULL; - } - pBuf = pNew_buf; - out_buf_capacity = new_out_buf_capacity; - } - return pBuf; -} - -size_t tinfl_decompress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags) -{ - tinfl_decompressor decomp; - tinfl_status status; - tinfl_init(&decomp); - status = tinfl_decompress(&decomp, (const mz_uint8 *)pSrc_buf, &src_buf_len, (mz_uint8 *)pOut_buf, (mz_uint8 *)pOut_buf, &out_buf_len, (flags & ~TINFL_FLAG_HAS_MORE_INPUT) | TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF); - return (status != TINFL_STATUS_DONE) ? TINFL_DECOMPRESS_MEM_TO_MEM_FAILED : out_buf_len; -} - -int tinfl_decompress_mem_to_callback(const void *pIn_buf, size_t *pIn_buf_size, tinfl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags) -{ - int result = 0; - tinfl_decompressor decomp; - mz_uint8 *pDict = (mz_uint8 *)MZ_MALLOC(TINFL_LZ_DICT_SIZE); - size_t in_buf_ofs = 0, dict_ofs = 0; - if (!pDict) - return TINFL_STATUS_FAILED; - memset(pDict,0,TINFL_LZ_DICT_SIZE); - tinfl_init(&decomp); - for (;;) - { - size_t in_buf_size = *pIn_buf_size - in_buf_ofs, dst_buf_size = TINFL_LZ_DICT_SIZE - dict_ofs; - tinfl_status status = tinfl_decompress(&decomp, (const mz_uint8 *)pIn_buf + in_buf_ofs, &in_buf_size, pDict, pDict + dict_ofs, &dst_buf_size, - (flags & ~(TINFL_FLAG_HAS_MORE_INPUT | TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF))); - in_buf_ofs += in_buf_size; - if ((dst_buf_size) && (!(*pPut_buf_func)(pDict + dict_ofs, (int)dst_buf_size, pPut_buf_user))) - break; - if (status != TINFL_STATUS_HAS_MORE_OUTPUT) - { - result = (status == TINFL_STATUS_DONE); - break; - } - dict_ofs = (dict_ofs + dst_buf_size) & (TINFL_LZ_DICT_SIZE - 1); - } - MZ_FREE(pDict); - *pIn_buf_size = in_buf_ofs; - return result; -} - -#ifndef MINIZ_NO_MALLOC -tinfl_decompressor *tinfl_decompressor_alloc(void) -{ - tinfl_decompressor *pDecomp = (tinfl_decompressor *)MZ_MALLOC(sizeof(tinfl_decompressor)); - if (pDecomp) - tinfl_init(pDecomp); - return pDecomp; -} - -void tinfl_decompressor_free(tinfl_decompressor *pDecomp) -{ - MZ_FREE(pDecomp); -} -#endif - -#ifdef __cplusplus -} -#endif - -#endif /*#ifndef MINIZ_NO_INFLATE_APIS*/ - /************************************************************************** - * - * Copyright 2013-2014 RAD Game Tools and Valve Software - * Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC - * Copyright 2016 Martin Raiber - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - **************************************************************************/ - - -#ifndef MINIZ_NO_ARCHIVE_APIS - -#ifdef __cplusplus -extern "C" { -#endif - -/* ------------------- .ZIP archive reading */ - -#ifdef MINIZ_NO_STDIO -#define MZ_FILE void * -#else -#include - -#if defined(_MSC_VER) || defined(__MINGW64__) - -#define WIN32_LEAN_AND_MEAN -#include - -static WCHAR* mz_utf8z_to_widechar(const char* str) -{ - int reqChars = MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0); - WCHAR* wStr = (WCHAR*)malloc(reqChars * sizeof(WCHAR)); - MultiByteToWideChar(CP_UTF8, 0, str, -1, wStr, reqChars); - return wStr; -} - -static FILE *mz_fopen(const char *pFilename, const char *pMode) -{ - WCHAR* wFilename = mz_utf8z_to_widechar(pFilename); - WCHAR* wMode = mz_utf8z_to_widechar(pMode); - FILE* pFile = NULL; - errno_t err = _wfopen_s(&pFile, wFilename, wMode); - free(wFilename); - free(wMode); - return err ? NULL : pFile; -} - -static FILE *mz_freopen(const char *pPath, const char *pMode, FILE *pStream) -{ - WCHAR* wPath = mz_utf8z_to_widechar(pPath); - WCHAR* wMode = mz_utf8z_to_widechar(pMode); - FILE* pFile = NULL; - errno_t err = _wfreopen_s(&pFile, wPath, wMode, pStream); - free(wPath); - free(wMode); - return err ? NULL : pFile; -} - -static int mz_stat64(const char *path, struct __stat64 *buffer) -{ - WCHAR* wPath = mz_utf8z_to_widechar(path); - int res = _wstat64(wPath, buffer); - free(wPath); - return res; -} - -#ifndef MINIZ_NO_TIME -#include -#endif -#define MZ_FOPEN mz_fopen -#define MZ_FCLOSE fclose -#define MZ_FREAD fread -#define MZ_FWRITE fwrite -#define MZ_FTELL64 _ftelli64 -#define MZ_FSEEK64 _fseeki64 -#define MZ_FILE_STAT_STRUCT _stat64 -#define MZ_FILE_STAT mz_stat64 -#define MZ_FFLUSH fflush -#define MZ_FREOPEN mz_freopen -#define MZ_DELETE_FILE remove - -#elif defined(__MINGW32__) || defined(__WATCOMC__) -#ifndef MINIZ_NO_TIME -#include -#endif -#define MZ_FOPEN(f, m) fopen(f, m) -#define MZ_FCLOSE fclose -#define MZ_FREAD fread -#define MZ_FWRITE fwrite -#define MZ_FTELL64 _ftelli64 -#define MZ_FSEEK64 _fseeki64 -#define MZ_FILE_STAT_STRUCT stat -#define MZ_FILE_STAT stat -#define MZ_FFLUSH fflush -#define MZ_FREOPEN(f, m, s) freopen(f, m, s) -#define MZ_DELETE_FILE remove - -#elif defined(__TINYC__) -#ifndef MINIZ_NO_TIME -#include -#endif -#define MZ_FOPEN(f, m) fopen(f, m) -#define MZ_FCLOSE fclose -#define MZ_FREAD fread -#define MZ_FWRITE fwrite -#define MZ_FTELL64 ftell -#define MZ_FSEEK64 fseek -#define MZ_FILE_STAT_STRUCT stat -#define MZ_FILE_STAT stat -#define MZ_FFLUSH fflush -#define MZ_FREOPEN(f, m, s) freopen(f, m, s) -#define MZ_DELETE_FILE remove - -#elif defined(__USE_LARGEFILE64) /* gcc, clang */ -#ifndef MINIZ_NO_TIME -#include -#endif -#define MZ_FOPEN(f, m) fopen64(f, m) -#define MZ_FCLOSE fclose -#define MZ_FREAD fread -#define MZ_FWRITE fwrite -#define MZ_FTELL64 ftello64 -#define MZ_FSEEK64 fseeko64 -#define MZ_FILE_STAT_STRUCT stat64 -#define MZ_FILE_STAT stat64 -#define MZ_FFLUSH fflush -#define MZ_FREOPEN(p, m, s) freopen64(p, m, s) -#define MZ_DELETE_FILE remove - -#elif defined(__APPLE__) || defined(__FreeBSD__) -#ifndef MINIZ_NO_TIME -#include -#endif -#define MZ_FOPEN(f, m) fopen(f, m) -#define MZ_FCLOSE fclose -#define MZ_FREAD fread -#define MZ_FWRITE fwrite -#define MZ_FTELL64 ftello -#define MZ_FSEEK64 fseeko -#define MZ_FILE_STAT_STRUCT stat -#define MZ_FILE_STAT stat -#define MZ_FFLUSH fflush -#define MZ_FREOPEN(p, m, s) freopen(p, m, s) -#define MZ_DELETE_FILE remove - -#else -#pragma message("Using fopen, ftello, fseeko, stat() etc. path for file I/O - this path may not support large files.") -#ifndef MINIZ_NO_TIME -#include -#endif -#define MZ_FOPEN(f, m) fopen(f, m) -#define MZ_FCLOSE fclose -#define MZ_FREAD fread -#define MZ_FWRITE fwrite -#ifdef __STRICT_ANSI__ -#define MZ_FTELL64 ftell -#define MZ_FSEEK64 fseek -#else -#define MZ_FTELL64 ftello -#define MZ_FSEEK64 fseeko -#endif -#define MZ_FILE_STAT_STRUCT stat -#define MZ_FILE_STAT stat -#define MZ_FFLUSH fflush -#define MZ_FREOPEN(f, m, s) freopen(f, m, s) -#define MZ_DELETE_FILE remove -#endif /* #ifdef _MSC_VER */ -#endif /* #ifdef MINIZ_NO_STDIO */ - -#define MZ_TOLOWER(c) ((((c) >= 'A') && ((c) <= 'Z')) ? ((c) - 'A' + 'a') : (c)) - -/* Various ZIP archive enums. To completely avoid cross platform compiler alignment and platform endian issues, miniz.c doesn't use structs for any of this stuff. */ -enum -{ - /* ZIP archive identifiers and record sizes */ - MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG = 0x06054b50, - MZ_ZIP_CENTRAL_DIR_HEADER_SIG = 0x02014b50, - MZ_ZIP_LOCAL_DIR_HEADER_SIG = 0x04034b50, - MZ_ZIP_LOCAL_DIR_HEADER_SIZE = 30, - MZ_ZIP_CENTRAL_DIR_HEADER_SIZE = 46, - MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE = 22, - - /* ZIP64 archive identifier and record sizes */ - MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIG = 0x06064b50, - MZ_ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIG = 0x07064b50, - MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIZE = 56, - MZ_ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIZE = 20, - MZ_ZIP64_EXTENDED_INFORMATION_FIELD_HEADER_ID = 0x0001, - MZ_ZIP_DATA_DESCRIPTOR_ID = 0x08074b50, - MZ_ZIP_DATA_DESCRIPTER_SIZE64 = 24, - MZ_ZIP_DATA_DESCRIPTER_SIZE32 = 16, - - /* Central directory header record offsets */ - MZ_ZIP_CDH_SIG_OFS = 0, - MZ_ZIP_CDH_VERSION_MADE_BY_OFS = 4, - MZ_ZIP_CDH_VERSION_NEEDED_OFS = 6, - MZ_ZIP_CDH_BIT_FLAG_OFS = 8, - MZ_ZIP_CDH_METHOD_OFS = 10, - MZ_ZIP_CDH_FILE_TIME_OFS = 12, - MZ_ZIP_CDH_FILE_DATE_OFS = 14, - MZ_ZIP_CDH_CRC32_OFS = 16, - MZ_ZIP_CDH_COMPRESSED_SIZE_OFS = 20, - MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS = 24, - MZ_ZIP_CDH_FILENAME_LEN_OFS = 28, - MZ_ZIP_CDH_EXTRA_LEN_OFS = 30, - MZ_ZIP_CDH_COMMENT_LEN_OFS = 32, - MZ_ZIP_CDH_DISK_START_OFS = 34, - MZ_ZIP_CDH_INTERNAL_ATTR_OFS = 36, - MZ_ZIP_CDH_EXTERNAL_ATTR_OFS = 38, - MZ_ZIP_CDH_LOCAL_HEADER_OFS = 42, - - /* Local directory header offsets */ - MZ_ZIP_LDH_SIG_OFS = 0, - MZ_ZIP_LDH_VERSION_NEEDED_OFS = 4, - MZ_ZIP_LDH_BIT_FLAG_OFS = 6, - MZ_ZIP_LDH_METHOD_OFS = 8, - MZ_ZIP_LDH_FILE_TIME_OFS = 10, - MZ_ZIP_LDH_FILE_DATE_OFS = 12, - MZ_ZIP_LDH_CRC32_OFS = 14, - MZ_ZIP_LDH_COMPRESSED_SIZE_OFS = 18, - MZ_ZIP_LDH_DECOMPRESSED_SIZE_OFS = 22, - MZ_ZIP_LDH_FILENAME_LEN_OFS = 26, - MZ_ZIP_LDH_EXTRA_LEN_OFS = 28, - MZ_ZIP_LDH_BIT_FLAG_HAS_LOCATOR = 1 << 3, - - /* End of central directory offsets */ - MZ_ZIP_ECDH_SIG_OFS = 0, - MZ_ZIP_ECDH_NUM_THIS_DISK_OFS = 4, - MZ_ZIP_ECDH_NUM_DISK_CDIR_OFS = 6, - MZ_ZIP_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS = 8, - MZ_ZIP_ECDH_CDIR_TOTAL_ENTRIES_OFS = 10, - MZ_ZIP_ECDH_CDIR_SIZE_OFS = 12, - MZ_ZIP_ECDH_CDIR_OFS_OFS = 16, - MZ_ZIP_ECDH_COMMENT_SIZE_OFS = 20, - - /* ZIP64 End of central directory locator offsets */ - MZ_ZIP64_ECDL_SIG_OFS = 0, /* 4 bytes */ - MZ_ZIP64_ECDL_NUM_DISK_CDIR_OFS = 4, /* 4 bytes */ - MZ_ZIP64_ECDL_REL_OFS_TO_ZIP64_ECDR_OFS = 8, /* 8 bytes */ - MZ_ZIP64_ECDL_TOTAL_NUMBER_OF_DISKS_OFS = 16, /* 4 bytes */ - - /* ZIP64 End of central directory header offsets */ - MZ_ZIP64_ECDH_SIG_OFS = 0, /* 4 bytes */ - MZ_ZIP64_ECDH_SIZE_OF_RECORD_OFS = 4, /* 8 bytes */ - MZ_ZIP64_ECDH_VERSION_MADE_BY_OFS = 12, /* 2 bytes */ - MZ_ZIP64_ECDH_VERSION_NEEDED_OFS = 14, /* 2 bytes */ - MZ_ZIP64_ECDH_NUM_THIS_DISK_OFS = 16, /* 4 bytes */ - MZ_ZIP64_ECDH_NUM_DISK_CDIR_OFS = 20, /* 4 bytes */ - MZ_ZIP64_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS = 24, /* 8 bytes */ - MZ_ZIP64_ECDH_CDIR_TOTAL_ENTRIES_OFS = 32, /* 8 bytes */ - MZ_ZIP64_ECDH_CDIR_SIZE_OFS = 40, /* 8 bytes */ - MZ_ZIP64_ECDH_CDIR_OFS_OFS = 48, /* 8 bytes */ - MZ_ZIP_VERSION_MADE_BY_DOS_FILESYSTEM_ID = 0, - MZ_ZIP_DOS_DIR_ATTRIBUTE_BITFLAG = 0x10, - MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_IS_ENCRYPTED = 1, - MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_COMPRESSED_PATCH_FLAG = 32, - MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_USES_STRONG_ENCRYPTION = 64, - MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_LOCAL_DIR_IS_MASKED = 8192, - MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_UTF8 = 1 << 11 -}; - -typedef struct -{ - void *m_p; - size_t m_size, m_capacity; - mz_uint m_element_size; -} mz_zip_array; - -struct mz_zip_internal_state_tag -{ - mz_zip_array m_central_dir; - mz_zip_array m_central_dir_offsets; - mz_zip_array m_sorted_central_dir_offsets; - - /* The flags passed in when the archive is initially opened. */ - mz_uint32 m_init_flags; - - /* MZ_TRUE if the archive has a zip64 end of central directory headers, etc. */ - mz_bool m_zip64; - - /* MZ_TRUE if we found zip64 extended info in the central directory (m_zip64 will also be slammed to true too, even if we didn't find a zip64 end of central dir header, etc.) */ - mz_bool m_zip64_has_extended_info_fields; - - /* These fields are used by the file, FILE, memory, and memory/heap read/write helpers. */ - MZ_FILE *m_pFile; - mz_uint64 m_file_archive_start_ofs; - - void *m_pMem; - size_t m_mem_size; - size_t m_mem_capacity; -}; - -#define MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(array_ptr, element_size) (array_ptr)->m_element_size = element_size - -#if defined(DEBUG) || defined(_DEBUG) -static MZ_FORCEINLINE mz_uint mz_zip_array_range_check(const mz_zip_array *pArray, mz_uint index) -{ - MZ_ASSERT(index < pArray->m_size); - return index; -} -#define MZ_ZIP_ARRAY_ELEMENT(array_ptr, element_type, index) ((element_type *)((array_ptr)->m_p))[mz_zip_array_range_check(array_ptr, index)] -#else -#define MZ_ZIP_ARRAY_ELEMENT(array_ptr, element_type, index) ((element_type *)((array_ptr)->m_p))[index] -#endif - -static MZ_FORCEINLINE void mz_zip_array_init(mz_zip_array *pArray, mz_uint32 element_size) -{ - memset(pArray, 0, sizeof(mz_zip_array)); - pArray->m_element_size = element_size; -} - -static MZ_FORCEINLINE void mz_zip_array_clear(mz_zip_archive *pZip, mz_zip_array *pArray) -{ - pZip->m_pFree(pZip->m_pAlloc_opaque, pArray->m_p); - memset(pArray, 0, sizeof(mz_zip_array)); -} - -static mz_bool mz_zip_array_ensure_capacity(mz_zip_archive *pZip, mz_zip_array *pArray, size_t min_new_capacity, mz_uint growing) -{ - void *pNew_p; - size_t new_capacity = min_new_capacity; - MZ_ASSERT(pArray->m_element_size); - if (pArray->m_capacity >= min_new_capacity) - return MZ_TRUE; - if (growing) - { - new_capacity = MZ_MAX(1, pArray->m_capacity); - while (new_capacity < min_new_capacity) - new_capacity *= 2; - } - if (NULL == (pNew_p = pZip->m_pRealloc(pZip->m_pAlloc_opaque, pArray->m_p, pArray->m_element_size, new_capacity))) - return MZ_FALSE; - pArray->m_p = pNew_p; - pArray->m_capacity = new_capacity; - return MZ_TRUE; -} - -static MZ_FORCEINLINE mz_bool mz_zip_array_reserve(mz_zip_archive *pZip, mz_zip_array *pArray, size_t new_capacity, mz_uint growing) -{ - if (new_capacity > pArray->m_capacity) - { - if (!mz_zip_array_ensure_capacity(pZip, pArray, new_capacity, growing)) - return MZ_FALSE; - } - return MZ_TRUE; -} - -static MZ_FORCEINLINE mz_bool mz_zip_array_resize(mz_zip_archive *pZip, mz_zip_array *pArray, size_t new_size, mz_uint growing) -{ - if (new_size > pArray->m_capacity) - { - if (!mz_zip_array_ensure_capacity(pZip, pArray, new_size, growing)) - return MZ_FALSE; - } - pArray->m_size = new_size; - return MZ_TRUE; -} - -static MZ_FORCEINLINE mz_bool mz_zip_array_ensure_room(mz_zip_archive *pZip, mz_zip_array *pArray, size_t n) -{ - return mz_zip_array_reserve(pZip, pArray, pArray->m_size + n, MZ_TRUE); -} - -static MZ_FORCEINLINE mz_bool mz_zip_array_push_back(mz_zip_archive *pZip, mz_zip_array *pArray, const void *pElements, size_t n) -{ - size_t orig_size = pArray->m_size; - if (!mz_zip_array_resize(pZip, pArray, orig_size + n, MZ_TRUE)) - return MZ_FALSE; - if (n > 0) - memcpy((mz_uint8 *)pArray->m_p + orig_size * pArray->m_element_size, pElements, n * pArray->m_element_size); - return MZ_TRUE; -} - -#ifndef MINIZ_NO_TIME -static MZ_TIME_T mz_zip_dos_to_time_t(int dos_time, int dos_date) -{ - struct tm tm; - memset(&tm, 0, sizeof(tm)); - tm.tm_isdst = -1; - tm.tm_year = ((dos_date >> 9) & 127) + 1980 - 1900; - tm.tm_mon = ((dos_date >> 5) & 15) - 1; - tm.tm_mday = dos_date & 31; - tm.tm_hour = (dos_time >> 11) & 31; - tm.tm_min = (dos_time >> 5) & 63; - tm.tm_sec = (dos_time << 1) & 62; - return mktime(&tm); -} - -#ifndef MINIZ_NO_ARCHIVE_WRITING_APIS -static void mz_zip_time_t_to_dos_time(MZ_TIME_T time, mz_uint16 *pDOS_time, mz_uint16 *pDOS_date) -{ -#ifdef _MSC_VER - struct tm tm_struct; - struct tm *tm = &tm_struct; - errno_t err = localtime_s(tm, &time); - if (err) - { - *pDOS_date = 0; - *pDOS_time = 0; - return; - } -#else - struct tm *tm = localtime(&time); -#endif /* #ifdef _MSC_VER */ - - *pDOS_time = (mz_uint16)(((tm->tm_hour) << 11) + ((tm->tm_min) << 5) + ((tm->tm_sec) >> 1)); - *pDOS_date = (mz_uint16)(((tm->tm_year + 1900 - 1980) << 9) + ((tm->tm_mon + 1) << 5) + tm->tm_mday); -} -#endif /* MINIZ_NO_ARCHIVE_WRITING_APIS */ - -#ifndef MINIZ_NO_STDIO -#ifndef MINIZ_NO_ARCHIVE_WRITING_APIS -static mz_bool mz_zip_get_file_modified_time(const char *pFilename, MZ_TIME_T *pTime) -{ - struct MZ_FILE_STAT_STRUCT file_stat; - - /* On Linux with x86 glibc, this call will fail on large files (I think >= 0x80000000 bytes) unless you compiled with _LARGEFILE64_SOURCE. Argh. */ - if (MZ_FILE_STAT(pFilename, &file_stat) != 0) - return MZ_FALSE; - - *pTime = file_stat.st_mtime; - - return MZ_TRUE; -} -#endif /* #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS*/ - -static mz_bool mz_zip_set_file_times(const char *pFilename, MZ_TIME_T access_time, MZ_TIME_T modified_time) -{ - struct utimbuf t; - - memset(&t, 0, sizeof(t)); - t.actime = access_time; - t.modtime = modified_time; - - return !utime(pFilename, &t); -} -#endif /* #ifndef MINIZ_NO_STDIO */ -#endif /* #ifndef MINIZ_NO_TIME */ - -static MZ_FORCEINLINE mz_bool mz_zip_set_error(mz_zip_archive *pZip, mz_zip_error err_num) -{ - if (pZip) - pZip->m_last_error = err_num; - return MZ_FALSE; -} - -static mz_bool mz_zip_reader_init_internal(mz_zip_archive *pZip, mz_uint flags) -{ - (void)flags; - if ((!pZip) || (pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_INVALID)) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - - if (!pZip->m_pAlloc) - pZip->m_pAlloc = miniz_def_alloc_func; - if (!pZip->m_pFree) - pZip->m_pFree = miniz_def_free_func; - if (!pZip->m_pRealloc) - pZip->m_pRealloc = miniz_def_realloc_func; - - pZip->m_archive_size = 0; - pZip->m_central_directory_file_ofs = 0; - pZip->m_total_files = 0; - pZip->m_last_error = MZ_ZIP_NO_ERROR; - - if (NULL == (pZip->m_pState = (mz_zip_internal_state *)pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, sizeof(mz_zip_internal_state)))) - return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED); - - memset(pZip->m_pState, 0, sizeof(mz_zip_internal_state)); - MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir, sizeof(mz_uint8)); - MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir_offsets, sizeof(mz_uint32)); - MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_sorted_central_dir_offsets, sizeof(mz_uint32)); - pZip->m_pState->m_init_flags = flags; - pZip->m_pState->m_zip64 = MZ_FALSE; - pZip->m_pState->m_zip64_has_extended_info_fields = MZ_FALSE; - - pZip->m_zip_mode = MZ_ZIP_MODE_READING; - - return MZ_TRUE; -} - -static MZ_FORCEINLINE mz_bool mz_zip_reader_filename_less(const mz_zip_array *pCentral_dir_array, const mz_zip_array *pCentral_dir_offsets, mz_uint l_index, mz_uint r_index) -{ - const mz_uint8 *pL = &MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_array, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, l_index)), *pE; - const mz_uint8 *pR = &MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_array, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, r_index)); - mz_uint l_len = MZ_READ_LE16(pL + MZ_ZIP_CDH_FILENAME_LEN_OFS), r_len = MZ_READ_LE16(pR + MZ_ZIP_CDH_FILENAME_LEN_OFS); - mz_uint8 l = 0, r = 0; - pL += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE; - pR += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE; - pE = pL + MZ_MIN(l_len, r_len); - while (pL < pE) - { - if ((l = MZ_TOLOWER(*pL)) != (r = MZ_TOLOWER(*pR))) - break; - pL++; - pR++; - } - return (pL == pE) ? (l_len < r_len) : (l < r); -} - -#define MZ_SWAP_UINT32(a, b) \ - do \ - { \ - mz_uint32 t = a; \ - a = b; \ - b = t; \ - } \ - MZ_MACRO_END - -/* Heap sort of lowercased filenames, used to help accelerate plain central directory searches by mz_zip_reader_locate_file(). (Could also use qsort(), but it could allocate memory.) */ -static void mz_zip_reader_sort_central_dir_offsets_by_filename(mz_zip_archive *pZip) -{ - mz_zip_internal_state *pState = pZip->m_pState; - const mz_zip_array *pCentral_dir_offsets = &pState->m_central_dir_offsets; - const mz_zip_array *pCentral_dir = &pState->m_central_dir; - mz_uint32 *pIndices; - mz_uint32 start, end; - const mz_uint32 size = pZip->m_total_files; - - if (size <= 1U) - return; - - pIndices = &MZ_ZIP_ARRAY_ELEMENT(&pState->m_sorted_central_dir_offsets, mz_uint32, 0); - - start = (size - 2U) >> 1U; - for (;;) - { - mz_uint64 child, root = start; - for (;;) - { - if ((child = (root << 1U) + 1U) >= size) - break; - child += (((child + 1U) < size) && (mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[child], pIndices[child + 1U]))); - if (!mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[root], pIndices[child])) - break; - MZ_SWAP_UINT32(pIndices[root], pIndices[child]); - root = child; - } - if (!start) - break; - start--; - } - - end = size - 1; - while (end > 0) - { - mz_uint64 child, root = 0; - MZ_SWAP_UINT32(pIndices[end], pIndices[0]); - for (;;) - { - if ((child = (root << 1U) + 1U) >= end) - break; - child += (((child + 1U) < end) && mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[child], pIndices[child + 1U])); - if (!mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[root], pIndices[child])) - break; - MZ_SWAP_UINT32(pIndices[root], pIndices[child]); - root = child; - } - end--; - } -} - -static mz_bool mz_zip_reader_locate_header_sig(mz_zip_archive *pZip, mz_uint32 record_sig, mz_uint32 record_size, mz_int64 *pOfs) -{ - mz_int64 cur_file_ofs; - mz_uint32 buf_u32[4096 / sizeof(mz_uint32)]; - mz_uint8 *pBuf = (mz_uint8 *)buf_u32; - - /* Basic sanity checks - reject files which are too small */ - if (pZip->m_archive_size < record_size) - return MZ_FALSE; - - /* Find the record by scanning the file from the end towards the beginning. */ - cur_file_ofs = MZ_MAX((mz_int64)pZip->m_archive_size - (mz_int64)sizeof(buf_u32), 0); - for (;;) - { - int i, n = (int)MZ_MIN(sizeof(buf_u32), pZip->m_archive_size - cur_file_ofs); - - if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pBuf, n) != (mz_uint)n) - return MZ_FALSE; - - for (i = n - 4; i >= 0; --i) - { - mz_uint s = MZ_READ_LE32(pBuf + i); - if (s == record_sig) - { - if ((pZip->m_archive_size - (cur_file_ofs + i)) >= record_size) - break; - } - } - - if (i >= 0) - { - cur_file_ofs += i; - break; - } - - /* Give up if we've searched the entire file, or we've gone back "too far" (~64kb) */ - if ((!cur_file_ofs) || ((pZip->m_archive_size - cur_file_ofs) >= (MZ_UINT16_MAX + record_size))) - return MZ_FALSE; - - cur_file_ofs = MZ_MAX(cur_file_ofs - (sizeof(buf_u32) - 3), 0); - } - - *pOfs = cur_file_ofs; - return MZ_TRUE; -} - -static mz_bool mz_zip_reader_read_central_dir(mz_zip_archive *pZip, mz_uint flags) -{ - mz_uint cdir_size = 0, cdir_entries_on_this_disk = 0, num_this_disk = 0, cdir_disk_index = 0; - mz_uint64 cdir_ofs = 0; - mz_int64 cur_file_ofs = 0; - const mz_uint8 *p; - - mz_uint32 buf_u32[4096 / sizeof(mz_uint32)]; - mz_uint8 *pBuf = (mz_uint8 *)buf_u32; - mz_bool sort_central_dir = ((flags & MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY) == 0); - mz_uint32 zip64_end_of_central_dir_locator_u32[(MZ_ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)]; - mz_uint8 *pZip64_locator = (mz_uint8 *)zip64_end_of_central_dir_locator_u32; - - mz_uint32 zip64_end_of_central_dir_header_u32[(MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)]; - mz_uint8 *pZip64_end_of_central_dir = (mz_uint8 *)zip64_end_of_central_dir_header_u32; - - mz_uint64 zip64_end_of_central_dir_ofs = 0; - - /* Basic sanity checks - reject files which are too small, and check the first 4 bytes of the file to make sure a local header is there. */ - if (pZip->m_archive_size < MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) - return mz_zip_set_error(pZip, MZ_ZIP_NOT_AN_ARCHIVE); - - if (!mz_zip_reader_locate_header_sig(pZip, MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG, MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE, &cur_file_ofs)) - return mz_zip_set_error(pZip, MZ_ZIP_FAILED_FINDING_CENTRAL_DIR); - - /* Read and verify the end of central directory record. */ - if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pBuf, MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) != MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) - return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED); - - if (MZ_READ_LE32(pBuf + MZ_ZIP_ECDH_SIG_OFS) != MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG) - return mz_zip_set_error(pZip, MZ_ZIP_NOT_AN_ARCHIVE); - - if (cur_file_ofs >= (MZ_ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIZE + MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIZE)) - { - if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs - MZ_ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIZE, pZip64_locator, MZ_ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIZE) == MZ_ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIZE) - { - if (MZ_READ_LE32(pZip64_locator + MZ_ZIP64_ECDL_SIG_OFS) == MZ_ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIG) - { - zip64_end_of_central_dir_ofs = MZ_READ_LE64(pZip64_locator + MZ_ZIP64_ECDL_REL_OFS_TO_ZIP64_ECDR_OFS); - if (zip64_end_of_central_dir_ofs > (pZip->m_archive_size - MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIZE)) - return mz_zip_set_error(pZip, MZ_ZIP_NOT_AN_ARCHIVE); - - if (pZip->m_pRead(pZip->m_pIO_opaque, zip64_end_of_central_dir_ofs, pZip64_end_of_central_dir, MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIZE) == MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIZE) - { - if (MZ_READ_LE32(pZip64_end_of_central_dir + MZ_ZIP64_ECDH_SIG_OFS) == MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIG) - { - pZip->m_pState->m_zip64 = MZ_TRUE; - } - } - } - } - } - - pZip->m_total_files = MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_CDIR_TOTAL_ENTRIES_OFS); - cdir_entries_on_this_disk = MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS); - num_this_disk = MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_NUM_THIS_DISK_OFS); - cdir_disk_index = MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_NUM_DISK_CDIR_OFS); - cdir_size = MZ_READ_LE32(pBuf + MZ_ZIP_ECDH_CDIR_SIZE_OFS); - cdir_ofs = MZ_READ_LE32(pBuf + MZ_ZIP_ECDH_CDIR_OFS_OFS); - - if (pZip->m_pState->m_zip64) - { - mz_uint32 zip64_total_num_of_disks = MZ_READ_LE32(pZip64_locator + MZ_ZIP64_ECDL_TOTAL_NUMBER_OF_DISKS_OFS); - mz_uint64 zip64_cdir_total_entries = MZ_READ_LE64(pZip64_end_of_central_dir + MZ_ZIP64_ECDH_CDIR_TOTAL_ENTRIES_OFS); - mz_uint64 zip64_cdir_total_entries_on_this_disk = MZ_READ_LE64(pZip64_end_of_central_dir + MZ_ZIP64_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS); - mz_uint64 zip64_size_of_end_of_central_dir_record = MZ_READ_LE64(pZip64_end_of_central_dir + MZ_ZIP64_ECDH_SIZE_OF_RECORD_OFS); - mz_uint64 zip64_size_of_central_directory = MZ_READ_LE64(pZip64_end_of_central_dir + MZ_ZIP64_ECDH_CDIR_SIZE_OFS); - - if (zip64_size_of_end_of_central_dir_record < (MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIZE - 12)) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED); - - if (zip64_total_num_of_disks != 1U) - return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_MULTIDISK); - - /* Check for miniz's practical limits */ - if (zip64_cdir_total_entries > MZ_UINT32_MAX) - return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES); - - pZip->m_total_files = (mz_uint32)zip64_cdir_total_entries; - - if (zip64_cdir_total_entries_on_this_disk > MZ_UINT32_MAX) - return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES); - - cdir_entries_on_this_disk = (mz_uint32)zip64_cdir_total_entries_on_this_disk; - - /* Check for miniz's current practical limits (sorry, this should be enough for millions of files) */ - if (zip64_size_of_central_directory > MZ_UINT32_MAX) - return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_CDIR_SIZE); - - cdir_size = (mz_uint32)zip64_size_of_central_directory; - - num_this_disk = MZ_READ_LE32(pZip64_end_of_central_dir + MZ_ZIP64_ECDH_NUM_THIS_DISK_OFS); - - cdir_disk_index = MZ_READ_LE32(pZip64_end_of_central_dir + MZ_ZIP64_ECDH_NUM_DISK_CDIR_OFS); - - cdir_ofs = MZ_READ_LE64(pZip64_end_of_central_dir + MZ_ZIP64_ECDH_CDIR_OFS_OFS); - } - - if (pZip->m_total_files != cdir_entries_on_this_disk) - return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_MULTIDISK); - - if (((num_this_disk | cdir_disk_index) != 0) && ((num_this_disk != 1) || (cdir_disk_index != 1))) - return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_MULTIDISK); - - if (cdir_size < (mz_uint64)pZip->m_total_files * MZ_ZIP_CENTRAL_DIR_HEADER_SIZE) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED); - - if ((cdir_ofs + (mz_uint64)cdir_size) > pZip->m_archive_size) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED); - - pZip->m_central_directory_file_ofs = cdir_ofs; - - if (pZip->m_total_files) - { - mz_uint i, n; - /* Read the entire central directory into a heap block, and allocate another heap block to hold the unsorted central dir file record offsets, and possibly another to hold the sorted indices. */ - if ((!mz_zip_array_resize(pZip, &pZip->m_pState->m_central_dir, cdir_size, MZ_FALSE)) || - (!mz_zip_array_resize(pZip, &pZip->m_pState->m_central_dir_offsets, pZip->m_total_files, MZ_FALSE))) - return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED); - - if (sort_central_dir) - { - if (!mz_zip_array_resize(pZip, &pZip->m_pState->m_sorted_central_dir_offsets, pZip->m_total_files, MZ_FALSE)) - return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED); - } - - if (pZip->m_pRead(pZip->m_pIO_opaque, cdir_ofs, pZip->m_pState->m_central_dir.m_p, cdir_size) != cdir_size) - return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED); - - /* Now create an index into the central directory file records, do some basic sanity checking on each record */ - p = (const mz_uint8 *)pZip->m_pState->m_central_dir.m_p; - for (n = cdir_size, i = 0; i < pZip->m_total_files; ++i) - { - mz_uint total_header_size, disk_index, bit_flags, filename_size, ext_data_size; - mz_uint64 comp_size, decomp_size, local_header_ofs; - - if ((n < MZ_ZIP_CENTRAL_DIR_HEADER_SIZE) || (MZ_READ_LE32(p) != MZ_ZIP_CENTRAL_DIR_HEADER_SIG)) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED); - - MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, i) = (mz_uint32)(p - (const mz_uint8 *)pZip->m_pState->m_central_dir.m_p); - - if (sort_central_dir) - MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_sorted_central_dir_offsets, mz_uint32, i) = i; - - comp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS); - decomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS); - local_header_ofs = MZ_READ_LE32(p + MZ_ZIP_CDH_LOCAL_HEADER_OFS); - filename_size = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS); - ext_data_size = MZ_READ_LE16(p + MZ_ZIP_CDH_EXTRA_LEN_OFS); - - if ((!pZip->m_pState->m_zip64_has_extended_info_fields) && - (ext_data_size) && - (MZ_MAX(MZ_MAX(comp_size, decomp_size), local_header_ofs) == MZ_UINT32_MAX)) - { - /* Attempt to find zip64 extended information field in the entry's extra data */ - mz_uint32 extra_size_remaining = ext_data_size; - - if (extra_size_remaining) - { - const mz_uint8 *pExtra_data; - void* buf = NULL; - - if (MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + filename_size + ext_data_size > n) - { - buf = MZ_MALLOC(ext_data_size); - if(buf==NULL) - return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED); - - if (pZip->m_pRead(pZip->m_pIO_opaque, cdir_ofs + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + filename_size, buf, ext_data_size) != ext_data_size) - { - MZ_FREE(buf); - return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED); - } - - pExtra_data = (mz_uint8*)buf; - } - else - { - pExtra_data = p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + filename_size; - } - - do - { - mz_uint32 field_id; - mz_uint32 field_data_size; - - if (extra_size_remaining < (sizeof(mz_uint16) * 2)) - { - MZ_FREE(buf); - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED); - } - - field_id = MZ_READ_LE16(pExtra_data); - field_data_size = MZ_READ_LE16(pExtra_data + sizeof(mz_uint16)); - - if ((field_data_size + sizeof(mz_uint16) * 2) > extra_size_remaining) - { - MZ_FREE(buf); - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED); - } - - if (field_id == MZ_ZIP64_EXTENDED_INFORMATION_FIELD_HEADER_ID) - { - /* Ok, the archive didn't have any zip64 headers but it uses a zip64 extended information field so mark it as zip64 anyway (this can occur with infozip's zip util when it reads compresses files from stdin). */ - pZip->m_pState->m_zip64 = MZ_TRUE; - pZip->m_pState->m_zip64_has_extended_info_fields = MZ_TRUE; - break; - } - - pExtra_data += sizeof(mz_uint16) * 2 + field_data_size; - extra_size_remaining = extra_size_remaining - sizeof(mz_uint16) * 2 - field_data_size; - } while (extra_size_remaining); - - MZ_FREE(buf); - } - } - - /* I've seen archives that aren't marked as zip64 that uses zip64 ext data, argh */ - if ((comp_size != MZ_UINT32_MAX) && (decomp_size != MZ_UINT32_MAX)) - { - if (((!MZ_READ_LE32(p + MZ_ZIP_CDH_METHOD_OFS)) && (decomp_size != comp_size)) || (decomp_size && !comp_size)) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED); - } - - disk_index = MZ_READ_LE16(p + MZ_ZIP_CDH_DISK_START_OFS); - if ((disk_index == MZ_UINT16_MAX) || ((disk_index != num_this_disk) && (disk_index != 1))) - return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_MULTIDISK); - - if (comp_size != MZ_UINT32_MAX) - { - if (((mz_uint64)MZ_READ_LE32(p + MZ_ZIP_CDH_LOCAL_HEADER_OFS) + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + comp_size) > pZip->m_archive_size) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED); - } - - bit_flags = MZ_READ_LE16(p + MZ_ZIP_CDH_BIT_FLAG_OFS); - if (bit_flags & MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_LOCAL_DIR_IS_MASKED) - return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_ENCRYPTION); - - if ((total_header_size = MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS) + MZ_READ_LE16(p + MZ_ZIP_CDH_EXTRA_LEN_OFS) + MZ_READ_LE16(p + MZ_ZIP_CDH_COMMENT_LEN_OFS)) > n) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED); - - n -= total_header_size; - p += total_header_size; - } - } - - if (sort_central_dir) - mz_zip_reader_sort_central_dir_offsets_by_filename(pZip); - - return MZ_TRUE; -} - -void mz_zip_zero_struct(mz_zip_archive *pZip) -{ - if (pZip) - MZ_CLEAR_PTR(pZip); -} - -static mz_bool mz_zip_reader_end_internal(mz_zip_archive *pZip, mz_bool set_last_error) -{ - mz_bool status = MZ_TRUE; - - if (!pZip) - return MZ_FALSE; - - if ((!pZip->m_pState) || (!pZip->m_pAlloc) || (!pZip->m_pFree) || (pZip->m_zip_mode != MZ_ZIP_MODE_READING)) - { - if (set_last_error) - pZip->m_last_error = MZ_ZIP_INVALID_PARAMETER; - - return MZ_FALSE; - } - - if (pZip->m_pState) - { - mz_zip_internal_state *pState = pZip->m_pState; - pZip->m_pState = NULL; - - mz_zip_array_clear(pZip, &pState->m_central_dir); - mz_zip_array_clear(pZip, &pState->m_central_dir_offsets); - mz_zip_array_clear(pZip, &pState->m_sorted_central_dir_offsets); - -#ifndef MINIZ_NO_STDIO - if (pState->m_pFile) - { - if (pZip->m_zip_type == MZ_ZIP_TYPE_FILE) - { - if (MZ_FCLOSE(pState->m_pFile) == EOF) - { - if (set_last_error) - pZip->m_last_error = MZ_ZIP_FILE_CLOSE_FAILED; - status = MZ_FALSE; - } - } - pState->m_pFile = NULL; - } -#endif /* #ifndef MINIZ_NO_STDIO */ - - pZip->m_pFree(pZip->m_pAlloc_opaque, pState); - } - pZip->m_zip_mode = MZ_ZIP_MODE_INVALID; - - return status; -} - -mz_bool mz_zip_reader_end(mz_zip_archive *pZip) -{ - return mz_zip_reader_end_internal(pZip, MZ_TRUE); -} -mz_bool mz_zip_reader_init(mz_zip_archive *pZip, mz_uint64 size, mz_uint flags) -{ - if ((!pZip) || (!pZip->m_pRead)) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - - if (!mz_zip_reader_init_internal(pZip, flags)) - return MZ_FALSE; - - pZip->m_zip_type = MZ_ZIP_TYPE_USER; - pZip->m_archive_size = size; - - if (!mz_zip_reader_read_central_dir(pZip, flags)) - { - mz_zip_reader_end_internal(pZip, MZ_FALSE); - return MZ_FALSE; - } - - return MZ_TRUE; -} - -static size_t mz_zip_mem_read_func(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n) -{ - mz_zip_archive *pZip = (mz_zip_archive *)pOpaque; - size_t s = (file_ofs >= pZip->m_archive_size) ? 0 : (size_t)MZ_MIN(pZip->m_archive_size - file_ofs, n); - memcpy(pBuf, (const mz_uint8 *)pZip->m_pState->m_pMem + file_ofs, s); - return s; -} - -mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem, size_t size, mz_uint flags) -{ - if (!pMem) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - - if (size < MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) - return mz_zip_set_error(pZip, MZ_ZIP_NOT_AN_ARCHIVE); - - if (!mz_zip_reader_init_internal(pZip, flags)) - return MZ_FALSE; - - pZip->m_zip_type = MZ_ZIP_TYPE_MEMORY; - pZip->m_archive_size = size; - pZip->m_pRead = mz_zip_mem_read_func; - pZip->m_pIO_opaque = pZip; - pZip->m_pNeeds_keepalive = NULL; - -#ifdef __cplusplus - pZip->m_pState->m_pMem = const_cast(pMem); -#else - pZip->m_pState->m_pMem = (void *)pMem; -#endif - - pZip->m_pState->m_mem_size = size; - - if (!mz_zip_reader_read_central_dir(pZip, flags)) - { - mz_zip_reader_end_internal(pZip, MZ_FALSE); - return MZ_FALSE; - } - - return MZ_TRUE; -} - -#ifndef MINIZ_NO_STDIO -static size_t mz_zip_file_read_func(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n) -{ - mz_zip_archive *pZip = (mz_zip_archive *)pOpaque; - mz_int64 cur_ofs = MZ_FTELL64(pZip->m_pState->m_pFile); - - file_ofs += pZip->m_pState->m_file_archive_start_ofs; - - if (((mz_int64)file_ofs < 0) || (((cur_ofs != (mz_int64)file_ofs)) && (MZ_FSEEK64(pZip->m_pState->m_pFile, (mz_int64)file_ofs, SEEK_SET)))) - return 0; - - return MZ_FREAD(pBuf, 1, n, pZip->m_pState->m_pFile); -} - -mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint32 flags) -{ - return mz_zip_reader_init_file_v2(pZip, pFilename, flags, 0, 0); -} - -mz_bool mz_zip_reader_init_file_v2(mz_zip_archive *pZip, const char *pFilename, mz_uint flags, mz_uint64 file_start_ofs, mz_uint64 archive_size) -{ - mz_uint64 file_size; - MZ_FILE *pFile; - - if ((!pZip) || (!pFilename) || ((archive_size) && (archive_size < MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE))) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - - pFile = MZ_FOPEN(pFilename, "rb"); - if (!pFile) - return mz_zip_set_error(pZip, MZ_ZIP_FILE_OPEN_FAILED); - - file_size = archive_size; - if (!file_size) - { - if (MZ_FSEEK64(pFile, 0, SEEK_END)) - { - MZ_FCLOSE(pFile); - return mz_zip_set_error(pZip, MZ_ZIP_FILE_SEEK_FAILED); - } - - file_size = MZ_FTELL64(pFile); - } - - /* TODO: Better sanity check archive_size and the # of actual remaining bytes */ - - if (file_size < MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) - { - MZ_FCLOSE(pFile); - return mz_zip_set_error(pZip, MZ_ZIP_NOT_AN_ARCHIVE); - } - - if (!mz_zip_reader_init_internal(pZip, flags)) - { - MZ_FCLOSE(pFile); - return MZ_FALSE; - } - - pZip->m_zip_type = MZ_ZIP_TYPE_FILE; - pZip->m_pRead = mz_zip_file_read_func; - pZip->m_pIO_opaque = pZip; - pZip->m_pState->m_pFile = pFile; - pZip->m_archive_size = file_size; - pZip->m_pState->m_file_archive_start_ofs = file_start_ofs; - - if (!mz_zip_reader_read_central_dir(pZip, flags)) - { - mz_zip_reader_end_internal(pZip, MZ_FALSE); - return MZ_FALSE; - } - - return MZ_TRUE; -} - -mz_bool mz_zip_reader_init_cfile(mz_zip_archive *pZip, MZ_FILE *pFile, mz_uint64 archive_size, mz_uint flags) -{ - mz_uint64 cur_file_ofs; - - if ((!pZip) || (!pFile)) - return mz_zip_set_error(pZip, MZ_ZIP_FILE_OPEN_FAILED); - - cur_file_ofs = MZ_FTELL64(pFile); - - if (!archive_size) - { - if (MZ_FSEEK64(pFile, 0, SEEK_END)) - return mz_zip_set_error(pZip, MZ_ZIP_FILE_SEEK_FAILED); - - archive_size = MZ_FTELL64(pFile) - cur_file_ofs; - - if (archive_size < MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) - return mz_zip_set_error(pZip, MZ_ZIP_NOT_AN_ARCHIVE); - } - - if (!mz_zip_reader_init_internal(pZip, flags)) - return MZ_FALSE; - - pZip->m_zip_type = MZ_ZIP_TYPE_CFILE; - pZip->m_pRead = mz_zip_file_read_func; - - pZip->m_pIO_opaque = pZip; - pZip->m_pState->m_pFile = pFile; - pZip->m_archive_size = archive_size; - pZip->m_pState->m_file_archive_start_ofs = cur_file_ofs; - - if (!mz_zip_reader_read_central_dir(pZip, flags)) - { - mz_zip_reader_end_internal(pZip, MZ_FALSE); - return MZ_FALSE; - } - - return MZ_TRUE; -} - -#endif /* #ifndef MINIZ_NO_STDIO */ - -static MZ_FORCEINLINE const mz_uint8 *mz_zip_get_cdh(mz_zip_archive *pZip, mz_uint file_index) -{ - if ((!pZip) || (!pZip->m_pState) || (file_index >= pZip->m_total_files)) - return NULL; - return &MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, file_index)); -} - -mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip, mz_uint file_index) -{ - mz_uint m_bit_flag; - const mz_uint8 *p = mz_zip_get_cdh(pZip, file_index); - if (!p) - { - mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - return MZ_FALSE; - } - - m_bit_flag = MZ_READ_LE16(p + MZ_ZIP_CDH_BIT_FLAG_OFS); - return (m_bit_flag & (MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_IS_ENCRYPTED | MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_USES_STRONG_ENCRYPTION)) != 0; -} - -mz_bool mz_zip_reader_is_file_supported(mz_zip_archive *pZip, mz_uint file_index) -{ - mz_uint bit_flag; - mz_uint method; - - const mz_uint8 *p = mz_zip_get_cdh(pZip, file_index); - if (!p) - { - mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - return MZ_FALSE; - } - - method = MZ_READ_LE16(p + MZ_ZIP_CDH_METHOD_OFS); - bit_flag = MZ_READ_LE16(p + MZ_ZIP_CDH_BIT_FLAG_OFS); - - if ((method != 0) && (method != MZ_DEFLATED)) - { - mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_METHOD); - return MZ_FALSE; - } - - if (bit_flag & (MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_IS_ENCRYPTED | MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_USES_STRONG_ENCRYPTION)) - { - mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_ENCRYPTION); - return MZ_FALSE; - } - - if (bit_flag & MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_COMPRESSED_PATCH_FLAG) - { - mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_FEATURE); - return MZ_FALSE; - } - - return MZ_TRUE; -} - -mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip, mz_uint file_index) -{ - mz_uint filename_len, attribute_mapping_id, external_attr; - const mz_uint8 *p = mz_zip_get_cdh(pZip, file_index); - if (!p) - { - mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - return MZ_FALSE; - } - - filename_len = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS); - if (filename_len) - { - if (*(p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + filename_len - 1) == '/') - return MZ_TRUE; - } - - /* Bugfix: This code was also checking if the internal attribute was non-zero, which wasn't correct. */ - /* Most/all zip writers (hopefully) set DOS file/directory attributes in the low 16-bits, so check for the DOS directory flag and ignore the source OS ID in the created by field. */ - /* FIXME: Remove this check? Is it necessary - we already check the filename. */ - attribute_mapping_id = MZ_READ_LE16(p + MZ_ZIP_CDH_VERSION_MADE_BY_OFS) >> 8; - (void)attribute_mapping_id; - - external_attr = MZ_READ_LE32(p + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS); - if ((external_attr & MZ_ZIP_DOS_DIR_ATTRIBUTE_BITFLAG) != 0) - { - return MZ_TRUE; - } - - return MZ_FALSE; -} - -static mz_bool mz_zip_file_stat_internal(mz_zip_archive *pZip, mz_uint file_index, const mz_uint8 *pCentral_dir_header, mz_zip_archive_file_stat *pStat, mz_bool *pFound_zip64_extra_data) -{ - mz_uint n; - const mz_uint8 *p = pCentral_dir_header; - - if (pFound_zip64_extra_data) - *pFound_zip64_extra_data = MZ_FALSE; - - if ((!p) || (!pStat)) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - - /* Extract fields from the central directory record. */ - pStat->m_file_index = file_index; - pStat->m_central_dir_ofs = MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, file_index); - pStat->m_version_made_by = MZ_READ_LE16(p + MZ_ZIP_CDH_VERSION_MADE_BY_OFS); - pStat->m_version_needed = MZ_READ_LE16(p + MZ_ZIP_CDH_VERSION_NEEDED_OFS); - pStat->m_bit_flag = MZ_READ_LE16(p + MZ_ZIP_CDH_BIT_FLAG_OFS); - pStat->m_method = MZ_READ_LE16(p + MZ_ZIP_CDH_METHOD_OFS); -#ifndef MINIZ_NO_TIME - pStat->m_time = mz_zip_dos_to_time_t(MZ_READ_LE16(p + MZ_ZIP_CDH_FILE_TIME_OFS), MZ_READ_LE16(p + MZ_ZIP_CDH_FILE_DATE_OFS)); -#endif - pStat->m_crc32 = MZ_READ_LE32(p + MZ_ZIP_CDH_CRC32_OFS); - pStat->m_comp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS); - pStat->m_uncomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS); - pStat->m_internal_attr = MZ_READ_LE16(p + MZ_ZIP_CDH_INTERNAL_ATTR_OFS); - pStat->m_external_attr = MZ_READ_LE32(p + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS); - pStat->m_local_header_ofs = MZ_READ_LE32(p + MZ_ZIP_CDH_LOCAL_HEADER_OFS); - - /* Copy as much of the filename and comment as possible. */ - n = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS); - n = MZ_MIN(n, MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE - 1); - memcpy(pStat->m_filename, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, n); - pStat->m_filename[n] = '\0'; - - n = MZ_READ_LE16(p + MZ_ZIP_CDH_COMMENT_LEN_OFS); - n = MZ_MIN(n, MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE - 1); - pStat->m_comment_size = n; - memcpy(pStat->m_comment, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS) + MZ_READ_LE16(p + MZ_ZIP_CDH_EXTRA_LEN_OFS), n); - pStat->m_comment[n] = '\0'; - - /* Set some flags for convienance */ - pStat->m_is_directory = mz_zip_reader_is_file_a_directory(pZip, file_index); - pStat->m_is_encrypted = mz_zip_reader_is_file_encrypted(pZip, file_index); - pStat->m_is_supported = mz_zip_reader_is_file_supported(pZip, file_index); - - /* See if we need to read any zip64 extended information fields. */ - /* Confusingly, these zip64 fields can be present even on non-zip64 archives (Debian zip on a huge files from stdin piped to stdout creates them). */ - if (MZ_MAX(MZ_MAX(pStat->m_comp_size, pStat->m_uncomp_size), pStat->m_local_header_ofs) == MZ_UINT32_MAX) - { - /* Attempt to find zip64 extended information field in the entry's extra data */ - mz_uint32 extra_size_remaining = MZ_READ_LE16(p + MZ_ZIP_CDH_EXTRA_LEN_OFS); - - if (extra_size_remaining) - { - const mz_uint8 *pExtra_data = p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS); - - do - { - mz_uint32 field_id; - mz_uint32 field_data_size; - - if (extra_size_remaining < (sizeof(mz_uint16) * 2)) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED); - - field_id = MZ_READ_LE16(pExtra_data); - field_data_size = MZ_READ_LE16(pExtra_data + sizeof(mz_uint16)); - - if ((field_data_size + sizeof(mz_uint16) * 2) > extra_size_remaining) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED); - - if (field_id == MZ_ZIP64_EXTENDED_INFORMATION_FIELD_HEADER_ID) - { - const mz_uint8 *pField_data = pExtra_data + sizeof(mz_uint16) * 2; - mz_uint32 field_data_remaining = field_data_size; - - if (pFound_zip64_extra_data) - *pFound_zip64_extra_data = MZ_TRUE; - - if (pStat->m_uncomp_size == MZ_UINT32_MAX) - { - if (field_data_remaining < sizeof(mz_uint64)) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED); - - pStat->m_uncomp_size = MZ_READ_LE64(pField_data); - pField_data += sizeof(mz_uint64); - field_data_remaining -= sizeof(mz_uint64); - } - - if (pStat->m_comp_size == MZ_UINT32_MAX) - { - if (field_data_remaining < sizeof(mz_uint64)) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED); - - pStat->m_comp_size = MZ_READ_LE64(pField_data); - pField_data += sizeof(mz_uint64); - field_data_remaining -= sizeof(mz_uint64); - } - - if (pStat->m_local_header_ofs == MZ_UINT32_MAX) - { - if (field_data_remaining < sizeof(mz_uint64)) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED); - - pStat->m_local_header_ofs = MZ_READ_LE64(pField_data); - pField_data += sizeof(mz_uint64); - field_data_remaining -= sizeof(mz_uint64); - } - - break; - } - - pExtra_data += sizeof(mz_uint16) * 2 + field_data_size; - extra_size_remaining = extra_size_remaining - sizeof(mz_uint16) * 2 - field_data_size; - } while (extra_size_remaining); - } - } - - return MZ_TRUE; -} - -static MZ_FORCEINLINE mz_bool mz_zip_string_equal(const char *pA, const char *pB, mz_uint len, mz_uint flags) -{ - mz_uint i; - if (flags & MZ_ZIP_FLAG_CASE_SENSITIVE) - return 0 == memcmp(pA, pB, len); - for (i = 0; i < len; ++i) - if (MZ_TOLOWER(pA[i]) != MZ_TOLOWER(pB[i])) - return MZ_FALSE; - return MZ_TRUE; -} - -static MZ_FORCEINLINE int mz_zip_filename_compare(const mz_zip_array *pCentral_dir_array, const mz_zip_array *pCentral_dir_offsets, mz_uint l_index, const char *pR, mz_uint r_len) -{ - const mz_uint8 *pL = &MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_array, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, l_index)), *pE; - mz_uint l_len = MZ_READ_LE16(pL + MZ_ZIP_CDH_FILENAME_LEN_OFS); - mz_uint8 l = 0, r = 0; - pL += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE; - pE = pL + MZ_MIN(l_len, r_len); - while (pL < pE) - { - if ((l = MZ_TOLOWER(*pL)) != (r = MZ_TOLOWER(*pR))) - break; - pL++; - pR++; - } - return (pL == pE) ? (int)(l_len - r_len) : (l - r); -} - -static mz_bool mz_zip_locate_file_binary_search(mz_zip_archive *pZip, const char *pFilename, mz_uint32 *pIndex) -{ - mz_zip_internal_state *pState = pZip->m_pState; - const mz_zip_array *pCentral_dir_offsets = &pState->m_central_dir_offsets; - const mz_zip_array *pCentral_dir = &pState->m_central_dir; - mz_uint32 *pIndices = &MZ_ZIP_ARRAY_ELEMENT(&pState->m_sorted_central_dir_offsets, mz_uint32, 0); - const mz_uint32 size = pZip->m_total_files; - const mz_uint filename_len = (mz_uint)strlen(pFilename); - - if (pIndex) - *pIndex = 0; - - if (size) - { - /* yes I could use uint32_t's, but then we would have to add some special case checks in the loop, argh, and */ - /* honestly the major expense here on 32-bit CPU's will still be the filename compare */ - mz_int64 l = 0, h = (mz_int64)size - 1; - - while (l <= h) - { - mz_int64 m = l + ((h - l) >> 1); - mz_uint32 file_index = pIndices[(mz_uint32)m]; - - int comp = mz_zip_filename_compare(pCentral_dir, pCentral_dir_offsets, file_index, pFilename, filename_len); - if (!comp) - { - if (pIndex) - *pIndex = file_index; - return MZ_TRUE; - } - else if (comp < 0) - l = m + 1; - else - h = m - 1; - } - } - - return mz_zip_set_error(pZip, MZ_ZIP_FILE_NOT_FOUND); -} - -int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags) -{ - mz_uint32 index; - if (!mz_zip_reader_locate_file_v2(pZip, pName, pComment, flags, &index)) - return -1; - else - return (int)index; -} - -mz_bool mz_zip_reader_locate_file_v2(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags, mz_uint32 *pIndex) -{ - mz_uint file_index; - size_t name_len, comment_len; - - if (pIndex) - *pIndex = 0; - - if ((!pZip) || (!pZip->m_pState) || (!pName)) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - - /* See if we can use a binary search */ - if (((pZip->m_pState->m_init_flags & MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY) == 0) && - (pZip->m_zip_mode == MZ_ZIP_MODE_READING) && - ((flags & (MZ_ZIP_FLAG_IGNORE_PATH | MZ_ZIP_FLAG_CASE_SENSITIVE)) == 0) && (!pComment) && (pZip->m_pState->m_sorted_central_dir_offsets.m_size)) - { - return mz_zip_locate_file_binary_search(pZip, pName, pIndex); - } - - /* Locate the entry by scanning the entire central directory */ - name_len = strlen(pName); - if (name_len > MZ_UINT16_MAX) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - - comment_len = pComment ? strlen(pComment) : 0; - if (comment_len > MZ_UINT16_MAX) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - - for (file_index = 0; file_index < pZip->m_total_files; file_index++) - { - const mz_uint8 *pHeader = &MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, file_index)); - mz_uint filename_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_FILENAME_LEN_OFS); - const char *pFilename = (const char *)pHeader + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE; - if (filename_len < name_len) - continue; - if (comment_len) - { - mz_uint file_extra_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_EXTRA_LEN_OFS), file_comment_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_COMMENT_LEN_OFS); - const char *pFile_comment = pFilename + filename_len + file_extra_len; - if ((file_comment_len != comment_len) || (!mz_zip_string_equal(pComment, pFile_comment, file_comment_len, flags))) - continue; - } - if ((flags & MZ_ZIP_FLAG_IGNORE_PATH) && (filename_len)) - { - int ofs = filename_len - 1; - do - { - if ((pFilename[ofs] == '/') || (pFilename[ofs] == '\\') || (pFilename[ofs] == ':')) - break; - } while (--ofs >= 0); - ofs++; - pFilename += ofs; - filename_len -= ofs; - } - if ((filename_len == name_len) && (mz_zip_string_equal(pName, pFilename, filename_len, flags))) - { - if (pIndex) - *pIndex = file_index; - return MZ_TRUE; - } - } - - return mz_zip_set_error(pZip, MZ_ZIP_FILE_NOT_FOUND); -} - -static -mz_bool mz_zip_reader_extract_to_mem_no_alloc1(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size, const mz_zip_archive_file_stat *st) -{ - int status = TINFL_STATUS_DONE; - mz_uint64 needed_size, cur_file_ofs, comp_remaining, out_buf_ofs = 0, read_buf_size, read_buf_ofs = 0, read_buf_avail; - mz_zip_archive_file_stat file_stat; - void *pRead_buf; - mz_uint32 local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)]; - mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32; - tinfl_decompressor inflator; - - if ((!pZip) || (!pZip->m_pState) || ((buf_size) && (!pBuf)) || ((user_read_buf_size) && (!pUser_read_buf)) || (!pZip->m_pRead)) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - - if (st) { - file_stat = *st; - } else - if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat)) - return MZ_FALSE; - - /* A directory or zero length file */ - if ((file_stat.m_is_directory) || (!file_stat.m_comp_size)) - return MZ_TRUE; - - /* Encryption and patch files are not supported. */ - if (file_stat.m_bit_flag & (MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_IS_ENCRYPTED | MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_USES_STRONG_ENCRYPTION | MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_COMPRESSED_PATCH_FLAG)) - return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_ENCRYPTION); - - /* This function only supports decompressing stored and deflate. */ - if ((!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (file_stat.m_method != 0) && (file_stat.m_method != MZ_DEFLATED)) - return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_METHOD); - - /* Ensure supplied output buffer is large enough. */ - needed_size = (flags & MZ_ZIP_FLAG_COMPRESSED_DATA) ? file_stat.m_comp_size : file_stat.m_uncomp_size; - if (buf_size < needed_size) - return mz_zip_set_error(pZip, MZ_ZIP_BUF_TOO_SMALL); - - /* Read and parse the local directory entry. */ - cur_file_ofs = file_stat.m_local_header_ofs; - if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE) - return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED); - - if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED); - - cur_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS) + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS); - if ((cur_file_ofs + file_stat.m_comp_size) > pZip->m_archive_size) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED); - - if ((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) || (!file_stat.m_method)) - { - /* The file is stored or the caller has requested the compressed data. */ - if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pBuf, (size_t)needed_size) != needed_size) - return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED); - -#ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS - if ((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) == 0) - { - if (mz_crc32(MZ_CRC32_INIT, (const mz_uint8 *)pBuf, (size_t)file_stat.m_uncomp_size) != file_stat.m_crc32) - return mz_zip_set_error(pZip, MZ_ZIP_CRC_CHECK_FAILED); - } -#endif - - return MZ_TRUE; - } - - /* Decompress the file either directly from memory or from a file input buffer. */ - tinfl_init(&inflator); - - if (pZip->m_pState->m_pMem) - { - /* Read directly from the archive in memory. */ - pRead_buf = (mz_uint8 *)pZip->m_pState->m_pMem + cur_file_ofs; - read_buf_size = read_buf_avail = file_stat.m_comp_size; - comp_remaining = 0; - } - else if (pUser_read_buf) - { - /* Use a user provided read buffer. */ - if (!user_read_buf_size) - return MZ_FALSE; - pRead_buf = (mz_uint8 *)pUser_read_buf; - read_buf_size = user_read_buf_size; - read_buf_avail = 0; - comp_remaining = file_stat.m_comp_size; - } - else - { - /* Temporarily allocate a read buffer. */ - read_buf_size = MZ_MIN(file_stat.m_comp_size, (mz_uint64)MZ_ZIP_MAX_IO_BUF_SIZE); - if (((sizeof(size_t) == sizeof(mz_uint32))) && (read_buf_size > 0x7FFFFFFF)) - return mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR); - - if (NULL == (pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)read_buf_size))) - return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED); - - read_buf_avail = 0; - comp_remaining = file_stat.m_comp_size; - } - - do - { - /* The size_t cast here should be OK because we've verified that the output buffer is >= file_stat.m_uncomp_size above */ - size_t in_buf_size, out_buf_size = (size_t)(file_stat.m_uncomp_size - out_buf_ofs); - if ((!read_buf_avail) && (!pZip->m_pState->m_pMem)) - { - read_buf_avail = MZ_MIN(read_buf_size, comp_remaining); - if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pRead_buf, (size_t)read_buf_avail) != read_buf_avail) - { - status = TINFL_STATUS_FAILED; - mz_zip_set_error(pZip, MZ_ZIP_DECOMPRESSION_FAILED); - break; - } - cur_file_ofs += read_buf_avail; - comp_remaining -= read_buf_avail; - read_buf_ofs = 0; - } - in_buf_size = (size_t)read_buf_avail; - status = tinfl_decompress(&inflator, (mz_uint8 *)pRead_buf + read_buf_ofs, &in_buf_size, (mz_uint8 *)pBuf, (mz_uint8 *)pBuf + out_buf_ofs, &out_buf_size, TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF | (comp_remaining ? TINFL_FLAG_HAS_MORE_INPUT : 0)); - read_buf_avail -= in_buf_size; - read_buf_ofs += in_buf_size; - out_buf_ofs += out_buf_size; - } while (status == TINFL_STATUS_NEEDS_MORE_INPUT); - - if (status == TINFL_STATUS_DONE) - { - /* Make sure the entire file was decompressed, and check its CRC. */ - if (out_buf_ofs != file_stat.m_uncomp_size) - { - mz_zip_set_error(pZip, MZ_ZIP_UNEXPECTED_DECOMPRESSED_SIZE); - status = TINFL_STATUS_FAILED; - } -#ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS - else if (mz_crc32(MZ_CRC32_INIT, (const mz_uint8 *)pBuf, (size_t)file_stat.m_uncomp_size) != file_stat.m_crc32) - { - mz_zip_set_error(pZip, MZ_ZIP_CRC_CHECK_FAILED); - status = TINFL_STATUS_FAILED; - } -#endif - } - - if ((!pZip->m_pState->m_pMem) && (!pUser_read_buf)) - pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); - - return status == TINFL_STATUS_DONE; -} - -mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size) -{ - return mz_zip_reader_extract_to_mem_no_alloc1(pZip, file_index, pBuf, buf_size, flags, pUser_read_buf, user_read_buf_size, NULL); -} - -mz_bool mz_zip_reader_extract_file_to_mem_no_alloc(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size) -{ - mz_uint32 file_index; - if (!mz_zip_reader_locate_file_v2(pZip, pFilename, NULL, flags, &file_index)) - return MZ_FALSE; - return mz_zip_reader_extract_to_mem_no_alloc1(pZip, file_index, pBuf, buf_size, flags, pUser_read_buf, user_read_buf_size, NULL); -} - -mz_bool mz_zip_reader_extract_to_mem(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags) -{ - return mz_zip_reader_extract_to_mem_no_alloc1(pZip, file_index, pBuf, buf_size, flags, NULL, 0, NULL); -} - -mz_bool mz_zip_reader_extract_file_to_mem(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags) -{ - return mz_zip_reader_extract_file_to_mem_no_alloc(pZip, pFilename, pBuf, buf_size, flags, NULL, 0); -} - -void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index, size_t *pSize, mz_uint flags) -{ - mz_zip_archive_file_stat file_stat; - mz_uint64 alloc_size; - void *pBuf; - - if (pSize) - *pSize = 0; - - if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat)) - return NULL; - - alloc_size = (flags & MZ_ZIP_FLAG_COMPRESSED_DATA) ? file_stat.m_comp_size : file_stat.m_uncomp_size; - if (((sizeof(size_t) == sizeof(mz_uint32))) && (alloc_size > 0x7FFFFFFF)) - { - mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR); - return NULL; - } - - if (NULL == (pBuf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)alloc_size))) - { - mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED); - return NULL; - } - - if (!mz_zip_reader_extract_to_mem_no_alloc1(pZip, file_index, pBuf, (size_t)alloc_size, flags, NULL, 0, &file_stat)) - { - pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); - return NULL; - } - - if (pSize) - *pSize = (size_t)alloc_size; - return pBuf; -} - -void *mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip, const char *pFilename, size_t *pSize, mz_uint flags) -{ - mz_uint32 file_index; - if (!mz_zip_reader_locate_file_v2(pZip, pFilename, NULL, flags, &file_index)) - { - if (pSize) - *pSize = 0; - return MZ_FALSE; - } - return mz_zip_reader_extract_to_heap(pZip, file_index, pSize, flags); -} - -mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip, mz_uint file_index, mz_file_write_func pCallback, void *pOpaque, mz_uint flags) -{ - int status = TINFL_STATUS_DONE; -#ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS - mz_uint file_crc32 = MZ_CRC32_INIT; -#endif - mz_uint64 read_buf_size, read_buf_ofs = 0, read_buf_avail, comp_remaining, out_buf_ofs = 0, cur_file_ofs; - mz_zip_archive_file_stat file_stat; - void *pRead_buf = NULL; - void *pWrite_buf = NULL; - mz_uint32 local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)]; - mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32; - - if ((!pZip) || (!pZip->m_pState) || (!pCallback) || (!pZip->m_pRead)) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - - if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat)) - return MZ_FALSE; - - /* A directory or zero length file */ - if ((file_stat.m_is_directory) || (!file_stat.m_comp_size)) - return MZ_TRUE; - - /* Encryption and patch files are not supported. */ - if (file_stat.m_bit_flag & (MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_IS_ENCRYPTED | MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_USES_STRONG_ENCRYPTION | MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_COMPRESSED_PATCH_FLAG)) - return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_ENCRYPTION); - - /* This function only supports decompressing stored and deflate. */ - if ((!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (file_stat.m_method != 0) && (file_stat.m_method != MZ_DEFLATED)) - return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_METHOD); - - /* Read and do some minimal validation of the local directory entry (this doesn't crack the zip64 stuff, which we already have from the central dir) */ - cur_file_ofs = file_stat.m_local_header_ofs; - if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE) - return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED); - - if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED); - - cur_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS) + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS); - if ((cur_file_ofs + file_stat.m_comp_size) > pZip->m_archive_size) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED); - - /* Decompress the file either directly from memory or from a file input buffer. */ - if (pZip->m_pState->m_pMem) - { - pRead_buf = (mz_uint8 *)pZip->m_pState->m_pMem + cur_file_ofs; - read_buf_size = read_buf_avail = file_stat.m_comp_size; - comp_remaining = 0; - } - else - { - read_buf_size = MZ_MIN(file_stat.m_comp_size, (mz_uint64)MZ_ZIP_MAX_IO_BUF_SIZE); - if (NULL == (pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)read_buf_size))) - return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED); - - read_buf_avail = 0; - comp_remaining = file_stat.m_comp_size; - } - - if ((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) || (!file_stat.m_method)) - { - /* The file is stored or the caller has requested the compressed data. */ - if (pZip->m_pState->m_pMem) - { - if (((sizeof(size_t) == sizeof(mz_uint32))) && (file_stat.m_comp_size > MZ_UINT32_MAX)) - return mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR); - - if (pCallback(pOpaque, out_buf_ofs, pRead_buf, (size_t)file_stat.m_comp_size) != file_stat.m_comp_size) - { - mz_zip_set_error(pZip, MZ_ZIP_WRITE_CALLBACK_FAILED); - status = TINFL_STATUS_FAILED; - } - else if (!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) - { -#ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS - file_crc32 = (mz_uint32)mz_crc32(file_crc32, (const mz_uint8 *)pRead_buf, (size_t)file_stat.m_comp_size); -#endif - } - - cur_file_ofs += file_stat.m_comp_size; - out_buf_ofs += file_stat.m_comp_size; - comp_remaining = 0; - } - else - { - while (comp_remaining) - { - read_buf_avail = MZ_MIN(read_buf_size, comp_remaining); - if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pRead_buf, (size_t)read_buf_avail) != read_buf_avail) - { - mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED); - status = TINFL_STATUS_FAILED; - break; - } - -#ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS - if (!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) - { - file_crc32 = (mz_uint32)mz_crc32(file_crc32, (const mz_uint8 *)pRead_buf, (size_t)read_buf_avail); - } -#endif - - if (pCallback(pOpaque, out_buf_ofs, pRead_buf, (size_t)read_buf_avail) != read_buf_avail) - { - mz_zip_set_error(pZip, MZ_ZIP_WRITE_CALLBACK_FAILED); - status = TINFL_STATUS_FAILED; - break; - } - - cur_file_ofs += read_buf_avail; - out_buf_ofs += read_buf_avail; - comp_remaining -= read_buf_avail; - } - } - } - else - { - tinfl_decompressor inflator; - tinfl_init(&inflator); - - if (NULL == (pWrite_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, TINFL_LZ_DICT_SIZE))) - { - mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED); - status = TINFL_STATUS_FAILED; - } - else - { - do - { - mz_uint8 *pWrite_buf_cur = (mz_uint8 *)pWrite_buf + (out_buf_ofs & (TINFL_LZ_DICT_SIZE - 1)); - size_t in_buf_size, out_buf_size = TINFL_LZ_DICT_SIZE - (out_buf_ofs & (TINFL_LZ_DICT_SIZE - 1)); - if ((!read_buf_avail) && (!pZip->m_pState->m_pMem)) - { - read_buf_avail = MZ_MIN(read_buf_size, comp_remaining); - if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pRead_buf, (size_t)read_buf_avail) != read_buf_avail) - { - mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED); - status = TINFL_STATUS_FAILED; - break; - } - cur_file_ofs += read_buf_avail; - comp_remaining -= read_buf_avail; - read_buf_ofs = 0; - } - - in_buf_size = (size_t)read_buf_avail; - status = tinfl_decompress(&inflator, (const mz_uint8 *)pRead_buf + read_buf_ofs, &in_buf_size, (mz_uint8 *)pWrite_buf, pWrite_buf_cur, &out_buf_size, comp_remaining ? TINFL_FLAG_HAS_MORE_INPUT : 0); - read_buf_avail -= in_buf_size; - read_buf_ofs += in_buf_size; - - if (out_buf_size) - { - if (pCallback(pOpaque, out_buf_ofs, pWrite_buf_cur, out_buf_size) != out_buf_size) - { - mz_zip_set_error(pZip, MZ_ZIP_WRITE_CALLBACK_FAILED); - status = TINFL_STATUS_FAILED; - break; - } - -#ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS - file_crc32 = (mz_uint32)mz_crc32(file_crc32, pWrite_buf_cur, out_buf_size); -#endif - if ((out_buf_ofs += out_buf_size) > file_stat.m_uncomp_size) - { - mz_zip_set_error(pZip, MZ_ZIP_DECOMPRESSION_FAILED); - status = TINFL_STATUS_FAILED; - break; - } - } - } while ((status == TINFL_STATUS_NEEDS_MORE_INPUT) || (status == TINFL_STATUS_HAS_MORE_OUTPUT)); - } - } - - if ((status == TINFL_STATUS_DONE) && (!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA))) - { - /* Make sure the entire file was decompressed, and check its CRC. */ - if (out_buf_ofs != file_stat.m_uncomp_size) - { - mz_zip_set_error(pZip, MZ_ZIP_UNEXPECTED_DECOMPRESSED_SIZE); - status = TINFL_STATUS_FAILED; - } -#ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS - else if (file_crc32 != file_stat.m_crc32) - { - mz_zip_set_error(pZip, MZ_ZIP_DECOMPRESSION_FAILED); - status = TINFL_STATUS_FAILED; - } -#endif - } - - if (!pZip->m_pState->m_pMem) - pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); - - if (pWrite_buf) - pZip->m_pFree(pZip->m_pAlloc_opaque, pWrite_buf); - - return status == TINFL_STATUS_DONE; -} - -mz_bool mz_zip_reader_extract_file_to_callback(mz_zip_archive *pZip, const char *pFilename, mz_file_write_func pCallback, void *pOpaque, mz_uint flags) -{ - mz_uint32 file_index; - if (!mz_zip_reader_locate_file_v2(pZip, pFilename, NULL, flags, &file_index)) - return MZ_FALSE; - - return mz_zip_reader_extract_to_callback(pZip, file_index, pCallback, pOpaque, flags); -} - -mz_zip_reader_extract_iter_state* mz_zip_reader_extract_iter_new(mz_zip_archive *pZip, mz_uint file_index, mz_uint flags) -{ - mz_zip_reader_extract_iter_state *pState; - mz_uint32 local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)]; - mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32; - - /* Argument sanity check */ - if ((!pZip) || (!pZip->m_pState)) - return NULL; - - /* Allocate an iterator status structure */ - pState = (mz_zip_reader_extract_iter_state*)pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, sizeof(mz_zip_reader_extract_iter_state)); - if (!pState) - { - mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED); - return NULL; - } - - /* Fetch file details */ - if (!mz_zip_reader_file_stat(pZip, file_index, &pState->file_stat)) - { - pZip->m_pFree(pZip->m_pAlloc_opaque, pState); - return NULL; - } - - /* Encryption and patch files are not supported. */ - if (pState->file_stat.m_bit_flag & (MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_IS_ENCRYPTED | MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_USES_STRONG_ENCRYPTION | MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_COMPRESSED_PATCH_FLAG)) - { - mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_ENCRYPTION); - pZip->m_pFree(pZip->m_pAlloc_opaque, pState); - return NULL; - } - - /* This function only supports decompressing stored and deflate. */ - if ((!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (pState->file_stat.m_method != 0) && (pState->file_stat.m_method != MZ_DEFLATED)) - { - mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_METHOD); - pZip->m_pFree(pZip->m_pAlloc_opaque, pState); - return NULL; - } - - /* Init state - save args */ - pState->pZip = pZip; - pState->flags = flags; - - /* Init state - reset variables to defaults */ - pState->status = TINFL_STATUS_DONE; -#ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS - pState->file_crc32 = MZ_CRC32_INIT; -#endif - pState->read_buf_ofs = 0; - pState->out_buf_ofs = 0; - pState->pRead_buf = NULL; - pState->pWrite_buf = NULL; - pState->out_blk_remain = 0; - - /* Read and parse the local directory entry. */ - pState->cur_file_ofs = pState->file_stat.m_local_header_ofs; - if (pZip->m_pRead(pZip->m_pIO_opaque, pState->cur_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE) - { - mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED); - pZip->m_pFree(pZip->m_pAlloc_opaque, pState); - return NULL; - } - - if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG) - { - mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED); - pZip->m_pFree(pZip->m_pAlloc_opaque, pState); - return NULL; - } - - pState->cur_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS) + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS); - if ((pState->cur_file_ofs + pState->file_stat.m_comp_size) > pZip->m_archive_size) - { - mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED); - pZip->m_pFree(pZip->m_pAlloc_opaque, pState); - return NULL; - } - - /* Decompress the file either directly from memory or from a file input buffer. */ - if (pZip->m_pState->m_pMem) - { - pState->pRead_buf = (mz_uint8 *)pZip->m_pState->m_pMem + pState->cur_file_ofs; - pState->read_buf_size = pState->read_buf_avail = pState->file_stat.m_comp_size; - pState->comp_remaining = pState->file_stat.m_comp_size; - } - else - { - if (!((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) || (!pState->file_stat.m_method))) - { - /* Decompression required, therefore intermediate read buffer required */ - pState->read_buf_size = MZ_MIN(pState->file_stat.m_comp_size, (mz_uint64)MZ_ZIP_MAX_IO_BUF_SIZE); - if (NULL == (pState->pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)pState->read_buf_size))) - { - mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED); - pZip->m_pFree(pZip->m_pAlloc_opaque, pState); - return NULL; - } - } - else - { - /* Decompression not required - we will be reading directly into user buffer, no temp buf required */ - pState->read_buf_size = 0; - } - pState->read_buf_avail = 0; - pState->comp_remaining = pState->file_stat.m_comp_size; - } - - if (!((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) || (!pState->file_stat.m_method))) - { - /* Decompression required, init decompressor */ - tinfl_init( &pState->inflator ); - - /* Allocate write buffer */ - if (NULL == (pState->pWrite_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, TINFL_LZ_DICT_SIZE))) - { - mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED); - if (pState->pRead_buf) - pZip->m_pFree(pZip->m_pAlloc_opaque, pState->pRead_buf); - pZip->m_pFree(pZip->m_pAlloc_opaque, pState); - return NULL; - } - } - - return pState; -} - -mz_zip_reader_extract_iter_state* mz_zip_reader_extract_file_iter_new(mz_zip_archive *pZip, const char *pFilename, mz_uint flags) -{ - mz_uint32 file_index; - - /* Locate file index by name */ - if (!mz_zip_reader_locate_file_v2(pZip, pFilename, NULL, flags, &file_index)) - return NULL; - - /* Construct iterator */ - return mz_zip_reader_extract_iter_new(pZip, file_index, flags); -} - -size_t mz_zip_reader_extract_iter_read(mz_zip_reader_extract_iter_state* pState, void* pvBuf, size_t buf_size) -{ - size_t copied_to_caller = 0; - - /* Argument sanity check */ - if ((!pState) || (!pState->pZip) || (!pState->pZip->m_pState) || (!pvBuf)) - return 0; - - if ((pState->flags & MZ_ZIP_FLAG_COMPRESSED_DATA) || (!pState->file_stat.m_method)) - { - /* The file is stored or the caller has requested the compressed data, calc amount to return. */ - copied_to_caller = (size_t)MZ_MIN( buf_size, pState->comp_remaining ); - - /* Zip is in memory....or requires reading from a file? */ - if (pState->pZip->m_pState->m_pMem) - { - /* Copy data to caller's buffer */ - memcpy( pvBuf, pState->pRead_buf, copied_to_caller ); - pState->pRead_buf = ((mz_uint8*)pState->pRead_buf) + copied_to_caller; - } - else - { - /* Read directly into caller's buffer */ - if (pState->pZip->m_pRead(pState->pZip->m_pIO_opaque, pState->cur_file_ofs, pvBuf, copied_to_caller) != copied_to_caller) - { - /* Failed to read all that was asked for, flag failure and alert user */ - mz_zip_set_error(pState->pZip, MZ_ZIP_FILE_READ_FAILED); - pState->status = TINFL_STATUS_FAILED; - copied_to_caller = 0; - } - } - -#ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS - /* Compute CRC if not returning compressed data only */ - if (!(pState->flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) - pState->file_crc32 = (mz_uint32)mz_crc32(pState->file_crc32, (const mz_uint8 *)pvBuf, copied_to_caller); -#endif - - /* Advance offsets, dec counters */ - pState->cur_file_ofs += copied_to_caller; - pState->out_buf_ofs += copied_to_caller; - pState->comp_remaining -= copied_to_caller; - } - else - { - do - { - /* Calc ptr to write buffer - given current output pos and block size */ - mz_uint8 *pWrite_buf_cur = (mz_uint8 *)pState->pWrite_buf + (pState->out_buf_ofs & (TINFL_LZ_DICT_SIZE - 1)); - - /* Calc max output size - given current output pos and block size */ - size_t in_buf_size, out_buf_size = TINFL_LZ_DICT_SIZE - (pState->out_buf_ofs & (TINFL_LZ_DICT_SIZE - 1)); - - if (!pState->out_blk_remain) - { - /* Read more data from file if none available (and reading from file) */ - if ((!pState->read_buf_avail) && (!pState->pZip->m_pState->m_pMem)) - { - /* Calc read size */ - pState->read_buf_avail = MZ_MIN(pState->read_buf_size, pState->comp_remaining); - if (pState->pZip->m_pRead(pState->pZip->m_pIO_opaque, pState->cur_file_ofs, pState->pRead_buf, (size_t)pState->read_buf_avail) != pState->read_buf_avail) - { - mz_zip_set_error(pState->pZip, MZ_ZIP_FILE_READ_FAILED); - pState->status = TINFL_STATUS_FAILED; - break; - } - - /* Advance offsets, dec counters */ - pState->cur_file_ofs += pState->read_buf_avail; - pState->comp_remaining -= pState->read_buf_avail; - pState->read_buf_ofs = 0; - } - - /* Perform decompression */ - in_buf_size = (size_t)pState->read_buf_avail; - pState->status = tinfl_decompress(&pState->inflator, (const mz_uint8 *)pState->pRead_buf + pState->read_buf_ofs, &in_buf_size, (mz_uint8 *)pState->pWrite_buf, pWrite_buf_cur, &out_buf_size, pState->comp_remaining ? TINFL_FLAG_HAS_MORE_INPUT : 0); - pState->read_buf_avail -= in_buf_size; - pState->read_buf_ofs += in_buf_size; - - /* Update current output block size remaining */ - pState->out_blk_remain = out_buf_size; - } - - if (pState->out_blk_remain) - { - /* Calc amount to return. */ - size_t to_copy = MZ_MIN( (buf_size - copied_to_caller), pState->out_blk_remain ); - - /* Copy data to caller's buffer */ - memcpy( (mz_uint8*)pvBuf + copied_to_caller, pWrite_buf_cur, to_copy ); - -#ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS - /* Perform CRC */ - pState->file_crc32 = (mz_uint32)mz_crc32(pState->file_crc32, pWrite_buf_cur, to_copy); -#endif - - /* Decrement data consumed from block */ - pState->out_blk_remain -= to_copy; - - /* Inc output offset, while performing sanity check */ - if ((pState->out_buf_ofs += to_copy) > pState->file_stat.m_uncomp_size) - { - mz_zip_set_error(pState->pZip, MZ_ZIP_DECOMPRESSION_FAILED); - pState->status = TINFL_STATUS_FAILED; - break; - } - - /* Increment counter of data copied to caller */ - copied_to_caller += to_copy; - } - } while ( (copied_to_caller < buf_size) && ((pState->status == TINFL_STATUS_NEEDS_MORE_INPUT) || (pState->status == TINFL_STATUS_HAS_MORE_OUTPUT)) ); - } - - /* Return how many bytes were copied into user buffer */ - return copied_to_caller; -} - -mz_bool mz_zip_reader_extract_iter_free(mz_zip_reader_extract_iter_state* pState) -{ - int status; - - /* Argument sanity check */ - if ((!pState) || (!pState->pZip) || (!pState->pZip->m_pState)) - return MZ_FALSE; - - /* Was decompression completed and requested? */ - if ((pState->status == TINFL_STATUS_DONE) && (!(pState->flags & MZ_ZIP_FLAG_COMPRESSED_DATA))) - { - /* Make sure the entire file was decompressed, and check its CRC. */ - if (pState->out_buf_ofs != pState->file_stat.m_uncomp_size) - { - mz_zip_set_error(pState->pZip, MZ_ZIP_UNEXPECTED_DECOMPRESSED_SIZE); - pState->status = TINFL_STATUS_FAILED; - } -#ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS - else if (pState->file_crc32 != pState->file_stat.m_crc32) - { - mz_zip_set_error(pState->pZip, MZ_ZIP_DECOMPRESSION_FAILED); - pState->status = TINFL_STATUS_FAILED; - } -#endif - } - - /* Free buffers */ - if (!pState->pZip->m_pState->m_pMem) - pState->pZip->m_pFree(pState->pZip->m_pAlloc_opaque, pState->pRead_buf); - if (pState->pWrite_buf) - pState->pZip->m_pFree(pState->pZip->m_pAlloc_opaque, pState->pWrite_buf); - - /* Save status */ - status = pState->status; - - /* Free context */ - pState->pZip->m_pFree(pState->pZip->m_pAlloc_opaque, pState); - - return status == TINFL_STATUS_DONE; -} - -#ifndef MINIZ_NO_STDIO -static size_t mz_zip_file_write_callback(void *pOpaque, mz_uint64 ofs, const void *pBuf, size_t n) -{ - (void)ofs; - - return MZ_FWRITE(pBuf, 1, n, (MZ_FILE *)pOpaque); -} - -mz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint file_index, const char *pDst_filename, mz_uint flags) -{ - mz_bool status; - mz_zip_archive_file_stat file_stat; - MZ_FILE *pFile; - - if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat)) - return MZ_FALSE; - - if ((file_stat.m_is_directory) || (!file_stat.m_is_supported)) - return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_FEATURE); - - pFile = MZ_FOPEN(pDst_filename, "wb"); - if (!pFile) - return mz_zip_set_error(pZip, MZ_ZIP_FILE_OPEN_FAILED); - - status = mz_zip_reader_extract_to_callback(pZip, file_index, mz_zip_file_write_callback, pFile, flags); - - if (MZ_FCLOSE(pFile) == EOF) - { - if (status) - mz_zip_set_error(pZip, MZ_ZIP_FILE_CLOSE_FAILED); - - status = MZ_FALSE; - } - -#if !defined(MINIZ_NO_TIME) && !defined(MINIZ_NO_STDIO) - if (status) - mz_zip_set_file_times(pDst_filename, file_stat.m_time, file_stat.m_time); -#endif - - return status; -} - -mz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive *pZip, const char *pArchive_filename, const char *pDst_filename, mz_uint flags) -{ - mz_uint32 file_index; - if (!mz_zip_reader_locate_file_v2(pZip, pArchive_filename, NULL, flags, &file_index)) - return MZ_FALSE; - - return mz_zip_reader_extract_to_file(pZip, file_index, pDst_filename, flags); -} - -mz_bool mz_zip_reader_extract_to_cfile(mz_zip_archive *pZip, mz_uint file_index, MZ_FILE *pFile, mz_uint flags) -{ - mz_zip_archive_file_stat file_stat; - - if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat)) - return MZ_FALSE; - - if ((file_stat.m_is_directory) || (!file_stat.m_is_supported)) - return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_FEATURE); - - return mz_zip_reader_extract_to_callback(pZip, file_index, mz_zip_file_write_callback, pFile, flags); -} - -mz_bool mz_zip_reader_extract_file_to_cfile(mz_zip_archive *pZip, const char *pArchive_filename, MZ_FILE *pFile, mz_uint flags) -{ - mz_uint32 file_index; - if (!mz_zip_reader_locate_file_v2(pZip, pArchive_filename, NULL, flags, &file_index)) - return MZ_FALSE; - - return mz_zip_reader_extract_to_cfile(pZip, file_index, pFile, flags); -} -#endif /* #ifndef MINIZ_NO_STDIO */ - -static size_t mz_zip_compute_crc32_callback(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n) -{ - mz_uint32 *p = (mz_uint32 *)pOpaque; - (void)file_ofs; - *p = (mz_uint32)mz_crc32(*p, (const mz_uint8 *)pBuf, n); - return n; -} - -mz_bool mz_zip_validate_file(mz_zip_archive *pZip, mz_uint file_index, mz_uint flags) -{ - mz_zip_archive_file_stat file_stat; - mz_zip_internal_state *pState; - const mz_uint8 *pCentral_dir_header; - mz_bool found_zip64_ext_data_in_cdir = MZ_FALSE; - mz_bool found_zip64_ext_data_in_ldir = MZ_FALSE; - mz_uint32 local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)]; - mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32; - mz_uint64 local_header_ofs = 0; - mz_uint32 local_header_filename_len, local_header_extra_len, local_header_crc32; - mz_uint64 local_header_comp_size, local_header_uncomp_size; - mz_uint32 uncomp_crc32 = MZ_CRC32_INIT; - mz_bool has_data_descriptor; - mz_uint32 local_header_bit_flags; - - mz_zip_array file_data_array; - mz_zip_array_init(&file_data_array, 1); - - if ((!pZip) || (!pZip->m_pState) || (!pZip->m_pAlloc) || (!pZip->m_pFree) || (!pZip->m_pRead)) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - - if (file_index > pZip->m_total_files) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - - pState = pZip->m_pState; - - pCentral_dir_header = mz_zip_get_cdh(pZip, file_index); - - if (!mz_zip_file_stat_internal(pZip, file_index, pCentral_dir_header, &file_stat, &found_zip64_ext_data_in_cdir)) - return MZ_FALSE; - - /* A directory or zero length file */ - if ((file_stat.m_is_directory) || (!file_stat.m_uncomp_size)) - return MZ_TRUE; - - /* Encryption and patch files are not supported. */ - if (file_stat.m_is_encrypted) - return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_ENCRYPTION); - - /* This function only supports stored and deflate. */ - if ((file_stat.m_method != 0) && (file_stat.m_method != MZ_DEFLATED)) - return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_METHOD); - - if (!file_stat.m_is_supported) - return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_FEATURE); - - /* Read and parse the local directory entry. */ - local_header_ofs = file_stat.m_local_header_ofs; - if (pZip->m_pRead(pZip->m_pIO_opaque, local_header_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE) - return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED); - - if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED); - - local_header_filename_len = MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS); - local_header_extra_len = MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS); - local_header_comp_size = MZ_READ_LE32(pLocal_header + MZ_ZIP_LDH_COMPRESSED_SIZE_OFS); - local_header_uncomp_size = MZ_READ_LE32(pLocal_header + MZ_ZIP_LDH_DECOMPRESSED_SIZE_OFS); - local_header_crc32 = MZ_READ_LE32(pLocal_header + MZ_ZIP_LDH_CRC32_OFS); - local_header_bit_flags = MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_BIT_FLAG_OFS); - has_data_descriptor = (local_header_bit_flags & 8) != 0; - - if (local_header_filename_len != strlen(file_stat.m_filename)) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED); - - if ((local_header_ofs + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + local_header_filename_len + local_header_extra_len + file_stat.m_comp_size) > pZip->m_archive_size) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED); - - if (!mz_zip_array_resize(pZip, &file_data_array, MZ_MAX(local_header_filename_len, local_header_extra_len), MZ_FALSE)) - { - mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED); - goto handle_failure; - } - - if (local_header_filename_len) - { - if (pZip->m_pRead(pZip->m_pIO_opaque, local_header_ofs + MZ_ZIP_LOCAL_DIR_HEADER_SIZE, file_data_array.m_p, local_header_filename_len) != local_header_filename_len) - { - mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED); - goto handle_failure; - } - - /* I've seen 1 archive that had the same pathname, but used backslashes in the local dir and forward slashes in the central dir. Do we care about this? For now, this case will fail validation. */ - if (memcmp(file_stat.m_filename, file_data_array.m_p, local_header_filename_len) != 0) - { - mz_zip_set_error(pZip, MZ_ZIP_VALIDATION_FAILED); - goto handle_failure; - } - } - - if ((local_header_extra_len) && ((local_header_comp_size == MZ_UINT32_MAX) || (local_header_uncomp_size == MZ_UINT32_MAX))) - { - mz_uint32 extra_size_remaining = local_header_extra_len; - const mz_uint8 *pExtra_data = (const mz_uint8 *)file_data_array.m_p; - - if (pZip->m_pRead(pZip->m_pIO_opaque, local_header_ofs + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + local_header_filename_len, file_data_array.m_p, local_header_extra_len) != local_header_extra_len) - { - mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED); - goto handle_failure; - } - - do - { - mz_uint32 field_id, field_data_size, field_total_size; - - if (extra_size_remaining < (sizeof(mz_uint16) * 2)) - { - mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED); - goto handle_failure; - } - - field_id = MZ_READ_LE16(pExtra_data); - field_data_size = MZ_READ_LE16(pExtra_data + sizeof(mz_uint16)); - field_total_size = field_data_size + sizeof(mz_uint16) * 2; - - if (field_total_size > extra_size_remaining) - { - mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED); - goto handle_failure; - } - - if (field_id == MZ_ZIP64_EXTENDED_INFORMATION_FIELD_HEADER_ID) - { - const mz_uint8 *pSrc_field_data = pExtra_data + sizeof(mz_uint32); - - if (field_data_size < sizeof(mz_uint64) * 2) - { - mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED); - goto handle_failure; - } - - local_header_uncomp_size = MZ_READ_LE64(pSrc_field_data); - local_header_comp_size = MZ_READ_LE64(pSrc_field_data + sizeof(mz_uint64)); - - found_zip64_ext_data_in_ldir = MZ_TRUE; - break; - } - - pExtra_data += field_total_size; - extra_size_remaining -= field_total_size; - } while (extra_size_remaining); - } - - /* TODO: parse local header extra data when local_header_comp_size is 0xFFFFFFFF! (big_descriptor.zip) */ - /* I've seen zips in the wild with the data descriptor bit set, but proper local header values and bogus data descriptors */ - if ((has_data_descriptor) && (!local_header_comp_size) && (!local_header_crc32)) - { - mz_uint8 descriptor_buf[32]; - mz_bool has_id; - const mz_uint8 *pSrc; - mz_uint32 file_crc32; - mz_uint64 comp_size = 0, uncomp_size = 0; - - mz_uint32 num_descriptor_uint32s = ((pState->m_zip64) || (found_zip64_ext_data_in_ldir)) ? 6 : 4; - - if (pZip->m_pRead(pZip->m_pIO_opaque, local_header_ofs + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + local_header_filename_len + local_header_extra_len + file_stat.m_comp_size, descriptor_buf, sizeof(mz_uint32) * num_descriptor_uint32s) != (sizeof(mz_uint32) * num_descriptor_uint32s)) - { - mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED); - goto handle_failure; - } - - has_id = (MZ_READ_LE32(descriptor_buf) == MZ_ZIP_DATA_DESCRIPTOR_ID); - pSrc = has_id ? (descriptor_buf + sizeof(mz_uint32)) : descriptor_buf; - - file_crc32 = MZ_READ_LE32(pSrc); - - if ((pState->m_zip64) || (found_zip64_ext_data_in_ldir)) - { - comp_size = MZ_READ_LE64(pSrc + sizeof(mz_uint32)); - uncomp_size = MZ_READ_LE64(pSrc + sizeof(mz_uint32) + sizeof(mz_uint64)); - } - else - { - comp_size = MZ_READ_LE32(pSrc + sizeof(mz_uint32)); - uncomp_size = MZ_READ_LE32(pSrc + sizeof(mz_uint32) + sizeof(mz_uint32)); - } - - if ((file_crc32 != file_stat.m_crc32) || (comp_size != file_stat.m_comp_size) || (uncomp_size != file_stat.m_uncomp_size)) - { - mz_zip_set_error(pZip, MZ_ZIP_VALIDATION_FAILED); - goto handle_failure; - } - } - else - { - if ((local_header_crc32 != file_stat.m_crc32) || (local_header_comp_size != file_stat.m_comp_size) || (local_header_uncomp_size != file_stat.m_uncomp_size)) - { - mz_zip_set_error(pZip, MZ_ZIP_VALIDATION_FAILED); - goto handle_failure; - } - } - - mz_zip_array_clear(pZip, &file_data_array); - - if ((flags & MZ_ZIP_FLAG_VALIDATE_HEADERS_ONLY) == 0) - { - if (!mz_zip_reader_extract_to_callback(pZip, file_index, mz_zip_compute_crc32_callback, &uncomp_crc32, 0)) - return MZ_FALSE; - - /* 1 more check to be sure, although the extract checks too. */ - if (uncomp_crc32 != file_stat.m_crc32) - { - mz_zip_set_error(pZip, MZ_ZIP_VALIDATION_FAILED); - return MZ_FALSE; - } - } - - return MZ_TRUE; - -handle_failure: - mz_zip_array_clear(pZip, &file_data_array); - return MZ_FALSE; -} - -mz_bool mz_zip_validate_archive(mz_zip_archive *pZip, mz_uint flags) -{ - mz_zip_internal_state *pState; - mz_uint32 i; - - if ((!pZip) || (!pZip->m_pState) || (!pZip->m_pAlloc) || (!pZip->m_pFree) || (!pZip->m_pRead)) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - - pState = pZip->m_pState; - - /* Basic sanity checks */ - if (!pState->m_zip64) - { - if (pZip->m_total_files > MZ_UINT16_MAX) - return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE); - - if (pZip->m_archive_size > MZ_UINT32_MAX) - return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE); - } - else - { - if (pState->m_central_dir.m_size >= MZ_UINT32_MAX) - return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE); - } - - for (i = 0; i < pZip->m_total_files; i++) - { - if (MZ_ZIP_FLAG_VALIDATE_LOCATE_FILE_FLAG & flags) - { - mz_uint32 found_index; - mz_zip_archive_file_stat stat; - - if (!mz_zip_reader_file_stat(pZip, i, &stat)) - return MZ_FALSE; - - if (!mz_zip_reader_locate_file_v2(pZip, stat.m_filename, NULL, 0, &found_index)) - return MZ_FALSE; - - /* This check can fail if there are duplicate filenames in the archive (which we don't check for when writing - that's up to the user) */ - if (found_index != i) - return mz_zip_set_error(pZip, MZ_ZIP_VALIDATION_FAILED); - } - - if (!mz_zip_validate_file(pZip, i, flags)) - return MZ_FALSE; - } - - return MZ_TRUE; -} - -mz_bool mz_zip_validate_mem_archive(const void *pMem, size_t size, mz_uint flags, mz_zip_error *pErr) -{ - mz_bool success = MZ_TRUE; - mz_zip_archive zip; - mz_zip_error actual_err = MZ_ZIP_NO_ERROR; - - if ((!pMem) || (!size)) - { - if (pErr) - *pErr = MZ_ZIP_INVALID_PARAMETER; - return MZ_FALSE; - } - - mz_zip_zero_struct(&zip); - - if (!mz_zip_reader_init_mem(&zip, pMem, size, flags)) - { - if (pErr) - *pErr = zip.m_last_error; - return MZ_FALSE; - } - - if (!mz_zip_validate_archive(&zip, flags)) - { - actual_err = zip.m_last_error; - success = MZ_FALSE; - } - - if (!mz_zip_reader_end_internal(&zip, success)) - { - if (!actual_err) - actual_err = zip.m_last_error; - success = MZ_FALSE; - } - - if (pErr) - *pErr = actual_err; - - return success; -} - -#ifndef MINIZ_NO_STDIO -mz_bool mz_zip_validate_file_archive(const char *pFilename, mz_uint flags, mz_zip_error *pErr) -{ - mz_bool success = MZ_TRUE; - mz_zip_archive zip; - mz_zip_error actual_err = MZ_ZIP_NO_ERROR; - - if (!pFilename) - { - if (pErr) - *pErr = MZ_ZIP_INVALID_PARAMETER; - return MZ_FALSE; - } - - mz_zip_zero_struct(&zip); - - if (!mz_zip_reader_init_file_v2(&zip, pFilename, flags, 0, 0)) - { - if (pErr) - *pErr = zip.m_last_error; - return MZ_FALSE; - } - - if (!mz_zip_validate_archive(&zip, flags)) - { - actual_err = zip.m_last_error; - success = MZ_FALSE; - } - - if (!mz_zip_reader_end_internal(&zip, success)) - { - if (!actual_err) - actual_err = zip.m_last_error; - success = MZ_FALSE; - } - - if (pErr) - *pErr = actual_err; - - return success; -} -#endif /* #ifndef MINIZ_NO_STDIO */ - -/* ------------------- .ZIP archive writing */ - -#ifndef MINIZ_NO_ARCHIVE_WRITING_APIS - -static MZ_FORCEINLINE void mz_write_le16(mz_uint8 *p, mz_uint16 v) -{ - p[0] = (mz_uint8)v; - p[1] = (mz_uint8)(v >> 8); -} -static MZ_FORCEINLINE void mz_write_le32(mz_uint8 *p, mz_uint32 v) -{ - p[0] = (mz_uint8)v; - p[1] = (mz_uint8)(v >> 8); - p[2] = (mz_uint8)(v >> 16); - p[3] = (mz_uint8)(v >> 24); -} -static MZ_FORCEINLINE void mz_write_le64(mz_uint8 *p, mz_uint64 v) -{ - mz_write_le32(p, (mz_uint32)v); - mz_write_le32(p + sizeof(mz_uint32), (mz_uint32)(v >> 32)); -} - -#define MZ_WRITE_LE16(p, v) mz_write_le16((mz_uint8 *)(p), (mz_uint16)(v)) -#define MZ_WRITE_LE32(p, v) mz_write_le32((mz_uint8 *)(p), (mz_uint32)(v)) -#define MZ_WRITE_LE64(p, v) mz_write_le64((mz_uint8 *)(p), (mz_uint64)(v)) - -static size_t mz_zip_heap_write_func(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n) -{ - mz_zip_archive *pZip = (mz_zip_archive *)pOpaque; - mz_zip_internal_state *pState = pZip->m_pState; - mz_uint64 new_size = MZ_MAX(file_ofs + n, pState->m_mem_size); - - if (!n) - return 0; - - /* An allocation this big is likely to just fail on 32-bit systems, so don't even go there. */ - if ((sizeof(size_t) == sizeof(mz_uint32)) && (new_size > 0x7FFFFFFF)) - { - mz_zip_set_error(pZip, MZ_ZIP_FILE_TOO_LARGE); - return 0; - } - - if (new_size > pState->m_mem_capacity) - { - void *pNew_block; - size_t new_capacity = MZ_MAX(64, pState->m_mem_capacity); - - while (new_capacity < new_size) - new_capacity *= 2; - - if (NULL == (pNew_block = pZip->m_pRealloc(pZip->m_pAlloc_opaque, pState->m_pMem, 1, new_capacity))) - { - mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED); - return 0; - } - - pState->m_pMem = pNew_block; - pState->m_mem_capacity = new_capacity; - } - memcpy((mz_uint8 *)pState->m_pMem + file_ofs, pBuf, n); - pState->m_mem_size = (size_t)new_size; - return n; -} - -static mz_bool mz_zip_writer_end_internal(mz_zip_archive *pZip, mz_bool set_last_error) -{ - mz_zip_internal_state *pState; - mz_bool status = MZ_TRUE; - - if ((!pZip) || (!pZip->m_pState) || (!pZip->m_pAlloc) || (!pZip->m_pFree) || ((pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) && (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED))) - { - if (set_last_error) - mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - return MZ_FALSE; - } - - pState = pZip->m_pState; - pZip->m_pState = NULL; - mz_zip_array_clear(pZip, &pState->m_central_dir); - mz_zip_array_clear(pZip, &pState->m_central_dir_offsets); - mz_zip_array_clear(pZip, &pState->m_sorted_central_dir_offsets); - -#ifndef MINIZ_NO_STDIO - if (pState->m_pFile) - { - if (pZip->m_zip_type == MZ_ZIP_TYPE_FILE) - { - if (MZ_FCLOSE(pState->m_pFile) == EOF) - { - if (set_last_error) - mz_zip_set_error(pZip, MZ_ZIP_FILE_CLOSE_FAILED); - status = MZ_FALSE; - } - } - - pState->m_pFile = NULL; - } -#endif /* #ifndef MINIZ_NO_STDIO */ - - if ((pZip->m_pWrite == mz_zip_heap_write_func) && (pState->m_pMem)) - { - pZip->m_pFree(pZip->m_pAlloc_opaque, pState->m_pMem); - pState->m_pMem = NULL; - } - - pZip->m_pFree(pZip->m_pAlloc_opaque, pState); - pZip->m_zip_mode = MZ_ZIP_MODE_INVALID; - return status; -} - -mz_bool mz_zip_writer_init_v2(mz_zip_archive *pZip, mz_uint64 existing_size, mz_uint flags) -{ - mz_bool zip64 = (flags & MZ_ZIP_FLAG_WRITE_ZIP64) != 0; - - if ((!pZip) || (pZip->m_pState) || (!pZip->m_pWrite) || (pZip->m_zip_mode != MZ_ZIP_MODE_INVALID)) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - - if (flags & MZ_ZIP_FLAG_WRITE_ALLOW_READING) - { - if (!pZip->m_pRead) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - } - - if (pZip->m_file_offset_alignment) - { - /* Ensure user specified file offset alignment is a power of 2. */ - if (pZip->m_file_offset_alignment & (pZip->m_file_offset_alignment - 1)) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - } - - if (!pZip->m_pAlloc) - pZip->m_pAlloc = miniz_def_alloc_func; - if (!pZip->m_pFree) - pZip->m_pFree = miniz_def_free_func; - if (!pZip->m_pRealloc) - pZip->m_pRealloc = miniz_def_realloc_func; - - pZip->m_archive_size = existing_size; - pZip->m_central_directory_file_ofs = 0; - pZip->m_total_files = 0; - - if (NULL == (pZip->m_pState = (mz_zip_internal_state *)pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, sizeof(mz_zip_internal_state)))) - return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED); - - memset(pZip->m_pState, 0, sizeof(mz_zip_internal_state)); - - MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir, sizeof(mz_uint8)); - MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir_offsets, sizeof(mz_uint32)); - MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_sorted_central_dir_offsets, sizeof(mz_uint32)); - - pZip->m_pState->m_zip64 = zip64; - pZip->m_pState->m_zip64_has_extended_info_fields = zip64; - - pZip->m_zip_type = MZ_ZIP_TYPE_USER; - pZip->m_zip_mode = MZ_ZIP_MODE_WRITING; - - return MZ_TRUE; -} - -mz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size) -{ - return mz_zip_writer_init_v2(pZip, existing_size, 0); -} - -mz_bool mz_zip_writer_init_heap_v2(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size, mz_uint flags) -{ - pZip->m_pWrite = mz_zip_heap_write_func; - pZip->m_pNeeds_keepalive = NULL; - - if (flags & MZ_ZIP_FLAG_WRITE_ALLOW_READING) - pZip->m_pRead = mz_zip_mem_read_func; - - pZip->m_pIO_opaque = pZip; - - if (!mz_zip_writer_init_v2(pZip, size_to_reserve_at_beginning, flags)) - return MZ_FALSE; - - pZip->m_zip_type = MZ_ZIP_TYPE_HEAP; - - if (0 != (initial_allocation_size = MZ_MAX(initial_allocation_size, size_to_reserve_at_beginning))) - { - if (NULL == (pZip->m_pState->m_pMem = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, initial_allocation_size))) - { - mz_zip_writer_end_internal(pZip, MZ_FALSE); - return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED); - } - pZip->m_pState->m_mem_capacity = initial_allocation_size; - } - - return MZ_TRUE; -} - -mz_bool mz_zip_writer_init_heap(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size) -{ - return mz_zip_writer_init_heap_v2(pZip, size_to_reserve_at_beginning, initial_allocation_size, 0); -} - -#ifndef MINIZ_NO_STDIO -static size_t mz_zip_file_write_func(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n) -{ - mz_zip_archive *pZip = (mz_zip_archive *)pOpaque; - mz_int64 cur_ofs = MZ_FTELL64(pZip->m_pState->m_pFile); - - file_ofs += pZip->m_pState->m_file_archive_start_ofs; - - if (((mz_int64)file_ofs < 0) || (((cur_ofs != (mz_int64)file_ofs)) && (MZ_FSEEK64(pZip->m_pState->m_pFile, (mz_int64)file_ofs, SEEK_SET)))) - { - mz_zip_set_error(pZip, MZ_ZIP_FILE_SEEK_FAILED); - return 0; - } - - return MZ_FWRITE(pBuf, 1, n, pZip->m_pState->m_pFile); -} - -mz_bool mz_zip_writer_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint64 size_to_reserve_at_beginning) -{ - return mz_zip_writer_init_file_v2(pZip, pFilename, size_to_reserve_at_beginning, 0); -} - -mz_bool mz_zip_writer_init_file_v2(mz_zip_archive *pZip, const char *pFilename, mz_uint64 size_to_reserve_at_beginning, mz_uint flags) -{ - MZ_FILE *pFile; - - pZip->m_pWrite = mz_zip_file_write_func; - pZip->m_pNeeds_keepalive = NULL; - - if (flags & MZ_ZIP_FLAG_WRITE_ALLOW_READING) - pZip->m_pRead = mz_zip_file_read_func; - - pZip->m_pIO_opaque = pZip; - - if (!mz_zip_writer_init_v2(pZip, size_to_reserve_at_beginning, flags)) - return MZ_FALSE; - - if (NULL == (pFile = MZ_FOPEN(pFilename, (flags & MZ_ZIP_FLAG_WRITE_ALLOW_READING) ? "w+b" : "wb"))) - { - mz_zip_writer_end(pZip); - return mz_zip_set_error(pZip, MZ_ZIP_FILE_OPEN_FAILED); - } - - pZip->m_pState->m_pFile = pFile; - pZip->m_zip_type = MZ_ZIP_TYPE_FILE; - - if (size_to_reserve_at_beginning) - { - mz_uint64 cur_ofs = 0; - char buf[4096]; - - MZ_CLEAR_ARR(buf); - - do - { - size_t n = (size_t)MZ_MIN(sizeof(buf), size_to_reserve_at_beginning); - if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_ofs, buf, n) != n) - { - mz_zip_writer_end(pZip); - return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED); - } - cur_ofs += n; - size_to_reserve_at_beginning -= n; - } while (size_to_reserve_at_beginning); - } - - return MZ_TRUE; -} - -mz_bool mz_zip_writer_init_cfile(mz_zip_archive *pZip, MZ_FILE *pFile, mz_uint flags) -{ - pZip->m_pWrite = mz_zip_file_write_func; - pZip->m_pNeeds_keepalive = NULL; - - if (flags & MZ_ZIP_FLAG_WRITE_ALLOW_READING) - pZip->m_pRead = mz_zip_file_read_func; - - pZip->m_pIO_opaque = pZip; - - if (!mz_zip_writer_init_v2(pZip, 0, flags)) - return MZ_FALSE; - - pZip->m_pState->m_pFile = pFile; - pZip->m_pState->m_file_archive_start_ofs = MZ_FTELL64(pZip->m_pState->m_pFile); - pZip->m_zip_type = MZ_ZIP_TYPE_CFILE; - - return MZ_TRUE; -} -#endif /* #ifndef MINIZ_NO_STDIO */ - -mz_bool mz_zip_writer_init_from_reader_v2(mz_zip_archive *pZip, const char *pFilename, mz_uint flags) -{ - mz_zip_internal_state *pState; - - if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_READING)) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - - if (flags & MZ_ZIP_FLAG_WRITE_ZIP64) - { - /* We don't support converting a non-zip64 file to zip64 - this seems like more trouble than it's worth. (What about the existing 32-bit data descriptors that could follow the compressed data?) */ - if (!pZip->m_pState->m_zip64) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - } - - /* No sense in trying to write to an archive that's already at the support max size */ - if (pZip->m_pState->m_zip64) - { - if (pZip->m_total_files == MZ_UINT32_MAX) - return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES); - } - else - { - if (pZip->m_total_files == MZ_UINT16_MAX) - return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES); - - if ((pZip->m_archive_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + MZ_ZIP_LOCAL_DIR_HEADER_SIZE) > MZ_UINT32_MAX) - return mz_zip_set_error(pZip, MZ_ZIP_FILE_TOO_LARGE); - } - - pState = pZip->m_pState; - - if (pState->m_pFile) - { -#ifdef MINIZ_NO_STDIO - (void)pFilename; - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); -#else - if (pZip->m_pIO_opaque != pZip) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - - if (pZip->m_zip_type == MZ_ZIP_TYPE_FILE) - { - if (!pFilename) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - - /* Archive is being read from stdio and was originally opened only for reading. Try to reopen as writable. */ - if (NULL == (pState->m_pFile = MZ_FREOPEN(pFilename, "r+b", pState->m_pFile))) - { - /* The mz_zip_archive is now in a bogus state because pState->m_pFile is NULL, so just close it. */ - mz_zip_reader_end_internal(pZip, MZ_FALSE); - return mz_zip_set_error(pZip, MZ_ZIP_FILE_OPEN_FAILED); - } - } - - pZip->m_pWrite = mz_zip_file_write_func; - pZip->m_pNeeds_keepalive = NULL; -#endif /* #ifdef MINIZ_NO_STDIO */ - } - else if (pState->m_pMem) - { - /* Archive lives in a memory block. Assume it's from the heap that we can resize using the realloc callback. */ - if (pZip->m_pIO_opaque != pZip) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - - pState->m_mem_capacity = pState->m_mem_size; - pZip->m_pWrite = mz_zip_heap_write_func; - pZip->m_pNeeds_keepalive = NULL; - } - /* Archive is being read via a user provided read function - make sure the user has specified a write function too. */ - else if (!pZip->m_pWrite) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - - /* Start writing new files at the archive's current central directory location. */ - /* TODO: We could add a flag that lets the user start writing immediately AFTER the existing central dir - this would be safer. */ - pZip->m_archive_size = pZip->m_central_directory_file_ofs; - pZip->m_central_directory_file_ofs = 0; - - /* Clear the sorted central dir offsets, they aren't useful or maintained now. */ - /* Even though we're now in write mode, files can still be extracted and verified, but file locates will be slow. */ - /* TODO: We could easily maintain the sorted central directory offsets. */ - mz_zip_array_clear(pZip, &pZip->m_pState->m_sorted_central_dir_offsets); - - pZip->m_zip_mode = MZ_ZIP_MODE_WRITING; - - return MZ_TRUE; -} - -mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip, const char *pFilename) -{ - return mz_zip_writer_init_from_reader_v2(pZip, pFilename, 0); -} - -/* TODO: pArchive_name is a terrible name here! */ -mz_bool mz_zip_writer_add_mem(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, mz_uint level_and_flags) -{ - return mz_zip_writer_add_mem_ex(pZip, pArchive_name, pBuf, buf_size, NULL, 0, level_and_flags, 0, 0); -} - -typedef struct -{ - mz_zip_archive *m_pZip; - mz_uint64 m_cur_archive_file_ofs; - mz_uint64 m_comp_size; -} mz_zip_writer_add_state; - -static mz_bool mz_zip_writer_add_put_buf_callback(const void *pBuf, int len, void *pUser) -{ - mz_zip_writer_add_state *pState = (mz_zip_writer_add_state *)pUser; - if ((int)pState->m_pZip->m_pWrite(pState->m_pZip->m_pIO_opaque, pState->m_cur_archive_file_ofs, pBuf, len) != len) - return MZ_FALSE; - - pState->m_cur_archive_file_ofs += len; - pState->m_comp_size += len; - return MZ_TRUE; -} - -#define MZ_ZIP64_MAX_LOCAL_EXTRA_FIELD_SIZE (sizeof(mz_uint16) * 2 + sizeof(mz_uint64) * 2) -#define MZ_ZIP64_MAX_CENTRAL_EXTRA_FIELD_SIZE (sizeof(mz_uint16) * 2 + sizeof(mz_uint64) * 3) -static mz_uint32 mz_zip_writer_create_zip64_extra_data(mz_uint8 *pBuf, mz_uint64 *pUncomp_size, mz_uint64 *pComp_size, mz_uint64 *pLocal_header_ofs) -{ - mz_uint8 *pDst = pBuf; - mz_uint32 field_size = 0; - - MZ_WRITE_LE16(pDst + 0, MZ_ZIP64_EXTENDED_INFORMATION_FIELD_HEADER_ID); - MZ_WRITE_LE16(pDst + 2, 0); - pDst += sizeof(mz_uint16) * 2; - - if (pUncomp_size) - { - MZ_WRITE_LE64(pDst, *pUncomp_size); - pDst += sizeof(mz_uint64); - field_size += sizeof(mz_uint64); - } - - if (pComp_size) - { - MZ_WRITE_LE64(pDst, *pComp_size); - pDst += sizeof(mz_uint64); - field_size += sizeof(mz_uint64); - } - - if (pLocal_header_ofs) - { - MZ_WRITE_LE64(pDst, *pLocal_header_ofs); - pDst += sizeof(mz_uint64); - field_size += sizeof(mz_uint64); - } - - MZ_WRITE_LE16(pBuf + 2, field_size); - - return (mz_uint32)(pDst - pBuf); -} - -static mz_bool mz_zip_writer_create_local_dir_header(mz_zip_archive *pZip, mz_uint8 *pDst, mz_uint16 filename_size, mz_uint16 extra_size, mz_uint64 uncomp_size, mz_uint64 comp_size, mz_uint32 uncomp_crc32, mz_uint16 method, mz_uint16 bit_flags, mz_uint16 dos_time, mz_uint16 dos_date) -{ - (void)pZip; - memset(pDst, 0, MZ_ZIP_LOCAL_DIR_HEADER_SIZE); - MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_SIG_OFS, MZ_ZIP_LOCAL_DIR_HEADER_SIG); - MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_VERSION_NEEDED_OFS, method ? 20 : 0); - MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_BIT_FLAG_OFS, bit_flags); - MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_METHOD_OFS, method); - MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_FILE_TIME_OFS, dos_time); - MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_FILE_DATE_OFS, dos_date); - MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_CRC32_OFS, uncomp_crc32); - MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_COMPRESSED_SIZE_OFS, MZ_MIN(comp_size, MZ_UINT32_MAX)); - MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_DECOMPRESSED_SIZE_OFS, MZ_MIN(uncomp_size, MZ_UINT32_MAX)); - MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_FILENAME_LEN_OFS, filename_size); - MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_EXTRA_LEN_OFS, extra_size); - return MZ_TRUE; -} - -static mz_bool mz_zip_writer_create_central_dir_header(mz_zip_archive *pZip, mz_uint8 *pDst, - mz_uint16 filename_size, mz_uint16 extra_size, mz_uint16 comment_size, - mz_uint64 uncomp_size, mz_uint64 comp_size, mz_uint32 uncomp_crc32, - mz_uint16 method, mz_uint16 bit_flags, mz_uint16 dos_time, mz_uint16 dos_date, - mz_uint64 local_header_ofs, mz_uint32 ext_attributes) -{ - (void)pZip; - memset(pDst, 0, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE); - MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_SIG_OFS, MZ_ZIP_CENTRAL_DIR_HEADER_SIG); - MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_VERSION_NEEDED_OFS, method ? 20 : 0); - MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_BIT_FLAG_OFS, bit_flags); - MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_METHOD_OFS, method); - MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_FILE_TIME_OFS, dos_time); - MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_FILE_DATE_OFS, dos_date); - MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_CRC32_OFS, uncomp_crc32); - MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS, MZ_MIN(comp_size, MZ_UINT32_MAX)); - MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS, MZ_MIN(uncomp_size, MZ_UINT32_MAX)); - MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_FILENAME_LEN_OFS, filename_size); - MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_EXTRA_LEN_OFS, extra_size); - MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_COMMENT_LEN_OFS, comment_size); - MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS, ext_attributes); - MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_LOCAL_HEADER_OFS, MZ_MIN(local_header_ofs, MZ_UINT32_MAX)); - return MZ_TRUE; -} - -static mz_bool mz_zip_writer_add_to_central_dir(mz_zip_archive *pZip, const char *pFilename, mz_uint16 filename_size, - const void *pExtra, mz_uint16 extra_size, const void *pComment, mz_uint16 comment_size, - mz_uint64 uncomp_size, mz_uint64 comp_size, mz_uint32 uncomp_crc32, - mz_uint16 method, mz_uint16 bit_flags, mz_uint16 dos_time, mz_uint16 dos_date, - mz_uint64 local_header_ofs, mz_uint32 ext_attributes, - const char *user_extra_data, mz_uint user_extra_data_len) -{ - mz_zip_internal_state *pState = pZip->m_pState; - mz_uint32 central_dir_ofs = (mz_uint32)pState->m_central_dir.m_size; - size_t orig_central_dir_size = pState->m_central_dir.m_size; - mz_uint8 central_dir_header[MZ_ZIP_CENTRAL_DIR_HEADER_SIZE]; - - if (!pZip->m_pState->m_zip64) - { - if (local_header_ofs > 0xFFFFFFFF) - return mz_zip_set_error(pZip, MZ_ZIP_FILE_TOO_LARGE); - } - - /* miniz doesn't support central dirs >= MZ_UINT32_MAX bytes yet */ - if (((mz_uint64)pState->m_central_dir.m_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + filename_size + extra_size + user_extra_data_len + comment_size) >= MZ_UINT32_MAX) - return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_CDIR_SIZE); - - if (!mz_zip_writer_create_central_dir_header(pZip, central_dir_header, filename_size, (mz_uint16)(extra_size + user_extra_data_len), comment_size, uncomp_size, comp_size, uncomp_crc32, method, bit_flags, dos_time, dos_date, local_header_ofs, ext_attributes)) - return mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR); - - if ((!mz_zip_array_push_back(pZip, &pState->m_central_dir, central_dir_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE)) || - (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pFilename, filename_size)) || - (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pExtra, extra_size)) || - (!mz_zip_array_push_back(pZip, &pState->m_central_dir, user_extra_data, user_extra_data_len)) || - (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pComment, comment_size)) || - (!mz_zip_array_push_back(pZip, &pState->m_central_dir_offsets, ¢ral_dir_ofs, 1))) - { - /* Try to resize the central directory array back into its original state. */ - mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE); - return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED); - } - - return MZ_TRUE; -} - -static mz_bool mz_zip_writer_validate_archive_name(const char *pArchive_name) -{ - /* Basic ZIP archive filename validity checks: Valid filenames cannot start with a forward slash, cannot contain a drive letter, and cannot use DOS-style backward slashes. */ - if (*pArchive_name == '/') - return MZ_FALSE; - - /* Making sure the name does not contain drive letters or DOS style backward slashes is the responsibility of the program using miniz*/ - - return MZ_TRUE; -} - -static mz_uint mz_zip_writer_compute_padding_needed_for_file_alignment(mz_zip_archive *pZip) -{ - mz_uint32 n; - if (!pZip->m_file_offset_alignment) - return 0; - n = (mz_uint32)(pZip->m_archive_size & (pZip->m_file_offset_alignment - 1)); - return (mz_uint)((pZip->m_file_offset_alignment - n) & (pZip->m_file_offset_alignment - 1)); -} - -static mz_bool mz_zip_writer_write_zeros(mz_zip_archive *pZip, mz_uint64 cur_file_ofs, mz_uint32 n) -{ - char buf[4096]; - memset(buf, 0, MZ_MIN(sizeof(buf), n)); - while (n) - { - mz_uint32 s = MZ_MIN(sizeof(buf), n); - if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_file_ofs, buf, s) != s) - return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED); - - cur_file_ofs += s; - n -= s; - } - return MZ_TRUE; -} - -mz_bool mz_zip_writer_add_mem_ex(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, - mz_uint64 uncomp_size, mz_uint32 uncomp_crc32) -{ - return mz_zip_writer_add_mem_ex_v2(pZip, pArchive_name, pBuf, buf_size, pComment, comment_size, level_and_flags, uncomp_size, uncomp_crc32, NULL, NULL, 0, NULL, 0); -} - -mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, - mz_uint level_and_flags, mz_uint64 uncomp_size, mz_uint32 uncomp_crc32, MZ_TIME_T *last_modified, - const char *user_extra_data, mz_uint user_extra_data_len, const char *user_extra_data_central, mz_uint user_extra_data_central_len) -{ - mz_uint16 method = 0, dos_time = 0, dos_date = 0; - mz_uint level, ext_attributes = 0, num_alignment_padding_bytes; - mz_uint64 local_dir_header_ofs = pZip->m_archive_size, cur_archive_file_ofs = pZip->m_archive_size, comp_size = 0; - size_t archive_name_size; - mz_uint8 local_dir_header[MZ_ZIP_LOCAL_DIR_HEADER_SIZE]; - tdefl_compressor *pComp = NULL; - mz_bool store_data_uncompressed; - mz_zip_internal_state *pState; - mz_uint8 *pExtra_data = NULL; - mz_uint32 extra_size = 0; - mz_uint8 extra_data[MZ_ZIP64_MAX_CENTRAL_EXTRA_FIELD_SIZE]; - mz_uint16 bit_flags = 0; - - if ((int)level_and_flags < 0) - level_and_flags = MZ_DEFAULT_LEVEL; - - if (uncomp_size || (buf_size && !(level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA))) - bit_flags |= MZ_ZIP_LDH_BIT_FLAG_HAS_LOCATOR; - - if (!(level_and_flags & MZ_ZIP_FLAG_ASCII_FILENAME)) - bit_flags |= MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_UTF8; - - level = level_and_flags & 0xF; - store_data_uncompressed = ((!level) || (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)); - - if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) || ((buf_size) && (!pBuf)) || (!pArchive_name) || ((comment_size) && (!pComment)) || (level > MZ_UBER_COMPRESSION)) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - - pState = pZip->m_pState; - - if (pState->m_zip64) - { - if (pZip->m_total_files == MZ_UINT32_MAX) - return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES); - } - else - { - if (pZip->m_total_files == MZ_UINT16_MAX) - { - pState->m_zip64 = MZ_TRUE; - /*return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES); */ - } - if (((mz_uint64)buf_size > 0xFFFFFFFF) || (uncomp_size > 0xFFFFFFFF)) - { - pState->m_zip64 = MZ_TRUE; - /*return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE); */ - } - } - - if ((!(level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (uncomp_size)) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - - if (!mz_zip_writer_validate_archive_name(pArchive_name)) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_FILENAME); - -#ifndef MINIZ_NO_TIME - if (last_modified != NULL) - { - mz_zip_time_t_to_dos_time(*last_modified, &dos_time, &dos_date); - } - else - { - MZ_TIME_T cur_time; - time(&cur_time); - mz_zip_time_t_to_dos_time(cur_time, &dos_time, &dos_date); - } -#endif /* #ifndef MINIZ_NO_TIME */ - - if (!(level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) - { - uncomp_crc32 = (mz_uint32)mz_crc32(MZ_CRC32_INIT, (const mz_uint8 *)pBuf, buf_size); - uncomp_size = buf_size; - if (uncomp_size <= 3) - { - level = 0; - store_data_uncompressed = MZ_TRUE; - } - } - - archive_name_size = strlen(pArchive_name); - if (archive_name_size > MZ_UINT16_MAX) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_FILENAME); - - num_alignment_padding_bytes = mz_zip_writer_compute_padding_needed_for_file_alignment(pZip); - - /* miniz doesn't support central dirs >= MZ_UINT32_MAX bytes yet */ - if (((mz_uint64)pState->m_central_dir.m_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + archive_name_size + MZ_ZIP64_MAX_CENTRAL_EXTRA_FIELD_SIZE + comment_size) >= MZ_UINT32_MAX) - return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_CDIR_SIZE); - - if (!pState->m_zip64) - { - /* Bail early if the archive would obviously become too large */ - if ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + archive_name_size - + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + archive_name_size + comment_size + user_extra_data_len + - pState->m_central_dir.m_size + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE + user_extra_data_central_len - + MZ_ZIP_DATA_DESCRIPTER_SIZE32) > 0xFFFFFFFF) - { - pState->m_zip64 = MZ_TRUE; - /*return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE); */ - } - } - - if ((archive_name_size) && (pArchive_name[archive_name_size - 1] == '/')) - { - /* Set DOS Subdirectory attribute bit. */ - ext_attributes |= MZ_ZIP_DOS_DIR_ATTRIBUTE_BITFLAG; - - /* Subdirectories cannot contain data. */ - if ((buf_size) || (uncomp_size)) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - } - - /* Try to do any allocations before writing to the archive, so if an allocation fails the file remains unmodified. (A good idea if we're doing an in-place modification.) */ - if ((!mz_zip_array_ensure_room(pZip, &pState->m_central_dir, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + archive_name_size + comment_size + (pState->m_zip64 ? MZ_ZIP64_MAX_CENTRAL_EXTRA_FIELD_SIZE : 0))) || (!mz_zip_array_ensure_room(pZip, &pState->m_central_dir_offsets, 1))) - return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED); - - if ((!store_data_uncompressed) && (buf_size)) - { - if (NULL == (pComp = (tdefl_compressor *)pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, sizeof(tdefl_compressor)))) - return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED); - } - - if (!mz_zip_writer_write_zeros(pZip, cur_archive_file_ofs, num_alignment_padding_bytes)) - { - pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); - return MZ_FALSE; - } - - local_dir_header_ofs += num_alignment_padding_bytes; - if (pZip->m_file_offset_alignment) - { - MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) == 0); - } - cur_archive_file_ofs += num_alignment_padding_bytes; - - MZ_CLEAR_ARR(local_dir_header); - - if (!store_data_uncompressed || (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) - { - method = MZ_DEFLATED; - } - - if (pState->m_zip64) - { - if (uncomp_size >= MZ_UINT32_MAX || local_dir_header_ofs >= MZ_UINT32_MAX) - { - pExtra_data = extra_data; - extra_size = mz_zip_writer_create_zip64_extra_data(extra_data, (uncomp_size >= MZ_UINT32_MAX) ? &uncomp_size : NULL, - (uncomp_size >= MZ_UINT32_MAX) ? &comp_size : NULL, (local_dir_header_ofs >= MZ_UINT32_MAX) ? &local_dir_header_ofs : NULL); - } - - if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, (mz_uint16)(extra_size + user_extra_data_len), 0, 0, 0, method, bit_flags, dos_time, dos_date)) - return mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR); - - if (pZip->m_pWrite(pZip->m_pIO_opaque, local_dir_header_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header)) - return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED); - - cur_archive_file_ofs += sizeof(local_dir_header); - - if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size) - { - pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); - return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED); - } - cur_archive_file_ofs += archive_name_size; - - if (pExtra_data != NULL) - { - if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, extra_data, extra_size) != extra_size) - return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED); - - cur_archive_file_ofs += extra_size; - } - } - else - { - if ((comp_size > MZ_UINT32_MAX) || (cur_archive_file_ofs > MZ_UINT32_MAX)) - return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE); - if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, (mz_uint16)user_extra_data_len, 0, 0, 0, method, bit_flags, dos_time, dos_date)) - return mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR); - - if (pZip->m_pWrite(pZip->m_pIO_opaque, local_dir_header_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header)) - return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED); - - cur_archive_file_ofs += sizeof(local_dir_header); - - if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size) - { - pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); - return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED); - } - cur_archive_file_ofs += archive_name_size; - } - - if (user_extra_data_len > 0) - { - if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, user_extra_data, user_extra_data_len) != user_extra_data_len) - return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED); - - cur_archive_file_ofs += user_extra_data_len; - } - - if (store_data_uncompressed) - { - if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pBuf, buf_size) != buf_size) - { - pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); - return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED); - } - - cur_archive_file_ofs += buf_size; - comp_size = buf_size; - } - else if (buf_size) - { - mz_zip_writer_add_state state; - - state.m_pZip = pZip; - state.m_cur_archive_file_ofs = cur_archive_file_ofs; - state.m_comp_size = 0; - - if ((tdefl_init(pComp, mz_zip_writer_add_put_buf_callback, &state, tdefl_create_comp_flags_from_zip_params(level, -15, MZ_DEFAULT_STRATEGY)) != TDEFL_STATUS_OKAY) || - (tdefl_compress_buffer(pComp, pBuf, buf_size, TDEFL_FINISH) != TDEFL_STATUS_DONE)) - { - pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); - return mz_zip_set_error(pZip, MZ_ZIP_COMPRESSION_FAILED); - } - - comp_size = state.m_comp_size; - cur_archive_file_ofs = state.m_cur_archive_file_ofs; - } - - pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); - pComp = NULL; - - if (uncomp_size) - { - mz_uint8 local_dir_footer[MZ_ZIP_DATA_DESCRIPTER_SIZE64]; - mz_uint32 local_dir_footer_size = MZ_ZIP_DATA_DESCRIPTER_SIZE32; - - MZ_ASSERT(bit_flags & MZ_ZIP_LDH_BIT_FLAG_HAS_LOCATOR); - - MZ_WRITE_LE32(local_dir_footer + 0, MZ_ZIP_DATA_DESCRIPTOR_ID); - MZ_WRITE_LE32(local_dir_footer + 4, uncomp_crc32); - if (pExtra_data == NULL) - { - if (comp_size > MZ_UINT32_MAX) - return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE); - - MZ_WRITE_LE32(local_dir_footer + 8, comp_size); - MZ_WRITE_LE32(local_dir_footer + 12, uncomp_size); - } - else - { - MZ_WRITE_LE64(local_dir_footer + 8, comp_size); - MZ_WRITE_LE64(local_dir_footer + 16, uncomp_size); - local_dir_footer_size = MZ_ZIP_DATA_DESCRIPTER_SIZE64; - } - - if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, local_dir_footer, local_dir_footer_size) != local_dir_footer_size) - return MZ_FALSE; - - cur_archive_file_ofs += local_dir_footer_size; - } - - if (pExtra_data != NULL) - { - extra_size = mz_zip_writer_create_zip64_extra_data(extra_data, (uncomp_size >= MZ_UINT32_MAX) ? &uncomp_size : NULL, - (uncomp_size >= MZ_UINT32_MAX) ? &comp_size : NULL, (local_dir_header_ofs >= MZ_UINT32_MAX) ? &local_dir_header_ofs : NULL); - } - - if (!mz_zip_writer_add_to_central_dir(pZip, pArchive_name, (mz_uint16)archive_name_size, pExtra_data, (mz_uint16)extra_size, pComment, - comment_size, uncomp_size, comp_size, uncomp_crc32, method, bit_flags, dos_time, dos_date, local_dir_header_ofs, ext_attributes, - user_extra_data_central, user_extra_data_central_len)) - return MZ_FALSE; - - pZip->m_total_files++; - pZip->m_archive_size = cur_archive_file_ofs; - - return MZ_TRUE; -} - -mz_bool mz_zip_writer_add_read_buf_callback(mz_zip_archive *pZip, const char *pArchive_name, mz_file_read_func read_callback, void* callback_opaque, mz_uint64 max_size, const MZ_TIME_T *pFile_time, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, - const char *user_extra_data, mz_uint user_extra_data_len, const char *user_extra_data_central, mz_uint user_extra_data_central_len) -{ - mz_uint16 gen_flags; - mz_uint uncomp_crc32 = MZ_CRC32_INIT, level, num_alignment_padding_bytes; - mz_uint16 method = 0, dos_time = 0, dos_date = 0, ext_attributes = 0; - mz_uint64 local_dir_header_ofs, cur_archive_file_ofs = pZip->m_archive_size, uncomp_size = 0, comp_size = 0; - size_t archive_name_size; - mz_uint8 local_dir_header[MZ_ZIP_LOCAL_DIR_HEADER_SIZE]; - mz_uint8 *pExtra_data = NULL; - mz_uint32 extra_size = 0; - mz_uint8 extra_data[MZ_ZIP64_MAX_CENTRAL_EXTRA_FIELD_SIZE]; - mz_zip_internal_state *pState; - mz_uint64 file_ofs = 0, cur_archive_header_file_ofs; - - if ((int)level_and_flags < 0) - level_and_flags = MZ_DEFAULT_LEVEL; - level = level_and_flags & 0xF; - - gen_flags = (level_and_flags & MZ_ZIP_FLAG_WRITE_HEADER_SET_SIZE) ? 0 : MZ_ZIP_LDH_BIT_FLAG_HAS_LOCATOR; - - if (!(level_and_flags & MZ_ZIP_FLAG_ASCII_FILENAME)) - gen_flags |= MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_UTF8; - - /* Sanity checks */ - if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) || (!pArchive_name) || ((comment_size) && (!pComment)) || (level > MZ_UBER_COMPRESSION)) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - - pState = pZip->m_pState; - - if ((!pState->m_zip64) && (max_size > MZ_UINT32_MAX)) - { - /* Source file is too large for non-zip64 */ - /*return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE); */ - pState->m_zip64 = MZ_TRUE; - } - - /* We could support this, but why? */ - if (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - - if (!mz_zip_writer_validate_archive_name(pArchive_name)) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_FILENAME); - - if (pState->m_zip64) - { - if (pZip->m_total_files == MZ_UINT32_MAX) - return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES); - } - else - { - if (pZip->m_total_files == MZ_UINT16_MAX) - { - pState->m_zip64 = MZ_TRUE; - /*return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES); */ - } - } - - archive_name_size = strlen(pArchive_name); - if (archive_name_size > MZ_UINT16_MAX) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_FILENAME); - - num_alignment_padding_bytes = mz_zip_writer_compute_padding_needed_for_file_alignment(pZip); - - /* miniz doesn't support central dirs >= MZ_UINT32_MAX bytes yet */ - if (((mz_uint64)pState->m_central_dir.m_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + archive_name_size + MZ_ZIP64_MAX_CENTRAL_EXTRA_FIELD_SIZE + comment_size) >= MZ_UINT32_MAX) - return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_CDIR_SIZE); - - if (!pState->m_zip64) - { - /* Bail early if the archive would obviously become too large */ - if ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + archive_name_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE - + archive_name_size + comment_size + user_extra_data_len + pState->m_central_dir.m_size + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE + 1024 - + MZ_ZIP_DATA_DESCRIPTER_SIZE32 + user_extra_data_central_len) > 0xFFFFFFFF) - { - pState->m_zip64 = MZ_TRUE; - /*return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE); */ - } - } - -#ifndef MINIZ_NO_TIME - if (pFile_time) - { - mz_zip_time_t_to_dos_time(*pFile_time, &dos_time, &dos_date); - } -#endif - - if (max_size <= 3) - level = 0; - - if (!mz_zip_writer_write_zeros(pZip, cur_archive_file_ofs, num_alignment_padding_bytes)) - { - return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED); - } - - cur_archive_file_ofs += num_alignment_padding_bytes; - local_dir_header_ofs = cur_archive_file_ofs; - - if (pZip->m_file_offset_alignment) - { - MZ_ASSERT((cur_archive_file_ofs & (pZip->m_file_offset_alignment - 1)) == 0); - } - - if (max_size && level) - { - method = MZ_DEFLATED; - } - - MZ_CLEAR_ARR(local_dir_header); - if (pState->m_zip64) - { - if (max_size >= MZ_UINT32_MAX || local_dir_header_ofs >= MZ_UINT32_MAX) - { - pExtra_data = extra_data; - if (level_and_flags & MZ_ZIP_FLAG_WRITE_HEADER_SET_SIZE) - extra_size = mz_zip_writer_create_zip64_extra_data(extra_data, (max_size >= MZ_UINT32_MAX) ? &uncomp_size : NULL, - (max_size >= MZ_UINT32_MAX) ? &comp_size : NULL, - (local_dir_header_ofs >= MZ_UINT32_MAX) ? &local_dir_header_ofs : NULL); - else - extra_size = mz_zip_writer_create_zip64_extra_data(extra_data, NULL, - NULL, - (local_dir_header_ofs >= MZ_UINT32_MAX) ? &local_dir_header_ofs : NULL); - } - - if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, (mz_uint16)(extra_size + user_extra_data_len), 0, 0, 0, method, gen_flags, dos_time, dos_date)) - return mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR); - - if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header)) - return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED); - - cur_archive_file_ofs += sizeof(local_dir_header); - - if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size) - { - return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED); - } - - cur_archive_file_ofs += archive_name_size; - - if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, extra_data, extra_size) != extra_size) - return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED); - - cur_archive_file_ofs += extra_size; - } - else - { - if ((comp_size > MZ_UINT32_MAX) || (cur_archive_file_ofs > MZ_UINT32_MAX)) - return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE); - if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, (mz_uint16)user_extra_data_len, 0, 0, 0, method, gen_flags, dos_time, dos_date)) - return mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR); - - if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header)) - return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED); - - cur_archive_file_ofs += sizeof(local_dir_header); - - if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size) - { - return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED); - } - - cur_archive_file_ofs += archive_name_size; - } - - if (user_extra_data_len > 0) - { - if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, user_extra_data, user_extra_data_len) != user_extra_data_len) - return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED); - - cur_archive_file_ofs += user_extra_data_len; - } - - if (max_size) - { - void *pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, MZ_ZIP_MAX_IO_BUF_SIZE); - if (!pRead_buf) - { - return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED); - } - - if (!level) - { - while (1) - { - size_t n = read_callback(callback_opaque, file_ofs, pRead_buf, MZ_ZIP_MAX_IO_BUF_SIZE); - if (n == 0) - break; - - if ((n > MZ_ZIP_MAX_IO_BUF_SIZE) || (file_ofs + n > max_size)) - { - pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); - return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED); - } - if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pRead_buf, n) != n) - { - pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); - return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED); - } - file_ofs += n; - uncomp_crc32 = (mz_uint32)mz_crc32(uncomp_crc32, (const mz_uint8 *)pRead_buf, n); - cur_archive_file_ofs += n; - } - uncomp_size = file_ofs; - comp_size = uncomp_size; - } - else - { - mz_bool result = MZ_FALSE; - mz_zip_writer_add_state state; - tdefl_compressor *pComp = (tdefl_compressor *)pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, sizeof(tdefl_compressor)); - if (!pComp) - { - pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); - return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED); - } - - state.m_pZip = pZip; - state.m_cur_archive_file_ofs = cur_archive_file_ofs; - state.m_comp_size = 0; - - if (tdefl_init(pComp, mz_zip_writer_add_put_buf_callback, &state, tdefl_create_comp_flags_from_zip_params(level, -15, MZ_DEFAULT_STRATEGY)) != TDEFL_STATUS_OKAY) - { - pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); - pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); - return mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR); - } - - for (;;) - { - tdefl_status status; - tdefl_flush flush = TDEFL_NO_FLUSH; - - size_t n = read_callback(callback_opaque, file_ofs, pRead_buf, MZ_ZIP_MAX_IO_BUF_SIZE); - if ((n > MZ_ZIP_MAX_IO_BUF_SIZE) || (file_ofs + n > max_size)) - { - mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED); - break; - } - - file_ofs += n; - uncomp_crc32 = (mz_uint32)mz_crc32(uncomp_crc32, (const mz_uint8 *)pRead_buf, n); - - if (pZip->m_pNeeds_keepalive != NULL && pZip->m_pNeeds_keepalive(pZip->m_pIO_opaque)) - flush = TDEFL_FULL_FLUSH; - - if (n == 0) - flush = TDEFL_FINISH; - - status = tdefl_compress_buffer(pComp, pRead_buf, n, flush); - if (status == TDEFL_STATUS_DONE) - { - result = MZ_TRUE; - break; - } - else if (status != TDEFL_STATUS_OKAY) - { - mz_zip_set_error(pZip, MZ_ZIP_COMPRESSION_FAILED); - break; - } - } - - pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); - - if (!result) - { - pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); - return MZ_FALSE; - } - - uncomp_size = file_ofs; - comp_size = state.m_comp_size; - cur_archive_file_ofs = state.m_cur_archive_file_ofs; - } - - pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); - } - - if (!(level_and_flags & MZ_ZIP_FLAG_WRITE_HEADER_SET_SIZE)) - { - mz_uint8 local_dir_footer[MZ_ZIP_DATA_DESCRIPTER_SIZE64]; - mz_uint32 local_dir_footer_size = MZ_ZIP_DATA_DESCRIPTER_SIZE32; - - MZ_WRITE_LE32(local_dir_footer + 0, MZ_ZIP_DATA_DESCRIPTOR_ID); - MZ_WRITE_LE32(local_dir_footer + 4, uncomp_crc32); - if (pExtra_data == NULL) - { - if (comp_size > MZ_UINT32_MAX) - return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE); - - MZ_WRITE_LE32(local_dir_footer + 8, comp_size); - MZ_WRITE_LE32(local_dir_footer + 12, uncomp_size); - } - else - { - MZ_WRITE_LE64(local_dir_footer + 8, comp_size); - MZ_WRITE_LE64(local_dir_footer + 16, uncomp_size); - local_dir_footer_size = MZ_ZIP_DATA_DESCRIPTER_SIZE64; - } - - if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, local_dir_footer, local_dir_footer_size) != local_dir_footer_size) - return MZ_FALSE; - - cur_archive_file_ofs += local_dir_footer_size; - } - - if (level_and_flags & MZ_ZIP_FLAG_WRITE_HEADER_SET_SIZE) - { - if (pExtra_data != NULL) - { - extra_size = mz_zip_writer_create_zip64_extra_data(extra_data, (max_size >= MZ_UINT32_MAX) ? &uncomp_size : NULL, - (max_size >= MZ_UINT32_MAX) ? &comp_size : NULL, (local_dir_header_ofs >= MZ_UINT32_MAX) ? &local_dir_header_ofs : NULL); - } - - if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, - (mz_uint16)archive_name_size, (mz_uint16)(extra_size + user_extra_data_len), - (max_size >= MZ_UINT32_MAX) ? MZ_UINT32_MAX : uncomp_size, - (max_size >= MZ_UINT32_MAX) ? MZ_UINT32_MAX : comp_size, - uncomp_crc32, method, gen_flags, dos_time, dos_date)) - return mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR); - - cur_archive_header_file_ofs = local_dir_header_ofs; - - if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_header_file_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header)) - return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED); - - if (pExtra_data != NULL) - { - cur_archive_header_file_ofs += sizeof(local_dir_header); - - if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_header_file_ofs, pArchive_name, archive_name_size) != archive_name_size) - { - return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED); - } - - cur_archive_header_file_ofs += archive_name_size; - - if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_header_file_ofs, extra_data, extra_size) != extra_size) - return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED); - - cur_archive_header_file_ofs += extra_size; - } - } - - if (pExtra_data != NULL) - { - extra_size = mz_zip_writer_create_zip64_extra_data(extra_data, (uncomp_size >= MZ_UINT32_MAX) ? &uncomp_size : NULL, - (uncomp_size >= MZ_UINT32_MAX) ? &comp_size : NULL, (local_dir_header_ofs >= MZ_UINT32_MAX) ? &local_dir_header_ofs : NULL); - } - - if (!mz_zip_writer_add_to_central_dir(pZip, pArchive_name, (mz_uint16)archive_name_size, pExtra_data, (mz_uint16)extra_size, pComment, comment_size, - uncomp_size, comp_size, uncomp_crc32, method, gen_flags, dos_time, dos_date, local_dir_header_ofs, ext_attributes, - user_extra_data_central, user_extra_data_central_len)) - return MZ_FALSE; - - pZip->m_total_files++; - pZip->m_archive_size = cur_archive_file_ofs; - - return MZ_TRUE; -} - -#ifndef MINIZ_NO_STDIO - -static size_t mz_file_read_func_stdio(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n) -{ - MZ_FILE *pSrc_file = (MZ_FILE *)pOpaque; - mz_int64 cur_ofs = MZ_FTELL64(pSrc_file); - - if (((mz_int64)file_ofs < 0) || (((cur_ofs != (mz_int64)file_ofs)) && (MZ_FSEEK64(pSrc_file, (mz_int64)file_ofs, SEEK_SET)))) - return 0; - - return MZ_FREAD(pBuf, 1, n, pSrc_file); -} - -mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name, MZ_FILE *pSrc_file, mz_uint64 max_size, const MZ_TIME_T *pFile_time, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, - const char *user_extra_data, mz_uint user_extra_data_len, const char *user_extra_data_central, mz_uint user_extra_data_central_len) -{ - return mz_zip_writer_add_read_buf_callback(pZip, pArchive_name, mz_file_read_func_stdio, pSrc_file, max_size, pFile_time, pComment, comment_size, level_and_flags, - user_extra_data, user_extra_data_len, user_extra_data_central, user_extra_data_central_len); -} - -mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name, const char *pSrc_filename, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags) -{ - MZ_FILE *pSrc_file = NULL; - mz_uint64 uncomp_size = 0; - MZ_TIME_T file_modified_time; - MZ_TIME_T *pFile_time = NULL; - mz_bool status; - - memset(&file_modified_time, 0, sizeof(file_modified_time)); - -#if !defined(MINIZ_NO_TIME) && !defined(MINIZ_NO_STDIO) - pFile_time = &file_modified_time; - if (!mz_zip_get_file_modified_time(pSrc_filename, &file_modified_time)) - return mz_zip_set_error(pZip, MZ_ZIP_FILE_STAT_FAILED); -#endif - - pSrc_file = MZ_FOPEN(pSrc_filename, "rb"); - if (!pSrc_file) - return mz_zip_set_error(pZip, MZ_ZIP_FILE_OPEN_FAILED); - - MZ_FSEEK64(pSrc_file, 0, SEEK_END); - uncomp_size = MZ_FTELL64(pSrc_file); - MZ_FSEEK64(pSrc_file, 0, SEEK_SET); - - status = mz_zip_writer_add_cfile(pZip, pArchive_name, pSrc_file, uncomp_size, pFile_time, pComment, comment_size, level_and_flags, NULL, 0, NULL, 0); - - MZ_FCLOSE(pSrc_file); - - return status; -} -#endif /* #ifndef MINIZ_NO_STDIO */ - -static mz_bool mz_zip_writer_update_zip64_extension_block(mz_zip_array *pNew_ext, mz_zip_archive *pZip, const mz_uint8 *pExt, mz_uint32 ext_len, mz_uint64 *pComp_size, mz_uint64 *pUncomp_size, mz_uint64 *pLocal_header_ofs, mz_uint32 *pDisk_start) -{ - /* + 64 should be enough for any new zip64 data */ - if (!mz_zip_array_reserve(pZip, pNew_ext, ext_len + 64, MZ_FALSE)) - return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED); - - mz_zip_array_resize(pZip, pNew_ext, 0, MZ_FALSE); - - if ((pUncomp_size) || (pComp_size) || (pLocal_header_ofs) || (pDisk_start)) - { - mz_uint8 new_ext_block[64]; - mz_uint8 *pDst = new_ext_block; - mz_write_le16(pDst, MZ_ZIP64_EXTENDED_INFORMATION_FIELD_HEADER_ID); - mz_write_le16(pDst + sizeof(mz_uint16), 0); - pDst += sizeof(mz_uint16) * 2; - - if (pUncomp_size) - { - mz_write_le64(pDst, *pUncomp_size); - pDst += sizeof(mz_uint64); - } - - if (pComp_size) - { - mz_write_le64(pDst, *pComp_size); - pDst += sizeof(mz_uint64); - } - - if (pLocal_header_ofs) - { - mz_write_le64(pDst, *pLocal_header_ofs); - pDst += sizeof(mz_uint64); - } - - if (pDisk_start) - { - mz_write_le32(pDst, *pDisk_start); - pDst += sizeof(mz_uint32); - } - - mz_write_le16(new_ext_block + sizeof(mz_uint16), (mz_uint16)((pDst - new_ext_block) - sizeof(mz_uint16) * 2)); - - if (!mz_zip_array_push_back(pZip, pNew_ext, new_ext_block, pDst - new_ext_block)) - return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED); - } - - if ((pExt) && (ext_len)) - { - mz_uint32 extra_size_remaining = ext_len; - const mz_uint8 *pExtra_data = pExt; - - do - { - mz_uint32 field_id, field_data_size, field_total_size; - - if (extra_size_remaining < (sizeof(mz_uint16) * 2)) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED); - - field_id = MZ_READ_LE16(pExtra_data); - field_data_size = MZ_READ_LE16(pExtra_data + sizeof(mz_uint16)); - field_total_size = field_data_size + sizeof(mz_uint16) * 2; - - if (field_total_size > extra_size_remaining) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED); - - if (field_id != MZ_ZIP64_EXTENDED_INFORMATION_FIELD_HEADER_ID) - { - if (!mz_zip_array_push_back(pZip, pNew_ext, pExtra_data, field_total_size)) - return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED); - } - - pExtra_data += field_total_size; - extra_size_remaining -= field_total_size; - } while (extra_size_remaining); - } - - return MZ_TRUE; -} - -/* TODO: This func is now pretty freakin complex due to zip64, split it up? */ -mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive *pSource_zip, mz_uint src_file_index) -{ - mz_uint n, bit_flags, num_alignment_padding_bytes, src_central_dir_following_data_size; - mz_uint64 src_archive_bytes_remaining, local_dir_header_ofs; - mz_uint64 cur_src_file_ofs, cur_dst_file_ofs; - mz_uint32 local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)]; - mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32; - mz_uint8 new_central_header[MZ_ZIP_CENTRAL_DIR_HEADER_SIZE]; - size_t orig_central_dir_size; - mz_zip_internal_state *pState; - void *pBuf; - const mz_uint8 *pSrc_central_header; - mz_zip_archive_file_stat src_file_stat; - mz_uint32 src_filename_len, src_comment_len, src_ext_len; - mz_uint32 local_header_filename_size, local_header_extra_len; - mz_uint64 local_header_comp_size, local_header_uncomp_size; - mz_bool found_zip64_ext_data_in_ldir = MZ_FALSE; - - /* Sanity checks */ - if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) || (!pSource_zip->m_pRead)) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - - pState = pZip->m_pState; - - /* Don't support copying files from zip64 archives to non-zip64, even though in some cases this is possible */ - if ((pSource_zip->m_pState->m_zip64) && (!pZip->m_pState->m_zip64)) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - - /* Get pointer to the source central dir header and crack it */ - if (NULL == (pSrc_central_header = mz_zip_get_cdh(pSource_zip, src_file_index))) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - - if (MZ_READ_LE32(pSrc_central_header + MZ_ZIP_CDH_SIG_OFS) != MZ_ZIP_CENTRAL_DIR_HEADER_SIG) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED); - - src_filename_len = MZ_READ_LE16(pSrc_central_header + MZ_ZIP_CDH_FILENAME_LEN_OFS); - src_comment_len = MZ_READ_LE16(pSrc_central_header + MZ_ZIP_CDH_COMMENT_LEN_OFS); - src_ext_len = MZ_READ_LE16(pSrc_central_header + MZ_ZIP_CDH_EXTRA_LEN_OFS); - src_central_dir_following_data_size = src_filename_len + src_ext_len + src_comment_len; - - /* TODO: We don't support central dir's >= MZ_UINT32_MAX bytes right now (+32 fudge factor in case we need to add more extra data) */ - if ((pState->m_central_dir.m_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + src_central_dir_following_data_size + 32) >= MZ_UINT32_MAX) - return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_CDIR_SIZE); - - num_alignment_padding_bytes = mz_zip_writer_compute_padding_needed_for_file_alignment(pZip); - - if (!pState->m_zip64) - { - if (pZip->m_total_files == MZ_UINT16_MAX) - return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES); - } - else - { - /* TODO: Our zip64 support still has some 32-bit limits that may not be worth fixing. */ - if (pZip->m_total_files == MZ_UINT32_MAX) - return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES); - } - - if (!mz_zip_file_stat_internal(pSource_zip, src_file_index, pSrc_central_header, &src_file_stat, NULL)) - return MZ_FALSE; - - cur_src_file_ofs = src_file_stat.m_local_header_ofs; - cur_dst_file_ofs = pZip->m_archive_size; - - /* Read the source archive's local dir header */ - if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE) - return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED); - - if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED); - - cur_src_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE; - - /* Compute the total size we need to copy (filename+extra data+compressed data) */ - local_header_filename_size = MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS); - local_header_extra_len = MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS); - local_header_comp_size = MZ_READ_LE32(pLocal_header + MZ_ZIP_LDH_COMPRESSED_SIZE_OFS); - local_header_uncomp_size = MZ_READ_LE32(pLocal_header + MZ_ZIP_LDH_DECOMPRESSED_SIZE_OFS); - src_archive_bytes_remaining = local_header_filename_size + local_header_extra_len + src_file_stat.m_comp_size; - - /* Try to find a zip64 extended information field */ - if ((local_header_extra_len) && ((local_header_comp_size == MZ_UINT32_MAX) || (local_header_uncomp_size == MZ_UINT32_MAX))) - { - mz_zip_array file_data_array; - const mz_uint8 *pExtra_data; - mz_uint32 extra_size_remaining = local_header_extra_len; - - mz_zip_array_init(&file_data_array, 1); - if (!mz_zip_array_resize(pZip, &file_data_array, local_header_extra_len, MZ_FALSE)) - { - return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED); - } - - if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, src_file_stat.m_local_header_ofs + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + local_header_filename_size, file_data_array.m_p, local_header_extra_len) != local_header_extra_len) - { - mz_zip_array_clear(pZip, &file_data_array); - return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED); - } - - pExtra_data = (const mz_uint8 *)file_data_array.m_p; - - do - { - mz_uint32 field_id, field_data_size, field_total_size; - - if (extra_size_remaining < (sizeof(mz_uint16) * 2)) - { - mz_zip_array_clear(pZip, &file_data_array); - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED); - } - - field_id = MZ_READ_LE16(pExtra_data); - field_data_size = MZ_READ_LE16(pExtra_data + sizeof(mz_uint16)); - field_total_size = field_data_size + sizeof(mz_uint16) * 2; - - if (field_total_size > extra_size_remaining) - { - mz_zip_array_clear(pZip, &file_data_array); - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED); - } - - if (field_id == MZ_ZIP64_EXTENDED_INFORMATION_FIELD_HEADER_ID) - { - const mz_uint8 *pSrc_field_data = pExtra_data + sizeof(mz_uint32); - - if (field_data_size < sizeof(mz_uint64) * 2) - { - mz_zip_array_clear(pZip, &file_data_array); - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED); - } - - local_header_uncomp_size = MZ_READ_LE64(pSrc_field_data); - local_header_comp_size = MZ_READ_LE64(pSrc_field_data + sizeof(mz_uint64)); /* may be 0 if there's a descriptor */ - - found_zip64_ext_data_in_ldir = MZ_TRUE; - break; - } - - pExtra_data += field_total_size; - extra_size_remaining -= field_total_size; - } while (extra_size_remaining); - - mz_zip_array_clear(pZip, &file_data_array); - } - - if (!pState->m_zip64) - { - /* Try to detect if the new archive will most likely wind up too big and bail early (+(sizeof(mz_uint32) * 4) is for the optional descriptor which could be present, +64 is a fudge factor). */ - /* We also check when the archive is finalized so this doesn't need to be perfect. */ - mz_uint64 approx_new_archive_size = cur_dst_file_ofs + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + src_archive_bytes_remaining + (sizeof(mz_uint32) * 4) + - pState->m_central_dir.m_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + src_central_dir_following_data_size + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE + 64; - - if (approx_new_archive_size >= MZ_UINT32_MAX) - return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE); - } - - /* Write dest archive padding */ - if (!mz_zip_writer_write_zeros(pZip, cur_dst_file_ofs, num_alignment_padding_bytes)) - return MZ_FALSE; - - cur_dst_file_ofs += num_alignment_padding_bytes; - - local_dir_header_ofs = cur_dst_file_ofs; - if (pZip->m_file_offset_alignment) - { - MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) == 0); - } - - /* The original zip's local header+ext block doesn't change, even with zip64, so we can just copy it over to the dest zip */ - if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE) - return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED); - - cur_dst_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE; - - /* Copy over the source archive bytes to the dest archive, also ensure we have enough buf space to handle optional data descriptor */ - if (NULL == (pBuf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)MZ_MAX(32U, MZ_MIN((mz_uint64)MZ_ZIP_MAX_IO_BUF_SIZE, src_archive_bytes_remaining))))) - return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED); - - while (src_archive_bytes_remaining) - { - n = (mz_uint)MZ_MIN((mz_uint64)MZ_ZIP_MAX_IO_BUF_SIZE, src_archive_bytes_remaining); - if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pBuf, n) != n) - { - pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); - return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED); - } - cur_src_file_ofs += n; - - if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pBuf, n) != n) - { - pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); - return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED); - } - cur_dst_file_ofs += n; - - src_archive_bytes_remaining -= n; - } - - /* Now deal with the optional data descriptor */ - bit_flags = MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_BIT_FLAG_OFS); - if (bit_flags & 8) - { - /* Copy data descriptor */ - if ((pSource_zip->m_pState->m_zip64) || (found_zip64_ext_data_in_ldir)) - { - /* src is zip64, dest must be zip64 */ - - /* name uint32_t's */ - /* id 1 (optional in zip64?) */ - /* crc 1 */ - /* comp_size 2 */ - /* uncomp_size 2 */ - if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pBuf, (sizeof(mz_uint32) * 6)) != (sizeof(mz_uint32) * 6)) - { - pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); - return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED); - } - - n = sizeof(mz_uint32) * ((MZ_READ_LE32(pBuf) == MZ_ZIP_DATA_DESCRIPTOR_ID) ? 6 : 5); - } - else - { - /* src is NOT zip64 */ - mz_bool has_id; - - if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pBuf, sizeof(mz_uint32) * 4) != sizeof(mz_uint32) * 4) - { - pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); - return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED); - } - - has_id = (MZ_READ_LE32(pBuf) == MZ_ZIP_DATA_DESCRIPTOR_ID); - - if (pZip->m_pState->m_zip64) - { - /* dest is zip64, so upgrade the data descriptor */ - const mz_uint8 *pSrc_descriptor = (const mz_uint8 *)pBuf + (has_id ? sizeof(mz_uint32) : 0); - const mz_uint32 src_crc32 = MZ_READ_LE32(pSrc_descriptor); - const mz_uint64 src_comp_size = MZ_READ_LE32(pSrc_descriptor + sizeof(mz_uint32)); - const mz_uint64 src_uncomp_size = MZ_READ_LE32(pSrc_descriptor + 2*sizeof(mz_uint32)); - - mz_write_le32((mz_uint8 *)pBuf, MZ_ZIP_DATA_DESCRIPTOR_ID); - mz_write_le32((mz_uint8 *)pBuf + sizeof(mz_uint32) * 1, src_crc32); - mz_write_le64((mz_uint8 *)pBuf + sizeof(mz_uint32) * 2, src_comp_size); - mz_write_le64((mz_uint8 *)pBuf + sizeof(mz_uint32) * 4, src_uncomp_size); - - n = sizeof(mz_uint32) * 6; - } - else - { - /* dest is NOT zip64, just copy it as-is */ - n = sizeof(mz_uint32) * (has_id ? 4 : 3); - } - } - - if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pBuf, n) != n) - { - pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); - return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED); - } - - cur_src_file_ofs += n; - cur_dst_file_ofs += n; - } - pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); - - /* Finally, add the new central dir header */ - orig_central_dir_size = pState->m_central_dir.m_size; - - memcpy(new_central_header, pSrc_central_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE); - - if (pState->m_zip64) - { - /* This is the painful part: We need to write a new central dir header + ext block with updated zip64 fields, and ensure the old fields (if any) are not included. */ - const mz_uint8 *pSrc_ext = pSrc_central_header + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + src_filename_len; - mz_zip_array new_ext_block; - - mz_zip_array_init(&new_ext_block, sizeof(mz_uint8)); - - MZ_WRITE_LE32(new_central_header + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS, MZ_UINT32_MAX); - MZ_WRITE_LE32(new_central_header + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS, MZ_UINT32_MAX); - MZ_WRITE_LE32(new_central_header + MZ_ZIP_CDH_LOCAL_HEADER_OFS, MZ_UINT32_MAX); - - if (!mz_zip_writer_update_zip64_extension_block(&new_ext_block, pZip, pSrc_ext, src_ext_len, &src_file_stat.m_comp_size, &src_file_stat.m_uncomp_size, &local_dir_header_ofs, NULL)) - { - mz_zip_array_clear(pZip, &new_ext_block); - return MZ_FALSE; - } - - MZ_WRITE_LE16(new_central_header + MZ_ZIP_CDH_EXTRA_LEN_OFS, new_ext_block.m_size); - - if (!mz_zip_array_push_back(pZip, &pState->m_central_dir, new_central_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE)) - { - mz_zip_array_clear(pZip, &new_ext_block); - return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED); - } - - if (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pSrc_central_header + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, src_filename_len)) - { - mz_zip_array_clear(pZip, &new_ext_block); - mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE); - return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED); - } - - if (!mz_zip_array_push_back(pZip, &pState->m_central_dir, new_ext_block.m_p, new_ext_block.m_size)) - { - mz_zip_array_clear(pZip, &new_ext_block); - mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE); - return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED); - } - - if (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pSrc_central_header + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + src_filename_len + src_ext_len, src_comment_len)) - { - mz_zip_array_clear(pZip, &new_ext_block); - mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE); - return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED); - } - - mz_zip_array_clear(pZip, &new_ext_block); - } - else - { - /* sanity checks */ - if (cur_dst_file_ofs > MZ_UINT32_MAX) - return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE); - - if (local_dir_header_ofs >= MZ_UINT32_MAX) - return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE); - - MZ_WRITE_LE32(new_central_header + MZ_ZIP_CDH_LOCAL_HEADER_OFS, local_dir_header_ofs); - - if (!mz_zip_array_push_back(pZip, &pState->m_central_dir, new_central_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE)) - return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED); - - if (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pSrc_central_header + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, src_central_dir_following_data_size)) - { - mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE); - return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED); - } - } - - /* This shouldn't trigger unless we screwed up during the initial sanity checks */ - if (pState->m_central_dir.m_size >= MZ_UINT32_MAX) - { - /* TODO: Support central dirs >= 32-bits in size */ - mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE); - return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_CDIR_SIZE); - } - - n = (mz_uint32)orig_central_dir_size; - if (!mz_zip_array_push_back(pZip, &pState->m_central_dir_offsets, &n, 1)) - { - mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE); - return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED); - } - - pZip->m_total_files++; - pZip->m_archive_size = cur_dst_file_ofs; - - return MZ_TRUE; -} - -mz_bool mz_zip_writer_finalize_archive(mz_zip_archive *pZip) -{ - mz_zip_internal_state *pState; - mz_uint64 central_dir_ofs, central_dir_size; - mz_uint8 hdr[256]; - - if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING)) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - - pState = pZip->m_pState; - - if (pState->m_zip64) - { - if ((mz_uint64)pState->m_central_dir.m_size >= MZ_UINT32_MAX) - return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES); - } - else - { - if ((pZip->m_total_files > MZ_UINT16_MAX) || ((pZip->m_archive_size + pState->m_central_dir.m_size + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) > MZ_UINT32_MAX)) - return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES); - } - - central_dir_ofs = 0; - central_dir_size = 0; - if (pZip->m_total_files) - { - /* Write central directory */ - central_dir_ofs = pZip->m_archive_size; - central_dir_size = pState->m_central_dir.m_size; - pZip->m_central_directory_file_ofs = central_dir_ofs; - if (pZip->m_pWrite(pZip->m_pIO_opaque, central_dir_ofs, pState->m_central_dir.m_p, (size_t)central_dir_size) != central_dir_size) - return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED); - - pZip->m_archive_size += central_dir_size; - } - - if (pState->m_zip64) - { - /* Write zip64 end of central directory header */ - mz_uint64 rel_ofs_to_zip64_ecdr = pZip->m_archive_size; - - MZ_CLEAR_ARR(hdr); - MZ_WRITE_LE32(hdr + MZ_ZIP64_ECDH_SIG_OFS, MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIG); - MZ_WRITE_LE64(hdr + MZ_ZIP64_ECDH_SIZE_OF_RECORD_OFS, MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIZE - sizeof(mz_uint32) - sizeof(mz_uint64)); - MZ_WRITE_LE16(hdr + MZ_ZIP64_ECDH_VERSION_MADE_BY_OFS, 0x031E); /* TODO: always Unix */ - MZ_WRITE_LE16(hdr + MZ_ZIP64_ECDH_VERSION_NEEDED_OFS, 0x002D); - MZ_WRITE_LE64(hdr + MZ_ZIP64_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS, pZip->m_total_files); - MZ_WRITE_LE64(hdr + MZ_ZIP64_ECDH_CDIR_TOTAL_ENTRIES_OFS, pZip->m_total_files); - MZ_WRITE_LE64(hdr + MZ_ZIP64_ECDH_CDIR_SIZE_OFS, central_dir_size); - MZ_WRITE_LE64(hdr + MZ_ZIP64_ECDH_CDIR_OFS_OFS, central_dir_ofs); - if (pZip->m_pWrite(pZip->m_pIO_opaque, pZip->m_archive_size, hdr, MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIZE) != MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIZE) - return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED); - - pZip->m_archive_size += MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIZE; - - /* Write zip64 end of central directory locator */ - MZ_CLEAR_ARR(hdr); - MZ_WRITE_LE32(hdr + MZ_ZIP64_ECDL_SIG_OFS, MZ_ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIG); - MZ_WRITE_LE64(hdr + MZ_ZIP64_ECDL_REL_OFS_TO_ZIP64_ECDR_OFS, rel_ofs_to_zip64_ecdr); - MZ_WRITE_LE32(hdr + MZ_ZIP64_ECDL_TOTAL_NUMBER_OF_DISKS_OFS, 1); - if (pZip->m_pWrite(pZip->m_pIO_opaque, pZip->m_archive_size, hdr, MZ_ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIZE) != MZ_ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIZE) - return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED); - - pZip->m_archive_size += MZ_ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIZE; - } - - /* Write end of central directory record */ - MZ_CLEAR_ARR(hdr); - MZ_WRITE_LE32(hdr + MZ_ZIP_ECDH_SIG_OFS, MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG); - MZ_WRITE_LE16(hdr + MZ_ZIP_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS, MZ_MIN(MZ_UINT16_MAX, pZip->m_total_files)); - MZ_WRITE_LE16(hdr + MZ_ZIP_ECDH_CDIR_TOTAL_ENTRIES_OFS, MZ_MIN(MZ_UINT16_MAX, pZip->m_total_files)); - MZ_WRITE_LE32(hdr + MZ_ZIP_ECDH_CDIR_SIZE_OFS, MZ_MIN(MZ_UINT32_MAX, central_dir_size)); - MZ_WRITE_LE32(hdr + MZ_ZIP_ECDH_CDIR_OFS_OFS, MZ_MIN(MZ_UINT32_MAX, central_dir_ofs)); - - if (pZip->m_pWrite(pZip->m_pIO_opaque, pZip->m_archive_size, hdr, MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) != MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) - return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED); - -#ifndef MINIZ_NO_STDIO - if ((pState->m_pFile) && (MZ_FFLUSH(pState->m_pFile) == EOF)) - return mz_zip_set_error(pZip, MZ_ZIP_FILE_CLOSE_FAILED); -#endif /* #ifndef MINIZ_NO_STDIO */ - - pZip->m_archive_size += MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE; - - pZip->m_zip_mode = MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED; - return MZ_TRUE; -} - -mz_bool mz_zip_writer_finalize_heap_archive(mz_zip_archive *pZip, void **ppBuf, size_t *pSize) -{ - if ((!ppBuf) || (!pSize)) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - - *ppBuf = NULL; - *pSize = 0; - - if ((!pZip) || (!pZip->m_pState)) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - - if (pZip->m_pWrite != mz_zip_heap_write_func) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - - if (!mz_zip_writer_finalize_archive(pZip)) - return MZ_FALSE; - - *ppBuf = pZip->m_pState->m_pMem; - *pSize = pZip->m_pState->m_mem_size; - pZip->m_pState->m_pMem = NULL; - pZip->m_pState->m_mem_size = pZip->m_pState->m_mem_capacity = 0; - - return MZ_TRUE; -} - -mz_bool mz_zip_writer_end(mz_zip_archive *pZip) -{ - return mz_zip_writer_end_internal(pZip, MZ_TRUE); -} - -#ifndef MINIZ_NO_STDIO -mz_bool mz_zip_add_mem_to_archive_file_in_place(const char *pZip_filename, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags) -{ - return mz_zip_add_mem_to_archive_file_in_place_v2(pZip_filename, pArchive_name, pBuf, buf_size, pComment, comment_size, level_and_flags, NULL); -} - -mz_bool mz_zip_add_mem_to_archive_file_in_place_v2(const char *pZip_filename, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, mz_zip_error *pErr) -{ - mz_bool status, created_new_archive = MZ_FALSE; - mz_zip_archive zip_archive; - struct MZ_FILE_STAT_STRUCT file_stat; - mz_zip_error actual_err = MZ_ZIP_NO_ERROR; - - mz_zip_zero_struct(&zip_archive); - if ((int)level_and_flags < 0) - level_and_flags = MZ_DEFAULT_LEVEL; - - if ((!pZip_filename) || (!pArchive_name) || ((buf_size) && (!pBuf)) || ((comment_size) && (!pComment)) || ((level_and_flags & 0xF) > MZ_UBER_COMPRESSION)) - { - if (pErr) - *pErr = MZ_ZIP_INVALID_PARAMETER; - return MZ_FALSE; - } - - if (!mz_zip_writer_validate_archive_name(pArchive_name)) - { - if (pErr) - *pErr = MZ_ZIP_INVALID_FILENAME; - return MZ_FALSE; - } - - /* Important: The regular non-64 bit version of stat() can fail here if the file is very large, which could cause the archive to be overwritten. */ - /* So be sure to compile with _LARGEFILE64_SOURCE 1 */ - if (MZ_FILE_STAT(pZip_filename, &file_stat) != 0) - { - /* Create a new archive. */ - if (!mz_zip_writer_init_file_v2(&zip_archive, pZip_filename, 0, level_and_flags)) - { - if (pErr) - *pErr = zip_archive.m_last_error; - return MZ_FALSE; - } - - created_new_archive = MZ_TRUE; - } - else - { - /* Append to an existing archive. */ - if (!mz_zip_reader_init_file_v2(&zip_archive, pZip_filename, level_and_flags | MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY, 0, 0)) - { - if (pErr) - *pErr = zip_archive.m_last_error; - return MZ_FALSE; - } - - if (!mz_zip_writer_init_from_reader_v2(&zip_archive, pZip_filename, level_and_flags)) - { - if (pErr) - *pErr = zip_archive.m_last_error; - - mz_zip_reader_end_internal(&zip_archive, MZ_FALSE); - - return MZ_FALSE; - } - } - - status = mz_zip_writer_add_mem_ex(&zip_archive, pArchive_name, pBuf, buf_size, pComment, comment_size, level_and_flags, 0, 0); - actual_err = zip_archive.m_last_error; - - /* Always finalize, even if adding failed for some reason, so we have a valid central directory. (This may not always succeed, but we can try.) */ - if (!mz_zip_writer_finalize_archive(&zip_archive)) - { - if (!actual_err) - actual_err = zip_archive.m_last_error; - - status = MZ_FALSE; - } - - if (!mz_zip_writer_end_internal(&zip_archive, status)) - { - if (!actual_err) - actual_err = zip_archive.m_last_error; - - status = MZ_FALSE; - } - - if ((!status) && (created_new_archive)) - { - /* It's a new archive and something went wrong, so just delete it. */ - int ignoredStatus = MZ_DELETE_FILE(pZip_filename); - (void)ignoredStatus; - } - - if (pErr) - *pErr = actual_err; - - return status; -} - -void *mz_zip_extract_archive_file_to_heap_v2(const char *pZip_filename, const char *pArchive_name, const char *pComment, size_t *pSize, mz_uint flags, mz_zip_error *pErr) -{ - mz_uint32 file_index; - mz_zip_archive zip_archive; - void *p = NULL; - - if (pSize) - *pSize = 0; - - if ((!pZip_filename) || (!pArchive_name)) - { - if (pErr) - *pErr = MZ_ZIP_INVALID_PARAMETER; - - return NULL; - } - - mz_zip_zero_struct(&zip_archive); - if (!mz_zip_reader_init_file_v2(&zip_archive, pZip_filename, flags | MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY, 0, 0)) - { - if (pErr) - *pErr = zip_archive.m_last_error; - - return NULL; - } - - if (mz_zip_reader_locate_file_v2(&zip_archive, pArchive_name, pComment, flags, &file_index)) - { - p = mz_zip_reader_extract_to_heap(&zip_archive, file_index, pSize, flags); - } - - mz_zip_reader_end_internal(&zip_archive, p != NULL); - - if (pErr) - *pErr = zip_archive.m_last_error; - - return p; -} - -void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, size_t *pSize, mz_uint flags) -{ - return mz_zip_extract_archive_file_to_heap_v2(pZip_filename, pArchive_name, NULL, pSize, flags, NULL); -} - -#endif /* #ifndef MINIZ_NO_STDIO */ - -#endif /* #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS */ - -/* ------------------- Misc utils */ - -mz_zip_mode mz_zip_get_mode(mz_zip_archive *pZip) -{ - return pZip ? pZip->m_zip_mode : MZ_ZIP_MODE_INVALID; -} - -mz_zip_type mz_zip_get_type(mz_zip_archive *pZip) -{ - return pZip ? pZip->m_zip_type : MZ_ZIP_TYPE_INVALID; -} - -mz_zip_error mz_zip_set_last_error(mz_zip_archive *pZip, mz_zip_error err_num) -{ - mz_zip_error prev_err; - - if (!pZip) - return MZ_ZIP_INVALID_PARAMETER; - - prev_err = pZip->m_last_error; - - pZip->m_last_error = err_num; - return prev_err; -} - -mz_zip_error mz_zip_peek_last_error(mz_zip_archive *pZip) -{ - if (!pZip) - return MZ_ZIP_INVALID_PARAMETER; - - return pZip->m_last_error; -} - -mz_zip_error mz_zip_clear_last_error(mz_zip_archive *pZip) -{ - return mz_zip_set_last_error(pZip, MZ_ZIP_NO_ERROR); -} - -mz_zip_error mz_zip_get_last_error(mz_zip_archive *pZip) -{ - mz_zip_error prev_err; - - if (!pZip) - return MZ_ZIP_INVALID_PARAMETER; - - prev_err = pZip->m_last_error; - - pZip->m_last_error = MZ_ZIP_NO_ERROR; - return prev_err; -} - -const char *mz_zip_get_error_string(mz_zip_error mz_err) -{ - switch (mz_err) - { - case MZ_ZIP_NO_ERROR: - return "no error"; - case MZ_ZIP_UNDEFINED_ERROR: - return "undefined error"; - case MZ_ZIP_TOO_MANY_FILES: - return "too many files"; - case MZ_ZIP_FILE_TOO_LARGE: - return "file too large"; - case MZ_ZIP_UNSUPPORTED_METHOD: - return "unsupported method"; - case MZ_ZIP_UNSUPPORTED_ENCRYPTION: - return "unsupported encryption"; - case MZ_ZIP_UNSUPPORTED_FEATURE: - return "unsupported feature"; - case MZ_ZIP_FAILED_FINDING_CENTRAL_DIR: - return "failed finding central directory"; - case MZ_ZIP_NOT_AN_ARCHIVE: - return "not a ZIP archive"; - case MZ_ZIP_INVALID_HEADER_OR_CORRUPTED: - return "invalid header or archive is corrupted"; - case MZ_ZIP_UNSUPPORTED_MULTIDISK: - return "unsupported multidisk archive"; - case MZ_ZIP_DECOMPRESSION_FAILED: - return "decompression failed or archive is corrupted"; - case MZ_ZIP_COMPRESSION_FAILED: - return "compression failed"; - case MZ_ZIP_UNEXPECTED_DECOMPRESSED_SIZE: - return "unexpected decompressed size"; - case MZ_ZIP_CRC_CHECK_FAILED: - return "CRC-32 check failed"; - case MZ_ZIP_UNSUPPORTED_CDIR_SIZE: - return "unsupported central directory size"; - case MZ_ZIP_ALLOC_FAILED: - return "allocation failed"; - case MZ_ZIP_FILE_OPEN_FAILED: - return "file open failed"; - case MZ_ZIP_FILE_CREATE_FAILED: - return "file create failed"; - case MZ_ZIP_FILE_WRITE_FAILED: - return "file write failed"; - case MZ_ZIP_FILE_READ_FAILED: - return "file read failed"; - case MZ_ZIP_FILE_CLOSE_FAILED: - return "file close failed"; - case MZ_ZIP_FILE_SEEK_FAILED: - return "file seek failed"; - case MZ_ZIP_FILE_STAT_FAILED: - return "file stat failed"; - case MZ_ZIP_INVALID_PARAMETER: - return "invalid parameter"; - case MZ_ZIP_INVALID_FILENAME: - return "invalid filename"; - case MZ_ZIP_BUF_TOO_SMALL: - return "buffer too small"; - case MZ_ZIP_INTERNAL_ERROR: - return "internal error"; - case MZ_ZIP_FILE_NOT_FOUND: - return "file not found"; - case MZ_ZIP_ARCHIVE_TOO_LARGE: - return "archive is too large"; - case MZ_ZIP_VALIDATION_FAILED: - return "validation failed"; - case MZ_ZIP_WRITE_CALLBACK_FAILED: - return "write callback failed"; - case MZ_ZIP_TOTAL_ERRORS: - return "total errors"; - default: - break; - } - - return "unknown error"; -} - -/* Note: Just because the archive is not zip64 doesn't necessarily mean it doesn't have Zip64 extended information extra field, argh. */ -mz_bool mz_zip_is_zip64(mz_zip_archive *pZip) -{ - if ((!pZip) || (!pZip->m_pState)) - return MZ_FALSE; - - return pZip->m_pState->m_zip64; -} - -size_t mz_zip_get_central_dir_size(mz_zip_archive *pZip) -{ - if ((!pZip) || (!pZip->m_pState)) - return 0; - - return pZip->m_pState->m_central_dir.m_size; -} - -mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip) -{ - return pZip ? pZip->m_total_files : 0; -} - -mz_uint64 mz_zip_get_archive_size(mz_zip_archive *pZip) -{ - if (!pZip) - return 0; - return pZip->m_archive_size; -} - -mz_uint64 mz_zip_get_archive_file_start_offset(mz_zip_archive *pZip) -{ - if ((!pZip) || (!pZip->m_pState)) - return 0; - return pZip->m_pState->m_file_archive_start_ofs; -} - -MZ_FILE *mz_zip_get_cfile(mz_zip_archive *pZip) -{ - if ((!pZip) || (!pZip->m_pState)) - return 0; - return pZip->m_pState->m_pFile; -} - -size_t mz_zip_read_archive_data(mz_zip_archive *pZip, mz_uint64 file_ofs, void *pBuf, size_t n) -{ - if ((!pZip) || (!pZip->m_pState) || (!pBuf) || (!pZip->m_pRead)) - return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - - return pZip->m_pRead(pZip->m_pIO_opaque, file_ofs, pBuf, n); -} - -mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index, char *pFilename, mz_uint filename_buf_size) -{ - mz_uint n; - const mz_uint8 *p = mz_zip_get_cdh(pZip, file_index); - if (!p) - { - if (filename_buf_size) - pFilename[0] = '\0'; - mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER); - return 0; - } - n = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS); - if (filename_buf_size) - { - n = MZ_MIN(n, filename_buf_size - 1); - memcpy(pFilename, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, n); - pFilename[n] = '\0'; - } - return n + 1; -} - -mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index, mz_zip_archive_file_stat *pStat) -{ - return mz_zip_file_stat_internal(pZip, file_index, mz_zip_get_cdh(pZip, file_index), pStat, NULL); -} - -mz_bool mz_zip_end(mz_zip_archive *pZip) -{ - if (!pZip) - return MZ_FALSE; - - if (pZip->m_zip_mode == MZ_ZIP_MODE_READING) - return mz_zip_reader_end(pZip); -#ifndef MINIZ_NO_ARCHIVE_WRITING_APIS - else if ((pZip->m_zip_mode == MZ_ZIP_MODE_WRITING) || (pZip->m_zip_mode == MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED)) - return mz_zip_writer_end(pZip); -#endif - - return MZ_FALSE; -} - -#ifdef __cplusplus -} -#endif - -#endif /*#ifndef MINIZ_NO_ARCHIVE_APIS*/ diff --git a/extern/tinyexr/miniz.h b/extern/tinyexr/miniz.h deleted file mode 100644 index 9fcfffc..0000000 --- a/extern/tinyexr/miniz.h +++ /dev/null @@ -1,1422 +0,0 @@ -#ifndef MINIZ_EXPORT -#define MINIZ_EXPORT -#endif -/* miniz.c 3.0.0 - public domain deflate/inflate, zlib-subset, ZIP reading/writing/appending, PNG writing - See "unlicense" statement at the end of this file. - Rich Geldreich , last updated Oct. 13, 2013 - Implements RFC 1950: http://www.ietf.org/rfc/rfc1950.txt and RFC 1951: http://www.ietf.org/rfc/rfc1951.txt - - Most API's defined in miniz.c are optional. For example, to disable the archive related functions just define - MINIZ_NO_ARCHIVE_APIS, or to get rid of all stdio usage define MINIZ_NO_STDIO (see the list below for more macros). - - * Low-level Deflate/Inflate implementation notes: - - Compression: Use the "tdefl" API's. The compressor supports raw, static, and dynamic blocks, lazy or - greedy parsing, match length filtering, RLE-only, and Huffman-only streams. It performs and compresses - approximately as well as zlib. - - Decompression: Use the "tinfl" API's. The entire decompressor is implemented as a single function - coroutine: see tinfl_decompress(). It supports decompression into a 32KB (or larger power of 2) wrapping buffer, or into a memory - block large enough to hold the entire file. - - The low-level tdefl/tinfl API's do not make any use of dynamic memory allocation. - - * zlib-style API notes: - - miniz.c implements a fairly large subset of zlib. There's enough functionality present for it to be a drop-in - zlib replacement in many apps: - The z_stream struct, optional memory allocation callbacks - deflateInit/deflateInit2/deflate/deflateReset/deflateEnd/deflateBound - inflateInit/inflateInit2/inflate/inflateReset/inflateEnd - compress, compress2, compressBound, uncompress - CRC-32, Adler-32 - Using modern, minimal code size, CPU cache friendly routines. - Supports raw deflate streams or standard zlib streams with adler-32 checking. - - Limitations: - The callback API's are not implemented yet. No support for gzip headers or zlib static dictionaries. - I've tried to closely emulate zlib's various flavors of stream flushing and return status codes, but - there are no guarantees that miniz.c pulls this off perfectly. - - * PNG writing: See the tdefl_write_image_to_png_file_in_memory() function, originally written by - Alex Evans. Supports 1-4 bytes/pixel images. - - * ZIP archive API notes: - - The ZIP archive API's where designed with simplicity and efficiency in mind, with just enough abstraction to - get the job done with minimal fuss. There are simple API's to retrieve file information, read files from - existing archives, create new archives, append new files to existing archives, or clone archive data from - one archive to another. It supports archives located in memory or the heap, on disk (using stdio.h), - or you can specify custom file read/write callbacks. - - - Archive reading: Just call this function to read a single file from a disk archive: - - void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, - size_t *pSize, mz_uint zip_flags); - - For more complex cases, use the "mz_zip_reader" functions. Upon opening an archive, the entire central - directory is located and read as-is into memory, and subsequent file access only occurs when reading individual files. - - - Archives file scanning: The simple way is to use this function to scan a loaded archive for a specific file: - - int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags); - - The locate operation can optionally check file comments too, which (as one example) can be used to identify - multiple versions of the same file in an archive. This function uses a simple linear search through the central - directory, so it's not very fast. - - Alternately, you can iterate through all the files in an archive (using mz_zip_reader_get_num_files()) and - retrieve detailed info on each file by calling mz_zip_reader_file_stat(). - - - Archive creation: Use the "mz_zip_writer" functions. The ZIP writer immediately writes compressed file data - to disk and builds an exact image of the central directory in memory. The central directory image is written - all at once at the end of the archive file when the archive is finalized. - - The archive writer can optionally align each file's local header and file data to any power of 2 alignment, - which can be useful when the archive will be read from optical media. Also, the writer supports placing - arbitrary data blobs at the very beginning of ZIP archives. Archives written using either feature are still - readable by any ZIP tool. - - - Archive appending: The simple way to add a single file to an archive is to call this function: - - mz_bool mz_zip_add_mem_to_archive_file_in_place(const char *pZip_filename, const char *pArchive_name, - const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags); - - The archive will be created if it doesn't already exist, otherwise it'll be appended to. - Note the appending is done in-place and is not an atomic operation, so if something goes wrong - during the operation it's possible the archive could be left without a central directory (although the local - file headers and file data will be fine, so the archive will be recoverable). - - For more complex archive modification scenarios: - 1. The safest way is to use a mz_zip_reader to read the existing archive, cloning only those bits you want to - preserve into a new archive using using the mz_zip_writer_add_from_zip_reader() function (which compiles the - compressed file data as-is). When you're done, delete the old archive and rename the newly written archive, and - you're done. This is safe but requires a bunch of temporary disk space or heap memory. - - 2. Or, you can convert an mz_zip_reader in-place to an mz_zip_writer using mz_zip_writer_init_from_reader(), - append new files as needed, then finalize the archive which will write an updated central directory to the - original archive. (This is basically what mz_zip_add_mem_to_archive_file_in_place() does.) There's a - possibility that the archive's central directory could be lost with this method if anything goes wrong, though. - - - ZIP archive support limitations: - No spanning support. Extraction functions can only handle unencrypted, stored or deflated files. - Requires streams capable of seeking. - - * This is a header file library, like stb_image.c. To get only a header file, either cut and paste the - below header, or create miniz.h, #define MINIZ_HEADER_FILE_ONLY, and then include miniz.c from it. - - * Important: For best perf. be sure to customize the below macros for your target platform: - #define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 1 - #define MINIZ_LITTLE_ENDIAN 1 - #define MINIZ_HAS_64BIT_REGISTERS 1 - - * On platforms using glibc, Be sure to "#define _LARGEFILE64_SOURCE 1" before including miniz.c to ensure miniz - uses the 64-bit variants: fopen64(), stat64(), etc. Otherwise you won't be able to process large files - (i.e. 32-bit stat() fails for me on files > 0x7FFFFFFF bytes). -*/ -#pragma once - - - -/* Defines to completely disable specific portions of miniz.c: - If all macros here are defined the only functionality remaining will be CRC-32 and adler-32. */ - -/* Define MINIZ_NO_STDIO to disable all usage and any functions which rely on stdio for file I/O. */ -/*#define MINIZ_NO_STDIO */ - -/* If MINIZ_NO_TIME is specified then the ZIP archive functions will not be able to get the current time, or */ -/* get/set file times, and the C run-time funcs that get/set times won't be called. */ -/* The current downside is the times written to your archives will be from 1979. */ -/*#define MINIZ_NO_TIME */ - -/* Define MINIZ_NO_DEFLATE_APIS to disable all compression API's. */ -/*#define MINIZ_NO_DEFLATE_APIS */ - -/* Define MINIZ_NO_INFLATE_APIS to disable all decompression API's. */ -/*#define MINIZ_NO_INFLATE_APIS */ - -/* Define MINIZ_NO_ARCHIVE_APIS to disable all ZIP archive API's. */ -/*#define MINIZ_NO_ARCHIVE_APIS */ - -/* Define MINIZ_NO_ARCHIVE_WRITING_APIS to disable all writing related ZIP archive API's. */ -/*#define MINIZ_NO_ARCHIVE_WRITING_APIS */ - -/* Define MINIZ_NO_ZLIB_APIS to remove all ZLIB-style compression/decompression API's. */ -/*#define MINIZ_NO_ZLIB_APIS */ - -/* Define MINIZ_NO_ZLIB_COMPATIBLE_NAME to disable zlib names, to prevent conflicts against stock zlib. */ -/*#define MINIZ_NO_ZLIB_COMPATIBLE_NAMES */ - -/* Define MINIZ_NO_MALLOC to disable all calls to malloc, free, and realloc. - Note if MINIZ_NO_MALLOC is defined then the user must always provide custom user alloc/free/realloc - callbacks to the zlib and archive API's, and a few stand-alone helper API's which don't provide custom user - functions (such as tdefl_compress_mem_to_heap() and tinfl_decompress_mem_to_heap()) won't work. */ -/*#define MINIZ_NO_MALLOC */ - -#ifdef MINIZ_NO_INFLATE_APIS -#define MINIZ_NO_ARCHIVE_APIS -#endif - -#ifdef MINIZ_NO_DEFLATE_APIS -#define MINIZ_NO_ARCHIVE_WRITING_APIS -#endif - -#if defined(__TINYC__) && (defined(__linux) || defined(__linux__)) -/* TODO: Work around "error: include file 'sys\utime.h' when compiling with tcc on Linux */ -#define MINIZ_NO_TIME -#endif - -#include - -#if !defined(MINIZ_NO_TIME) && !defined(MINIZ_NO_ARCHIVE_APIS) -#include -#endif - -#if defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || defined(__i386) || defined(__i486__) || defined(__i486) || defined(i386) || defined(__ia64__) || defined(__x86_64__) -/* MINIZ_X86_OR_X64_CPU is only used to help set the below macros. */ -#define MINIZ_X86_OR_X64_CPU 1 -#else -#define MINIZ_X86_OR_X64_CPU 0 -#endif - -/* Set MINIZ_LITTLE_ENDIAN only if not set */ -#if !defined(MINIZ_LITTLE_ENDIAN) -#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) - -#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) -/* Set MINIZ_LITTLE_ENDIAN to 1 if the processor is little endian. */ -#define MINIZ_LITTLE_ENDIAN 1 -#else -#define MINIZ_LITTLE_ENDIAN 0 -#endif - -#else - -#if MINIZ_X86_OR_X64_CPU -#define MINIZ_LITTLE_ENDIAN 1 -#else -#define MINIZ_LITTLE_ENDIAN 0 -#endif - -#endif -#endif - -/* Using unaligned loads and stores causes errors when using UBSan */ -#if defined(__has_feature) -#if __has_feature(undefined_behavior_sanitizer) -#define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 0 -#endif -#endif - -/* Set MINIZ_USE_UNALIGNED_LOADS_AND_STORES only if not set */ -#if !defined(MINIZ_USE_UNALIGNED_LOADS_AND_STORES) -#if MINIZ_X86_OR_X64_CPU -/* Set MINIZ_USE_UNALIGNED_LOADS_AND_STORES to 1 on CPU's that permit efficient integer loads and stores from unaligned addresses. */ -#define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 0 -#define MINIZ_UNALIGNED_USE_MEMCPY -#else -#define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 0 -#endif -#endif - -#if defined(_M_X64) || defined(_WIN64) || defined(__MINGW64__) || defined(_LP64) || defined(__LP64__) || defined(__ia64__) || defined(__x86_64__) -/* Set MINIZ_HAS_64BIT_REGISTERS to 1 if operations on 64-bit integers are reasonably fast (and don't involve compiler generated calls to helper functions). */ -#define MINIZ_HAS_64BIT_REGISTERS 1 -#else -#define MINIZ_HAS_64BIT_REGISTERS 0 -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* ------------------- zlib-style API Definitions. */ - -/* For more compatibility with zlib, miniz.c uses unsigned long for some parameters/struct members. Beware: mz_ulong can be either 32 or 64-bits! */ -typedef unsigned long mz_ulong; - -/* mz_free() internally uses the MZ_FREE() macro (which by default calls free() unless you've modified the MZ_MALLOC macro) to release a block allocated from the heap. */ -MINIZ_EXPORT void mz_free(void *p); - -#define MZ_ADLER32_INIT (1) -/* mz_adler32() returns the initial adler-32 value to use when called with ptr==NULL. */ -MINIZ_EXPORT mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len); - -#define MZ_CRC32_INIT (0) -/* mz_crc32() returns the initial CRC-32 value to use when called with ptr==NULL. */ -MINIZ_EXPORT mz_ulong mz_crc32(mz_ulong crc, const unsigned char *ptr, size_t buf_len); - -/* Compression strategies. */ -enum -{ - MZ_DEFAULT_STRATEGY = 0, - MZ_FILTERED = 1, - MZ_HUFFMAN_ONLY = 2, - MZ_RLE = 3, - MZ_FIXED = 4 -}; - -/* Method */ -#define MZ_DEFLATED 8 - -/* Heap allocation callbacks. -Note that mz_alloc_func parameter types purposely differ from zlib's: items/size is size_t, not unsigned long. */ -typedef void *(*mz_alloc_func)(void *opaque, size_t items, size_t size); -typedef void (*mz_free_func)(void *opaque, void *address); -typedef void *(*mz_realloc_func)(void *opaque, void *address, size_t items, size_t size); - -/* Compression levels: 0-9 are the standard zlib-style levels, 10 is best possible compression (not zlib compatible, and may be very slow), MZ_DEFAULT_COMPRESSION=MZ_DEFAULT_LEVEL. */ -enum -{ - MZ_NO_COMPRESSION = 0, - MZ_BEST_SPEED = 1, - MZ_BEST_COMPRESSION = 9, - MZ_UBER_COMPRESSION = 10, - MZ_DEFAULT_LEVEL = 6, - MZ_DEFAULT_COMPRESSION = -1 -}; - -#define MZ_VERSION "11.0.2" -#define MZ_VERNUM 0xB002 -#define MZ_VER_MAJOR 11 -#define MZ_VER_MINOR 2 -#define MZ_VER_REVISION 0 -#define MZ_VER_SUBREVISION 0 - -#ifndef MINIZ_NO_ZLIB_APIS - -/* Flush values. For typical usage you only need MZ_NO_FLUSH and MZ_FINISH. The other values are for advanced use (refer to the zlib docs). */ -enum -{ - MZ_NO_FLUSH = 0, - MZ_PARTIAL_FLUSH = 1, - MZ_SYNC_FLUSH = 2, - MZ_FULL_FLUSH = 3, - MZ_FINISH = 4, - MZ_BLOCK = 5 -}; - -/* Return status codes. MZ_PARAM_ERROR is non-standard. */ -enum -{ - MZ_OK = 0, - MZ_STREAM_END = 1, - MZ_NEED_DICT = 2, - MZ_ERRNO = -1, - MZ_STREAM_ERROR = -2, - MZ_DATA_ERROR = -3, - MZ_MEM_ERROR = -4, - MZ_BUF_ERROR = -5, - MZ_VERSION_ERROR = -6, - MZ_PARAM_ERROR = -10000 -}; - -/* Window bits */ -#define MZ_DEFAULT_WINDOW_BITS 15 - -struct mz_internal_state; - -/* Compression/decompression stream struct. */ -typedef struct mz_stream_s -{ - const unsigned char *next_in; /* pointer to next byte to read */ - unsigned int avail_in; /* number of bytes available at next_in */ - mz_ulong total_in; /* total number of bytes consumed so far */ - - unsigned char *next_out; /* pointer to next byte to write */ - unsigned int avail_out; /* number of bytes that can be written to next_out */ - mz_ulong total_out; /* total number of bytes produced so far */ - - char *msg; /* error msg (unused) */ - struct mz_internal_state *state; /* internal state, allocated by zalloc/zfree */ - - mz_alloc_func zalloc; /* optional heap allocation function (defaults to malloc) */ - mz_free_func zfree; /* optional heap free function (defaults to free) */ - void *opaque; /* heap alloc function user pointer */ - - int data_type; /* data_type (unused) */ - mz_ulong adler; /* adler32 of the source or uncompressed data */ - mz_ulong reserved; /* not used */ -} mz_stream; - -typedef mz_stream *mz_streamp; - -/* Returns the version string of miniz.c. */ -MINIZ_EXPORT const char *mz_version(void); - -#ifndef MINIZ_NO_DEFLATE_APIS - -/* mz_deflateInit() initializes a compressor with default options: */ -/* Parameters: */ -/* pStream must point to an initialized mz_stream struct. */ -/* level must be between [MZ_NO_COMPRESSION, MZ_BEST_COMPRESSION]. */ -/* level 1 enables a specially optimized compression function that's been optimized purely for performance, not ratio. */ -/* (This special func. is currently only enabled when MINIZ_USE_UNALIGNED_LOADS_AND_STORES and MINIZ_LITTLE_ENDIAN are defined.) */ -/* Return values: */ -/* MZ_OK on success. */ -/* MZ_STREAM_ERROR if the stream is bogus. */ -/* MZ_PARAM_ERROR if the input parameters are bogus. */ -/* MZ_MEM_ERROR on out of memory. */ -MINIZ_EXPORT int mz_deflateInit(mz_streamp pStream, int level); - -/* mz_deflateInit2() is like mz_deflate(), except with more control: */ -/* Additional parameters: */ -/* method must be MZ_DEFLATED */ -/* window_bits must be MZ_DEFAULT_WINDOW_BITS (to wrap the deflate stream with zlib header/adler-32 footer) or -MZ_DEFAULT_WINDOW_BITS (raw deflate/no header or footer) */ -/* mem_level must be between [1, 9] (it's checked but ignored by miniz.c) */ -MINIZ_EXPORT int mz_deflateInit2(mz_streamp pStream, int level, int method, int window_bits, int mem_level, int strategy); - -/* Quickly resets a compressor without having to reallocate anything. Same as calling mz_deflateEnd() followed by mz_deflateInit()/mz_deflateInit2(). */ -MINIZ_EXPORT int mz_deflateReset(mz_streamp pStream); - -/* mz_deflate() compresses the input to output, consuming as much of the input and producing as much output as possible. */ -/* Parameters: */ -/* pStream is the stream to read from and write to. You must initialize/update the next_in, avail_in, next_out, and avail_out members. */ -/* flush may be MZ_NO_FLUSH, MZ_PARTIAL_FLUSH/MZ_SYNC_FLUSH, MZ_FULL_FLUSH, or MZ_FINISH. */ -/* Return values: */ -/* MZ_OK on success (when flushing, or if more input is needed but not available, and/or there's more output to be written but the output buffer is full). */ -/* MZ_STREAM_END if all input has been consumed and all output bytes have been written. Don't call mz_deflate() on the stream anymore. */ -/* MZ_STREAM_ERROR if the stream is bogus. */ -/* MZ_PARAM_ERROR if one of the parameters is invalid. */ -/* MZ_BUF_ERROR if no forward progress is possible because the input and/or output buffers are empty. (Fill up the input buffer or free up some output space and try again.) */ -MINIZ_EXPORT int mz_deflate(mz_streamp pStream, int flush); - -/* mz_deflateEnd() deinitializes a compressor: */ -/* Return values: */ -/* MZ_OK on success. */ -/* MZ_STREAM_ERROR if the stream is bogus. */ -MINIZ_EXPORT int mz_deflateEnd(mz_streamp pStream); - -/* mz_deflateBound() returns a (very) conservative upper bound on the amount of data that could be generated by deflate(), assuming flush is set to only MZ_NO_FLUSH or MZ_FINISH. */ -MINIZ_EXPORT mz_ulong mz_deflateBound(mz_streamp pStream, mz_ulong source_len); - -/* Single-call compression functions mz_compress() and mz_compress2(): */ -/* Returns MZ_OK on success, or one of the error codes from mz_deflate() on failure. */ -MINIZ_EXPORT int mz_compress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len); -MINIZ_EXPORT int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len, int level); - -/* mz_compressBound() returns a (very) conservative upper bound on the amount of data that could be generated by calling mz_compress(). */ -MINIZ_EXPORT mz_ulong mz_compressBound(mz_ulong source_len); - -#endif /*#ifndef MINIZ_NO_DEFLATE_APIS*/ - -#ifndef MINIZ_NO_INFLATE_APIS - -/* Initializes a decompressor. */ -MINIZ_EXPORT int mz_inflateInit(mz_streamp pStream); - -/* mz_inflateInit2() is like mz_inflateInit() with an additional option that controls the window size and whether or not the stream has been wrapped with a zlib header/footer: */ -/* window_bits must be MZ_DEFAULT_WINDOW_BITS (to parse zlib header/footer) or -MZ_DEFAULT_WINDOW_BITS (raw deflate). */ -MINIZ_EXPORT int mz_inflateInit2(mz_streamp pStream, int window_bits); - -/* Quickly resets a compressor without having to reallocate anything. Same as calling mz_inflateEnd() followed by mz_inflateInit()/mz_inflateInit2(). */ -MINIZ_EXPORT int mz_inflateReset(mz_streamp pStream); - -/* Decompresses the input stream to the output, consuming only as much of the input as needed, and writing as much to the output as possible. */ -/* Parameters: */ -/* pStream is the stream to read from and write to. You must initialize/update the next_in, avail_in, next_out, and avail_out members. */ -/* flush may be MZ_NO_FLUSH, MZ_SYNC_FLUSH, or MZ_FINISH. */ -/* On the first call, if flush is MZ_FINISH it's assumed the input and output buffers are both sized large enough to decompress the entire stream in a single call (this is slightly faster). */ -/* MZ_FINISH implies that there are no more source bytes available beside what's already in the input buffer, and that the output buffer is large enough to hold the rest of the decompressed data. */ -/* Return values: */ -/* MZ_OK on success. Either more input is needed but not available, and/or there's more output to be written but the output buffer is full. */ -/* MZ_STREAM_END if all needed input has been consumed and all output bytes have been written. For zlib streams, the adler-32 of the decompressed data has also been verified. */ -/* MZ_STREAM_ERROR if the stream is bogus. */ -/* MZ_DATA_ERROR if the deflate stream is invalid. */ -/* MZ_PARAM_ERROR if one of the parameters is invalid. */ -/* MZ_BUF_ERROR if no forward progress is possible because the input buffer is empty but the inflater needs more input to continue, or if the output buffer is not large enough. Call mz_inflate() again */ -/* with more input data, or with more room in the output buffer (except when using single call decompression, described above). */ -MINIZ_EXPORT int mz_inflate(mz_streamp pStream, int flush); - -/* Deinitializes a decompressor. */ -MINIZ_EXPORT int mz_inflateEnd(mz_streamp pStream); - -/* Single-call decompression. */ -/* Returns MZ_OK on success, or one of the error codes from mz_inflate() on failure. */ -MINIZ_EXPORT int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len); -MINIZ_EXPORT int mz_uncompress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong *pSource_len); -#endif /*#ifndef MINIZ_NO_INFLATE_APIS*/ - -/* Returns a string description of the specified error code, or NULL if the error code is invalid. */ -MINIZ_EXPORT const char *mz_error(int err); - -/* Redefine zlib-compatible names to miniz equivalents, so miniz.c can be used as a drop-in replacement for the subset of zlib that miniz.c supports. */ -/* Define MINIZ_NO_ZLIB_COMPATIBLE_NAMES to disable zlib-compatibility if you use zlib in the same project. */ -#ifndef MINIZ_NO_ZLIB_COMPATIBLE_NAMES -typedef unsigned char Byte; -typedef unsigned int uInt; -typedef mz_ulong uLong; -typedef Byte Bytef; -typedef uInt uIntf; -typedef char charf; -typedef int intf; -typedef void *voidpf; -typedef uLong uLongf; -typedef void *voidp; -typedef void *const voidpc; -#define Z_NULL 0 -#define Z_NO_FLUSH MZ_NO_FLUSH -#define Z_PARTIAL_FLUSH MZ_PARTIAL_FLUSH -#define Z_SYNC_FLUSH MZ_SYNC_FLUSH -#define Z_FULL_FLUSH MZ_FULL_FLUSH -#define Z_FINISH MZ_FINISH -#define Z_BLOCK MZ_BLOCK -#define Z_OK MZ_OK -#define Z_STREAM_END MZ_STREAM_END -#define Z_NEED_DICT MZ_NEED_DICT -#define Z_ERRNO MZ_ERRNO -#define Z_STREAM_ERROR MZ_STREAM_ERROR -#define Z_DATA_ERROR MZ_DATA_ERROR -#define Z_MEM_ERROR MZ_MEM_ERROR -#define Z_BUF_ERROR MZ_BUF_ERROR -#define Z_VERSION_ERROR MZ_VERSION_ERROR -#define Z_PARAM_ERROR MZ_PARAM_ERROR -#define Z_NO_COMPRESSION MZ_NO_COMPRESSION -#define Z_BEST_SPEED MZ_BEST_SPEED -#define Z_BEST_COMPRESSION MZ_BEST_COMPRESSION -#define Z_DEFAULT_COMPRESSION MZ_DEFAULT_COMPRESSION -#define Z_DEFAULT_STRATEGY MZ_DEFAULT_STRATEGY -#define Z_FILTERED MZ_FILTERED -#define Z_HUFFMAN_ONLY MZ_HUFFMAN_ONLY -#define Z_RLE MZ_RLE -#define Z_FIXED MZ_FIXED -#define Z_DEFLATED MZ_DEFLATED -#define Z_DEFAULT_WINDOW_BITS MZ_DEFAULT_WINDOW_BITS -#define alloc_func mz_alloc_func -#define free_func mz_free_func -#define internal_state mz_internal_state -#define z_stream mz_stream - -#ifndef MINIZ_NO_DEFLATE_APIS -#define deflateInit mz_deflateInit -#define deflateInit2 mz_deflateInit2 -#define deflateReset mz_deflateReset -#define deflate mz_deflate -#define deflateEnd mz_deflateEnd -#define deflateBound mz_deflateBound -#define compress mz_compress -#define compress2 mz_compress2 -#define compressBound mz_compressBound -#endif /*#ifndef MINIZ_NO_DEFLATE_APIS*/ - -#ifndef MINIZ_NO_INFLATE_APIS -#define inflateInit mz_inflateInit -#define inflateInit2 mz_inflateInit2 -#define inflateReset mz_inflateReset -#define inflate mz_inflate -#define inflateEnd mz_inflateEnd -#define uncompress mz_uncompress -#define uncompress2 mz_uncompress2 -#endif /*#ifndef MINIZ_NO_INFLATE_APIS*/ - -#define crc32 mz_crc32 -#define adler32 mz_adler32 -#define MAX_WBITS 15 -#define MAX_MEM_LEVEL 9 -#define zError mz_error -#define ZLIB_VERSION MZ_VERSION -#define ZLIB_VERNUM MZ_VERNUM -#define ZLIB_VER_MAJOR MZ_VER_MAJOR -#define ZLIB_VER_MINOR MZ_VER_MINOR -#define ZLIB_VER_REVISION MZ_VER_REVISION -#define ZLIB_VER_SUBREVISION MZ_VER_SUBREVISION -#define zlibVersion mz_version -#define zlib_version mz_version() -#endif /* #ifndef MINIZ_NO_ZLIB_COMPATIBLE_NAMES */ - -#endif /* MINIZ_NO_ZLIB_APIS */ - -#ifdef __cplusplus -} -#endif - - - - - -#pragma once -#include -#include -#include -#include - - - -/* ------------------- Types and macros */ -typedef unsigned char mz_uint8; -typedef signed short mz_int16; -typedef unsigned short mz_uint16; -typedef unsigned int mz_uint32; -typedef unsigned int mz_uint; -typedef int64_t mz_int64; -typedef uint64_t mz_uint64; -typedef int mz_bool; - -#define MZ_FALSE (0) -#define MZ_TRUE (1) - -/* Works around MSVC's spammy "warning C4127: conditional expression is constant" message. */ -#ifdef _MSC_VER -#define MZ_MACRO_END while (0, 0) -#else -#define MZ_MACRO_END while (0) -#endif - -#ifdef MINIZ_NO_STDIO -#define MZ_FILE void * -#else -#include -#define MZ_FILE FILE -#endif /* #ifdef MINIZ_NO_STDIO */ - -#ifdef MINIZ_NO_TIME -typedef struct mz_dummy_time_t_tag -{ - mz_uint32 m_dummy1; - mz_uint32 m_dummy2; -} mz_dummy_time_t; -#define MZ_TIME_T mz_dummy_time_t -#else -#define MZ_TIME_T time_t -#endif - -#define MZ_ASSERT(x) assert(x) - -#ifdef MINIZ_NO_MALLOC -#define MZ_MALLOC(x) NULL -#define MZ_FREE(x) (void)x, ((void)0) -#define MZ_REALLOC(p, x) NULL -#else -#define MZ_MALLOC(x) malloc(x) -#define MZ_FREE(x) free(x) -#define MZ_REALLOC(p, x) realloc(p, x) -#endif - -#define MZ_MAX(a, b) (((a) > (b)) ? (a) : (b)) -#define MZ_MIN(a, b) (((a) < (b)) ? (a) : (b)) -#define MZ_CLEAR_OBJ(obj) memset(&(obj), 0, sizeof(obj)) -#define MZ_CLEAR_ARR(obj) memset((obj), 0, sizeof(obj)) -#define MZ_CLEAR_PTR(obj) memset((obj), 0, sizeof(*obj)) - -#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN -#define MZ_READ_LE16(p) *((const mz_uint16 *)(p)) -#define MZ_READ_LE32(p) *((const mz_uint32 *)(p)) -#else -#define MZ_READ_LE16(p) ((mz_uint32)(((const mz_uint8 *)(p))[0]) | ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U)) -#define MZ_READ_LE32(p) ((mz_uint32)(((const mz_uint8 *)(p))[0]) | ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U) | ((mz_uint32)(((const mz_uint8 *)(p))[2]) << 16U) | ((mz_uint32)(((const mz_uint8 *)(p))[3]) << 24U)) -#endif - -#define MZ_READ_LE64(p) (((mz_uint64)MZ_READ_LE32(p)) | (((mz_uint64)MZ_READ_LE32((const mz_uint8 *)(p) + sizeof(mz_uint32))) << 32U)) - -#ifdef _MSC_VER -#define MZ_FORCEINLINE __forceinline -#elif defined(__GNUC__) -#define MZ_FORCEINLINE __inline__ __attribute__((__always_inline__)) -#else -#define MZ_FORCEINLINE inline -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -extern MINIZ_EXPORT void *miniz_def_alloc_func(void *opaque, size_t items, size_t size); -extern MINIZ_EXPORT void miniz_def_free_func(void *opaque, void *address); -extern MINIZ_EXPORT void *miniz_def_realloc_func(void *opaque, void *address, size_t items, size_t size); - -#define MZ_UINT16_MAX (0xFFFFU) -#define MZ_UINT32_MAX (0xFFFFFFFFU) - -#ifdef __cplusplus -} -#endif - #pragma once - - -#ifndef MINIZ_NO_DEFLATE_APIS - -#ifdef __cplusplus -extern "C" { -#endif -/* ------------------- Low-level Compression API Definitions */ - -/* Set TDEFL_LESS_MEMORY to 1 to use less memory (compression will be slightly slower, and raw/dynamic blocks will be output more frequently). */ -#define TDEFL_LESS_MEMORY 0 - -/* tdefl_init() compression flags logically OR'd together (low 12 bits contain the max. number of probes per dictionary search): */ -/* TDEFL_DEFAULT_MAX_PROBES: The compressor defaults to 128 dictionary probes per dictionary search. 0=Huffman only, 1=Huffman+LZ (fastest/crap compression), 4095=Huffman+LZ (slowest/best compression). */ -enum -{ - TDEFL_HUFFMAN_ONLY = 0, - TDEFL_DEFAULT_MAX_PROBES = 128, - TDEFL_MAX_PROBES_MASK = 0xFFF -}; - -/* TDEFL_WRITE_ZLIB_HEADER: If set, the compressor outputs a zlib header before the deflate data, and the Adler-32 of the source data at the end. Otherwise, you'll get raw deflate data. */ -/* TDEFL_COMPUTE_ADLER32: Always compute the adler-32 of the input data (even when not writing zlib headers). */ -/* TDEFL_GREEDY_PARSING_FLAG: Set to use faster greedy parsing, instead of more efficient lazy parsing. */ -/* TDEFL_NONDETERMINISTIC_PARSING_FLAG: Enable to decrease the compressor's initialization time to the minimum, but the output may vary from run to run given the same input (depending on the contents of memory). */ -/* TDEFL_RLE_MATCHES: Only look for RLE matches (matches with a distance of 1) */ -/* TDEFL_FILTER_MATCHES: Discards matches <= 5 chars if enabled. */ -/* TDEFL_FORCE_ALL_STATIC_BLOCKS: Disable usage of optimized Huffman tables. */ -/* TDEFL_FORCE_ALL_RAW_BLOCKS: Only use raw (uncompressed) deflate blocks. */ -/* The low 12 bits are reserved to control the max # of hash probes per dictionary lookup (see TDEFL_MAX_PROBES_MASK). */ -enum -{ - TDEFL_WRITE_ZLIB_HEADER = 0x01000, - TDEFL_COMPUTE_ADLER32 = 0x02000, - TDEFL_GREEDY_PARSING_FLAG = 0x04000, - TDEFL_NONDETERMINISTIC_PARSING_FLAG = 0x08000, - TDEFL_RLE_MATCHES = 0x10000, - TDEFL_FILTER_MATCHES = 0x20000, - TDEFL_FORCE_ALL_STATIC_BLOCKS = 0x40000, - TDEFL_FORCE_ALL_RAW_BLOCKS = 0x80000 -}; - -/* High level compression functions: */ -/* tdefl_compress_mem_to_heap() compresses a block in memory to a heap block allocated via malloc(). */ -/* On entry: */ -/* pSrc_buf, src_buf_len: Pointer and size of source block to compress. */ -/* flags: The max match finder probes (default is 128) logically OR'd against the above flags. Higher probes are slower but improve compression. */ -/* On return: */ -/* Function returns a pointer to the compressed data, or NULL on failure. */ -/* *pOut_len will be set to the compressed data's size, which could be larger than src_buf_len on uncompressible data. */ -/* The caller must free() the returned block when it's no longer needed. */ -MINIZ_EXPORT void *tdefl_compress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags); - -/* tdefl_compress_mem_to_mem() compresses a block in memory to another block in memory. */ -/* Returns 0 on failure. */ -MINIZ_EXPORT size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags); - -/* Compresses an image to a compressed PNG file in memory. */ -/* On entry: */ -/* pImage, w, h, and num_chans describe the image to compress. num_chans may be 1, 2, 3, or 4. */ -/* The image pitch in bytes per scanline will be w*num_chans. The leftmost pixel on the top scanline is stored first in memory. */ -/* level may range from [0,10], use MZ_NO_COMPRESSION, MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc. or a decent default is MZ_DEFAULT_LEVEL */ -/* If flip is true, the image will be flipped on the Y axis (useful for OpenGL apps). */ -/* On return: */ -/* Function returns a pointer to the compressed data, or NULL on failure. */ -/* *pLen_out will be set to the size of the PNG image file. */ -/* The caller must mz_free() the returned heap block (which will typically be larger than *pLen_out) when it's no longer needed. */ -MINIZ_EXPORT void *tdefl_write_image_to_png_file_in_memory_ex(const void *pImage, int w, int h, int num_chans, size_t *pLen_out, mz_uint level, mz_bool flip); -MINIZ_EXPORT void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int num_chans, size_t *pLen_out); - -/* Output stream interface. The compressor uses this interface to write compressed data. It'll typically be called TDEFL_OUT_BUF_SIZE at a time. */ -typedef mz_bool (*tdefl_put_buf_func_ptr)(const void *pBuf, int len, void *pUser); - -/* tdefl_compress_mem_to_output() compresses a block to an output stream. The above helpers use this function internally. */ -MINIZ_EXPORT mz_bool tdefl_compress_mem_to_output(const void *pBuf, size_t buf_len, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags); - -enum -{ - TDEFL_MAX_HUFF_TABLES = 3, - TDEFL_MAX_HUFF_SYMBOLS_0 = 288, - TDEFL_MAX_HUFF_SYMBOLS_1 = 32, - TDEFL_MAX_HUFF_SYMBOLS_2 = 19, - TDEFL_LZ_DICT_SIZE = 32768, - TDEFL_LZ_DICT_SIZE_MASK = TDEFL_LZ_DICT_SIZE - 1, - TDEFL_MIN_MATCH_LEN = 3, - TDEFL_MAX_MATCH_LEN = 258 -}; - -/* TDEFL_OUT_BUF_SIZE MUST be large enough to hold a single entire compressed output block (using static/fixed Huffman codes). */ -#if TDEFL_LESS_MEMORY -enum -{ - TDEFL_LZ_CODE_BUF_SIZE = 24 * 1024, - TDEFL_OUT_BUF_SIZE = (TDEFL_LZ_CODE_BUF_SIZE * 13) / 10, - TDEFL_MAX_HUFF_SYMBOLS = 288, - TDEFL_LZ_HASH_BITS = 12, - TDEFL_LEVEL1_HASH_SIZE_MASK = 4095, - TDEFL_LZ_HASH_SHIFT = (TDEFL_LZ_HASH_BITS + 2) / 3, - TDEFL_LZ_HASH_SIZE = 1 << TDEFL_LZ_HASH_BITS -}; -#else -enum -{ - TDEFL_LZ_CODE_BUF_SIZE = 64 * 1024, - TDEFL_OUT_BUF_SIZE = (TDEFL_LZ_CODE_BUF_SIZE * 13) / 10, - TDEFL_MAX_HUFF_SYMBOLS = 288, - TDEFL_LZ_HASH_BITS = 15, - TDEFL_LEVEL1_HASH_SIZE_MASK = 4095, - TDEFL_LZ_HASH_SHIFT = (TDEFL_LZ_HASH_BITS + 2) / 3, - TDEFL_LZ_HASH_SIZE = 1 << TDEFL_LZ_HASH_BITS -}; -#endif - -/* The low-level tdefl functions below may be used directly if the above helper functions aren't flexible enough. The low-level functions don't make any heap allocations, unlike the above helper functions. */ -typedef enum { - TDEFL_STATUS_BAD_PARAM = -2, - TDEFL_STATUS_PUT_BUF_FAILED = -1, - TDEFL_STATUS_OKAY = 0, - TDEFL_STATUS_DONE = 1 -} tdefl_status; - -/* Must map to MZ_NO_FLUSH, MZ_SYNC_FLUSH, etc. enums */ -typedef enum { - TDEFL_NO_FLUSH = 0, - TDEFL_SYNC_FLUSH = 2, - TDEFL_FULL_FLUSH = 3, - TDEFL_FINISH = 4 -} tdefl_flush; - -/* tdefl's compression state structure. */ -typedef struct -{ - tdefl_put_buf_func_ptr m_pPut_buf_func; - void *m_pPut_buf_user; - mz_uint m_flags, m_max_probes[2]; - int m_greedy_parsing; - mz_uint m_adler32, m_lookahead_pos, m_lookahead_size, m_dict_size; - mz_uint8 *m_pLZ_code_buf, *m_pLZ_flags, *m_pOutput_buf, *m_pOutput_buf_end; - mz_uint m_num_flags_left, m_total_lz_bytes, m_lz_code_buf_dict_pos, m_bits_in, m_bit_buffer; - mz_uint m_saved_match_dist, m_saved_match_len, m_saved_lit, m_output_flush_ofs, m_output_flush_remaining, m_finished, m_block_index, m_wants_to_finish; - tdefl_status m_prev_return_status; - const void *m_pIn_buf; - void *m_pOut_buf; - size_t *m_pIn_buf_size, *m_pOut_buf_size; - tdefl_flush m_flush; - const mz_uint8 *m_pSrc; - size_t m_src_buf_left, m_out_buf_ofs; - mz_uint8 m_dict[TDEFL_LZ_DICT_SIZE + TDEFL_MAX_MATCH_LEN - 1]; - mz_uint16 m_huff_count[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]; - mz_uint16 m_huff_codes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]; - mz_uint8 m_huff_code_sizes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]; - mz_uint8 m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE]; - mz_uint16 m_next[TDEFL_LZ_DICT_SIZE]; - mz_uint16 m_hash[TDEFL_LZ_HASH_SIZE]; - mz_uint8 m_output_buf[TDEFL_OUT_BUF_SIZE]; -} tdefl_compressor; - -/* Initializes the compressor. */ -/* There is no corresponding deinit() function because the tdefl API's do not dynamically allocate memory. */ -/* pBut_buf_func: If NULL, output data will be supplied to the specified callback. In this case, the user should call the tdefl_compress_buffer() API for compression. */ -/* If pBut_buf_func is NULL the user should always call the tdefl_compress() API. */ -/* flags: See the above enums (TDEFL_HUFFMAN_ONLY, TDEFL_WRITE_ZLIB_HEADER, etc.) */ -MINIZ_EXPORT tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags); - -/* Compresses a block of data, consuming as much of the specified input buffer as possible, and writing as much compressed data to the specified output buffer as possible. */ -MINIZ_EXPORT tdefl_status tdefl_compress(tdefl_compressor *d, const void *pIn_buf, size_t *pIn_buf_size, void *pOut_buf, size_t *pOut_buf_size, tdefl_flush flush); - -/* tdefl_compress_buffer() is only usable when the tdefl_init() is called with a non-NULL tdefl_put_buf_func_ptr. */ -/* tdefl_compress_buffer() always consumes the entire input buffer. */ -MINIZ_EXPORT tdefl_status tdefl_compress_buffer(tdefl_compressor *d, const void *pIn_buf, size_t in_buf_size, tdefl_flush flush); - -MINIZ_EXPORT tdefl_status tdefl_get_prev_return_status(tdefl_compressor *d); -MINIZ_EXPORT mz_uint32 tdefl_get_adler32(tdefl_compressor *d); - -/* Create tdefl_compress() flags given zlib-style compression parameters. */ -/* level may range from [0,10] (where 10 is absolute max compression, but may be much slower on some files) */ -/* window_bits may be -15 (raw deflate) or 15 (zlib) */ -/* strategy may be either MZ_DEFAULT_STRATEGY, MZ_FILTERED, MZ_HUFFMAN_ONLY, MZ_RLE, or MZ_FIXED */ -MINIZ_EXPORT mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, int strategy); - -#ifndef MINIZ_NO_MALLOC -/* Allocate the tdefl_compressor structure in C so that */ -/* non-C language bindings to tdefl_ API don't need to worry about */ -/* structure size and allocation mechanism. */ -MINIZ_EXPORT tdefl_compressor *tdefl_compressor_alloc(void); -MINIZ_EXPORT void tdefl_compressor_free(tdefl_compressor *pComp); -#endif - -#ifdef __cplusplus -} -#endif - -#endif /*#ifndef MINIZ_NO_DEFLATE_APIS*/ - #pragma once - -/* ------------------- Low-level Decompression API Definitions */ - -#ifndef MINIZ_NO_INFLATE_APIS - -#ifdef __cplusplus -extern "C" { -#endif -/* Decompression flags used by tinfl_decompress(). */ -/* TINFL_FLAG_PARSE_ZLIB_HEADER: If set, the input has a valid zlib header and ends with an adler32 checksum (it's a valid zlib stream). Otherwise, the input is a raw deflate stream. */ -/* TINFL_FLAG_HAS_MORE_INPUT: If set, there are more input bytes available beyond the end of the supplied input buffer. If clear, the input buffer contains all remaining input. */ -/* TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF: If set, the output buffer is large enough to hold the entire decompressed stream. If clear, the output buffer is at least the size of the dictionary (typically 32KB). */ -/* TINFL_FLAG_COMPUTE_ADLER32: Force adler-32 checksum computation of the decompressed bytes. */ -enum -{ - TINFL_FLAG_PARSE_ZLIB_HEADER = 1, - TINFL_FLAG_HAS_MORE_INPUT = 2, - TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF = 4, - TINFL_FLAG_COMPUTE_ADLER32 = 8 -}; - -/* High level decompression functions: */ -/* tinfl_decompress_mem_to_heap() decompresses a block in memory to a heap block allocated via malloc(). */ -/* On entry: */ -/* pSrc_buf, src_buf_len: Pointer and size of the Deflate or zlib source data to decompress. */ -/* On return: */ -/* Function returns a pointer to the decompressed data, or NULL on failure. */ -/* *pOut_len will be set to the decompressed data's size, which could be larger than src_buf_len on uncompressible data. */ -/* The caller must call mz_free() on the returned block when it's no longer needed. */ -MINIZ_EXPORT void *tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags); - -/* tinfl_decompress_mem_to_mem() decompresses a block in memory to another block in memory. */ -/* Returns TINFL_DECOMPRESS_MEM_TO_MEM_FAILED on failure, or the number of bytes written on success. */ -#define TINFL_DECOMPRESS_MEM_TO_MEM_FAILED ((size_t)(-1)) -MINIZ_EXPORT size_t tinfl_decompress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags); - -/* tinfl_decompress_mem_to_callback() decompresses a block in memory to an internal 32KB buffer, and a user provided callback function will be called to flush the buffer. */ -/* Returns 1 on success or 0 on failure. */ -typedef int (*tinfl_put_buf_func_ptr)(const void *pBuf, int len, void *pUser); -MINIZ_EXPORT int tinfl_decompress_mem_to_callback(const void *pIn_buf, size_t *pIn_buf_size, tinfl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags); - -struct tinfl_decompressor_tag; -typedef struct tinfl_decompressor_tag tinfl_decompressor; - -#ifndef MINIZ_NO_MALLOC -/* Allocate the tinfl_decompressor structure in C so that */ -/* non-C language bindings to tinfl_ API don't need to worry about */ -/* structure size and allocation mechanism. */ -MINIZ_EXPORT tinfl_decompressor *tinfl_decompressor_alloc(void); -MINIZ_EXPORT void tinfl_decompressor_free(tinfl_decompressor *pDecomp); -#endif - -/* Max size of LZ dictionary. */ -#define TINFL_LZ_DICT_SIZE 32768 - -/* Return status. */ -typedef enum { - /* This flags indicates the inflator needs 1 or more input bytes to make forward progress, but the caller is indicating that no more are available. The compressed data */ - /* is probably corrupted. If you call the inflator again with more bytes it'll try to continue processing the input but this is a BAD sign (either the data is corrupted or you called it incorrectly). */ - /* If you call it again with no input you'll just get TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS again. */ - TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS = -4, - - /* This flag indicates that one or more of the input parameters was obviously bogus. (You can try calling it again, but if you get this error the calling code is wrong.) */ - TINFL_STATUS_BAD_PARAM = -3, - - /* This flags indicate the inflator is finished but the adler32 check of the uncompressed data didn't match. If you call it again it'll return TINFL_STATUS_DONE. */ - TINFL_STATUS_ADLER32_MISMATCH = -2, - - /* This flags indicate the inflator has somehow failed (bad code, corrupted input, etc.). If you call it again without resetting via tinfl_init() it it'll just keep on returning the same status failure code. */ - TINFL_STATUS_FAILED = -1, - - /* Any status code less than TINFL_STATUS_DONE must indicate a failure. */ - - /* This flag indicates the inflator has returned every byte of uncompressed data that it can, has consumed every byte that it needed, has successfully reached the end of the deflate stream, and */ - /* if zlib headers and adler32 checking enabled that it has successfully checked the uncompressed data's adler32. If you call it again you'll just get TINFL_STATUS_DONE over and over again. */ - TINFL_STATUS_DONE = 0, - - /* This flag indicates the inflator MUST have more input data (even 1 byte) before it can make any more forward progress, or you need to clear the TINFL_FLAG_HAS_MORE_INPUT */ - /* flag on the next call if you don't have any more source data. If the source data was somehow corrupted it's also possible (but unlikely) for the inflator to keep on demanding input to */ - /* proceed, so be sure to properly set the TINFL_FLAG_HAS_MORE_INPUT flag. */ - TINFL_STATUS_NEEDS_MORE_INPUT = 1, - - /* This flag indicates the inflator definitely has 1 or more bytes of uncompressed data available, but it cannot write this data into the output buffer. */ - /* Note if the source compressed data was corrupted it's possible for the inflator to return a lot of uncompressed data to the caller. I've been assuming you know how much uncompressed data to expect */ - /* (either exact or worst case) and will stop calling the inflator and fail after receiving too much. In pure streaming scenarios where you have no idea how many bytes to expect this may not be possible */ - /* so I may need to add some code to address this. */ - TINFL_STATUS_HAS_MORE_OUTPUT = 2 -} tinfl_status; - -/* Initializes the decompressor to its initial state. */ -#define tinfl_init(r) \ - do \ - { \ - (r)->m_state = 0; \ - } \ - MZ_MACRO_END -#define tinfl_get_adler32(r) (r)->m_check_adler32 - -/* Main low-level decompressor coroutine function. This is the only function actually needed for decompression. All the other functions are just high-level helpers for improved usability. */ -/* This is a universal API, i.e. it can be used as a building block to build any desired higher level decompression API. In the limit case, it can be called once per every byte input or output. */ -MINIZ_EXPORT tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_next, size_t *pIn_buf_size, mz_uint8 *pOut_buf_start, mz_uint8 *pOut_buf_next, size_t *pOut_buf_size, const mz_uint32 decomp_flags); - -/* Internal/private bits follow. */ -enum -{ - TINFL_MAX_HUFF_TABLES = 3, - TINFL_MAX_HUFF_SYMBOLS_0 = 288, - TINFL_MAX_HUFF_SYMBOLS_1 = 32, - TINFL_MAX_HUFF_SYMBOLS_2 = 19, - TINFL_FAST_LOOKUP_BITS = 10, - TINFL_FAST_LOOKUP_SIZE = 1 << TINFL_FAST_LOOKUP_BITS -}; - -#if MINIZ_HAS_64BIT_REGISTERS -#define TINFL_USE_64BIT_BITBUF 1 -#else -#define TINFL_USE_64BIT_BITBUF 0 -#endif - -#if TINFL_USE_64BIT_BITBUF -typedef mz_uint64 tinfl_bit_buf_t; -#define TINFL_BITBUF_SIZE (64) -#else -typedef mz_uint32 tinfl_bit_buf_t; -#define TINFL_BITBUF_SIZE (32) -#endif - -struct tinfl_decompressor_tag -{ - mz_uint32 m_state, m_num_bits, m_zhdr0, m_zhdr1, m_z_adler32, m_final, m_type, m_check_adler32, m_dist, m_counter, m_num_extra, m_table_sizes[TINFL_MAX_HUFF_TABLES]; - tinfl_bit_buf_t m_bit_buf; - size_t m_dist_from_out_buf_start; - mz_int16 m_look_up[TINFL_MAX_HUFF_TABLES][TINFL_FAST_LOOKUP_SIZE]; - mz_int16 m_tree_0[TINFL_MAX_HUFF_SYMBOLS_0 * 2]; - mz_int16 m_tree_1[TINFL_MAX_HUFF_SYMBOLS_1 * 2]; - mz_int16 m_tree_2[TINFL_MAX_HUFF_SYMBOLS_2 * 2]; - mz_uint8 m_code_size_0[TINFL_MAX_HUFF_SYMBOLS_0]; - mz_uint8 m_code_size_1[TINFL_MAX_HUFF_SYMBOLS_1]; - mz_uint8 m_code_size_2[TINFL_MAX_HUFF_SYMBOLS_2]; - mz_uint8 m_raw_header[4], m_len_codes[TINFL_MAX_HUFF_SYMBOLS_0 + TINFL_MAX_HUFF_SYMBOLS_1 + 137]; -}; - -#ifdef __cplusplus -} -#endif - -#endif /*#ifndef MINIZ_NO_INFLATE_APIS*/ - -#pragma once - - -/* ------------------- ZIP archive reading/writing */ - -#ifndef MINIZ_NO_ARCHIVE_APIS - -#ifdef __cplusplus -extern "C" { -#endif - -enum -{ - /* Note: These enums can be reduced as needed to save memory or stack space - they are pretty conservative. */ - MZ_ZIP_MAX_IO_BUF_SIZE = 64 * 1024, - MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE = 512, - MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE = 512 -}; - -typedef struct -{ - /* Central directory file index. */ - mz_uint32 m_file_index; - - /* Byte offset of this entry in the archive's central directory. Note we currently only support up to UINT_MAX or less bytes in the central dir. */ - mz_uint64 m_central_dir_ofs; - - /* These fields are copied directly from the zip's central dir. */ - mz_uint16 m_version_made_by; - mz_uint16 m_version_needed; - mz_uint16 m_bit_flag; - mz_uint16 m_method; - - /* CRC-32 of uncompressed data. */ - mz_uint32 m_crc32; - - /* File's compressed size. */ - mz_uint64 m_comp_size; - - /* File's uncompressed size. Note, I've seen some old archives where directory entries had 512 bytes for their uncompressed sizes, but when you try to unpack them you actually get 0 bytes. */ - mz_uint64 m_uncomp_size; - - /* Zip internal and external file attributes. */ - mz_uint16 m_internal_attr; - mz_uint32 m_external_attr; - - /* Entry's local header file offset in bytes. */ - mz_uint64 m_local_header_ofs; - - /* Size of comment in bytes. */ - mz_uint32 m_comment_size; - - /* MZ_TRUE if the entry appears to be a directory. */ - mz_bool m_is_directory; - - /* MZ_TRUE if the entry uses encryption/strong encryption (which miniz_zip doesn't support) */ - mz_bool m_is_encrypted; - - /* MZ_TRUE if the file is not encrypted, a patch file, and if it uses a compression method we support. */ - mz_bool m_is_supported; - - /* Filename. If string ends in '/' it's a subdirectory entry. */ - /* Guaranteed to be zero terminated, may be truncated to fit. */ - char m_filename[MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE]; - - /* Comment field. */ - /* Guaranteed to be zero terminated, may be truncated to fit. */ - char m_comment[MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE]; - -#ifdef MINIZ_NO_TIME - MZ_TIME_T m_padding; -#else - MZ_TIME_T m_time; -#endif -} mz_zip_archive_file_stat; - -typedef size_t (*mz_file_read_func)(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n); -typedef size_t (*mz_file_write_func)(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n); -typedef mz_bool (*mz_file_needs_keepalive)(void *pOpaque); - -struct mz_zip_internal_state_tag; -typedef struct mz_zip_internal_state_tag mz_zip_internal_state; - -typedef enum { - MZ_ZIP_MODE_INVALID = 0, - MZ_ZIP_MODE_READING = 1, - MZ_ZIP_MODE_WRITING = 2, - MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED = 3 -} mz_zip_mode; - -typedef enum { - MZ_ZIP_FLAG_CASE_SENSITIVE = 0x0100, - MZ_ZIP_FLAG_IGNORE_PATH = 0x0200, - MZ_ZIP_FLAG_COMPRESSED_DATA = 0x0400, - MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY = 0x0800, - MZ_ZIP_FLAG_VALIDATE_LOCATE_FILE_FLAG = 0x1000, /* if enabled, mz_zip_reader_locate_file() will be called on each file as its validated to ensure the func finds the file in the central dir (intended for testing) */ - MZ_ZIP_FLAG_VALIDATE_HEADERS_ONLY = 0x2000, /* validate the local headers, but don't decompress the entire file and check the crc32 */ - MZ_ZIP_FLAG_WRITE_ZIP64 = 0x4000, /* always use the zip64 file format, instead of the original zip file format with automatic switch to zip64. Use as flags parameter with mz_zip_writer_init*_v2 */ - MZ_ZIP_FLAG_WRITE_ALLOW_READING = 0x8000, - MZ_ZIP_FLAG_ASCII_FILENAME = 0x10000, - /*After adding a compressed file, seek back - to local file header and set the correct sizes*/ - MZ_ZIP_FLAG_WRITE_HEADER_SET_SIZE = 0x20000 -} mz_zip_flags; - -typedef enum { - MZ_ZIP_TYPE_INVALID = 0, - MZ_ZIP_TYPE_USER, - MZ_ZIP_TYPE_MEMORY, - MZ_ZIP_TYPE_HEAP, - MZ_ZIP_TYPE_FILE, - MZ_ZIP_TYPE_CFILE, - MZ_ZIP_TOTAL_TYPES -} mz_zip_type; - -/* miniz error codes. Be sure to update mz_zip_get_error_string() if you add or modify this enum. */ -typedef enum { - MZ_ZIP_NO_ERROR = 0, - MZ_ZIP_UNDEFINED_ERROR, - MZ_ZIP_TOO_MANY_FILES, - MZ_ZIP_FILE_TOO_LARGE, - MZ_ZIP_UNSUPPORTED_METHOD, - MZ_ZIP_UNSUPPORTED_ENCRYPTION, - MZ_ZIP_UNSUPPORTED_FEATURE, - MZ_ZIP_FAILED_FINDING_CENTRAL_DIR, - MZ_ZIP_NOT_AN_ARCHIVE, - MZ_ZIP_INVALID_HEADER_OR_CORRUPTED, - MZ_ZIP_UNSUPPORTED_MULTIDISK, - MZ_ZIP_DECOMPRESSION_FAILED, - MZ_ZIP_COMPRESSION_FAILED, - MZ_ZIP_UNEXPECTED_DECOMPRESSED_SIZE, - MZ_ZIP_CRC_CHECK_FAILED, - MZ_ZIP_UNSUPPORTED_CDIR_SIZE, - MZ_ZIP_ALLOC_FAILED, - MZ_ZIP_FILE_OPEN_FAILED, - MZ_ZIP_FILE_CREATE_FAILED, - MZ_ZIP_FILE_WRITE_FAILED, - MZ_ZIP_FILE_READ_FAILED, - MZ_ZIP_FILE_CLOSE_FAILED, - MZ_ZIP_FILE_SEEK_FAILED, - MZ_ZIP_FILE_STAT_FAILED, - MZ_ZIP_INVALID_PARAMETER, - MZ_ZIP_INVALID_FILENAME, - MZ_ZIP_BUF_TOO_SMALL, - MZ_ZIP_INTERNAL_ERROR, - MZ_ZIP_FILE_NOT_FOUND, - MZ_ZIP_ARCHIVE_TOO_LARGE, - MZ_ZIP_VALIDATION_FAILED, - MZ_ZIP_WRITE_CALLBACK_FAILED, - MZ_ZIP_TOTAL_ERRORS -} mz_zip_error; - -typedef struct -{ - mz_uint64 m_archive_size; - mz_uint64 m_central_directory_file_ofs; - - /* We only support up to UINT32_MAX files in zip64 mode. */ - mz_uint32 m_total_files; - mz_zip_mode m_zip_mode; - mz_zip_type m_zip_type; - mz_zip_error m_last_error; - - mz_uint64 m_file_offset_alignment; - - mz_alloc_func m_pAlloc; - mz_free_func m_pFree; - mz_realloc_func m_pRealloc; - void *m_pAlloc_opaque; - - mz_file_read_func m_pRead; - mz_file_write_func m_pWrite; - mz_file_needs_keepalive m_pNeeds_keepalive; - void *m_pIO_opaque; - - mz_zip_internal_state *m_pState; - -} mz_zip_archive; - -typedef struct -{ - mz_zip_archive *pZip; - mz_uint flags; - - int status; - - mz_uint64 read_buf_size, read_buf_ofs, read_buf_avail, comp_remaining, out_buf_ofs, cur_file_ofs; - mz_zip_archive_file_stat file_stat; - void *pRead_buf; - void *pWrite_buf; - - size_t out_blk_remain; - - tinfl_decompressor inflator; - -#ifdef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS - mz_uint padding; -#else - mz_uint file_crc32; -#endif - -} mz_zip_reader_extract_iter_state; - -/* -------- ZIP reading */ - -/* Inits a ZIP archive reader. */ -/* These functions read and validate the archive's central directory. */ -MINIZ_EXPORT mz_bool mz_zip_reader_init(mz_zip_archive *pZip, mz_uint64 size, mz_uint flags); - -MINIZ_EXPORT mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem, size_t size, mz_uint flags); - -#ifndef MINIZ_NO_STDIO -/* Read a archive from a disk file. */ -/* file_start_ofs is the file offset where the archive actually begins, or 0. */ -/* actual_archive_size is the true total size of the archive, which may be smaller than the file's actual size on disk. If zero the entire file is treated as the archive. */ -MINIZ_EXPORT mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint32 flags); -MINIZ_EXPORT mz_bool mz_zip_reader_init_file_v2(mz_zip_archive *pZip, const char *pFilename, mz_uint flags, mz_uint64 file_start_ofs, mz_uint64 archive_size); - -/* Read an archive from an already opened FILE, beginning at the current file position. */ -/* The archive is assumed to be archive_size bytes long. If archive_size is 0, then the entire rest of the file is assumed to contain the archive. */ -/* The FILE will NOT be closed when mz_zip_reader_end() is called. */ -MINIZ_EXPORT mz_bool mz_zip_reader_init_cfile(mz_zip_archive *pZip, MZ_FILE *pFile, mz_uint64 archive_size, mz_uint flags); -#endif - -/* Ends archive reading, freeing all allocations, and closing the input archive file if mz_zip_reader_init_file() was used. */ -MINIZ_EXPORT mz_bool mz_zip_reader_end(mz_zip_archive *pZip); - -/* -------- ZIP reading or writing */ - -/* Clears a mz_zip_archive struct to all zeros. */ -/* Important: This must be done before passing the struct to any mz_zip functions. */ -MINIZ_EXPORT void mz_zip_zero_struct(mz_zip_archive *pZip); - -MINIZ_EXPORT mz_zip_mode mz_zip_get_mode(mz_zip_archive *pZip); -MINIZ_EXPORT mz_zip_type mz_zip_get_type(mz_zip_archive *pZip); - -/* Returns the total number of files in the archive. */ -MINIZ_EXPORT mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip); - -MINIZ_EXPORT mz_uint64 mz_zip_get_archive_size(mz_zip_archive *pZip); -MINIZ_EXPORT mz_uint64 mz_zip_get_archive_file_start_offset(mz_zip_archive *pZip); -MINIZ_EXPORT MZ_FILE *mz_zip_get_cfile(mz_zip_archive *pZip); - -/* Reads n bytes of raw archive data, starting at file offset file_ofs, to pBuf. */ -MINIZ_EXPORT size_t mz_zip_read_archive_data(mz_zip_archive *pZip, mz_uint64 file_ofs, void *pBuf, size_t n); - -/* All mz_zip funcs set the m_last_error field in the mz_zip_archive struct. These functions retrieve/manipulate this field. */ -/* Note that the m_last_error functionality is not thread safe. */ -MINIZ_EXPORT mz_zip_error mz_zip_set_last_error(mz_zip_archive *pZip, mz_zip_error err_num); -MINIZ_EXPORT mz_zip_error mz_zip_peek_last_error(mz_zip_archive *pZip); -MINIZ_EXPORT mz_zip_error mz_zip_clear_last_error(mz_zip_archive *pZip); -MINIZ_EXPORT mz_zip_error mz_zip_get_last_error(mz_zip_archive *pZip); -MINIZ_EXPORT const char *mz_zip_get_error_string(mz_zip_error mz_err); - -/* MZ_TRUE if the archive file entry is a directory entry. */ -MINIZ_EXPORT mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip, mz_uint file_index); - -/* MZ_TRUE if the file is encrypted/strong encrypted. */ -MINIZ_EXPORT mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip, mz_uint file_index); - -/* MZ_TRUE if the compression method is supported, and the file is not encrypted, and the file is not a compressed patch file. */ -MINIZ_EXPORT mz_bool mz_zip_reader_is_file_supported(mz_zip_archive *pZip, mz_uint file_index); - -/* Retrieves the filename of an archive file entry. */ -/* Returns the number of bytes written to pFilename, or if filename_buf_size is 0 this function returns the number of bytes needed to fully store the filename. */ -MINIZ_EXPORT mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index, char *pFilename, mz_uint filename_buf_size); - -/* Attempts to locates a file in the archive's central directory. */ -/* Valid flags: MZ_ZIP_FLAG_CASE_SENSITIVE, MZ_ZIP_FLAG_IGNORE_PATH */ -/* Returns -1 if the file cannot be found. */ -MINIZ_EXPORT int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags); -MINIZ_EXPORT mz_bool mz_zip_reader_locate_file_v2(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags, mz_uint32 *file_index); - -/* Returns detailed information about an archive file entry. */ -MINIZ_EXPORT mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index, mz_zip_archive_file_stat *pStat); - -/* MZ_TRUE if the file is in zip64 format. */ -/* A file is considered zip64 if it contained a zip64 end of central directory marker, or if it contained any zip64 extended file information fields in the central directory. */ -MINIZ_EXPORT mz_bool mz_zip_is_zip64(mz_zip_archive *pZip); - -/* Returns the total central directory size in bytes. */ -/* The current max supported size is <= MZ_UINT32_MAX. */ -MINIZ_EXPORT size_t mz_zip_get_central_dir_size(mz_zip_archive *pZip); - -/* Extracts a archive file to a memory buffer using no memory allocation. */ -/* There must be at least enough room on the stack to store the inflator's state (~34KB or so). */ -MINIZ_EXPORT mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size); -MINIZ_EXPORT mz_bool mz_zip_reader_extract_file_to_mem_no_alloc(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size); - -/* Extracts a archive file to a memory buffer. */ -MINIZ_EXPORT mz_bool mz_zip_reader_extract_to_mem(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags); -MINIZ_EXPORT mz_bool mz_zip_reader_extract_file_to_mem(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags); - -/* Extracts a archive file to a dynamically allocated heap buffer. */ -/* The memory will be allocated via the mz_zip_archive's alloc/realloc functions. */ -/* Returns NULL and sets the last error on failure. */ -MINIZ_EXPORT void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index, size_t *pSize, mz_uint flags); -MINIZ_EXPORT void *mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip, const char *pFilename, size_t *pSize, mz_uint flags); - -/* Extracts a archive file using a callback function to output the file's data. */ -MINIZ_EXPORT mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip, mz_uint file_index, mz_file_write_func pCallback, void *pOpaque, mz_uint flags); -MINIZ_EXPORT mz_bool mz_zip_reader_extract_file_to_callback(mz_zip_archive *pZip, const char *pFilename, mz_file_write_func pCallback, void *pOpaque, mz_uint flags); - -/* Extract a file iteratively */ -MINIZ_EXPORT mz_zip_reader_extract_iter_state* mz_zip_reader_extract_iter_new(mz_zip_archive *pZip, mz_uint file_index, mz_uint flags); -MINIZ_EXPORT mz_zip_reader_extract_iter_state* mz_zip_reader_extract_file_iter_new(mz_zip_archive *pZip, const char *pFilename, mz_uint flags); -MINIZ_EXPORT size_t mz_zip_reader_extract_iter_read(mz_zip_reader_extract_iter_state* pState, void* pvBuf, size_t buf_size); -MINIZ_EXPORT mz_bool mz_zip_reader_extract_iter_free(mz_zip_reader_extract_iter_state* pState); - -#ifndef MINIZ_NO_STDIO -/* Extracts a archive file to a disk file and sets its last accessed and modified times. */ -/* This function only extracts files, not archive directory records. */ -MINIZ_EXPORT mz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint file_index, const char *pDst_filename, mz_uint flags); -MINIZ_EXPORT mz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive *pZip, const char *pArchive_filename, const char *pDst_filename, mz_uint flags); - -/* Extracts a archive file starting at the current position in the destination FILE stream. */ -MINIZ_EXPORT mz_bool mz_zip_reader_extract_to_cfile(mz_zip_archive *pZip, mz_uint file_index, MZ_FILE *File, mz_uint flags); -MINIZ_EXPORT mz_bool mz_zip_reader_extract_file_to_cfile(mz_zip_archive *pZip, const char *pArchive_filename, MZ_FILE *pFile, mz_uint flags); -#endif - -#if 0 -/* TODO */ - typedef void *mz_zip_streaming_extract_state_ptr; - mz_zip_streaming_extract_state_ptr mz_zip_streaming_extract_begin(mz_zip_archive *pZip, mz_uint file_index, mz_uint flags); - mz_uint64 mz_zip_streaming_extract_get_size(mz_zip_archive *pZip, mz_zip_streaming_extract_state_ptr pState); - mz_uint64 mz_zip_streaming_extract_get_cur_ofs(mz_zip_archive *pZip, mz_zip_streaming_extract_state_ptr pState); - mz_bool mz_zip_streaming_extract_seek(mz_zip_archive *pZip, mz_zip_streaming_extract_state_ptr pState, mz_uint64 new_ofs); - size_t mz_zip_streaming_extract_read(mz_zip_archive *pZip, mz_zip_streaming_extract_state_ptr pState, void *pBuf, size_t buf_size); - mz_bool mz_zip_streaming_extract_end(mz_zip_archive *pZip, mz_zip_streaming_extract_state_ptr pState); -#endif - -/* This function compares the archive's local headers, the optional local zip64 extended information block, and the optional descriptor following the compressed data vs. the data in the central directory. */ -/* It also validates that each file can be successfully uncompressed unless the MZ_ZIP_FLAG_VALIDATE_HEADERS_ONLY is specified. */ -MINIZ_EXPORT mz_bool mz_zip_validate_file(mz_zip_archive *pZip, mz_uint file_index, mz_uint flags); - -/* Validates an entire archive by calling mz_zip_validate_file() on each file. */ -MINIZ_EXPORT mz_bool mz_zip_validate_archive(mz_zip_archive *pZip, mz_uint flags); - -/* Misc utils/helpers, valid for ZIP reading or writing */ -MINIZ_EXPORT mz_bool mz_zip_validate_mem_archive(const void *pMem, size_t size, mz_uint flags, mz_zip_error *pErr); -#ifndef MINIZ_NO_STDIO -MINIZ_EXPORT mz_bool mz_zip_validate_file_archive(const char *pFilename, mz_uint flags, mz_zip_error *pErr); -#endif - -/* Universal end function - calls either mz_zip_reader_end() or mz_zip_writer_end(). */ -MINIZ_EXPORT mz_bool mz_zip_end(mz_zip_archive *pZip); - -/* -------- ZIP writing */ - -#ifndef MINIZ_NO_ARCHIVE_WRITING_APIS - -/* Inits a ZIP archive writer. */ -/*Set pZip->m_pWrite (and pZip->m_pIO_opaque) before calling mz_zip_writer_init or mz_zip_writer_init_v2*/ -/*The output is streamable, i.e. file_ofs in mz_file_write_func always increases only by n*/ -MINIZ_EXPORT mz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size); -MINIZ_EXPORT mz_bool mz_zip_writer_init_v2(mz_zip_archive *pZip, mz_uint64 existing_size, mz_uint flags); - -MINIZ_EXPORT mz_bool mz_zip_writer_init_heap(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size); -MINIZ_EXPORT mz_bool mz_zip_writer_init_heap_v2(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size, mz_uint flags); - -#ifndef MINIZ_NO_STDIO -MINIZ_EXPORT mz_bool mz_zip_writer_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint64 size_to_reserve_at_beginning); -MINIZ_EXPORT mz_bool mz_zip_writer_init_file_v2(mz_zip_archive *pZip, const char *pFilename, mz_uint64 size_to_reserve_at_beginning, mz_uint flags); -MINIZ_EXPORT mz_bool mz_zip_writer_init_cfile(mz_zip_archive *pZip, MZ_FILE *pFile, mz_uint flags); -#endif - -/* Converts a ZIP archive reader object into a writer object, to allow efficient in-place file appends to occur on an existing archive. */ -/* For archives opened using mz_zip_reader_init_file, pFilename must be the archive's filename so it can be reopened for writing. If the file can't be reopened, mz_zip_reader_end() will be called. */ -/* For archives opened using mz_zip_reader_init_mem, the memory block must be growable using the realloc callback (which defaults to realloc unless you've overridden it). */ -/* Finally, for archives opened using mz_zip_reader_init, the mz_zip_archive's user provided m_pWrite function cannot be NULL. */ -/* Note: In-place archive modification is not recommended unless you know what you're doing, because if execution stops or something goes wrong before */ -/* the archive is finalized the file's central directory will be hosed. */ -MINIZ_EXPORT mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip, const char *pFilename); -MINIZ_EXPORT mz_bool mz_zip_writer_init_from_reader_v2(mz_zip_archive *pZip, const char *pFilename, mz_uint flags); - -/* Adds the contents of a memory buffer to an archive. These functions record the current local time into the archive. */ -/* To add a directory entry, call this method with an archive name ending in a forwardslash with an empty buffer. */ -/* level_and_flags - compression level (0-10, see MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or just set to MZ_DEFAULT_COMPRESSION. */ -MINIZ_EXPORT mz_bool mz_zip_writer_add_mem(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, mz_uint level_and_flags); - -/* Like mz_zip_writer_add_mem(), except you can specify a file comment field, and optionally supply the function with already compressed data. */ -/* uncomp_size/uncomp_crc32 are only used if the MZ_ZIP_FLAG_COMPRESSED_DATA flag is specified. */ -MINIZ_EXPORT mz_bool mz_zip_writer_add_mem_ex(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, - mz_uint64 uncomp_size, mz_uint32 uncomp_crc32); - -MINIZ_EXPORT mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, - mz_uint64 uncomp_size, mz_uint32 uncomp_crc32, MZ_TIME_T *last_modified, const char *user_extra_data_local, mz_uint user_extra_data_local_len, - const char *user_extra_data_central, mz_uint user_extra_data_central_len); - -/* Adds the contents of a file to an archive. This function also records the disk file's modified time into the archive. */ -/* File data is supplied via a read callback function. User mz_zip_writer_add_(c)file to add a file directly.*/ -MINIZ_EXPORT mz_bool mz_zip_writer_add_read_buf_callback(mz_zip_archive *pZip, const char *pArchive_name, mz_file_read_func read_callback, void* callback_opaque, mz_uint64 max_size, - const MZ_TIME_T *pFile_time, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, const char *user_extra_data_local, mz_uint user_extra_data_local_len, - const char *user_extra_data_central, mz_uint user_extra_data_central_len); - - -#ifndef MINIZ_NO_STDIO -/* Adds the contents of a disk file to an archive. This function also records the disk file's modified time into the archive. */ -/* level_and_flags - compression level (0-10, see MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or just set to MZ_DEFAULT_COMPRESSION. */ -MINIZ_EXPORT mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name, const char *pSrc_filename, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags); - -/* Like mz_zip_writer_add_file(), except the file data is read from the specified FILE stream. */ -MINIZ_EXPORT mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name, MZ_FILE *pSrc_file, mz_uint64 max_size, - const MZ_TIME_T *pFile_time, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, const char *user_extra_data_local, mz_uint user_extra_data_local_len, - const char *user_extra_data_central, mz_uint user_extra_data_central_len); -#endif - -/* Adds a file to an archive by fully cloning the data from another archive. */ -/* This function fully clones the source file's compressed data (no recompression), along with its full filename, extra data (it may add or modify the zip64 local header extra data field), and the optional descriptor following the compressed data. */ -MINIZ_EXPORT mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive *pSource_zip, mz_uint src_file_index); - -/* Finalizes the archive by writing the central directory records followed by the end of central directory record. */ -/* After an archive is finalized, the only valid call on the mz_zip_archive struct is mz_zip_writer_end(). */ -/* An archive must be manually finalized by calling this function for it to be valid. */ -MINIZ_EXPORT mz_bool mz_zip_writer_finalize_archive(mz_zip_archive *pZip); - -/* Finalizes a heap archive, returning a pointer to the heap block and its size. */ -/* The heap block will be allocated using the mz_zip_archive's alloc/realloc callbacks. */ -MINIZ_EXPORT mz_bool mz_zip_writer_finalize_heap_archive(mz_zip_archive *pZip, void **ppBuf, size_t *pSize); - -/* Ends archive writing, freeing all allocations, and closing the output file if mz_zip_writer_init_file() was used. */ -/* Note for the archive to be valid, it *must* have been finalized before ending (this function will not do it for you). */ -MINIZ_EXPORT mz_bool mz_zip_writer_end(mz_zip_archive *pZip); - -/* -------- Misc. high-level helper functions: */ - -/* mz_zip_add_mem_to_archive_file_in_place() efficiently (but not atomically) appends a memory blob to a ZIP archive. */ -/* Note this is NOT a fully safe operation. If it crashes or dies in some way your archive can be left in a screwed up state (without a central directory). */ -/* level_and_flags - compression level (0-10, see MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or just set to MZ_DEFAULT_COMPRESSION. */ -/* TODO: Perhaps add an option to leave the existing central dir in place in case the add dies? We could then truncate the file (so the old central dir would be at the end) if something goes wrong. */ -MINIZ_EXPORT mz_bool mz_zip_add_mem_to_archive_file_in_place(const char *pZip_filename, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags); -MINIZ_EXPORT mz_bool mz_zip_add_mem_to_archive_file_in_place_v2(const char *pZip_filename, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, mz_zip_error *pErr); - -#ifndef MINIZ_NO_STDIO -/* Reads a single file from an archive into a heap block. */ -/* If pComment is not NULL, only the file with the specified comment will be extracted. */ -/* Returns NULL on failure. */ -MINIZ_EXPORT void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, size_t *pSize, mz_uint flags); -MINIZ_EXPORT void *mz_zip_extract_archive_file_to_heap_v2(const char *pZip_filename, const char *pArchive_name, const char *pComment, size_t *pSize, mz_uint flags, mz_zip_error *pErr); -#endif - -#endif /* #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS */ - -#ifdef __cplusplus -} -#endif - -#endif /* MINIZ_NO_ARCHIVE_APIS */ diff --git a/extern/tinyexr/tinyexr.cc b/extern/tinyexr/tinyexr.cc deleted file mode 100644 index fef8f66..0000000 --- a/extern/tinyexr/tinyexr.cc +++ /dev/null @@ -1,8 +0,0 @@ -#if defined(_WIN32) -#ifndef NOMINMAX -#define NOMINMAX -#endif -#endif - -#define TINYEXR_IMPLEMENTATION -#include "tinyexr.h" diff --git a/extern/tinyexr/tinyexr.h b/extern/tinyexr/tinyexr.h deleted file mode 100644 index 5348af9..0000000 --- a/extern/tinyexr/tinyexr.h +++ /dev/null @@ -1,8534 +0,0 @@ -#ifndef TINYEXR_H_ -#define TINYEXR_H_ -/* -Copyright (c) 2014 - 2021, Syoyo Fujita and many contributors. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the Syoyo Fujita nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -// TinyEXR contains some OpenEXR code, which is licensed under ------------ - -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas -// Digital Ltd. LLC -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Industrial Light & Magic nor the names of -// its contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////// - -// End of OpenEXR license ------------------------------------------------- - - -// -// -// Do this: -// #define TINYEXR_IMPLEMENTATION -// before you include this file in *one* C or C++ file to create the -// implementation. -// -// // i.e. it should look like this: -// #include ... -// #include ... -// #include ... -// #define TINYEXR_IMPLEMENTATION -// #include "tinyexr.h" -// -// - -#include // for size_t -#include // guess stdint.h is available(C99) - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || \ - defined(__i386) || defined(__i486__) || defined(__i486) || \ - defined(i386) || defined(__ia64__) || defined(__x86_64__) -#define TINYEXR_X86_OR_X64_CPU 1 -#else -#define TINYEXR_X86_OR_X64_CPU 0 -#endif - -#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || TINYEXR_X86_OR_X64_CPU -#define TINYEXR_LITTLE_ENDIAN 1 -#else -#define TINYEXR_LITTLE_ENDIAN 0 -#endif - -// Use miniz or not to decode ZIP format pixel. Linking with zlib -// required if this flas is 0. -#ifndef TINYEXR_USE_MINIZ -#define TINYEXR_USE_MINIZ (1) -#endif - -// Disable PIZ comporession when applying cpplint. -#ifndef TINYEXR_USE_PIZ -#define TINYEXR_USE_PIZ (1) -#endif - -#ifndef TINYEXR_USE_ZFP -#define TINYEXR_USE_ZFP (0) // TinyEXR extension. -// http://computation.llnl.gov/projects/floating-point-compression -#endif - -#ifndef TINYEXR_USE_THREAD -#define TINYEXR_USE_THREAD (0) // No threaded loading. -// http://computation.llnl.gov/projects/floating-point-compression -#endif - -#ifndef TINYEXR_USE_OPENMP -#ifdef _OPENMP -#define TINYEXR_USE_OPENMP (1) -#else -#define TINYEXR_USE_OPENMP (0) -#endif -#endif - -#define TINYEXR_SUCCESS (0) -#define TINYEXR_ERROR_INVALID_MAGIC_NUMBER (-1) -#define TINYEXR_ERROR_INVALID_EXR_VERSION (-2) -#define TINYEXR_ERROR_INVALID_ARGUMENT (-3) -#define TINYEXR_ERROR_INVALID_DATA (-4) -#define TINYEXR_ERROR_INVALID_FILE (-5) -#define TINYEXR_ERROR_INVALID_PARAMETER (-6) -#define TINYEXR_ERROR_CANT_OPEN_FILE (-7) -#define TINYEXR_ERROR_UNSUPPORTED_FORMAT (-8) -#define TINYEXR_ERROR_INVALID_HEADER (-9) -#define TINYEXR_ERROR_UNSUPPORTED_FEATURE (-10) -#define TINYEXR_ERROR_CANT_WRITE_FILE (-11) -#define TINYEXR_ERROR_SERIALZATION_FAILED (-12) -#define TINYEXR_ERROR_LAYER_NOT_FOUND (-13) - -// @note { OpenEXR file format: http://www.openexr.com/openexrfilelayout.pdf } - -// pixel type: possible values are: UINT = 0 HALF = 1 FLOAT = 2 -#define TINYEXR_PIXELTYPE_UINT (0) -#define TINYEXR_PIXELTYPE_HALF (1) -#define TINYEXR_PIXELTYPE_FLOAT (2) - -#define TINYEXR_MAX_HEADER_ATTRIBUTES (1024) -#define TINYEXR_MAX_CUSTOM_ATTRIBUTES (128) - -#define TINYEXR_COMPRESSIONTYPE_NONE (0) -#define TINYEXR_COMPRESSIONTYPE_RLE (1) -#define TINYEXR_COMPRESSIONTYPE_ZIPS (2) -#define TINYEXR_COMPRESSIONTYPE_ZIP (3) -#define TINYEXR_COMPRESSIONTYPE_PIZ (4) -#define TINYEXR_COMPRESSIONTYPE_ZFP (128) // TinyEXR extension - -#define TINYEXR_ZFP_COMPRESSIONTYPE_RATE (0) -#define TINYEXR_ZFP_COMPRESSIONTYPE_PRECISION (1) -#define TINYEXR_ZFP_COMPRESSIONTYPE_ACCURACY (2) - -#define TINYEXR_TILE_ONE_LEVEL (0) -#define TINYEXR_TILE_MIPMAP_LEVELS (1) -#define TINYEXR_TILE_RIPMAP_LEVELS (2) - -#define TINYEXR_TILE_ROUND_DOWN (0) -#define TINYEXR_TILE_ROUND_UP (1) - -typedef struct _EXRVersion { - int version; // this must be 2 - // tile format image; - // not zero for only a single-part "normal" tiled file (according to spec.) - int tiled; - int long_name; // long name attribute - // deep image(EXR 2.0); - // for a multi-part file, indicates that at least one part is of type deep* (according to spec.) - int non_image; - int multipart; // multi-part(EXR 2.0) -} EXRVersion; - -typedef struct _EXRAttribute { - char name[256]; // name and type are up to 255 chars long. - char type[256]; - unsigned char *value; // uint8_t* - int size; - int pad0; -} EXRAttribute; - -typedef struct _EXRChannelInfo { - char name[256]; // less than 255 bytes long - int pixel_type; - int x_sampling; - int y_sampling; - unsigned char p_linear; - unsigned char pad[3]; -} EXRChannelInfo; - -typedef struct _EXRTile { - int offset_x; - int offset_y; - int level_x; - int level_y; - - int width; // actual width in a tile. - int height; // actual height int a tile. - - unsigned char **images; // image[channels][pixels] -} EXRTile; - -typedef struct _EXRBox2i { - int min_x; - int min_y; - int max_x; - int max_y; -} EXRBox2i; - -typedef struct _EXRHeader { - float pixel_aspect_ratio; - int line_order; - EXRBox2i data_window; - EXRBox2i display_window; - float screen_window_center[2]; - float screen_window_width; - - int chunk_count; - - // Properties for tiled format(`tiledesc`). - int tiled; - int tile_size_x; - int tile_size_y; - int tile_level_mode; - int tile_rounding_mode; - - int long_name; - // for a single-part file, agree with the version field bit 11 - // for a multi-part file, it is consistent with the type of part - int non_image; - int multipart; - unsigned int header_len; - - // Custom attributes(exludes required attributes(e.g. `channels`, - // `compression`, etc) - int num_custom_attributes; - EXRAttribute *custom_attributes; // array of EXRAttribute. size = - // `num_custom_attributes`. - - EXRChannelInfo *channels; // [num_channels] - - int *pixel_types; // Loaded pixel type(TINYEXR_PIXELTYPE_*) of `images` for - // each channel. This is overwritten with `requested_pixel_types` when - // loading. - int num_channels; - - int compression_type; // compression type(TINYEXR_COMPRESSIONTYPE_*) - int *requested_pixel_types; // Filled initially by - // ParseEXRHeaderFrom(Meomory|File), then users - // can edit it(only valid for HALF pixel type - // channel) - // name attribute required for multipart files; - // must be unique and non empty (according to spec.); - // use EXRSetNameAttr for setting value; - // max 255 character allowed - excluding terminating zero - char name[256]; -} EXRHeader; - -typedef struct _EXRMultiPartHeader { - int num_headers; - EXRHeader *headers; - -} EXRMultiPartHeader; - -typedef struct _EXRImage { - EXRTile *tiles; // Tiled pixel data. The application must reconstruct image - // from tiles manually. NULL if scanline format. - struct _EXRImage* next_level; // NULL if scanline format or image is the last level. - int level_x; // x level index - int level_y; // y level index - - unsigned char **images; // image[channels][pixels]. NULL if tiled format. - - int width; - int height; - int num_channels; - - // Properties for tile format. - int num_tiles; - -} EXRImage; - -typedef struct _EXRMultiPartImage { - int num_images; - EXRImage *images; - -} EXRMultiPartImage; - -typedef struct _DeepImage { - const char **channel_names; - float ***image; // image[channels][scanlines][samples] - int **offset_table; // offset_table[scanline][offsets] - int num_channels; - int width; - int height; - int pad0; -} DeepImage; - -// @deprecated { For backward compatibility. Not recommended to use. } -// Loads single-frame OpenEXR image. Assume EXR image contains A(single channel -// alpha) or RGB(A) channels. -// Application must free image data as returned by `out_rgba` -// Result image format is: float x RGBA x width x hight -// Returns negative value and may set error string in `err` when there's an -// error -extern int LoadEXR(float **out_rgba, int *width, int *height, - const char *filename, const char **err); - -// Loads single-frame OpenEXR image by specifying layer name. Assume EXR image -// contains A(single channel alpha) or RGB(A) channels. Application must free -// image data as returned by `out_rgba` Result image format is: float x RGBA x -// width x hight Returns negative value and may set error string in `err` when -// there's an error When the specified layer name is not found in the EXR file, -// the function will return `TINYEXR_ERROR_LAYER_NOT_FOUND`. -extern int LoadEXRWithLayer(float **out_rgba, int *width, int *height, - const char *filename, const char *layer_name, - const char **err); - -// -// Get layer infos from EXR file. -// -// @param[out] layer_names List of layer names. Application must free memory -// after using this. -// @param[out] num_layers The number of layers -// @param[out] err Error string(will be filled when the function returns error -// code). Free it using FreeEXRErrorMessage after using this value. -// -// @return TINYEXR_SUCCEES upon success. -// -extern int EXRLayers(const char *filename, const char **layer_names[], - int *num_layers, const char **err); - -// @deprecated { to be removed. } -// Simple wrapper API for ParseEXRHeaderFromFile. -// checking given file is a EXR file(by just look up header) -// @return TINYEXR_SUCCEES for EXR image, TINYEXR_ERROR_INVALID_HEADER for -// others -extern int IsEXR(const char *filename); - -// @deprecated { to be removed. } -// Saves single-frame OpenEXR image. Assume EXR image contains RGB(A) channels. -// components must be 1(Grayscale), 3(RGB) or 4(RGBA). -// Input image format is: `float x width x height`, or `float x RGB(A) x width x -// hight` -// Save image as fp16(HALF) format when `save_as_fp16` is positive non-zero -// value. -// Save image as fp32(FLOAT) format when `save_as_fp16` is 0. -// Use ZIP compression by default. -// Returns negative value and may set error string in `err` when there's an -// error -extern int SaveEXR(const float *data, const int width, const int height, - const int components, const int save_as_fp16, - const char *filename, const char **err); - -// Returns the number of resolution levels of the image (including the base) -extern int EXRNumLevels(const EXRImage* exr_image); - -// Initialize EXRHeader struct -extern void InitEXRHeader(EXRHeader *exr_header); - -// Set name attribute of EXRHeader struct (it makes a copy) -extern void EXRSetNameAttr(EXRHeader *exr_header, const char* name); - -// Initialize EXRImage struct -extern void InitEXRImage(EXRImage *exr_image); - -// Frees internal data of EXRHeader struct -extern int FreeEXRHeader(EXRHeader *exr_header); - -// Frees internal data of EXRImage struct -extern int FreeEXRImage(EXRImage *exr_image); - -// Frees error message -extern void FreeEXRErrorMessage(const char *msg); - -// Parse EXR version header of a file. -extern int ParseEXRVersionFromFile(EXRVersion *version, const char *filename); - -// Parse EXR version header from memory-mapped EXR data. -extern int ParseEXRVersionFromMemory(EXRVersion *version, - const unsigned char *memory, size_t size); - -// Parse single-part OpenEXR header from a file and initialize `EXRHeader`. -// When there was an error message, Application must free `err` with -// FreeEXRErrorMessage() -extern int ParseEXRHeaderFromFile(EXRHeader *header, const EXRVersion *version, - const char *filename, const char **err); - -// Parse single-part OpenEXR header from a memory and initialize `EXRHeader`. -// When there was an error message, Application must free `err` with -// FreeEXRErrorMessage() -extern int ParseEXRHeaderFromMemory(EXRHeader *header, - const EXRVersion *version, - const unsigned char *memory, size_t size, - const char **err); - -// Parse multi-part OpenEXR headers from a file and initialize `EXRHeader*` -// array. -// When there was an error message, Application must free `err` with -// FreeEXRErrorMessage() -extern int ParseEXRMultipartHeaderFromFile(EXRHeader ***headers, - int *num_headers, - const EXRVersion *version, - const char *filename, - const char **err); - -// Parse multi-part OpenEXR headers from a memory and initialize `EXRHeader*` -// array -// When there was an error message, Application must free `err` with -// FreeEXRErrorMessage() -extern int ParseEXRMultipartHeaderFromMemory(EXRHeader ***headers, - int *num_headers, - const EXRVersion *version, - const unsigned char *memory, - size_t size, const char **err); - -// Loads single-part OpenEXR image from a file. -// Application must setup `ParseEXRHeaderFromFile` before calling this function. -// Application can free EXRImage using `FreeEXRImage` -// Returns negative value and may set error string in `err` when there's an -// error -// When there was an error message, Application must free `err` with -// FreeEXRErrorMessage() -extern int LoadEXRImageFromFile(EXRImage *image, const EXRHeader *header, - const char *filename, const char **err); - -// Loads single-part OpenEXR image from a memory. -// Application must setup `EXRHeader` with -// `ParseEXRHeaderFromMemory` before calling this function. -// Application can free EXRImage using `FreeEXRImage` -// Returns negative value and may set error string in `err` when there's an -// error -// When there was an error message, Application must free `err` with -// FreeEXRErrorMessage() -extern int LoadEXRImageFromMemory(EXRImage *image, const EXRHeader *header, - const unsigned char *memory, - const size_t size, const char **err); - -// Loads multi-part OpenEXR image from a file. -// Application must setup `ParseEXRMultipartHeaderFromFile` before calling this -// function. -// Application can free EXRImage using `FreeEXRImage` -// Returns negative value and may set error string in `err` when there's an -// error -// When there was an error message, Application must free `err` with -// FreeEXRErrorMessage() -extern int LoadEXRMultipartImageFromFile(EXRImage *images, - const EXRHeader **headers, - unsigned int num_parts, - const char *filename, - const char **err); - -// Loads multi-part OpenEXR image from a memory. -// Application must setup `EXRHeader*` array with -// `ParseEXRMultipartHeaderFromMemory` before calling this function. -// Application can free EXRImage using `FreeEXRImage` -// Returns negative value and may set error string in `err` when there's an -// error -// When there was an error message, Application must free `err` with -// FreeEXRErrorMessage() -extern int LoadEXRMultipartImageFromMemory(EXRImage *images, - const EXRHeader **headers, - unsigned int num_parts, - const unsigned char *memory, - const size_t size, const char **err); - -// Saves multi-channel, single-frame OpenEXR image to a file. -// Returns negative value and may set error string in `err` when there's an -// error -// When there was an error message, Application must free `err` with -// FreeEXRErrorMessage() -extern int SaveEXRImageToFile(const EXRImage *image, - const EXRHeader *exr_header, const char *filename, - const char **err); - -// Saves multi-channel, single-frame OpenEXR image to a memory. -// Image is compressed using EXRImage.compression value. -// Return the number of bytes if success. -// Return zero and will set error string in `err` when there's an -// error. -// When there was an error message, Application must free `err` with -// FreeEXRErrorMessage() -extern size_t SaveEXRImageToMemory(const EXRImage *image, - const EXRHeader *exr_header, - unsigned char **memory, const char **err); - -// Saves multi-channel, multi-frame OpenEXR image to a memory. -// Image is compressed using EXRImage.compression value. -// File global attributes (eg. display_window) must be set in the first header. -// Returns negative value and may set error string in `err` when there's an -// error -// When there was an error message, Application must free `err` with -// FreeEXRErrorMessage() -extern int SaveEXRMultipartImageToFile(const EXRImage *images, - const EXRHeader **exr_headers, - unsigned int num_parts, - const char *filename, const char **err); - -// Saves multi-channel, multi-frame OpenEXR image to a memory. -// Image is compressed using EXRImage.compression value. -// File global attributes (eg. display_window) must be set in the first header. -// Return the number of bytes if success. -// Return zero and will set error string in `err` when there's an -// error. -// When there was an error message, Application must free `err` with -// FreeEXRErrorMessage() -extern size_t SaveEXRMultipartImageToMemory(const EXRImage *images, - const EXRHeader **exr_headers, - unsigned int num_parts, - unsigned char **memory, const char **err); -// Loads single-frame OpenEXR deep image. -// Application must free memory of variables in DeepImage(image, offset_table) -// Returns negative value and may set error string in `err` when there's an -// error -// When there was an error message, Application must free `err` with -// FreeEXRErrorMessage() -extern int LoadDeepEXR(DeepImage *out_image, const char *filename, - const char **err); - -// NOT YET IMPLEMENTED: -// Saves single-frame OpenEXR deep image. -// Returns negative value and may set error string in `err` when there's an -// error -// extern int SaveDeepEXR(const DeepImage *in_image, const char *filename, -// const char **err); - -// NOT YET IMPLEMENTED: -// Loads multi-part OpenEXR deep image. -// Application must free memory of variables in DeepImage(image, offset_table) -// extern int LoadMultiPartDeepEXR(DeepImage **out_image, int num_parts, const -// char *filename, -// const char **err); - -// For emscripten. -// Loads single-frame OpenEXR image from memory. Assume EXR image contains -// RGB(A) channels. -// Returns negative value and may set error string in `err` when there's an -// error -// When there was an error message, Application must free `err` with -// FreeEXRErrorMessage() -extern int LoadEXRFromMemory(float **out_rgba, int *width, int *height, - const unsigned char *memory, size_t size, - const char **err); - -#ifdef __cplusplus -} -#endif - -#endif // TINYEXR_H_ - -#ifdef TINYEXR_IMPLEMENTATION -#ifndef TINYEXR_IMPLEMENTATION_DEFINED -#define TINYEXR_IMPLEMENTATION_DEFINED - -#ifdef _WIN32 - -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif -#ifndef NOMINMAX -#define NOMINMAX -#endif -#include // for UTF-8 - -#endif - -#include -#include -#include -#include -#include -#include - -// #include // debug - -#include -#include -#include -#include - -// https://stackoverflow.com/questions/5047971/how-do-i-check-for-c11-support -#if __cplusplus > 199711L || (defined(_MSC_VER) && _MSC_VER >= 1900) -#define TINYEXR_HAS_CXX11 (1) -// C++11 -#include - -#if TINYEXR_USE_THREAD -#include -#include -#endif - -#endif // __cplusplus > 199711L - -#if TINYEXR_USE_OPENMP -#include -#endif - -#if TINYEXR_USE_MINIZ -#include "miniz.h" -#else -// Issue #46. Please include your own zlib-compatible API header before -// including `tinyexr.h` -//#include "zlib.h" -#endif - -#if TINYEXR_USE_ZFP - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Weverything" -#endif - -#include "zfp.h" - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -#endif - -namespace tinyexr { - -#if __cplusplus > 199711L -// C++11 -typedef uint64_t tinyexr_uint64; -typedef int64_t tinyexr_int64; -#else -// Although `long long` is not a standard type pre C++11, assume it is defined -// as a compiler's extension. -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wc++11-long-long" -#endif -typedef unsigned long long tinyexr_uint64; -typedef long long tinyexr_int64; -#ifdef __clang__ -#pragma clang diagnostic pop -#endif -#endif - -// static bool IsBigEndian(void) { -// union { -// unsigned int i; -// char c[4]; -// } bint = {0x01020304}; -// -// return bint.c[0] == 1; -//} - -static void SetErrorMessage(const std::string &msg, const char **err) { - if (err) { -#ifdef _WIN32 - (*err) = _strdup(msg.c_str()); -#else - (*err) = strdup(msg.c_str()); -#endif - } -} - -static const int kEXRVersionSize = 8; - -static void cpy2(unsigned short *dst_val, const unsigned short *src_val) { - unsigned char *dst = reinterpret_cast(dst_val); - const unsigned char *src = reinterpret_cast(src_val); - - dst[0] = src[0]; - dst[1] = src[1]; -} - -static void swap2(unsigned short *val) { -#ifdef TINYEXR_LITTLE_ENDIAN - (void)val; -#else - unsigned short tmp = *val; - unsigned char *dst = reinterpret_cast(val); - unsigned char *src = reinterpret_cast(&tmp); - - dst[0] = src[1]; - dst[1] = src[0]; -#endif -} - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunused-function" -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-function" -#endif -static void cpy4(int *dst_val, const int *src_val) { - unsigned char *dst = reinterpret_cast(dst_val); - const unsigned char *src = reinterpret_cast(src_val); - - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - dst[3] = src[3]; -} - -static void cpy4(unsigned int *dst_val, const unsigned int *src_val) { - unsigned char *dst = reinterpret_cast(dst_val); - const unsigned char *src = reinterpret_cast(src_val); - - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - dst[3] = src[3]; -} - -static void cpy4(float *dst_val, const float *src_val) { - unsigned char *dst = reinterpret_cast(dst_val); - const unsigned char *src = reinterpret_cast(src_val); - - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - dst[3] = src[3]; -} -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif - -static void swap4(unsigned int *val) { -#ifdef TINYEXR_LITTLE_ENDIAN - (void)val; -#else - unsigned int tmp = *val; - unsigned char *dst = reinterpret_cast(val); - unsigned char *src = reinterpret_cast(&tmp); - - dst[0] = src[3]; - dst[1] = src[2]; - dst[2] = src[1]; - dst[3] = src[0]; -#endif -} - -static void swap4(int *val) { -#ifdef TINYEXR_LITTLE_ENDIAN - (void)val; -#else - int tmp = *val; - unsigned char *dst = reinterpret_cast(val); - unsigned char *src = reinterpret_cast(&tmp); - - dst[0] = src[3]; - dst[1] = src[2]; - dst[2] = src[1]; - dst[3] = src[0]; -#endif -} - -static void swap4(float *val) { -#ifdef TINYEXR_LITTLE_ENDIAN - (void)val; -#else - float tmp = *val; - unsigned char *dst = reinterpret_cast(val); - unsigned char *src = reinterpret_cast(&tmp); - - dst[0] = src[3]; - dst[1] = src[2]; - dst[2] = src[1]; - dst[3] = src[0]; -#endif -} - -#if 0 -static void cpy8(tinyexr::tinyexr_uint64 *dst_val, const tinyexr::tinyexr_uint64 *src_val) { - unsigned char *dst = reinterpret_cast(dst_val); - const unsigned char *src = reinterpret_cast(src_val); - - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - dst[3] = src[3]; - dst[4] = src[4]; - dst[5] = src[5]; - dst[6] = src[6]; - dst[7] = src[7]; -} -#endif - -static void swap8(tinyexr::tinyexr_uint64 *val) { -#ifdef TINYEXR_LITTLE_ENDIAN - (void)val; -#else - tinyexr::tinyexr_uint64 tmp = (*val); - unsigned char *dst = reinterpret_cast(val); - unsigned char *src = reinterpret_cast(&tmp); - - dst[0] = src[7]; - dst[1] = src[6]; - dst[2] = src[5]; - dst[3] = src[4]; - dst[4] = src[3]; - dst[5] = src[2]; - dst[6] = src[1]; - dst[7] = src[0]; -#endif -} - -// https://gist.github.com/rygorous/2156668 -union FP32 { - unsigned int u; - float f; - struct { -#if TINYEXR_LITTLE_ENDIAN - unsigned int Mantissa : 23; - unsigned int Exponent : 8; - unsigned int Sign : 1; -#else - unsigned int Sign : 1; - unsigned int Exponent : 8; - unsigned int Mantissa : 23; -#endif - } s; -}; - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wpadded" -#endif - -union FP16 { - unsigned short u; - struct { -#if TINYEXR_LITTLE_ENDIAN - unsigned int Mantissa : 10; - unsigned int Exponent : 5; - unsigned int Sign : 1; -#else - unsigned int Sign : 1; - unsigned int Exponent : 5; - unsigned int Mantissa : 10; -#endif - } s; -}; - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -static FP32 half_to_float(FP16 h) { - static const FP32 magic = {113 << 23}; - static const unsigned int shifted_exp = 0x7c00 - << 13; // exponent mask after shift - FP32 o; - - o.u = (h.u & 0x7fffU) << 13U; // exponent/mantissa bits - unsigned int exp_ = shifted_exp & o.u; // just the exponent - o.u += (127 - 15) << 23; // exponent adjust - - // handle exponent special cases - if (exp_ == shifted_exp) // Inf/NaN? - o.u += (128 - 16) << 23; // extra exp adjust - else if (exp_ == 0) // Zero/Denormal? - { - o.u += 1 << 23; // extra exp adjust - o.f -= magic.f; // renormalize - } - - o.u |= (h.u & 0x8000U) << 16U; // sign bit - return o; -} - -static FP16 float_to_half_full(FP32 f) { - FP16 o = {0}; - - // Based on ISPC reference code (with minor modifications) - if (f.s.Exponent == 0) // Signed zero/denormal (which will underflow) - o.s.Exponent = 0; - else if (f.s.Exponent == 255) // Inf or NaN (all exponent bits set) - { - o.s.Exponent = 31; - o.s.Mantissa = f.s.Mantissa ? 0x200 : 0; // NaN->qNaN and Inf->Inf - } else // Normalized number - { - // Exponent unbias the single, then bias the halfp - int newexp = f.s.Exponent - 127 + 15; - if (newexp >= 31) // Overflow, return signed infinity - o.s.Exponent = 31; - else if (newexp <= 0) // Underflow - { - if ((14 - newexp) <= 24) // Mantissa might be non-zero - { - unsigned int mant = f.s.Mantissa | 0x800000; // Hidden 1 bit - o.s.Mantissa = mant >> (14 - newexp); - if ((mant >> (13 - newexp)) & 1) // Check for rounding - o.u++; // Round, might overflow into exp bit, but this is OK - } - } else { - o.s.Exponent = static_cast(newexp); - o.s.Mantissa = f.s.Mantissa >> 13; - if (f.s.Mantissa & 0x1000) // Check for rounding - o.u++; // Round, might overflow to inf, this is OK - } - } - - o.s.Sign = f.s.Sign; - return o; -} - -// NOTE: From OpenEXR code -// #define IMF_INCREASING_Y 0 -// #define IMF_DECREASING_Y 1 -// #define IMF_RAMDOM_Y 2 -// -// #define IMF_NO_COMPRESSION 0 -// #define IMF_RLE_COMPRESSION 1 -// #define IMF_ZIPS_COMPRESSION 2 -// #define IMF_ZIP_COMPRESSION 3 -// #define IMF_PIZ_COMPRESSION 4 -// #define IMF_PXR24_COMPRESSION 5 -// #define IMF_B44_COMPRESSION 6 -// #define IMF_B44A_COMPRESSION 7 - -#ifdef __clang__ -#pragma clang diagnostic push - -#if __has_warning("-Wzero-as-null-pointer-constant") -#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" -#endif - -#endif - -static const char *ReadString(std::string *s, const char *ptr, size_t len) { - // Read untile NULL(\0). - const char *p = ptr; - const char *q = ptr; - while ((size_t(q - ptr) < len) && (*q) != 0) { - q++; - } - - if (size_t(q - ptr) >= len) { - (*s) = std::string(); - return NULL; - } - - (*s) = std::string(p, q); - - return q + 1; // skip '\0' -} - -static bool ReadAttribute(std::string *name, std::string *type, - std::vector *data, size_t *marker_size, - const char *marker, size_t size) { - size_t name_len = strnlen(marker, size); - if (name_len == size) { - // String does not have a terminating character. - return false; - } - *name = std::string(marker, name_len); - - marker += name_len + 1; - size -= name_len + 1; - - size_t type_len = strnlen(marker, size); - if (type_len == size) { - return false; - } - *type = std::string(marker, type_len); - - marker += type_len + 1; - size -= type_len + 1; - - if (size < sizeof(uint32_t)) { - return false; - } - - uint32_t data_len; - memcpy(&data_len, marker, sizeof(uint32_t)); - tinyexr::swap4(reinterpret_cast(&data_len)); - - if (data_len == 0) { - if ((*type).compare("string") == 0) { - // Accept empty string attribute. - - marker += sizeof(uint32_t); - size -= sizeof(uint32_t); - - *marker_size = name_len + 1 + type_len + 1 + sizeof(uint32_t); - - data->resize(1); - (*data)[0] = '\0'; - - return true; - } else { - return false; - } - } - - marker += sizeof(uint32_t); - size -= sizeof(uint32_t); - - if (size < data_len) { - return false; - } - - data->resize(static_cast(data_len)); - memcpy(&data->at(0), marker, static_cast(data_len)); - - *marker_size = name_len + 1 + type_len + 1 + sizeof(uint32_t) + data_len; - return true; -} - -static void WriteAttributeToMemory(std::vector *out, - const char *name, const char *type, - const unsigned char *data, int len) { - out->insert(out->end(), name, name + strlen(name) + 1); - out->insert(out->end(), type, type + strlen(type) + 1); - - int outLen = len; - tinyexr::swap4(&outLen); - out->insert(out->end(), reinterpret_cast(&outLen), - reinterpret_cast(&outLen) + sizeof(int)); - out->insert(out->end(), data, data + len); -} - -typedef struct { - std::string name; // less than 255 bytes long - int pixel_type; - int requested_pixel_type; - int x_sampling; - int y_sampling; - unsigned char p_linear; - unsigned char pad[3]; -} ChannelInfo; - -typedef struct { - int min_x; - int min_y; - int max_x; - int max_y; -} Box2iInfo; - -struct HeaderInfo { - std::vector channels; - std::vector attributes; - - Box2iInfo data_window; - int line_order; - Box2iInfo display_window; - float screen_window_center[2]; - float screen_window_width; - float pixel_aspect_ratio; - - int chunk_count; - - // Tiled format - int tiled; // Non-zero if the part is tiled. - int tile_size_x; - int tile_size_y; - int tile_level_mode; - int tile_rounding_mode; - - unsigned int header_len; - - int compression_type; - - // required for multi-part or non-image files - std::string name; - // required for multi-part or non-image files - std::string type; - - void clear() { - channels.clear(); - attributes.clear(); - - data_window.min_x = 0; - data_window.min_y = 0; - data_window.max_x = 0; - data_window.max_y = 0; - line_order = 0; - display_window.min_x = 0; - display_window.min_y = 0; - display_window.max_x = 0; - display_window.max_y = 0; - screen_window_center[0] = 0.0f; - screen_window_center[1] = 0.0f; - screen_window_width = 0.0f; - pixel_aspect_ratio = 0.0f; - - chunk_count = 0; - - // Tiled format - tiled = 0; - tile_size_x = 0; - tile_size_y = 0; - tile_level_mode = 0; - tile_rounding_mode = 0; - - header_len = 0; - compression_type = 0; - - name.clear(); - type.clear(); - } -}; - -static bool ReadChannelInfo(std::vector &channels, - const std::vector &data) { - const char *p = reinterpret_cast(&data.at(0)); - - for (;;) { - if ((*p) == 0) { - break; - } - ChannelInfo info; - - tinyexr_int64 data_len = static_cast(data.size()) - - (p - reinterpret_cast(data.data())); - if (data_len < 0) { - return false; - } - - p = ReadString(&info.name, p, size_t(data_len)); - if ((p == NULL) && (info.name.empty())) { - // Buffer overrun. Issue #51. - return false; - } - - const unsigned char *data_end = - reinterpret_cast(p) + 16; - if (data_end >= (data.data() + data.size())) { - return false; - } - - memcpy(&info.pixel_type, p, sizeof(int)); - p += 4; - info.p_linear = static_cast(p[0]); // uchar - p += 1 + 3; // reserved: uchar[3] - memcpy(&info.x_sampling, p, sizeof(int)); // int - p += 4; - memcpy(&info.y_sampling, p, sizeof(int)); // int - p += 4; - - tinyexr::swap4(&info.pixel_type); - tinyexr::swap4(&info.x_sampling); - tinyexr::swap4(&info.y_sampling); - - channels.push_back(info); - } - - return true; -} - -static void WriteChannelInfo(std::vector &data, - const std::vector &channels) { - size_t sz = 0; - - // Calculate total size. - for (size_t c = 0; c < channels.size(); c++) { - sz += strlen(channels[c].name.c_str()) + 1; // +1 for \0 - sz += 16; // 4 * int - } - data.resize(sz + 1); - - unsigned char *p = &data.at(0); - - for (size_t c = 0; c < channels.size(); c++) { - memcpy(p, channels[c].name.c_str(), strlen(channels[c].name.c_str())); - p += strlen(channels[c].name.c_str()); - (*p) = '\0'; - p++; - - int pixel_type = channels[c].requested_pixel_type; - int x_sampling = channels[c].x_sampling; - int y_sampling = channels[c].y_sampling; - tinyexr::swap4(&pixel_type); - tinyexr::swap4(&x_sampling); - tinyexr::swap4(&y_sampling); - - memcpy(p, &pixel_type, sizeof(int)); - p += sizeof(int); - - (*p) = channels[c].p_linear; - p += 4; - - memcpy(p, &x_sampling, sizeof(int)); - p += sizeof(int); - - memcpy(p, &y_sampling, sizeof(int)); - p += sizeof(int); - } - - (*p) = '\0'; -} - -static void CompressZip(unsigned char *dst, - tinyexr::tinyexr_uint64 &compressedSize, - const unsigned char *src, unsigned long src_size) { - std::vector tmpBuf(src_size); - - // - // Apply EXR-specific? postprocess. Grabbed from OpenEXR's - // ImfZipCompressor.cpp - // - - // - // Reorder the pixel data. - // - - const char *srcPtr = reinterpret_cast(src); - - { - char *t1 = reinterpret_cast(&tmpBuf.at(0)); - char *t2 = reinterpret_cast(&tmpBuf.at(0)) + (src_size + 1) / 2; - const char *stop = srcPtr + src_size; - - for (;;) { - if (srcPtr < stop) - *(t1++) = *(srcPtr++); - else - break; - - if (srcPtr < stop) - *(t2++) = *(srcPtr++); - else - break; - } - } - - // - // Predictor. - // - - { - unsigned char *t = &tmpBuf.at(0) + 1; - unsigned char *stop = &tmpBuf.at(0) + src_size; - int p = t[-1]; - - while (t < stop) { - int d = int(t[0]) - p + (128 + 256); - p = t[0]; - t[0] = static_cast(d); - ++t; - } - } - -#if TINYEXR_USE_MINIZ - // - // Compress the data using miniz - // - - mz_ulong outSize = mz_compressBound(src_size); - int ret = mz_compress( - dst, &outSize, static_cast(&tmpBuf.at(0)), - src_size); - assert(ret == MZ_OK); - (void)ret; - - compressedSize = outSize; -#else - uLong outSize = compressBound(static_cast(src_size)); - int ret = compress(dst, &outSize, static_cast(&tmpBuf.at(0)), - src_size); - assert(ret == Z_OK); - - compressedSize = outSize; -#endif - - // Use uncompressed data when compressed data is larger than uncompressed. - // (Issue 40) - if (compressedSize >= src_size) { - compressedSize = src_size; - memcpy(dst, src, src_size); - } -} - -static bool DecompressZip(unsigned char *dst, - unsigned long *uncompressed_size /* inout */, - const unsigned char *src, unsigned long src_size) { - if ((*uncompressed_size) == src_size) { - // Data is not compressed(Issue 40). - memcpy(dst, src, src_size); - return true; - } - std::vector tmpBuf(*uncompressed_size); - -#if TINYEXR_USE_MINIZ - int ret = - mz_uncompress(&tmpBuf.at(0), uncompressed_size, src, src_size); - if (MZ_OK != ret) { - return false; - } -#else - int ret = uncompress(&tmpBuf.at(0), uncompressed_size, src, src_size); - if (Z_OK != ret) { - return false; - } -#endif - - // - // Apply EXR-specific? postprocess. Grabbed from OpenEXR's - // ImfZipCompressor.cpp - // - - // Predictor. - { - unsigned char *t = &tmpBuf.at(0) + 1; - unsigned char *stop = &tmpBuf.at(0) + (*uncompressed_size); - - while (t < stop) { - int d = int(t[-1]) + int(t[0]) - 128; - t[0] = static_cast(d); - ++t; - } - } - - // Reorder the pixel data. - { - const char *t1 = reinterpret_cast(&tmpBuf.at(0)); - const char *t2 = reinterpret_cast(&tmpBuf.at(0)) + - (*uncompressed_size + 1) / 2; - char *s = reinterpret_cast(dst); - char *stop = s + (*uncompressed_size); - - for (;;) { - if (s < stop) - *(s++) = *(t1++); - else - break; - - if (s < stop) - *(s++) = *(t2++); - else - break; - } - } - - return true; -} - -// RLE code from OpenEXR -------------------------------------- - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wsign-conversion" -#if __has_warning("-Wextra-semi-stmt") -#pragma clang diagnostic ignored "-Wextra-semi-stmt" -#endif -#endif - -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4204) // nonstandard extension used : non-constant - // aggregate initializer (also supported by GNU - // C and C99, so no big deal) -#pragma warning(disable : 4244) // 'initializing': conversion from '__int64' to - // 'int', possible loss of data -#pragma warning(disable : 4267) // 'argument': conversion from '__int64' to - // 'int', possible loss of data -#pragma warning(disable : 4996) // 'strdup': The POSIX name for this item is - // deprecated. Instead, use the ISO C and C++ - // conformant name: _strdup. -#endif - -const int MIN_RUN_LENGTH = 3; -const int MAX_RUN_LENGTH = 127; - -// -// Compress an array of bytes, using run-length encoding, -// and return the length of the compressed data. -// - -static int rleCompress(int inLength, const char in[], signed char out[]) { - const char *inEnd = in + inLength; - const char *runStart = in; - const char *runEnd = in + 1; - signed char *outWrite = out; - - while (runStart < inEnd) { - while (runEnd < inEnd && *runStart == *runEnd && - runEnd - runStart - 1 < MAX_RUN_LENGTH) { - ++runEnd; - } - - if (runEnd - runStart >= MIN_RUN_LENGTH) { - // - // Compressible run - // - - *outWrite++ = static_cast(runEnd - runStart) - 1; - *outWrite++ = *(reinterpret_cast(runStart)); - runStart = runEnd; - } else { - // - // Uncompressable run - // - - while (runEnd < inEnd && - ((runEnd + 1 >= inEnd || *runEnd != *(runEnd + 1)) || - (runEnd + 2 >= inEnd || *(runEnd + 1) != *(runEnd + 2))) && - runEnd - runStart < MAX_RUN_LENGTH) { - ++runEnd; - } - - *outWrite++ = static_cast(runStart - runEnd); - - while (runStart < runEnd) { - *outWrite++ = *(reinterpret_cast(runStart++)); - } - } - - ++runEnd; - } - - return static_cast(outWrite - out); -} - -// -// Uncompress an array of bytes compressed with rleCompress(). -// Returns the length of the oncompressed data, or 0 if the -// length of the uncompressed data would be more than maxLength. -// - -static int rleUncompress(int inLength, int maxLength, const signed char in[], - char out[]) { - char *outStart = out; - - while (inLength > 0) { - if (*in < 0) { - int count = -(static_cast(*in++)); - inLength -= count + 1; - - // Fixes #116: Add bounds check to in buffer. - if ((0 > (maxLength -= count)) || (inLength < 0)) return 0; - - memcpy(out, in, count); - out += count; - in += count; - } else { - int count = *in++; - inLength -= 2; - - if (0 > (maxLength -= count + 1)) return 0; - - memset(out, *reinterpret_cast(in), count + 1); - out += count + 1; - - in++; - } - } - - return static_cast(out - outStart); -} - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -// End of RLE code from OpenEXR ----------------------------------- - -static void CompressRle(unsigned char *dst, - tinyexr::tinyexr_uint64 &compressedSize, - const unsigned char *src, unsigned long src_size) { - std::vector tmpBuf(src_size); - - // - // Apply EXR-specific? postprocess. Grabbed from OpenEXR's - // ImfRleCompressor.cpp - // - - // - // Reorder the pixel data. - // - - const char *srcPtr = reinterpret_cast(src); - - { - char *t1 = reinterpret_cast(&tmpBuf.at(0)); - char *t2 = reinterpret_cast(&tmpBuf.at(0)) + (src_size + 1) / 2; - const char *stop = srcPtr + src_size; - - for (;;) { - if (srcPtr < stop) - *(t1++) = *(srcPtr++); - else - break; - - if (srcPtr < stop) - *(t2++) = *(srcPtr++); - else - break; - } - } - - // - // Predictor. - // - - { - unsigned char *t = &tmpBuf.at(0) + 1; - unsigned char *stop = &tmpBuf.at(0) + src_size; - int p = t[-1]; - - while (t < stop) { - int d = int(t[0]) - p + (128 + 256); - p = t[0]; - t[0] = static_cast(d); - ++t; - } - } - - // outSize will be (srcSiz * 3) / 2 at max. - int outSize = rleCompress(static_cast(src_size), - reinterpret_cast(&tmpBuf.at(0)), - reinterpret_cast(dst)); - assert(outSize > 0); - - compressedSize = static_cast(outSize); - - // Use uncompressed data when compressed data is larger than uncompressed. - // (Issue 40) - if (compressedSize >= src_size) { - compressedSize = src_size; - memcpy(dst, src, src_size); - } -} - -static bool DecompressRle(unsigned char *dst, - const unsigned long uncompressed_size, - const unsigned char *src, unsigned long src_size) { - if (uncompressed_size == src_size) { - // Data is not compressed(Issue 40). - memcpy(dst, src, src_size); - return true; - } - - // Workaround for issue #112. - // TODO(syoyo): Add more robust out-of-bounds check in `rleUncompress`. - if (src_size <= 2) { - return false; - } - - std::vector tmpBuf(uncompressed_size); - - int ret = rleUncompress(static_cast(src_size), - static_cast(uncompressed_size), - reinterpret_cast(src), - reinterpret_cast(&tmpBuf.at(0))); - if (ret != static_cast(uncompressed_size)) { - return false; - } - - // - // Apply EXR-specific? postprocess. Grabbed from OpenEXR's - // ImfRleCompressor.cpp - // - - // Predictor. - { - unsigned char *t = &tmpBuf.at(0) + 1; - unsigned char *stop = &tmpBuf.at(0) + uncompressed_size; - - while (t < stop) { - int d = int(t[-1]) + int(t[0]) - 128; - t[0] = static_cast(d); - ++t; - } - } - - // Reorder the pixel data. - { - const char *t1 = reinterpret_cast(&tmpBuf.at(0)); - const char *t2 = reinterpret_cast(&tmpBuf.at(0)) + - (uncompressed_size + 1) / 2; - char *s = reinterpret_cast(dst); - char *stop = s + uncompressed_size; - - for (;;) { - if (s < stop) - *(s++) = *(t1++); - else - break; - - if (s < stop) - *(s++) = *(t2++); - else - break; - } - } - - return true; -} - -#if TINYEXR_USE_PIZ - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wc++11-long-long" -#pragma clang diagnostic ignored "-Wold-style-cast" -#pragma clang diagnostic ignored "-Wpadded" -#pragma clang diagnostic ignored "-Wsign-conversion" -#pragma clang diagnostic ignored "-Wc++11-extensions" -#pragma clang diagnostic ignored "-Wconversion" -#pragma clang diagnostic ignored "-Wc++98-compat-pedantic" - -#if __has_warning("-Wcast-qual") -#pragma clang diagnostic ignored "-Wcast-qual" -#endif - -#if __has_warning("-Wextra-semi-stmt") -#pragma clang diagnostic ignored "-Wextra-semi-stmt" -#endif - -#endif - -// -// PIZ compress/uncompress, based on OpenEXR's ImfPizCompressor.cpp -// -// ----------------------------------------------------------------- -// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas -// Digital Ltd. LLC) -// (3 clause BSD license) -// - -struct PIZChannelData { - unsigned short *start; - unsigned short *end; - int nx; - int ny; - int ys; - int size; -}; - -//----------------------------------------------------------------------------- -// -// 16-bit Haar Wavelet encoding and decoding -// -// The source code in this file is derived from the encoding -// and decoding routines written by Christian Rouet for his -// PIZ image file format. -// -//----------------------------------------------------------------------------- - -// -// Wavelet basis functions without modulo arithmetic; they produce -// the best compression ratios when the wavelet-transformed data are -// Huffman-encoded, but the wavelet transform works only for 14-bit -// data (untransformed data values must be less than (1 << 14)). -// - -inline void wenc14(unsigned short a, unsigned short b, unsigned short &l, - unsigned short &h) { - short as = static_cast(a); - short bs = static_cast(b); - - short ms = (as + bs) >> 1; - short ds = as - bs; - - l = static_cast(ms); - h = static_cast(ds); -} - -inline void wdec14(unsigned short l, unsigned short h, unsigned short &a, - unsigned short &b) { - short ls = static_cast(l); - short hs = static_cast(h); - - int hi = hs; - int ai = ls + (hi & 1) + (hi >> 1); - - short as = static_cast(ai); - short bs = static_cast(ai - hi); - - a = static_cast(as); - b = static_cast(bs); -} - -// -// Wavelet basis functions with modulo arithmetic; they work with full -// 16-bit data, but Huffman-encoding the wavelet-transformed data doesn't -// compress the data quite as well. -// - -const int NBITS = 16; -const int A_OFFSET = 1 << (NBITS - 1); -const int M_OFFSET = 1 << (NBITS - 1); -const int MOD_MASK = (1 << NBITS) - 1; - -inline void wenc16(unsigned short a, unsigned short b, unsigned short &l, - unsigned short &h) { - int ao = (a + A_OFFSET) & MOD_MASK; - int m = ((ao + b) >> 1); - int d = ao - b; - - if (d < 0) m = (m + M_OFFSET) & MOD_MASK; - - d &= MOD_MASK; - - l = static_cast(m); - h = static_cast(d); -} - -inline void wdec16(unsigned short l, unsigned short h, unsigned short &a, - unsigned short &b) { - int m = l; - int d = h; - int bb = (m - (d >> 1)) & MOD_MASK; - int aa = (d + bb - A_OFFSET) & MOD_MASK; - b = static_cast(bb); - a = static_cast(aa); -} - -// -// 2D Wavelet encoding: -// - -static void wav2Encode( - unsigned short *in, // io: values are transformed in place - int nx, // i : x size - int ox, // i : x offset - int ny, // i : y size - int oy, // i : y offset - unsigned short mx) // i : maximum in[x][y] value -{ - bool w14 = (mx < (1 << 14)); - int n = (nx > ny) ? ny : nx; - int p = 1; // == 1 << level - int p2 = 2; // == 1 << (level+1) - - // - // Hierarchical loop on smaller dimension n - // - - while (p2 <= n) { - unsigned short *py = in; - unsigned short *ey = in + oy * (ny - p2); - int oy1 = oy * p; - int oy2 = oy * p2; - int ox1 = ox * p; - int ox2 = ox * p2; - unsigned short i00, i01, i10, i11; - - // - // Y loop - // - - for (; py <= ey; py += oy2) { - unsigned short *px = py; - unsigned short *ex = py + ox * (nx - p2); - - // - // X loop - // - - for (; px <= ex; px += ox2) { - unsigned short *p01 = px + ox1; - unsigned short *p10 = px + oy1; - unsigned short *p11 = p10 + ox1; - - // - // 2D wavelet encoding - // - - if (w14) { - wenc14(*px, *p01, i00, i01); - wenc14(*p10, *p11, i10, i11); - wenc14(i00, i10, *px, *p10); - wenc14(i01, i11, *p01, *p11); - } else { - wenc16(*px, *p01, i00, i01); - wenc16(*p10, *p11, i10, i11); - wenc16(i00, i10, *px, *p10); - wenc16(i01, i11, *p01, *p11); - } - } - - // - // Encode (1D) odd column (still in Y loop) - // - - if (nx & p) { - unsigned short *p10 = px + oy1; - - if (w14) - wenc14(*px, *p10, i00, *p10); - else - wenc16(*px, *p10, i00, *p10); - - *px = i00; - } - } - - // - // Encode (1D) odd line (must loop in X) - // - - if (ny & p) { - unsigned short *px = py; - unsigned short *ex = py + ox * (nx - p2); - - for (; px <= ex; px += ox2) { - unsigned short *p01 = px + ox1; - - if (w14) - wenc14(*px, *p01, i00, *p01); - else - wenc16(*px, *p01, i00, *p01); - - *px = i00; - } - } - - // - // Next level - // - - p = p2; - p2 <<= 1; - } -} - -// -// 2D Wavelet decoding: -// - -static void wav2Decode( - unsigned short *in, // io: values are transformed in place - int nx, // i : x size - int ox, // i : x offset - int ny, // i : y size - int oy, // i : y offset - unsigned short mx) // i : maximum in[x][y] value -{ - bool w14 = (mx < (1 << 14)); - int n = (nx > ny) ? ny : nx; - int p = 1; - int p2; - - // - // Search max level - // - - while (p <= n) p <<= 1; - - p >>= 1; - p2 = p; - p >>= 1; - - // - // Hierarchical loop on smaller dimension n - // - - while (p >= 1) { - unsigned short *py = in; - unsigned short *ey = in + oy * (ny - p2); - int oy1 = oy * p; - int oy2 = oy * p2; - int ox1 = ox * p; - int ox2 = ox * p2; - unsigned short i00, i01, i10, i11; - - // - // Y loop - // - - for (; py <= ey; py += oy2) { - unsigned short *px = py; - unsigned short *ex = py + ox * (nx - p2); - - // - // X loop - // - - for (; px <= ex; px += ox2) { - unsigned short *p01 = px + ox1; - unsigned short *p10 = px + oy1; - unsigned short *p11 = p10 + ox1; - - // - // 2D wavelet decoding - // - - if (w14) { - wdec14(*px, *p10, i00, i10); - wdec14(*p01, *p11, i01, i11); - wdec14(i00, i01, *px, *p01); - wdec14(i10, i11, *p10, *p11); - } else { - wdec16(*px, *p10, i00, i10); - wdec16(*p01, *p11, i01, i11); - wdec16(i00, i01, *px, *p01); - wdec16(i10, i11, *p10, *p11); - } - } - - // - // Decode (1D) odd column (still in Y loop) - // - - if (nx & p) { - unsigned short *p10 = px + oy1; - - if (w14) - wdec14(*px, *p10, i00, *p10); - else - wdec16(*px, *p10, i00, *p10); - - *px = i00; - } - } - - // - // Decode (1D) odd line (must loop in X) - // - - if (ny & p) { - unsigned short *px = py; - unsigned short *ex = py + ox * (nx - p2); - - for (; px <= ex; px += ox2) { - unsigned short *p01 = px + ox1; - - if (w14) - wdec14(*px, *p01, i00, *p01); - else - wdec16(*px, *p01, i00, *p01); - - *px = i00; - } - } - - // - // Next level - // - - p2 = p; - p >>= 1; - } -} - -//----------------------------------------------------------------------------- -// -// 16-bit Huffman compression and decompression. -// -// The source code in this file is derived from the 8-bit -// Huffman compression and decompression routines written -// by Christian Rouet for his PIZ image file format. -// -//----------------------------------------------------------------------------- - -// Adds some modification for tinyexr. - -const int HUF_ENCBITS = 16; // literal (value) bit length -const int HUF_DECBITS = 14; // decoding bit size (>= 8) - -const int HUF_ENCSIZE = (1 << HUF_ENCBITS) + 1; // encoding table size -const int HUF_DECSIZE = 1 << HUF_DECBITS; // decoding table size -const int HUF_DECMASK = HUF_DECSIZE - 1; - -struct HufDec { // short code long code - //------------------------------- - unsigned int len : 8; // code length 0 - unsigned int lit : 24; // lit p size - unsigned int *p; // 0 lits -}; - -inline long long hufLength(long long code) { return code & 63; } - -inline long long hufCode(long long code) { return code >> 6; } - -inline void outputBits(int nBits, long long bits, long long &c, int &lc, - char *&out) { - c <<= nBits; - lc += nBits; - - c |= bits; - - while (lc >= 8) *out++ = static_cast((c >> (lc -= 8))); -} - -inline long long getBits(int nBits, long long &c, int &lc, const char *&in) { - while (lc < nBits) { - c = (c << 8) | *(reinterpret_cast(in++)); - lc += 8; - } - - lc -= nBits; - return (c >> lc) & ((1 << nBits) - 1); -} - -// -// ENCODING TABLE BUILDING & (UN)PACKING -// - -// -// Build a "canonical" Huffman code table: -// - for each (uncompressed) symbol, hcode contains the length -// of the corresponding code (in the compressed data) -// - canonical codes are computed and stored in hcode -// - the rules for constructing canonical codes are as follows: -// * shorter codes (if filled with zeroes to the right) -// have a numerically higher value than longer codes -// * for codes with the same length, numerical values -// increase with numerical symbol values -// - because the canonical code table can be constructed from -// symbol lengths alone, the code table can be transmitted -// without sending the actual code values -// - see http://www.compressconsult.com/huffman/ -// - -static void hufCanonicalCodeTable(long long hcode[HUF_ENCSIZE]) { - long long n[59]; - - // - // For each i from 0 through 58, count the - // number of different codes of length i, and - // store the count in n[i]. - // - - for (int i = 0; i <= 58; ++i) n[i] = 0; - - for (int i = 0; i < HUF_ENCSIZE; ++i) n[hcode[i]] += 1; - - // - // For each i from 58 through 1, compute the - // numerically lowest code with length i, and - // store that code in n[i]. - // - - long long c = 0; - - for (int i = 58; i > 0; --i) { - long long nc = ((c + n[i]) >> 1); - n[i] = c; - c = nc; - } - - // - // hcode[i] contains the length, l, of the - // code for symbol i. Assign the next available - // code of length l to the symbol and store both - // l and the code in hcode[i]. - // - - for (int i = 0; i < HUF_ENCSIZE; ++i) { - int l = static_cast(hcode[i]); - - if (l > 0) hcode[i] = l | (n[l]++ << 6); - } -} - -// -// Compute Huffman codes (based on frq input) and store them in frq: -// - code structure is : [63:lsb - 6:msb] | [5-0: bit length]; -// - max code length is 58 bits; -// - codes outside the range [im-iM] have a null length (unused values); -// - original frequencies are destroyed; -// - encoding tables are used by hufEncode() and hufBuildDecTable(); -// - -struct FHeapCompare { - bool operator()(long long *a, long long *b) { return *a > *b; } -}; - -static void hufBuildEncTable( - long long *frq, // io: input frequencies [HUF_ENCSIZE], output table - int *im, // o: min frq index - int *iM) // o: max frq index -{ - // - // This function assumes that when it is called, array frq - // indicates the frequency of all possible symbols in the data - // that are to be Huffman-encoded. (frq[i] contains the number - // of occurrences of symbol i in the data.) - // - // The loop below does three things: - // - // 1) Finds the minimum and maximum indices that point - // to non-zero entries in frq: - // - // frq[im] != 0, and frq[i] == 0 for all i < im - // frq[iM] != 0, and frq[i] == 0 for all i > iM - // - // 2) Fills array fHeap with pointers to all non-zero - // entries in frq. - // - // 3) Initializes array hlink such that hlink[i] == i - // for all array entries. - // - - std::vector hlink(HUF_ENCSIZE); - std::vector fHeap(HUF_ENCSIZE); - - *im = 0; - - while (!frq[*im]) (*im)++; - - int nf = 0; - - for (int i = *im; i < HUF_ENCSIZE; i++) { - hlink[i] = i; - - if (frq[i]) { - fHeap[nf] = &frq[i]; - nf++; - *iM = i; - } - } - - // - // Add a pseudo-symbol, with a frequency count of 1, to frq; - // adjust the fHeap and hlink array accordingly. Function - // hufEncode() uses the pseudo-symbol for run-length encoding. - // - - (*iM)++; - frq[*iM] = 1; - fHeap[nf] = &frq[*iM]; - nf++; - - // - // Build an array, scode, such that scode[i] contains the number - // of bits assigned to symbol i. Conceptually this is done by - // constructing a tree whose leaves are the symbols with non-zero - // frequency: - // - // Make a heap that contains all symbols with a non-zero frequency, - // with the least frequent symbol on top. - // - // Repeat until only one symbol is left on the heap: - // - // Take the two least frequent symbols off the top of the heap. - // Create a new node that has first two nodes as children, and - // whose frequency is the sum of the frequencies of the first - // two nodes. Put the new node back into the heap. - // - // The last node left on the heap is the root of the tree. For each - // leaf node, the distance between the root and the leaf is the length - // of the code for the corresponding symbol. - // - // The loop below doesn't actually build the tree; instead we compute - // the distances of the leaves from the root on the fly. When a new - // node is added to the heap, then that node's descendants are linked - // into a single linear list that starts at the new node, and the code - // lengths of the descendants (that is, their distance from the root - // of the tree) are incremented by one. - // - - std::make_heap(&fHeap[0], &fHeap[nf], FHeapCompare()); - - std::vector scode(HUF_ENCSIZE); - memset(scode.data(), 0, sizeof(long long) * HUF_ENCSIZE); - - while (nf > 1) { - // - // Find the indices, mm and m, of the two smallest non-zero frq - // values in fHeap, add the smallest frq to the second-smallest - // frq, and remove the smallest frq value from fHeap. - // - - int mm = fHeap[0] - frq; - std::pop_heap(&fHeap[0], &fHeap[nf], FHeapCompare()); - --nf; - - int m = fHeap[0] - frq; - std::pop_heap(&fHeap[0], &fHeap[nf], FHeapCompare()); - - frq[m] += frq[mm]; - std::push_heap(&fHeap[0], &fHeap[nf], FHeapCompare()); - - // - // The entries in scode are linked into lists with the - // entries in hlink serving as "next" pointers and with - // the end of a list marked by hlink[j] == j. - // - // Traverse the lists that start at scode[m] and scode[mm]. - // For each element visited, increment the length of the - // corresponding code by one bit. (If we visit scode[j] - // during the traversal, then the code for symbol j becomes - // one bit longer.) - // - // Merge the lists that start at scode[m] and scode[mm] - // into a single list that starts at scode[m]. - // - - // - // Add a bit to all codes in the first list. - // - - for (int j = m;; j = hlink[j]) { - scode[j]++; - - assert(scode[j] <= 58); - - if (hlink[j] == j) { - // - // Merge the two lists. - // - - hlink[j] = mm; - break; - } - } - - // - // Add a bit to all codes in the second list - // - - for (int j = mm;; j = hlink[j]) { - scode[j]++; - - assert(scode[j] <= 58); - - if (hlink[j] == j) break; - } - } - - // - // Build a canonical Huffman code table, replacing the code - // lengths in scode with (code, code length) pairs. Copy the - // code table from scode into frq. - // - - hufCanonicalCodeTable(scode.data()); - memcpy(frq, scode.data(), sizeof(long long) * HUF_ENCSIZE); -} - -// -// Pack an encoding table: -// - only code lengths, not actual codes, are stored -// - runs of zeroes are compressed as follows: -// -// unpacked packed -// -------------------------------- -// 1 zero 0 (6 bits) -// 2 zeroes 59 -// 3 zeroes 60 -// 4 zeroes 61 -// 5 zeroes 62 -// n zeroes (6 or more) 63 n-6 (6 + 8 bits) -// - -const int SHORT_ZEROCODE_RUN = 59; -const int LONG_ZEROCODE_RUN = 63; -const int SHORTEST_LONG_RUN = 2 + LONG_ZEROCODE_RUN - SHORT_ZEROCODE_RUN; -const int LONGEST_LONG_RUN = 255 + SHORTEST_LONG_RUN; - -static void hufPackEncTable( - const long long *hcode, // i : encoding table [HUF_ENCSIZE] - int im, // i : min hcode index - int iM, // i : max hcode index - char **pcode) // o: ptr to packed table (updated) -{ - char *p = *pcode; - long long c = 0; - int lc = 0; - - for (; im <= iM; im++) { - int l = hufLength(hcode[im]); - - if (l == 0) { - int zerun = 1; - - while ((im < iM) && (zerun < LONGEST_LONG_RUN)) { - if (hufLength(hcode[im + 1]) > 0) break; - im++; - zerun++; - } - - if (zerun >= 2) { - if (zerun >= SHORTEST_LONG_RUN) { - outputBits(6, LONG_ZEROCODE_RUN, c, lc, p); - outputBits(8, zerun - SHORTEST_LONG_RUN, c, lc, p); - } else { - outputBits(6, SHORT_ZEROCODE_RUN + zerun - 2, c, lc, p); - } - continue; - } - } - - outputBits(6, l, c, lc, p); - } - - if (lc > 0) *p++ = (unsigned char)(c << (8 - lc)); - - *pcode = p; -} - -// -// Unpack an encoding table packed by hufPackEncTable(): -// - -static bool hufUnpackEncTable( - const char **pcode, // io: ptr to packed table (updated) - int ni, // i : input size (in bytes) - int im, // i : min hcode index - int iM, // i : max hcode index - long long *hcode) // o: encoding table [HUF_ENCSIZE] -{ - memset(hcode, 0, sizeof(long long) * HUF_ENCSIZE); - - const char *p = *pcode; - long long c = 0; - int lc = 0; - - for (; im <= iM; im++) { - if (p - *pcode >= ni) { - return false; - } - - long long l = hcode[im] = getBits(6, c, lc, p); // code length - - if (l == (long long)LONG_ZEROCODE_RUN) { - if (p - *pcode > ni) { - return false; - } - - int zerun = getBits(8, c, lc, p) + SHORTEST_LONG_RUN; - - if (im + zerun > iM + 1) { - return false; - } - - while (zerun--) hcode[im++] = 0; - - im--; - } else if (l >= (long long)SHORT_ZEROCODE_RUN) { - int zerun = l - SHORT_ZEROCODE_RUN + 2; - - if (im + zerun > iM + 1) { - return false; - } - - while (zerun--) hcode[im++] = 0; - - im--; - } - } - - *pcode = const_cast(p); - - hufCanonicalCodeTable(hcode); - - return true; -} - -// -// DECODING TABLE BUILDING -// - -// -// Clear a newly allocated decoding table so that it contains only zeroes. -// - -static void hufClearDecTable(HufDec *hdecod) // io: (allocated by caller) -// decoding table [HUF_DECSIZE] -{ - for (int i = 0; i < HUF_DECSIZE; i++) { - hdecod[i].len = 0; - hdecod[i].lit = 0; - hdecod[i].p = NULL; - } - // memset(hdecod, 0, sizeof(HufDec) * HUF_DECSIZE); -} - -// -// Build a decoding hash table based on the encoding table hcode: -// - short codes (<= HUF_DECBITS) are resolved with a single table access; -// - long code entry allocations are not optimized, because long codes are -// unfrequent; -// - decoding tables are used by hufDecode(); -// - -static bool hufBuildDecTable(const long long *hcode, // i : encoding table - int im, // i : min index in hcode - int iM, // i : max index in hcode - HufDec *hdecod) // o: (allocated by caller) -// decoding table [HUF_DECSIZE] -{ - // - // Init hashtable & loop on all codes. - // Assumes that hufClearDecTable(hdecod) has already been called. - // - - for (; im <= iM; im++) { - long long c = hufCode(hcode[im]); - int l = hufLength(hcode[im]); - - if (c >> l) { - // - // Error: c is supposed to be an l-bit code, - // but c contains a value that is greater - // than the largest l-bit number. - // - - // invalidTableEntry(); - return false; - } - - if (l > HUF_DECBITS) { - // - // Long code: add a secondary entry - // - - HufDec *pl = hdecod + (c >> (l - HUF_DECBITS)); - - if (pl->len) { - // - // Error: a short code has already - // been stored in table entry *pl. - // - - // invalidTableEntry(); - return false; - } - - pl->lit++; - - if (pl->p) { - unsigned int *p = pl->p; - pl->p = new unsigned int[pl->lit]; - - for (int i = 0; i < (int)pl->lit - 1; ++i) pl->p[i] = p[i]; - - delete[] p; - } else { - pl->p = new unsigned int[1]; - } - - pl->p[pl->lit - 1] = im; - } else if (l) { - // - // Short code: init all primary entries - // - - HufDec *pl = hdecod + (c << (HUF_DECBITS - l)); - - for (long long i = 1ULL << (HUF_DECBITS - l); i > 0; i--, pl++) { - if (pl->len || pl->p) { - // - // Error: a short code or a long code has - // already been stored in table entry *pl. - // - - // invalidTableEntry(); - return false; - } - - pl->len = l; - pl->lit = im; - } - } - } - - return true; -} - -// -// Free the long code entries of a decoding table built by hufBuildDecTable() -// - -static void hufFreeDecTable(HufDec *hdecod) // io: Decoding table -{ - for (int i = 0; i < HUF_DECSIZE; i++) { - if (hdecod[i].p) { - delete[] hdecod[i].p; - hdecod[i].p = 0; - } - } -} - -// -// ENCODING -// - -inline void outputCode(long long code, long long &c, int &lc, char *&out) { - outputBits(hufLength(code), hufCode(code), c, lc, out); -} - -inline void sendCode(long long sCode, int runCount, long long runCode, - long long &c, int &lc, char *&out) { - // - // Output a run of runCount instances of the symbol sCount. - // Output the symbols explicitly, or if that is shorter, output - // the sCode symbol once followed by a runCode symbol and runCount - // expressed as an 8-bit number. - // - - if (hufLength(sCode) + hufLength(runCode) + 8 < hufLength(sCode) * runCount) { - outputCode(sCode, c, lc, out); - outputCode(runCode, c, lc, out); - outputBits(8, runCount, c, lc, out); - } else { - while (runCount-- >= 0) outputCode(sCode, c, lc, out); - } -} - -// -// Encode (compress) ni values based on the Huffman encoding table hcode: -// - -static int hufEncode // return: output size (in bits) - (const long long *hcode, // i : encoding table - const unsigned short *in, // i : uncompressed input buffer - const int ni, // i : input buffer size (in bytes) - int rlc, // i : rl code - char *out) // o: compressed output buffer -{ - char *outStart = out; - long long c = 0; // bits not yet written to out - int lc = 0; // number of valid bits in c (LSB) - int s = in[0]; - int cs = 0; - - // - // Loop on input values - // - - for (int i = 1; i < ni; i++) { - // - // Count same values or send code - // - - if (s == in[i] && cs < 255) { - cs++; - } else { - sendCode(hcode[s], cs, hcode[rlc], c, lc, out); - cs = 0; - } - - s = in[i]; - } - - // - // Send remaining code - // - - sendCode(hcode[s], cs, hcode[rlc], c, lc, out); - - if (lc) *out = (c << (8 - lc)) & 0xff; - - return (out - outStart) * 8 + lc; -} - -// -// DECODING -// - -// -// In order to force the compiler to inline them, -// getChar() and getCode() are implemented as macros -// instead of "inline" functions. -// - -#define getChar(c, lc, in) \ - { \ - c = (c << 8) | *(unsigned char *)(in++); \ - lc += 8; \ - } - -#if 0 -#define getCode(po, rlc, c, lc, in, out, ob, oe) \ - { \ - if (po == rlc) { \ - if (lc < 8) getChar(c, lc, in); \ - \ - lc -= 8; \ - \ - unsigned char cs = (c >> lc); \ - \ - if (out + cs > oe) return false; \ - \ - /* TinyEXR issue 78 */ \ - unsigned short s = out[-1]; \ - \ - while (cs-- > 0) *out++ = s; \ - } else if (out < oe) { \ - *out++ = po; \ - } else { \ - return false; \ - } \ - } -#else -static bool getCode(int po, int rlc, long long &c, int &lc, const char *&in, - const char *in_end, unsigned short *&out, - const unsigned short *ob, const unsigned short *oe) { - (void)ob; - if (po == rlc) { - if (lc < 8) { - /* TinyEXR issue 78 */ - /* TinyEXR issue 160. in + 1 -> in */ - if (in >= in_end) { - return false; - } - - getChar(c, lc, in); - } - - lc -= 8; - - unsigned char cs = (c >> lc); - - if (out + cs > oe) return false; - - // Bounds check for safety - // Issue 100. - if ((out - 1) < ob) return false; - unsigned short s = out[-1]; - - while (cs-- > 0) *out++ = s; - } else if (out < oe) { - *out++ = po; - } else { - return false; - } - return true; -} -#endif - -// -// Decode (uncompress) ni bits based on encoding & decoding tables: -// - -static bool hufDecode(const long long *hcode, // i : encoding table - const HufDec *hdecod, // i : decoding table - const char *in, // i : compressed input buffer - int ni, // i : input size (in bits) - int rlc, // i : run-length code - int no, // i : expected output size (in bytes) - unsigned short *out) // o: uncompressed output buffer -{ - long long c = 0; - int lc = 0; - unsigned short *outb = out; // begin - unsigned short *oe = out + no; // end - const char *ie = in + (ni + 7) / 8; // input byte size - - // - // Loop on input bytes - // - - while (in < ie) { - getChar(c, lc, in); - - // - // Access decoding table - // - - while (lc >= HUF_DECBITS) { - const HufDec pl = hdecod[(c >> (lc - HUF_DECBITS)) & HUF_DECMASK]; - - if (pl.len) { - // - // Get short code - // - - lc -= pl.len; - // std::cout << "lit = " << pl.lit << std::endl; - // std::cout << "rlc = " << rlc << std::endl; - // std::cout << "c = " << c << std::endl; - // std::cout << "lc = " << lc << std::endl; - // std::cout << "in = " << in << std::endl; - // std::cout << "out = " << out << std::endl; - // std::cout << "oe = " << oe << std::endl; - if (!getCode(pl.lit, rlc, c, lc, in, ie, out, outb, oe)) { - return false; - } - } else { - if (!pl.p) { - return false; - } - // invalidCode(); // wrong code - - // - // Search long code - // - - int j; - - for (j = 0; j < (int)pl.lit; j++) { - int l = hufLength(hcode[pl.p[j]]); - - while (lc < l && in < ie) // get more bits - getChar(c, lc, in); - - if (lc >= l) { - if (hufCode(hcode[pl.p[j]]) == - ((c >> (lc - l)) & (((long long)(1) << l) - 1))) { - // - // Found : get long code - // - - lc -= l; - if (!getCode(pl.p[j], rlc, c, lc, in, ie, out, outb, oe)) { - return false; - } - break; - } - } - } - - if (j == pl.lit) { - return false; - // invalidCode(); // Not found - } - } - } - } - - // - // Get remaining (short) codes - // - - int i = (8 - ni) & 7; - c >>= i; - lc -= i; - - while (lc > 0) { - const HufDec pl = hdecod[(c << (HUF_DECBITS - lc)) & HUF_DECMASK]; - - if (pl.len) { - lc -= pl.len; - if (!getCode(pl.lit, rlc, c, lc, in, ie, out, outb, oe)) { - return false; - } - } else { - return false; - // invalidCode(); // wrong (long) code - } - } - - if (out - outb != no) { - return false; - } - // notEnoughData (); - - return true; -} - -static void countFrequencies(std::vector &freq, - const unsigned short data[/*n*/], int n) { - for (int i = 0; i < HUF_ENCSIZE; ++i) freq[i] = 0; - - for (int i = 0; i < n; ++i) ++freq[data[i]]; -} - -static void writeUInt(char buf[4], unsigned int i) { - unsigned char *b = (unsigned char *)buf; - - b[0] = i; - b[1] = i >> 8; - b[2] = i >> 16; - b[3] = i >> 24; -} - -static unsigned int readUInt(const char buf[4]) { - const unsigned char *b = (const unsigned char *)buf; - - return (b[0] & 0x000000ff) | ((b[1] << 8) & 0x0000ff00) | - ((b[2] << 16) & 0x00ff0000) | ((b[3] << 24) & 0xff000000); -} - -// -// EXTERNAL INTERFACE -// - -static int hufCompress(const unsigned short raw[], int nRaw, - char compressed[]) { - if (nRaw == 0) return 0; - - std::vector freq(HUF_ENCSIZE); - - countFrequencies(freq, raw, nRaw); - - int im = 0; - int iM = 0; - hufBuildEncTable(freq.data(), &im, &iM); - - char *tableStart = compressed + 20; - char *tableEnd = tableStart; - hufPackEncTable(freq.data(), im, iM, &tableEnd); - int tableLength = tableEnd - tableStart; - - char *dataStart = tableEnd; - int nBits = hufEncode(freq.data(), raw, nRaw, iM, dataStart); - int data_length = (nBits + 7) / 8; - - writeUInt(compressed, im); - writeUInt(compressed + 4, iM); - writeUInt(compressed + 8, tableLength); - writeUInt(compressed + 12, nBits); - writeUInt(compressed + 16, 0); // room for future extensions - - return dataStart + data_length - compressed; -} - -static bool hufUncompress(const char compressed[], int nCompressed, - std::vector *raw) { - if (nCompressed == 0) { - if (raw->size() != 0) return false; - - return false; - } - - int im = readUInt(compressed); - int iM = readUInt(compressed + 4); - // int tableLength = readUInt (compressed + 8); - int nBits = readUInt(compressed + 12); - - if (im < 0 || im >= HUF_ENCSIZE || iM < 0 || iM >= HUF_ENCSIZE) return false; - - const char *ptr = compressed + 20; - - // - // Fast decoder needs at least 2x64-bits of compressed data, and - // needs to be run-able on this platform. Otherwise, fall back - // to the original decoder - // - - // if (FastHufDecoder::enabled() && nBits > 128) - //{ - // FastHufDecoder fhd (ptr, nCompressed - (ptr - compressed), im, iM, iM); - // fhd.decode ((unsigned char*)ptr, nBits, raw, nRaw); - //} - // else - { - std::vector freq(HUF_ENCSIZE); - std::vector hdec(HUF_DECSIZE); - - hufClearDecTable(&hdec.at(0)); - - hufUnpackEncTable(&ptr, nCompressed - (ptr - compressed), im, iM, - &freq.at(0)); - - { - if (nBits > 8 * (nCompressed - (ptr - compressed))) { - return false; - } - - hufBuildDecTable(&freq.at(0), im, iM, &hdec.at(0)); - hufDecode(&freq.at(0), &hdec.at(0), ptr, nBits, iM, raw->size(), - raw->data()); - } - // catch (...) - //{ - // hufFreeDecTable (hdec); - // throw; - //} - - hufFreeDecTable(&hdec.at(0)); - } - - return true; -} - -// -// Functions to compress the range of values in the pixel data -// - -const int USHORT_RANGE = (1 << 16); -const int BITMAP_SIZE = (USHORT_RANGE >> 3); - -static void bitmapFromData(const unsigned short data[/*nData*/], int nData, - unsigned char bitmap[BITMAP_SIZE], - unsigned short &minNonZero, - unsigned short &maxNonZero) { - for (int i = 0; i < BITMAP_SIZE; ++i) bitmap[i] = 0; - - for (int i = 0; i < nData; ++i) bitmap[data[i] >> 3] |= (1 << (data[i] & 7)); - - bitmap[0] &= ~1; // zero is not explicitly stored in - // the bitmap; we assume that the - // data always contain zeroes - minNonZero = BITMAP_SIZE - 1; - maxNonZero = 0; - - for (int i = 0; i < BITMAP_SIZE; ++i) { - if (bitmap[i]) { - if (minNonZero > i) minNonZero = i; - if (maxNonZero < i) maxNonZero = i; - } - } -} - -static unsigned short forwardLutFromBitmap( - const unsigned char bitmap[BITMAP_SIZE], unsigned short lut[USHORT_RANGE]) { - int k = 0; - - for (int i = 0; i < USHORT_RANGE; ++i) { - if ((i == 0) || (bitmap[i >> 3] & (1 << (i & 7)))) - lut[i] = k++; - else - lut[i] = 0; - } - - return k - 1; // maximum value stored in lut[], -} // i.e. number of ones in bitmap minus 1 - -static unsigned short reverseLutFromBitmap( - const unsigned char bitmap[BITMAP_SIZE], unsigned short lut[USHORT_RANGE]) { - int k = 0; - - for (int i = 0; i < USHORT_RANGE; ++i) { - if ((i == 0) || (bitmap[i >> 3] & (1 << (i & 7)))) lut[k++] = i; - } - - int n = k - 1; - - while (k < USHORT_RANGE) lut[k++] = 0; - - return n; // maximum k where lut[k] is non-zero, -} // i.e. number of ones in bitmap minus 1 - -static void applyLut(const unsigned short lut[USHORT_RANGE], - unsigned short data[/*nData*/], int nData) { - for (int i = 0; i < nData; ++i) data[i] = lut[data[i]]; -} - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif // __clang__ - -#ifdef _MSC_VER -#pragma warning(pop) -#endif - -static bool CompressPiz(unsigned char *outPtr, unsigned int *outSize, - const unsigned char *inPtr, size_t inSize, - const std::vector &channelInfo, - int data_width, int num_lines) { - std::vector bitmap(BITMAP_SIZE); - unsigned short minNonZero; - unsigned short maxNonZero; - -#if !TINYEXR_LITTLE_ENDIAN - // @todo { PIZ compression on BigEndian architecture. } - assert(0); - return false; -#endif - - // Assume `inSize` is multiple of 2 or 4. - std::vector tmpBuffer(inSize / sizeof(unsigned short)); - - std::vector channelData(channelInfo.size()); - unsigned short *tmpBufferEnd = &tmpBuffer.at(0); - - for (size_t c = 0; c < channelData.size(); c++) { - PIZChannelData &cd = channelData[c]; - - cd.start = tmpBufferEnd; - cd.end = cd.start; - - cd.nx = data_width; - cd.ny = num_lines; - // cd.ys = c.channel().ySampling; - - size_t pixelSize = sizeof(int); // UINT and FLOAT - if (channelInfo[c].requested_pixel_type == TINYEXR_PIXELTYPE_HALF) { - pixelSize = sizeof(short); - } - - cd.size = static_cast(pixelSize / sizeof(short)); - - tmpBufferEnd += cd.nx * cd.ny * cd.size; - } - - const unsigned char *ptr = inPtr; - for (int y = 0; y < num_lines; ++y) { - for (size_t i = 0; i < channelData.size(); ++i) { - PIZChannelData &cd = channelData[i]; - - // if (modp (y, cd.ys) != 0) - // continue; - - size_t n = static_cast(cd.nx * cd.size); - memcpy(cd.end, ptr, n * sizeof(unsigned short)); - ptr += n * sizeof(unsigned short); - cd.end += n; - } - } - - bitmapFromData(&tmpBuffer.at(0), static_cast(tmpBuffer.size()), - bitmap.data(), minNonZero, maxNonZero); - - std::vector lut(USHORT_RANGE); - unsigned short maxValue = forwardLutFromBitmap(bitmap.data(), lut.data()); - applyLut(lut.data(), &tmpBuffer.at(0), static_cast(tmpBuffer.size())); - - // - // Store range compression info in _outBuffer - // - - char *buf = reinterpret_cast(outPtr); - - memcpy(buf, &minNonZero, sizeof(unsigned short)); - buf += sizeof(unsigned short); - memcpy(buf, &maxNonZero, sizeof(unsigned short)); - buf += sizeof(unsigned short); - - if (minNonZero <= maxNonZero) { - memcpy(buf, reinterpret_cast(&bitmap[0] + minNonZero), - maxNonZero - minNonZero + 1); - buf += maxNonZero - minNonZero + 1; - } - - // - // Apply wavelet encoding - // - - for (size_t i = 0; i < channelData.size(); ++i) { - PIZChannelData &cd = channelData[i]; - - for (int j = 0; j < cd.size; ++j) { - wav2Encode(cd.start + j, cd.nx, cd.size, cd.ny, cd.nx * cd.size, - maxValue); - } - } - - // - // Apply Huffman encoding; append the result to _outBuffer - // - - // length header(4byte), then huff data. Initialize length header with zero, - // then later fill it by `length`. - char *lengthPtr = buf; - int zero = 0; - memcpy(buf, &zero, sizeof(int)); - buf += sizeof(int); - - int length = - hufCompress(&tmpBuffer.at(0), static_cast(tmpBuffer.size()), buf); - memcpy(lengthPtr, &length, sizeof(int)); - - (*outSize) = static_cast( - (reinterpret_cast(buf) - outPtr) + - static_cast(length)); - - // Use uncompressed data when compressed data is larger than uncompressed. - // (Issue 40) - if ((*outSize) >= inSize) { - (*outSize) = static_cast(inSize); - memcpy(outPtr, inPtr, inSize); - } - return true; -} - -static bool DecompressPiz(unsigned char *outPtr, const unsigned char *inPtr, - size_t tmpBufSizeInBytes, size_t inLen, int num_channels, - const EXRChannelInfo *channels, int data_width, - int num_lines) { - if (inLen == tmpBufSizeInBytes) { - // Data is not compressed(Issue 40). - memcpy(outPtr, inPtr, inLen); - return true; - } - - std::vector bitmap(BITMAP_SIZE); - unsigned short minNonZero; - unsigned short maxNonZero; - -#if !TINYEXR_LITTLE_ENDIAN - // @todo { PIZ compression on BigEndian architecture. } - assert(0); - return false; -#endif - - memset(bitmap.data(), 0, BITMAP_SIZE); - - const unsigned char *ptr = inPtr; - // minNonZero = *(reinterpret_cast(ptr)); - tinyexr::cpy2(&minNonZero, reinterpret_cast(ptr)); - // maxNonZero = *(reinterpret_cast(ptr + 2)); - tinyexr::cpy2(&maxNonZero, reinterpret_cast(ptr + 2)); - ptr += 4; - - if (maxNonZero >= BITMAP_SIZE) { - return false; - } - - if (minNonZero <= maxNonZero) { - memcpy(reinterpret_cast(&bitmap[0] + minNonZero), ptr, - maxNonZero - minNonZero + 1); - ptr += maxNonZero - minNonZero + 1; - } - - std::vector lut(USHORT_RANGE); - memset(lut.data(), 0, sizeof(unsigned short) * USHORT_RANGE); - unsigned short maxValue = reverseLutFromBitmap(bitmap.data(), lut.data()); - - // - // Huffman decoding - // - - int length; - - // length = *(reinterpret_cast(ptr)); - tinyexr::cpy4(&length, reinterpret_cast(ptr)); - ptr += sizeof(int); - - if (size_t((ptr - inPtr) + length) > inLen) { - return false; - } - - std::vector tmpBuffer(tmpBufSizeInBytes / sizeof(unsigned short)); - hufUncompress(reinterpret_cast(ptr), length, &tmpBuffer); - - // - // Wavelet decoding - // - - std::vector channelData(static_cast(num_channels)); - - unsigned short *tmpBufferEnd = &tmpBuffer.at(0); - - for (size_t i = 0; i < static_cast(num_channels); ++i) { - const EXRChannelInfo &chan = channels[i]; - - size_t pixelSize = sizeof(int); // UINT and FLOAT - if (chan.pixel_type == TINYEXR_PIXELTYPE_HALF) { - pixelSize = sizeof(short); - } - - channelData[i].start = tmpBufferEnd; - channelData[i].end = channelData[i].start; - channelData[i].nx = data_width; - channelData[i].ny = num_lines; - // channelData[i].ys = 1; - channelData[i].size = static_cast(pixelSize / sizeof(short)); - - tmpBufferEnd += channelData[i].nx * channelData[i].ny * channelData[i].size; - } - - for (size_t i = 0; i < channelData.size(); ++i) { - PIZChannelData &cd = channelData[i]; - - for (int j = 0; j < cd.size; ++j) { - wav2Decode(cd.start + j, cd.nx, cd.size, cd.ny, cd.nx * cd.size, - maxValue); - } - } - - // - // Expand the pixel data to their original range - // - - applyLut(lut.data(), &tmpBuffer.at(0), static_cast(tmpBufSizeInBytes / sizeof(unsigned short))); - - for (int y = 0; y < num_lines; y++) { - for (size_t i = 0; i < channelData.size(); ++i) { - PIZChannelData &cd = channelData[i]; - - // if (modp (y, cd.ys) != 0) - // continue; - - size_t n = static_cast(cd.nx * cd.size); - memcpy(outPtr, cd.end, static_cast(n * sizeof(unsigned short))); - outPtr += n * sizeof(unsigned short); - cd.end += n; - } - } - - return true; -} -#endif // TINYEXR_USE_PIZ - -#if TINYEXR_USE_ZFP - -struct ZFPCompressionParam { - double rate; - unsigned int precision; - unsigned int __pad0; - double tolerance; - int type; // TINYEXR_ZFP_COMPRESSIONTYPE_* - unsigned int __pad1; - - ZFPCompressionParam() { - type = TINYEXR_ZFP_COMPRESSIONTYPE_RATE; - rate = 2.0; - precision = 0; - tolerance = 0.0; - } -}; - -static bool FindZFPCompressionParam(ZFPCompressionParam *param, - const EXRAttribute *attributes, - int num_attributes, std::string *err) { - bool foundType = false; - - for (int i = 0; i < num_attributes; i++) { - if ((strcmp(attributes[i].name, "zfpCompressionType") == 0)) { - if (attributes[i].size == 1) { - param->type = static_cast(attributes[i].value[0]); - foundType = true; - break; - } else { - if (err) { - (*err) += - "zfpCompressionType attribute must be uchar(1 byte) type.\n"; - } - return false; - } - } - } - - if (!foundType) { - if (err) { - (*err) += "`zfpCompressionType` attribute not found.\n"; - } - return false; - } - - if (param->type == TINYEXR_ZFP_COMPRESSIONTYPE_RATE) { - for (int i = 0; i < num_attributes; i++) { - if ((strcmp(attributes[i].name, "zfpCompressionRate") == 0) && - (attributes[i].size == 8)) { - param->rate = *(reinterpret_cast(attributes[i].value)); - return true; - } - } - - if (err) { - (*err) += "`zfpCompressionRate` attribute not found.\n"; - } - - } else if (param->type == TINYEXR_ZFP_COMPRESSIONTYPE_PRECISION) { - for (int i = 0; i < num_attributes; i++) { - if ((strcmp(attributes[i].name, "zfpCompressionPrecision") == 0) && - (attributes[i].size == 4)) { - param->rate = *(reinterpret_cast(attributes[i].value)); - return true; - } - } - - if (err) { - (*err) += "`zfpCompressionPrecision` attribute not found.\n"; - } - - } else if (param->type == TINYEXR_ZFP_COMPRESSIONTYPE_ACCURACY) { - for (int i = 0; i < num_attributes; i++) { - if ((strcmp(attributes[i].name, "zfpCompressionTolerance") == 0) && - (attributes[i].size == 8)) { - param->tolerance = *(reinterpret_cast(attributes[i].value)); - return true; - } - } - - if (err) { - (*err) += "`zfpCompressionTolerance` attribute not found.\n"; - } - } else { - if (err) { - (*err) += "Unknown value specified for `zfpCompressionType`.\n"; - } - } - - return false; -} - -// Assume pixel format is FLOAT for all channels. -static bool DecompressZfp(float *dst, int dst_width, int dst_num_lines, - size_t num_channels, const unsigned char *src, - unsigned long src_size, - const ZFPCompressionParam ¶m) { - size_t uncompressed_size = - size_t(dst_width) * size_t(dst_num_lines) * num_channels; - - if (uncompressed_size == src_size) { - // Data is not compressed(Issue 40). - memcpy(dst, src, src_size); - } - - zfp_stream *zfp = NULL; - zfp_field *field = NULL; - - assert((dst_width % 4) == 0); - assert((dst_num_lines % 4) == 0); - - if ((size_t(dst_width) & 3U) || (size_t(dst_num_lines) & 3U)) { - return false; - } - - field = - zfp_field_2d(reinterpret_cast(const_cast(src)), - zfp_type_float, static_cast(dst_width), - static_cast(dst_num_lines) * - static_cast(num_channels)); - zfp = zfp_stream_open(NULL); - - if (param.type == TINYEXR_ZFP_COMPRESSIONTYPE_RATE) { - zfp_stream_set_rate(zfp, param.rate, zfp_type_float, /* dimension */ 2, - /* write random access */ 0); - } else if (param.type == TINYEXR_ZFP_COMPRESSIONTYPE_PRECISION) { - zfp_stream_set_precision(zfp, param.precision); - } else if (param.type == TINYEXR_ZFP_COMPRESSIONTYPE_ACCURACY) { - zfp_stream_set_accuracy(zfp, param.tolerance); - } else { - assert(0); - } - - size_t buf_size = zfp_stream_maximum_size(zfp, field); - std::vector buf(buf_size); - memcpy(&buf.at(0), src, src_size); - - bitstream *stream = stream_open(&buf.at(0), buf_size); - zfp_stream_set_bit_stream(zfp, stream); - zfp_stream_rewind(zfp); - - size_t image_size = size_t(dst_width) * size_t(dst_num_lines); - - for (size_t c = 0; c < size_t(num_channels); c++) { - // decompress 4x4 pixel block. - for (size_t y = 0; y < size_t(dst_num_lines); y += 4) { - for (size_t x = 0; x < size_t(dst_width); x += 4) { - float fblock[16]; - zfp_decode_block_float_2(zfp, fblock); - for (size_t j = 0; j < 4; j++) { - for (size_t i = 0; i < 4; i++) { - dst[c * image_size + ((y + j) * size_t(dst_width) + (x + i))] = - fblock[j * 4 + i]; - } - } - } - } - } - - zfp_field_free(field); - zfp_stream_close(zfp); - stream_close(stream); - - return true; -} - -// Assume pixel format is FLOAT for all channels. -static bool CompressZfp(std::vector *outBuf, - unsigned int *outSize, const float *inPtr, int width, - int num_lines, int num_channels, - const ZFPCompressionParam ¶m) { - zfp_stream *zfp = NULL; - zfp_field *field = NULL; - - assert((width % 4) == 0); - assert((num_lines % 4) == 0); - - if ((size_t(width) & 3U) || (size_t(num_lines) & 3U)) { - return false; - } - - // create input array. - field = zfp_field_2d(reinterpret_cast(const_cast(inPtr)), - zfp_type_float, static_cast(width), - static_cast(num_lines * num_channels)); - - zfp = zfp_stream_open(NULL); - - if (param.type == TINYEXR_ZFP_COMPRESSIONTYPE_RATE) { - zfp_stream_set_rate(zfp, param.rate, zfp_type_float, 2, 0); - } else if (param.type == TINYEXR_ZFP_COMPRESSIONTYPE_PRECISION) { - zfp_stream_set_precision(zfp, param.precision); - } else if (param.type == TINYEXR_ZFP_COMPRESSIONTYPE_ACCURACY) { - zfp_stream_set_accuracy(zfp, param.tolerance); - } else { - assert(0); - } - - size_t buf_size = zfp_stream_maximum_size(zfp, field); - - outBuf->resize(buf_size); - - bitstream *stream = stream_open(&outBuf->at(0), buf_size); - zfp_stream_set_bit_stream(zfp, stream); - zfp_field_free(field); - - size_t image_size = size_t(width) * size_t(num_lines); - - for (size_t c = 0; c < size_t(num_channels); c++) { - // compress 4x4 pixel block. - for (size_t y = 0; y < size_t(num_lines); y += 4) { - for (size_t x = 0; x < size_t(width); x += 4) { - float fblock[16]; - for (size_t j = 0; j < 4; j++) { - for (size_t i = 0; i < 4; i++) { - fblock[j * 4 + i] = - inPtr[c * image_size + ((y + j) * size_t(width) + (x + i))]; - } - } - zfp_encode_block_float_2(zfp, fblock); - } - } - } - - zfp_stream_flush(zfp); - (*outSize) = static_cast(zfp_stream_compressed_size(zfp)); - - zfp_stream_close(zfp); - - return true; -} - -#endif - -// -// ----------------------------------------------------------------- -// - -// heuristics -#define TINYEXR_DIMENSION_THRESHOLD (1024 * 8192) - -// TODO(syoyo): Refactor function arguments. -static bool DecodePixelData(/* out */ unsigned char **out_images, - const int *requested_pixel_types, - const unsigned char *data_ptr, size_t data_len, - int compression_type, int line_order, int width, - int height, int x_stride, int y, int line_no, - int num_lines, size_t pixel_data_size, - size_t num_attributes, - const EXRAttribute *attributes, size_t num_channels, - const EXRChannelInfo *channels, - const std::vector &channel_offset_list) { - if (compression_type == TINYEXR_COMPRESSIONTYPE_PIZ) { // PIZ -#if TINYEXR_USE_PIZ - if ((width == 0) || (num_lines == 0) || (pixel_data_size == 0)) { - // Invalid input #90 - return false; - } - - // Allocate original data size. - std::vector outBuf(static_cast( - static_cast(width * num_lines) * pixel_data_size)); - size_t tmpBufLen = outBuf.size(); - - bool ret = tinyexr::DecompressPiz( - reinterpret_cast(&outBuf.at(0)), data_ptr, tmpBufLen, - data_len, static_cast(num_channels), channels, width, num_lines); - - if (!ret) { - return false; - } - - // For PIZ_COMPRESSION: - // pixel sample data for channel 0 for scanline 0 - // pixel sample data for channel 1 for scanline 0 - // pixel sample data for channel ... for scanline 0 - // pixel sample data for channel n for scanline 0 - // pixel sample data for channel 0 for scanline 1 - // pixel sample data for channel 1 for scanline 1 - // pixel sample data for channel ... for scanline 1 - // pixel sample data for channel n for scanline 1 - // ... - for (size_t c = 0; c < static_cast(num_channels); c++) { - if (channels[c].pixel_type == TINYEXR_PIXELTYPE_HALF) { - for (size_t v = 0; v < static_cast(num_lines); v++) { - const unsigned short *line_ptr = reinterpret_cast( - &outBuf.at(v * pixel_data_size * static_cast(width) + - channel_offset_list[c] * static_cast(width))); - for (size_t u = 0; u < static_cast(width); u++) { - FP16 hf; - - // hf.u = line_ptr[u]; - // use `cpy` to avoid unaligned memory access when compiler's - // optimization is on. - tinyexr::cpy2(&(hf.u), line_ptr + u); - - tinyexr::swap2(reinterpret_cast(&hf.u)); - - if (requested_pixel_types[c] == TINYEXR_PIXELTYPE_HALF) { - unsigned short *image = - reinterpret_cast(out_images)[c]; - if (line_order == 0) { - image += (static_cast(line_no) + v) * - static_cast(x_stride) + - u; - } else { - image += static_cast( - (height - 1 - (line_no + static_cast(v)))) * - static_cast(x_stride) + - u; - } - *image = hf.u; - } else { // HALF -> FLOAT - FP32 f32 = half_to_float(hf); - float *image = reinterpret_cast(out_images)[c]; - size_t offset = 0; - if (line_order == 0) { - offset = (static_cast(line_no) + v) * - static_cast(x_stride) + - u; - } else { - offset = static_cast( - (height - 1 - (line_no + static_cast(v)))) * - static_cast(x_stride) + - u; - } - image += offset; - *image = f32.f; - } - } - } - } else if (channels[c].pixel_type == TINYEXR_PIXELTYPE_UINT) { - assert(requested_pixel_types[c] == TINYEXR_PIXELTYPE_UINT); - - for (size_t v = 0; v < static_cast(num_lines); v++) { - const unsigned int *line_ptr = reinterpret_cast( - &outBuf.at(v * pixel_data_size * static_cast(width) + - channel_offset_list[c] * static_cast(width))); - for (size_t u = 0; u < static_cast(width); u++) { - unsigned int val; - // val = line_ptr[u]; - tinyexr::cpy4(&val, line_ptr + u); - - tinyexr::swap4(&val); - - unsigned int *image = - reinterpret_cast(out_images)[c]; - if (line_order == 0) { - image += (static_cast(line_no) + v) * - static_cast(x_stride) + - u; - } else { - image += static_cast( - (height - 1 - (line_no + static_cast(v)))) * - static_cast(x_stride) + - u; - } - *image = val; - } - } - } else if (channels[c].pixel_type == TINYEXR_PIXELTYPE_FLOAT) { - assert(requested_pixel_types[c] == TINYEXR_PIXELTYPE_FLOAT); - for (size_t v = 0; v < static_cast(num_lines); v++) { - const float *line_ptr = reinterpret_cast(&outBuf.at( - v * pixel_data_size * static_cast(x_stride) + - channel_offset_list[c] * static_cast(x_stride))); - for (size_t u = 0; u < static_cast(width); u++) { - float val; - // val = line_ptr[u]; - tinyexr::cpy4(&val, line_ptr + u); - - tinyexr::swap4(reinterpret_cast(&val)); - - float *image = reinterpret_cast(out_images)[c]; - if (line_order == 0) { - image += (static_cast(line_no) + v) * - static_cast(x_stride) + - u; - } else { - image += static_cast( - (height - 1 - (line_no + static_cast(v)))) * - static_cast(x_stride) + - u; - } - *image = val; - } - } - } else { - assert(0); - } - } -#else - assert(0 && "PIZ is enabled in this build"); - return false; -#endif - - } else if (compression_type == TINYEXR_COMPRESSIONTYPE_ZIPS || - compression_type == TINYEXR_COMPRESSIONTYPE_ZIP) { - // Allocate original data size. - std::vector outBuf(static_cast(width) * - static_cast(num_lines) * - pixel_data_size); - - unsigned long dstLen = static_cast(outBuf.size()); - assert(dstLen > 0); - if (!tinyexr::DecompressZip( - reinterpret_cast(&outBuf.at(0)), &dstLen, data_ptr, - static_cast(data_len))) { - return false; - } - - // For ZIP_COMPRESSION: - // pixel sample data for channel 0 for scanline 0 - // pixel sample data for channel 1 for scanline 0 - // pixel sample data for channel ... for scanline 0 - // pixel sample data for channel n for scanline 0 - // pixel sample data for channel 0 for scanline 1 - // pixel sample data for channel 1 for scanline 1 - // pixel sample data for channel ... for scanline 1 - // pixel sample data for channel n for scanline 1 - // ... - for (size_t c = 0; c < static_cast(num_channels); c++) { - if (channels[c].pixel_type == TINYEXR_PIXELTYPE_HALF) { - for (size_t v = 0; v < static_cast(num_lines); v++) { - const unsigned short *line_ptr = reinterpret_cast( - &outBuf.at(v * static_cast(pixel_data_size) * - static_cast(width) + - channel_offset_list[c] * static_cast(width))); - for (size_t u = 0; u < static_cast(width); u++) { - tinyexr::FP16 hf; - - // hf.u = line_ptr[u]; - tinyexr::cpy2(&(hf.u), line_ptr + u); - - tinyexr::swap2(reinterpret_cast(&hf.u)); - - if (requested_pixel_types[c] == TINYEXR_PIXELTYPE_HALF) { - unsigned short *image = - reinterpret_cast(out_images)[c]; - if (line_order == 0) { - image += (static_cast(line_no) + v) * - static_cast(x_stride) + - u; - } else { - image += (static_cast(height) - 1U - - (static_cast(line_no) + v)) * - static_cast(x_stride) + - u; - } - *image = hf.u; - } else { // HALF -> FLOAT - tinyexr::FP32 f32 = half_to_float(hf); - float *image = reinterpret_cast(out_images)[c]; - size_t offset = 0; - if (line_order == 0) { - offset = (static_cast(line_no) + v) * - static_cast(x_stride) + - u; - } else { - offset = (static_cast(height) - 1U - - (static_cast(line_no) + v)) * - static_cast(x_stride) + - u; - } - image += offset; - - *image = f32.f; - } - } - } - } else if (channels[c].pixel_type == TINYEXR_PIXELTYPE_UINT) { - assert(requested_pixel_types[c] == TINYEXR_PIXELTYPE_UINT); - - for (size_t v = 0; v < static_cast(num_lines); v++) { - const unsigned int *line_ptr = reinterpret_cast( - &outBuf.at(v * pixel_data_size * static_cast(width) + - channel_offset_list[c] * static_cast(width))); - for (size_t u = 0; u < static_cast(width); u++) { - unsigned int val; - // val = line_ptr[u]; - tinyexr::cpy4(&val, line_ptr + u); - - tinyexr::swap4(&val); - - unsigned int *image = - reinterpret_cast(out_images)[c]; - if (line_order == 0) { - image += (static_cast(line_no) + v) * - static_cast(x_stride) + - u; - } else { - image += (static_cast(height) - 1U - - (static_cast(line_no) + v)) * - static_cast(x_stride) + - u; - } - *image = val; - } - } - } else if (channels[c].pixel_type == TINYEXR_PIXELTYPE_FLOAT) { - assert(requested_pixel_types[c] == TINYEXR_PIXELTYPE_FLOAT); - for (size_t v = 0; v < static_cast(num_lines); v++) { - const float *line_ptr = reinterpret_cast( - &outBuf.at(v * pixel_data_size * static_cast(width) + - channel_offset_list[c] * static_cast(width))); - for (size_t u = 0; u < static_cast(width); u++) { - float val; - // val = line_ptr[u]; - tinyexr::cpy4(&val, line_ptr + u); - - tinyexr::swap4(reinterpret_cast(&val)); - - float *image = reinterpret_cast(out_images)[c]; - if (line_order == 0) { - image += (static_cast(line_no) + v) * - static_cast(x_stride) + - u; - } else { - image += (static_cast(height) - 1U - - (static_cast(line_no) + v)) * - static_cast(x_stride) + - u; - } - *image = val; - } - } - } else { - assert(0); - return false; - } - } - } else if (compression_type == TINYEXR_COMPRESSIONTYPE_RLE) { - // Allocate original data size. - std::vector outBuf(static_cast(width) * - static_cast(num_lines) * - pixel_data_size); - - unsigned long dstLen = static_cast(outBuf.size()); - if (dstLen == 0) { - return false; - } - - if (!tinyexr::DecompressRle( - reinterpret_cast(&outBuf.at(0)), dstLen, data_ptr, - static_cast(data_len))) { - return false; - } - - // For RLE_COMPRESSION: - // pixel sample data for channel 0 for scanline 0 - // pixel sample data for channel 1 for scanline 0 - // pixel sample data for channel ... for scanline 0 - // pixel sample data for channel n for scanline 0 - // pixel sample data for channel 0 for scanline 1 - // pixel sample data for channel 1 for scanline 1 - // pixel sample data for channel ... for scanline 1 - // pixel sample data for channel n for scanline 1 - // ... - for (size_t c = 0; c < static_cast(num_channels); c++) { - if (channels[c].pixel_type == TINYEXR_PIXELTYPE_HALF) { - for (size_t v = 0; v < static_cast(num_lines); v++) { - const unsigned short *line_ptr = reinterpret_cast( - &outBuf.at(v * static_cast(pixel_data_size) * - static_cast(width) + - channel_offset_list[c] * static_cast(width))); - for (size_t u = 0; u < static_cast(width); u++) { - tinyexr::FP16 hf; - - // hf.u = line_ptr[u]; - tinyexr::cpy2(&(hf.u), line_ptr + u); - - tinyexr::swap2(reinterpret_cast(&hf.u)); - - if (requested_pixel_types[c] == TINYEXR_PIXELTYPE_HALF) { - unsigned short *image = - reinterpret_cast(out_images)[c]; - if (line_order == 0) { - image += (static_cast(line_no) + v) * - static_cast(x_stride) + - u; - } else { - image += (static_cast(height) - 1U - - (static_cast(line_no) + v)) * - static_cast(x_stride) + - u; - } - *image = hf.u; - } else { // HALF -> FLOAT - tinyexr::FP32 f32 = half_to_float(hf); - float *image = reinterpret_cast(out_images)[c]; - if (line_order == 0) { - image += (static_cast(line_no) + v) * - static_cast(x_stride) + - u; - } else { - image += (static_cast(height) - 1U - - (static_cast(line_no) + v)) * - static_cast(x_stride) + - u; - } - *image = f32.f; - } - } - } - } else if (channels[c].pixel_type == TINYEXR_PIXELTYPE_UINT) { - assert(requested_pixel_types[c] == TINYEXR_PIXELTYPE_UINT); - - for (size_t v = 0; v < static_cast(num_lines); v++) { - const unsigned int *line_ptr = reinterpret_cast( - &outBuf.at(v * pixel_data_size * static_cast(width) + - channel_offset_list[c] * static_cast(width))); - for (size_t u = 0; u < static_cast(width); u++) { - unsigned int val; - // val = line_ptr[u]; - tinyexr::cpy4(&val, line_ptr + u); - - tinyexr::swap4(&val); - - unsigned int *image = - reinterpret_cast(out_images)[c]; - if (line_order == 0) { - image += (static_cast(line_no) + v) * - static_cast(x_stride) + - u; - } else { - image += (static_cast(height) - 1U - - (static_cast(line_no) + v)) * - static_cast(x_stride) + - u; - } - *image = val; - } - } - } else if (channels[c].pixel_type == TINYEXR_PIXELTYPE_FLOAT) { - assert(requested_pixel_types[c] == TINYEXR_PIXELTYPE_FLOAT); - for (size_t v = 0; v < static_cast(num_lines); v++) { - const float *line_ptr = reinterpret_cast( - &outBuf.at(v * pixel_data_size * static_cast(width) + - channel_offset_list[c] * static_cast(width))); - for (size_t u = 0; u < static_cast(width); u++) { - float val; - // val = line_ptr[u]; - tinyexr::cpy4(&val, line_ptr + u); - - tinyexr::swap4(reinterpret_cast(&val)); - - float *image = reinterpret_cast(out_images)[c]; - if (line_order == 0) { - image += (static_cast(line_no) + v) * - static_cast(x_stride) + - u; - } else { - image += (static_cast(height) - 1U - - (static_cast(line_no) + v)) * - static_cast(x_stride) + - u; - } - *image = val; - } - } - } else { - assert(0); - return false; - } - } - } else if (compression_type == TINYEXR_COMPRESSIONTYPE_ZFP) { -#if TINYEXR_USE_ZFP - tinyexr::ZFPCompressionParam zfp_compression_param; - std::string e; - if (!tinyexr::FindZFPCompressionParam(&zfp_compression_param, attributes, - int(num_attributes), &e)) { - // This code path should not be reachable. - assert(0); - return false; - } - - // Allocate original data size. - std::vector outBuf(static_cast(width) * - static_cast(num_lines) * - pixel_data_size); - - unsigned long dstLen = outBuf.size(); - assert(dstLen > 0); - tinyexr::DecompressZfp(reinterpret_cast(&outBuf.at(0)), width, - num_lines, num_channels, data_ptr, - static_cast(data_len), - zfp_compression_param); - - // For ZFP_COMPRESSION: - // pixel sample data for channel 0 for scanline 0 - // pixel sample data for channel 1 for scanline 0 - // pixel sample data for channel ... for scanline 0 - // pixel sample data for channel n for scanline 0 - // pixel sample data for channel 0 for scanline 1 - // pixel sample data for channel 1 for scanline 1 - // pixel sample data for channel ... for scanline 1 - // pixel sample data for channel n for scanline 1 - // ... - for (size_t c = 0; c < static_cast(num_channels); c++) { - assert(channels[c].pixel_type == TINYEXR_PIXELTYPE_FLOAT); - if (channels[c].pixel_type == TINYEXR_PIXELTYPE_FLOAT) { - assert(requested_pixel_types[c] == TINYEXR_PIXELTYPE_FLOAT); - for (size_t v = 0; v < static_cast(num_lines); v++) { - const float *line_ptr = reinterpret_cast( - &outBuf.at(v * pixel_data_size * static_cast(width) + - channel_offset_list[c] * static_cast(width))); - for (size_t u = 0; u < static_cast(width); u++) { - float val; - tinyexr::cpy4(&val, line_ptr + u); - - tinyexr::swap4(reinterpret_cast(&val)); - - float *image = reinterpret_cast(out_images)[c]; - if (line_order == 0) { - image += (static_cast(line_no) + v) * - static_cast(x_stride) + - u; - } else { - image += (static_cast(height) - 1U - - (static_cast(line_no) + v)) * - static_cast(x_stride) + - u; - } - *image = val; - } - } - } else { - assert(0); - return false; - } - } -#else - (void)attributes; - (void)num_attributes; - (void)num_channels; - assert(0); - return false; -#endif - } else if (compression_type == TINYEXR_COMPRESSIONTYPE_NONE) { - for (size_t c = 0; c < num_channels; c++) { - for (size_t v = 0; v < static_cast(num_lines); v++) { - if (channels[c].pixel_type == TINYEXR_PIXELTYPE_HALF) { - const unsigned short *line_ptr = - reinterpret_cast( - data_ptr + v * pixel_data_size * size_t(width) + - channel_offset_list[c] * static_cast(width)); - - if (requested_pixel_types[c] == TINYEXR_PIXELTYPE_HALF) { - unsigned short *outLine = - reinterpret_cast(out_images[c]); - if (line_order == 0) { - outLine += (size_t(y) + v) * size_t(x_stride); - } else { - outLine += - (size_t(height) - 1 - (size_t(y) + v)) * size_t(x_stride); - } - - for (int u = 0; u < width; u++) { - tinyexr::FP16 hf; - - // hf.u = line_ptr[u]; - tinyexr::cpy2(&(hf.u), line_ptr + u); - - tinyexr::swap2(reinterpret_cast(&hf.u)); - - outLine[u] = hf.u; - } - } else if (requested_pixel_types[c] == TINYEXR_PIXELTYPE_FLOAT) { - float *outLine = reinterpret_cast(out_images[c]); - if (line_order == 0) { - outLine += (size_t(y) + v) * size_t(x_stride); - } else { - outLine += - (size_t(height) - 1 - (size_t(y) + v)) * size_t(x_stride); - } - - if (reinterpret_cast(line_ptr + width) > - (data_ptr + data_len)) { - // Insufficient data size - return false; - } - - for (int u = 0; u < width; u++) { - tinyexr::FP16 hf; - - // address may not be aliged. use byte-wise copy for safety.#76 - // hf.u = line_ptr[u]; - tinyexr::cpy2(&(hf.u), line_ptr + u); - - tinyexr::swap2(reinterpret_cast(&hf.u)); - - tinyexr::FP32 f32 = half_to_float(hf); - - outLine[u] = f32.f; - } - } else { - assert(0); - return false; - } - } else if (channels[c].pixel_type == TINYEXR_PIXELTYPE_FLOAT) { - const float *line_ptr = reinterpret_cast( - data_ptr + v * pixel_data_size * size_t(width) + - channel_offset_list[c] * static_cast(width)); - - float *outLine = reinterpret_cast(out_images[c]); - if (line_order == 0) { - outLine += (size_t(y) + v) * size_t(x_stride); - } else { - outLine += - (size_t(height) - 1 - (size_t(y) + v)) * size_t(x_stride); - } - - if (reinterpret_cast(line_ptr + width) > - (data_ptr + data_len)) { - // Insufficient data size - return false; - } - - for (int u = 0; u < width; u++) { - float val; - tinyexr::cpy4(&val, line_ptr + u); - - tinyexr::swap4(reinterpret_cast(&val)); - - outLine[u] = val; - } - } else if (channels[c].pixel_type == TINYEXR_PIXELTYPE_UINT) { - const unsigned int *line_ptr = reinterpret_cast( - data_ptr + v * pixel_data_size * size_t(width) + - channel_offset_list[c] * static_cast(width)); - - unsigned int *outLine = - reinterpret_cast(out_images[c]); - if (line_order == 0) { - outLine += (size_t(y) + v) * size_t(x_stride); - } else { - outLine += - (size_t(height) - 1 - (size_t(y) + v)) * size_t(x_stride); - } - - for (int u = 0; u < width; u++) { - if (reinterpret_cast(line_ptr + u) >= - (data_ptr + data_len)) { - // Corrupsed data? - return false; - } - - unsigned int val; - tinyexr::cpy4(&val, line_ptr + u); - - tinyexr::swap4(reinterpret_cast(&val)); - - outLine[u] = val; - } - } - } - } - } - - return true; -} - -static bool DecodeTiledPixelData( - unsigned char **out_images, int *width, int *height, - const int *requested_pixel_types, const unsigned char *data_ptr, - size_t data_len, int compression_type, int line_order, int data_width, - int data_height, int tile_offset_x, int tile_offset_y, int tile_size_x, - int tile_size_y, size_t pixel_data_size, size_t num_attributes, - const EXRAttribute *attributes, size_t num_channels, - const EXRChannelInfo *channels, - const std::vector &channel_offset_list) { - // Here, data_width and data_height are the dimensions of the current (sub)level. - if (tile_size_x * tile_offset_x > data_width || - tile_size_y * tile_offset_y > data_height) { - return false; - } - - // Compute actual image size in a tile. - if ((tile_offset_x + 1) * tile_size_x >= data_width) { - (*width) = data_width - (tile_offset_x * tile_size_x); - } else { - (*width) = tile_size_x; - } - - if ((tile_offset_y + 1) * tile_size_y >= data_height) { - (*height) = data_height - (tile_offset_y * tile_size_y); - } else { - (*height) = tile_size_y; - } - - // Image size = tile size. - return DecodePixelData(out_images, requested_pixel_types, data_ptr, data_len, - compression_type, line_order, (*width), tile_size_y, - /* stride */ tile_size_x, /* y */ 0, /* line_no */ 0, - (*height), pixel_data_size, num_attributes, attributes, - num_channels, channels, channel_offset_list); -} - -static bool ComputeChannelLayout(std::vector *channel_offset_list, - int *pixel_data_size, size_t *channel_offset, - int num_channels, - const EXRChannelInfo *channels) { - channel_offset_list->resize(static_cast(num_channels)); - - (*pixel_data_size) = 0; - (*channel_offset) = 0; - - for (size_t c = 0; c < static_cast(num_channels); c++) { - (*channel_offset_list)[c] = (*channel_offset); - if (channels[c].pixel_type == TINYEXR_PIXELTYPE_HALF) { - (*pixel_data_size) += sizeof(unsigned short); - (*channel_offset) += sizeof(unsigned short); - } else if (channels[c].pixel_type == TINYEXR_PIXELTYPE_FLOAT) { - (*pixel_data_size) += sizeof(float); - (*channel_offset) += sizeof(float); - } else if (channels[c].pixel_type == TINYEXR_PIXELTYPE_UINT) { - (*pixel_data_size) += sizeof(unsigned int); - (*channel_offset) += sizeof(unsigned int); - } else { - // ??? - return false; - } - } - return true; -} - -static unsigned char **AllocateImage(int num_channels, - const EXRChannelInfo *channels, - const int *requested_pixel_types, - int data_width, int data_height) { - unsigned char **images = - reinterpret_cast(static_cast( - malloc(sizeof(float *) * static_cast(num_channels)))); - - for (size_t c = 0; c < static_cast(num_channels); c++) { - size_t data_len = - static_cast(data_width) * static_cast(data_height); - if (channels[c].pixel_type == TINYEXR_PIXELTYPE_HALF) { - // pixel_data_size += sizeof(unsigned short); - // channel_offset += sizeof(unsigned short); - // Alloc internal image for half type. - if (requested_pixel_types[c] == TINYEXR_PIXELTYPE_HALF) { - images[c] = - reinterpret_cast(static_cast( - malloc(sizeof(unsigned short) * data_len))); - } else if (requested_pixel_types[c] == TINYEXR_PIXELTYPE_FLOAT) { - images[c] = reinterpret_cast( - static_cast(malloc(sizeof(float) * data_len))); - } else { - assert(0); - } - } else if (channels[c].pixel_type == TINYEXR_PIXELTYPE_FLOAT) { - // pixel_data_size += sizeof(float); - // channel_offset += sizeof(float); - images[c] = reinterpret_cast( - static_cast(malloc(sizeof(float) * data_len))); - } else if (channels[c].pixel_type == TINYEXR_PIXELTYPE_UINT) { - // pixel_data_size += sizeof(unsigned int); - // channel_offset += sizeof(unsigned int); - images[c] = reinterpret_cast( - static_cast(malloc(sizeof(unsigned int) * data_len))); - } else { - assert(0); - } - } - - return images; -} - -#ifdef _WIN32 -static inline std::wstring UTF8ToWchar(const std::string &str) { - int wstr_size = - MultiByteToWideChar(CP_UTF8, 0, str.data(), (int)str.size(), NULL, 0); - std::wstring wstr(wstr_size, 0); - MultiByteToWideChar(CP_UTF8, 0, str.data(), (int)str.size(), &wstr[0], - (int)wstr.size()); - return wstr; -} -#endif - - -static int ParseEXRHeader(HeaderInfo *info, bool *empty_header, - const EXRVersion *version, std::string *err, - const unsigned char *buf, size_t size) { - const char *marker = reinterpret_cast(&buf[0]); - - if (empty_header) { - (*empty_header) = false; - } - - if (version->multipart) { - if (size > 0 && marker[0] == '\0') { - // End of header list. - if (empty_header) { - (*empty_header) = true; - } - return TINYEXR_SUCCESS; - } - } - - // According to the spec, the header of every OpenEXR file must contain at - // least the following attributes: - // - // channels chlist - // compression compression - // dataWindow box2i - // displayWindow box2i - // lineOrder lineOrder - // pixelAspectRatio float - // screenWindowCenter v2f - // screenWindowWidth float - bool has_channels = false; - bool has_compression = false; - bool has_data_window = false; - bool has_display_window = false; - bool has_line_order = false; - bool has_pixel_aspect_ratio = false; - bool has_screen_window_center = false; - bool has_screen_window_width = false; - bool has_name = false; - bool has_type = false; - - info->name.clear(); - info->type.clear(); - - info->data_window.min_x = 0; - info->data_window.min_y = 0; - info->data_window.max_x = 0; - info->data_window.max_y = 0; - info->line_order = 0; // @fixme - info->display_window.min_x = 0; - info->display_window.min_y = 0; - info->display_window.max_x = 0; - info->display_window.max_y = 0; - info->screen_window_center[0] = 0.0f; - info->screen_window_center[1] = 0.0f; - info->screen_window_width = -1.0f; - info->pixel_aspect_ratio = -1.0f; - - info->tiled = 0; - info->tile_size_x = -1; - info->tile_size_y = -1; - info->tile_level_mode = -1; - info->tile_rounding_mode = -1; - - info->attributes.clear(); - - // Read attributes - size_t orig_size = size; - for (size_t nattr = 0; nattr < TINYEXR_MAX_HEADER_ATTRIBUTES; nattr++) { - if (0 == size) { - if (err) { - (*err) += "Insufficient data size for attributes.\n"; - } - return TINYEXR_ERROR_INVALID_DATA; - } else if (marker[0] == '\0') { - size--; - break; - } - - std::string attr_name; - std::string attr_type; - std::vector data; - size_t marker_size; - if (!tinyexr::ReadAttribute(&attr_name, &attr_type, &data, &marker_size, - marker, size)) { - if (err) { - (*err) += "Failed to read attribute.\n"; - } - return TINYEXR_ERROR_INVALID_DATA; - } - marker += marker_size; - size -= marker_size; - - // For a multipart file, the version field 9th bit is 0. - if ((version->tiled || version->multipart || version->non_image) && attr_name.compare("tiles") == 0) { - unsigned int x_size, y_size; - unsigned char tile_mode; - assert(data.size() == 9); - memcpy(&x_size, &data.at(0), sizeof(int)); - memcpy(&y_size, &data.at(4), sizeof(int)); - tile_mode = data[8]; - tinyexr::swap4(&x_size); - tinyexr::swap4(&y_size); - - if (x_size > static_cast(std::numeric_limits::max()) || - y_size > static_cast(std::numeric_limits::max())) { - if (err) { - (*err) = "Tile sizes were invalid."; - } - return TINYEXR_ERROR_UNSUPPORTED_FORMAT; - } - - info->tile_size_x = static_cast(x_size); - info->tile_size_y = static_cast(y_size); - - // mode = levelMode + roundingMode * 16 - info->tile_level_mode = tile_mode & 0x3; - info->tile_rounding_mode = (tile_mode >> 4) & 0x1; - info->tiled = 1; - } else if (attr_name.compare("compression") == 0) { - bool ok = false; - if (data[0] < TINYEXR_COMPRESSIONTYPE_PIZ) { - ok = true; - } - - if (data[0] == TINYEXR_COMPRESSIONTYPE_PIZ) { -#if TINYEXR_USE_PIZ - ok = true; -#else - if (err) { - (*err) = "PIZ compression is not supported."; - } - return TINYEXR_ERROR_UNSUPPORTED_FORMAT; -#endif - } - - if (data[0] == TINYEXR_COMPRESSIONTYPE_ZFP) { -#if TINYEXR_USE_ZFP - ok = true; -#else - if (err) { - (*err) = "ZFP compression is not supported."; - } - return TINYEXR_ERROR_UNSUPPORTED_FORMAT; -#endif - } - - if (!ok) { - if (err) { - (*err) = "Unknown compression type."; - } - return TINYEXR_ERROR_UNSUPPORTED_FORMAT; - } - - info->compression_type = static_cast(data[0]); - has_compression = true; - - } else if (attr_name.compare("channels") == 0) { - // name: zero-terminated string, from 1 to 255 bytes long - // pixel type: int, possible values are: UINT = 0 HALF = 1 FLOAT = 2 - // pLinear: unsigned char, possible values are 0 and 1 - // reserved: three chars, should be zero - // xSampling: int - // ySampling: int - - if (!ReadChannelInfo(info->channels, data)) { - if (err) { - (*err) += "Failed to parse channel info.\n"; - } - return TINYEXR_ERROR_INVALID_DATA; - } - - if (info->channels.size() < 1) { - if (err) { - (*err) += "# of channels is zero.\n"; - } - return TINYEXR_ERROR_INVALID_DATA; - } - - has_channels = true; - - } else if (attr_name.compare("dataWindow") == 0) { - if (data.size() >= 16) { - memcpy(&info->data_window.min_x, &data.at(0), sizeof(int)); - memcpy(&info->data_window.min_y, &data.at(4), sizeof(int)); - memcpy(&info->data_window.max_x, &data.at(8), sizeof(int)); - memcpy(&info->data_window.max_y, &data.at(12), sizeof(int)); - tinyexr::swap4(&info->data_window.min_x); - tinyexr::swap4(&info->data_window.min_y); - tinyexr::swap4(&info->data_window.max_x); - tinyexr::swap4(&info->data_window.max_y); - has_data_window = true; - } - } else if (attr_name.compare("displayWindow") == 0) { - if (data.size() >= 16) { - memcpy(&info->display_window.min_x, &data.at(0), sizeof(int)); - memcpy(&info->display_window.min_y, &data.at(4), sizeof(int)); - memcpy(&info->display_window.max_x, &data.at(8), sizeof(int)); - memcpy(&info->display_window.max_y, &data.at(12), sizeof(int)); - tinyexr::swap4(&info->display_window.min_x); - tinyexr::swap4(&info->display_window.min_y); - tinyexr::swap4(&info->display_window.max_x); - tinyexr::swap4(&info->display_window.max_y); - - has_display_window = true; - } - } else if (attr_name.compare("lineOrder") == 0) { - if (data.size() >= 1) { - info->line_order = static_cast(data[0]); - has_line_order = true; - } - } else if (attr_name.compare("pixelAspectRatio") == 0) { - if (data.size() >= sizeof(float)) { - memcpy(&info->pixel_aspect_ratio, &data.at(0), sizeof(float)); - tinyexr::swap4(&info->pixel_aspect_ratio); - has_pixel_aspect_ratio = true; - } - } else if (attr_name.compare("screenWindowCenter") == 0) { - if (data.size() >= 8) { - memcpy(&info->screen_window_center[0], &data.at(0), sizeof(float)); - memcpy(&info->screen_window_center[1], &data.at(4), sizeof(float)); - tinyexr::swap4(&info->screen_window_center[0]); - tinyexr::swap4(&info->screen_window_center[1]); - has_screen_window_center = true; - } - } else if (attr_name.compare("screenWindowWidth") == 0) { - if (data.size() >= sizeof(float)) { - memcpy(&info->screen_window_width, &data.at(0), sizeof(float)); - tinyexr::swap4(&info->screen_window_width); - - has_screen_window_width = true; - } - } else if (attr_name.compare("chunkCount") == 0) { - if (data.size() >= sizeof(int)) { - memcpy(&info->chunk_count, &data.at(0), sizeof(int)); - tinyexr::swap4(&info->chunk_count); - } - } else if (attr_name.compare("name") == 0) { - if (!data.empty() && data[0]) { - data.push_back(0); - size_t len = strlen(reinterpret_cast(&data[0])); - info->name.resize(len); - info->name.assign(reinterpret_cast(&data[0]), len); - has_name = true; - } - } else if (attr_name.compare("type") == 0) { - if (!data.empty() && data[0]) { - data.push_back(0); - size_t len = strlen(reinterpret_cast(&data[0])); - info->type.resize(len); - info->type.assign(reinterpret_cast(&data[0]), len); - has_type = true; - } - } else { - // Custom attribute(up to TINYEXR_MAX_CUSTOM_ATTRIBUTES) - if (info->attributes.size() < TINYEXR_MAX_CUSTOM_ATTRIBUTES) { - EXRAttribute attrib; -#ifdef _MSC_VER - strncpy_s(attrib.name, attr_name.c_str(), 255); - strncpy_s(attrib.type, attr_type.c_str(), 255); -#else - strncpy(attrib.name, attr_name.c_str(), 255); - strncpy(attrib.type, attr_type.c_str(), 255); -#endif - attrib.name[255] = '\0'; - attrib.type[255] = '\0'; - attrib.size = static_cast(data.size()); - attrib.value = static_cast(malloc(data.size())); - memcpy(reinterpret_cast(attrib.value), &data.at(0), - data.size()); - info->attributes.push_back(attrib); - } - } - } - - // Check if required attributes exist - { - std::stringstream ss_err; - - if (!has_compression) { - ss_err << "\"compression\" attribute not found in the header." - << std::endl; - } - - if (!has_channels) { - ss_err << "\"channels\" attribute not found in the header." << std::endl; - } - - if (!has_line_order) { - ss_err << "\"lineOrder\" attribute not found in the header." << std::endl; - } - - if (!has_display_window) { - ss_err << "\"displayWindow\" attribute not found in the header." - << std::endl; - } - - if (!has_data_window) { - ss_err << "\"dataWindow\" attribute not found in the header or invalid." - << std::endl; - } - - if (!has_pixel_aspect_ratio) { - ss_err << "\"pixelAspectRatio\" attribute not found in the header." - << std::endl; - } - - if (!has_screen_window_width) { - ss_err << "\"screenWindowWidth\" attribute not found in the header." - << std::endl; - } - - if (!has_screen_window_center) { - ss_err << "\"screenWindowCenter\" attribute not found in the header." - << std::endl; - } - - if (version->multipart || version->non_image) { - if (!has_name) { - ss_err << "\"name\" attribute not found in the header." - << std::endl; - } - if (!has_type) { - ss_err << "\"type\" attribute not found in the header." - << std::endl; - } - } - - if (!(ss_err.str().empty())) { - if (err) { - (*err) += ss_err.str(); - } - return TINYEXR_ERROR_INVALID_HEADER; - } - } - - info->header_len = static_cast(orig_size - size); - - return TINYEXR_SUCCESS; -} - -// C++ HeaderInfo to C EXRHeader conversion. -static void ConvertHeader(EXRHeader *exr_header, const HeaderInfo &info) { - exr_header->pixel_aspect_ratio = info.pixel_aspect_ratio; - exr_header->screen_window_center[0] = info.screen_window_center[0]; - exr_header->screen_window_center[1] = info.screen_window_center[1]; - exr_header->screen_window_width = info.screen_window_width; - exr_header->chunk_count = info.chunk_count; - exr_header->display_window.min_x = info.display_window.min_x; - exr_header->display_window.min_y = info.display_window.min_y; - exr_header->display_window.max_x = info.display_window.max_x; - exr_header->display_window.max_y = info.display_window.max_y; - exr_header->data_window.min_x = info.data_window.min_x; - exr_header->data_window.min_y = info.data_window.min_y; - exr_header->data_window.max_x = info.data_window.max_x; - exr_header->data_window.max_y = info.data_window.max_y; - exr_header->line_order = info.line_order; - exr_header->compression_type = info.compression_type; - exr_header->tiled = info.tiled; - exr_header->tile_size_x = info.tile_size_x; - exr_header->tile_size_y = info.tile_size_y; - exr_header->tile_level_mode = info.tile_level_mode; - exr_header->tile_rounding_mode = info.tile_rounding_mode; - - EXRSetNameAttr(exr_header, info.name.c_str()); - - if (!info.type.empty()) { - if (info.type == "scanlineimage") { - assert(!exr_header->tiled); - } else if (info.type == "tiledimage") { - assert(exr_header->tiled); - } else if (info.type == "deeptile") { - exr_header->non_image = 1; - assert(exr_header->tiled); - } else if (info.type == "deepscanline") { - exr_header->non_image = 1; - assert(!exr_header->tiled); - } else { - assert(false); - } - } - - exr_header->num_channels = static_cast(info.channels.size()); - - exr_header->channels = static_cast(malloc( - sizeof(EXRChannelInfo) * static_cast(exr_header->num_channels))); - for (size_t c = 0; c < static_cast(exr_header->num_channels); c++) { -#ifdef _MSC_VER - strncpy_s(exr_header->channels[c].name, info.channels[c].name.c_str(), 255); -#else - strncpy(exr_header->channels[c].name, info.channels[c].name.c_str(), 255); -#endif - // manually add '\0' for safety. - exr_header->channels[c].name[255] = '\0'; - - exr_header->channels[c].pixel_type = info.channels[c].pixel_type; - exr_header->channels[c].p_linear = info.channels[c].p_linear; - exr_header->channels[c].x_sampling = info.channels[c].x_sampling; - exr_header->channels[c].y_sampling = info.channels[c].y_sampling; - } - - exr_header->pixel_types = static_cast( - malloc(sizeof(int) * static_cast(exr_header->num_channels))); - for (size_t c = 0; c < static_cast(exr_header->num_channels); c++) { - exr_header->pixel_types[c] = info.channels[c].pixel_type; - } - - // Initially fill with values of `pixel_types` - exr_header->requested_pixel_types = static_cast( - malloc(sizeof(int) * static_cast(exr_header->num_channels))); - for (size_t c = 0; c < static_cast(exr_header->num_channels); c++) { - exr_header->requested_pixel_types[c] = info.channels[c].pixel_type; - } - - exr_header->num_custom_attributes = static_cast(info.attributes.size()); - - if (exr_header->num_custom_attributes > 0) { - // TODO(syoyo): Report warning when # of attributes exceeds - // `TINYEXR_MAX_CUSTOM_ATTRIBUTES` - if (exr_header->num_custom_attributes > TINYEXR_MAX_CUSTOM_ATTRIBUTES) { - exr_header->num_custom_attributes = TINYEXR_MAX_CUSTOM_ATTRIBUTES; - } - - exr_header->custom_attributes = static_cast(malloc( - sizeof(EXRAttribute) * size_t(exr_header->num_custom_attributes))); - - for (size_t i = 0; i < info.attributes.size(); i++) { - memcpy(exr_header->custom_attributes[i].name, info.attributes[i].name, - 256); - memcpy(exr_header->custom_attributes[i].type, info.attributes[i].type, - 256); - exr_header->custom_attributes[i].size = info.attributes[i].size; - // Just copy pointer - exr_header->custom_attributes[i].value = info.attributes[i].value; - } - - } else { - exr_header->custom_attributes = NULL; - } - - exr_header->header_len = info.header_len; -} - -struct OffsetData { - OffsetData() : num_x_levels(0), num_y_levels(0) {} - std::vector > > offsets; - int num_x_levels; - int num_y_levels; -}; - -int LevelIndex(int lx, int ly, int tile_level_mode, int num_x_levels) { - switch (tile_level_mode) { - case TINYEXR_TILE_ONE_LEVEL: - return 0; - - case TINYEXR_TILE_MIPMAP_LEVELS: - return lx; - - case TINYEXR_TILE_RIPMAP_LEVELS: - return lx + ly * num_x_levels; - - default: - assert(false); - } - return 0; -} - -static int LevelSize(int toplevel_size, int level, int tile_rounding_mode) { - assert(level >= 0); - - int b = (int)(1u << (unsigned)level); - int level_size = toplevel_size / b; - - if (tile_rounding_mode == TINYEXR_TILE_ROUND_UP && level_size * b < toplevel_size) - level_size += 1; - - return std::max(level_size, 1); -} - -static int DecodeTiledLevel(EXRImage* exr_image, const EXRHeader* exr_header, - const OffsetData& offset_data, - const std::vector& channel_offset_list, - int pixel_data_size, - const unsigned char* head, const size_t size, - std::string* err) { - int num_channels = exr_header->num_channels; - - int level_index = LevelIndex(exr_image->level_x, exr_image->level_y, exr_header->tile_level_mode, offset_data.num_x_levels); - int num_y_tiles = (int)offset_data.offsets[level_index].size(); - assert(num_y_tiles); - int num_x_tiles = (int)offset_data.offsets[level_index][0].size(); - assert(num_x_tiles); - int num_tiles = num_x_tiles * num_y_tiles; - - int err_code = TINYEXR_SUCCESS; - - enum { - EF_SUCCESS = 0, - EF_INVALID_DATA = 1, - EF_INSUFFICIENT_DATA = 2, - EF_FAILED_TO_DECODE = 4 - }; -#if TINYEXR_HAS_CXX11 && (TINYEXR_USE_THREAD > 0) - std::atomic error_flag(EF_SUCCESS); -#else - unsigned error_flag(EF_SUCCESS); -#endif - - // Although the spec says : "...the data window is subdivided into an array of smaller rectangles...", - // the IlmImf library allows the dimensions of the tile to be larger (or equal) than the dimensions of the data window. -#if 0 - if ((exr_header->tile_size_x > exr_image->width || exr_header->tile_size_y > exr_image->height) && - exr_image->level_x == 0 && exr_image->level_y == 0) { - if (err) { - (*err) += "Failed to decode tile data.\n"; - } - err_code = TINYEXR_ERROR_INVALID_DATA; - } -#endif - exr_image->tiles = static_cast( - calloc(sizeof(EXRTile), static_cast(num_tiles))); - -#if TINYEXR_HAS_CXX11 && (TINYEXR_USE_THREAD > 0) - std::vector workers; - std::atomic tile_count(0); - - int num_threads = std::max(1, int(std::thread::hardware_concurrency())); - if (num_threads > int(num_tiles)) { - num_threads = int(num_tiles); - } - - for (int t = 0; t < num_threads; t++) { - workers.emplace_back(std::thread([&]() - { - int tile_idx = 0; - while ((tile_idx = tile_count++) < num_tiles) { - -#else -#if TINYEXR_USE_OPENMP -#pragma omp parallel for -#endif - for (int tile_idx = 0; tile_idx < num_tiles; tile_idx++) { -#endif - // Allocate memory for each tile. - exr_image->tiles[tile_idx].images = tinyexr::AllocateImage( - num_channels, exr_header->channels, - exr_header->requested_pixel_types, exr_header->tile_size_x, - exr_header->tile_size_y); - - int x_tile = tile_idx % num_x_tiles; - int y_tile = tile_idx / num_x_tiles; - // 16 byte: tile coordinates - // 4 byte : data size - // ~ : data(uncompressed or compressed) - tinyexr::tinyexr_uint64 offset = offset_data.offsets[level_index][y_tile][x_tile]; - if (offset + sizeof(int) * 5 > size) { - // Insufficient data size. - error_flag |= EF_INSUFFICIENT_DATA; - continue; - } - - size_t data_size = - size_t(size - (offset + sizeof(int) * 5)); - const unsigned char* data_ptr = - reinterpret_cast(head + offset); - - int tile_coordinates[4]; - memcpy(tile_coordinates, data_ptr, sizeof(int) * 4); - tinyexr::swap4(&tile_coordinates[0]); - tinyexr::swap4(&tile_coordinates[1]); - tinyexr::swap4(&tile_coordinates[2]); - tinyexr::swap4(&tile_coordinates[3]); - - if (tile_coordinates[2] != exr_image->level_x) { - // Invalid data. - error_flag |= EF_INVALID_DATA; - continue; - } - if (tile_coordinates[3] != exr_image->level_y) { - // Invalid data. - error_flag |= EF_INVALID_DATA; - continue; - } - - int data_len; - memcpy(&data_len, data_ptr + 16, - sizeof(int)); // 16 = sizeof(tile_coordinates) - tinyexr::swap4(&data_len); - - if (data_len < 2 || size_t(data_len) > data_size) { - // Insufficient data size. - error_flag |= EF_INSUFFICIENT_DATA; - continue; - } - - // Move to data addr: 20 = 16 + 4; - data_ptr += 20; - bool ret = tinyexr::DecodeTiledPixelData( - exr_image->tiles[tile_idx].images, - &(exr_image->tiles[tile_idx].width), - &(exr_image->tiles[tile_idx].height), - exr_header->requested_pixel_types, data_ptr, - static_cast(data_len), exr_header->compression_type, - exr_header->line_order, - exr_image->width, exr_image->height, - tile_coordinates[0], tile_coordinates[1], exr_header->tile_size_x, - exr_header->tile_size_y, static_cast(pixel_data_size), - static_cast(exr_header->num_custom_attributes), - exr_header->custom_attributes, - static_cast(exr_header->num_channels), - exr_header->channels, channel_offset_list); - - if (!ret) { - // Failed to decode tile data. - error_flag |= EF_FAILED_TO_DECODE; - } - - exr_image->tiles[tile_idx].offset_x = tile_coordinates[0]; - exr_image->tiles[tile_idx].offset_y = tile_coordinates[1]; - exr_image->tiles[tile_idx].level_x = tile_coordinates[2]; - exr_image->tiles[tile_idx].level_y = tile_coordinates[3]; - -#if TINYEXR_HAS_CXX11 && (TINYEXR_USE_THREAD > 0) - } - })); - } // num_thread loop - - for (auto& t : workers) { - t.join(); - } - -#else - } // parallel for -#endif - - // Even in the event of an error, the reserved memory may be freed. - exr_image->num_channels = num_channels; - exr_image->num_tiles = static_cast(num_tiles); - - if (error_flag) err_code = TINYEXR_ERROR_INVALID_DATA; - if (err) { - if (error_flag & EF_INSUFFICIENT_DATA) { - (*err) += "Insufficient data length.\n"; - } - if (error_flag & EF_FAILED_TO_DECODE) { - (*err) += "Failed to decode tile data.\n"; - } - } - return err_code; -} - -static int DecodeChunk(EXRImage *exr_image, const EXRHeader *exr_header, - const OffsetData& offset_data, - const unsigned char *head, const size_t size, - std::string *err) { - int num_channels = exr_header->num_channels; - - int num_scanline_blocks = 1; - if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_ZIP) { - num_scanline_blocks = 16; - } else if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_PIZ) { - num_scanline_blocks = 32; - } else if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_ZFP) { - num_scanline_blocks = 16; - -#if TINYEXR_USE_ZFP - tinyexr::ZFPCompressionParam zfp_compression_param; - if (!FindZFPCompressionParam(&zfp_compression_param, - exr_header->custom_attributes, - int(exr_header->num_custom_attributes), err)) { - return TINYEXR_ERROR_INVALID_HEADER; - } -#endif - } - - if (exr_header->data_window.max_x < exr_header->data_window.min_x || - exr_header->data_window.max_y < exr_header->data_window.min_y) { - if (err) { - (*err) += "Invalid data window.\n"; - } - return TINYEXR_ERROR_INVALID_DATA; - } - - int data_width = - exr_header->data_window.max_x - exr_header->data_window.min_x + 1; - int data_height = - exr_header->data_window.max_y - exr_header->data_window.min_y + 1; - - // Do not allow too large data_width and data_height. header invalid? - { - if ((data_width > TINYEXR_DIMENSION_THRESHOLD) || (data_height > TINYEXR_DIMENSION_THRESHOLD)) { - if (err) { - std::stringstream ss; - ss << "data_with or data_height too large. data_width: " << data_width - << ", " - << "data_height = " << data_height << std::endl; - (*err) += ss.str(); - } - return TINYEXR_ERROR_INVALID_DATA; - } - if (exr_header->tiled) { - if ((exr_header->tile_size_x > TINYEXR_DIMENSION_THRESHOLD) || (exr_header->tile_size_y > TINYEXR_DIMENSION_THRESHOLD)) { - if (err) { - std::stringstream ss; - ss << "tile with or tile height too large. tile width: " << exr_header->tile_size_x - << ", " - << "tile height = " << exr_header->tile_size_y << std::endl; - (*err) += ss.str(); - } - return TINYEXR_ERROR_INVALID_DATA; - } - } - } - - const std::vector& offsets = offset_data.offsets[0][0]; - size_t num_blocks = offsets.size(); - - std::vector channel_offset_list; - int pixel_data_size = 0; - size_t channel_offset = 0; - if (!tinyexr::ComputeChannelLayout(&channel_offset_list, &pixel_data_size, - &channel_offset, num_channels, - exr_header->channels)) { - if (err) { - (*err) += "Failed to compute channel layout.\n"; - } - return TINYEXR_ERROR_INVALID_DATA; - } - -#if TINYEXR_HAS_CXX11 && (TINYEXR_USE_THREAD > 0) - std::atomic invalid_data(false); -#else - bool invalid_data(false); -#endif - - if (exr_header->tiled) { - // value check - if (exr_header->tile_size_x < 0) { - if (err) { - std::stringstream ss; - ss << "Invalid tile size x : " << exr_header->tile_size_x << "\n"; - (*err) += ss.str(); - } - return TINYEXR_ERROR_INVALID_HEADER; - } - - if (exr_header->tile_size_y < 0) { - if (err) { - std::stringstream ss; - ss << "Invalid tile size y : " << exr_header->tile_size_y << "\n"; - (*err) += ss.str(); - } - return TINYEXR_ERROR_INVALID_HEADER; - } - if (exr_header->tile_level_mode != TINYEXR_TILE_RIPMAP_LEVELS) { - EXRImage* level_image = NULL; - for (int level = 0; level < offset_data.num_x_levels; ++level) { - if (!level_image) { - level_image = exr_image; - } else { - level_image->next_level = new EXRImage; - InitEXRImage(level_image->next_level); - level_image = level_image->next_level; - } - level_image->width = - LevelSize(exr_header->data_window.max_x - exr_header->data_window.min_x + 1, level, exr_header->tile_rounding_mode); - level_image->height = - LevelSize(exr_header->data_window.max_y - exr_header->data_window.min_y + 1, level, exr_header->tile_rounding_mode); - level_image->level_x = level; - level_image->level_y = level; - - int ret = DecodeTiledLevel(level_image, exr_header, - offset_data, - channel_offset_list, - pixel_data_size, - head, size, - err); - if (ret != TINYEXR_SUCCESS) return ret; - } - } else { - EXRImage* level_image = NULL; - for (int level_y = 0; level_y < offset_data.num_y_levels; ++level_y) - for (int level_x = 0; level_x < offset_data.num_x_levels; ++level_x) { - if (!level_image) { - level_image = exr_image; - } else { - level_image->next_level = new EXRImage; - InitEXRImage(level_image->next_level); - level_image = level_image->next_level; - } - - level_image->width = - LevelSize(exr_header->data_window.max_x - exr_header->data_window.min_x + 1, level_x, exr_header->tile_rounding_mode); - level_image->height = - LevelSize(exr_header->data_window.max_y - exr_header->data_window.min_y + 1, level_y, exr_header->tile_rounding_mode); - level_image->level_x = level_x; - level_image->level_y = level_y; - - int ret = DecodeTiledLevel(level_image, exr_header, - offset_data, - channel_offset_list, - pixel_data_size, - head, size, - err); - if (ret != TINYEXR_SUCCESS) return ret; - } - } - } else { // scanline format - // Don't allow too large image(256GB * pixel_data_size or more). Workaround - // for #104. - size_t total_data_len = - size_t(data_width) * size_t(data_height) * size_t(num_channels); - const bool total_data_len_overflown = - sizeof(void *) == 8 ? (total_data_len >= 0x4000000000) : false; - if ((total_data_len == 0) || total_data_len_overflown) { - if (err) { - std::stringstream ss; - ss << "Image data size is zero or too large: width = " << data_width - << ", height = " << data_height << ", channels = " << num_channels - << std::endl; - (*err) += ss.str(); - } - return TINYEXR_ERROR_INVALID_DATA; - } - - exr_image->images = tinyexr::AllocateImage( - num_channels, exr_header->channels, exr_header->requested_pixel_types, - data_width, data_height); - -#if TINYEXR_HAS_CXX11 && (TINYEXR_USE_THREAD > 0) - std::vector workers; - std::atomic y_count(0); - - int num_threads = std::max(1, int(std::thread::hardware_concurrency())); - if (num_threads > int(num_blocks)) { - num_threads = int(num_blocks); - } - - for (int t = 0; t < num_threads; t++) { - workers.emplace_back(std::thread([&]() { - int y = 0; - while ((y = y_count++) < int(num_blocks)) { - -#else - -#if TINYEXR_USE_OPENMP -#pragma omp parallel for -#endif - for (int y = 0; y < static_cast(num_blocks); y++) { - -#endif - size_t y_idx = static_cast(y); - - if (offsets[y_idx] + sizeof(int) * 2 > size) { - invalid_data = true; - } else { - // 4 byte: scan line - // 4 byte: data size - // ~ : pixel data(uncompressed or compressed) - size_t data_size = - size_t(size - (offsets[y_idx] + sizeof(int) * 2)); - const unsigned char *data_ptr = - reinterpret_cast(head + offsets[y_idx]); - - int line_no; - memcpy(&line_no, data_ptr, sizeof(int)); - int data_len; - memcpy(&data_len, data_ptr + 4, sizeof(int)); - tinyexr::swap4(&line_no); - tinyexr::swap4(&data_len); - - if (size_t(data_len) > data_size) { - invalid_data = true; - - } else if ((line_no > (2 << 20)) || (line_no < -(2 << 20))) { - // Too large value. Assume this is invalid - // 2**20 = 1048576 = heuristic value. - invalid_data = true; - } else if (data_len == 0) { - // TODO(syoyo): May be ok to raise the threshold for example - // `data_len < 4` - invalid_data = true; - } else { - // line_no may be negative. - int end_line_no = (std::min)(line_no + num_scanline_blocks, - (exr_header->data_window.max_y + 1)); - - int num_lines = end_line_no - line_no; - - if (num_lines <= 0) { - invalid_data = true; - } else { - // Move to data addr: 8 = 4 + 4; - data_ptr += 8; - - // Adjust line_no with data_window.bmin.y - - // overflow check - tinyexr_int64 lno = - static_cast(line_no) - - static_cast(exr_header->data_window.min_y); - if (lno > std::numeric_limits::max()) { - line_no = -1; // invalid - } else if (lno < -std::numeric_limits::max()) { - line_no = -1; // invalid - } else { - line_no -= exr_header->data_window.min_y; - } - - if (line_no < 0) { - invalid_data = true; - } else { - if (!tinyexr::DecodePixelData( - exr_image->images, exr_header->requested_pixel_types, - data_ptr, static_cast(data_len), - exr_header->compression_type, exr_header->line_order, - data_width, data_height, data_width, y, line_no, - num_lines, static_cast(pixel_data_size), - static_cast( - exr_header->num_custom_attributes), - exr_header->custom_attributes, - static_cast(exr_header->num_channels), - exr_header->channels, channel_offset_list)) { - invalid_data = true; - } - } - } - } - } - -#if TINYEXR_HAS_CXX11 && (TINYEXR_USE_THREAD > 0) - } - })); - } - - for (auto &t : workers) { - t.join(); - } -#else - } // omp parallel -#endif - } - - if (invalid_data) { - if (err) { - std::stringstream ss; - (*err) += "Invalid data found when decoding pixels.\n"; - } - return TINYEXR_ERROR_INVALID_DATA; - } - - // Overwrite `pixel_type` with `requested_pixel_type`. - { - for (int c = 0; c < exr_header->num_channels; c++) { - exr_header->pixel_types[c] = exr_header->requested_pixel_types[c]; - } - } - - { - exr_image->num_channels = num_channels; - - exr_image->width = data_width; - exr_image->height = data_height; - } - - return TINYEXR_SUCCESS; -} - -static bool ReconstructLineOffsets( - std::vector *offsets, size_t n, - const unsigned char *head, const unsigned char *marker, const size_t size) { - assert(head < marker); - assert(offsets->size() == n); - - for (size_t i = 0; i < n; i++) { - size_t offset = static_cast(marker - head); - // Offset should not exceed whole EXR file/data size. - if ((offset + sizeof(tinyexr::tinyexr_uint64)) >= size) { - return false; - } - - int y; - unsigned int data_len; - - memcpy(&y, marker, sizeof(int)); - memcpy(&data_len, marker + 4, sizeof(unsigned int)); - - if (data_len >= size) { - return false; - } - - tinyexr::swap4(&y); - tinyexr::swap4(&data_len); - - (*offsets)[i] = offset; - - marker += data_len + 8; // 8 = 4 bytes(y) + 4 bytes(data_len) - } - - return true; -} - - -static int FloorLog2(unsigned x) { - // - // For x > 0, floorLog2(y) returns floor(log(x)/log(2)). - // - int y = 0; - while (x > 1) { - y += 1; - x >>= 1u; - } - return y; -} - - -static int CeilLog2(unsigned x) { - // - // For x > 0, ceilLog2(y) returns ceil(log(x)/log(2)). - // - int y = 0; - int r = 0; - while (x > 1) { - if (x & 1) - r = 1; - - y += 1; - x >>= 1u; - } - return y + r; -} - -static int RoundLog2(int x, int tile_rounding_mode) { - return (tile_rounding_mode == TINYEXR_TILE_ROUND_DOWN) ? FloorLog2(static_cast(x)) : CeilLog2(static_cast(x)); -} - -static int CalculateNumXLevels(const EXRHeader* exr_header) { - int min_x = exr_header->data_window.min_x; - int max_x = exr_header->data_window.max_x; - int min_y = exr_header->data_window.min_y; - int max_y = exr_header->data_window.max_y; - - int num = 0; - switch (exr_header->tile_level_mode) { - case TINYEXR_TILE_ONE_LEVEL: - - num = 1; - break; - - case TINYEXR_TILE_MIPMAP_LEVELS: - - { - int w = max_x - min_x + 1; - int h = max_y - min_y + 1; - num = RoundLog2(std::max(w, h), exr_header->tile_rounding_mode) + 1; - } - break; - - case TINYEXR_TILE_RIPMAP_LEVELS: - - { - int w = max_x - min_x + 1; - num = RoundLog2(w, exr_header->tile_rounding_mode) + 1; - } - break; - - default: - - assert(false); - } - - return num; -} - -static int CalculateNumYLevels(const EXRHeader* exr_header) { - int min_x = exr_header->data_window.min_x; - int max_x = exr_header->data_window.max_x; - int min_y = exr_header->data_window.min_y; - int max_y = exr_header->data_window.max_y; - int num = 0; - - switch (exr_header->tile_level_mode) { - case TINYEXR_TILE_ONE_LEVEL: - - num = 1; - break; - - case TINYEXR_TILE_MIPMAP_LEVELS: - - { - int w = max_x - min_x + 1; - int h = max_y - min_y + 1; - num = RoundLog2(std::max(w, h), exr_header->tile_rounding_mode) + 1; - } - break; - - case TINYEXR_TILE_RIPMAP_LEVELS: - - { - int h = max_y - min_y + 1; - num = RoundLog2(h, exr_header->tile_rounding_mode) + 1; - } - break; - - default: - - assert(false); - } - - return num; -} - -static void CalculateNumTiles(std::vector& numTiles, - int toplevel_size, - int size, - int tile_rounding_mode) { - for (unsigned i = 0; i < numTiles.size(); i++) { - int l = LevelSize(toplevel_size, i, tile_rounding_mode); - assert(l <= std::numeric_limits::max() - size + 1); - - numTiles[i] = (l + size - 1) / size; - } -} - -static void PrecalculateTileInfo(std::vector& num_x_tiles, - std::vector& num_y_tiles, - const EXRHeader* exr_header) { - int min_x = exr_header->data_window.min_x; - int max_x = exr_header->data_window.max_x; - int min_y = exr_header->data_window.min_y; - int max_y = exr_header->data_window.max_y; - - int num_x_levels = CalculateNumXLevels(exr_header); - int num_y_levels = CalculateNumYLevels(exr_header); - - num_x_tiles.resize(num_x_levels); - num_y_tiles.resize(num_y_levels); - - CalculateNumTiles(num_x_tiles, - max_x - min_x + 1, - exr_header->tile_size_x, - exr_header->tile_rounding_mode); - - CalculateNumTiles(num_y_tiles, - max_y - min_y + 1, - exr_header->tile_size_y, - exr_header->tile_rounding_mode); -} - -static void InitSingleResolutionOffsets(OffsetData& offset_data, size_t num_blocks) { - offset_data.offsets.resize(1); - offset_data.offsets[0].resize(1); - offset_data.offsets[0][0].resize(num_blocks); - offset_data.num_x_levels = 1; - offset_data.num_y_levels = 1; -} - -// Return sum of tile blocks. -static int InitTileOffsets(OffsetData& offset_data, - const EXRHeader* exr_header, - const std::vector& num_x_tiles, - const std::vector& num_y_tiles) { - int num_tile_blocks = 0; - offset_data.num_x_levels = static_cast(num_x_tiles.size()); - offset_data.num_y_levels = static_cast(num_y_tiles.size()); - switch (exr_header->tile_level_mode) { - case TINYEXR_TILE_ONE_LEVEL: - case TINYEXR_TILE_MIPMAP_LEVELS: - assert(offset_data.num_x_levels == offset_data.num_y_levels); - offset_data.offsets.resize(offset_data.num_x_levels); - - for (unsigned int l = 0; l < offset_data.offsets.size(); ++l) { - offset_data.offsets[l].resize(num_y_tiles[l]); - - for (unsigned int dy = 0; dy < offset_data.offsets[l].size(); ++dy) { - offset_data.offsets[l][dy].resize(num_x_tiles[l]); - num_tile_blocks += num_x_tiles[l]; - } - } - break; - - case TINYEXR_TILE_RIPMAP_LEVELS: - - offset_data.offsets.resize(static_cast(offset_data.num_x_levels) * static_cast(offset_data.num_y_levels)); - - for (int ly = 0; ly < offset_data.num_y_levels; ++ly) { - for (int lx = 0; lx < offset_data.num_x_levels; ++lx) { - int l = ly * offset_data.num_x_levels + lx; - offset_data.offsets[l].resize(num_y_tiles[ly]); - - for (size_t dy = 0; dy < offset_data.offsets[l].size(); ++dy) { - offset_data.offsets[l][dy].resize(num_x_tiles[lx]); - num_tile_blocks += num_x_tiles[lx]; - } - } - } - break; - - default: - assert(false); - } - return num_tile_blocks; -} - -static bool IsAnyOffsetsAreInvalid(const OffsetData& offset_data) { - for (unsigned int l = 0; l < offset_data.offsets.size(); ++l) - for (unsigned int dy = 0; dy < offset_data.offsets[l].size(); ++dy) - for (unsigned int dx = 0; dx < offset_data.offsets[l][dy].size(); ++dx) - if (reinterpret_cast(offset_data.offsets[l][dy][dx]) <= 0) - return true; - - return false; -} - -static bool isValidTile(const EXRHeader* exr_header, - const OffsetData& offset_data, - int dx, int dy, int lx, int ly) { - if (lx < 0 || ly < 0 || dx < 0 || dy < 0) return false; - int num_x_levels = offset_data.num_x_levels; - int num_y_levels = offset_data.num_y_levels; - switch (exr_header->tile_level_mode) { - case TINYEXR_TILE_ONE_LEVEL: - - if (lx == 0 && - ly == 0 && - offset_data.offsets.size() > 0 && - offset_data.offsets[0].size() > static_cast(dy) && - offset_data.offsets[0][dy].size() > static_cast(dx)) { - return true; - } - - break; - - case TINYEXR_TILE_MIPMAP_LEVELS: - - if (lx < num_x_levels && - ly < num_y_levels && - offset_data.offsets.size() > static_cast(lx) && - offset_data.offsets[lx].size() > static_cast(dy) && - offset_data.offsets[lx][dy].size() > static_cast(dx)) { - return true; - } - - break; - - case TINYEXR_TILE_RIPMAP_LEVELS: - { - size_t idx = static_cast(lx) + static_cast(ly)* static_cast(num_x_levels); - if (lx < num_x_levels && - ly < num_y_levels && - (offset_data.offsets.size() > idx) && - offset_data.offsets[idx].size() > static_cast(dy) && - offset_data.offsets[idx][dy].size() > static_cast(dx)) { - return true; - } - } - - break; - - default: - - return false; - } - - return false; -} - -static void ReconstructTileOffsets(OffsetData& offset_data, - const EXRHeader* exr_header, - const unsigned char* head, const unsigned char* marker, const size_t /*size*/, - bool isMultiPartFile, - bool isDeep) { - int numXLevels = offset_data.num_x_levels; - for (unsigned int l = 0; l < offset_data.offsets.size(); ++l) { - for (unsigned int dy = 0; dy < offset_data.offsets[l].size(); ++dy) { - for (unsigned int dx = 0; dx < offset_data.offsets[l][dy].size(); ++dx) { - tinyexr::tinyexr_uint64 tileOffset = marker - head; - - if (isMultiPartFile) { - //int partNumber; - marker += sizeof(int); - } - - int tileX; - memcpy(&tileX, marker, sizeof(int)); - tinyexr::swap4(&tileX); - marker += sizeof(int); - - int tileY; - memcpy(&tileY, marker, sizeof(int)); - tinyexr::swap4(&tileY); - marker += sizeof(int); - - int levelX; - memcpy(&levelX, marker, sizeof(int)); - tinyexr::swap4(&levelX); - marker += sizeof(int); - - int levelY; - memcpy(&levelY, marker, sizeof(int)); - tinyexr::swap4(&levelY); - marker += sizeof(int); - - if (isDeep) { - tinyexr::tinyexr_int64 packed_offset_table_size; - memcpy(&packed_offset_table_size, marker, sizeof(tinyexr::tinyexr_int64)); - tinyexr::swap8(reinterpret_cast(&packed_offset_table_size)); - marker += sizeof(tinyexr::tinyexr_int64); - - tinyexr::tinyexr_int64 packed_sample_size; - memcpy(&packed_sample_size, marker, sizeof(tinyexr::tinyexr_int64)); - tinyexr::swap8(reinterpret_cast(&packed_sample_size)); - marker += sizeof(tinyexr::tinyexr_int64); - - // next Int64 is unpacked sample size - skip that too - marker += packed_offset_table_size + packed_sample_size + 8; - - } else { - - int dataSize; - memcpy(&dataSize, marker, sizeof(int)); - tinyexr::swap4(&dataSize); - marker += sizeof(int); - marker += dataSize; - } - - if (!isValidTile(exr_header, offset_data, - tileX, tileY, levelX, levelY)) - return; - - int level_idx = LevelIndex(levelX, levelY, exr_header->tile_level_mode, numXLevels); - offset_data.offsets[level_idx][tileY][tileX] = tileOffset; - } - } - } -} - -// marker output is also -static int ReadOffsets(OffsetData& offset_data, - const unsigned char* head, - const unsigned char*& marker, - const size_t size, - const char** err) { - for (unsigned int l = 0; l < offset_data.offsets.size(); ++l) { - for (unsigned int dy = 0; dy < offset_data.offsets[l].size(); ++dy) { - for (unsigned int dx = 0; dx < offset_data.offsets[l][dy].size(); ++dx) { - tinyexr::tinyexr_uint64 offset; - if ((marker + sizeof(tinyexr_uint64)) >= (head + size)) { - tinyexr::SetErrorMessage("Insufficient data size in offset table.", err); - return TINYEXR_ERROR_INVALID_DATA; - } - - memcpy(&offset, marker, sizeof(tinyexr::tinyexr_uint64)); - tinyexr::swap8(&offset); - if (offset >= size) { - tinyexr::SetErrorMessage("Invalid offset value in DecodeEXRImage.", err); - return TINYEXR_ERROR_INVALID_DATA; - } - marker += sizeof(tinyexr::tinyexr_uint64); // = 8 - offset_data.offsets[l][dy][dx] = offset; - } - } - } - return TINYEXR_SUCCESS; -} - -static int DecodeEXRImage(EXRImage *exr_image, const EXRHeader *exr_header, - const unsigned char *head, - const unsigned char *marker, const size_t size, - const char **err) { - if (exr_image == NULL || exr_header == NULL || head == NULL || - marker == NULL || (size <= tinyexr::kEXRVersionSize)) { - tinyexr::SetErrorMessage("Invalid argument for DecodeEXRImage().", err); - return TINYEXR_ERROR_INVALID_ARGUMENT; - } - - int num_scanline_blocks = 1; - if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_ZIP) { - num_scanline_blocks = 16; - } else if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_PIZ) { - num_scanline_blocks = 32; - } else if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_ZFP) { - num_scanline_blocks = 16; - } - - if (exr_header->data_window.max_x < exr_header->data_window.min_x || - exr_header->data_window.max_x - exr_header->data_window.min_x == - std::numeric_limits::max()) { - // Issue 63 - tinyexr::SetErrorMessage("Invalid data width value", err); - return TINYEXR_ERROR_INVALID_DATA; - } - int data_width = - exr_header->data_window.max_x - exr_header->data_window.min_x + 1; - - if (exr_header->data_window.max_y < exr_header->data_window.min_y || - exr_header->data_window.max_y - exr_header->data_window.min_y == - std::numeric_limits::max()) { - tinyexr::SetErrorMessage("Invalid data height value", err); - return TINYEXR_ERROR_INVALID_DATA; - } - int data_height = - exr_header->data_window.max_y - exr_header->data_window.min_y + 1; - - // Do not allow too large data_width and data_height. header invalid? - { - if (data_width > TINYEXR_DIMENSION_THRESHOLD) { - tinyexr::SetErrorMessage("data width too large.", err); - return TINYEXR_ERROR_INVALID_DATA; - } - if (data_height > TINYEXR_DIMENSION_THRESHOLD) { - tinyexr::SetErrorMessage("data height too large.", err); - return TINYEXR_ERROR_INVALID_DATA; - } - } - - if (exr_header->tiled) { - if (exr_header->tile_size_x > TINYEXR_DIMENSION_THRESHOLD) { - tinyexr::SetErrorMessage("tile width too large.", err); - return TINYEXR_ERROR_INVALID_DATA; - } - if (exr_header->tile_size_y > TINYEXR_DIMENSION_THRESHOLD) { - tinyexr::SetErrorMessage("tile height too large.", err); - return TINYEXR_ERROR_INVALID_DATA; - } - } - - // Read offset tables. - OffsetData offset_data; - size_t num_blocks = 0; - // For a multi-resolution image, the size of the offset table will be calculated from the other attributes of the header. - // If chunk_count > 0 then chunk_count must be equal to the calculated tile count. - if (exr_header->tiled) { - { - std::vector num_x_tiles, num_y_tiles; - PrecalculateTileInfo(num_x_tiles, num_y_tiles, exr_header); - num_blocks = InitTileOffsets(offset_data, exr_header, num_x_tiles, num_y_tiles); - if (exr_header->chunk_count > 0) { - if (exr_header->chunk_count != static_cast(num_blocks)) { - tinyexr::SetErrorMessage("Invalid offset table size.", err); - return TINYEXR_ERROR_INVALID_DATA; - } - } - } - - int ret = ReadOffsets(offset_data, head, marker, size, err); - if (ret != TINYEXR_SUCCESS) return ret; - if (IsAnyOffsetsAreInvalid(offset_data)) { - ReconstructTileOffsets(offset_data, exr_header, - head, marker, size, - exr_header->multipart, exr_header->non_image); - } - } else if (exr_header->chunk_count > 0) { - // Use `chunkCount` attribute. - num_blocks = static_cast(exr_header->chunk_count); - InitSingleResolutionOffsets(offset_data, num_blocks); - } else { - num_blocks = static_cast(data_height) / - static_cast(num_scanline_blocks); - if (num_blocks * static_cast(num_scanline_blocks) < - static_cast(data_height)) { - num_blocks++; - } - - InitSingleResolutionOffsets(offset_data, num_blocks); - } - - if (!exr_header->tiled) { - std::vector& offsets = offset_data.offsets[0][0]; - for (size_t y = 0; y < num_blocks; y++) { - tinyexr::tinyexr_uint64 offset; - // Issue #81 - if ((marker + sizeof(tinyexr_uint64)) >= (head + size)) { - tinyexr::SetErrorMessage("Insufficient data size in offset table.", err); - return TINYEXR_ERROR_INVALID_DATA; - } - - memcpy(&offset, marker, sizeof(tinyexr::tinyexr_uint64)); - tinyexr::swap8(&offset); - if (offset >= size) { - tinyexr::SetErrorMessage("Invalid offset value in DecodeEXRImage.", err); - return TINYEXR_ERROR_INVALID_DATA; - } - marker += sizeof(tinyexr::tinyexr_uint64); // = 8 - offsets[y] = offset; - } - - // If line offsets are invalid, we try to reconstruct it. - // See OpenEXR/IlmImf/ImfScanLineInputFile.cpp::readLineOffsets() for details. - for (size_t y = 0; y < num_blocks; y++) { - if (offsets[y] <= 0) { - // TODO(syoyo) Report as warning? - // if (err) { - // stringstream ss; - // ss << "Incomplete lineOffsets." << std::endl; - // (*err) += ss.str(); - //} - bool ret = - ReconstructLineOffsets(&offsets, num_blocks, head, marker, size); - if (ret) { - // OK - break; - } else { - tinyexr::SetErrorMessage( - "Cannot reconstruct lineOffset table in DecodeEXRImage.", err); - return TINYEXR_ERROR_INVALID_DATA; - } - } - } - } - - { - std::string e; - int ret = DecodeChunk(exr_image, exr_header, offset_data, head, size, &e); - - if (ret != TINYEXR_SUCCESS) { - if (!e.empty()) { - tinyexr::SetErrorMessage(e, err); - } - -#if 1 - FreeEXRImage(exr_image); -#else - // release memory(if exists) - if ((exr_header->num_channels > 0) && exr_image && exr_image->images) { - for (size_t c = 0; c < size_t(exr_header->num_channels); c++) { - if (exr_image->images[c]) { - free(exr_image->images[c]); - exr_image->images[c] = NULL; - } - } - free(exr_image->images); - exr_image->images = NULL; - } -#endif - } - - return ret; - } -} - -static void GetLayers(const EXRHeader &exr_header, - std::vector &layer_names) { - // Naive implementation - // Group channels by layers - // go over all channel names, split by periods - // collect unique names - layer_names.clear(); - for (int c = 0; c < exr_header.num_channels; c++) { - std::string full_name(exr_header.channels[c].name); - const size_t pos = full_name.find_last_of('.'); - if (pos != std::string::npos && pos != 0 && pos + 1 < full_name.size()) { - full_name.erase(pos); - if (std::find(layer_names.begin(), layer_names.end(), full_name) == - layer_names.end()) - layer_names.push_back(full_name); - } - } -} - -struct LayerChannel { - explicit LayerChannel(size_t i, std::string n) : index(i), name(n) {} - size_t index; - std::string name; -}; - -static void ChannelsInLayer(const EXRHeader &exr_header, - const std::string layer_name, - std::vector &channels) { - channels.clear(); - for (int c = 0; c < exr_header.num_channels; c++) { - std::string ch_name(exr_header.channels[c].name); - if (layer_name.empty()) { - const size_t pos = ch_name.find_last_of('.'); - if (pos != std::string::npos && pos < ch_name.size()) { - ch_name = ch_name.substr(pos + 1); - } - } else { - const size_t pos = ch_name.find(layer_name + '.'); - if (pos == std::string::npos) continue; - if (pos == 0) { - ch_name = ch_name.substr(layer_name.size() + 1); - } - } - LayerChannel ch(size_t(c), ch_name); - channels.push_back(ch); - } -} - -} // namespace tinyexr - -int EXRLayers(const char *filename, const char **layer_names[], int *num_layers, - const char **err) { - EXRVersion exr_version; - EXRHeader exr_header; - InitEXRHeader(&exr_header); - - { - int ret = ParseEXRVersionFromFile(&exr_version, filename); - if (ret != TINYEXR_SUCCESS) { - tinyexr::SetErrorMessage("Invalid EXR header.", err); - return ret; - } - - if (exr_version.multipart || exr_version.non_image) { - tinyexr::SetErrorMessage( - "Loading multipart or DeepImage is not supported in LoadEXR() API", - err); - return TINYEXR_ERROR_INVALID_DATA; // @fixme. - } - } - - int ret = ParseEXRHeaderFromFile(&exr_header, &exr_version, filename, err); - if (ret != TINYEXR_SUCCESS) { - FreeEXRHeader(&exr_header); - return ret; - } - - std::vector layer_vec; - tinyexr::GetLayers(exr_header, layer_vec); - - (*num_layers) = int(layer_vec.size()); - (*layer_names) = static_cast( - malloc(sizeof(const char *) * static_cast(layer_vec.size()))); - for (size_t c = 0; c < static_cast(layer_vec.size()); c++) { -#ifdef _MSC_VER - (*layer_names)[c] = _strdup(layer_vec[c].c_str()); -#else - (*layer_names)[c] = strdup(layer_vec[c].c_str()); -#endif - } - - FreeEXRHeader(&exr_header); - return TINYEXR_SUCCESS; -} - -int LoadEXR(float **out_rgba, int *width, int *height, const char *filename, - const char **err) { - return LoadEXRWithLayer(out_rgba, width, height, filename, - /* layername */ NULL, err); -} - -int LoadEXRWithLayer(float **out_rgba, int *width, int *height, - const char *filename, const char *layername, - const char **err) { - if (out_rgba == NULL) { - tinyexr::SetErrorMessage("Invalid argument for LoadEXR()", err); - return TINYEXR_ERROR_INVALID_ARGUMENT; - } - - EXRVersion exr_version; - EXRImage exr_image; - EXRHeader exr_header; - InitEXRHeader(&exr_header); - InitEXRImage(&exr_image); - - { - int ret = ParseEXRVersionFromFile(&exr_version, filename); - if (ret != TINYEXR_SUCCESS) { - std::stringstream ss; - ss << "Failed to open EXR file or read version info from EXR file. code(" - << ret << ")"; - tinyexr::SetErrorMessage(ss.str(), err); - return ret; - } - - if (exr_version.multipart || exr_version.non_image) { - tinyexr::SetErrorMessage( - "Loading multipart or DeepImage is not supported in LoadEXR() API", - err); - return TINYEXR_ERROR_INVALID_DATA; // @fixme. - } - } - - { - int ret = ParseEXRHeaderFromFile(&exr_header, &exr_version, filename, err); - if (ret != TINYEXR_SUCCESS) { - FreeEXRHeader(&exr_header); - return ret; - } - } - - // Read HALF channel as FLOAT. - for (int i = 0; i < exr_header.num_channels; i++) { - if (exr_header.pixel_types[i] == TINYEXR_PIXELTYPE_HALF) { - exr_header.requested_pixel_types[i] = TINYEXR_PIXELTYPE_FLOAT; - } - } - - // TODO: Probably limit loading to layers (channels) selected by layer index - { - int ret = LoadEXRImageFromFile(&exr_image, &exr_header, filename, err); - if (ret != TINYEXR_SUCCESS) { - FreeEXRHeader(&exr_header); - return ret; - } - } - - // RGBA - int idxR = -1; - int idxG = -1; - int idxB = -1; - int idxA = -1; - - std::vector layer_names; - tinyexr::GetLayers(exr_header, layer_names); - - std::vector channels; - tinyexr::ChannelsInLayer( - exr_header, layername == NULL ? "" : std::string(layername), channels); - - if (channels.size() < 1) { - tinyexr::SetErrorMessage("Layer Not Found", err); - FreeEXRHeader(&exr_header); - FreeEXRImage(&exr_image); - return TINYEXR_ERROR_LAYER_NOT_FOUND; - } - - size_t ch_count = channels.size() < 4 ? channels.size() : 4; - for (size_t c = 0; c < ch_count; c++) { - const tinyexr::LayerChannel &ch = channels[c]; - - if (ch.name == "R") { - idxR = int(ch.index); - } else if (ch.name == "G") { - idxG = int(ch.index); - } else if (ch.name == "B") { - idxB = int(ch.index); - } else if (ch.name == "A") { - idxA = int(ch.index); - } - } - - if (channels.size() == 1) { - int chIdx = int(channels.front().index); - // Grayscale channel only. - - (*out_rgba) = reinterpret_cast( - malloc(4 * sizeof(float) * static_cast(exr_image.width) * - static_cast(exr_image.height))); - - if (exr_header.tiled) { - for (int it = 0; it < exr_image.num_tiles; it++) { - for (int j = 0; j < exr_header.tile_size_y; j++) { - for (int i = 0; i < exr_header.tile_size_x; i++) { - const int ii = exr_image.tiles[it].offset_x * - static_cast(exr_header.tile_size_x) + - i; - const int jj = exr_image.tiles[it].offset_y * - static_cast(exr_header.tile_size_y) + - j; - const int idx = ii + jj * static_cast(exr_image.width); - - // out of region check. - if (ii >= exr_image.width) { - continue; - } - if (jj >= exr_image.height) { - continue; - } - const int srcIdx = i + j * exr_header.tile_size_x; - unsigned char **src = exr_image.tiles[it].images; - (*out_rgba)[4 * idx + 0] = - reinterpret_cast(src)[chIdx][srcIdx]; - (*out_rgba)[4 * idx + 1] = - reinterpret_cast(src)[chIdx][srcIdx]; - (*out_rgba)[4 * idx + 2] = - reinterpret_cast(src)[chIdx][srcIdx]; - (*out_rgba)[4 * idx + 3] = - reinterpret_cast(src)[chIdx][srcIdx]; - } - } - } - } else { - for (int i = 0; i < exr_image.width * exr_image.height; i++) { - const float val = - reinterpret_cast(exr_image.images)[chIdx][i]; - (*out_rgba)[4 * i + 0] = val; - (*out_rgba)[4 * i + 1] = val; - (*out_rgba)[4 * i + 2] = val; - (*out_rgba)[4 * i + 3] = val; - } - } - } else { - // Assume RGB(A) - - if (idxR == -1) { - tinyexr::SetErrorMessage("R channel not found", err); - - FreeEXRHeader(&exr_header); - FreeEXRImage(&exr_image); - return TINYEXR_ERROR_INVALID_DATA; - } - - if (idxG == -1) { - tinyexr::SetErrorMessage("G channel not found", err); - FreeEXRHeader(&exr_header); - FreeEXRImage(&exr_image); - return TINYEXR_ERROR_INVALID_DATA; - } - - if (idxB == -1) { - tinyexr::SetErrorMessage("B channel not found", err); - FreeEXRHeader(&exr_header); - FreeEXRImage(&exr_image); - return TINYEXR_ERROR_INVALID_DATA; - } - - (*out_rgba) = reinterpret_cast( - malloc(4 * sizeof(float) * static_cast(exr_image.width) * - static_cast(exr_image.height))); - if (exr_header.tiled) { - for (int it = 0; it < exr_image.num_tiles; it++) { - for (int j = 0; j < exr_header.tile_size_y; j++) { - for (int i = 0; i < exr_header.tile_size_x; i++) { - const int ii = - exr_image.tiles[it].offset_x * exr_header.tile_size_x + i; - const int jj = - exr_image.tiles[it].offset_y * exr_header.tile_size_y + j; - const int idx = ii + jj * exr_image.width; - - // out of region check. - if (ii >= exr_image.width) { - continue; - } - if (jj >= exr_image.height) { - continue; - } - const int srcIdx = i + j * exr_header.tile_size_x; - unsigned char **src = exr_image.tiles[it].images; - (*out_rgba)[4 * idx + 0] = - reinterpret_cast(src)[idxR][srcIdx]; - (*out_rgba)[4 * idx + 1] = - reinterpret_cast(src)[idxG][srcIdx]; - (*out_rgba)[4 * idx + 2] = - reinterpret_cast(src)[idxB][srcIdx]; - if (idxA != -1) { - (*out_rgba)[4 * idx + 3] = - reinterpret_cast(src)[idxA][srcIdx]; - } else { - (*out_rgba)[4 * idx + 3] = 1.0; - } - } - } - } - } else { - for (int i = 0; i < exr_image.width * exr_image.height; i++) { - (*out_rgba)[4 * i + 0] = - reinterpret_cast(exr_image.images)[idxR][i]; - (*out_rgba)[4 * i + 1] = - reinterpret_cast(exr_image.images)[idxG][i]; - (*out_rgba)[4 * i + 2] = - reinterpret_cast(exr_image.images)[idxB][i]; - if (idxA != -1) { - (*out_rgba)[4 * i + 3] = - reinterpret_cast(exr_image.images)[idxA][i]; - } else { - (*out_rgba)[4 * i + 3] = 1.0; - } - } - } - } - - (*width) = exr_image.width; - (*height) = exr_image.height; - - FreeEXRHeader(&exr_header); - FreeEXRImage(&exr_image); - - return TINYEXR_SUCCESS; -} - -int IsEXR(const char *filename) { - EXRVersion exr_version; - - int ret = ParseEXRVersionFromFile(&exr_version, filename); - if (ret != TINYEXR_SUCCESS) { - return ret; - } - - return TINYEXR_SUCCESS; -} - -int ParseEXRHeaderFromMemory(EXRHeader *exr_header, const EXRVersion *version, - const unsigned char *memory, size_t size, - const char **err) { - if (memory == NULL || exr_header == NULL) { - tinyexr::SetErrorMessage( - "Invalid argument. `memory` or `exr_header` argument is null in " - "ParseEXRHeaderFromMemory()", - err); - - // Invalid argument - return TINYEXR_ERROR_INVALID_ARGUMENT; - } - - if (size < tinyexr::kEXRVersionSize) { - tinyexr::SetErrorMessage("Insufficient header/data size.\n", err); - return TINYEXR_ERROR_INVALID_DATA; - } - - const unsigned char *marker = memory + tinyexr::kEXRVersionSize; - size_t marker_size = size - tinyexr::kEXRVersionSize; - - tinyexr::HeaderInfo info; - info.clear(); - - std::string err_str; - int ret = ParseEXRHeader(&info, NULL, version, &err_str, marker, marker_size); - - if (ret != TINYEXR_SUCCESS) { - if (err && !err_str.empty()) { - tinyexr::SetErrorMessage(err_str, err); - } - } - - ConvertHeader(exr_header, info); - - exr_header->multipart = version->multipart ? 1 : 0; - exr_header->non_image = version->non_image ? 1 : 0; - - return ret; -} - -int LoadEXRFromMemory(float **out_rgba, int *width, int *height, - const unsigned char *memory, size_t size, - const char **err) { - if (out_rgba == NULL || memory == NULL) { - tinyexr::SetErrorMessage("Invalid argument for LoadEXRFromMemory", err); - return TINYEXR_ERROR_INVALID_ARGUMENT; - } - - EXRVersion exr_version; - EXRImage exr_image; - EXRHeader exr_header; - - InitEXRHeader(&exr_header); - - int ret = ParseEXRVersionFromMemory(&exr_version, memory, size); - if (ret != TINYEXR_SUCCESS) { - std::stringstream ss; - ss << "Failed to parse EXR version. code(" << ret << ")"; - tinyexr::SetErrorMessage(ss.str(), err); - return ret; - } - - ret = ParseEXRHeaderFromMemory(&exr_header, &exr_version, memory, size, err); - if (ret != TINYEXR_SUCCESS) { - return ret; - } - - // Read HALF channel as FLOAT. - for (int i = 0; i < exr_header.num_channels; i++) { - if (exr_header.pixel_types[i] == TINYEXR_PIXELTYPE_HALF) { - exr_header.requested_pixel_types[i] = TINYEXR_PIXELTYPE_FLOAT; - } - } - - InitEXRImage(&exr_image); - ret = LoadEXRImageFromMemory(&exr_image, &exr_header, memory, size, err); - if (ret != TINYEXR_SUCCESS) { - return ret; - } - - // RGBA - int idxR = -1; - int idxG = -1; - int idxB = -1; - int idxA = -1; - for (int c = 0; c < exr_header.num_channels; c++) { - if (strcmp(exr_header.channels[c].name, "R") == 0) { - idxR = c; - } else if (strcmp(exr_header.channels[c].name, "G") == 0) { - idxG = c; - } else if (strcmp(exr_header.channels[c].name, "B") == 0) { - idxB = c; - } else if (strcmp(exr_header.channels[c].name, "A") == 0) { - idxA = c; - } - } - - // TODO(syoyo): Refactor removing same code as used in LoadEXR(). - if (exr_header.num_channels == 1) { - // Grayscale channel only. - - (*out_rgba) = reinterpret_cast( - malloc(4 * sizeof(float) * static_cast(exr_image.width) * - static_cast(exr_image.height))); - - if (exr_header.tiled) { - for (int it = 0; it < exr_image.num_tiles; it++) { - for (int j = 0; j < exr_header.tile_size_y; j++) { - for (int i = 0; i < exr_header.tile_size_x; i++) { - const int ii = - exr_image.tiles[it].offset_x * exr_header.tile_size_x + i; - const int jj = - exr_image.tiles[it].offset_y * exr_header.tile_size_y + j; - const int idx = ii + jj * exr_image.width; - - // out of region check. - if (ii >= exr_image.width) { - continue; - } - if (jj >= exr_image.height) { - continue; - } - const int srcIdx = i + j * exr_header.tile_size_x; - unsigned char **src = exr_image.tiles[it].images; - (*out_rgba)[4 * idx + 0] = - reinterpret_cast(src)[0][srcIdx]; - (*out_rgba)[4 * idx + 1] = - reinterpret_cast(src)[0][srcIdx]; - (*out_rgba)[4 * idx + 2] = - reinterpret_cast(src)[0][srcIdx]; - (*out_rgba)[4 * idx + 3] = - reinterpret_cast(src)[0][srcIdx]; - } - } - } - } else { - for (int i = 0; i < exr_image.width * exr_image.height; i++) { - const float val = reinterpret_cast(exr_image.images)[0][i]; - (*out_rgba)[4 * i + 0] = val; - (*out_rgba)[4 * i + 1] = val; - (*out_rgba)[4 * i + 2] = val; - (*out_rgba)[4 * i + 3] = val; - } - } - - } else { - // TODO(syoyo): Support non RGBA image. - - if (idxR == -1) { - tinyexr::SetErrorMessage("R channel not found", err); - - // @todo { free exr_image } - return TINYEXR_ERROR_INVALID_DATA; - } - - if (idxG == -1) { - tinyexr::SetErrorMessage("G channel not found", err); - // @todo { free exr_image } - return TINYEXR_ERROR_INVALID_DATA; - } - - if (idxB == -1) { - tinyexr::SetErrorMessage("B channel not found", err); - // @todo { free exr_image } - return TINYEXR_ERROR_INVALID_DATA; - } - - (*out_rgba) = reinterpret_cast( - malloc(4 * sizeof(float) * static_cast(exr_image.width) * - static_cast(exr_image.height))); - - if (exr_header.tiled) { - for (int it = 0; it < exr_image.num_tiles; it++) { - for (int j = 0; j < exr_header.tile_size_y; j++) - for (int i = 0; i < exr_header.tile_size_x; i++) { - const int ii = - exr_image.tiles[it].offset_x * exr_header.tile_size_x + i; - const int jj = - exr_image.tiles[it].offset_y * exr_header.tile_size_y + j; - const int idx = ii + jj * exr_image.width; - - // out of region check. - if (ii >= exr_image.width) { - continue; - } - if (jj >= exr_image.height) { - continue; - } - const int srcIdx = i + j * exr_header.tile_size_x; - unsigned char **src = exr_image.tiles[it].images; - (*out_rgba)[4 * idx + 0] = - reinterpret_cast(src)[idxR][srcIdx]; - (*out_rgba)[4 * idx + 1] = - reinterpret_cast(src)[idxG][srcIdx]; - (*out_rgba)[4 * idx + 2] = - reinterpret_cast(src)[idxB][srcIdx]; - if (idxA != -1) { - (*out_rgba)[4 * idx + 3] = - reinterpret_cast(src)[idxA][srcIdx]; - } else { - (*out_rgba)[4 * idx + 3] = 1.0; - } - } - } - } else { - for (int i = 0; i < exr_image.width * exr_image.height; i++) { - (*out_rgba)[4 * i + 0] = - reinterpret_cast(exr_image.images)[idxR][i]; - (*out_rgba)[4 * i + 1] = - reinterpret_cast(exr_image.images)[idxG][i]; - (*out_rgba)[4 * i + 2] = - reinterpret_cast(exr_image.images)[idxB][i]; - if (idxA != -1) { - (*out_rgba)[4 * i + 3] = - reinterpret_cast(exr_image.images)[idxA][i]; - } else { - (*out_rgba)[4 * i + 3] = 1.0; - } - } - } - } - - (*width) = exr_image.width; - (*height) = exr_image.height; - - FreeEXRHeader(&exr_header); - FreeEXRImage(&exr_image); - - return TINYEXR_SUCCESS; -} - -int LoadEXRImageFromFile(EXRImage *exr_image, const EXRHeader *exr_header, - const char *filename, const char **err) { - if (exr_image == NULL) { - tinyexr::SetErrorMessage("Invalid argument for LoadEXRImageFromFile", err); - return TINYEXR_ERROR_INVALID_ARGUMENT; - } - - FILE *fp = NULL; -#ifdef _WIN32 -#if defined(_MSC_VER) || defined(__MINGW32__) // MSVC, MinGW gcc or clang - errno_t errcode = - _wfopen_s(&fp, tinyexr::UTF8ToWchar(filename).c_str(), L"rb"); - if (errcode != 0) { - tinyexr::SetErrorMessage("Cannot read file " + std::string(filename), err); - // TODO(syoyo): return wfopen_s erro code - return TINYEXR_ERROR_CANT_OPEN_FILE; - } -#else - // Unknown compiler - fp = fopen(filename, "rb"); -#endif -#else - fp = fopen(filename, "rb"); -#endif - if (!fp) { - tinyexr::SetErrorMessage("Cannot read file " + std::string(filename), err); - return TINYEXR_ERROR_CANT_OPEN_FILE; - } - - size_t filesize; - // Compute size - fseek(fp, 0, SEEK_END); - filesize = static_cast(ftell(fp)); - fseek(fp, 0, SEEK_SET); - - if (filesize < 16) { - tinyexr::SetErrorMessage("File size too short " + std::string(filename), - err); - return TINYEXR_ERROR_INVALID_FILE; - } - - std::vector buf(filesize); // @todo { use mmap } - { - size_t ret; - ret = fread(&buf[0], 1, filesize, fp); - assert(ret == filesize); - fclose(fp); - (void)ret; - } - - return LoadEXRImageFromMemory(exr_image, exr_header, &buf.at(0), filesize, - err); -} - -int LoadEXRImageFromMemory(EXRImage *exr_image, const EXRHeader *exr_header, - const unsigned char *memory, const size_t size, - const char **err) { - if (exr_image == NULL || memory == NULL || - (size < tinyexr::kEXRVersionSize)) { - tinyexr::SetErrorMessage("Invalid argument for LoadEXRImageFromMemory", - err); - return TINYEXR_ERROR_INVALID_ARGUMENT; - } - - if (exr_header->header_len == 0) { - tinyexr::SetErrorMessage("EXRHeader variable is not initialized.", err); - return TINYEXR_ERROR_INVALID_ARGUMENT; - } - - const unsigned char *head = memory; - const unsigned char *marker = reinterpret_cast( - memory + exr_header->header_len + - 8); // +8 for magic number + version header. - return tinyexr::DecodeEXRImage(exr_image, exr_header, head, marker, size, - err); -} - -namespace tinyexr -{ - -// out_data must be allocated initially with the block-header size -// of the current image(-part) type -static bool EncodePixelData(/* out */ std::vector& out_data, - const unsigned char* const* images, - int compression_type, - int /*line_order*/, - int width, // for tiled : tile.width - int /*height*/, // for tiled : header.tile_size_y - int x_stride, // for tiled : header.tile_size_x - int line_no, // for tiled : 0 - int num_lines, // for tiled : tile.height - size_t pixel_data_size, - const std::vector& channels, - const std::vector& channel_offset_list, - const void* compression_param = 0) // zfp compression param -{ - size_t buf_size = static_cast(width) * - static_cast(num_lines) * - static_cast(pixel_data_size); - //int last2bit = (buf_size & 3); - // buf_size must be multiple of four - //if(last2bit) buf_size += 4 - last2bit; - std::vector buf(buf_size); - - size_t start_y = static_cast(line_no); - for (size_t c = 0; c < channels.size(); c++) { - if (channels[c].pixel_type == TINYEXR_PIXELTYPE_HALF) { - if (channels[c].requested_pixel_type == TINYEXR_PIXELTYPE_FLOAT) { - for (int y = 0; y < num_lines; y++) { - // Assume increasing Y - float *line_ptr = reinterpret_cast(&buf.at( - static_cast(pixel_data_size * y * width) + - channel_offset_list[c] * - static_cast(width))); - for (int x = 0; x < width; x++) { - tinyexr::FP16 h16; - h16.u = reinterpret_cast( - images)[c][(y + start_y) * x_stride + x]; - - tinyexr::FP32 f32 = half_to_float(h16); - - tinyexr::swap4(&f32.f); - - // line_ptr[x] = f32.f; - tinyexr::cpy4(line_ptr + x, &(f32.f)); - } - } - } else if (channels[c].requested_pixel_type == TINYEXR_PIXELTYPE_HALF) { - for (int y = 0; y < num_lines; y++) { - // Assume increasing Y - unsigned short *line_ptr = reinterpret_cast( - &buf.at(static_cast(pixel_data_size * y * - width) + - channel_offset_list[c] * - static_cast(width))); - for (int x = 0; x < width; x++) { - unsigned short val = reinterpret_cast( - images)[c][(y + start_y) * x_stride + x]; - - tinyexr::swap2(&val); - - // line_ptr[x] = val; - tinyexr::cpy2(line_ptr + x, &val); - } - } - } else { - assert(0); - } - - } else if (channels[c].pixel_type == TINYEXR_PIXELTYPE_FLOAT) { - if (channels[c].requested_pixel_type == TINYEXR_PIXELTYPE_HALF) { - for (int y = 0; y < num_lines; y++) { - // Assume increasing Y - unsigned short *line_ptr = reinterpret_cast( - &buf.at(static_cast(pixel_data_size * y * - width) + - channel_offset_list[c] * - static_cast(width))); - for (int x = 0; x < width; x++) { - tinyexr::FP32 f32; - f32.f = reinterpret_cast( - images)[c][(y + start_y) * x_stride + x]; - - tinyexr::FP16 h16; - h16 = float_to_half_full(f32); - - tinyexr::swap2(reinterpret_cast(&h16.u)); - - // line_ptr[x] = h16.u; - tinyexr::cpy2(line_ptr + x, &(h16.u)); - } - } - } else if (channels[c].requested_pixel_type == TINYEXR_PIXELTYPE_FLOAT) { - for (int y = 0; y < num_lines; y++) { - // Assume increasing Y - float *line_ptr = reinterpret_cast(&buf.at( - static_cast(pixel_data_size * y * width) + - channel_offset_list[c] * - static_cast(width))); - for (int x = 0; x < width; x++) { - float val = reinterpret_cast( - images)[c][(y + start_y) * x_stride + x]; - - tinyexr::swap4(&val); - - // line_ptr[x] = val; - tinyexr::cpy4(line_ptr + x, &val); - } - } - } else { - assert(0); - } - } else if (channels[c].pixel_type == TINYEXR_PIXELTYPE_UINT) { - for (int y = 0; y < num_lines; y++) { - // Assume increasing Y - unsigned int *line_ptr = reinterpret_cast(&buf.at( - static_cast(pixel_data_size * y * width) + - channel_offset_list[c] * static_cast(width))); - for (int x = 0; x < width; x++) { - unsigned int val = reinterpret_cast( - images)[c][(y + start_y) * x_stride + x]; - - tinyexr::swap4(&val); - - // line_ptr[x] = val; - tinyexr::cpy4(line_ptr + x, &val); - } - } - } - } - - if (compression_type == TINYEXR_COMPRESSIONTYPE_NONE) { - // 4 byte: scan line - // 4 byte: data size - // ~ : pixel data(uncompressed) - out_data.insert(out_data.end(), buf.begin(), buf.end()); - - } else if ((compression_type == TINYEXR_COMPRESSIONTYPE_ZIPS) || - (compression_type == TINYEXR_COMPRESSIONTYPE_ZIP)) { -#if TINYEXR_USE_MINIZ - std::vector block(mz_compressBound( - static_cast(buf.size()))); -#else - std::vector block( - compressBound(static_cast(buf.size()))); -#endif - tinyexr::tinyexr_uint64 outSize = block.size(); - - tinyexr::CompressZip(&block.at(0), outSize, - reinterpret_cast(&buf.at(0)), - static_cast(buf.size())); - - // 4 byte: scan line - // 4 byte: data size - // ~ : pixel data(compressed) - unsigned int data_len = static_cast(outSize); // truncate - - out_data.insert(out_data.end(), block.begin(), block.begin() + data_len); - - } else if (compression_type == TINYEXR_COMPRESSIONTYPE_RLE) { - // (buf.size() * 3) / 2 would be enough. - std::vector block((buf.size() * 3) / 2); - - tinyexr::tinyexr_uint64 outSize = block.size(); - - tinyexr::CompressRle(&block.at(0), outSize, - reinterpret_cast(&buf.at(0)), - static_cast(buf.size())); - - // 4 byte: scan line - // 4 byte: data size - // ~ : pixel data(compressed) - unsigned int data_len = static_cast(outSize); // truncate - out_data.insert(out_data.end(), block.begin(), block.begin() + data_len); - - } else if (compression_type == TINYEXR_COMPRESSIONTYPE_PIZ) { -#if TINYEXR_USE_PIZ - unsigned int bufLen = - 8192 + static_cast( - 2 * static_cast( - buf.size())); // @fixme { compute good bound. } - std::vector block(bufLen); - unsigned int outSize = static_cast(block.size()); - - CompressPiz(&block.at(0), &outSize, - reinterpret_cast(&buf.at(0)), - buf.size(), channels, width, num_lines); - - // 4 byte: scan line - // 4 byte: data size - // ~ : pixel data(compressed) - unsigned int data_len = outSize; - out_data.insert(out_data.end(), block.begin(), block.begin() + data_len); - -#else - assert(0); -#endif - } else if (compression_type == TINYEXR_COMPRESSIONTYPE_ZFP) { -#if TINYEXR_USE_ZFP - const ZFPCompressionParam* zfp_compression_param = reinterpret_cast(compression_param); - std::vector block; - unsigned int outSize; - - tinyexr::CompressZfp( - &block, &outSize, reinterpret_cast(&buf.at(0)), - width, num_lines, static_cast(channels.size()), *zfp_compression_param); - - // 4 byte: scan line - // 4 byte: data size - // ~ : pixel data(compressed) - unsigned int data_len = outSize; - out_data.insert(out_data.end(), block.begin(), block.begin() + data_len); - -#else - (void)compression_param; - assert(0); -#endif - } else { - assert(0); - return false; - } - - return true; -} - -static int EncodeTiledLevel(const EXRImage* level_image, const EXRHeader* exr_header, - const std::vector& channels, - std::vector >& data_list, - size_t start_index, // for data_list - int num_x_tiles, int num_y_tiles, - const std::vector& channel_offset_list, - int pixel_data_size, - const void* compression_param, // must be set if zfp compression is enabled - std::string* err) { - int num_tiles = num_x_tiles * num_y_tiles; - assert(num_tiles == level_image->num_tiles); - - if ((exr_header->tile_size_x > level_image->width || exr_header->tile_size_y > level_image->height) && - level_image->level_x == 0 && level_image->level_y == 0) { - if (err) { - (*err) += "Failed to encode tile data.\n"; - } - return TINYEXR_ERROR_INVALID_DATA; - } - - -#if TINYEXR_HAS_CXX11 && (TINYEXR_USE_THREAD > 0) - std::atomic invalid_data(false); -#else - bool invalid_data(false); -#endif - -#if TINYEXR_HAS_CXX11 && (TINYEXR_USE_THREAD > 0) - std::vector workers; - std::atomic tile_count(0); - - int num_threads = std::max(1, int(std::thread::hardware_concurrency())); - if (num_threads > int(num_tiles)) { - num_threads = int(num_tiles); - } - - for (int t = 0; t < num_threads; t++) { - workers.emplace_back(std::thread([&]() { - int i = 0; - while ((i = tile_count++) < num_tiles) { - -#else - // Use signed int since some OpenMP compiler doesn't allow unsigned type for - // `parallel for` -#if TINYEXR_USE_OPENMP -#pragma omp parallel for -#endif - for (int i = 0; i < num_tiles; i++) { - -#endif - size_t tile_idx = static_cast(i); - size_t data_idx = tile_idx + start_index; - - int x_tile = i % num_x_tiles; - int y_tile = i / num_x_tiles; - - EXRTile& tile = level_image->tiles[tile_idx]; - - const unsigned char* const* images = - static_cast(tile.images); - - data_list[data_idx].resize(5*sizeof(int)); - size_t data_header_size = data_list[data_idx].size(); - bool ret = EncodePixelData(data_list[data_idx], - images, - exr_header->compression_type, - 0, // increasing y - tile.width, - exr_header->tile_size_y, - exr_header->tile_size_x, - 0, - tile.height, - pixel_data_size, - channels, - channel_offset_list, - compression_param); - if (!ret) { - invalid_data = true; - continue; - } - assert(data_list[data_idx].size() > data_header_size); - int data_len = static_cast(data_list[data_idx].size() - data_header_size); - //tileX, tileY, levelX, levelY // pixel_data_size(int) - memcpy(&data_list[data_idx][0], &x_tile, sizeof(int)); - memcpy(&data_list[data_idx][4], &y_tile, sizeof(int)); - memcpy(&data_list[data_idx][8], &level_image->level_x, sizeof(int)); - memcpy(&data_list[data_idx][12], &level_image->level_y, sizeof(int)); - memcpy(&data_list[data_idx][16], &data_len, sizeof(int)); - - swap4(reinterpret_cast(&data_list[data_idx][0])); - swap4(reinterpret_cast(&data_list[data_idx][4])); - swap4(reinterpret_cast(&data_list[data_idx][8])); - swap4(reinterpret_cast(&data_list[data_idx][12])); - swap4(reinterpret_cast(&data_list[data_idx][16])); - -#if TINYEXR_HAS_CXX11 && (TINYEXR_USE_THREAD > 0) - } -})); - } - - for (auto &t : workers) { - t.join(); - } -#else - } // omp parallel -#endif - - if (invalid_data) { - if (err) { - (*err) += "Failed to encode tile data.\n"; - } - return TINYEXR_ERROR_INVALID_DATA; - } - return TINYEXR_SUCCESS; -} - -static int NumScanlines(int compression_type) { - int num_scanlines = 1; - if (compression_type == TINYEXR_COMPRESSIONTYPE_ZIP) { - num_scanlines = 16; - } else if (compression_type == TINYEXR_COMPRESSIONTYPE_PIZ) { - num_scanlines = 32; - } else if (compression_type == TINYEXR_COMPRESSIONTYPE_ZFP) { - num_scanlines = 16; - } - return num_scanlines; -} - -static int EncodeChunk(const EXRImage* exr_image, const EXRHeader* exr_header, - const std::vector& channels, - int num_blocks, - tinyexr_uint64 chunk_offset, // starting offset of current chunk - bool is_multipart, - OffsetData& offset_data, // output block offsets, must be initialized - std::vector >& data_list, // output - tinyexr_uint64& total_size, // output: ending offset of current chunk - std::string* err) { - int num_scanlines = NumScanlines(exr_header->compression_type); - - data_list.resize(num_blocks); - - std::vector channel_offset_list( - static_cast(exr_header->num_channels)); - - int pixel_data_size = 0; - { - size_t channel_offset = 0; - for (size_t c = 0; c < static_cast(exr_header->num_channels); c++) { - channel_offset_list[c] = channel_offset; - if (channels[c].requested_pixel_type == TINYEXR_PIXELTYPE_HALF) { - pixel_data_size += sizeof(unsigned short); - channel_offset += sizeof(unsigned short); - } else if (channels[c].requested_pixel_type == - TINYEXR_PIXELTYPE_FLOAT) { - pixel_data_size += sizeof(float); - channel_offset += sizeof(float); - } else if (channels[c].requested_pixel_type == TINYEXR_PIXELTYPE_UINT) { - pixel_data_size += sizeof(unsigned int); - channel_offset += sizeof(unsigned int); - } else { - assert(0); - } - } - } - - const void* compression_param = 0; -#if TINYEXR_USE_ZFP - tinyexr::ZFPCompressionParam zfp_compression_param; - - // Use ZFP compression parameter from custom attributes(if such a parameter - // exists) - { - std::string e; - bool ret = tinyexr::FindZFPCompressionParam( - &zfp_compression_param, exr_header->custom_attributes, - exr_header->num_custom_attributes, &e); - - if (!ret) { - // Use predefined compression parameter. - zfp_compression_param.type = 0; - zfp_compression_param.rate = 2; - } - compression_param = &zfp_compression_param; - } -#endif - - tinyexr_uint64 offset = chunk_offset; - tinyexr_uint64 doffset = is_multipart ? 4u : 0u; - - if (exr_image->tiles) { - const EXRImage* level_image = exr_image; - size_t block_idx = 0; - tinyexr::tinyexr_uint64 block_data_size = 0; - int num_levels = (exr_header->tile_level_mode != TINYEXR_TILE_RIPMAP_LEVELS) ? - offset_data.num_x_levels : (offset_data.num_x_levels * offset_data.num_y_levels); - for (int level_index = 0; level_index < num_levels; ++level_index) { - if (!level_image) { - if (err) { - (*err) += "Invalid number of tiled levels for EncodeChunk\n"; - } - return TINYEXR_ERROR_INVALID_DATA; - } - - int level_index_from_image = LevelIndex(level_image->level_x, level_image->level_y, - exr_header->tile_level_mode, offset_data.num_x_levels); - if (level_index_from_image != level_index) { - if (err) { - (*err) += "Incorrect level ordering in tiled image\n"; - } - return TINYEXR_ERROR_INVALID_DATA; - } - int num_y_tiles = (int)offset_data.offsets[level_index].size(); - assert(num_y_tiles); - int num_x_tiles = (int)offset_data.offsets[level_index][0].size(); - assert(num_x_tiles); - - std::string e; - int ret = EncodeTiledLevel(level_image, - exr_header, - channels, - data_list, - block_idx, - num_x_tiles, - num_y_tiles, - channel_offset_list, - pixel_data_size, - compression_param, - &e); - if (ret != TINYEXR_SUCCESS) { - if (!e.empty() && err) { - (*err) += e; - } - return ret; - } - - for (size_t j = 0; j < static_cast(num_y_tiles); ++j) - for (size_t i = 0; i < static_cast(num_x_tiles); ++i) { - offset_data.offsets[level_index][j][i] = offset; - swap8(reinterpret_cast(&offset_data.offsets[level_index][j][i])); - offset += data_list[block_idx].size() + doffset; - block_data_size += data_list[block_idx].size(); - ++block_idx; - } - level_image = level_image->next_level; - } - assert(static_cast(block_idx) == num_blocks); - total_size = offset; - } else { // scanlines - std::vector& offsets = offset_data.offsets[0][0]; - -#if TINYEXR_HAS_CXX11 && (TINYEXR_USE_THREAD > 0) - std::atomic invalid_data(false); - std::vector workers; - std::atomic block_count(0); - - int num_threads = std::min(std::max(1, int(std::thread::hardware_concurrency())), num_blocks); - - for (int t = 0; t < num_threads; t++) { - workers.emplace_back(std::thread([&]() { - int i = 0; - while ((i = block_count++) < num_blocks) { - -#else - bool invalid_data(false); -#if TINYEXR_USE_OPENMP -#pragma omp parallel for -#endif - for (int i = 0; i < num_blocks; i++) { - -#endif - int start_y = num_scanlines * i; - int end_Y = (std::min)(num_scanlines * (i + 1), exr_image->height); - int num_lines = end_Y - start_y; - - const unsigned char* const* images = - static_cast(exr_image->images); - - data_list[i].resize(2*sizeof(int)); - size_t data_header_size = data_list[i].size(); - - bool ret = EncodePixelData(data_list[i], - images, - exr_header->compression_type, - 0, // increasing y - exr_image->width, - exr_image->height, - exr_image->width, - start_y, - num_lines, - pixel_data_size, - channels, - channel_offset_list, - compression_param); - if (!ret) { - invalid_data = true; - continue; // "break" cannot be used with OpenMP - } - assert(data_list[i].size() > data_header_size); - int data_len = static_cast(data_list[i].size() - data_header_size); - memcpy(&data_list[i][0], &start_y, sizeof(int)); - memcpy(&data_list[i][4], &data_len, sizeof(int)); - - swap4(reinterpret_cast(&data_list[i][0])); - swap4(reinterpret_cast(&data_list[i][4])); -#if TINYEXR_HAS_CXX11 && (TINYEXR_USE_THREAD > 0) - } - })); - } - - for (auto &t : workers) { - t.join(); - } -#else - } // omp parallel -#endif - - if (invalid_data) { - if (err) { - (*err) += "Failed to encode scanline data.\n"; - } - return TINYEXR_ERROR_INVALID_DATA; - } - - for (size_t i = 0; i < static_cast(num_blocks); i++) { - offsets[i] = offset; - tinyexr::swap8(reinterpret_cast(&offsets[i])); - offset += data_list[i].size() + doffset; - } - - total_size = static_cast(offset); - } - return TINYEXR_SUCCESS; -} - -// can save a single or multi-part image (no deep* formats) -static size_t SaveEXRNPartImageToMemory(const EXRImage* exr_images, - const EXRHeader** exr_headers, - unsigned int num_parts, - unsigned char** memory_out, const char** err) { - if (exr_images == NULL || exr_headers == NULL || num_parts == 0 || - memory_out == NULL) { - SetErrorMessage("Invalid argument for SaveEXRNPartImageToMemory", - err); - return 0; - } - { - for (unsigned int i = 0; i < num_parts; ++i) { - if (exr_headers[i]->compression_type < 0) { - SetErrorMessage("Invalid argument for SaveEXRNPartImageToMemory", - err); - return 0; - } -#if !TINYEXR_USE_PIZ - if (exr_headers[i]->compression_type == TINYEXR_COMPRESSIONTYPE_PIZ) { - SetErrorMessage("PIZ compression is not supported in this build", - err); - return 0; - } -#endif -#if !TINYEXR_USE_ZFP - if (exr_headers[i]->compression_type == TINYEXR_COMPRESSIONTYPE_ZFP) { - SetErrorMessage("ZFP compression is not supported in this build", - err); - return 0; - } -#else - for (int c = 0; c < exr_header->num_channels; ++c) { - if (exr_headers[i]->requested_pixel_types[c] != TINYEXR_PIXELTYPE_FLOAT) { - SetErrorMessage("Pixel type must be FLOAT for ZFP compression", - err); - return 0; - } - } -#endif - } - } - - std::vector memory; - - // Header - { - const char header[] = { 0x76, 0x2f, 0x31, 0x01 }; - memory.insert(memory.end(), header, header + 4); - } - - // Version - // using value from the first header - int long_name = exr_headers[0]->long_name; - { - char marker[] = { 2, 0, 0, 0 }; - /* @todo - if (exr_header->non_image) { - marker[1] |= 0x8; - } - */ - // tiled - if (num_parts == 1 && exr_images[0].tiles) { - marker[1] |= 0x2; - } - // long_name - if (long_name) { - marker[1] |= 0x4; - } - // multipart - if (num_parts > 1) { - marker[1] |= 0x10; - } - memory.insert(memory.end(), marker, marker + 4); - } - - int total_chunk_count = 0; - std::vector chunk_count(num_parts); - std::vector offset_data(num_parts); - for (unsigned int i = 0; i < num_parts; ++i) { - if (!exr_images[i].tiles) { - int num_scanlines = NumScanlines(exr_headers[i]->compression_type); - chunk_count[i] = - (exr_images[i].height + num_scanlines - 1) / num_scanlines; - InitSingleResolutionOffsets(offset_data[i], chunk_count[i]); - total_chunk_count += chunk_count[i]; - } else { - { - std::vector num_x_tiles, num_y_tiles; - PrecalculateTileInfo(num_x_tiles, num_y_tiles, exr_headers[i]); - chunk_count[i] = - InitTileOffsets(offset_data[i], exr_headers[i], num_x_tiles, num_y_tiles); - total_chunk_count += chunk_count[i]; - } - } - } - // Write attributes to memory buffer. - std::vector< std::vector > channels(num_parts); - { - std::set partnames; - for (unsigned int i = 0; i < num_parts; ++i) { - //channels - { - std::vector data; - - for (int c = 0; c < exr_headers[i]->num_channels; c++) { - tinyexr::ChannelInfo info; - info.p_linear = 0; - info.pixel_type = exr_headers[i]->pixel_types[c]; - info.requested_pixel_type = exr_headers[i]->requested_pixel_types[c]; - info.x_sampling = 1; - info.y_sampling = 1; - info.name = std::string(exr_headers[i]->channels[c].name); - channels[i].push_back(info); - } - - tinyexr::WriteChannelInfo(data, channels[i]); - - tinyexr::WriteAttributeToMemory(&memory, "channels", "chlist", &data.at(0), - static_cast(data.size())); - } - - { - int comp = exr_headers[i]->compression_type; - swap4(&comp); - WriteAttributeToMemory( - &memory, "compression", "compression", - reinterpret_cast(&comp), 1); - } - - { - int data[4] = { 0, 0, exr_images[i].width - 1, exr_images[i].height - 1 }; - swap4(&data[0]); - swap4(&data[1]); - swap4(&data[2]); - swap4(&data[3]); - WriteAttributeToMemory( - &memory, "dataWindow", "box2i", - reinterpret_cast(data), sizeof(int) * 4); - - int data0[4] = { 0, 0, exr_images[0].width - 1, exr_images[0].height - 1 }; - swap4(&data0[0]); - swap4(&data0[1]); - swap4(&data0[2]); - swap4(&data0[3]); - // Note: must be the same across parts (currently, using value from the first header) - WriteAttributeToMemory( - &memory, "displayWindow", "box2i", - reinterpret_cast(data0), sizeof(int) * 4); - } - - { - unsigned char line_order = 0; // @fixme { read line_order from EXRHeader } - WriteAttributeToMemory(&memory, "lineOrder", "lineOrder", - &line_order, 1); - } - - { - // Note: must be the same across parts - float aspectRatio = 1.0f; - swap4(&aspectRatio); - WriteAttributeToMemory( - &memory, "pixelAspectRatio", "float", - reinterpret_cast(&aspectRatio), sizeof(float)); - } - - { - float center[2] = { 0.0f, 0.0f }; - swap4(¢er[0]); - swap4(¢er[1]); - WriteAttributeToMemory( - &memory, "screenWindowCenter", "v2f", - reinterpret_cast(center), 2 * sizeof(float)); - } - - { - float w = 1.0f; - swap4(&w); - WriteAttributeToMemory(&memory, "screenWindowWidth", "float", - reinterpret_cast(&w), - sizeof(float)); - } - - if (exr_images[i].tiles) { - unsigned char tile_mode = static_cast(exr_headers[i]->tile_level_mode & 0x3); - if (exr_headers[i]->tile_rounding_mode) tile_mode |= (1u << 4u); - //unsigned char data[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - unsigned int datai[3] = { 0, 0, 0 }; - unsigned char* data = reinterpret_cast(&datai[0]); - datai[0] = static_cast(exr_headers[i]->tile_size_x); - datai[1] = static_cast(exr_headers[i]->tile_size_y); - data[8] = tile_mode; - swap4(reinterpret_cast(&data[0])); - swap4(reinterpret_cast(&data[4])); - WriteAttributeToMemory( - &memory, "tiles", "tiledesc", - reinterpret_cast(data), 9); - } - - // must be present for multi-part files - according to spec. - if (num_parts > 1) { - // name - { - size_t len = 0; - if ((len = strlen(exr_headers[i]->name)) > 0) { - partnames.insert(std::string(exr_headers[i]->name)); - if (partnames.size() != i + 1) { - SetErrorMessage("'name' attributes must be unique for a multi-part file", err); - return 0; - } - WriteAttributeToMemory( - &memory, "name", "string", - reinterpret_cast(exr_headers[i]->name), - static_cast(len)); - } else { - SetErrorMessage("Invalid 'name' attribute for a multi-part file", err); - return 0; - } - } - // type - { - const char* type = "scanlineimage"; - if (exr_images[i].tiles) type = "tiledimage"; - WriteAttributeToMemory( - &memory, "type", "string", - reinterpret_cast(type), - static_cast(strlen(type))); - } - // chunkCount - { - WriteAttributeToMemory( - &memory, "chunkCount", "int", - reinterpret_cast(&chunk_count[i]), - 4); - } - } - - // Custom attributes - if (exr_headers[i]->num_custom_attributes > 0) { - for (int j = 0; j < exr_headers[i]->num_custom_attributes; j++) { - tinyexr::WriteAttributeToMemory( - &memory, exr_headers[i]->custom_attributes[j].name, - exr_headers[i]->custom_attributes[j].type, - reinterpret_cast( - exr_headers[i]->custom_attributes[j].value), - exr_headers[i]->custom_attributes[j].size); - } - } - - { // end of header - memory.push_back(0); - } - } - } - if (num_parts > 1) { - // end of header list - memory.push_back(0); - } - - tinyexr_uint64 chunk_offset = memory.size() + size_t(total_chunk_count) * sizeof(tinyexr_uint64); - - tinyexr_uint64 total_size = 0; - std::vector< std::vector< std::vector > > data_lists(num_parts); - for (unsigned int i = 0; i < num_parts; ++i) { - std::string e; - int ret = EncodeChunk(&exr_images[i], exr_headers[i], - channels[i], - chunk_count[i], - // starting offset of current chunk after part-number - chunk_offset, - num_parts > 1, - offset_data[i], // output: block offsets, must be initialized - data_lists[i], // output - total_size, // output - &e); - if (ret != TINYEXR_SUCCESS) { - if (!e.empty()) { - tinyexr::SetErrorMessage(e, err); - } - return 0; - } - chunk_offset = total_size; - } - - // Allocating required memory - if (total_size == 0) { // something went wrong - tinyexr::SetErrorMessage("Output memory size is zero", err); - return 0; - } - (*memory_out) = static_cast(malloc(total_size)); - - // Writing header - memcpy((*memory_out), &memory[0], memory.size()); - unsigned char* memory_ptr = *memory_out + memory.size(); - size_t sum = memory.size(); - - // Writing offset data for chunks - for (unsigned int i = 0; i < num_parts; ++i) { - if (exr_images[i].tiles) { - const EXRImage* level_image = &exr_images[i]; - int num_levels = (exr_headers[i]->tile_level_mode != TINYEXR_TILE_RIPMAP_LEVELS) ? - offset_data[i].num_x_levels : (offset_data[i].num_x_levels * offset_data[i].num_y_levels); - for (int level_index = 0; level_index < num_levels; ++level_index) { - for (size_t j = 0; j < offset_data[i].offsets[level_index].size(); ++j) { - size_t num_bytes = sizeof(tinyexr_uint64) * offset_data[i].offsets[level_index][j].size(); - sum += num_bytes; - assert(sum <= total_size); - memcpy(memory_ptr, - reinterpret_cast(&offset_data[i].offsets[level_index][j][0]), - num_bytes); - memory_ptr += num_bytes; - } - level_image = level_image->next_level; - } - } else { - size_t num_bytes = sizeof(tinyexr::tinyexr_uint64) * static_cast(chunk_count[i]); - sum += num_bytes; - assert(sum <= total_size); - std::vector& offsets = offset_data[i].offsets[0][0]; - memcpy(memory_ptr, reinterpret_cast(&offsets[0]), num_bytes); - memory_ptr += num_bytes; - } - } - - // Writing chunk data - for (unsigned int i = 0; i < num_parts; ++i) { - for (size_t j = 0; j < static_cast(chunk_count[i]); ++j) { - if (num_parts > 1) { - sum += 4; - assert(sum <= total_size); - unsigned int part_number = i; - swap4(&part_number); - memcpy(memory_ptr, &part_number, 4); - memory_ptr += 4; - } - sum += data_lists[i][j].size(); - assert(sum <= total_size); - memcpy(memory_ptr, &data_lists[i][j][0], data_lists[i][j].size()); - memory_ptr += data_lists[i][j].size(); - } - } - assert(sum == total_size); - return total_size; // OK -} - -} // tinyexr - -size_t SaveEXRImageToMemory(const EXRImage* exr_image, - const EXRHeader* exr_header, - unsigned char** memory_out, const char** err) { - return tinyexr::SaveEXRNPartImageToMemory(exr_image, &exr_header, 1, memory_out, err); -} - -int SaveEXRImageToFile(const EXRImage *exr_image, const EXRHeader *exr_header, - const char *filename, const char **err) { - if (exr_image == NULL || filename == NULL || - exr_header->compression_type < 0) { - tinyexr::SetErrorMessage("Invalid argument for SaveEXRImageToFile", err); - return TINYEXR_ERROR_INVALID_ARGUMENT; - } - -#if !TINYEXR_USE_PIZ - if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_PIZ) { - tinyexr::SetErrorMessage("PIZ compression is not supported in this build", - err); - return TINYEXR_ERROR_UNSUPPORTED_FEATURE; - } -#endif - -#if !TINYEXR_USE_ZFP - if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_ZFP) { - tinyexr::SetErrorMessage("ZFP compression is not supported in this build", - err); - return TINYEXR_ERROR_UNSUPPORTED_FEATURE; - } -#endif - - FILE *fp = NULL; -#ifdef _WIN32 -#if defined(_MSC_VER) || defined(__MINGW32__) // MSVC, MinGW gcc or clang - errno_t errcode = - _wfopen_s(&fp, tinyexr::UTF8ToWchar(filename).c_str(), L"wb"); - if (errcode != 0) { - tinyexr::SetErrorMessage("Cannot write a file: " + std::string(filename), - err); - return TINYEXR_ERROR_CANT_WRITE_FILE; - } -#else - // Unknown compiler - fp = fopen(filename, "wb"); -#endif -#else - fp = fopen(filename, "wb"); -#endif - if (!fp) { - tinyexr::SetErrorMessage("Cannot write a file: " + std::string(filename), - err); - return TINYEXR_ERROR_CANT_WRITE_FILE; - } - - unsigned char *mem = NULL; - size_t mem_size = SaveEXRImageToMemory(exr_image, exr_header, &mem, err); - if (mem_size == 0) { - return TINYEXR_ERROR_SERIALZATION_FAILED; - } - - size_t written_size = 0; - if ((mem_size > 0) && mem) { - written_size = fwrite(mem, 1, mem_size, fp); - } - free(mem); - - fclose(fp); - - if (written_size != mem_size) { - tinyexr::SetErrorMessage("Cannot write a file", err); - return TINYEXR_ERROR_CANT_WRITE_FILE; - } - - return TINYEXR_SUCCESS; -} - -size_t SaveEXRMultipartImageToMemory(const EXRImage* exr_images, - const EXRHeader** exr_headers, - unsigned int num_parts, - unsigned char** memory_out, const char** err) { - if (exr_images == NULL || exr_headers == NULL || num_parts < 2 || - memory_out == NULL) { - tinyexr::SetErrorMessage("Invalid argument for SaveEXRNPartImageToMemory", - err); - return 0; - } - return tinyexr::SaveEXRNPartImageToMemory(exr_images, exr_headers, num_parts, memory_out, err); -} - -int SaveEXRMultipartImageToFile(const EXRImage* exr_images, - const EXRHeader** exr_headers, - unsigned int num_parts, - const char* filename, - const char** err) { - if (exr_images == NULL || exr_headers == NULL || num_parts < 2) { - tinyexr::SetErrorMessage("Invalid argument for SaveEXRMultipartImageToFile", - err); - return TINYEXR_ERROR_INVALID_ARGUMENT; - } - - FILE *fp = NULL; -#ifdef _WIN32 -#if defined(_MSC_VER) || defined(__MINGW32__) // MSVC, MinGW gcc or clang - errno_t errcode = - _wfopen_s(&fp, tinyexr::UTF8ToWchar(filename).c_str(), L"wb"); - if (errcode != 0) { - tinyexr::SetErrorMessage("Cannot write a file: " + std::string(filename), - err); - return TINYEXR_ERROR_CANT_WRITE_FILE; - } -#else - // Unknown compiler - fp = fopen(filename, "wb"); -#endif -#else - fp = fopen(filename, "wb"); -#endif - if (!fp) { - tinyexr::SetErrorMessage("Cannot write a file: " + std::string(filename), - err); - return TINYEXR_ERROR_CANT_WRITE_FILE; - } - - unsigned char *mem = NULL; - size_t mem_size = SaveEXRMultipartImageToMemory(exr_images, exr_headers, num_parts, &mem, err); - if (mem_size == 0) { - return TINYEXR_ERROR_SERIALZATION_FAILED; - } - - size_t written_size = 0; - if ((mem_size > 0) && mem) { - written_size = fwrite(mem, 1, mem_size, fp); - } - free(mem); - - fclose(fp); - - if (written_size != mem_size) { - tinyexr::SetErrorMessage("Cannot write a file", err); - return TINYEXR_ERROR_CANT_WRITE_FILE; - } - - return TINYEXR_SUCCESS; -} - -int LoadDeepEXR(DeepImage *deep_image, const char *filename, const char **err) { - if (deep_image == NULL) { - tinyexr::SetErrorMessage("Invalid argument for LoadDeepEXR", err); - return TINYEXR_ERROR_INVALID_ARGUMENT; - } - -#ifdef _WIN32 - FILE *fp = NULL; -#if defined(_MSC_VER) || defined(__MINGW32__) // MSVC, MinGW gcc or clang - errno_t errcode = - _wfopen_s(&fp, tinyexr::UTF8ToWchar(filename).c_str(), L"rb"); - if (errcode != 0) { - tinyexr::SetErrorMessage("Cannot read a file " + std::string(filename), - err); - return TINYEXR_ERROR_CANT_OPEN_FILE; - } -#else - // Unknown compiler - fp = fopen(filename, "rb"); -#endif - if (!fp) { - tinyexr::SetErrorMessage("Cannot read a file " + std::string(filename), - err); - return TINYEXR_ERROR_CANT_OPEN_FILE; - } -#else - FILE *fp = fopen(filename, "rb"); - if (!fp) { - tinyexr::SetErrorMessage("Cannot read a file " + std::string(filename), - err); - return TINYEXR_ERROR_CANT_OPEN_FILE; - } -#endif - - size_t filesize; - // Compute size - fseek(fp, 0, SEEK_END); - filesize = static_cast(ftell(fp)); - fseek(fp, 0, SEEK_SET); - - if (filesize == 0) { - fclose(fp); - tinyexr::SetErrorMessage("File size is zero : " + std::string(filename), - err); - return TINYEXR_ERROR_INVALID_FILE; - } - - std::vector buf(filesize); // @todo { use mmap } - { - size_t ret; - ret = fread(&buf[0], 1, filesize, fp); - assert(ret == filesize); - (void)ret; - } - fclose(fp); - - const char *head = &buf[0]; - const char *marker = &buf[0]; - - // Header check. - { - const char header[] = {0x76, 0x2f, 0x31, 0x01}; - - if (memcmp(marker, header, 4) != 0) { - tinyexr::SetErrorMessage("Invalid magic number", err); - return TINYEXR_ERROR_INVALID_MAGIC_NUMBER; - } - marker += 4; - } - - // Version, scanline. - { - // ver 2.0, scanline, deep bit on(0x800) - // must be [2, 0, 0, 0] - if (marker[0] != 2 || marker[1] != 8 || marker[2] != 0 || marker[3] != 0) { - tinyexr::SetErrorMessage("Unsupported version or scanline", err); - return TINYEXR_ERROR_UNSUPPORTED_FORMAT; - } - - marker += 4; - } - - int dx = -1; - int dy = -1; - int dw = -1; - int dh = -1; - int num_scanline_blocks = 1; // 16 for ZIP compression. - int compression_type = -1; - int num_channels = -1; - std::vector channels; - - // Read attributes - size_t size = filesize - tinyexr::kEXRVersionSize; - for (;;) { - if (0 == size) { - return TINYEXR_ERROR_INVALID_DATA; - } else if (marker[0] == '\0') { - marker++; - size--; - break; - } - - std::string attr_name; - std::string attr_type; - std::vector data; - size_t marker_size; - if (!tinyexr::ReadAttribute(&attr_name, &attr_type, &data, &marker_size, - marker, size)) { - std::stringstream ss; - ss << "Failed to parse attribute\n"; - tinyexr::SetErrorMessage(ss.str(), err); - return TINYEXR_ERROR_INVALID_DATA; - } - marker += marker_size; - size -= marker_size; - - if (attr_name.compare("compression") == 0) { - compression_type = data[0]; - if (compression_type > TINYEXR_COMPRESSIONTYPE_PIZ) { - std::stringstream ss; - ss << "Unsupported compression type : " << compression_type; - tinyexr::SetErrorMessage(ss.str(), err); - return TINYEXR_ERROR_UNSUPPORTED_FORMAT; - } - - if (compression_type == TINYEXR_COMPRESSIONTYPE_ZIP) { - num_scanline_blocks = 16; - } - - } else if (attr_name.compare("channels") == 0) { - // name: zero-terminated string, from 1 to 255 bytes long - // pixel type: int, possible values are: UINT = 0 HALF = 1 FLOAT = 2 - // pLinear: unsigned char, possible values are 0 and 1 - // reserved: three chars, should be zero - // xSampling: int - // ySampling: int - - if (!tinyexr::ReadChannelInfo(channels, data)) { - tinyexr::SetErrorMessage("Failed to parse channel info", err); - return TINYEXR_ERROR_INVALID_DATA; - } - - num_channels = static_cast(channels.size()); - - if (num_channels < 1) { - tinyexr::SetErrorMessage("Invalid channels format", err); - return TINYEXR_ERROR_INVALID_DATA; - } - - } else if (attr_name.compare("dataWindow") == 0) { - memcpy(&dx, &data.at(0), sizeof(int)); - memcpy(&dy, &data.at(4), sizeof(int)); - memcpy(&dw, &data.at(8), sizeof(int)); - memcpy(&dh, &data.at(12), sizeof(int)); - tinyexr::swap4(&dx); - tinyexr::swap4(&dy); - tinyexr::swap4(&dw); - tinyexr::swap4(&dh); - - } else if (attr_name.compare("displayWindow") == 0) { - int x; - int y; - int w; - int h; - memcpy(&x, &data.at(0), sizeof(int)); - memcpy(&y, &data.at(4), sizeof(int)); - memcpy(&w, &data.at(8), sizeof(int)); - memcpy(&h, &data.at(12), sizeof(int)); - tinyexr::swap4(&x); - tinyexr::swap4(&y); - tinyexr::swap4(&w); - tinyexr::swap4(&h); - } - } - - assert(dx >= 0); - assert(dy >= 0); - assert(dw >= 0); - assert(dh >= 0); - assert(num_channels >= 1); - - int data_width = dw - dx + 1; - int data_height = dh - dy + 1; - - std::vector image( - static_cast(data_width * data_height * 4)); // 4 = RGBA - - // Read offset tables. - int num_blocks = data_height / num_scanline_blocks; - if (num_blocks * num_scanline_blocks < data_height) { - num_blocks++; - } - - std::vector offsets(static_cast(num_blocks)); - - for (size_t y = 0; y < static_cast(num_blocks); y++) { - tinyexr::tinyexr_int64 offset; - memcpy(&offset, marker, sizeof(tinyexr::tinyexr_int64)); - tinyexr::swap8(reinterpret_cast(&offset)); - marker += sizeof(tinyexr::tinyexr_int64); // = 8 - offsets[y] = offset; - } - -#if TINYEXR_USE_PIZ - if ((compression_type == TINYEXR_COMPRESSIONTYPE_NONE) || - (compression_type == TINYEXR_COMPRESSIONTYPE_RLE) || - (compression_type == TINYEXR_COMPRESSIONTYPE_ZIPS) || - (compression_type == TINYEXR_COMPRESSIONTYPE_ZIP) || - (compression_type == TINYEXR_COMPRESSIONTYPE_PIZ)) { -#else - if ((compression_type == TINYEXR_COMPRESSIONTYPE_NONE) || - (compression_type == TINYEXR_COMPRESSIONTYPE_RLE) || - (compression_type == TINYEXR_COMPRESSIONTYPE_ZIPS) || - (compression_type == TINYEXR_COMPRESSIONTYPE_ZIP)) { -#endif - // OK - } else { - tinyexr::SetErrorMessage("Unsupported compression format", err); - return TINYEXR_ERROR_UNSUPPORTED_FORMAT; - } - - deep_image->image = static_cast( - malloc(sizeof(float **) * static_cast(num_channels))); - for (int c = 0; c < num_channels; c++) { - deep_image->image[c] = static_cast( - malloc(sizeof(float *) * static_cast(data_height))); - for (int y = 0; y < data_height; y++) { - } - } - - deep_image->offset_table = static_cast( - malloc(sizeof(int *) * static_cast(data_height))); - for (int y = 0; y < data_height; y++) { - deep_image->offset_table[y] = static_cast( - malloc(sizeof(int) * static_cast(data_width))); - } - - for (size_t y = 0; y < static_cast(num_blocks); y++) { - const unsigned char *data_ptr = - reinterpret_cast(head + offsets[y]); - - // int: y coordinate - // int64: packed size of pixel offset table - // int64: packed size of sample data - // int64: unpacked size of sample data - // compressed pixel offset table - // compressed sample data - int line_no; - tinyexr::tinyexr_int64 packedOffsetTableSize; - tinyexr::tinyexr_int64 packedSampleDataSize; - tinyexr::tinyexr_int64 unpackedSampleDataSize; - memcpy(&line_no, data_ptr, sizeof(int)); - memcpy(&packedOffsetTableSize, data_ptr + 4, - sizeof(tinyexr::tinyexr_int64)); - memcpy(&packedSampleDataSize, data_ptr + 12, - sizeof(tinyexr::tinyexr_int64)); - memcpy(&unpackedSampleDataSize, data_ptr + 20, - sizeof(tinyexr::tinyexr_int64)); - - tinyexr::swap4(&line_no); - tinyexr::swap8( - reinterpret_cast(&packedOffsetTableSize)); - tinyexr::swap8( - reinterpret_cast(&packedSampleDataSize)); - tinyexr::swap8( - reinterpret_cast(&unpackedSampleDataSize)); - - std::vector pixelOffsetTable(static_cast(data_width)); - - // decode pixel offset table. - { - unsigned long dstLen = - static_cast(pixelOffsetTable.size() * sizeof(int)); - if (!tinyexr::DecompressZip( - reinterpret_cast(&pixelOffsetTable.at(0)), - &dstLen, data_ptr + 28, - static_cast(packedOffsetTableSize))) { - return false; - } - - assert(dstLen == pixelOffsetTable.size() * sizeof(int)); - for (size_t i = 0; i < static_cast(data_width); i++) { - deep_image->offset_table[y][i] = pixelOffsetTable[i]; - } - } - - std::vector sample_data( - static_cast(unpackedSampleDataSize)); - - // decode sample data. - { - unsigned long dstLen = static_cast(unpackedSampleDataSize); - if (dstLen) { - if (!tinyexr::DecompressZip( - reinterpret_cast(&sample_data.at(0)), &dstLen, - data_ptr + 28 + packedOffsetTableSize, - static_cast(packedSampleDataSize))) { - return false; - } - assert(dstLen == static_cast(unpackedSampleDataSize)); - } - } - - // decode sample - int sampleSize = -1; - std::vector channel_offset_list(static_cast(num_channels)); - { - int channel_offset = 0; - for (size_t i = 0; i < static_cast(num_channels); i++) { - channel_offset_list[i] = channel_offset; - if (channels[i].pixel_type == TINYEXR_PIXELTYPE_UINT) { // UINT - channel_offset += 4; - } else if (channels[i].pixel_type == TINYEXR_PIXELTYPE_HALF) { // half - channel_offset += 2; - } else if (channels[i].pixel_type == - TINYEXR_PIXELTYPE_FLOAT) { // float - channel_offset += 4; - } else { - assert(0); - } - } - sampleSize = channel_offset; - } - assert(sampleSize >= 2); - - assert(static_cast( - pixelOffsetTable[static_cast(data_width - 1)] * - sampleSize) == sample_data.size()); - int samples_per_line = static_cast(sample_data.size()) / sampleSize; - - // - // Alloc memory - // - - // - // pixel data is stored as image[channels][pixel_samples] - // - { - tinyexr::tinyexr_uint64 data_offset = 0; - for (size_t c = 0; c < static_cast(num_channels); c++) { - deep_image->image[c][y] = static_cast( - malloc(sizeof(float) * static_cast(samples_per_line))); - - if (channels[c].pixel_type == 0) { // UINT - for (size_t x = 0; x < static_cast(samples_per_line); x++) { - unsigned int ui; - unsigned int *src_ptr = reinterpret_cast( - &sample_data.at(size_t(data_offset) + x * sizeof(int))); - tinyexr::cpy4(&ui, src_ptr); - deep_image->image[c][y][x] = static_cast(ui); // @fixme - } - data_offset += - sizeof(unsigned int) * static_cast(samples_per_line); - } else if (channels[c].pixel_type == 1) { // half - for (size_t x = 0; x < static_cast(samples_per_line); x++) { - tinyexr::FP16 f16; - const unsigned short *src_ptr = reinterpret_cast( - &sample_data.at(size_t(data_offset) + x * sizeof(short))); - tinyexr::cpy2(&(f16.u), src_ptr); - tinyexr::FP32 f32 = half_to_float(f16); - deep_image->image[c][y][x] = f32.f; - } - data_offset += sizeof(short) * static_cast(samples_per_line); - } else { // float - for (size_t x = 0; x < static_cast(samples_per_line); x++) { - float f; - const float *src_ptr = reinterpret_cast( - &sample_data.at(size_t(data_offset) + x * sizeof(float))); - tinyexr::cpy4(&f, src_ptr); - deep_image->image[c][y][x] = f; - } - data_offset += sizeof(float) * static_cast(samples_per_line); - } - } - } - } // y - - deep_image->width = data_width; - deep_image->height = data_height; - - deep_image->channel_names = static_cast( - malloc(sizeof(const char *) * static_cast(num_channels))); - for (size_t c = 0; c < static_cast(num_channels); c++) { -#ifdef _WIN32 - deep_image->channel_names[c] = _strdup(channels[c].name.c_str()); -#else - deep_image->channel_names[c] = strdup(channels[c].name.c_str()); -#endif - } - deep_image->num_channels = num_channels; - - return TINYEXR_SUCCESS; -} - -void InitEXRImage(EXRImage *exr_image) { - if (exr_image == NULL) { - return; - } - - exr_image->width = 0; - exr_image->height = 0; - exr_image->num_channels = 0; - - exr_image->images = NULL; - exr_image->tiles = NULL; - exr_image->next_level = NULL; - exr_image->level_x = 0; - exr_image->level_y = 0; - - exr_image->num_tiles = 0; -} - -void FreeEXRErrorMessage(const char *msg) { - if (msg) { - free(reinterpret_cast(const_cast(msg))); - } - return; -} - -void InitEXRHeader(EXRHeader *exr_header) { - if (exr_header == NULL) { - return; - } - - memset(exr_header, 0, sizeof(EXRHeader)); -} - -int FreeEXRHeader(EXRHeader *exr_header) { - if (exr_header == NULL) { - return TINYEXR_ERROR_INVALID_ARGUMENT; - } - - if (exr_header->channels) { - free(exr_header->channels); - } - - if (exr_header->pixel_types) { - free(exr_header->pixel_types); - } - - if (exr_header->requested_pixel_types) { - free(exr_header->requested_pixel_types); - } - - for (int i = 0; i < exr_header->num_custom_attributes; i++) { - if (exr_header->custom_attributes[i].value) { - free(exr_header->custom_attributes[i].value); - } - } - - if (exr_header->custom_attributes) { - free(exr_header->custom_attributes); - } - - EXRSetNameAttr(exr_header, NULL); - - return TINYEXR_SUCCESS; -} - -void EXRSetNameAttr(EXRHeader* exr_header, const char* name) { - if (exr_header == NULL) { - return; - } - memset(exr_header->name, 0, 256); - if (name != NULL) { - size_t len = std::min(strlen(name), (size_t)255); - if (len) { - memcpy(exr_header->name, name, len); - } - } -} - -int EXRNumLevels(const EXRImage* exr_image) { - if (exr_image == NULL) return 0; - if(exr_image->images) return 1; // scanlines - int levels = 1; - const EXRImage* level_image = exr_image; - while((level_image = level_image->next_level)) ++levels; - return levels; -} - -int FreeEXRImage(EXRImage *exr_image) { - if (exr_image == NULL) { - return TINYEXR_ERROR_INVALID_ARGUMENT; - } - - if (exr_image->next_level) { - FreeEXRImage(exr_image->next_level); - delete exr_image->next_level; - } - - for (int i = 0; i < exr_image->num_channels; i++) { - if (exr_image->images && exr_image->images[i]) { - free(exr_image->images[i]); - } - } - - if (exr_image->images) { - free(exr_image->images); - } - - if (exr_image->tiles) { - for (int tid = 0; tid < exr_image->num_tiles; tid++) { - for (int i = 0; i < exr_image->num_channels; i++) { - if (exr_image->tiles[tid].images && exr_image->tiles[tid].images[i]) { - free(exr_image->tiles[tid].images[i]); - } - } - if (exr_image->tiles[tid].images) { - free(exr_image->tiles[tid].images); - } - } - free(exr_image->tiles); - } - - return TINYEXR_SUCCESS; -} - -int ParseEXRHeaderFromFile(EXRHeader *exr_header, const EXRVersion *exr_version, - const char *filename, const char **err) { - if (exr_header == NULL || exr_version == NULL || filename == NULL) { - tinyexr::SetErrorMessage("Invalid argument for ParseEXRHeaderFromFile", - err); - return TINYEXR_ERROR_INVALID_ARGUMENT; - } - - FILE *fp = NULL; -#ifdef _WIN32 -#if defined(_MSC_VER) || defined(__MINGW32__) // MSVC, MinGW gcc or clang - errno_t errcode = - _wfopen_s(&fp, tinyexr::UTF8ToWchar(filename).c_str(), L"rb"); - if (errcode != 0) { - tinyexr::SetErrorMessage("Cannot read file " + std::string(filename), err); - return TINYEXR_ERROR_INVALID_FILE; - } -#else - // Unknown compiler - fp = fopen(filename, "rb"); -#endif -#else - fp = fopen(filename, "rb"); -#endif - if (!fp) { - tinyexr::SetErrorMessage("Cannot read file " + std::string(filename), err); - return TINYEXR_ERROR_CANT_OPEN_FILE; - } - - size_t filesize; - // Compute size - fseek(fp, 0, SEEK_END); - filesize = static_cast(ftell(fp)); - fseek(fp, 0, SEEK_SET); - - std::vector buf(filesize); // @todo { use mmap } - { - size_t ret; - ret = fread(&buf[0], 1, filesize, fp); - assert(ret == filesize); - fclose(fp); - - if (ret != filesize) { - tinyexr::SetErrorMessage("fread() error on " + std::string(filename), - err); - return TINYEXR_ERROR_INVALID_FILE; - } - } - - return ParseEXRHeaderFromMemory(exr_header, exr_version, &buf.at(0), filesize, - err); -} - -int ParseEXRMultipartHeaderFromMemory(EXRHeader ***exr_headers, - int *num_headers, - const EXRVersion *exr_version, - const unsigned char *memory, size_t size, - const char **err) { - if (memory == NULL || exr_headers == NULL || num_headers == NULL || - exr_version == NULL) { - // Invalid argument - tinyexr::SetErrorMessage( - "Invalid argument for ParseEXRMultipartHeaderFromMemory", err); - return TINYEXR_ERROR_INVALID_ARGUMENT; - } - - if (size < tinyexr::kEXRVersionSize) { - tinyexr::SetErrorMessage("Data size too short", err); - return TINYEXR_ERROR_INVALID_DATA; - } - - const unsigned char *marker = memory + tinyexr::kEXRVersionSize; - size_t marker_size = size - tinyexr::kEXRVersionSize; - - std::vector infos; - - for (;;) { - tinyexr::HeaderInfo info; - info.clear(); - - std::string err_str; - bool empty_header = false; - int ret = ParseEXRHeader(&info, &empty_header, exr_version, &err_str, - marker, marker_size); - - if (ret != TINYEXR_SUCCESS) { - tinyexr::SetErrorMessage(err_str, err); - return ret; - } - - if (empty_header) { - marker += 1; // skip '\0' - break; - } - - // `chunkCount` must exist in the header. - if (info.chunk_count == 0) { - tinyexr::SetErrorMessage( - "`chunkCount' attribute is not found in the header.", err); - return TINYEXR_ERROR_INVALID_DATA; - } - - infos.push_back(info); - - // move to next header. - marker += info.header_len; - size -= info.header_len; - } - - // allocate memory for EXRHeader and create array of EXRHeader pointers. - (*exr_headers) = - static_cast(malloc(sizeof(EXRHeader *) * infos.size())); - for (size_t i = 0; i < infos.size(); i++) { - EXRHeader *exr_header = static_cast(malloc(sizeof(EXRHeader))); - memset(exr_header, 0, sizeof(EXRHeader)); - - ConvertHeader(exr_header, infos[i]); - - exr_header->multipart = exr_version->multipart ? 1 : 0; - - (*exr_headers)[i] = exr_header; - } - - (*num_headers) = static_cast(infos.size()); - - return TINYEXR_SUCCESS; -} - -int ParseEXRMultipartHeaderFromFile(EXRHeader ***exr_headers, int *num_headers, - const EXRVersion *exr_version, - const char *filename, const char **err) { - if (exr_headers == NULL || num_headers == NULL || exr_version == NULL || - filename == NULL) { - tinyexr::SetErrorMessage( - "Invalid argument for ParseEXRMultipartHeaderFromFile()", err); - return TINYEXR_ERROR_INVALID_ARGUMENT; - } - - FILE *fp = NULL; -#ifdef _WIN32 -#if defined(_MSC_VER) || defined(__MINGW32__) // MSVC, MinGW gcc or clang - errno_t errcode = - _wfopen_s(&fp, tinyexr::UTF8ToWchar(filename).c_str(), L"rb"); - if (errcode != 0) { - tinyexr::SetErrorMessage("Cannot read file " + std::string(filename), err); - return TINYEXR_ERROR_INVALID_FILE; - } -#else - // Unknown compiler - fp = fopen(filename, "rb"); -#endif -#else - fp = fopen(filename, "rb"); -#endif - if (!fp) { - tinyexr::SetErrorMessage("Cannot read file " + std::string(filename), err); - return TINYEXR_ERROR_CANT_OPEN_FILE; - } - - size_t filesize; - // Compute size - fseek(fp, 0, SEEK_END); - filesize = static_cast(ftell(fp)); - fseek(fp, 0, SEEK_SET); - - std::vector buf(filesize); // @todo { use mmap } - { - size_t ret; - ret = fread(&buf[0], 1, filesize, fp); - assert(ret == filesize); - fclose(fp); - - if (ret != filesize) { - tinyexr::SetErrorMessage("`fread' error. file may be corrupted.", err); - return TINYEXR_ERROR_INVALID_FILE; - } - } - - return ParseEXRMultipartHeaderFromMemory( - exr_headers, num_headers, exr_version, &buf.at(0), filesize, err); -} - -int ParseEXRVersionFromMemory(EXRVersion *version, const unsigned char *memory, - size_t size) { - if (version == NULL || memory == NULL) { - return TINYEXR_ERROR_INVALID_ARGUMENT; - } - - if (size < tinyexr::kEXRVersionSize) { - return TINYEXR_ERROR_INVALID_DATA; - } - - const unsigned char *marker = memory; - - // Header check. - { - const char header[] = {0x76, 0x2f, 0x31, 0x01}; - - if (memcmp(marker, header, 4) != 0) { - return TINYEXR_ERROR_INVALID_MAGIC_NUMBER; - } - marker += 4; - } - - version->tiled = false; - version->long_name = false; - version->non_image = false; - version->multipart = false; - - // Parse version header. - { - // must be 2 - if (marker[0] != 2) { - return TINYEXR_ERROR_INVALID_EXR_VERSION; - } - - if (version == NULL) { - return TINYEXR_SUCCESS; // May OK - } - - version->version = 2; - - if (marker[1] & 0x2) { // 9th bit - version->tiled = true; - } - if (marker[1] & 0x4) { // 10th bit - version->long_name = true; - } - if (marker[1] & 0x8) { // 11th bit - version->non_image = true; // (deep image) - } - if (marker[1] & 0x10) { // 12th bit - version->multipart = true; - } - } - - return TINYEXR_SUCCESS; -} - -int ParseEXRVersionFromFile(EXRVersion *version, const char *filename) { - if (filename == NULL) { - return TINYEXR_ERROR_INVALID_ARGUMENT; - } - - FILE *fp = NULL; -#ifdef _WIN32 -#if defined(_MSC_VER) || defined(__MINGW32__) // MSVC, MinGW gcc or clang - errno_t err = _wfopen_s(&fp, tinyexr::UTF8ToWchar(filename).c_str(), L"rb"); - if (err != 0) { - // TODO(syoyo): return wfopen_s erro code - return TINYEXR_ERROR_CANT_OPEN_FILE; - } -#else - // Unknown compiler - fp = fopen(filename, "rb"); -#endif -#else - fp = fopen(filename, "rb"); -#endif - if (!fp) { - return TINYEXR_ERROR_CANT_OPEN_FILE; - } - - size_t file_size; - // Compute size - fseek(fp, 0, SEEK_END); - file_size = static_cast(ftell(fp)); - fseek(fp, 0, SEEK_SET); - - if (file_size < tinyexr::kEXRVersionSize) { - return TINYEXR_ERROR_INVALID_FILE; - } - - unsigned char buf[tinyexr::kEXRVersionSize]; - size_t ret = fread(&buf[0], 1, tinyexr::kEXRVersionSize, fp); - fclose(fp); - - if (ret != tinyexr::kEXRVersionSize) { - return TINYEXR_ERROR_INVALID_FILE; - } - - return ParseEXRVersionFromMemory(version, buf, tinyexr::kEXRVersionSize); -} - -int LoadEXRMultipartImageFromMemory(EXRImage *exr_images, - const EXRHeader **exr_headers, - unsigned int num_parts, - const unsigned char *memory, - const size_t size, const char **err) { - if (exr_images == NULL || exr_headers == NULL || num_parts == 0 || - memory == NULL || (size <= tinyexr::kEXRVersionSize)) { - tinyexr::SetErrorMessage( - "Invalid argument for LoadEXRMultipartImageFromMemory()", err); - return TINYEXR_ERROR_INVALID_ARGUMENT; - } - - // compute total header size. - size_t total_header_size = 0; - for (unsigned int i = 0; i < num_parts; i++) { - if (exr_headers[i]->header_len == 0) { - tinyexr::SetErrorMessage("EXRHeader variable is not initialized.", err); - return TINYEXR_ERROR_INVALID_ARGUMENT; - } - - total_header_size += exr_headers[i]->header_len; - } - - const char *marker = reinterpret_cast( - memory + total_header_size + 4 + - 4); // +8 for magic number and version header. - - marker += 1; // Skip empty header. - - // NOTE 1: - // In multipart image, There is 'part number' before chunk data. - // 4 byte : part number - // 4+ : chunk - // - // NOTE 2: - // EXR spec says 'part number' is 'unsigned long' but actually this is - // 'unsigned int(4 bytes)' in OpenEXR implementation... - // http://www.openexr.com/openexrfilelayout.pdf - - // Load chunk offset table. - std::vector chunk_offset_table_list; - chunk_offset_table_list.reserve(num_parts); - for (size_t i = 0; i < static_cast(num_parts); i++) { - chunk_offset_table_list.resize(chunk_offset_table_list.size() + 1); - tinyexr::OffsetData& offset_data = chunk_offset_table_list.back(); - if (!exr_headers[i]->tiled || exr_headers[i]->tile_level_mode == TINYEXR_TILE_ONE_LEVEL) { - tinyexr::InitSingleResolutionOffsets(offset_data, exr_headers[i]->chunk_count); - std::vector& offset_table = offset_data.offsets[0][0]; - - for (size_t c = 0; c < offset_table.size(); c++) { - tinyexr::tinyexr_uint64 offset; - memcpy(&offset, marker, 8); - tinyexr::swap8(&offset); - - if (offset >= size) { - tinyexr::SetErrorMessage("Invalid offset size in EXR header chunks.", - err); - return TINYEXR_ERROR_INVALID_DATA; - } - - offset_table[c] = offset + 4; // +4 to skip 'part number' - marker += 8; - } - } else { - { - std::vector num_x_tiles, num_y_tiles; - tinyexr::PrecalculateTileInfo(num_x_tiles, num_y_tiles, exr_headers[i]); - int num_blocks = InitTileOffsets(offset_data, exr_headers[i], num_x_tiles, num_y_tiles); - if (num_blocks != exr_headers[i]->chunk_count) { - tinyexr::SetErrorMessage("Invalid offset table size.", err); - return TINYEXR_ERROR_INVALID_DATA; - } - } - for (unsigned int l = 0; l < offset_data.offsets.size(); ++l) { - for (unsigned int dy = 0; dy < offset_data.offsets[l].size(); ++dy) { - for (unsigned int dx = 0; dx < offset_data.offsets[l][dy].size(); ++dx) { - tinyexr::tinyexr_uint64 offset; - memcpy(&offset, marker, sizeof(tinyexr::tinyexr_uint64)); - tinyexr::swap8(&offset); - if (offset >= size) { - tinyexr::SetErrorMessage("Invalid offset size in EXR header chunks.", - err); - return TINYEXR_ERROR_INVALID_DATA; - } - offset_data.offsets[l][dy][dx] = offset + 4; // +4 to skip 'part number' - marker += sizeof(tinyexr::tinyexr_uint64); // = 8 - } - } - } - } - } - - // Decode image. - for (size_t i = 0; i < static_cast(num_parts); i++) { - tinyexr::OffsetData &offset_data = chunk_offset_table_list[i]; - - // First check 'part number' is identitical to 'i' - for (unsigned int l = 0; l < offset_data.offsets.size(); ++l) - for (unsigned int dy = 0; dy < offset_data.offsets[l].size(); ++dy) - for (unsigned int dx = 0; dx < offset_data.offsets[l][dy].size(); ++dx) { - - const unsigned char *part_number_addr = - memory + offset_data.offsets[l][dy][dx] - 4; // -4 to move to 'part number' field. - unsigned int part_no; - memcpy(&part_no, part_number_addr, sizeof(unsigned int)); // 4 - tinyexr::swap4(&part_no); - - if (part_no != i) { - tinyexr::SetErrorMessage("Invalid `part number' in EXR header chunks.", - err); - return TINYEXR_ERROR_INVALID_DATA; - } - } - - std::string e; - int ret = tinyexr::DecodeChunk(&exr_images[i], exr_headers[i], offset_data, - memory, size, &e); - if (ret != TINYEXR_SUCCESS) { - if (!e.empty()) { - tinyexr::SetErrorMessage(e, err); - } - return ret; - } - } - - return TINYEXR_SUCCESS; -} - -int LoadEXRMultipartImageFromFile(EXRImage *exr_images, - const EXRHeader **exr_headers, - unsigned int num_parts, const char *filename, - const char **err) { - if (exr_images == NULL || exr_headers == NULL || num_parts == 0) { - tinyexr::SetErrorMessage( - "Invalid argument for LoadEXRMultipartImageFromFile", err); - return TINYEXR_ERROR_INVALID_ARGUMENT; - } - - FILE *fp = NULL; -#ifdef _WIN32 -#if defined(_MSC_VER) || defined(__MINGW32__) // MSVC, MinGW gcc or clang - errno_t errcode = - _wfopen_s(&fp, tinyexr::UTF8ToWchar(filename).c_str(), L"rb"); - if (errcode != 0) { - tinyexr::SetErrorMessage("Cannot read file " + std::string(filename), err); - return TINYEXR_ERROR_CANT_OPEN_FILE; - } -#else - // Unknown compiler - fp = fopen(filename, "rb"); -#endif -#else - fp = fopen(filename, "rb"); -#endif - if (!fp) { - tinyexr::SetErrorMessage("Cannot read file " + std::string(filename), err); - return TINYEXR_ERROR_CANT_OPEN_FILE; - } - - size_t filesize; - // Compute size - fseek(fp, 0, SEEK_END); - filesize = static_cast(ftell(fp)); - fseek(fp, 0, SEEK_SET); - - std::vector buf(filesize); // @todo { use mmap } - { - size_t ret; - ret = fread(&buf[0], 1, filesize, fp); - assert(ret == filesize); - fclose(fp); - (void)ret; - } - - return LoadEXRMultipartImageFromMemory(exr_images, exr_headers, num_parts, - &buf.at(0), filesize, err); -} - -int SaveEXR(const float *data, int width, int height, int components, - const int save_as_fp16, const char *outfilename, const char **err) { - if ((components == 1) || components == 3 || components == 4) { - // OK - } else { - std::stringstream ss; - ss << "Unsupported component value : " << components << std::endl; - - tinyexr::SetErrorMessage(ss.str(), err); - return TINYEXR_ERROR_INVALID_ARGUMENT; - } - - EXRHeader header; - InitEXRHeader(&header); - - if ((width < 16) && (height < 16)) { - // No compression for small image. - header.compression_type = TINYEXR_COMPRESSIONTYPE_NONE; - } else { - header.compression_type = TINYEXR_COMPRESSIONTYPE_ZIP; - } - - EXRImage image; - InitEXRImage(&image); - - image.num_channels = components; - - std::vector images[4]; - - if (components == 1) { - images[0].resize(static_cast(width * height)); - memcpy(images[0].data(), data, sizeof(float) * size_t(width * height)); - } else { - images[0].resize(static_cast(width * height)); - images[1].resize(static_cast(width * height)); - images[2].resize(static_cast(width * height)); - images[3].resize(static_cast(width * height)); - - // Split RGB(A)RGB(A)RGB(A)... into R, G and B(and A) layers - for (size_t i = 0; i < static_cast(width * height); i++) { - images[0][i] = data[static_cast(components) * i + 0]; - images[1][i] = data[static_cast(components) * i + 1]; - images[2][i] = data[static_cast(components) * i + 2]; - if (components == 4) { - images[3][i] = data[static_cast(components) * i + 3]; - } - } - } - - float *image_ptr[4] = {0, 0, 0, 0}; - if (components == 4) { - image_ptr[0] = &(images[3].at(0)); // A - image_ptr[1] = &(images[2].at(0)); // B - image_ptr[2] = &(images[1].at(0)); // G - image_ptr[3] = &(images[0].at(0)); // R - } else if (components == 3) { - image_ptr[0] = &(images[2].at(0)); // B - image_ptr[1] = &(images[1].at(0)); // G - image_ptr[2] = &(images[0].at(0)); // R - } else if (components == 1) { - image_ptr[0] = &(images[0].at(0)); // A - } - - image.images = reinterpret_cast(image_ptr); - image.width = width; - image.height = height; - - header.num_channels = components; - header.channels = static_cast(malloc( - sizeof(EXRChannelInfo) * static_cast(header.num_channels))); - // Must be (A)BGR order, since most of EXR viewers expect this channel order. - if (components == 4) { -#ifdef _MSC_VER - strncpy_s(header.channels[0].name, "A", 255); - strncpy_s(header.channels[1].name, "B", 255); - strncpy_s(header.channels[2].name, "G", 255); - strncpy_s(header.channels[3].name, "R", 255); -#else - strncpy(header.channels[0].name, "A", 255); - strncpy(header.channels[1].name, "B", 255); - strncpy(header.channels[2].name, "G", 255); - strncpy(header.channels[3].name, "R", 255); -#endif - header.channels[0].name[strlen("A")] = '\0'; - header.channels[1].name[strlen("B")] = '\0'; - header.channels[2].name[strlen("G")] = '\0'; - header.channels[3].name[strlen("R")] = '\0'; - } else if (components == 3) { -#ifdef _MSC_VER - strncpy_s(header.channels[0].name, "B", 255); - strncpy_s(header.channels[1].name, "G", 255); - strncpy_s(header.channels[2].name, "R", 255); -#else - strncpy(header.channels[0].name, "B", 255); - strncpy(header.channels[1].name, "G", 255); - strncpy(header.channels[2].name, "R", 255); -#endif - header.channels[0].name[strlen("B")] = '\0'; - header.channels[1].name[strlen("G")] = '\0'; - header.channels[2].name[strlen("R")] = '\0'; - } else { -#ifdef _MSC_VER - strncpy_s(header.channels[0].name, "A", 255); -#else - strncpy(header.channels[0].name, "A", 255); -#endif - header.channels[0].name[strlen("A")] = '\0'; - } - - header.pixel_types = static_cast( - malloc(sizeof(int) * static_cast(header.num_channels))); - header.requested_pixel_types = static_cast( - malloc(sizeof(int) * static_cast(header.num_channels))); - for (int i = 0; i < header.num_channels; i++) { - header.pixel_types[i] = - TINYEXR_PIXELTYPE_FLOAT; // pixel type of input image - - if (save_as_fp16 > 0) { - header.requested_pixel_types[i] = - TINYEXR_PIXELTYPE_HALF; // save with half(fp16) pixel format - } else { - header.requested_pixel_types[i] = - TINYEXR_PIXELTYPE_FLOAT; // save with float(fp32) pixel format(i.e. - // no precision reduction) - } - } - - int ret = SaveEXRImageToFile(&image, &header, outfilename, err); - if (ret != TINYEXR_SUCCESS) { - return ret; - } - - free(header.channels); - free(header.pixel_types); - free(header.requested_pixel_types); - - return ret; -} - -#ifdef __clang__ -// zero-as-null-ppinter-constant -#pragma clang diagnostic pop -#endif - -#endif // TINYEXR_IMPLEMENTATION_DEFINED -#endif // TINYEXR_IMPLEMENTATION diff --git a/extern/tinygltf/.clang-format b/extern/tinygltf/.clang-format deleted file mode 100644 index 74210b0..0000000 --- a/extern/tinygltf/.clang-format +++ /dev/null @@ -1,7 +0,0 @@ ---- -BasedOnStyle: Google -IndentWidth: 2 -TabWidth: 2 -UseTab: Never -BreakBeforeBraces: Attach -Standard: Cpp03 diff --git a/extern/tinygltf/.gitignore b/extern/tinygltf/.gitignore deleted file mode 100644 index 879c4cd..0000000 --- a/extern/tinygltf/.gitignore +++ /dev/null @@ -1,71 +0,0 @@ -# CMake -CMakeCache.txt -CMakeFiles -CMakeScripts -Testing -Makefile -cmake_install.cmake -install_manifest.txt -compile_commands.json -CTestTestfile.cmake - -#Files created by the CI scripts (downloading and installing premake) -premake5 -premake5.tar.gz - -#built examples -/examples/raytrace/bin/ - -#visual studio files -*.sln -*.vcxproj* -.vs - -#binary directories -bin/ -obj/ - -#runtime gui config -imgui.ini - -#visual stuido code -.vscode - -# Prerequisites -*.d - -# Compiled Object files -*.slo -*.lo -*.o -*.obj - -# Precompiled Headers -*.gch -*.pch - -# Compiled Dynamic libraries -*.so -*.dylib -*.dll - -# Fortran module files -*.mod -*.smod - -# Compiled Static libraries -*.lai -*.la -*.a -*.lib - -# Executables -*.exe -*.out -*.app - -loader_example -tests/tester -tests/tester_noexcept -tests/issue-97.gltf - diff --git a/extern/tinygltf/LICENSE b/extern/tinygltf/LICENSE deleted file mode 100644 index 34398ad..0000000 --- a/extern/tinygltf/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2017 Syoyo Fujita, Aurélien Chatelain and many contributors - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/extern/tinygltf/README.md b/extern/tinygltf/README.md deleted file mode 100644 index bcf53fd..0000000 --- a/extern/tinygltf/README.md +++ /dev/null @@ -1,229 +0,0 @@ -# Header only C++ tiny glTF library(loader/saver). - -`TinyGLTF` is a header only C++11 glTF 2.0 https://github.com/KhronosGroup/glTF library. - -`TinyGLTF` uses Niels Lohmann's json library(https://github.com/nlohmann/json), so now it requires C++11 compiler. -If you are looking for old, C++03 version, please use `devel-picojson` branch(but not maintained anymore). - -## Status - - - v2.4.0 Experimental RapidJSON support. Experimental C++14 support(C++14 may give better performance) - - v2.3.0 Modified Material representation according to glTF 2.0 schema(and introduced TextureInfo class) - - v2.2.0 release(Support loading 16bit PNG. Sparse accessor support) - - v2.1.0 release(Draco support) - - v2.0.0 release(22 Aug, 2018)! - -### Branches - -* `sajson` : Use sajson to parse JSON. Parsing only but faster compile time(2x reduction compared to json.hpp and RapidJson) - -## Builds - -[![Build Status](https://travis-ci.org/syoyo/tinygltf.svg?branch=devel)](https://travis-ci.org/syoyo/tinygltf) - -[![Build status](https://ci.appveyor.com/api/projects/status/warngenu9wjjhlm8?svg=true)](https://ci.appveyor.com/project/syoyo/tinygltf) - -![C/C++ CI](https://github.com/syoyo/tinygltf/workflows/C/C++%20CI/badge.svg) - -## Features - -* Written in portable C++. C++-11 with STL dependency only. - * [x] macOS + clang(LLVM) - * [x] iOS + clang - * [x] Linux + gcc/clang - * [x] Windows + MinGW - * [x] Windows + Visual Studio 2015 Update 3 or later. - * Visual Studio 2013 is not supported since they have limited C++11 support and failed to compile `json.hpp`. - * [x] Android NDK - * [x] Android + CrystaX(NDK drop-in replacement) GCC - * [x] Web using Emscripten(LLVM) -* Moderate parsing time and memory consumption. -* glTF specification v2.0.0 - * [x] ASCII glTF - * [x] Load - * [x] Save - * [x] Binary glTF(GLB) - * [x] Load - * [x] Save(.bin embedded .glb) -* Buffers - * [x] Parse BASE64 encoded embedded buffer data(DataURI). - * [x] Load `.bin` file. -* Image(Using stb_image) - * [x] Parse BASE64 encoded embedded image data(DataURI). - * [x] Load external image file. - * [x] Load PNG(8bit and 16bit) - * [x] Load JPEG(8bit only) - * [x] Load BMP - * [x] Load GIF - * [x] Custom Image decoder callback(e.g. for decoding OpenEXR image) -* Morph traget - * [x] Sparse accessor -* Load glTF from memory -* Custom callback handler - * [x] Image load - * [x] Image save -* Extensions - * [x] Draco mesh decoding - * [ ] Draco mesh encoding - -## Note on extension property - -In extension(`ExtensionMap`), JSON number value is parsed as int or float(number) and stored as `tinygltf::Value` object. If you want a floating point value from `tinygltf::Value`, use `GetNumberAsDouble()` method. - -`IsNumber()` returns true if the underlying value is an int value or a floating point value. - -## Examples - -* [glview](examples/glview) : Simple glTF geometry viewer. -* [validator](examples/validator) : Simple glTF validator with JSON schema. -* [basic](examples/basic) : Basic glTF viewer with texturing support. - -## Projects using TinyGLTF - -* px_render Single header C++ Libraries for Thread Scheduling, Rendering, and so on... https://github.com/pplux/px -* Physical based rendering with Vulkan using glTF 2.0 models https://github.com/SaschaWillems/Vulkan-glTF-PBR -* GLTF loader plugin for OGRE 2.1. Support for PBR materials via HLMS/PBS https://github.com/Ybalrid/Ogre_glTF -* [TinyGltfImporter](http://doc.magnum.graphics/magnum/classMagnum_1_1Trade_1_1TinyGltfImporter.html) plugin for [Magnum](https://github.com/mosra/magnum), a lightweight and modular C++11/C++14 graphics middleware for games and data visualization. -* [Diligent Engine](https://github.com/DiligentGraphics/DiligentEngine) - A modern cross-platform low-level graphics library and rendering framework -* Lighthouse 2: a rendering framework for real-time ray tracing / path tracing experiments. https://github.com/jbikker/lighthouse2 -* [QuickLook GLTF](https://github.com/toshiks/glTF-quicklook) - quicklook plugin for macos. Also SceneKit wrapper for tinygltf. -* [GlslViewer](https://github.com/patriciogonzalezvivo/glslViewer) - live GLSL coding for MacOS and Linux -* [Vulkan-Samples](https://github.com/KhronosGroup/Vulkan-Samples) - The Vulkan Samples is collection of resources to help you develop optimized Vulkan applications. -* [TDME2](https://github.com/andreasdr/tdme2) - TDME2 - ThreeDeeMiniEngine2 is a lightweight 3D engine including tools suited for 3D game development using C++11 -* Your projects here! (Please send PR) - -## TODOs - -* [ ] Write C++ code generator which emits C++ code from JSON schema for robust parsing. -* [ ] Mesh Compression/decompression(Open3DGC, etc) - * [x] Load Draco compressed mesh - * [ ] Save Draco compressed mesh - * [ ] Open3DGC? -* [x] Support `extensions` and `extras` property -* [ ] HDR image? - * [ ] OpenEXR extension through TinyEXR. -* [ ] 16bit PNG support in Serialization -* [ ] Write example and tests for `animation` and `skin` - -## Licenses - -TinyGLTF is licensed under MIT license. - -TinyGLTF uses the following third party libraries. - -* json.hpp : Copyright (c) 2013-2017 Niels Lohmann. MIT license. -* base64 : Copyright (C) 2004-2008 René Nyffenegger -* stb_image.h : v2.08 - public domain image loader - [Github link](https://github.com/nothings/stb/blob/master/stb_image.h) -* stb_image_write.h : v1.09 - public domain image writer - [Github link](https://github.com/nothings/stb/blob/master/stb_image_write.h) - - -## Build and example - -Copy `stb_image.h`, `stb_image_write.h`, `json.hpp` and `tiny_gltf.h` to your project. - -### Loading glTF 2.0 model - -```c++ -// Define these only in *one* .cc file. -#define TINYGLTF_IMPLEMENTATION -#define STB_IMAGE_IMPLEMENTATION -#define STB_IMAGE_WRITE_IMPLEMENTATION -// #define TINYGLTF_NOEXCEPTION // optional. disable exception handling. -#include "tiny_gltf.h" - -using namespace tinygltf; - -Model model; -TinyGLTF loader; -std::string err; -std::string warn; - -bool ret = loader.LoadASCIIFromFile(&model, &err, &warn, argv[1]); -//bool ret = loader.LoadBinaryFromFile(&model, &err, &warn, argv[1]); // for binary glTF(.glb) - -if (!warn.empty()) { - printf("Warn: %s\n", warn.c_str()); -} - -if (!err.empty()) { - printf("Err: %s\n", err.c_str()); -} - -if (!ret) { - printf("Failed to parse glTF\n"); - return -1; -} -``` - -#### Loader options - -* `TinyGLTF::SetPreserveimageChannels(bool onoff)`. `true` to preserve image channels as stored in image file for loaded image. `false` by default for backward compatibility(image channels are widen to `RGBA` 4 channels). Effective only when using builtin image loader(STB image loader). - -## Compile options - -* `TINYGLTF_NOEXCEPTION` : Disable C++ exception in JSON parsing. You can use `-fno-exceptions` or by defining the symbol `JSON_NOEXCEPTION` and `TINYGLTF_NOEXCEPTION` to fully remove C++ exception codes when compiling TinyGLTF. -* `TINYGLTF_NO_STB_IMAGE` : Do not load images with stb_image. Instead use `TinyGLTF::SetImageLoader(LoadimageDataFunction LoadImageData, void *user_data)` to set a callback for loading images. -* `TINYGLTF_NO_STB_IMAGE_WRITE` : Do not write images with stb_image_write. Instead use `TinyGLTF::SetImageWriter(WriteimageDataFunction WriteImageData, void *user_data)` to set a callback for writing images. -* `TINYGLTF_NO_EXTERNAL_IMAGE` : Do not try to load external image file. This option would be helpful if you do not want to load image files during glTF parsing. -* `TINYGLTF_ANDROID_LOAD_FROM_ASSETS`: Load all files from packaged app assets instead of the regular file system. **Note:** You must pass a valid asset manager from your android app to `tinygltf::asset_manager` beforehand. -* `TINYGLTF_ENABLE_DRACO`: Enable Draco compression. User must provide include path and link correspnding libraries in your project file. -* `TINYGLTF_NO_INCLUDE_JSON `: Disable including `json.hpp` from within `tiny_gltf.h` because it has been already included before or you want to include it using custom path before including `tiny_gltf.h`. -* `TINYGLTF_NO_INCLUDE_STB_IMAGE `: Disable including `stb_image.h` from within `tiny_gltf.h` because it has been already included before or you want to include it using custom path before including `tiny_gltf.h`. -* `TINYGLTF_NO_INCLUDE_STB_IMAGE_WRITE `: Disable including `stb_image_write.h` from within `tiny_gltf.h` because it has been already included before or you want to include it using custom path before including `tiny_gltf.h`. -* `TINYGLTF_USE_RAPIDJSON` : Use RapidJSON as a JSON parser/serializer. RapidJSON files are not included in TinyGLTF repo. Please set an include path to RapidJSON if you enable this featrure. -* `TINYGLTF_USE_CPP14` : Use C++14 feature(requires C++14 compiler). This may give better performance than C++11. - - -### Saving gltTF 2.0 model - -* Buffers. - * [x] To file - * [x] Embedded - * [ ] Draco compressed? -* [x] Images - * [x] To file - * [x] Embedded -* Binary(.glb) - * [x] .bin embedded single .glb - * [ ] External .bin - -## Running tests. - -### glTF parsing test - -#### Setup - -Python 2.6 or 2.7 required. -Git clone https://github.com/KhronosGroup/glTF-Sample-Models to your local dir. - -#### Run parsing test - -After building `loader_example`, edit `test_runner.py`, then, - -```bash -$ python test_runner.py -``` - -### Unit tests - -```bash -$ cd tests -$ make -$ ./tester -$ ./tester_noexcept -``` - -### Fuzzing tests - -See `tests/fuzzer` for details. - -After running fuzzer on Ryzen9 3950X a week, at least `LoadASCIIFromString` looks safe except for out-of-memory error in Fuzzer. -We may be better to introduce bounded memory size checking when parsing glTF data. - -## Third party licenses - -* json.hpp : Licensed under the MIT License . Copyright (c) 2013-2017 Niels Lohmann . -* stb_image : Public domain. -* catch : Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. Distributed under the Boost Software License, Version 1.0. -* RapidJSON : Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. http://rapidjson.org/ -* dlib(uridecode, uriencode) : Copyright (C) 2003 Davis E. King Boost Software License 1.0. http://dlib.net/dlib/server/server_http.cpp.html diff --git a/extern/tinygltf/json.hpp b/extern/tinygltf/json.hpp deleted file mode 100644 index c9af0be..0000000 --- a/extern/tinygltf/json.hpp +++ /dev/null @@ -1,20406 +0,0 @@ -/* - __ _____ _____ _____ - __| | __| | | | JSON for Modern C++ -| | |__ | | | | | | version 3.5.0 -|_____|_____|_____|_|___| https://github.com/nlohmann/json - -Licensed under the MIT License . -SPDX-License-Identifier: MIT -Copyright (c) 2013-2018 Niels Lohmann . - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#ifndef NLOHMANN_JSON_HPP -#define NLOHMANN_JSON_HPP - -#define NLOHMANN_JSON_VERSION_MAJOR 3 -#define NLOHMANN_JSON_VERSION_MINOR 5 -#define NLOHMANN_JSON_VERSION_PATCH 0 - -#include // all_of, find, for_each -#include // assert -#include // and, not, or -#include // nullptr_t, ptrdiff_t, size_t -#include // hash, less -#include // initializer_list -#include // istream, ostream -#include // random_access_iterator_tag -#include // accumulate -#include // string, stoi, to_string -#include // declval, forward, move, pair, swap - -// #include -#ifndef NLOHMANN_JSON_FWD_HPP -#define NLOHMANN_JSON_FWD_HPP - -#include // int64_t, uint64_t -#include // map -#include // allocator -#include // string -#include // vector - -/*! -@brief namespace for Niels Lohmann -@see https://github.com/nlohmann -@since version 1.0.0 -*/ -namespace nlohmann -{ -/*! -@brief default JSONSerializer template argument - -This serializer ignores the template arguments and uses ADL -([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl)) -for serialization. -*/ -template -struct adl_serializer; - -template class ObjectType = - std::map, - template class ArrayType = std::vector, - class StringType = std::string, class BooleanType = bool, - class NumberIntegerType = std::int64_t, - class NumberUnsignedType = std::uint64_t, - class NumberFloatType = double, - template class AllocatorType = std::allocator, - template class JSONSerializer = - adl_serializer> -class basic_json; - -/*! -@brief JSON Pointer - -A JSON pointer defines a string syntax for identifying a specific value -within a JSON document. It can be used with functions `at` and -`operator[]`. Furthermore, JSON pointers are the base for JSON patches. - -@sa [RFC 6901](https://tools.ietf.org/html/rfc6901) - -@since version 2.0.0 -*/ -template -class json_pointer; - -/*! -@brief default JSON class - -This type is the default specialization of the @ref basic_json class which -uses the standard template types. - -@since version 1.0.0 -*/ -using json = basic_json<>; -} // namespace nlohmann - -#endif - -// #include - - -// This file contains all internal macro definitions -// You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them - -// exclude unsupported compilers -#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK) - #if defined(__clang__) - #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400 - #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers" - #endif - #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER)) - #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800 - #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers" - #endif - #endif -#endif - -// disable float-equal warnings on GCC/clang -#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wfloat-equal" -#endif - -// disable documentation warnings on clang -#if defined(__clang__) - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdocumentation" -#endif - -// allow for portable deprecation warnings -#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) - #define JSON_DEPRECATED __attribute__((deprecated)) -#elif defined(_MSC_VER) - #define JSON_DEPRECATED __declspec(deprecated) -#else - #define JSON_DEPRECATED -#endif - -// allow to disable exceptions -#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION) - #define JSON_THROW(exception) throw exception - #define JSON_TRY try - #define JSON_CATCH(exception) catch(exception) - #define JSON_INTERNAL_CATCH(exception) catch(exception) -#else - #define JSON_THROW(exception) std::abort() - #define JSON_TRY if(true) - #define JSON_CATCH(exception) if(false) - #define JSON_INTERNAL_CATCH(exception) if(false) -#endif - -// override exception macros -#if defined(JSON_THROW_USER) - #undef JSON_THROW - #define JSON_THROW JSON_THROW_USER -#endif -#if defined(JSON_TRY_USER) - #undef JSON_TRY - #define JSON_TRY JSON_TRY_USER -#endif -#if defined(JSON_CATCH_USER) - #undef JSON_CATCH - #define JSON_CATCH JSON_CATCH_USER - #undef JSON_INTERNAL_CATCH - #define JSON_INTERNAL_CATCH JSON_CATCH_USER -#endif -#if defined(JSON_INTERNAL_CATCH_USER) - #undef JSON_INTERNAL_CATCH - #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER -#endif - -// manual branch prediction -#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) - #define JSON_LIKELY(x) __builtin_expect(!!(x), 1) - #define JSON_UNLIKELY(x) __builtin_expect(!!(x), 0) -#else - #define JSON_LIKELY(x) x - #define JSON_UNLIKELY(x) x -#endif - -// C++ language standard detection -#if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 - #define JSON_HAS_CPP_17 - #define JSON_HAS_CPP_14 -#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) - #define JSON_HAS_CPP_14 -#endif - -/*! -@brief macro to briefly define a mapping between an enum and JSON -@def NLOHMANN_JSON_SERIALIZE_ENUM -@since version 3.4.0 -*/ -#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \ - template \ - inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \ - { \ - static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ - static const std::pair m[] = __VA_ARGS__; \ - auto it = std::find_if(std::begin(m), std::end(m), \ - [e](const std::pair& ej_pair) -> bool \ - { \ - return ej_pair.first == e; \ - }); \ - j = ((it != std::end(m)) ? it : std::begin(m))->second; \ - } \ - template \ - inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \ - { \ - static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ - static const std::pair m[] = __VA_ARGS__; \ - auto it = std::find_if(std::begin(m), std::end(m), \ - [j](const std::pair& ej_pair) -> bool \ - { \ - return ej_pair.second == j; \ - }); \ - e = ((it != std::end(m)) ? it : std::begin(m))->first; \ - } - -// Ugly macros to avoid uglier copy-paste when specializing basic_json. They -// may be removed in the future once the class is split. - -#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \ - template class ObjectType, \ - template class ArrayType, \ - class StringType, class BooleanType, class NumberIntegerType, \ - class NumberUnsignedType, class NumberFloatType, \ - template class AllocatorType, \ - template class JSONSerializer> - -#define NLOHMANN_BASIC_JSON_TPL \ - basic_json - -// #include - - -#include // not -#include // size_t -#include // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type - -namespace nlohmann -{ -namespace detail -{ -// alias templates to reduce boilerplate -template -using enable_if_t = typename std::enable_if::type; - -template -using uncvref_t = typename std::remove_cv::type>::type; - -// implementation of C++14 index_sequence and affiliates -// source: https://stackoverflow.com/a/32223343 -template -struct index_sequence -{ - using type = index_sequence; - using value_type = std::size_t; - static constexpr std::size_t size() noexcept - { - return sizeof...(Ints); - } -}; - -template -struct merge_and_renumber; - -template -struct merge_and_renumber, index_sequence> - : index_sequence < I1..., (sizeof...(I1) + I2)... > {}; - -template -struct make_index_sequence - : merge_and_renumber < typename make_index_sequence < N / 2 >::type, - typename make_index_sequence < N - N / 2 >::type > {}; - -template<> struct make_index_sequence<0> : index_sequence<> {}; -template<> struct make_index_sequence<1> : index_sequence<0> {}; - -template -using index_sequence_for = make_index_sequence; - -// dispatch utility (taken from ranges-v3) -template struct priority_tag : priority_tag < N - 1 > {}; -template<> struct priority_tag<0> {}; - -// taken from ranges-v3 -template -struct static_const -{ - static constexpr T value{}; -}; - -template -constexpr T static_const::value; -} // namespace detail -} // namespace nlohmann - -// #include - - -#include // not -#include // numeric_limits -#include // false_type, is_constructible, is_integral, is_same, true_type -#include // declval - -// #include - -// #include - - -#include // random_access_iterator_tag - -// #include - - -namespace nlohmann -{ -namespace detail -{ -template struct make_void -{ - using type = void; -}; -template using void_t = typename make_void::type; -} // namespace detail -} // namespace nlohmann - -// #include - - -namespace nlohmann -{ -namespace detail -{ -template -struct iterator_types {}; - -template -struct iterator_types < - It, - void_t> -{ - using difference_type = typename It::difference_type; - using value_type = typename It::value_type; - using pointer = typename It::pointer; - using reference = typename It::reference; - using iterator_category = typename It::iterator_category; -}; - -// This is required as some compilers implement std::iterator_traits in a way that -// doesn't work with SFINAE. See https://github.com/nlohmann/json/issues/1341. -template -struct iterator_traits -{ -}; - -template -struct iterator_traits < T, enable_if_t < !std::is_pointer::value >> - : iterator_types -{ -}; - -template -struct iterator_traits::value>> -{ - using iterator_category = std::random_access_iterator_tag; - using value_type = T; - using difference_type = ptrdiff_t; - using pointer = T*; - using reference = T&; -}; -} -} - -// #include - -// #include - - -#include - -// #include - - -// http://en.cppreference.com/w/cpp/experimental/is_detected -namespace nlohmann -{ -namespace detail -{ -struct nonesuch -{ - nonesuch() = delete; - ~nonesuch() = delete; - nonesuch(nonesuch const&) = delete; - void operator=(nonesuch const&) = delete; -}; - -template class Op, - class... Args> -struct detector -{ - using value_t = std::false_type; - using type = Default; -}; - -template class Op, class... Args> -struct detector>, Op, Args...> -{ - using value_t = std::true_type; - using type = Op; -}; - -template