OpenImpala
Image-based parallel transport property solver
Loading...
Searching...
No Matches
TiffReader.H
Go to the documentation of this file.
1
4#ifndef TIFF_READER_H
5#define TIFF_READER_H
6
7#include <string>
8#include <cstdint> // For standard integer types
9#include <stdexcept> // For std::runtime_error
10// #include <vector> // No longer needed for m_raw_bytes
11// #include <map> // Only needed if attributes are implemented
12
13#include <AMReX_REAL.H>
14#include <AMReX_Box.H>
15#include <AMReX_iMultiFab.H>
16
17// Forward declare TIFF - not strictly necessary now as TIFF* isn't in the
18// public/protected interface, but can be kept for clarity if desired.
19// struct tiff;
20// typedef struct tiff TIFF;
21
22namespace OpenImpala {
23
48public:
52 TiffReader();
53
63 explicit TiffReader(const std::string& filename);
64
77 TiffReader(const std::string& base_pattern, int num_files, int start_index = 0, int digits = 1,
78 const std::string& suffix = ".tif");
79
83 virtual ~TiffReader() = default;
84
85 // --- Deleted Copy Operations ---
86 TiffReader(const TiffReader&) = delete;
87 TiffReader& operator=(const TiffReader&) = delete;
88
89 // --- Default Move Operations ---
90 TiffReader(TiffReader&&) = default;
92
101 bool readFile(const std::string& filename);
102
116 bool readFileSequence(const std::string& base_pattern, int num_files, int start_index = 0,
117 int digits = 1, const std::string& suffix = ".tif");
118
134 void threshold(double raw_threshold, amrex::iMultiFab& mf) const;
135
154 void threshold(double raw_threshold, int value_if_true, int value_if_false,
155 amrex::iMultiFab& mf) const;
156
157 // --- Metadata Getters ---
160 amrex::Box box() const;
161
163 int width() const;
165 int height() const;
167 int depth() const;
168
170 int bitsPerSample() const;
173 int sampleFormat() const;
176 int samplesPerPixel() const;
177
180 uint16_t getFillOrder() const {
181 return m_fill_order;
182 } // <<< NEW GETTER ADDED HERE <<<
183
185 bool isRead() const {
186 return m_is_read;
187 }
188
189
190private:
191 // --- Member Variables ---
192 // Source Info
193 std::string m_filename;
194 std::string m_base_pattern;
195 std::string m_suffix;
196 int m_start_index = 0;
197 int m_digits = 1;
198 bool m_is_sequence = false;
199
200 // Domain/Metadata Info (Read by Rank 0, Broadcast to all)
201 int m_width = 0;
202 int m_height = 0;
203 int m_depth = 0;
204 bool m_is_read =
205 false;
206
207 // TIFF Format Info (Read by Rank 0, Broadcast to all)
208 uint16_t m_bits_per_sample = 0;
209 uint16_t m_sample_format = 0;
210 uint16_t m_samples_per_pixel = 0;
211 uint16_t m_fill_order; // Initialized in constructor(s)
212
213 // Private helper function implementing the core distributed read logic
214 // Called by the public threshold methods.
215 void readDistributedIntoFab(amrex::iMultiFab& dest_mf, int value_if_true, int value_if_false,
216 double raw_threshold) const;
217
218
219}; // class TiffReader
220
221} // namespace OpenImpala
222
223#endif // TIFF_READER_H
bool readFile(const std::string &filename)
Reads metadata from a single (potentially multi-directory) TIFF file.
Definition TiffReader.cpp:196
int width() const
Get width (X-dimension) in pixels/voxels. Requires metadata to be read.
Definition TiffReader.cpp:166
TiffReader(TiffReader &&)=default
uint16_t getFillOrder() const
Get TIFF FillOrder tag value (e.g., 1=MSB->LSB, 2=LSB->MSB). Requires metadata to be read.
Definition TiffReader.H:180
TiffReader(const TiffReader &)=delete
int samplesPerPixel() const
Get samples per pixel (e.g., 1 for grayscale, 3 for RGB). Requires metadata to be read.
Definition TiffReader.cpp:181
virtual ~TiffReader()=default
Virtual default destructor.
int depth() const
Get depth (Z-dimension) in pixels/voxels. Requires metadata to be read.
Definition TiffReader.cpp:172
TiffReader()
Default constructor. Creates an empty reader. Use readFile() or readFileSequence().
Definition TiffReader.cpp:135
void threshold(double raw_threshold, amrex::iMultiFab &mf) const
Reads data chunk-by-chunk into an iMultiFab based on thresholding (output 1/0).
Definition TiffReader.cpp:746
TiffReader & operator=(TiffReader &&)=default
TiffReader & operator=(const TiffReader &)=delete
int height() const
Get height (Y-dimension) in pixels/voxels. Requires metadata to be read.
Definition TiffReader.cpp:169
bool readFileSequence(const std::string &base_pattern, int num_files, int start_index=0, int digits=1, const std::string &suffix=".tif")
Reads metadata from the first file of a TIFF sequence.
Definition TiffReader.cpp:307
amrex::Box box() const
Returns the index space Box covering the entire image domain [0, w-1]x[0, h-1]x[0,...
Definition TiffReader.cpp:185
int sampleFormat() const
Get sample format (e.g., SAMPLEFORMAT_UINT, SAMPLEFORMAT_INT, SAMPLEFORMAT_IEEEFP from tiff....
Definition TiffReader.cpp:178
int bitsPerSample() const
Get bits per sample (e.g., 8, 16, 32). Requires metadata to be read.
Definition TiffReader.cpp:175
bool isRead() const
Check if metadata has been successfully read and broadcast.
Definition TiffReader.H:185
Definition CathodeWrite.cpp:12