moab
moab::DenseTag Class Reference

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

#include <DenseTag.hpp>

Inheritance diagram for moab::DenseTag:
moab::TagInfo

List of all members.

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.
ErrorCode get_array (const EntitySequence *seq, const unsigned char *&ptr) const
 Get non-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 (SequenceManager *seqman, Error *error, EntityHandle h, unsigned char *&ptr, size_t &count, bool allocate)
 Get or allocated tag storage.
ErrorCode get_array (const SequenceManager *seqman, Error *error, EntityHandle h, const unsigned char *&ptr, size_t &count) const
 Get tag storage.
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 19 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 41 of file DenseTag.cpp.

  : TagInfo( name, size, type, default_value, size ), 
    mySequenceArray(index),
    meshValue(0)
  {}

Definition at line 72 of file DenseTag.cpp.

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

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

  return clear_data( true, seqman, error, 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 507 of file DenseTag.cpp.

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

  return clear_data( true, seqman, error, 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 441 of file DenseTag.cpp.

{
  ErrorCode rval;
  const EntityHandle* const end = entities + num_entities;
  unsigned char* array;
  size_t junk;
  
  for (const EntityHandle* i = entities; i != end; ++i ) {
    rval = get_array( seqman, error, *i, array, junk, allocate );
    if (MB_SUCCESS != rval)
      return 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 465 of file DenseTag.cpp.

{
  ErrorCode rval;
  unsigned char* array;
  size_t avail;

  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, error, start, array, avail, allocate );
      if (MB_SUCCESS != rval)
        return 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 54 of file DenseTag.cpp.

{
  if (bytes < 1)
    return 0;

  int index;
  if (MB_SUCCESS != seqman->reserve_tag_array( error, 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_entitiesOpotional intersect list. If specified, search is restricted to entities in this list.

Implements moab::TagInfo.

Definition at line 608 of file DenseTag.cpp.

{
  if (value_bytes && value_bytes != get_size()) {
    error->set_last_error( "Cannot compare data of size %d with tag of size %d",
                           value_bytes, get_size() );
    return MB_INVALID_SIZE;
  }

  if (!intersect_entities) {
    std::pair<EntityType,EntityType> range = type_range(type);
    TypeSequenceManager::const_iterator i;
    for (EntityType t = range.first; t != range.second; ++i) {
      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, error, start, array, count );
        if (MB_SUCCESS != rval)
          return 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 88 of file DenseTag.cpp.

{
  return get_array(seqman, error, h, 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 127 of file DenseTag.cpp.

{
  return get_array(seq, ptr);
}
ErrorCode moab::DenseTag::get_array ( const EntitySequence seq,
const unsigned char *&  ptr 
) const

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

{
  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_array ( 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 143 of file DenseTag.cpp.

{
  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( error, 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) {
      error->set_last_error("Memory allocation failed for tag data");
      return MB_MEMORY_ALLOCATION_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 ( 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 97 of file DenseTag.cpp.

{
  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( error, 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_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 187 of file DenseTag.cpp.

{
  size_t junk;
  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, error, *i, data, junk );
    if (MB_SUCCESS != rval)
      return rval;
       
    if (data)
      memcpy( ptr, data, get_size() );
    else if (get_default_value())
      memcpy( ptr, get_default_value(), get_size() );
    else
     return not_found( error, 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 214 of file DenseTag.cpp.

{
  ErrorCode rval;
  size_t avail;
  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, error, start, array, avail );
      if (MB_SUCCESS != rval)
        return 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( error, 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 249 of file DenseTag.cpp.

{
  ErrorCode result;
  const EntityHandle *const end = entities + num_entities;
  size_t junk;
  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, error, *i, ptr, junk );
    if (MB_SUCCESS != result)
      return result;
  
    if (ptr)
      *pointers = ptr;
    else if (get_default_value())
      *pointers = get_default_value();
    else
      return not_found( error, 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 283 of file DenseTag.cpp.

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

  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, error, start, array, avail );
      if (MB_SUCCESS != rval)
        return 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( error, 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 682 of file DenseTag.cpp.

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

  { 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.
intersectOpotional intersect list. If specified, search is restricted to entities in this list.

Implements moab::TagInfo.

Definition at line 574 of file DenseTag.cpp.

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

{
  const unsigned char* ptr = NULL; // initialize to get rid of warning
  size_t count;
  return MB_SUCCESS == get_array( seqman, 0, h, ptr, count ) && 0 != 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.
intersectOpotional intersect list. If specified, search is restricted to entities in this list.

Implements moab::TagInfo.

Definition at line 597 of file DenseTag.cpp.

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

{
  ErrorCode result = seqman->release_tag_array( error, 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 519 of file DenseTag.cpp.

{
  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, error, 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 533 of file DenseTag.cpp.

{
  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, error, 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 329 of file DenseTag.cpp.

{
  ErrorCode rval;
  const unsigned char* ptr = reinterpret_cast<const unsigned char*>(data);
  const EntityHandle* const end = entities + num_entities;
  unsigned char* array;
  size_t junk;
  
  for (const EntityHandle* i = entities; i != end; ++i, ptr += get_size() ) {
    rval = get_array( seqman, error, *i, array, junk, true );
    if (MB_SUCCESS != rval)
      return 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 352 of file DenseTag.cpp.

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

  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, error, start, array, avail, true );
      if (MB_SUCCESS != rval)
        return 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 381 of file DenseTag.cpp.

{
  ErrorCode rval = validate_lengths( error, data_lengths, num_entities );
  if (MB_SUCCESS != rval)
    return rval;
  
  const EntityHandle* const end = entities + num_entities;
  unsigned char* array;
  size_t junk;
  
  for (const EntityHandle* i = entities; i != end; ++i, ++pointers ) {
    rval = get_array( seqman, error, *i, array, junk, true );
    if (MB_SUCCESS != rval)
      return 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 408 of file DenseTag.cpp.

{
  ErrorCode rval;
  unsigned char* array;
  size_t avail;

  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, error, start, array, avail, true );
      if (MB_SUCCESS != rval)
        return 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 547 of file DenseTag.cpp.

{
    // If asked for nothing, successfully return nothing.
  if (iter == end)
    return MB_SUCCESS;
  
  unsigned char* array;
  size_t avail;
  ErrorCode rval = get_array( seqman, error, *iter, array, avail, allocate);
  if (MB_SUCCESS != rval)
    return 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 24 of file DenseTag.hpp.

Array index in SequenceManager used to store tag data.

Definition at line 22 of file DenseTag.hpp.


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