FibreReader< DIM > Class Template Reference

#include <FibreReader.hpp>

Collaboration diagram for FibreReader< DIM >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 FibreReader (const FileFinder &rFileFinder, FibreFileType fibreFileType)
 ~FibreReader ()
void GetFibreSheetAndNormalMatrix (unsigned fibreIndex, c_matrix< double, DIM, DIM > &rFibreMatrix, bool checkOrthogonality=true)
void GetFibreVector (unsigned fibreIndex, c_vector< double, DIM > &rFibreVector, bool checkNormalised=true)
unsigned GetNumLinesOfData ()
void GetAllAxi (std::vector< c_vector< double, DIM > > &direction)
void GetAllOrtho (std::vector< c_vector< double, DIM > > &first_direction, std::vector< c_vector< double, DIM > > &second_direction, std::vector< c_vector< double, DIM > > &third_direction)
bool IsBinary ()

Private Member Functions

unsigned GetTokensAtNextLine ()
void ReadNumLinesOfDataFromFile ()

Private Attributes

std::ifstream mDataFile
std::string mFilePath
unsigned mNumLinesOfData
bool mFileIsBinary
unsigned mNumItemsPerLine
unsigned mNextIndex
std::vector< doublemTokens

Detailed Description

template<unsigned DIM>
class FibreReader< DIM >

A class for reading .axi files (files which define the fibre direction for each element) and .ortho files (files which define the fibre, sheet and normal directions for each element.

Definition at line 61 of file FibreReader.hpp.


Constructor & Destructor Documentation

template<unsigned DIM>
FibreReader< DIM >::FibreReader ( const FileFinder rFileFinder,
FibreFileType  fibreFileType 
) [inline]

Create a new FibreReader.

Parameters:
rFileFinder the path to the fibre direction file
fibreFileType AXISYM or ORTHO depending on type of file to be read

Definition at line 42 of file FibreReader.cpp.

References EXCEPTION, FileFinder::GetAbsolutePath(), FibreReader< DIM >::mDataFile, FibreReader< DIM >::mFilePath, FibreReader< DIM >::mNumItemsPerLine, FibreReader< DIM >::mTokens, and FibreReader< DIM >::ReadNumLinesOfDataFromFile().

template<unsigned DIM>
FibreReader< DIM >::~FibreReader (  )  [inline]

Destructor closes file.

Definition at line 68 of file FibreReader.cpp.

References FibreReader< DIM >::mDataFile.


Member Function Documentation

template<unsigned DIM>
void FibreReader< DIM >::GetAllAxi ( std::vector< c_vector< double, DIM > > &  direction  )  [inline]

Get every line of a fibre file (axi-symmetric) in vector of vectors format. This is useful for adding to a visualizer. (Do not use with GetNext...)

Parameters:
direction an empty vector which will be filled with data from file

Definition at line 74 of file FibreReader.cpp.

References EXCEPTION, FibreReader< DIM >::GetFibreVector(), FibreReader< DIM >::mNumItemsPerLine, and FibreReader< DIM >::mNumLinesOfData.

Referenced by FibreConverter::Convert().

template<unsigned DIM>
void FibreReader< DIM >::GetAllOrtho ( std::vector< c_vector< double, DIM > > &  first_direction,
std::vector< c_vector< double, DIM > > &  second_direction,
std::vector< c_vector< double, DIM > > &  third_direction 
) [inline]

Get every line of a fibre file (orthotropic) in vector of vectors format. This is useful for adding to a visualizer. (Do not use with GetNext...)

Parameters:
first_direction an empty vector which will be filled with data from file
second_direction an empty vector which will be filled with data from file
third_direction an empty vector which will be filled with data from file (or will remain empty in 2D)

Definition at line 91 of file FibreReader.cpp.

References EXCEPTION, FibreReader< DIM >::GetFibreSheetAndNormalMatrix(), FibreReader< DIM >::mNumItemsPerLine, and FibreReader< DIM >::mNumLinesOfData.

Referenced by FibreConverter::Convert().

template<unsigned DIM>
void FibreReader< DIM >::GetFibreSheetAndNormalMatrix ( unsigned  fibreIndex,
c_matrix< double, DIM, DIM > &  rFibreMatrix,
bool  checkOrthogonality = true 
) [inline]

Read a fibre direction matrix from the file. Must only be used when reading an orthotropic file. These have lines of the form

  fibre0 fibre1 fibre2 sheet0 sheet1 sheet2 normal0 normal1 normal2

which are converted to the matrix

     [ fibre0   sheet0   normal0  ]
     [ fibre1   sheet1   normal1  ]
     [ fibre2   sheet2   normal2  ]
Parameters:
fibreIndex which fibre vector to read. Note that vectors must be read in monotonically increasing order, so subsequent calls to this method must always pass a strictly greater index. They may skip vectors, however.
rFibreMatrix matrix to be filled in
checkOrthogonality if true, checks if the matrix is orthogonal and throws an exception if not

Definition at line 125 of file FibreReader.cpp.

References EXCEPTION, FibreReader< DIM >::GetTokensAtNextLine(), FibreReader< DIM >::mDataFile, FibreReader< DIM >::mFileIsBinary, FibreReader< DIM >::mFilePath, FibreReader< DIM >::mNextIndex, FibreReader< DIM >::mNumItemsPerLine, and FibreReader< DIM >::mTokens.

Referenced by FibreReader< DIM >::GetAllOrtho(), and AbstractCardiacMechanicsSolver< ELASTICITY_SOLVER, DIM >::SetVariableFibreSheetDirections().

template<unsigned DIM>
void FibreReader< DIM >::GetFibreVector ( unsigned  fibreIndex,
c_vector< double, DIM > &  rFibreVector,
bool  checkNormalised = true 
) [inline]

Read a fibre direction vector from the file. Must only be used when reading an axisymmetric file. These have lines of the form

  fibre0 fibre1 fibre2
Parameters:
fibreIndex which fibre vector to read. Note that vectors must be read in monotonically increasing order, so subsequent calls to this method must always pass a strictly greater index. They may skip vectors, however.
rFibreVector vector to be filled in
checkNormalised if true, checks if the read vector is normalised and throws an exception if not

Definition at line 197 of file FibreReader.cpp.

References EXCEPTION, FibreReader< DIM >::GetTokensAtNextLine(), FibreReader< DIM >::mDataFile, FibreReader< DIM >::mFileIsBinary, FibreReader< DIM >::mFilePath, FibreReader< DIM >::mNextIndex, FibreReader< DIM >::mNumItemsPerLine, and FibreReader< DIM >::mTokens.

Referenced by FibreReader< DIM >::GetAllAxi().

template<unsigned DIM>
unsigned FibreReader< DIM >::GetNumLinesOfData (  )  [inline]
Returns:
the number of lines of data in the file - this is the value read from the first line.

Definition at line 155 of file FibreReader.hpp.

References FibreReader< DIM >::mNumLinesOfData.

Referenced by AbstractCardiacMechanicsSolver< ELASTICITY_SOLVER, DIM >::SetVariableFibreSheetDirections().

template<unsigned DIM>
unsigned FibreReader< DIM >::GetTokensAtNextLine (  )  [inline, private]

Read a line of numbers from mDataFile. Sets up the member variable mTokens with the data in the next line.

Returns:
the number of data entries put into mTokens

Definition at line 248 of file FibreReader.cpp.

References EXCEPTION, FibreReader< DIM >::mDataFile, FibreReader< DIM >::mFilePath, FibreReader< DIM >::mNumItemsPerLine, and FibreReader< DIM >::mTokens.

Referenced by FibreReader< DIM >::GetFibreSheetAndNormalMatrix(), and FibreReader< DIM >::GetFibreVector().

template<unsigned DIM>
bool FibreReader< DIM >::IsBinary (  )  [inline]
Returns:
Whether the fibre file contains binary data.

Definition at line 185 of file FibreReader.hpp.

References FibreReader< DIM >::mFileIsBinary.

template<unsigned DIM>
void FibreReader< DIM >::ReadNumLinesOfDataFromFile (  )  [inline, private]

Read number of elements from mDataFile. Note: Must be called before GetTokensAtNextLine (it assumes that it's reading the first line).

Definition at line 305 of file FibreReader.cpp.

References EXCEPTION, FibreReader< DIM >::mDataFile, FibreReader< DIM >::mFileIsBinary, and FibreReader< DIM >::mNumLinesOfData.

Referenced by FibreReader< DIM >::FibreReader().


Member Data Documentation

template<unsigned DIM>
std::ifstream FibreReader< DIM >::mDataFile [private]
template<unsigned DIM>
bool FibreReader< DIM >::mFileIsBinary [private]
template<unsigned DIM>
std::string FibreReader< DIM >::mFilePath [private]
template<unsigned DIM>
unsigned FibreReader< DIM >::mNextIndex [private]

The next index we expect to read from the file.

Definition at line 79 of file FibreReader.hpp.

Referenced by FibreReader< DIM >::GetFibreSheetAndNormalMatrix(), and FibreReader< DIM >::GetFibreVector().

template<unsigned DIM>
unsigned FibreReader< DIM >::mNumItemsPerLine [private]
template<unsigned DIM>
unsigned FibreReader< DIM >::mNumLinesOfData [private]

Number of lines of data in the file, read from the first line of the file

Definition at line 71 of file FibreReader.hpp.

Referenced by FibreReader< DIM >::GetAllAxi(), FibreReader< DIM >::GetAllOrtho(), FibreReader< DIM >::GetNumLinesOfData(), and FibreReader< DIM >::ReadNumLinesOfDataFromFile().

template<unsigned DIM>
std::vector<double> FibreReader< DIM >::mTokens [private]

Vector which entries read from a line in a file is put into.

Definition at line 82 of file FibreReader.hpp.

Referenced by FibreReader< DIM >::FibreReader(), FibreReader< DIM >::GetFibreSheetAndNormalMatrix(), FibreReader< DIM >::GetFibreVector(), and FibreReader< DIM >::GetTokensAtNextLine().


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

Generated by  doxygen 1.6.2