Mesh Oriented datABase  (version 5.6.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 365 of file VarLenDenseTag.cpp.

371 {
372  if( !value_ptr || !value_len )
373  return remove_data( seqman, NULL, entities, num_entities );
374  else
375  return set_data( seqman, NULL, entities, num_entities, true, &value_ptr, &value_len );
376 }

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

383 {
384  if( !value_ptr || !value_len )
385  return remove_data( seqman, NULL, entities );
386  else
387  return set_data( seqman, NULL, entities, true, &value_ptr, &value_len );
388 }

References 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(), moab::index, 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 545 of file VarLenDenseTag.cpp.

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

References moab::Range::begin(), moab::TypeSequenceManager::begin(), moab::Range::const_pair_end(), moab::ByteArrayIterator::data, moab::TypeSequenceManager::end(), moab::SequenceManager::entity_map(), moab::error(), moab::find_tag_varlen_values_equal(), get_array(), moab::Range::lower_bound(), MB_CHK_ERR, MB_SUCCESS, MBMAXTYPE, mySequenceArray, 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 80 of file VarLenDenseTag.cpp.

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

References moab::EntitySequence::data(), moab::SequenceData::end_handle(), 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 111 of file VarLenDenseTag.cpp.

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

References moab::SequenceData::allocate_tag_array(), moab::EntitySequence::data(), moab::SequenceData::end_handle(), 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 168 of file VarLenDenseTag.cpp.

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

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

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

159 {
160  MB_SET_ERR( MB_VARIABLE_DATA_LENGTH, "No size specified for variable-length tag " << get_name() << " data" );
161 }

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

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

References moab::Range::const_pair_begin(), moab::Range::const_pair_end(), moab::VarLenTag::data(), 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 163 of file VarLenDenseTag.cpp.

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

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

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

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, and moab::SequenceData::size().

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

530 {
531  return get_tagged( seqman, mySequenceArray, entities, type, intersect );
532 }

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

610 {
611  const VarLenTag* ptr = NULL; // Initialize to get rid of warning
612  size_t count;
613  return ( MB_SUCCESS == get_array( seqman, 0, h, ptr, count ) ) && ( NULL != ptr ) && ( NULL != ptr->data() );
614 }

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

538 {
539  InsertCount counter( output_count );
540  MB_CHK_ERR( get_tagged( seqman, mySequenceArray, counter, type, intersect ) );
541  output_count = counter.end();
542  return MB_SUCCESS;
543 }

References moab::InsertCount::end(), moab::get_tagged(), moab::intersect(), MB_CHK_ERR, MB_SUCCESS, 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  MB_CHK_ERR( remove_data( seqman, error, all_ents ) );
75  MB_CHK_ERR( seqman->release_tag_array( error, mySequenceArray, delete_pending ) );
76  if( delete_pending ) mySequenceArray = -1;
77  return MB_SUCCESS;
78 }

References moab::error(), moab::SequenceManager::get_entities(), MB_CHK_ERR, 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 390 of file VarLenDenseTag.cpp.

394 {
395  const EntityHandle* const end = entities + num_entities;
396  VarLenTag* array = NULL;
397  size_t junk = 0;
398 
399  for( const EntityHandle* i = entities; i != end; ++i )
400  {
401  MB_CHK_ERR( get_array( seqman, NULL, *i, array, junk, false ) );
402 
403  if( array ) array->clear();
404  }
405 
406  return MB_SUCCESS;
407 }

References moab::VarLenTag::clear(), 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 409 of file VarLenDenseTag.cpp.

410 {
411  VarLenTag* array = NULL;
412  size_t avail = 0;
413 
414  for( Range::const_pair_iterator p = entities.const_pair_begin(); p != entities.const_pair_end(); ++p )
415  {
416  EntityHandle start = p->first;
417  while( start <= p->second )
418  {
419  MB_CHK_ERR( get_array( seqman, NULL, start, array, avail, false ) );
420 
421  const EntityHandle end = std::min< EntityHandle >( p->second + 1, start + avail );
422  if( array )
423  {
424  while( start != end )
425  {
426  array->clear();
427  ++start;
428  ++array;
429  }
430  }
431  else
432  {
433  start = end;
434  }
435  }
436  }
437 
438  return MB_SUCCESS;
439 }

References moab::VarLenTag::clear(), moab::Range::const_pair_begin(), moab::Range::const_pair_end(), 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 284 of file VarLenDenseTag.cpp.

291 {
292  MB_CHK_ERR( validate_lengths( NULL, lengths, one_value ? 1 : num_entities ) );
293 
294  const EntityHandle* const end = entities + num_entities;
295  VarLenTag* array = NULL;
296  size_t junk = 0;
297  const size_t step = one_value ? 0 : 1;
298 
299  for( const EntityHandle* i = entities; i != end; ++i )
300  {
301  MB_CHK_ERR( get_array( seqman, NULL, *i, array, junk, true ) );
302 
303  array->set( *pointers, *lengths );
304  pointers += step;
305  lengths += step;
306  }
307 
308  return MB_SUCCESS;
309 }

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

275 {
276  MB_SET_ERR( MB_VARIABLE_DATA_LENGTH, "No size specified for variable-length tag " << get_name() << " data" );
277 }

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

352 {
353  return set_data( seqman, NULL, entities, num_entities, false, pointers, lengths );
354 }

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

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

References moab::Range::const_pair_begin(), moab::Range::const_pair_end(), get_array(), MB_CHK_ERR, MB_SUCCESS, moab::VarLenTag::set(), moab::Range::size(), 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 279 of file VarLenDenseTag.cpp.

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

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

361 {
362  return set_data( seqman, NULL, entities, false, pointers, lengths );
363 }

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

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

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: