Peano
Loading...
Searching...
No Matches
tarch::reader::PeanoTextPatchFileReader Class Reference

Read a Peano patch file back into memory. More...

#include <PeanoTextPatchFileReader.h>

Inheritance diagram for tarch::reader::PeanoTextPatchFileReader:

Data Structures

struct  Content
 Whole content of a file. More...
 
struct  Header
 Information from the first lines of a file. More...
 
struct  Patch
 One patch of the file. More...
 

Public Types

enum class  Format { ASCII , Binary }
 

Public Member Functions

virtual ~PeanoTextPatchFileReader ()=default
 
Content read (const std::string &fileName) const
 Read the whole file.
 

Static Public Member Functions

static Header readHeader (const std::string &fileName)
 Read only the header of a file.
 

Protected Member Functions

virtual void readValues (std::istream &in, int numberOfValues, std::vector< double > &values) const
 Read the quantities of one patch.
 
virtual Format getFormat () const
 Format this reader supports.
 

Detailed Description

Read a Peano patch file back into memory.

The reader complements tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter and tarch::plotter::griddata::blockstructured::PeanoBinaryPatchFileWriter. The file format is described in Visualisation. This class reads files with format ASCII, i.e. files where the quantities of a patch are written as text. tarch::reader::PeanoBinaryPatchFileReader extends it for format Binary.

Which reader to use

Both formats share the whole structure of the file but the quantities of the patches. Therefore, the routine read() is the same for both readers and the subclass only overwrites readValues(). To find out which reader is the right one, call readHeader() first. It looks at the first lines of the file only, i.e. it is cheap.

Scope

The reader reads the cell data of a file, i.e. the cell-values of the patches. It does not read vertex data and it ignores the mappings.

Definition at line 40 of file PeanoTextPatchFileReader.h.

Member Enumeration Documentation

◆ Format

Enumerator
ASCII 
Binary 

Definition at line 42 of file PeanoTextPatchFileReader.h.

Constructor & Destructor Documentation

◆ ~PeanoTextPatchFileReader()

virtual tarch::reader::PeanoTextPatchFileReader::~PeanoTextPatchFileReader ( )
virtualdefault

Member Function Documentation

◆ getFormat()

virtual Format tarch::reader::PeanoTextPatchFileReader::getFormat ( ) const
protectedvirtual

Format this reader supports.

Reimplemented in tarch::reader::PeanoBinaryPatchFileReader.

◆ read()

Content tarch::reader::PeanoTextPatchFileReader::read ( const std::string &  fileName) const

Read the whole file.

The routine terminates the application if it cannot open the file, if the file claims a format other than the one the reader supports, or if the file is corrupted.

◆ readHeader()

static Header tarch::reader::PeanoTextPatchFileReader::readHeader ( const std::string &  fileName)
static

Read only the header of a file.

This is the light-touch routine: It runs through the first lines of the file until it has found the dimensions and does not parse any patch. Use it to find out which reader to instantiate.

A file without a format line is an ASCII file. The routine terminates the application if it cannot open the file.

◆ readValues()

virtual void tarch::reader::PeanoTextPatchFileReader::readValues ( std::istream &  in,
int  numberOfValues,
std::vector< double > &  values 
) const
protectedvirtual

Read the quantities of one patch.

The routine is called after the line begin cell-values has been read. It has to leave the stream such that the next line to be read is the line end cell-values.

Parameters
inStream of the file, opened in binary mode.
numberOfValuesNumber of doubles the patch holds. Derived from the cell metadata and the dimensions.
valuesOutput. Is cleared first.

Reimplemented in tarch::reader::PeanoBinaryPatchFileReader.


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