OpenImpala
Image-based parallel transport property solver
Loading...
Searching...
No Matches
DatReader.H
Go to the documentation of this file.
1
4#ifndef DAT_READER_H // Corrected header guard style
5#define DAT_READER_H
6
7#include <cstddef> // <--- ADD THIS LINE
8#include <vector>
9#include <string>
10#include <cstdint> // Use <cstdint> for fixed-width types
11#include <stdexcept> // For exceptions in constructor
12
13#include <AMReX_REAL.H>
14#include <AMReX_iMultiFab.H>
15#include <AMReX_Box.H>
16
17namespace OpenImpala {
18
32class DatReader {
33public:
34 // --- Define the expected raw data type ---
35 // IMPORTANT: Verify this matches the actual DAT file format!
36 // Common types: std::uint8_t, std::uint16_t, std::uint32_t, float, double
37 using DataType = std::uint16_t; // Example: Assuming 16-bit unsigned integer data
38
42 DatReader();
43
54 explicit DatReader(const std::string& filename);
55
59 virtual ~DatReader() = default;
60
61 // --- Deleted Copy Operations ---
62 // Prevent copying due to potentially large m_raw vector.
63 DatReader(const DatReader&) = delete;
64 DatReader& operator=(const DatReader&) = delete;
65
66 // --- Optional: Default Move Operations (C++11) ---
67 // DatReader(DatReader&&) = default;
68 // DatReader& operator=(DatReader&&) = default;
69
80 bool readFile(const std::string& filename);
81
86 bool isRead() const;
87
102 void threshold(DataType raw_threshold, amrex::iMultiFab& mf) const;
103
118 void threshold(DataType raw_threshold, int value_if_true, int value_if_false,
119 amrex::iMultiFab& mf) const;
120
127 amrex::Box box() const;
128
130 int width() const;
131
133 int height() const;
134
136 int depth() const;
137
147 DataType getRawValue(int i, int j, int k) const;
148
154 const std::vector<DataType>& getRawData() const;
155
156
157private:
162 bool readDatFileInternal();
163
164 // --- Member Variables ---
165 std::string m_filename;
166 std::vector<DataType> m_raw;
167 int m_width = 0;
168 int m_height = 0;
169 int m_depth = 0;
170 bool m_is_read = false;
171
172}; // class DatReader
173
174} // namespace OpenImpala
175
176#endif // DAT_READER_H
std::uint16_t DataType
Definition DatReader.H:37
DatReader(const DatReader &)=delete
int depth() const
Get depth (Z-dimension) of the dataset in pixels/voxels.
Definition DatReader.cpp:184
void threshold(DataType raw_threshold, amrex::iMultiFab &mf) const
Fills an iMultiFab based on thresholding the raw data.
Definition DatReader.cpp:270
int height() const
Get height (Y-dimension) of the dataset in pixels/voxels.
Definition DatReader.cpp:181
virtual ~DatReader()=default
Virtual default destructor.
DatReader & operator=(const DatReader &)=delete
DataType getRawValue(int i, int j, int k) const
Get the raw data value at a specific coordinate. Performs bounds checking. Throws std::out_of_range i...
Definition DatReader.cpp:197
bool readFile(const std::string &filename)
Reads data from the specified filename into this object.
Definition DatReader.cpp:75
bool isRead() const
Checks if the reader has successfully read metadata and data.
Definition DatReader.cpp:71
amrex::Box box() const
Returns the index space Box covering the entire image domain. The Box typically starts at (0,...
Definition DatReader.cpp:187
int width() const
Get width (X-dimension) of the dataset in pixels/voxels.
Definition DatReader.cpp:178
const std::vector< DataType > & getRawData() const
Get read-only access to the entire raw data vector. Provides direct access but exposes internal stora...
Definition DatReader.cpp:193
DatReader()
Default constructor. Creates an empty reader. Use readFile() later.
Definition DatReader.cpp:57
Definition CathodeWrite.cpp:12