ug4
ug::GridReaderVTU Class Reference

Grants read access to vtu (vtk) files. More...

#include <file_io_vtu.h>

Classes

struct  GridEntry
 
struct  SubsetHandlerEntry
 

Public Member Functions

const char * get_grid_name (size_t index) const
 returns the name of the i-th grid More...
 
const char * get_subset_handler_name (size_t refGridIndex, size_t subsetHandlerIndex) const
 returns the name of the given subset handler More...
 
template<class TPositionAttachment >
bool grid (Grid &gridOut, size_t index, TPositionAttachment &aPos)
 returns the i-th grid. More...
 
 GridReaderVTU ()
 
size_t num_grids () const
 returns the number of grids in the given file More...
 
size_t num_subset_handlers (size_t refGridIndex) const
 returns the number of subset handlers for the given grid More...
 
bool parse_file (const char *filename)
 parses an xml file More...
 
bool subset_handler (ISubsetHandler &shOut, size_t refGridIndex, size_t subsetHandlerIndex)
 fills the given subset-handler More...
 
virtual ~GridReaderVTU ()
 

Static Public Member Functions

static std::string const getRegionOfInterestIdentifyer ()
 
static void setRegionOfInterestIdentifier (std::string const &regOfInt)
 

Protected Member Functions

template<class T >
void check_indices (std::vector< T > &inds, size_t first, size_t num, size_t max)
 
bool create_cells (std::vector< GridObject * > &cellsOut, Grid &grid, rapidxml::xml_node<> *node, std::vector< Vertex * > vertices, size_t pieceVrtOffset)
 
template<class TAAPos >
bool create_vertices (std::vector< Vertex * > &vrtsOut, Grid &grid, rapidxml::xml_node<> *vrtNode, TAAPos aaPos)
 creates vertices from a vertex-node. More...
 
rapidxml::xml_node * find_child_node_by_argument_value (rapidxml::xml_node<> *parent, const char *nodeName, const char *argName, const char *argValue)
 
virtual bool new_document_parsed ()
 initializes internal arrays More...
 
template<class T >
void read_scalar_data (std::vector< T > &dataOut, rapidxml::xml_node<> *dataNode, bool clearData=true)
 
void trafoDblVec2Int (std::vector< double > const &dblVec, std::vector< int > &intVec)
 

Protected Attributes

rapidxml::xml_document m_doc
 the xml_document which stores the data More...
 
std::vector< GridEntrym_entries
 holds grids which already have been created More...
 
std::string m_filename
 stores the file-name More...
 

Static Protected Attributes

static std::string m_regionOfInterest = "regions"
 

Detailed Description

Grants read access to vtu (vtk) files.

Before any data can be retrieved using the get_* methods, a file has to be successfully loaded using load_file.

Todo:
: Improve performance by using in-situ stringstreams during element creation.

Constructor & Destructor Documentation

◆ GridReaderVTU()

ug::GridReaderVTU::GridReaderVTU ( )

◆ ~GridReaderVTU()

ug::GridReaderVTU::~GridReaderVTU ( )
virtual

Member Function Documentation

◆ check_indices()

template<class T >
void ug::GridReaderVTU::check_indices ( std::vector< T > &  inds,
size_t  first,
size_t  num,
size_t  max 
)
protected

References UG_COND_THROW.

Referenced by create_cells().

◆ create_cells()

bool ug::GridReaderVTU::create_cells ( std::vector< GridObject * > &  cellsOut,
Grid grid,
rapidxml::xml_node<> *  node,
std::vector< Vertex * >  vertices,
size_t  pieceVrtOffset 
)
protected

◆ create_vertices()

template<class TAAPos >
bool ug::GridReaderVTU::create_vertices ( std::vector< Vertex * > &  vrtsOut,
Grid grid,
rapidxml::xml_node<> *  vrtNode,
TAAPos  aaPos 
)
protected

creates vertices from a vertex-node.

if aaPos has more coordinates per vertex than the vrtNode, 0's will be appended. If it has less, unused coordinates will be ignored.

References ug::Grid::create(), UG_COND_THROW, and UG_LOG.

◆ find_child_node_by_argument_value()

xml_node * ug::GridReaderVTU::find_child_node_by_argument_value ( rapidxml::xml_node<> *  parent,
const char *  nodeName,
const char *  argName,
const char *  argValue 
)
protected

Referenced by subset_handler().

◆ get_grid_name()

const char * ug::GridReaderVTU::get_grid_name ( size_t  index) const

returns the name of the i-th grid

References m_entries, and num_grids().

◆ get_subset_handler_name()

const char * ug::GridReaderVTU::get_subset_handler_name ( size_t  refGridIndex,
size_t  subsetHandlerIndex 
) const

returns the name of the given subset handler

References m_entries, num_grids(), and ug::GridReaderVTU::GridEntry::subsetHandlerEntries.

Referenced by subset_handler().

◆ getRegionOfInterestIdentifyer()

static std::string const ug::GridReaderVTU::getRegionOfInterestIdentifyer ( )
inlinestatic

References m_regionOfInterest.

◆ grid()

template<class TPositionAttachment >
bool ug::GridReaderVTU::grid ( Grid gridOut,
size_t  index,
TPositionAttachment &  aPos 
)

returns the i-th grid.

TPositionAttachments value type has to be compatible with MathVector. Make sure that a file has already been loaded.

References ug::Grid::attach_to_vertices(), ug::Grid::get_options(), ug::GRIDOPT_NONE, ug::Grid::has_vertex_attachment(), ug::Grid::set_options(), UG_COND_THROW, UG_LOG, and boost::vertices().

Referenced by create_cells(), and ug::LoadGridFromVTU().

◆ new_document_parsed()

bool ug::GridReaderVTU::new_document_parsed ( )
protectedvirtual

initializes internal arrays

searches for all grid-nodes and stores, resizes m_entries and stores the node for each entry.

If you create your own version of this method, don't forget to call the base-class implementation!

References m_doc, m_entries, ug::GridReaderVTU::GridEntry::subsetHandlerEntries, and UG_COND_THROW.

Referenced by parse_file().

◆ num_grids()

size_t ug::GridReaderVTU::num_grids ( ) const
inline

returns the number of grids in the given file

References m_entries.

Referenced by get_grid_name(), get_subset_handler_name(), and ug::LoadGridFromVTU().

◆ num_subset_handlers()

size_t ug::GridReaderVTU::num_subset_handlers ( size_t  refGridIndex) const

returns the number of subset handlers for the given grid

References m_entries, and UG_LOG.

◆ parse_file()

bool ug::GridReaderVTU::parse_file ( const char *  filename)

parses an xml file

References m_doc, m_filename, m_regionOfInterest, and new_document_parsed().

Referenced by ug::LoadGridFromVTU().

◆ read_scalar_data()

template<class T >
void ug::GridReaderVTU::read_scalar_data ( std::vector< T > &  dataOut,
rapidxml::xml_node<> *  dataNode,
bool  clearData = true 
)
protected

Referenced by create_cells(), and subset_handler().

◆ setRegionOfInterestIdentifier()

static void ug::GridReaderVTU::setRegionOfInterestIdentifier ( std::string const &  regOfInt)
inlinestatic

References m_regionOfInterest.

◆ subset_handler()

◆ trafoDblVec2Int()

void ug::GridReaderVTU::trafoDblVec2Int ( std::vector< double > const &  dblVec,
std::vector< int > &  intVec 
)
protected

Referenced by subset_handler().

Member Data Documentation

◆ m_doc

rapidxml::xml_document ug::GridReaderVTU::m_doc
protected

the xml_document which stores the data

Referenced by new_document_parsed(), and parse_file().

◆ m_entries

std::vector<GridEntry> ug::GridReaderVTU::m_entries
protected

holds grids which already have been created

Referenced by get_grid_name(), get_subset_handler_name(), new_document_parsed(), num_grids(), num_subset_handlers(), and subset_handler().

◆ m_filename

std::string ug::GridReaderVTU::m_filename
protected

stores the file-name

Referenced by create_cells(), parse_file(), and subset_handler().

◆ m_regionOfInterest

std::string ug::GridReaderVTU::m_regionOfInterest = "regions"
staticprotected

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