Mesh Oriented datABase  (version 5.5.0)
An array-based unstructured mesh library
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. More...
 
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. More...
 
virtual ErrorCode get_data (const SequenceManager *seqman, Error *error_handler, const Range &entities, void *data) const
 Get tag value for passed entities. More...
 
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. More...
 
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. More...
 
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. More...
 
virtual ErrorCode set_data (SequenceManager *seqman, Error *error_handler, const Range &entities, const void *data)
 Set tag value for passed entities. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
virtual ErrorCode remove_data (SequenceManager *seqman, Error *error_handler, const EntityHandle *entities, size_t num_entities)
 Remove/clear tag data for entities. More...
 
virtual ErrorCode remove_data (SequenceManager *seqman, Error *error_handler, const Range &entities)
 Remove/clear tag data for entities. More...
 
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. More...
 
virtual ErrorCode get_tagged_entities (const SequenceManager *seqman, Range &output_entities, EntityType type=MBMAXTYPE, const Range *intersect=0) const
 Get all tagged entities. More...
 
virtual ErrorCode num_tagged_entities (const SequenceManager *seqman, size_t &output_count, EntityType type=MBMAXTYPE, const Range *intersect=0) const
 Count all tagged entities. More...
 
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. More...
 
virtual bool is_tagged (const SequenceManager *, EntityHandle h) const
 Check if entity is tagged. More...
 
virtual ErrorCode get_memory_use (const SequenceManager *seqman, unsigned long &total, unsigned long &per_entity) const
 Get memory use for tag data. More...
 
- Public Member Functions inherited from moab::TagInfo
 TagInfo ()
 constructor More...
 
 TagInfo (const char *name, int size, DataType type, const void *default_value, int default_value_size)
 constructor that takes all parameters More...
 
virtual ~TagInfo ()
 
void set_name (const std::string &name)
 set the name of the tag More...
 
const std::string & get_name () const
 get the name of the tag More...
 
int get_default_value_size () const
 get length of default value More...
 
const void * get_default_value () const
 get the default data More...
 
bool equals_default_value (const void *data, int size=-1) const
 compare the passed value to the default value. returns false if no default value. More...
 
DataType get_data_type () const
 
int get_size () const
 get the size of the data in bytes More...
 
bool variable_length () const
 Check if variable-length tag. More...
 
bool check_valid_sizes (const int *sizes, int num_sizes) const
 
ErrorCode validate_lengths (Error *error_handler, const int *lengths, size_t num_lengths) const
 

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)
 
- Static Public Member Functions inherited from moab::TagInfo
static int size_from_data_type (DataType t)
 

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. More...
 
ErrorCode get_array (const SequenceManager *seqman, Error *error_handler, EntityHandle h, const VarLenTag *&ptr, size_t &count) const
 Get tag storage. More...
 
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. More...
 
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. More...
 

Private Attributes

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

Additional Inherited Members

- Protected Member Functions inherited from moab::TagInfo
unsigned long get_memory_use () const
 

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

◆ VarLenDenseTag() [1/2]

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.

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

Referenced by create_tag().

◆ ~VarLenDenseTag()

moab::VarLenDenseTag::~VarLenDenseTag ( )
virtual

Definition at line 60 of file VarLenDenseTag.cpp.

61 {
62  assert( mySequenceArray < 0 );
63 }

References mySequenceArray.

◆ VarLenDenseTag() [2/2]

moab::VarLenDenseTag::VarLenDenseTag ( const VarLenDenseTag )
private

Member Function Documentation

◆ clear_data() [1/2]

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 372 of file VarLenDenseTag.cpp.

378 {
379  if( !value_ptr || !value_len )
380  return remove_data( seqman, NULL, entities, num_entities );
381  else
382  return set_data( seqman, NULL, entities, num_entities, true, &value_ptr, &value_len );
383 }

References entities, remove_data(), and set_data().

◆ clear_data() [2/2]

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 385 of file VarLenDenseTag.cpp.

390 {
391  if( !value_ptr || !value_len )
392  return remove_data( seqman, NULL, entities );
393  else
394  return set_data( seqman, NULL, entities, true, &value_ptr, &value_len );
395 }

References entities, remove_data(), and set_data().

◆ create_tag()

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 47 of file VarLenDenseTag.cpp.

53 {
54  int index;
55  if( MB_SUCCESS != seqman->reserve_tag_array( error, MB_VARIABLE_LENGTH, index ) ) return NULL;
56 
57  return new VarLenDenseTag( index, name, type, default_value, default_value_size );
58 }

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

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

◆ find_entities_with_value()

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 554 of file VarLenDenseTag.cpp.

561 {
562  if( !intersect_entities )
563  {
564  std::pair< EntityType, EntityType > range = type_range( type );
566  for( EntityType t = range.first; t != range.second; ++t )
567  {
568  const TypeSequenceManager& map = seqman->entity_map( t );
569  for( i = map.begin(); i != map.end(); ++i )
570  {
571  const void* data = ( *i )->data()->get_tag_data( mySequenceArray );
572  if( data )
573  {
574  ByteArrayIterator start( ( *i )->data()->start_handle(), data, *this );
575  ByteArrayIterator end( ( *i )->end_handle() + 1, 0, 0 );
576  start += ( *i )->start_handle() - ( *i )->data()->start_handle();
577  find_tag_varlen_values_equal( *this, value, value_bytes, start, end, output_entities );
578  }
579  }
580  }
581  }
582  else
583  {
584  const VarLenTag* array;
585  size_t count;
586  ErrorCode rval;
587 
588  Range::const_pair_iterator p = intersect_entities->begin();
589  if( type != MBMAXTYPE )
590  {
591  p = intersect_entities->lower_bound( type );
592  assert( TYPE_FROM_HANDLE( p->first ) == type );
593  }
594  for( ;
595  p != intersect_entities->const_pair_end() && ( MBMAXTYPE == type || TYPE_FROM_HANDLE( p->first ) == type );
596  ++p )
597  {
598  EntityHandle start = p->first;
599  while( start <= p->second )
600  {
601  rval = get_array( seqman, error, start, array, count );MB_CHK_ERR( rval );
602 
603  if( p->second - start < count - 1 ) count = p->second - start + 1;
604 
605  if( array )
606  {
607  ByteArrayIterator istart( start, array, *this );
608  ByteArrayIterator iend( start + count, 0, 0 );
609  find_tag_varlen_values_equal( *this, value, value_bytes, istart, iend, output_entities );
610  }
611  start += count;
612  }
613  }
614  }
615 
616  return MB_SUCCESS;
617 }

References moab::Range::begin(), moab::TypeSequenceManager::begin(), moab::Range::const_pair_end(), moab::ByteArrayIterator::data, moab::TypeSequenceManager::end(), moab::SequenceManager::entity_map(), moab::error(), 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().

◆ get_array() [1/2]

ErrorCode moab::VarLenDenseTag::get_array ( const SequenceManager seqman,
Error error_handler,
EntityHandle  h,
const VarLenTag *&  ptr,
size_t &  count 
) const
inlineprivate

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 84 of file VarLenDenseTag.cpp.

89 {
90  const EntitySequence* seq = NULL;
91  ErrorCode rval = seqman->find( h, seq );
92  if( MB_SUCCESS != rval )
93  {
94  if( !h )
95  { // Root set
96  ptr = &meshValue;
97  count = 1;
98  return MB_SUCCESS;
99  }
100  else
101  {
102  ptr = NULL;
103  count = 0;
104  return not_found( get_name(), h );
105  }
106  }
107 
108  const void* mem = seq->data()->get_tag_data( mySequenceArray );
109  ptr = reinterpret_cast< const VarLenTag* >( mem );
110  count = seq->data()->end_handle() - h + 1;
111  if( ptr ) ptr += h - seq->data()->start_handle();
112 
113  return MB_SUCCESS;
114 }

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().

◆ get_array() [2/2]

ErrorCode moab::VarLenDenseTag::get_array ( SequenceManager seqman,
Error error_handler,
EntityHandle  h,
VarLenTag *&  ptr,
size_t &  count,
bool  allocate 
)
inlineprivate

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 116 of file VarLenDenseTag.cpp.

122 {
123  EntitySequence* seq = NULL;
124  ErrorCode rval = seqman->find( h, seq );
125  if( MB_SUCCESS != rval )
126  {
127  if( !h )
128  { // Root set
129  ptr = &meshValue;
130  count = 1;
131  return MB_SUCCESS;
132  }
133  else
134  {
135  ptr = NULL;
136  count = 0;
137  return not_found( get_name(), h );
138  }
139  }
140 
141  void* mem = seq->data()->get_tag_data( mySequenceArray );
142  if( !mem && allocate )
143  {
144  mem = seq->data()->allocate_tag_array( mySequenceArray, sizeof( VarLenTag ) );
145  if( !mem )
146  {
147  MB_SET_ERR( MB_MEMORY_ALLOCATION_FAILED, "Memory allocation for variable-length dense tag data failed" );
148  }
149 
150  memset( mem, 0, sizeof( VarLenTag ) * seq->data()->size() );
151  }
152 
153  ptr = reinterpret_cast< VarLenTag* >( mem );
154  count = seq->data()->end_handle() - h + 1;
155  if( ptr ) ptr += h - seq->data()->start_handle();
156 
157  return MB_SUCCESS;
158 }

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().

◆ get_data() [1/4]

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 174 of file VarLenDenseTag.cpp.

180 {
181  if( !lengths )
182  {
183  MB_SET_ERR( MB_VARIABLE_DATA_LENGTH, "No size specified for variable-length tag " << get_name() << " data" );
184  }
185 
186  ErrorCode result = MB_SUCCESS, rval;
187  const EntityHandle* const end = entities + num_entities;
188  size_t junk = 0;
189  const VarLenTag* ptr = NULL;
190 
191  for( const EntityHandle* i = entities; i != end; ++i, ++pointers, ++lengths )
192  {
193  rval = get_array( seqman, NULL, *i, ptr, junk );MB_CHK_ERR( rval );
194 
195  if( ptr && ptr->size() )
196  {
197  *pointers = ptr->data();
198  *lengths = ptr->size();
199  }
200  else if( get_default_value() )
201  {
202  *pointers = get_default_value();
203  *lengths = get_default_value_size();
204  }
205  else
206  {
207  *pointers = 0;
208  *lengths = 0;
209  result = not_found( get_name(), *i );
210  }
211  }
212 
213  return result;
214 }

References moab::VarLenTag::data(), entities, 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().

◆ get_data() [2/4]

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.

\Note 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 160 of file VarLenDenseTag.cpp.

165 {
166  MB_SET_ERR( MB_VARIABLE_DATA_LENGTH, "No size specified for variable-length tag " << get_name() << " data" );
167 }

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

◆ get_data() [3/4]

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 216 of file VarLenDenseTag.cpp.

221 {
222  if( !lengths )
223  {
224  MB_SET_ERR( MB_VARIABLE_DATA_LENGTH, "No size specified for variable-length tag " << get_name() << " data" );
225  }
226 
227  ErrorCode rval;
228  size_t avail = 0;
229  const VarLenTag* array = NULL;
230 
231  for( Range::const_pair_iterator p = entities.const_pair_begin(); p != entities.const_pair_end(); ++p )
232  {
233  EntityHandle start = p->first;
234  while( start <= p->second )
235  {
236  rval = get_array( seqman, NULL, start, array, avail );MB_CHK_ERR( rval );
237 
238  const size_t count = std::min< size_t >( p->second - start + 1, avail );
239 
240  if( !array )
241  {
242  const void* defval = get_default_value();
243  const int len = get_default_value_size();
244  SysUtil::setmem( pointers, &defval, sizeof( void* ), count );
245  SysUtil::setmem( lengths, &len, sizeof( int ), count );
246  pointers += count;
247  lengths += count;
248  if( !defval ) return not_found( get_name(), start );
249  }
250 
251  const VarLenTag* end_data = array + count;
252  while( array != end_data )
253  {
254  if( array->size() )
255  {
256  *pointers = array->data();
257  *lengths = array->size();
258  }
259  else if( get_default_value() )
260  {
261  *pointers = get_default_value();
262  *lengths = get_default_value_size();
263  }
264  else
265  {
266  *pointers = NULL;
267  *lengths = 0;
268  return not_found( get_name(), start );
269  }
270  ++pointers;
271  ++lengths;
272  ++array;
273  ++start;
274  }
275  }
276  }
277 
278  return MB_SUCCESS;
279 }

References moab::VarLenTag::data(), entities, 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().

◆ get_data() [4/4]

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.

\Note 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 169 of file VarLenDenseTag.cpp.

170 {
171  MB_SET_ERR( MB_VARIABLE_DATA_LENGTH, "No size specified for variable-length tag " << get_name() << " data" );
172 }

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

◆ get_memory_use()

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 626 of file VarLenDenseTag.cpp.

630 {
631  total = 0;
632  per_entity = 0;
633  size_t count = 0;
634  for( EntityType t = MBVERTEX; t <= MBENTITYSET; ++t )
635  {
636  const TypeSequenceManager& map = seqman->entity_map( t );
637  const SequenceData* prev_data = 0;
638  for( TypeSequenceManager::const_iterator i = map.begin(); i != map.end(); ++i )
639  {
640  const void* mem = ( *i )->data()->get_tag_data( mySequenceArray );
641  if( !mem ) continue;
642 
643  if( ( *i )->data() != prev_data )
644  {
645  total += ( *i )->data()->size();
646  prev_data = ( *i )->data();
647  }
648 
649  count += ( *i )->size();
650  const VarLenTag* array = reinterpret_cast< const VarLenTag* >( mem );
651  for( int j = 0; j < ( *i )->size(); ++j )
652  per_entity += array[j].mem();
653  }
654  }
655  total *= sizeof( VarLenTag );
656  total += per_entity + sizeof( *this ) + TagInfo::get_memory_use();
657  total += meshValue.mem() + sizeof( meshValue );
658  if( count ) per_entity /= count;
659  per_entity += sizeof( VarLenTag );
660 
661  return MB_SUCCESS;
662 }

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.

◆ get_storage_type()

TagType moab::VarLenDenseTag::get_storage_type ( ) const
virtual

Implements moab::TagInfo.

Definition at line 65 of file VarLenDenseTag.cpp.

66 {
67  return MB_TAG_DENSE;
68 }

References MB_TAG_DENSE.

◆ get_tagged_entities()

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

539 {
540  return get_tagged( seqman, mySequenceArray, entities, type, intersect );
541 }

References entities, moab::get_tagged(), moab::intersect(), and mySequenceArray.

◆ is_tagged()

bool moab::VarLenDenseTag::is_tagged ( const SequenceManager seqman,
EntityHandle  h 
) const
virtual

Check if entity is tagged.

Implements moab::TagInfo.

Definition at line 619 of file VarLenDenseTag.cpp.

620 {
621  const VarLenTag* ptr = NULL; // Initialize to get rid of warning
622  size_t count;
623  return ( MB_SUCCESS == get_array( seqman, 0, h, ptr, count ) ) && ( NULL != ptr ) && ( NULL != ptr->data() );
624 }

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

◆ num_tagged_entities()

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 543 of file VarLenDenseTag.cpp.

547 {
548  InsertCount counter( output_count );
549  ErrorCode rval = get_tagged( seqman, mySequenceArray, counter, type, intersect );
550  output_count = counter.end();
551  return rval;
552 }

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

◆ operator=()

VarLenDenseTag& moab::VarLenDenseTag::operator= ( const VarLenDenseTag )
private

◆ release_all_data()

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.

\Note 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 70 of file VarLenDenseTag.cpp.

71 {
72  Range all_ents;
73  seqman->get_entities( all_ents );
74  ErrorCode rval = remove_data( seqman, error, all_ents );
75  if( MB_SUCCESS == rval )
76  {
77  rval = seqman->release_tag_array( error, mySequenceArray, delete_pending );
78  if( MB_SUCCESS == rval && delete_pending ) mySequenceArray = -1;
79  }
80 
81  return rval;
82 }

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

◆ remove_data() [1/2]

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 397 of file VarLenDenseTag.cpp.

401 {
402  const EntityHandle* const end = entities + num_entities;
403  VarLenTag* array = NULL;
404  size_t junk = 0;
405  ErrorCode rval;
406 
407  for( const EntityHandle* i = entities; i != end; ++i )
408  {
409  rval = get_array( seqman, NULL, *i, array, junk, false );MB_CHK_ERR( rval );
410 
411  if( array ) array->clear();
412  }
413 
414  return MB_SUCCESS;
415 }

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

Referenced by clear_data(), and release_all_data().

◆ remove_data() [2/2]

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 417 of file VarLenDenseTag.cpp.

418 {
419  VarLenTag* array = NULL;
420  size_t avail = 0;
421  ErrorCode rval;
422 
423  for( Range::const_pair_iterator p = entities.const_pair_begin(); p != entities.const_pair_end(); ++p )
424  {
425  EntityHandle start = p->first;
426  while( start <= p->second )
427  {
428  rval = get_array( seqman, NULL, start, array, avail, false );MB_CHK_ERR( rval );
429 
430  const EntityHandle end = std::min< EntityHandle >( p->second + 1, start + avail );
431  if( array )
432  {
433  while( start != end )
434  {
435  array->clear();
436  ++start;
437  ++array;
438  }
439  }
440  else
441  {
442  start = end;
443  }
444  }
445  }
446 
447  return MB_SUCCESS;
448 }

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

◆ set_data() [1/6]

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 
)
inlineprivate

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 291 of file VarLenDenseTag.cpp.

298 {
299  ErrorCode rval = validate_lengths( NULL, lengths, one_value ? 1 : num_entities );MB_CHK_ERR( rval );
300 
301  const EntityHandle* const end = entities + num_entities;
302  VarLenTag* array = NULL;
303  size_t junk = 0;
304  const size_t step = one_value ? 0 : 1;
305 
306  for( const EntityHandle* i = entities; i != end; ++i )
307  {
308  rval = get_array( seqman, NULL, *i, array, junk, true );MB_CHK_ERR( rval );
309 
310  array->set( *pointers, *lengths );
311  pointers += step;
312  lengths += step;
313  }
314 
315  return MB_SUCCESS;
316 }

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

◆ set_data() [2/6]

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 \Note 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 281 of file VarLenDenseTag.cpp.

282 {
283  MB_SET_ERR( MB_VARIABLE_DATA_LENGTH, "No size specified for variable-length tag " << get_name() << " data" );
284 }

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

Referenced by clear_data(), and set_data().

◆ set_data() [3/6]

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 353 of file VarLenDenseTag.cpp.

359 {
360  return set_data( seqman, NULL, entities, num_entities, false, pointers, lengths );
361 }

References entities, and set_data().

◆ set_data() [4/6]

ErrorCode moab::VarLenDenseTag::set_data ( SequenceManager seqman,
Error error_handler,
const Range entities,
bool  one_value,
void const *const *  pointers,
const int *  lengths 
)
inlineprivate

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 318 of file VarLenDenseTag.cpp.

324 {
325  ErrorCode rval = validate_lengths( NULL, lengths, one_value ? 1 : entities.size() );MB_CHK_ERR( rval );
326 
327  VarLenTag* array = NULL;
328  size_t avail = 0;
329  const size_t step = one_value ? 0 : 1;
330 
331  for( Range::const_pair_iterator p = entities.const_pair_begin(); p != entities.const_pair_end(); ++p )
332  {
333  EntityHandle start = p->first;
334  while( start <= p->second )
335  {
336  rval = get_array( seqman, NULL, start, array, avail, true );MB_CHK_ERR( rval );
337 
338  const EntityHandle end = std::min< EntityHandle >( p->second + 1, start + avail );
339  while( start != end )
340  {
341  array->set( *pointers, *lengths );
342  ++start;
343  ++array;
344  pointers += step;
345  lengths += step;
346  }
347  }
348  }
349 
350  return MB_SUCCESS;
351 }

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

◆ set_data() [5/6]

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 \Note 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 286 of file VarLenDenseTag.cpp.

287 {
288  MB_SET_ERR( MB_VARIABLE_DATA_LENGTH, "No size specified for variable-length tag " << get_name() << " data" );
289 }

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

◆ set_data() [6/6]

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 363 of file VarLenDenseTag.cpp.

368 {
369  return set_data( seqman, NULL, entities, false, pointers, lengths );
370 }

References entities, and set_data().

◆ tag_iterate()

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

\Note 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 450 of file VarLenDenseTag.cpp.

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

References MB_SET_ERR, and MB_VARIABLE_DATA_LENGTH.

Member Data Documentation

◆ meshValue

VarLenTag moab::VarLenDenseTag::meshValue
private

Definition at line 26 of file VarLenDenseTag.hpp.

Referenced by get_array(), and get_memory_use().

◆ mySequenceArray

int moab::VarLenDenseTag::mySequenceArray
private

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