MOAB: Mesh Oriented datABase  (version 5.3.1)
moab::VarLenDenseTag Class Reference

Dense storage of variable-length tag data. More...

#include <VarLenDenseTag.hpp>

+ Inheritance diagram for moab::VarLenDenseTag:
+ Collaboration diagram for moab::VarLenDenseTag:

Public Member Functions

virtual ~VarLenDenseTag ()
virtual TagType get_storage_type () const
virtual ErrorCode release_all_data (SequenceManager *seqman, Error *error_handler, bool delete_pending)
 Remove/clear tag data for all entities.
virtual ErrorCode get_data (const SequenceManager *seqman, Error *error_handler, const EntityHandle *entities, size_t num_entities, void *data) const
 Get tag value for passed entities.
virtual ErrorCode get_data (const SequenceManager *seqman, Error *error_handler, const Range &entities, void *data) const
 Get tag value for passed entities.
virtual ErrorCode get_data (const SequenceManager *seqman, Error *error_handler, const EntityHandle *entities, size_t num_entities, const void **data_ptrs, int *data_lengths) const
 Get tag value for passed entities.
virtual ErrorCode get_data (const SequenceManager *seqman, Error *error_handler, const Range &entities, const void **data_ptrs, int *data_lengths) const
 Get tag value for passed entities.
virtual ErrorCode set_data (SequenceManager *seqman, Error *error_handler, const EntityHandle *entities, size_t num_entities, const void *data)
 Set tag value for passed entities.
virtual ErrorCode set_data (SequenceManager *seqman, Error *error_handler, const Range &entities, const void *data)
 Set tag value for passed entities.
virtual ErrorCode set_data (SequenceManager *seqman, Error *error_handler, const EntityHandle *entities, size_t num_entities, void const *const *data_ptrs, const int *data_lengths)
 Set tag value for passed entities.
virtual ErrorCode set_data (SequenceManager *seqman, Error *error_handler, const Range &entities, void const *const *data_ptrs, const int *data_lengths)
 Set tag value for passed entities.
virtual ErrorCode clear_data (SequenceManager *seqman, Error *error_handler, const EntityHandle *entities, size_t num_entities, const void *value_ptr, int value_len=0)
 Set tag value for passed entities.
virtual ErrorCode clear_data (SequenceManager *seqman, Error *error_handler, const Range &entities, const void *value_ptr, int value_len=0)
 Set tag value for passed entities.
virtual ErrorCode remove_data (SequenceManager *seqman, Error *error_handler, const EntityHandle *entities, size_t num_entities)
 Remove/clear tag data for entities.
virtual ErrorCode remove_data (SequenceManager *seqman, Error *error_handler, const Range &entities)
 Remove/clear tag data for entities.
virtual ErrorCode tag_iterate (SequenceManager *seqman, Error *error_handler, Range::iterator &iter, const Range::iterator &end, void *&data_ptr, bool allocate)
 Access tag data via direct pointer into contiguous blocks.
virtual ErrorCode get_tagged_entities (const SequenceManager *seqman, Range &output_entities, EntityType type=MBMAXTYPE, const Range *intersect=0) const
 Get all tagged entities.
virtual ErrorCode num_tagged_entities (const SequenceManager *seqman, size_t &output_count, EntityType type=MBMAXTYPE, const Range *intersect=0) const
 Count all tagged entities.
virtual ErrorCode find_entities_with_value (const SequenceManager *seqman, Error *error, Range &output_entities, const void *value, int value_bytes=0, EntityType type=MBMAXTYPE, const Range *intersect_entities=0) const
 Get all tagged entities with tag value.
virtual bool is_tagged (const SequenceManager *, EntityHandle h) const
 Check if entity is tagged.
virtual ErrorCode get_memory_use (const SequenceManager *seqman, unsigned long &total, unsigned long &per_entity) const
 Get memory use for tag data.

Static Public Member Functions

static VarLenDenseTagcreate_tag (SequenceManager *seqman, Error *error_handler, const char *name, DataType type, const void *default_value, int default_value_len)

Private Member Functions

 VarLenDenseTag (int array_index, const char *name, DataType type, const void *default_value, int default_value_len)
 VarLenDenseTag (const VarLenDenseTag &)
VarLenDenseTagoperator= (const VarLenDenseTag &)
ErrorCode get_array (SequenceManager *seqman, Error *error_handler, EntityHandle h, VarLenTag *&ptr, size_t &count, bool allocate)
 Get or allocated tag storage.
ErrorCode get_array (const SequenceManager *seqman, Error *error_handler, EntityHandle h, const VarLenTag *&ptr, size_t &count) const
 Get tag storage.
ErrorCode set_data (SequenceManager *seqman, Error *error_handler, const EntityHandle *entities, size_t num_entities, bool one_value, void const *const *pointers, const int *lengths)
 Common implementation of set_data, and clear_data.
ErrorCode set_data (SequenceManager *seqman, Error *error_handler, const Range &entities, bool one_value, void const *const *pointers, const int *lengths)
 Common implementation of set_data, and clear_data.

Private Attributes

int mySequenceArray
 Array index in SequenceManager used to store tag data.
VarLenTag meshValue

Detailed Description

Dense storage of variable-length tag data.

Implement variable-length dense tag.

Definition at line 21 of file VarLenDenseTag.hpp.


Constructor & Destructor Documentation

moab::VarLenDenseTag::VarLenDenseTag ( int  array_index,
const char *  name,
DataType  type,
const void *  default_value,
int  default_value_len 
) [private]

Definition at line 38 of file VarLenDenseTag.cpp.

Referenced by create_tag().

    : TagInfo( name, MB_VARIABLE_LENGTH, type, default_value, default_value_size ), mySequenceArray( index )
{
}

Definition at line 53 of file VarLenDenseTag.cpp.

References mySequenceArray.

{
    assert( mySequenceArray < 0 );
}

Member Function Documentation

ErrorCode moab::VarLenDenseTag::clear_data ( SequenceManager seqman,
Error error_handler,
const EntityHandle entities,
size_t  num_entities,
const void *  value_ptr,
int  value_len = 0 
) [virtual]

Set tag value for passed entities.

Store tag data or update stored tag values.

Parameters:
seqmanPointer to mesh entity database
entitiesEntity handles for which to store tag data
num_entitiesLength of entities array
value_ptrPointer to a single tag value which is to be stored for each of the passed entities.
value_lenLength of tag value in bytes. Ignored for fixed-length tags. Required for variable- length tags.

Implements moab::TagInfo.

Definition at line 333 of file VarLenDenseTag.cpp.

References remove_data(), and set_data().

{
    if( !value_ptr || !value_len )
        return remove_data( seqman, NULL, entities, num_entities );
    else
        return set_data( seqman, NULL, entities, num_entities, true, &value_ptr, &value_len );
}
ErrorCode moab::VarLenDenseTag::clear_data ( SequenceManager seqman,
Error error_handler,
const Range entities,
const void *  value_ptr,
int  value_len = 0 
) [virtual]

Set tag value for passed entities.

Store tag data or update stored tag values.

Parameters:
seqmanPointer to mesh entity database
entitiesEntity handles for which to store tag data
value_ptrPointer to a single tag value which is to be stored for each of the passed entities.
value_lenLength of tag value in bytes. Ignored for fixed-length tags. Required for variable- length tags.

Implements moab::TagInfo.

Definition at line 342 of file VarLenDenseTag.cpp.

References remove_data(), and set_data().

{
    if( !value_ptr || !value_len )
        return remove_data( seqman, NULL, entities );
    else
        return set_data( seqman, NULL, entities, true, &value_ptr, &value_len );
}
VarLenDenseTag * moab::VarLenDenseTag::create_tag ( SequenceManager seqman,
Error error_handler,
const char *  name,
DataType  type,
const void *  default_value,
int  default_value_len 
) [static]

Definition at line 44 of file VarLenDenseTag.cpp.

References MB_SUCCESS, MB_VARIABLE_LENGTH, moab::SequenceManager::reserve_tag_array(), and VarLenDenseTag().

Referenced by moab::Core::tag_get_handle().

{
    int index;
    if( MB_SUCCESS != seqman->reserve_tag_array( error, MB_VARIABLE_LENGTH, index ) ) return NULL;

    return new VarLenDenseTag( index, name, type, default_value, default_value_size );
}
ErrorCode moab::VarLenDenseTag::find_entities_with_value ( const SequenceManager seqman,
Error error,
Range output_entities,
const void *  value,
int  value_bytes = 0,
EntityType  type = MBMAXTYPE,
const Range intersect_entities = 0 
) const [virtual]

Get all tagged entities with tag value.

Get the list of entities which have the specified tag value.

Parameters:
seqmanPointer to entity storage database
output_entitiesResults *appended* to this range
valuePointer to tag value
value_bytesSize of tag value in bytes.
typeOptional entity type. If specified, search is limited to entities of specified type.
intersect_entitiesOptional intersect list. If specified, search is restricted to entities in this list.

Implements moab::TagInfo.

Definition at line 490 of file VarLenDenseTag.cpp.

References moab::TypeSequenceManager::begin(), moab::Range::begin(), moab::Range::const_pair_end(), moab::ByteArrayIterator::data, moab::TypeSequenceManager::end(), moab::SequenceManager::entity_map(), ErrorCode, moab::find_tag_varlen_values_equal(), get_array(), moab::Range::lower_bound(), MB_CHK_ERR, MB_SUCCESS, MBMAXTYPE, mySequenceArray, t, moab::TYPE_FROM_HANDLE(), and moab::type_range().

{
    if( !intersect_entities )
    {
        std::pair< EntityType, EntityType > range = type_range( type );
        TypeSequenceManager::const_iterator i;
        for( EntityType t = range.first; t != range.second; ++t )
        {
            const TypeSequenceManager& map = seqman->entity_map( t );
            for( i = map.begin(); i != map.end(); ++i )
            {
                const void* data = ( *i )->data()->get_tag_data( mySequenceArray );
                if( data )
                {
                    ByteArrayIterator start( ( *i )->data()->start_handle(), data, *this );
                    ByteArrayIterator end( ( *i )->end_handle() + 1, 0, 0 );
                    start += ( *i )->start_handle() - ( *i )->data()->start_handle();
                    find_tag_varlen_values_equal( *this, value, value_bytes, start, end, output_entities );
                }
            }
        }
    }
    else
    {
        const VarLenTag* array;
        size_t count;
        ErrorCode rval;

        Range::const_pair_iterator p = intersect_entities->begin();
        if( type != MBMAXTYPE )
        {
            p = intersect_entities->lower_bound( type );
            assert( TYPE_FROM_HANDLE( p->first ) == type );
        }
        for( ;
             p != intersect_entities->const_pair_end() && ( MBMAXTYPE == type || TYPE_FROM_HANDLE( p->first ) == type );
             ++p )
        {
            EntityHandle start = p->first;
            while( start <= p->second )
            {
                rval = get_array( seqman, error, start, array, count );MB_CHK_ERR( rval );

                if( p->second - start < count - 1 ) count = p->second - start + 1;

                if( array )
                {
                    ByteArrayIterator istart( start, array, *this );
                    ByteArrayIterator iend( start + count, 0, 0 );
                    find_tag_varlen_values_equal( *this, value, value_bytes, istart, iend, output_entities );
                }
                start += count;
            }
        }
    }

    return MB_SUCCESS;
}
ErrorCode moab::VarLenDenseTag::get_array ( SequenceManager seqman,
Error error_handler,
EntityHandle  h,
VarLenTag *&  ptr,
size_t &  count,
bool  allocate 
) [inline, private]

Get or allocated tag storage.

Parameters:
hFirst entity for which to return storage.
ptrPointer to dag storage. This pointer will be set to null and MB_SUCCESS will be returned if the handle is valid but no tag storage has been allocated.
countNumber of consecutive entities for which tag storage is returned. This value will be valid even if null is returned for ptr and indicates the number of consecutive entities for which no tag storage has been allocated.
allocateIf true storage will be allocated and initialized if it has not already been allocated.
Returns:
MB_SUCCESS if handle is valid (regardless of whether or not any tag storage is allocated).

Definition at line 106 of file VarLenDenseTag.cpp.

References moab::SequenceData::allocate_tag_array(), moab::EntitySequence::data(), moab::SequenceData::end_handle(), ErrorCode, moab::SequenceManager::find(), moab::TagInfo::get_name(), moab::SequenceData::get_tag_data(), MB_MEMORY_ALLOCATION_FAILED, MB_SET_ERR, MB_SUCCESS, meshValue, mySequenceArray, moab::not_found(), moab::SequenceData::size(), and moab::SequenceData::start_handle().

Referenced by find_entities_with_value(), get_data(), is_tagged(), remove_data(), and set_data().

{
    EntitySequence* seq = NULL;
    ErrorCode rval      = seqman->find( h, seq );
    if( MB_SUCCESS != rval )
    {
        if( !h )
        {  // Root set
            ptr   = &meshValue;
            count = 1;
            return MB_SUCCESS;
        }
        else
        {
            ptr   = NULL;
            count = 0;
            return not_found( get_name(), h );
        }
    }

    void* mem = seq->data()->get_tag_data( mySequenceArray );
    if( !mem && allocate )
    {
        mem = seq->data()->allocate_tag_array( mySequenceArray, sizeof( VarLenTag ) );
        if( !mem )
        {
            MB_SET_ERR( MB_MEMORY_ALLOCATION_FAILED, "Memory allocation for variable-length dense tag data failed" );
        }

        memset( mem, 0, sizeof( VarLenTag ) * seq->data()->size() );
    }

    ptr   = reinterpret_cast< VarLenTag* >( mem );
    count = seq->data()->end_handle() - h + 1;
    if( ptr ) ptr += h - seq->data()->start_handle();

    return MB_SUCCESS;
}
ErrorCode moab::VarLenDenseTag::get_array ( const SequenceManager seqman,
Error error_handler,
EntityHandle  h,
const VarLenTag *&  ptr,
size_t &  count 
) const [inline, private]

Get tag storage.

Parameters:
hFirst entity for which to return storage.
ptrPointer to dag storage. This pointer will be set to null and MB_SUCCESS will be returned if the handle is valid but no tag storage has been allocated.
countNumber of consecutive entities for which tag storage is returned. This value will be valid even if null is returned for ptr and indicates the number of consecutive entities for which no tag storage has been allocated.
Returns:
MB_SUCCESS if handle is valid (regardless of whether or not any tag storage is allocated).

Definition at line 77 of file VarLenDenseTag.cpp.

References moab::EntitySequence::data(), moab::SequenceData::end_handle(), ErrorCode, moab::SequenceManager::find(), moab::TagInfo::get_name(), moab::SequenceData::get_tag_data(), MB_SUCCESS, meshValue, mySequenceArray, moab::not_found(), and moab::SequenceData::start_handle().

{
    const EntitySequence* seq = NULL;
    ErrorCode rval            = seqman->find( h, seq );
    if( MB_SUCCESS != rval )
    {
        if( !h )
        {  // Root set
            ptr   = &meshValue;
            count = 1;
            return MB_SUCCESS;
        }
        else
        {
            ptr   = NULL;
            count = 0;
            return not_found( get_name(), h );
        }
    }

    const void* mem = seq->data()->get_tag_data( mySequenceArray );
    ptr             = reinterpret_cast< const VarLenTag* >( mem );
    count           = seq->data()->end_handle() - h + 1;
    if( ptr ) ptr += h - seq->data()->start_handle();

    return MB_SUCCESS;
}
ErrorCode moab::VarLenDenseTag::get_data ( const SequenceManager seqman,
Error error_handler,
const EntityHandle entities,
size_t  num_entities,
void *  data 
) const [virtual]

Get tag value for passed entities.

Get tag values for specified entities.

Will fail for variable-length data.

Parameters:
seqmanPointer to mesh entity database
entitiesEntity handles for which to retrieve tag data
num_entitiesLength of entities array
dataPointer to memory in which to store consecutive tag values, one for each passed entity.

Implements moab::TagInfo.

Definition at line 146 of file VarLenDenseTag.cpp.

References moab::TagInfo::get_name(), MB_SET_ERR, and MB_VARIABLE_DATA_LENGTH.

{
    MB_SET_ERR( MB_VARIABLE_DATA_LENGTH, "No size specified for variable-length tag " << get_name() << " data" );
}
ErrorCode moab::VarLenDenseTag::get_data ( const SequenceManager seqman,
Error error_handler,
const Range entities,
void *  data 
) const [virtual]

Get tag value for passed entities.

Get tag values for specified entities.

Will fail for variable-length data.

Parameters:
seqmanPointer to mesh entity database
entitiesEntity handles for which to retrieve tag data
dataPointer to memory in which to store consecutive tag values, one for each passed entity.

Implements moab::TagInfo.

Definition at line 152 of file VarLenDenseTag.cpp.

References moab::TagInfo::get_name(), MB_SET_ERR, and MB_VARIABLE_DATA_LENGTH.

{
    MB_SET_ERR( MB_VARIABLE_DATA_LENGTH, "No size specified for variable-length tag " << get_name() << " data" );
}
ErrorCode moab::VarLenDenseTag::get_data ( const SequenceManager seqman,
Error error_handler,
const EntityHandle entities,
size_t  num_entities,
const void **  data_ptrs,
int *  data_lengths 
) const [virtual]

Get tag value for passed entities.

Get tag values for specified entities.

Parameters:
seqmanPointer to mesh entity database
entitiesEntity handles for which to retrieve tag data
num_entitiesLength of entities array
data_ptrsArray of pointers to tag values, one pointer for each passed entity.
data_lengthsOne value for each entity specifying the length of the tag value for the corresponding entity.

Implements moab::TagInfo.

Definition at line 157 of file VarLenDenseTag.cpp.

References moab::VarLenTag::data(), ErrorCode, get_array(), moab::TagInfo::get_default_value(), moab::TagInfo::get_default_value_size(), moab::TagInfo::get_name(), MB_CHK_ERR, MB_SET_ERR, MB_SUCCESS, MB_VARIABLE_DATA_LENGTH, moab::not_found(), and moab::VarLenTag::size().

{
    if( !lengths )
    {
        MB_SET_ERR( MB_VARIABLE_DATA_LENGTH, "No size specified for variable-length tag " << get_name() << " data" );
    }

    ErrorCode result              = MB_SUCCESS, rval;
    const EntityHandle* const end = entities + num_entities;
    size_t junk                   = 0;
    const VarLenTag* ptr          = NULL;

    for( const EntityHandle* i = entities; i != end; ++i, ++pointers, ++lengths )
    {
        rval = get_array( seqman, NULL, *i, ptr, junk );MB_CHK_ERR( rval );

        if( ptr && ptr->size() )
        {
            *pointers = ptr->data();
            *lengths  = ptr->size();
        }
        else if( get_default_value() )
        {
            *pointers = get_default_value();
            *lengths  = get_default_value_size();
        }
        else
        {
            *pointers = 0;
            *lengths  = 0;
            result    = not_found( get_name(), *i );
        }
    }

    return result;
}
ErrorCode moab::VarLenDenseTag::get_data ( const SequenceManager seqman,
Error error_handler,
const Range entities,
const void **  data_ptrs,
int *  data_lengths 
) const [virtual]

Get tag value for passed entities.

Get tag values for specified entities.

Parameters:
seqmanPointer to mesh entity database
entitiesEntity handles for which to retrieve tag data
data_ptrsArray of pointers to tag values, one pointer for each passed entity.
data_lengthsOne value for each entity specifying the length of the tag value for the corresponding entity.

Implements moab::TagInfo.

Definition at line 195 of file VarLenDenseTag.cpp.

References moab::Range::const_pair_begin(), moab::Range::const_pair_end(), moab::VarLenTag::data(), ErrorCode, get_array(), moab::TagInfo::get_default_value(), moab::TagInfo::get_default_value_size(), moab::TagInfo::get_name(), MB_CHK_ERR, MB_SET_ERR, MB_SUCCESS, MB_VARIABLE_DATA_LENGTH, moab::not_found(), moab::SysUtil::setmem(), and moab::VarLenTag::size().

{
    if( !lengths )
    {
        MB_SET_ERR( MB_VARIABLE_DATA_LENGTH, "No size specified for variable-length tag " << get_name() << " data" );
    }

    ErrorCode rval;
    size_t avail           = 0;
    const VarLenTag* array = NULL;

    for( Range::const_pair_iterator p = entities.const_pair_begin(); p != entities.const_pair_end(); ++p )
    {
        EntityHandle start = p->first;
        while( start <= p->second )
        {
            rval = get_array( seqman, NULL, start, array, avail );MB_CHK_ERR( rval );

            const size_t count = std::min< size_t >( p->second - start + 1, avail );

            if( !array )
            {
                const void* defval = get_default_value();
                const int len      = get_default_value_size();
                SysUtil::setmem( pointers, &defval, sizeof( void* ), count );
                SysUtil::setmem( lengths, &len, sizeof( int ), count );
                pointers += count;
                lengths += count;
                if( !defval ) return not_found( get_name(), start );
            }

            const VarLenTag* end_data = array + count;
            while( array != end_data )
            {
                if( array->size() )
                {
                    *pointers = array->data();
                    *lengths  = array->size();
                }
                else if( get_default_value() )
                {
                    *pointers = get_default_value();
                    *lengths  = get_default_value_size();
                }
                else
                {
                    *pointers = NULL;
                    *lengths  = 0;
                    return not_found( get_name(), start );
                }
                ++pointers;
                ++lengths;
                ++array;
                ++start;
            }
        }
    }

    return MB_SUCCESS;
}
ErrorCode moab::VarLenDenseTag::get_memory_use ( const SequenceManager seqman,
unsigned long &  total,
unsigned long &  per_entity 
) const [virtual]

Get memory use for tag data.

Implements moab::TagInfo.

Definition at line 558 of file VarLenDenseTag.cpp.

References moab::TypeSequenceManager::begin(), moab::TypeSequenceManager::end(), moab::SequenceManager::entity_map(), moab::TagInfo::get_memory_use(), moab::SequenceData::get_tag_data(), MB_SUCCESS, MBENTITYSET, MBVERTEX, moab::VarLenTag::mem(), meshValue, mySequenceArray, moab::SequenceData::size(), and t.

{
    total        = 0;
    per_entity   = 0;
    size_t count = 0;
    for( EntityType t = MBVERTEX; t <= MBENTITYSET; ++t )
    {
        const TypeSequenceManager& map = seqman->entity_map( t );
        const SequenceData* prev_data  = 0;
        for( TypeSequenceManager::const_iterator i = map.begin(); i != map.end(); ++i )
        {
            const void* mem = ( *i )->data()->get_tag_data( mySequenceArray );
            if( !mem ) continue;

            if( ( *i )->data() != prev_data )
            {
                total += ( *i )->data()->size();
                prev_data = ( *i )->data();
            }

            count += ( *i )->size();
            const VarLenTag* array = reinterpret_cast< const VarLenTag* >( mem );
            for( int j = 0; j < ( *i )->size(); ++j )
                per_entity += array[j].mem();
        }
    }
    total *= sizeof( VarLenTag );
    total += per_entity + sizeof( *this ) + TagInfo::get_memory_use();
    total += meshValue.mem() + sizeof( meshValue );
    if( count ) per_entity /= count;
    per_entity += sizeof( VarLenTag );

    return MB_SUCCESS;
}

Implements moab::TagInfo.

Definition at line 58 of file VarLenDenseTag.cpp.

References MB_TAG_DENSE.

{
    return MB_TAG_DENSE;
}
ErrorCode moab::VarLenDenseTag::get_tagged_entities ( const SequenceManager seqman,
Range output_entities,
EntityType  type = MBMAXTYPE,
const Range intersect = 0 
) const [virtual]

Get all tagged entities.

Get the list of entities for which the a tag value has been set, or a close approximation if the tag storage scheme cannot accurately determine exactly which entities have explicit values.

Parameters:
seqmanPointer to entity storage database
output_entitiesResults *appended* to this range
typeOptional entity type. If specified, search is limited to entities of specified type.
intersectOptional intersect list. If specified, search is restricted to entities in this list.

Implements moab::TagInfo.

Definition at line 475 of file VarLenDenseTag.cpp.

References moab::get_tagged(), and mySequenceArray.

{
    return get_tagged( seqman, mySequenceArray, entities, type, intersect );
}
bool moab::VarLenDenseTag::is_tagged ( const SequenceManager seqman,
EntityHandle  h 
) const [virtual]

Check if entity is tagged.

Implements moab::TagInfo.

Definition at line 551 of file VarLenDenseTag.cpp.

References moab::VarLenTag::data(), get_array(), and MB_SUCCESS.

{
    const VarLenTag* ptr = NULL;  // Initialize to get rid of warning
    size_t count;
    return ( MB_SUCCESS == get_array( seqman, 0, h, ptr, count ) ) && ( NULL != ptr ) && ( NULL != ptr->data() );
}
ErrorCode moab::VarLenDenseTag::num_tagged_entities ( const SequenceManager seqman,
size_t &  output_count,
EntityType  type = MBMAXTYPE,
const Range intersect = 0 
) const [virtual]

Count all tagged entities.

Count the entities for which the a tag value has been set, or a close approximation if the tag storage scheme cannot accurately determine exactly which entities have explicit values.

Parameters:
seqmanPointer to entity storage database
output_countThis is *incremented* for each detected entity.
typeOptional entity type. If specified, search is limited to entities of specified type.
intersectOptional intersect list. If specified, search is restricted to entities in this list.

Implements moab::TagInfo.

Definition at line 481 of file VarLenDenseTag.cpp.

References moab::InsertCount::end(), ErrorCode, moab::get_tagged(), and mySequenceArray.

{
    InsertCount counter( output_count );
    ErrorCode rval = get_tagged( seqman, mySequenceArray, counter, type, intersect );
    output_count   = counter.end();
    return rval;
}
VarLenDenseTag& moab::VarLenDenseTag::operator= ( const VarLenDenseTag ) [private]
ErrorCode moab::VarLenDenseTag::release_all_data ( SequenceManager seqman,
Error error_handler,
bool  delete_pending 
) [virtual]

Remove/clear tag data for all entities.

Remove tag values from entities.

Parameters:
delete_pendingIf true, then release any global data associated with the tag in preparation for deleting the tag itself.

Invalidates tag if tag_delete_pending is true. The only valid method that can be invoked that is is the destructor.

Parameters:
seqmanPointer to mesh entity database

Implements moab::TagInfo.

Definition at line 63 of file VarLenDenseTag.cpp.

References ErrorCode, moab::SequenceManager::get_entities(), MB_SUCCESS, mySequenceArray, moab::SequenceManager::release_tag_array(), and remove_data().

{
    Range all_ents;
    seqman->get_entities( all_ents );
    ErrorCode rval = remove_data( seqman, error, all_ents );
    if( MB_SUCCESS == rval )
    {
        rval = seqman->release_tag_array( error, mySequenceArray, delete_pending );
        if( MB_SUCCESS == rval && delete_pending ) mySequenceArray = -1;
    }

    return rval;
}
ErrorCode moab::VarLenDenseTag::remove_data ( SequenceManager seqman,
Error error_handler,
const EntityHandle entities,
size_t  num_entities 
) [virtual]

Remove/clear tag data for entities.

Remove tag values from entities.

Parameters:
seqmanPointer to mesh entity database
entitiesEntity handles for which to store tag data
num_entitiesLength of entities array

Implements moab::TagInfo.

Definition at line 351 of file VarLenDenseTag.cpp.

References moab::VarLenTag::clear(), ErrorCode, get_array(), MB_CHK_ERR, and MB_SUCCESS.

Referenced by clear_data(), and release_all_data().

{
    const EntityHandle* const end = entities + num_entities;
    VarLenTag* array              = NULL;
    size_t junk                   = 0;
    ErrorCode rval;

    for( const EntityHandle* i = entities; i != end; ++i )
    {
        rval = get_array( seqman, NULL, *i, array, junk, false );MB_CHK_ERR( rval );

        if( array ) array->clear();
    }

    return MB_SUCCESS;
}
ErrorCode moab::VarLenDenseTag::remove_data ( SequenceManager seqman,
Error error_handler,
const Range entities 
) [virtual]

Remove/clear tag data for entities.

Remove tag values from entities.

Parameters:
seqmanPointer to mesh entity database
entitiesEntity handles for which to store tag data

Implements moab::TagInfo.

Definition at line 369 of file VarLenDenseTag.cpp.

References moab::VarLenTag::clear(), moab::Range::const_pair_begin(), moab::Range::const_pair_end(), ErrorCode, get_array(), MB_CHK_ERR, and MB_SUCCESS.

{
    VarLenTag* array = NULL;
    size_t avail     = 0;
    ErrorCode rval;

    for( Range::const_pair_iterator p = entities.const_pair_begin(); p != entities.const_pair_end(); ++p )
    {
        EntityHandle start = p->first;
        while( start <= p->second )
        {
            rval = get_array( seqman, NULL, start, array, avail, false );MB_CHK_ERR( rval );

            const EntityHandle end = std::min< EntityHandle >( p->second + 1, start + avail );
            if( array )
            {
                while( start != end )
                {
                    array->clear();
                    ++start;
                    ++array;
                }
            }
            else
            {
                start = end;
            }
        }
    }

    return MB_SUCCESS;
}
ErrorCode moab::VarLenDenseTag::set_data ( SequenceManager seqman,
Error error_handler,
const EntityHandle entities,
size_t  num_entities,
const void *  data 
) [virtual]

Set tag value for passed entities.

Store tag data or update stored tag values Will fail for variable-length data.

Parameters:
seqmanPointer to mesh entity database
entitiesEntity handles for which to store tag data
num_entitiesLength of entities array
dataPointer to memory holding consecutive tag values, one for each passed entity.

Implements moab::TagInfo.

Definition at line 257 of file VarLenDenseTag.cpp.

References moab::TagInfo::get_name(), MB_SET_ERR, and MB_VARIABLE_DATA_LENGTH.

Referenced by clear_data(), and set_data().

{
    MB_SET_ERR( MB_VARIABLE_DATA_LENGTH, "No size specified for variable-length tag " << get_name() << " data" );
}
ErrorCode moab::VarLenDenseTag::set_data ( SequenceManager seqman,
Error error_handler,
const Range entities,
const void *  data 
) [virtual]

Set tag value for passed entities.

Store tag data or update stored tag values Will fail for variable-length data.

Parameters:
seqmanPointer to mesh entity database
entitiesEntity handles for which to store tag data
dataPointer to memory holding consecutive tag values, one for each passed entity.

Implements moab::TagInfo.

Definition at line 262 of file VarLenDenseTag.cpp.

References moab::TagInfo::get_name(), MB_SET_ERR, and MB_VARIABLE_DATA_LENGTH.

{
    MB_SET_ERR( MB_VARIABLE_DATA_LENGTH, "No size specified for variable-length tag " << get_name() << " data" );
}
ErrorCode moab::VarLenDenseTag::set_data ( SequenceManager seqman,
Error error_handler,
const EntityHandle entities,
size_t  num_entities,
void const *const *  data_ptrs,
const int *  data_lengths 
) [virtual]

Set tag value for passed entities.

Store tag data or update stored tag values

Parameters:
seqmanPointer to mesh entity database
entitiesEntity handles for which to store tag data
num_entitiesLength of entities array
data_ptrsArray of pointers to tag values, one pointer for each passed entity.
data_lengthsOne value for each entity specifying the length of the tag value for the corresponding entity. Array is required for variable-length tags and is ignored for fixed-length tags.

Implements moab::TagInfo.

Definition at line 321 of file VarLenDenseTag.cpp.

References set_data().

{
    return set_data( seqman, NULL, entities, num_entities, false, pointers, lengths );
}
ErrorCode moab::VarLenDenseTag::set_data ( SequenceManager seqman,
Error error_handler,
const Range entities,
void const *const *  data_ptrs,
const int *  data_lengths 
) [virtual]

Set tag value for passed entities.

Store tag data or update stored tag values

Parameters:
seqmanPointer to mesh entity database
entitiesEntity handles for which to store tag data
data_ptrsArray of pointers to tag values, one pointer for each passed entity.
data_lengthsOne value for each entity specifying the length of the tag value for the corresponding entity. Array is required for variable-length tags and is ignored for fixed-length tags.

Implements moab::TagInfo.

Definition at line 327 of file VarLenDenseTag.cpp.

References set_data().

{
    return set_data( seqman, NULL, entities, false, pointers, lengths );
}
ErrorCode moab::VarLenDenseTag::set_data ( SequenceManager seqman,
Error error_handler,
const EntityHandle entities,
size_t  num_entities,
bool  one_value,
void const *const *  pointers,
const int *  lengths 
) [inline, private]

Common implementation of set_data, and clear_data.

Parameters:
allocateIf false and no storage is currently allocated for an entity then leave entity tag unallocated.
one_valueIf true, pointers and lengths are assumed to be arrays of length 1 and all entities are set to the corresponding value

Definition at line 267 of file VarLenDenseTag.cpp.

References ErrorCode, get_array(), MB_CHK_ERR, MB_SUCCESS, moab::VarLenTag::set(), and moab::TagInfo::validate_lengths().

{
    ErrorCode rval = validate_lengths( NULL, lengths, one_value ? 1 : num_entities );MB_CHK_ERR( rval );

    const EntityHandle* const end = entities + num_entities;
    VarLenTag* array              = NULL;
    size_t junk                   = 0;
    const size_t step             = one_value ? 0 : 1;

    for( const EntityHandle* i = entities; i != end; ++i )
    {
        rval = get_array( seqman, NULL, *i, array, junk, true );MB_CHK_ERR( rval );

        array->set( *pointers, *lengths );
        pointers += step;
        lengths += step;
    }

    return MB_SUCCESS;
}
ErrorCode moab::VarLenDenseTag::set_data ( SequenceManager seqman,
Error error_handler,
const Range entities,
bool  one_value,
void const *const *  pointers,
const int *  lengths 
) [inline, private]

Common implementation of set_data, and clear_data.

Parameters:
allocateIf false and no storage is currently allocated for an entity then leave entity tag unallocated.
one_valueIf true, pointers and lengths are assumed to be arrays of length 1 and all entities are set to the corresponding value

Definition at line 290 of file VarLenDenseTag.cpp.

References moab::Range::const_pair_begin(), moab::Range::const_pair_end(), ErrorCode, get_array(), MB_CHK_ERR, MB_SUCCESS, moab::VarLenTag::set(), moab::Range::size(), and moab::TagInfo::validate_lengths().

{
    ErrorCode rval = validate_lengths( NULL, lengths, one_value ? 1 : entities.size() );MB_CHK_ERR( rval );

    VarLenTag* array  = NULL;
    size_t avail      = 0;
    const size_t step = one_value ? 0 : 1;

    for( Range::const_pair_iterator p = entities.const_pair_begin(); p != entities.const_pair_end(); ++p )
    {
        EntityHandle start = p->first;
        while( start <= p->second )
        {
            rval = get_array( seqman, NULL, start, array, avail, true );MB_CHK_ERR( rval );

            const EntityHandle end = std::min< EntityHandle >( p->second + 1, start + avail );
            while( start != end )
            {
                array->set( *pointers, *lengths );
                ++start;
                ++array;
                pointers += step;
                lengths += step;
            }
        }
    }

    return MB_SUCCESS;
}
ErrorCode moab::VarLenDenseTag::tag_iterate ( SequenceManager seqman,
Error error_handler,
Range::iterator iter,
const Range::iterator end,
void *&  data_ptr,
bool  allocate 
) [virtual]

Access tag data via direct pointer into contiguous blocks.

Iteratively obtain direct access to contiguous blocks of tag storage. This function cannot be used with bit tags because of the compressed bit storage. This function cannot be used with variable length tags because it does not provide a mechanism to determine the length of the value for each entity. This function may be used with sparse tags, but if it is used, it will return data for a single entity at a time.

Parameters:
iterAs input, the first entity for which to return data. As output, one past the last entity for which data was returned.
endOne past the last entity for which data is desired
data_ptrOutput: pointer to tag storage.
allocateIf true, space for this tag will be allocated, if not it wont

If this function is called for entities for which no tag value has been set, but for which a default value exists, it will force the allocation of explicit storage for each such entity even though MOAB would normally not explicitly store tag values for such entities.

Implements moab::TagInfo.

Definition at line 402 of file VarLenDenseTag.cpp.

References MB_SET_ERR, and MB_VARIABLE_DATA_LENGTH.

{
    MB_SET_ERR( MB_VARIABLE_DATA_LENGTH, "Cannot iterate over variable-length tag data" );
}

Member Data Documentation

Definition at line 26 of file VarLenDenseTag.hpp.

Referenced by get_array(), and get_memory_use().

List of all members.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines