OpenImpala
Image-based parallel transport property solver
Loading...
Searching...
No Matches
OpenImpala::DatReader Class Reference

Reads and provides access to raw image data from specific DAT files. More...

#include <DatReader.H>

Public Types

using DataType = std::uint16_t

Public Member Functions

amrex::Box box () const
 Returns the index space Box covering the entire image domain. The Box typically starts at (0,0,0).
 DatReader ()
 Default constructor. Creates an empty reader. Use readFile() later.
 DatReader (const DatReader &)=delete
 DatReader (const std::string &filename)
 Constructs a DatReader and reads data from the specified filename.
int depth () const
 Get depth (Z-dimension) of the dataset in pixels/voxels.
const std::vector< DataType > & getRawData () const
 Get read-only access to the entire raw data vector. Provides direct access but exposes internal storage layout (XYZ order assumed).
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 if indices are invalid.
int height () const
 Get height (Y-dimension) of the dataset in pixels/voxels.
bool isRead () const
 Checks if the reader has successfully read metadata and data.
DatReader & operator= (const DatReader &)=delete
bool readFile (const std::string &filename)
 Reads data from the specified filename into this object.
void threshold (DataType raw_threshold, amrex::iMultiFab &mf) const
 Fills an iMultiFab based on thresholding the raw data.
void threshold (DataType raw_threshold, int value_if_true, int value_if_false, amrex::iMultiFab &mf) const
 Fills an iMultiFab based on thresholding the raw data with custom output values.
int width () const
 Get width (X-dimension) of the dataset in pixels/voxels.
virtual ~DatReader ()=default
 Virtual default destructor.

Detailed Description

Reads and provides access to raw image data from specific DAT files.

This class reads a binary DAT file (assumed format from Heidelberg context, details need verification), stores the raw voxel data, and provides methods to query dimensions and generate thresholded AMReX iMultiFabs.

Warning
The exact DAT file format (data type, endianness, header presence/format, data layout) is assumed and needs verification. This implementation assumes a specific raw binary layout. Endianness might need handling in readFile().
Copying is disabled due to potentially large raw data size.

Member Typedef Documentation

◆ DataType

using OpenImpala::DatReader::DataType = std::uint16_t

Constructor & Destructor Documentation

◆ DatReader() [1/3]

OpenImpala::DatReader::DatReader ( )

Default constructor. Creates an empty reader. Use readFile() later.

◆ DatReader() [2/3]

OpenImpala::DatReader::DatReader ( const std::string & filename)
explicit

Constructs a DatReader and reads data from the specified filename.

Reads the DAT file header (if any, assumed structure) to get dimensions and then reads the raw voxel data. Throws std::runtime_error if the file cannot be opened or read correctly.

Parameters
filenamePath to the DAT file containing the image data.
Exceptions
std::runtime_erroron file open or read errors.

◆ ~DatReader()

virtual OpenImpala::DatReader::~DatReader ( )
virtualdefault

Virtual default destructor.

◆ DatReader() [3/3]

OpenImpala::DatReader::DatReader ( const DatReader & )
delete

Member Function Documentation

◆ box()

amrex::Box OpenImpala::DatReader::box ( ) const

Returns the index space Box covering the entire image domain. The Box typically starts at (0,0,0).

Returns
amrex::Box representing the full image dimensions. Returns empty box if data not read.

◆ depth()

int OpenImpala::DatReader::depth ( ) const

Get depth (Z-dimension) of the dataset in pixels/voxels.

◆ getRawData()

const std::vector< DatReader::DataType > & OpenImpala::DatReader::getRawData ( ) const

Get read-only access to the entire raw data vector. Provides direct access but exposes internal storage layout (XYZ order assumed).

Returns
Constant reference to the internal raw data vector.

◆ getRawValue()

DatReader::DataType OpenImpala::DatReader::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 if indices are invalid.

Parameters
iX-coordinate (0 to width-1).
jY-coordinate (0 to height-1).
kZ-coordinate (0 to depth-1).
Returns
The raw data value at (i,j,k).
Exceptions
std::out_of_rangeif indices are out of bounds.

◆ height()

int OpenImpala::DatReader::height ( ) const

Get height (Y-dimension) of the dataset in pixels/voxels.

◆ isRead()

bool OpenImpala::DatReader::isRead ( ) const

Checks if the reader has successfully read metadata and data.

Returns
true if data is read and the reader is operational, false otherwise.

◆ operator=()

DatReader & OpenImpala::DatReader::operator= ( const DatReader & )
delete

◆ readFile()

bool OpenImpala::DatReader::readFile ( const std::string & filename)

Reads data from the specified filename into this object.

Clears any existing data before reading. Reads header (if any) and raw data. Use this after default construction or to reuse the object for another file.

Parameters
filenamePath to the DAT file.
Returns
true if the file was read successfully, false otherwise. Prints error messages using amrex::Print on failure.

◆ threshold() [1/2]

void OpenImpala::DatReader::threshold ( DataType raw_threshold,
amrex::iMultiFab & mf ) const

Fills an iMultiFab based on thresholding the raw data.

Iterates through the cells of the iMultiFab 'mf'. For each cell (i,j,k), if the corresponding raw data value is greater than 'raw_threshold', sets mf(i,j,k) = 1, otherwise sets it to 0.

Warning
Caller must ensure mf's BoxArray is compatible with the dimensions read from the DAT file (available via box(), width(), etc.). Internal checks might be added in implementation for safety.
Parameters
raw_thresholdThe threshold value (in raw data units).
mfOutput amrex::iMultiFab reference to fill (must be defined).

◆ threshold() [2/2]

void OpenImpala::DatReader::threshold ( DataType raw_threshold,
int value_if_true,
int value_if_false,
amrex::iMultiFab & mf ) const

Fills an iMultiFab based on thresholding the raw data with custom output values.

Iterates through the cells of the iMultiFab 'mf'. For each cell (i,j,k), if the corresponding raw data value is greater than 'raw_threshold', sets mf(i,j,k) = value_if_true, otherwise sets it to value_if_false.

Warning
Caller must ensure mf's BoxArray is compatible with the dimensions.
Parameters
raw_thresholdThe threshold value (in raw data units).
value_if_trueThe integer value to set if raw_data[idx] > raw_threshold.
value_if_falseThe integer value to set otherwise.
mfOutput amrex::iMultiFab reference to fill (must be defined).

◆ width()

int OpenImpala::DatReader::width ( ) const

Get width (X-dimension) of the dataset in pixels/voxels.


The documentation for this class was generated from the following files: