OpenWalnut  1.5.0dev
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Friends | List of all members
WReaderFiberVTK Class Reference

Reads fibers from a VTK file. More...

#include <WReaderFiberVTK.h>

+ Inheritance diagram for WReaderFiberVTK:
+ Collaboration diagram for WReaderFiberVTK:

Public Member Functions

 WReaderFiberVTK (std::string fname)
 Constructs and makes a new VTK reader for separate thread start. More...
 
virtual ~WReaderFiberVTK () throw ()
 Destroys this instance and closes the file. More...
 
virtual std::shared_ptr< WDataSetFibersread ()
 Reads the fiber 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

void readHeader ()
 Read VTK header from file. More...
 
void readPoints ()
 Read VTK POINTS field from input stream. More...
 
void readValues ()
 Read VTK VALUES field from input stream. More...
 
void readLines ()
 Read VTK LINES field from input stream. More...
 

Protected Attributes

std::vector< std::string > m_header
 VTK header of the read file. More...
 
std::shared_ptr< std::vector< float > > m_points
 Stores for every point its x,y and z float value successivley. More...
 
std::shared_ptr< std::vector< size_t > > m_fiberStartIndices
 Stores the start indices (in the point array) for every fiber. More...
 
std::shared_ptr< std::vector< size_t > > m_fiberLengths
 Stores the length of every fiber. More...
 
WDataSetFibers::VertexParemeterArray m_fiberParameters
 additional colors if found in file. More...
 
std::shared_ptr< std::vector< size_t > > m_pointFiberMapping
 Stores for every point the fiber where it belongs to. 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 Member Functions

std::string getLine (const std::string &desc)
 Reads the next line from current position in stream of the fiber VTK file. More...
 
template<typename T >
getLexicalCast (std::string stringValue, const std::string &errMsg) const
 Try to cast from the given string to the template value T. More...
 

Friends

class WReaderFiberVTKTest
 Only UnitTests may be friends. More...
 

Detailed Description

Reads fibers from a VTK file.

For VTK just see http://www.vtk.org. Currently only a subset of the legacy format is supported: MedInria's Fib-VTK format. The byte order of the files is assumed to be big endian by default.

Definition at line 49 of file WReaderFiberVTK.h.

Constructor & Destructor Documentation

◆ WReaderFiberVTK()

WReaderFiberVTK::WReaderFiberVTK ( std::string  fname)
explicit

Constructs and makes a new VTK reader for separate thread start.

Parameters
fnameFile name where to read data from
Exceptions
WDHNoSuchFile

Definition at line 44 of file WReaderFiberVTK.cpp.

◆ ~WReaderFiberVTK()

WReaderFiberVTK::~WReaderFiberVTK ( )
throw (
)
virtual

Destroys this instance and closes the file.

Definition at line 49 of file WReaderFiberVTK.cpp.

Member Function Documentation

◆ getLexicalCast()

template<typename T >
T WReaderFiberVTK::getLexicalCast ( std::string  stringValue,
const std::string &  errMsg 
) const
inlineprivate

Try to cast from the given string to the template value T.

If the cast fails a WDHParseError is thrown.

Exceptions
WDHParseError
Parameters
stringValueThe string to cast from
errMsgError message incase the cast fails
Returns
The casted value from the given string.

Definition at line 146 of file WReaderFiberVTK.h.

References WReader::m_fname.

◆ getLine()

std::string WReaderFiberVTK::getLine ( const std::string &  desc)
private

Reads the next line from current position in stream of the fiber VTK file.

Parameters
descIn case of trouble while reading, this gives information in the error message about what was tried to read
Exceptions
WDHIOFailure,WDHParseError
Returns
Next line as string.

Definition at line 220 of file WReaderFiberVTK.cpp.

References WReader::m_fname, and m_ifs.

Referenced by readHeader(), readLines(), readPoints(), and readValues().

+ Here is the caller graph for this function:

◆ read()

std::shared_ptr< WDataSetFibers > WReaderFiberVTK::read ( )
virtual

Reads the fiber file and creates a dataset out of it.

Returns
Reference to the dataset.

Definition at line 53 of file WReaderFiberVTK.cpp.

References m_fiberLengths, m_fiberParameters, m_fiberStartIndices, WReader::m_fname, m_ifs, m_pointFiberMapping, m_points, readHeader(), readLines(), readPoints(), and readValues().

+ Here is the call graph for this function:

◆ readHeader()

void WReaderFiberVTK::readHeader ( )
protected

Read VTK header from file.

Exceptions
WDHIOFailure,WDHParseError

Definition at line 75 of file WReaderFiberVTK.cpp.

References wlog::error(), getLine(), WReader::m_fname, m_header, string_utils::toString(), and wlog::warn().

Referenced by read().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readLines()

void WReaderFiberVTK::readLines ( )
protected

Read VTK LINES field from input stream.

Definition at line 138 of file WReaderFiberVTK.cpp.

References getLine(), m_fiberLengths, m_fiberStartIndices, m_ifs, m_pointFiberMapping, string_utils::tokenize(), and string_utils::toUpper().

Referenced by read().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readPoints()

void WReaderFiberVTK::readPoints ( )
protected

Read VTK POINTS field from input stream.

Definition at line 108 of file WReaderFiberVTK.cpp.

References getLine(), m_ifs, m_pointFiberMapping, m_points, string_utils::tokenize(), and string_utils::toLower().

Referenced by read().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readValues()

void WReaderFiberVTK::readValues ( )
protected

Read VTK VALUES field from input stream.

Definition at line 183 of file WReaderFiberVTK.cpp.

References wlog::debug(), getLine(), m_fiberParameters, m_ifs, string_utils::tokenize(), and string_utils::toLower().

Referenced by read().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ WReaderFiberVTKTest

friend class WReaderFiberVTKTest
friend

Only UnitTests may be friends.

Definition at line 54 of file WReaderFiberVTK.h.

Member Data Documentation

◆ m_fiberLengths

std::shared_ptr< std::vector< size_t > > WReaderFiberVTK::m_fiberLengths
protected

Stores the length of every fiber.

Definition at line 110 of file WReaderFiberVTK.h.

Referenced by read(), and readLines().

◆ m_fiberParameters

WDataSetFibers::VertexParemeterArray WReaderFiberVTK::m_fiberParameters
protected

additional colors if found in file.

Definition at line 112 of file WReaderFiberVTK.h.

Referenced by read(), and readValues().

◆ m_fiberStartIndices

std::shared_ptr< std::vector< size_t > > WReaderFiberVTK::m_fiberStartIndices
protected

Stores the start indices (in the point array) for every fiber.

Definition at line 108 of file WReaderFiberVTK.h.

Referenced by read(), and readLines().

◆ m_header

std::vector< std::string > WReaderFiberVTK::m_header
protected

VTK header of the read file.

Definition at line 99 of file WReaderFiberVTK.h.

Referenced by readHeader().

◆ m_ifs

std::shared_ptr< std::ifstream > WReaderFiberVTK::m_ifs
protected

Pointer to the input file stream reader.

Definition at line 121 of file WReaderFiberVTK.h.

Referenced by getLine(), read(), readLines(), readPoints(), and readValues().

◆ m_pointFiberMapping

std::shared_ptr< std::vector< size_t > > WReaderFiberVTK::m_pointFiberMapping
protected

Stores for every point the fiber where it belongs to.

Note
This vector has as many components as there are points, hence its length is just a third of the length of the points vector.

Definition at line 119 of file WReaderFiberVTK.h.

Referenced by read(), readLines(), and readPoints().

◆ m_points

std::shared_ptr< std::vector< float > > WReaderFiberVTK::m_points
protected

Stores for every point its x,y and z float value successivley.

Note
The i'th point starts at the 3*i index since every point consumes 3 elements.

Definition at line 106 of file WReaderFiberVTK.h.

Referenced by read(), and readPoints().


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