Sparse tag data. More...
#include <SparseTag.hpp>
Public Types | |
typedef MOAB_UNORDERED_MAP_NS::unordered_map< EntityHandle, void * > | MapType |
map of entity id and tag data More... | |
Public Member Functions | |
SparseTag (const char *name, int size, DataType type, const void *default_value) | |
~SparseTag () | |
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=true) |
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_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. 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... | |
unsigned long | get_number_entities () |
get number of entities More... | |
![]() | |
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 |
Private Member Functions | |
SparseTag (const SparseTag &) | |
SparseTag & | operator= (const SparseTag &) |
void * | allocate_data (EntityHandle h, MapType::const_iterator iter, bool copy_default=true) |
allocate an entry for this sparse tag w/o setting its value (yet) More... | |
ErrorCode | set_data (Error *, EntityHandle entity_handle, const void *data) |
set the tag data for an entity id \NOTE Will fail with MB_VARIABLE_DATA_LENGTH if called for variable-length tag. More... | |
ErrorCode | get_data (Error *, EntityHandle entity_handle, void *data) const |
get the tag data for an entity id \NOTE Will fail with MB_VARIABLE_DATA_LENGTH if called for variable-length tag. More... | |
ErrorCode | get_data_ptr (EntityHandle entity_handle, const void *&data, bool allocate=true) const |
get the variable-length data for an entity id More... | |
ErrorCode | remove_data (Error *, EntityHandle entity_handle) |
removes the data More... | |
Private Attributes | |
SparseTagDataAllocator | mAllocator |
allocator for this collection More... | |
MapType | mData |
Additional Inherited Members | |
![]() | |
static int | size_from_data_type (DataType t) |
![]() | |
unsigned long | get_memory_use () const |
Sparse tag data.
Definition at line 64 of file SparseTag.hpp.
typedef MOAB_UNORDERED_MAP_NS::unordered_map< EntityHandle, void* > moab::SparseTag::MapType |
map of entity id and tag data
Definition at line 393 of file SparseTag.hpp.
moab::SparseTag::SparseTag | ( | const char * | name, |
int | size, | ||
DataType | type, | ||
const void * | default_value | ||
) |
Definition at line 31 of file SparseTag.cpp.
32 : TagInfo( name, size, type, default_value, size )
33 {
34 }
moab::SparseTag::~SparseTag | ( | ) |
Definition at line 36 of file SparseTag.cpp.
37 {
38 release_all_data( 0, 0, true );
39 }
References release_all_data().
|
private |
|
inlineprivate |
allocate an entry for this sparse tag w/o setting its value (yet)
Definition at line 427 of file SparseTag.hpp.
434 {
435 void* new_data = mAllocator.allocate( get_size() );
436 #ifdef MOAB_HAVE_UNORDERED_MAP
437 mData.insert( iter, std::pair< const EntityHandle, void* >( h, new_data ) );
438 #else
439 mData[h] = new_data;
440 #endif
441 if( copy_default ) memcpy( new_data, get_default_value(), get_size() );
442 return new_data;
443 }
References moab::SparseTagDataAllocator::allocate(), moab::TagInfo::get_default_value(), moab::TagInfo::get_size(), mAllocator, and mData.
Referenced by get_data_ptr(), set_data(), and tag_iterate().
|
virtual |
Set tag value for passed entities.
Store tag data or update stored tag values.
seqman | Pointer to mesh entity database |
entities | Entity handles for which to store tag data |
num_entities | Length of entities array |
value_ptr | Pointer to a single tag value which is to be stored for each of the passed entities. |
value_len | Length of tag value in bytes. Ignored for fixed-length tags. Required for variable- length tags. |
Implements moab::TagInfo.
Definition at line 275 of file SparseTag.cpp.
281 {
282 if( value_len && value_len != get_size() )
283 {
284 MB_SET_ERR( MB_INVALID_SIZE, "Invalid data size " << get_size() << " specified for sparse tag " << get_name()
285 << " of size " << value_len );
286 }
287
288 ErrorCode rval = seqman->check_valid_entities( NULL, entities, num_entities, true );MB_CHK_ERR( rval );
289
290 for( size_t i = 0; i < num_entities; ++i )
291 {
292 rval = set_data( NULL, entities[i], value_ptr );MB_CHK_ERR( rval );
293 }
294
295 return MB_SUCCESS;
296 }
References moab::SequenceManager::check_valid_entities(), entities, ErrorCode, moab::TagInfo::get_name(), moab::TagInfo::get_size(), MB_CHK_ERR, MB_INVALID_SIZE, MB_SET_ERR, MB_SUCCESS, and set_data().
|
virtual |
Set tag value for passed entities.
Store tag data or update stored tag values.
seqman | Pointer to mesh entity database |
entities | Entity handles for which to store tag data |
value_ptr | Pointer to a single tag value which is to be stored for each of the passed entities. |
value_len | Length of tag value in bytes. Ignored for fixed-length tags. Required for variable- length tags. |
Implements moab::TagInfo.
Definition at line 298 of file SparseTag.cpp.
303 {
304 if( value_len && value_len != get_size() )
305 {
306 MB_SET_ERR( MB_INVALID_SIZE, "Invalid data size " << get_size() << " specified for sparse tag " << get_name()
307 << " of size " << value_len );
308 }
309
310 ErrorCode rval = seqman->check_valid_entities( NULL, entities );MB_CHK_ERR( rval );
311
312 Range::const_iterator i;
313 for( i = entities.begin(); i != entities.end(); ++i )
314 {
315 rval = set_data( NULL, *i, value_ptr );MB_CHK_ERR( rval );
316 }
317
318 return MB_SUCCESS;
319 }
References moab::SequenceManager::check_valid_entities(), entities, ErrorCode, moab::TagInfo::get_name(), moab::TagInfo::get_size(), MB_CHK_ERR, MB_INVALID_SIZE, MB_SET_ERR, MB_SUCCESS, and set_data().
|
virtual |
Get all tagged entities with tag value.
Get the list of entities which have the specified tag value.
seqman | Pointer to entity storage database |
output_entities | Results appended to this range |
value | Pointer to tag value |
value_bytes | Size of tag value in bytes. |
type | Optional entity type. If specified, search is limited to entities of specified type. |
intersect_entities | Optional intersect list. If specified, search is restricted to entities in this list. |
Implements moab::TagInfo.
Definition at line 462 of file SparseTag.cpp.
474 {
475 if( value_bytes && value_bytes != get_size() )
476 {
477 MB_SET_ERR( MB_INVALID_SIZE, "Invalid data size " << get_size() << " specified for sparse tag " << get_name()
478 << " of size " << value_bytes );
479 }
480
481 MapType::const_iterator iter, end;
482 #ifdef MOAB_HAVE_UNORDERED_MAP
483 if( intersect_entities )
484 {
485 std::pair< Range::iterator, Range::iterator > r;
486 if( type == MBMAXTYPE )
487 {
488 r.first = intersect_entities->begin();
489 r.second = intersect_entities->end();
490 }
491 else
492 {
493 r = intersect_entities->equal_range( type );
494 }
495
496 find_map_values_equal( *this, value, get_size(), r.first, r.second, mData, output_entities );
497 }
498 else if( type == MBMAXTYPE )
499 {
500 find_tag_values_equal( *this, value, get_size(), mData.begin(), mData.end(), output_entities );
501 }
502 else
503 {
504 Range tmp;
505 seqman->get_entities( type, tmp );
506 find_map_values_equal( *this, value, get_size(), tmp.begin(), tmp.end(), mData, output_entities );
507 }
508 #else
509 if( intersect_entities )
510 {
511 for( Range::const_pair_iterator p = intersect_entities->begin(); p != intersect_entities->end(); ++p )
512 {
513 iter = mData.lower_bound( p->first );
514 end = mData.upper_bound( p->second );
515 find_tag_values_equal( *this, value, get_size(), iter, end, output_entities );
516 }
517 }
518 else
519 {
520 if( type == MBMAXTYPE )
521 {
522 iter = mData.begin();
523 end = mData.end();
524 }
525 else
526 {
527 iter = mData.lower_bound( CREATE_HANDLE( type, MB_START_ID ) );
528 end = mData.upper_bound( CREATE_HANDLE( type, MB_END_ID ) );
529 }
530 find_tag_values_equal( *this, value, get_size(), iter, end, output_entities );
531 }
532 #endif
533
534 return MB_SUCCESS;
535 }
References moab::Range::begin(), moab::CREATE_HANDLE(), moab::Range::end(), moab::Range::equal_range(), moab::find_map_values_equal(), moab::find_tag_values_equal(), moab::TagInfo::get_name(), moab::TagInfo::get_size(), MB_END_ID, MB_INVALID_SIZE, MB_SET_ERR, MB_START_ID, MB_SUCCESS, MBMAXTYPE, and mData.
|
virtual |
Get tag value for passed entities.
Get tag values for specified entities.
seqman | Pointer to mesh entity database |
entities | Entity handles for which to retrieve tag data |
num_entities | Length of entities array |
data_ptrs | Array of pointers to tag values, one pointer for each passed entity. |
data_lengths | One value for each entity specifying the length of the tag value for the corresponding entity. |
Implements moab::TagInfo.
Definition at line 148 of file SparseTag.cpp.
154 {
155 if( data_lengths )
156 {
157 int len = get_size();
158 SysUtil::setmem( data_lengths, &len, sizeof( int ), num_entities );
159 }
160
161 ErrorCode rval = MB_SUCCESS, rval_tmp;
162 for( size_t i = 0; i < num_entities; ++i, ++pointers )
163 {
164 rval_tmp = get_data_ptr( entities[i], *pointers );
165 if( MB_SUCCESS != rval_tmp && get_default_value() )
166 {
167 *pointers = get_default_value();
168 }
169 else if( MB_SUCCESS != rval_tmp )
170 {
171 return MB_TAG_NOT_FOUND;
172 }
173 }
174
175 return rval;
176 }
References entities, ErrorCode, get_data_ptr(), moab::TagInfo::get_default_value(), moab::TagInfo::get_size(), MB_SUCCESS, MB_TAG_NOT_FOUND, and moab::SysUtil::setmem().
|
virtual |
Get tag value for passed entities.
Get tag values for specified entities.
\Note Will fail for variable-length data.
seqman | Pointer to mesh entity database |
entities | Entity handles for which to retrieve tag data |
num_entities | Length of entities array |
data | Pointer to memory in which to store consecutive tag values, one for each passed entity. |
Implements moab::TagInfo.
Definition at line 117 of file SparseTag.cpp.
122 {
123 ErrorCode rval;
124 unsigned char* ptr = reinterpret_cast< unsigned char* >( data );
125 for( size_t i = 0; i < num_entities; ++i, ptr += get_size() )
126 {
127 rval = get_data( NULL, entities[i], ptr );
128 if( MB_SUCCESS != rval ) return rval;
129 }
130
131 return MB_SUCCESS;
132 }
References entities, ErrorCode, moab::TagInfo::get_size(), and MB_SUCCESS.
Referenced by get_data().
|
virtual |
Get tag value for passed entities.
Get tag values for specified entities.
seqman | Pointer to mesh entity database |
entities | Entity handles for which to retrieve tag data |
data_ptrs | Array of pointers to tag values, one pointer for each passed entity. |
data_lengths | One value for each entity specifying the length of the tag value for the corresponding entity. |
Implements moab::TagInfo.
Definition at line 178 of file SparseTag.cpp.
183 {
184 if( data_lengths )
185 {
186 int len = get_size();
187 SysUtil::setmem( data_lengths, &len, sizeof( int ), entities.size() );
188 }
189
190 ErrorCode rval = MB_SUCCESS, rval_tmp;
191 Range::const_iterator i;
192 for( i = entities.begin(); i != entities.end(); ++i, ++pointers )
193 {
194 rval_tmp = get_data_ptr( *i, *pointers );
195 if( MB_SUCCESS != rval_tmp && get_default_value() )
196 {
197 *pointers = get_default_value();
198 }
199 else if( MB_SUCCESS != rval_tmp )
200 {
201 return MB_TAG_NOT_FOUND;
202 }
203 }
204
205 return rval;
206 }
References entities, ErrorCode, get_data_ptr(), moab::TagInfo::get_default_value(), moab::TagInfo::get_size(), MB_SUCCESS, MB_TAG_NOT_FOUND, and moab::SysUtil::setmem().
|
virtual |
Get tag value for passed entities.
Get tag values for specified entities.
\Note Will fail for variable-length data.
seqman | Pointer to mesh entity database |
entities | Entity handles for which to retrieve tag data |
data | Pointer to memory in which to store consecutive tag values, one for each passed entity. |
Implements moab::TagInfo.
Definition at line 134 of file SparseTag.cpp.
135 {
136 ErrorCode rval;
137 unsigned char* ptr = reinterpret_cast< unsigned char* >( data );
138 Range::const_iterator i;
139 for( i = entities.begin(); i != entities.end(); ++i, ptr += get_size() )
140 {
141 rval = get_data( NULL, *i, ptr );
142 if( MB_SUCCESS != rval ) return rval;
143 }
144
145 return MB_SUCCESS;
146 }
References entities, ErrorCode, get_data(), moab::TagInfo::get_size(), and MB_SUCCESS.
|
inlineprivate |
get the tag data for an entity id \NOTE Will fail with MB_VARIABLE_DATA_LENGTH if called for variable-length tag.
Definition at line 88 of file SparseTag.cpp.
89 {
90 const void* ptr = 0;
91 ErrorCode rval = get_data_ptr( entity_handle, ptr, false );
92 if( MB_SUCCESS == rval )
93 {
94 memcpy( data, ptr, get_size() );
95 return rval;
96 }
97 else if( get_default_value() )
98 {
99 memcpy( data, get_default_value(), get_size() );
100 return MB_SUCCESS;
101 }
102 else
103 return MB_TAG_NOT_FOUND;
104 }
References ErrorCode, get_data_ptr(), moab::TagInfo::get_default_value(), moab::TagInfo::get_size(), MB_SUCCESS, and MB_TAG_NOT_FOUND.
|
inlineprivate |
get the variable-length data for an entity id
Definition at line 74 of file SparseTag.cpp.
75 {
76 MapType::const_iterator iter = mData.find( entity_handle );
77
78 if( iter != mData.end() )
79 ptr = iter->second;
80 else if( get_default_value() && allocate )
81 ptr = const_cast< SparseTag* >( this )->allocate_data( entity_handle, iter, allocate );
82 else
83 return MB_FAILURE;
84
85 return MB_SUCCESS;
86 }
References allocate_data(), moab::TagInfo::get_default_value(), MB_SUCCESS, and mData.
Referenced by get_data(), and tag_iterate().
|
virtual |
Get memory use for tag data.
Implements moab::TagInfo.
Definition at line 542 of file SparseTag.cpp.
544 {
545 per_entity = get_size() + 4 * sizeof( void* );
546 total = ( mData.size() * per_entity ) + sizeof( *this ) + TagInfo::get_memory_use();
547
548 return MB_SUCCESS;
549 }
References moab::TagInfo::get_memory_use(), moab::TagInfo::get_size(), MB_SUCCESS, and mData.
|
inline |
get number of entities
Definition at line 386 of file SparseTag.hpp.
387 {
388 return mData.size();
389 }
References mData.
|
virtual |
Implements moab::TagInfo.
Definition at line 41 of file SparseTag.cpp.
42 {
43 return MB_TAG_SPARSE;
44 }
References MB_TAG_SPARSE.
|
virtual |
Get all tagged entities.
Gets all entity handles that match a type and tag.
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.
seqman | Pointer to entity storage database |
output_entities | Results appended to this range |
type | Optional entity type. If specified, search is limited to entities of specified type. |
intersect | Optional intersect list. If specified, search is restricted to entities in this list. |
Implements moab::TagInfo.
Definition at line 441 of file SparseTag.cpp.
445 {
446 get_tagged( mData, output_range, type, intersect );
447 return MB_SUCCESS;
448 }
References moab::get_tagged(), moab::intersect(), MB_SUCCESS, and mData.
Referenced by moab::WriteDamsel::map_sparse_tags().
|
virtual |
Check if entity is tagged.
Implements moab::TagInfo.
Definition at line 537 of file SparseTag.cpp.
538 {
539 return mData.find( h ) != mData.end();
540 }
References mData.
|
virtual |
Count all tagged entities.
Gets all entity handles that match a type and tag.
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.
seqman | Pointer to entity storage database |
output_count | This is incremented for each detected entity. |
type | Optional entity type. If specified, search is limited to entities of specified type. |
intersect | Optional intersect list. If specified, search is restricted to entities in this list. |
Implements moab::TagInfo.
Definition at line 451 of file SparseTag.cpp.
455 {
456 InsertCount counter( output_count );
457 get_tagged( mData, counter, type, intersect );
458 output_count = counter.end();
459 return MB_SUCCESS;
460 }
References moab::InsertCount::end(), moab::get_tagged(), moab::intersect(), MB_SUCCESS, and mData.
|
virtual |
Remove/clear tag data for all entities.
Remove tag values from entities.
delete_pending | If 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.
seqman | Pointer to mesh entity database |
Implements moab::TagInfo.
Definition at line 46 of file SparseTag.cpp.
47 {
48 for( MapType::iterator i = mData.begin(); i != mData.end(); ++i )
49 mAllocator.destroy( i->second );
50 mData.clear();
51 return MB_SUCCESS;
52 }
References moab::SparseTagDataAllocator::destroy(), mAllocator, MB_SUCCESS, and mData.
Referenced by ~SparseTag().
|
inlineprivate |
removes the data
Definition at line 106 of file SparseTag.cpp.
107 {
108 MapType::iterator i = mData.find( entity_handle );
109 if( i == mData.end() ) return MB_TAG_NOT_FOUND;
110
111 mAllocator.destroy( i->second );
112 mData.erase( i );
113
114 return MB_SUCCESS;
115 }
References moab::SparseTagDataAllocator::destroy(), mAllocator, MB_SUCCESS, MB_TAG_NOT_FOUND, and mData.
|
virtual |
Remove/clear tag data for entities.
Remove tag values from entities.
seqman | Pointer to mesh entity database |
entities | Entity handles for which to store tag data |
num_entities | Length of entities array |
Implements moab::TagInfo.
Definition at line 321 of file SparseTag.cpp.
325 {
326 ErrorCode rval;
327 for( size_t i = 0; i < num_entities; ++i )
328 {
329 rval = remove_data( NULL, entities[i] );
330 if( MB_SUCCESS != rval ) return rval;
331 }
332
333 return MB_SUCCESS;
334 }
References entities, ErrorCode, and MB_SUCCESS.
Referenced by remove_data().
|
virtual |
Remove/clear tag data for entities.
Remove tag values from entities.
seqman | Pointer to mesh entity database |
entities | Entity handles for which to store tag data |
Implements moab::TagInfo.
Definition at line 336 of file SparseTag.cpp.
337 {
338 for( Range::const_iterator i = entities.begin(); i != entities.end(); ++i )
339 if( MB_SUCCESS != remove_data( NULL, *i ) ) return MB_TAG_NOT_FOUND;
340
341 return MB_SUCCESS;
342 }
References entities, MB_SUCCESS, MB_TAG_NOT_FOUND, and remove_data().
|
inlineprivate |
set the tag data for an entity id \NOTE Will fail with MB_VARIABLE_DATA_LENGTH if called for variable-length tag.
Definition at line 54 of file SparseTag.cpp.
55 {
56 #ifdef MOAB_HAVE_UNORDERED_MAP
57 MapType::iterator iter = mData.find( entity_handle );
58 #else
59 MapType::iterator iter = mData.lower_bound( entity_handle );
60 #endif
61
62 // Data space already exists
63 if( iter != mData.end() && iter->first == entity_handle ) memcpy( iter->second, data, get_size() );
64 // We need to make some data space
65 else
66 {
67 void* new_data = allocate_data( entity_handle, iter, false );
68 memcpy( new_data, data, get_size() );
69 }
70
71 return MB_SUCCESS;
72 }
References allocate_data(), moab::TagInfo::get_size(), MB_SUCCESS, and mData.
|
virtual |
Set tag value for passed entities.
Store tag data or update stored tag values \Note Will fail for variable-length data.
seqman | Pointer to mesh entity database |
entities | Entity handles for which to store tag data |
num_entities | Length of entities array |
data | Pointer to memory holding consecutive tag values, one for each passed entity. |
Implements moab::TagInfo.
Definition at line 208 of file SparseTag.cpp.
213 {
214 ErrorCode rval = seqman->check_valid_entities( NULL, entities, num_entities, true );MB_CHK_ERR( rval );
215
216 const unsigned char* ptr = reinterpret_cast< const unsigned char* >( data );
217 for( size_t i = 0; i < num_entities; ++i, ptr += get_size() )
218 {
219 rval = set_data( NULL, entities[i], ptr );MB_CHK_ERR( rval );
220 }
221
222 return MB_SUCCESS;
223 }
References moab::SequenceManager::check_valid_entities(), entities, ErrorCode, moab::TagInfo::get_size(), MB_CHK_ERR, and MB_SUCCESS.
Referenced by clear_data(), and set_data().
|
virtual |
Set tag value for passed entities.
Store tag data or update stored tag values
seqman | Pointer to mesh entity database |
entities | Entity handles for which to store tag data |
num_entities | Length of entities array |
data_ptrs | Array of pointers to tag values, one pointer for each passed entity. |
data_lengths | One 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 237 of file SparseTag.cpp.
243 {
244 ErrorCode rval = validate_lengths( NULL, lengths, num_entities );MB_CHK_ERR( rval );
245
246 rval = seqman->check_valid_entities( NULL, entities, num_entities, true );MB_CHK_ERR( rval );
247
248 for( size_t i = 0; i < num_entities; ++i, ++pointers )
249 {
250 rval = set_data( NULL, entities[i], *pointers );MB_CHK_ERR( rval );
251 }
252
253 return MB_SUCCESS;
254 }
References moab::SequenceManager::check_valid_entities(), entities, ErrorCode, MB_CHK_ERR, MB_SUCCESS, set_data(), and moab::TagInfo::validate_lengths().
|
virtual |
Set tag value for passed entities.
Store tag data or update stored tag values \Note Will fail for variable-length data.
seqman | Pointer to mesh entity database |
entities | Entity handles for which to store tag data |
data | Pointer to memory holding consecutive tag values, one for each passed entity. |
Implements moab::TagInfo.
Definition at line 225 of file SparseTag.cpp.
226 {
227 ErrorCode rval = seqman->check_valid_entities( NULL, entities );MB_CHK_ERR( rval );
228
229 const unsigned char* ptr = reinterpret_cast< const unsigned char* >( data );
230 Range::const_iterator i;
231 for( i = entities.begin(); i != entities.end(); ++i, ptr += get_size() )
232 if( MB_SUCCESS != ( rval = set_data( NULL, *i, ptr ) ) ) return rval;
233
234 return MB_SUCCESS;
235 }
References moab::SequenceManager::check_valid_entities(), entities, ErrorCode, moab::TagInfo::get_size(), MB_CHK_ERR, MB_SUCCESS, and set_data().
|
virtual |
Set tag value for passed entities.
Store tag data or update stored tag values
seqman | Pointer to mesh entity database |
entities | Entity handles for which to store tag data |
data_ptrs | Array of pointers to tag values, one pointer for each passed entity. |
data_lengths | One 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 256 of file SparseTag.cpp.
261 {
262 ErrorCode rval = validate_lengths( NULL, lengths, entities.size() );MB_CHK_ERR( rval );
263
264 rval = seqman->check_valid_entities( NULL, entities );MB_CHK_ERR( rval );
265
266 Range::const_iterator i;
267 for( i = entities.begin(); i != entities.end(); ++i, ++pointers )
268 {
269 rval = set_data( NULL, *i, *pointers );MB_CHK_ERR( rval );
270 }
271
272 return MB_SUCCESS;
273 }
References moab::SequenceManager::check_valid_entities(), entities, ErrorCode, MB_CHK_ERR, MB_SUCCESS, set_data(), and moab::TagInfo::validate_lengths().
|
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.
iter | As input, the first entity for which to return data. As output, one past the last entity for which data was returned. |
end | One past the last entity for which data is desired |
data_ptr | Output: pointer to tag storage. |
allocate | If 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 344 of file SparseTag.cpp.
350 {
351 // Note: We are asked to returning a block of contiguous storage
352 // for some block of contiguous handles for which the tag
353 // storage is also contiguous. As sparse tag storage is
354 // never contiguous, all we can do is return a pointer to the
355 // data for the first entity.
356
357 // If asked for nothing, successfully return nothing.
358 if( iter == end ) return MB_SUCCESS;
359
360 // Note: get_data_ptr will return the default value if the
361 // handle is not found, so test to make sure that the
362 // handle is valid.
363 ErrorCode rval = seqman->check_valid_entities( NULL, &*iter, 1 );MB_CHK_ERR( rval );
364
365 // Get pointer to tag storage for entity pointed to by iter
366 const void* ptr = NULL;
367 rval = get_data_ptr( *iter, ptr );
368 if( MB_SUCCESS == rval )
369 data_ptr = const_cast< void* >( ptr );
370 else if( get_default_value() && allocate )
371 {
372 ptr = allocate_data( *iter, mData.end() );
373 data_ptr = const_cast< void* >( ptr );
374 }
375 else
376 {
377 // If allocation was not requested, need to increment the iterator so that
378 // the count can be computed properly
379 if( get_default_value() && !allocate ) ++iter;
380 // return not_found(get_name(), *iter);
381 }
382
383 // Increment iterator and return
384 ++iter;
385 return MB_SUCCESS;
386 }
References allocate_data(), moab::SequenceManager::check_valid_entities(), ErrorCode, get_data_ptr(), moab::TagInfo::get_default_value(), MB_CHK_ERR, MB_SUCCESS, and mData.
|
private |
allocator for this collection
Definition at line 422 of file SparseTag.hpp.
Referenced by allocate_data(), release_all_data(), and remove_data().
|
private |
Definition at line 424 of file SparseTag.hpp.
Referenced by allocate_data(), find_entities_with_value(), get_data_ptr(), get_memory_use(), get_number_entities(), get_tagged_entities(), is_tagged(), num_tagged_entities(), release_all_data(), remove_data(), set_data(), and tag_iterate().