OpenWalnut
1.5.0dev
|
Reads simple VTK files. More...
#include <WReaderVTK.h>
Public Member Functions | |
WReaderVTK (std::string fname) | |
Constructs and makes a new VTK reader for separate thread start. More... | |
virtual | ~WReaderVTK () throw () |
Destroys this instance and closes the file. More... | |
virtual std::shared_ptr< WDataSet > | read () |
Reads the data file and creates a dataset out of it. More... | |
Public Member Functions inherited from WReader | |
WReader (std::string fname) | |
Creates a read object for file reading. More... | |
OW_API_DEPRECATED void | setFileName (std::string fname) |
Reset the file name and checks if it exists. More... | |
void | setFilename (std::string fname) |
Reset the file name and checks if it exists. More... | |
Protected Member Functions | |
bool | readHeader () |
Read VTK header from file. More... | |
std::shared_ptr< WGridRegular3D > | readStructuredPoints () |
Read VTK Domain specification and create a matching grid. More... | |
std::shared_ptr< WGridRegular3D > | readRectilinearGrid () |
Read VTK Domain specification and create a matching grid. More... | |
std::shared_ptr< WValueSetBase > | readData (std::shared_ptr< WGridRegular3D > const &grid) |
Read domain information for structured points. More... | |
std::shared_ptr< WValueSetBase > | readScalars (size_t nbScalars, const std::string &name) |
Read VTK SCALARS field. More... | |
std::shared_ptr< WValueSetBase > | readVectors (size_t nbVectors, const std::string &name) |
Read VTK SCALARS field. More... | |
std::shared_ptr< WValueSetBase > | readHARDI (std::size_t nbPoints, std::size_t nbGradients, const std::string &) |
Read HARDI data from the file. More... | |
std::shared_ptr< WValueSetBase > | readTensors (size_t nbTensors, const std::string &name) |
Read VTK TENSORS field. More... | |
Protected Attributes | |
std::vector< std::string > | m_header |
VTK header of the read file. More... | |
std::shared_ptr< std::ifstream > | m_ifs |
Pointer to the input file stream reader. More... | |
Protected Attributes inherited from WReader | |
std::string | m_fname |
Absolute path of the file to read from. More... | |
Private Types | |
enum | DomainType { STRUCTURED_POINTS , RECTILINEAR_GRID , UNSUPPORTED_DOMAIN } |
The types of domains supported so far. More... | |
enum | AttributeType { SCALARS , VECTORS , TENSORS , ARRAYS , UNSUPPORTED_ATTRIBUTE } |
The types of attributes supported so far. More... | |
Private Member Functions | |
std::string | getLine (const std::string &desc) |
Reads the next line from current position in stream of the fiber VTK file. More... | |
void | readCoords (std::string const &name, std::size_t dim, std::vector< float > &coords) |
Read the coordinates of the dataset's domain. More... | |
void | readValuesFromFile (std::vector< float > &values, std::size_t numValues) |
Read values from the file. More... | |
std::shared_ptr< std::vector< WVector3d > > | readGradients () |
Read gradients from a gradients file which has the same basename as the data file and ends in .bvec. More... | |
template<typename T > | |
T | getLexicalCast (std::string stringValue, const std::string &errMsg) const |
Try to cast from the given string to the template value T. More... | |
Private Attributes | |
std::shared_ptr< WDataSet > | m_newDataSet |
reference to the currently loading data set More... | |
std::shared_ptr< WGridRegular3D > | m_newGrid |
reference to the currently loading grid More... | |
bool | m_isASCII |
internal flag whether we read ascii or binary More... | |
DomainType | m_domainType |
The type of domain specified in the file. More... | |
AttributeType | m_attributeType |
The type of the attributes first read from the file. More... | |
Friends | |
class | WReaderVTKTest |
allow member access by the test class More... | |
Reads simple VTK files.
For VTK just see http://www.vtk.org. Currently only a subset of the legacy format is supported.
Formats read: Original ASCII and BINARY. The xml format is not supported. Grids read are: STRUCTURED_POINTS, RECTILINEAR_GRID is interpreted as a grid with equal spacing per coordinate axis Data types read: SCALARS, VECTORS, TENSORS
Endianess is kept as on the platform, so for intel hosts, most files, which are typically stored in little endian, are not readable if they are binary files.
Definition at line 56 of file WReaderVTK.h.
|
private |
The types of attributes supported so far.
Enumerator | |
---|---|
SCALARS | scalar data |
VECTORS | vector data |
TENSORS | tensor data |
ARRAYS | array data |
UNSUPPORTED_ATTRIBUTE | anything else |
Definition at line 181 of file WReaderVTK.h.
|
private |
The types of domains supported so far.
Enumerator | |
---|---|
STRUCTURED_POINTS | structured points |
RECTILINEAR_GRID | rectilinear grid |
UNSUPPORTED_DOMAIN | anything else |
Definition at line 168 of file WReaderVTK.h.
|
explicit |
Constructs and makes a new VTK reader for separate thread start.
fname | File name where to read data from |
WDHNoSuchFile |
Definition at line 49 of file WReaderVTK.cpp.
|
virtual |
Destroys this instance and closes the file.
Definition at line 54 of file WReaderVTK.cpp.
|
inlineprivate |
Try to cast from the given string to the template value T.
If the cast fails a WDHParseError is thrown.
WDHParseError |
stringValue | The string to cast from |
errMsg | Error message incase the cast fails |
Definition at line 266 of file WReaderVTK.h.
References WReader::m_fname.
|
private |
Reads the next line from current position in stream of the fiber VTK file.
desc | In case of trouble while reading, this gives information in the error message about what was tried to read |
WDHIOFailure,WDHParseError |
Definition at line 545 of file WReaderVTK.cpp.
References WReader::m_fname, and m_ifs.
Referenced by readCoords(), readData(), readHARDI(), readHeader(), readRectilinearGrid(), readScalars(), readStructuredPoints(), readTensors(), readValuesFromFile(), and readVectors().
|
virtual |
Reads the data file and creates a dataset out of it.
Definition at line 58 of file WReaderVTK.cpp.
References ARRAYS, wlog::error(), m_attributeType, m_domainType, WReader::m_fname, m_ifs, readData(), readGradients(), readHeader(), readRectilinearGrid(), readStructuredPoints(), RECTILINEAR_GRID, SCALARS, STRUCTURED_POINTS, TENSORS, and VECTORS.
|
private |
Read the coordinates of the dataset's domain.
name | The name to look for in the first line. |
dim | The number of coordinates. |
coords | The resulting vector of coordinates. |
Definition at line 316 of file WReaderVTK.cpp.
References getLine(), readValuesFromFile(), string_utils::tokenize(), and string_utils::toLower().
Referenced by readRectilinearGrid().
|
protected |
Read domain information for structured points.
grid | The grid constructed from the domain information. |
Definition at line 493 of file WReaderVTK.cpp.
References ARRAYS, getLine(), m_attributeType, readHARDI(), readScalars(), readTensors(), readVectors(), SCALARS, TENSORS, string_utils::tokenize(), string_utils::toUpper(), and VECTORS.
Referenced by read().
|
private |
Read gradients from a gradients file which has the same basename as the data file and ends in .bvec.
Definition at line 134 of file WReaderVTK.cpp.
References WReader::m_fname.
Referenced by read().
|
protected |
Read HARDI data from the file.
nbPoints | The number of voxels. |
nbGradients | The number of gradients for this HARDI dataset. |
Definition at line 463 of file WReaderVTK.cpp.
References getLine(), m_ifs, readValuesFromFile(), string_utils::tokenize(), and string_utils::toUpper().
Referenced by readData().
|
protected |
Read VTK header from file.
Sets the m_isASCII member accordingly.
Definition at line 186 of file WReaderVTK.cpp.
References wlog::error(), getLine(), m_domainType, WReader::m_fname, m_header, m_isASCII, RECTILINEAR_GRID, STRUCTURED_POINTS, and wlog::warn().
Referenced by read().
|
protected |
Read VTK Domain specification and create a matching grid.
Definition at line 289 of file WReaderVTK.cpp.
References getLine(), readCoords(), string_utils::tokenize(), string_utils::toLower(), and wlog::warn().
Referenced by read().
|
protected |
Read VTK SCALARS field.
nbScalars | the number of scalars to read |
name | the name of the data set that may be overwritten by information in the scalars line |
Definition at line 368 of file WReaderVTK.cpp.
References getLine(), m_ifs, readValuesFromFile(), string_utils::tokenize(), and string_utils::toUpper().
Referenced by readData().
|
protected |
Read VTK Domain specification and create a matching grid.
Definition at line 245 of file WReaderVTK.cpp.
References getLine(), string_utils::tokenize(), string_utils::toLower(), and WGridTransformOrthoTemplate< T >::translate().
Referenced by read().
|
protected |
Read VTK TENSORS field.
nbTensors | the number of tensors to read |
name | the name of the data set that may be overwritten by information in the tensors line |
Definition at line 418 of file WReaderVTK.cpp.
References ARRAYS, getLine(), m_attributeType, m_ifs, readValuesFromFile(), string_utils::tokenize(), and string_utils::toUpper().
Referenced by readData().
|
private |
Read values from the file.
The m_isASCII flag must be initialized accordingly.
values | The values read from the file. |
numValues | The number of values to read. |
Definition at line 328 of file WReaderVTK.cpp.
References wlog::debug(), getLine(), m_ifs, m_isASCII, and string_utils::tokenize().
Referenced by readCoords(), readHARDI(), readScalars(), readTensors(), and readVectors().
|
protected |
Read VTK SCALARS field.
nbVectors | the number of vectors to read |
name | the name of the data set that may be overwritten by information in the vectors line |
Definition at line 388 of file WReaderVTK.cpp.
References getLine(), m_ifs, readValuesFromFile(), string_utils::tokenize(), and string_utils::toUpper().
Referenced by readData().
|
friend |
allow member access by the test class
Definition at line 59 of file WReaderVTK.h.
|
private |
The type of the attributes first read from the file.
Definition at line 263 of file WReaderVTK.h.
Referenced by read(), readData(), and readTensors().
|
private |
The type of domain specified in the file.
Definition at line 260 of file WReaderVTK.h.
Referenced by read(), and readHeader().
|
protected |
VTK header of the read file.
Definition at line 162 of file WReaderVTK.h.
Referenced by readHeader().
|
protected |
Pointer to the input file stream reader.
Definition at line 164 of file WReaderVTK.h.
Referenced by getLine(), read(), readHARDI(), readScalars(), readTensors(), readValuesFromFile(), and readVectors().
|
private |
internal flag whether we read ascii or binary
Definition at line 257 of file WReaderVTK.h.
Referenced by readHeader(), and readValuesFromFile().
|
private |
reference to the currently loading data set
Definition at line 247 of file WReaderVTK.h.
|
private |
reference to the currently loading grid
Definition at line 252 of file WReaderVTK.h.