Dune::Copasi
Loading...
Searching...
No Matches
tiff_grayscale.hh
Go to the documentation of this file.
1#ifndef DUNE_COPASI_TIFF_GRAYSCALE_HH
2#define DUNE_COPASI_TIFF_GRAYSCALE_HH
3
5
6#include <function2/function2.hpp>
7
8#include <filesystem>
9#include <functional>
10#include <queue>
11
12namespace Dune::Copasi {
13
21{
25 struct TIFFGrayscaleRow
26 {
35 TIFFGrayscaleRow(const TIFFFile& tiff, const std::size_t& row);
46 [[nodiscard]] double operator[](const std::size_t& col) const;
47
53 [[nodiscard]] std::size_t size() const;
54
60 [[nodiscard]] std::size_t row() const;
61
62 private:
63 TIFFFile const* _tiff_ptr;
64 std::size_t _row;
65 std::size_t _max;
66 fu2::unique_function<std::size_t(std::size_t) const noexcept>
67 _read_col{};
68 };
69
70public:
77 explicit TIFFGrayscale(const std::filesystem::path& filename, std::size_t max_cache = 8);
78
87 const TIFFGrayscaleRow& operator[](std::size_t row) const;
88
102 [[nodiscard]] double operator()(double pos_x, double pos_y) noexcept;
103
109 [[nodiscard]] std::size_t size() const;
110
116 [[nodiscard]] std::size_t rows() const;
117
123 [[nodiscard]] std::size_t cols() const;
124
125private:
133 const TIFFGrayscaleRow& cache(std::size_t row) const;
134
135 TIFFFile _tiff;
136 mutable std::deque<TIFFGrayscaleRow> _row_cache;
137 std::size_t _max_cache;
138};
139
140} // namespace Dune::Copasi
141
142#endif // DUNE_COPASI_TIFF_GRAYSCALE_HH
This class describes a tiff grayscale.
Definition tiff_grayscale.hh:21
const TIFFGrayscaleRow & operator[](std::size_t row) const
Array indexer row operator.
std::size_t rows() const
The size of rows for this file.
double operator()(double pos_x, double pos_y) noexcept
TIFF value by position call operator.
TIFFGrayscale(const std::filesystem::path &filename, std::size_t max_cache=8)
Constructs a new instance.
std::size_t size() const
The size of rows for this file.
std::size_t cols() const
The size of cols for this file.
Definition axis_names.hh:7
constexpr bool is_bitflags_v
Alias for Bitflag indicator.
Definition bit_flags.hh:24
Simple tiff file interface.
Definition tiff_file.hh:18