MOAB: Mesh Oriented datABase
(version 5.4.1)
|
#include <ReadSparseTag.h>
Public Member Functions | |
ReadSparseTag (const smoab::CellSets &mSets, const smoab::Range &cells, const smoab::Interface &interface) | |
void | fill (vtkIntArray *array, const Tag *cellTag) const |
void | fill (vtkIdTypeArray *array, const Tag *cellTag) const |
Private Member Functions | |
template<typename T > | |
void | fillRawArray (T *sparseTagArray, std::size_t length, const Tag *cellTag) const |
template<typename T > | |
void | singleSetRead (T *sparseTagArray, const std::vector< int > &values, std::size_t length) const |
template<typename T > | |
void | multiSetRead (T *sparseTagArray, const std::vector< int > &values, std::size_t length, int defaultTagValue) const |
Private Attributes | |
const smoab::Interface & | Interface |
const smoab::CellSets & | MeshSets |
const smoab::Range & | Cells |
Definition at line 17 of file ReadSparseTag.h.
smoab::detail::ReadSparseTag::ReadSparseTag | ( | const smoab::CellSets & | mSets, |
const smoab::Range & | cells, | ||
const smoab::Interface & | interface | ||
) | [inline] |
Definition at line 20 of file ReadSparseTag.h.
void smoab::detail::ReadSparseTag::fill | ( | vtkIntArray * | array, |
const Tag * | cellTag | ||
) | const |
Definition at line 49 of file ReadSparseTag.h.
References Cells, fillRawArray(), length(), and moab::Range::size().
Referenced by smoab::DataSetConverter::fill(), multiSetRead(), and singleSetRead().
{ const std::size_t length = this->Cells.size(); array->SetNumberOfValues( length ); int* raw = static_cast< int* >( array->GetVoidPointer( 0 ) ); this->fillRawArray( raw, length, cellTag ); }
void smoab::detail::ReadSparseTag::fill | ( | vtkIdTypeArray * | array, |
const Tag * | cellTag | ||
) | const |
Definition at line 58 of file ReadSparseTag.h.
References Cells, fillRawArray(), length(), and moab::Range::size().
{ const std::size_t length = this->Cells.size(); array->SetNumberOfValues( length ); vtkIdType* raw = static_cast< vtkIdType* >( array->GetVoidPointer( 0 ) ); this->fillRawArray( raw, length, cellTag ); }
void smoab::detail::ReadSparseTag::fillRawArray | ( | T * | sparseTagArray, |
std::size_t | length, | ||
const Tag * | cellTag | ||
) | const [private] |
Definition at line 68 of file ReadSparseTag.h.
References smoab::Interface::getDefaultTagVaue(), smoab::Interface::getMoabTag(), smoab::Interface::getTagData(), MeshSets, multiSetRead(), and singleSetRead().
Referenced by fill().
{ typedef std::vector< int >::const_iterator IdConstIterator; typedef std::vector< int >::iterator IdIterator; typedef smoab::CellSets::const_iterator CellSetIterator; std::vector< int > sparseTagValues( this->MeshSets.size() ); //first off iterate the entities and determine which ones //have moab material ids //todo get proper default value from moab //wrap this area with scope, to remove local variables { const moab::Tag stag = this->Interface.getMoabTag( *sparseTag ); IdIterator tagIds = sparseTagValues.begin(); for( CellSetIterator i = this->MeshSets.begin(); i != this->MeshSets.end(); ++i, ++tagIds ) { //getTagData clobbers defaultValue int defaultValue = this->Interface.getDefaultTagVaue< int >( stag ); *tagIds = this->Interface.getTagData( stag, i->entity(), defaultValue ); } //now determine ids for all entities that don't have materials IdConstIterator maxPos = std::max_element( sparseTagValues.begin(), sparseTagValues.end() ); int maxValue = *maxPos; for( IdIterator i = sparseTagValues.begin(); i != sparseTagValues.end(); ++i ) { if( *i == -1 ) { *i = ++maxValue; } } } if( this->MeshSets.size() == 1 ) { this->singleSetRead( sparseTagArray, sparseTagValues, length ); } else { int defaultValue = this->Interface.getDefaultTagVaue< int >( *sparseTag ); this->multiSetRead( sparseTagArray, sparseTagValues, length, defaultValue ); } }
void smoab::detail::ReadSparseTag::multiSetRead | ( | T * | sparseTagArray, |
const std::vector< int > & | values, | ||
std::size_t | length, | ||
int | defaultTagValue | ||
) | const [private] |
Definition at line 127 of file ReadSparseTag.h.
References moab::Range::begin(), Cells, moab::Range::end(), fill(), MeshSets, smoab::RangeToVector(), and T.
Referenced by fillRawArray().
{ typedef std::vector< smoab::EntityHandle >::const_iterator EntityHandleIterator; typedef std::vector< int >::const_iterator IdConstIterator; typedef smoab::CellSets::const_iterator CellSetIterator; typedef smoab::Range::const_iterator RangeIterator; //create the search structure as a range is really slow to search with //lower_bounds std::vector< smoab::EntityHandle > searchableCells; smoab::RangeToVector( this->Cells, searchableCells ); //pre fill with -1 to mark cells we don't touch, since some cells //might no have a default tag T defaultValue = T( defaultTagValue ); std::fill( sparseTagArray, sparseTagArray + numCells, defaultValue ); EntityHandleIterator s_begin = searchableCells.begin(); EntityHandleIterator s_end = searchableCells.end(); IdConstIterator currentTagValue = sparseTagValues.begin(); for( CellSetIterator i = this->MeshSets.begin(); i != this->MeshSets.end(); ++i, ++currentTagValue ) { T value = static_cast< T >( *currentTagValue ); const smoab::Range& entitiesCells = i->cells(); for( RangeIterator j = entitiesCells.begin(); j != entitiesCells.end(); ++j ) { EntityHandleIterator result = std::lower_bound( s_begin, s_end, *j ); std::size_t newId = std::distance( s_begin, result ); sparseTagArray[newId] = value; } } }
void smoab::detail::ReadSparseTag::singleSetRead | ( | T * | sparseTagArray, |
const std::vector< int > & | values, | ||
std::size_t | length | ||
) | const [private] |
Definition at line 116 of file ReadSparseTag.h.
Referenced by fillRawArray().
const smoab::Range& smoab::detail::ReadSparseTag::Cells [private] |
Definition at line 45 of file ReadSparseTag.h.
Referenced by fill(), and multiSetRead().
const smoab::Interface& smoab::detail::ReadSparseTag::Interface [private] |
Definition at line 43 of file ReadSparseTag.h.
const smoab::CellSets& smoab::detail::ReadSparseTag::MeshSets [private] |
Definition at line 44 of file ReadSparseTag.h.
Referenced by fillRawArray(), and multiSetRead().