Mesh Oriented datABase  (version 5.4.1)
Array-based unstructured mesh datastructure
moab::DenseTag Class Reference

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

#include <DenseTag.hpp>

+ Inheritance diagram for moab::DenseTag:
+ Collaboration diagram for moab::DenseTag:

Public Member Functions

virtual ~DenseTag ()
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=true)
 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_handler, 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.
ErrorCode get_array (const SequenceManager *seqman, Error *error, EntityHandle h, const unsigned char *const &ptr, size_t &count) const
 Get read-only tag storage.
ErrorCode get_array (const EntitySequence *seq, const unsigned char *const &ptr) const
 Get read-only tag storage for entire sequence.

Static Public Member Functions

static DenseTagcreate_tag (SequenceManager *seqman, Error *error, const char *name, int bytes, DataType type, const void *default_value)

Private Member Functions

 DenseTag (int array_index, const char *name, int size, DataType type, const void *default_value)
 DenseTag (const DenseTag &)
DenseTagoperator= (const DenseTag &)
ErrorCode get_array_private (SequenceManager *seqman, Error *error, EntityHandle h, unsigned char *&ptr, size_t &count, bool allocate)
 Get or allocated tag storage.
ErrorCode get_array_private (const SequenceManager *seqman, Error *error, EntityHandle h, const unsigned char *&ptr, size_t &count) const
 Get tag storage.
ErrorCode get_array_private (const EntitySequence *seq, const unsigned char *&ptr) const
 Get non-read-only tag storage for entire sequence.
ErrorCode clear_data (bool allocate, SequenceManager *seqman, Error *error, const EntityHandle *entities, size_t num_entities, const void *value_ptr)
 Common implementation of public clear_data and remove_data.
ErrorCode clear_data (bool allocate, SequenceManager *seqman, Error *error, const Range &entities, const void *value_ptr)
 Common implementation of public clear_data and remove_data.

Private Attributes

int mySequenceArray
 Array index in SequenceManager used to store tag data.
unsigned char * meshValue

Detailed Description

Dense storage of fixed-length tag data.

Implement normal dense tag.

Definition at line 20 of file DenseTag.hpp.


Constructor & Destructor Documentation

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

Definition at line 52 of file DenseTag.cpp.

Referenced by create_tag().

Definition at line 77 of file DenseTag.cpp.

References meshValue, and mySequenceArray.

{
    assert( mySequenceArray < 0 );
    delete[] meshValue;
}
moab::DenseTag::DenseTag ( const DenseTag ) [private]

Member Function Documentation

ErrorCode moab::DenseTag::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 483 of file DenseTag.cpp.

References moab::TagInfo::get_size(), and MB_INVALID_SIZE.

Referenced by clear_data(), and remove_data().

{
    if( value_len && value_len != get_size() ) return MB_INVALID_SIZE;

    return clear_data( true, seqman, NULL, entities, num_entities, value_ptr );
}
ErrorCode moab::DenseTag::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 495 of file DenseTag.cpp.

References clear_data(), moab::TagInfo::get_size(), and MB_INVALID_SIZE.

{
    if( value_len && value_len != get_size() ) return MB_INVALID_SIZE;

    return clear_data( true, seqman, NULL, entities, value_ptr );
}
ErrorCode moab::DenseTag::clear_data ( bool  allocate,
SequenceManager seqman,
Error error,
const EntityHandle entities,
size_t  num_entities,
const void *  value_ptr 
) [private]

Common implementation of public clear_data and remove_data.

Definition at line 433 of file DenseTag.cpp.

References ErrorCode, get_array_private(), moab::TagInfo::get_size(), MB_CHK_ERR, and MB_SUCCESS.

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

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

        if( array )  // Array should never be null if allocate == true
            memcpy( array, value_ptr, get_size() );
    }

    return MB_SUCCESS;
}
ErrorCode moab::DenseTag::clear_data ( bool  allocate,
SequenceManager seqman,
Error error,
const Range entities,
const void *  value_ptr 
) [private]

Common implementation of public clear_data and remove_data.

Definition at line 456 of file DenseTag.cpp.

References moab::Range::const_pair_begin(), moab::Range::const_pair_end(), ErrorCode, get_array_private(), moab::TagInfo::get_size(), MB_CHK_ERR, MB_SUCCESS, and moab::SysUtil::setmem().

{
    ErrorCode rval;
    unsigned char* array = NULL;
    size_t avail         = 0;

    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_private( seqman, NULL, start, array, avail, allocate );MB_CHK_ERR( rval );

            const size_t count = std::min< size_t >( p->second - start + 1, avail );
            if( array )  // Array should never be null if allocate == true
                SysUtil::setmem( array, value_ptr, get_size(), count );
            start += count;
        }
    }

    return MB_SUCCESS;
}
DenseTag * moab::DenseTag::create_tag ( SequenceManager seqman,
Error error,
const char *  name,
int  bytes,
DataType  type,
const void *  default_value 
) [static]

Definition at line 62 of file DenseTag.cpp.

References DenseTag(), MB_SUCCESS, and moab::SequenceManager::reserve_tag_array().

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

{
    if( bytes < 1 ) return 0;

    int index;
    if( MB_SUCCESS != seqman->reserve_tag_array( NULL, bytes, index ) ) return 0;

    return new DenseTag( index, name, bytes, type, default_value );
}
ErrorCode moab::DenseTag::find_entities_with_value ( const SequenceManager seqman,
Error error_handler,
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 594 of file DenseTag.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_values_equal(), get_array(), moab::TagInfo::get_size(), moab::Range::lower_bound(), MB_CHK_ERR, MB_INVALID_SIZE, MB_SET_ERR, MB_SUCCESS, MBMAXTYPE, mySequenceArray, t, moab::TYPE_FROM_HANDLE(), and moab::type_range().

{
    if( value_bytes && value_bytes != get_size() )
    {
        MB_SET_ERR( MB_INVALID_SIZE,
                    "Cannot compare data of size " << value_bytes << " with tag of size " << get_size() );
    }

    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_values_equal( *this, value, get_size(), start, end, output_entities );
                }
            }
        }
    }
    else
    {
        const unsigned char* array = NULL;  // Initialize to get rid of warning
        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, NULL, 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_values_equal( *this, value, get_size(), istart, iend, output_entities );
                }
                start += count;
            }
        }
    }

    return MB_SUCCESS;
}
ErrorCode moab::DenseTag::get_array ( const SequenceManager seqman,
Error error,
EntityHandle  h,
const unsigned char *const &  ptr,
size_t &  count 
) const

Get read-only tag storage.

Parameters:
seqmanSequence manager
errorError object through which to report errors
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 90 of file DenseTag.cpp.

References get_array_private().

Referenced by find_entities_with_value(), get_data(), is_tagged(), and moab::WriteDamsel::map_dense_tags().

{
    //  cast away the const-ness; do we really want to do this?
    // probably we are not calling this anywhere;
    // clang compiler found this
    return get_array_private( seqman, NULL, h, const_cast< const unsigned char*& >( ptr ), count );
}
ErrorCode moab::DenseTag::get_array ( const EntitySequence seq,
const unsigned char *const &  ptr 
) const

Get read-only tag storage for entire sequence.

Parameters:
seqSequence
ptrPointer to dag storage. This pointer will be set to null and MB_SUCCESS will be returned if no tag storage has been allocated.
Returns:
MB_SUCCESS if sequence is valid (regardless of whether or not any tag storage is allocated).

Definition at line 134 of file DenseTag.cpp.

References get_array_private().

{
    // cast away the constness; otherwise it would be infinite recursion
    // probably we are not calling this anywhere
    return get_array_private( seq, const_cast< const unsigned char*& >( ptr ) );
}
ErrorCode moab::DenseTag::get_array_private ( SequenceManager seqman,
Error error,
EntityHandle  h,
unsigned char *&  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 149 of file DenseTag.cpp.

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

Referenced by clear_data(), get_array(), set_data(), and tag_iterate().

{
    EntitySequence* seq = 0;
    ErrorCode rval      = seqman->find( h, seq );
    if( MB_SUCCESS != rval )
    {
        if( !h )
        {  // Root set
            if( !meshValue && allocate ) meshValue = new unsigned char[get_size()];
            ptr   = meshValue;
            count = 1;
            return MB_SUCCESS;
        }
        else
        {  // Not root set
            ptr   = 0;
            count = 0;
            return ent_not_found( get_name(), h );
        }
    }

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

        if( !get_default_value() ) memset( mem, 0, get_size() * seq->data()->size() );
    }

    ptr   = reinterpret_cast< unsigned char* >( mem );
    count = seq->data()->end_handle() - h + 1;
    if( ptr ) ptr += get_size() * ( h - seq->data()->start_handle() );
    return MB_SUCCESS;
}
ErrorCode moab::DenseTag::get_array_private ( const SequenceManager seqman,
Error error,
EntityHandle  h,
const unsigned char *&  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 102 of file DenseTag.cpp.

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

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

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

    return MB_SUCCESS;
}
ErrorCode moab::DenseTag::get_array_private ( const EntitySequence seq,
const unsigned char *&  ptr 
) const [private]

Get non-read-only tag storage for entire sequence.

Parameters:
seqSequence
ptrPointer to dag storage. This pointer will be set to null and MB_SUCCESS will be returned if no tag storage has been allocated.
Returns:
MB_SUCCESS if sequence is valid (regardless of whether or not any tag storage is allocated).

Definition at line 141 of file DenseTag.cpp.

References moab::EntitySequence::data(), moab::TagInfo::get_size(), moab::SequenceData::get_tag_data(), MB_SUCCESS, mySequenceArray, moab::SequenceData::start_handle(), and moab::EntitySequence::start_handle().

{
    ptr = reinterpret_cast< const unsigned char* >( seq->data()->get_tag_data( mySequenceArray ) );
    if( ptr ) ptr += get_size() * ( seq->start_handle() - seq->data()->start_handle() );

    return MB_SUCCESS;
}
ErrorCode moab::DenseTag::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 193 of file DenseTag.cpp.

References ErrorCode, get_array(), moab::TagInfo::get_default_value(), moab::TagInfo::get_name(), moab::TagInfo::get_size(), MB_CHK_ERR, MB_SUCCESS, and moab::not_found().

{
    size_t junk                   = 0;
    unsigned char* ptr            = reinterpret_cast< unsigned char* >( adata );
    const EntityHandle* const end = entities + num_entities;
    for( const EntityHandle* i = entities; i != end; ++i, ptr += get_size() )
    {
        const unsigned char* data = 0;
        ErrorCode rval            = get_array( seqman, NULL, *i, data, junk );MB_CHK_ERR( rval );

        if( data )
            memcpy( ptr, data, get_size() );
        else if( get_default_value() )
            memcpy( ptr, get_default_value(), get_size() );
        else
            return not_found( get_name(), *i );
    }

    return MB_SUCCESS;
}
ErrorCode moab::DenseTag::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 218 of file DenseTag.cpp.

References moab::Range::const_pair_begin(), moab::Range::const_pair_end(), ErrorCode, get_array(), moab::TagInfo::get_default_value(), moab::TagInfo::get_name(), moab::TagInfo::get_size(), MB_CHK_ERR, MB_SUCCESS, moab::not_found(), and moab::SysUtil::setmem().

{
    ErrorCode rval;
    size_t avail               = 0;
    const unsigned char* array = NULL;  // Initialize to get rid of warning
    unsigned char* data        = reinterpret_cast< unsigned char* >( values );

    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 )
                memcpy( data, array, get_size() * count );
            else if( get_default_value() )
                SysUtil::setmem( data, get_default_value(), get_size(), count );
            else
                return not_found( get_name(), start );

            data += get_size() * count;
            start += count;
        }
    }

    return MB_SUCCESS;
}
ErrorCode moab::DenseTag::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 251 of file DenseTag.cpp.

References ErrorCode, get_array(), moab::TagInfo::get_default_value(), moab::TagInfo::get_name(), moab::TagInfo::get_size(), MB_CHK_ERR, MB_SUCCESS, moab::not_found(), and moab::SysUtil::setmem().

{
    ErrorCode result;
    const EntityHandle* const end = entities + num_entities;
    size_t junk                   = 0;
    const unsigned char* ptr      = NULL;  // Initialize to get rid of warning

    if( data_lengths )
    {
        const int len = get_size();
        SysUtil::setmem( data_lengths, &len, sizeof( int ), num_entities );
    }

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

        if( ptr )
            *pointers = ptr;
        else if( get_default_value() )
            *pointers = get_default_value();
        else
            return not_found( get_name(), *i );
    }

    return MB_SUCCESS;
}
ErrorCode moab::DenseTag::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 284 of file DenseTag.cpp.

References moab::Range::const_pair_begin(), moab::Range::const_pair_end(), ErrorCode, get_array(), moab::TagInfo::get_default_value(), moab::TagInfo::get_name(), moab::TagInfo::get_size(), MB_CHK_ERR, MB_SUCCESS, moab::not_found(), moab::SysUtil::setmem(), and moab::Range::size().

{
    ErrorCode rval;
    size_t avail               = 0;
    const unsigned char* array = NULL;

    if( data_lengths )
    {
        int len = get_size();
        SysUtil::setmem( data_lengths, &len, sizeof( int ), entities.size() );
    }

    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 )
            {
                for( EntityHandle end = start + count; start != end; ++start )
                {
                    *pointers = array;
                    array += get_size();
                    ++pointers;
                }
            }
            else if( const void* val = get_default_value() )
            {
                SysUtil::setmem( pointers, &val, sizeof( void* ), count );
                pointers += count;
                start += count;
            }
            else
            {
                return not_found( get_name(), start );
            }
        }
    }

    return MB_SUCCESS;
}
ErrorCode moab::DenseTag::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 672 of file DenseTag.cpp.

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

{
    per_entity = get_size();
    total      = TagInfo::get_memory_use() + sizeof( *this );
    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 )
        {
            if( ( *i )->data() != prev_data && ( *i )->data()->get_tag_data( mySequenceArray ) )
            {
                prev_data = ( *i )->data();
                total += get_size() * ( *i )->data()->size();
            }
        }
    }

    return MB_SUCCESS;
}

Implements moab::TagInfo.

Definition at line 57 of file DenseTag.cpp.

References MB_TAG_DENSE.

{
    return MB_TAG_DENSE;
}
ErrorCode moab::DenseTag::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 559 of file DenseTag.cpp.

References moab::TypeSequenceManager::begin(), moab::Range::begin(), moab::TypeSequenceManager::end(), entities, moab::SequenceManager::entity_map(), moab::Range::insert(), moab::intersect(), MB_SUCCESS, mySequenceArray, t, and moab::type_range().

Referenced by num_tagged_entities().

{
    Range tmp;
    Range* entities                           = intersect_list ? &tmp : &entities_in;
    Range::iterator hint                      = entities->begin();
    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 )
            if( ( *i )->data()->get_tag_data( mySequenceArray ) )
                hint = entities->insert( hint, ( *i )->start_handle(), ( *i )->end_handle() );
    }

    if( intersect_list ) entities_in = intersect( *entities, *intersect_list );

    return MB_SUCCESS;
}
bool moab::DenseTag::is_tagged ( const SequenceManager seqman,
EntityHandle  h 
) const [virtual]

Check if entity is tagged.

Implements moab::TagInfo.

Definition at line 665 of file DenseTag.cpp.

References get_array(), and MB_SUCCESS.

{
    const unsigned char* ptr = NULL;  // Initialize to get rid of warning
    size_t count;
    return ( MB_SUCCESS == get_array( seqman, 0, h, ptr, count ) ) && ( NULL != ptr );
}
ErrorCode moab::DenseTag::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 582 of file DenseTag.cpp.

References ErrorCode, get_tagged_entities(), and moab::Range::size().

{
    Range tmp;
    ErrorCode rval = get_tagged_entities( seqman, tmp, type, intersect );
    output_count += tmp.size();

    return rval;
}
DenseTag& moab::DenseTag::operator= ( const DenseTag ) [private]
ErrorCode moab::DenseTag::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 83 of file DenseTag.cpp.

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

{
    ErrorCode result = seqman->release_tag_array( NULL, mySequenceArray, delete_pending );
    if( MB_SUCCESS == result && delete_pending ) mySequenceArray = -1;
    return result;
}
ErrorCode moab::DenseTag::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 506 of file DenseTag.cpp.

References clear_data(), moab::TagInfo::get_default_value(), and moab::TagInfo::get_size().

{
    std::vector< unsigned char > zeros;
    const void* value = get_default_value();
    if( !value )
    {
        zeros.resize( get_size(), 0 );
        value = &zeros[0];
    }

    return clear_data( false, seqman, NULL, entities, num_entities, value );
}
ErrorCode moab::DenseTag::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 522 of file DenseTag.cpp.

References clear_data(), moab::TagInfo::get_default_value(), and moab::TagInfo::get_size().

{
    std::vector< unsigned char > zeros;
    const void* value = get_default_value();
    if( !value )
    {
        zeros.resize( get_size(), 0 );
        value = &zeros[0];
    }

    return clear_data( false, seqman, NULL, entities, value );
}
ErrorCode moab::DenseTag::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 333 of file DenseTag.cpp.

References ErrorCode, get_array_private(), moab::TagInfo::get_size(), MB_CHK_ERR, and MB_SUCCESS.

{
    ErrorCode rval;
    const unsigned char* ptr      = reinterpret_cast< const unsigned char* >( data );
    const EntityHandle* const end = entities + num_entities;
    unsigned char* array          = NULL;
    size_t junk                   = 0;

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

        memcpy( array, ptr, get_size() );
    }

    return MB_SUCCESS;
}
ErrorCode moab::DenseTag::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 355 of file DenseTag.cpp.

References moab::Range::const_pair_begin(), moab::Range::const_pair_end(), ErrorCode, get_array_private(), moab::TagInfo::get_size(), MB_CHK_ERR, and MB_SUCCESS.

{
    ErrorCode rval;
    const char* data     = reinterpret_cast< const char* >( values );
    unsigned char* array = NULL;
    size_t avail         = 0;

    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_private( seqman, NULL, start, array, avail, true );MB_CHK_ERR( rval );

            const size_t count = std::min< size_t >( p->second - start + 1, avail );
            memcpy( array, data, get_size() * count );
            data += get_size() * count;
            start += count;
        }
    }

    return MB_SUCCESS;
}
ErrorCode moab::DenseTag::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 379 of file DenseTag.cpp.

References ErrorCode, get_array_private(), moab::TagInfo::get_size(), MB_CHK_ERR, MB_SUCCESS, and moab::TagInfo::validate_lengths().

{
    ErrorCode rval = validate_lengths( NULL, data_lengths, num_entities );MB_CHK_ERR( rval );

    const EntityHandle* const end = entities + num_entities;
    unsigned char* array          = NULL;
    size_t junk                   = 0;

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

        memcpy( array, *pointers, get_size() );
    }

    return MB_SUCCESS;
}
ErrorCode moab::DenseTag::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 402 of file DenseTag.cpp.

References moab::Range::const_pair_begin(), moab::Range::const_pair_end(), ErrorCode, get_array_private(), moab::TagInfo::get_size(), MB_CHK_ERR, and MB_SUCCESS.

{
    ErrorCode rval;
    unsigned char* array = NULL;
    size_t avail         = 0;

    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_private( seqman, NULL, start, array, avail, true );MB_CHK_ERR( rval );

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

    return MB_SUCCESS;
}
ErrorCode moab::DenseTag::tag_iterate ( SequenceManager seqman,
Error error_handler,
Range::iterator iter,
const Range::iterator end,
void *&  data_ptr,
bool  allocate = true 
) [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.

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 535 of file DenseTag.cpp.

References moab::Range::const_iterator::end_of_block(), ErrorCode, get_array_private(), MB_CHK_ERR, and MB_SUCCESS.

{
    // If asked for nothing, successfully return nothing.
    if( iter == end ) return MB_SUCCESS;

    unsigned char* array = NULL;
    size_t avail         = 0;
    ErrorCode rval       = get_array_private( seqman, NULL, *iter, array, avail, allocate );MB_CHK_ERR( rval );
    data_ptr = array;

    size_t count = std::min< size_t >( avail, *( iter.end_of_block() ) - *iter + 1 );
    if( 0 != *end && *end <= *( iter.end_of_block() ) )
        iter = end;
    else
        iter += count;

    return MB_SUCCESS;
}

Member Data Documentation

unsigned char* moab::DenseTag::meshValue [private]

Definition at line 25 of file DenseTag.hpp.

Referenced by get_array_private(), and ~DenseTag().

Array index in SequenceManager used to store tag data.

Definition at line 23 of file DenseTag.hpp.

Referenced by find_entities_with_value(), get_array_private(), get_memory_use(), get_tagged_entities(), release_all_data(), and ~DenseTag().

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