moab
|
data for a single bit tag More...
#include <BitTag.hpp>
Public Types | |
enum | { Ln2PageSize = 12, PageSize = (1u << Ln2PageSize) } |
Public Member Functions | |
virtual | ~BitTag () |
virtual TagType | get_storage_type () const |
virtual ErrorCode | release_all_data (SequenceManager *seqman, Error *error_handler, bool delete_pending) |
Remove/clear tag data for all entities. | |
virtual ErrorCode | get_data (const SequenceManager *seqman, Error *error_handler, const EntityHandle *entities, size_t num_entities, void *data) const |
Get tag value for passed entities. | |
virtual ErrorCode | get_data (const SequenceManager *seqman, Error *error_handler, const Range &entities, void *data) const |
Get tag value for passed entities. | |
virtual ErrorCode | get_data (const SequenceManager *seqman, Error *error_handler, const EntityHandle *entities, size_t num_entities, const void **data_ptrs, int *data_lengths) const |
Get tag value for passed entities. | |
virtual ErrorCode | get_data (const SequenceManager *seqman, Error *error_handler, const Range &entities, const void **data_ptrs, int *data_lengths) const |
Get tag value for passed entities. | |
virtual ErrorCode | set_data (SequenceManager *seqman, Error *error_handler, const EntityHandle *entities, size_t num_entities, const void *data) |
Set tag value for passed entities. | |
virtual ErrorCode | set_data (SequenceManager *seqman, Error *error_handler, const Range &entities, const void *data) |
Set tag value for passed entities. | |
virtual ErrorCode | set_data (SequenceManager *seqman, Error *error_handler, const EntityHandle *entities, size_t num_entities, void const *const *data_ptrs, const int *data_lengths) |
Set tag value for passed entities. | |
virtual ErrorCode | set_data (SequenceManager *seqman, Error *error_handler, const Range &entities, void const *const *data_ptrs, const int *data_lengths) |
Set tag value for passed entities. | |
virtual ErrorCode | clear_data (SequenceManager *seqman, Error *error_handler, const EntityHandle *entities, size_t num_entities, const void *value_ptr, int value_len=0) |
Set tag value for passed entities. | |
virtual ErrorCode | clear_data (SequenceManager *seqman, Error *error_handler, const Range &entities, const void *value_ptr, int value_len=0) |
Set tag value for passed entities. | |
virtual ErrorCode | remove_data (SequenceManager *seqman, Error *error_handler, const EntityHandle *entities, size_t num_entities) |
Remove/clear tag data for entities. | |
virtual ErrorCode | remove_data (SequenceManager *seqman, Error *error_handler, const Range &entities) |
Remove/clear tag data for entities. | |
virtual ErrorCode | tag_iterate (SequenceManager *seqman, Error *error_handler, Range::iterator &iter, const Range::iterator &end, void *&data_ptr, bool allocate=true) |
Access tag data via direct pointer into contiguous blocks. | |
virtual ErrorCode | get_tagged_entities (const SequenceManager *seqman, Range &output_entities, EntityType type=MBMAXTYPE, const Range *intersect=0) const |
Get all tagged entities. | |
virtual ErrorCode | num_tagged_entities (const SequenceManager *seqman, size_t &output_count, EntityType type=MBMAXTYPE, const Range *intersect=0) const |
Count all tagged entities. | |
virtual ErrorCode | find_entities_with_value (const SequenceManager *seqman, Error *error_handler, Range &output_entities, const void *value, int value_bytes=0, EntityType type=MBMAXTYPE, const Range *intersect_entities=0) const |
Get all tagged entities with tag value. | |
virtual bool | is_tagged (const SequenceManager *, EntityHandle h) const |
Check if entity is tagged. | |
ErrorCode | get_memory_use (const SequenceManager *seqman, unsigned long &total, unsigned long &per_entity) const |
Get memory use for tag data. | |
ErrorCode | get_entities_with_bits (EntityType type, Range &entities, unsigned char bits) const |
Get entities for which an explicit tag of the specified value is stored. | |
ErrorCode | get_entities_with_bits (const Range &range, EntityType type, Range &entities, unsigned char bits) const |
Get entities for which an explicit tag of the specified value is stored. | |
Static Public Member Functions | |
static BitTag * | create_tag (const char *name, int size, const void *default_value=0) |
Private Member Functions | |
BitTag (const char *name, int size, const void *default_value) | |
BitTag (const BitTag &) | |
BitTag & | operator= (const BitTag &) |
ErrorCode | reserve (unsigned bits) |
unsigned char | default_val () const |
void | unpack (EntityHandle h, EntityType &type, size_t &page, int &offset) const |
Get indices from handle. | |
int | ents_per_page () const |
Get the number of tag values that are stored in each BitPage. | |
template<class Container > | |
void | get_tagged (EntityType type, Container &entities) const |
template<class Container > | |
void | get_tagged (Range::const_iterator begin, Range::const_iterator end, Container &entities) const |
template<class Container > | |
void | get_tagged (Container &entities, EntityType type, const Range *intersect) const |
Private Attributes | |
std::vector< BitPage * > | pageList [MBMAXTYPE] |
Array of BitPage instances storing actual data. | |
unsigned int | requestedBitsPerEntity |
user-requested bits per entity | |
unsigned int | storedBitsPerEntity |
allocated bits per entity (power of 2) | |
unsigned int | pageShift |
log2( ents_per_page() ) |
data for a single bit tag
Definition at line 15 of file BitTag.hpp.
anonymous enum |
Ln2PageSize |
Constant: log2(PageSize) |
PageSize |
Constant: Bytes per BitPage (power of 2) |
Definition at line 379 of file BitTag.hpp.
{ Ln2PageSize = 12, PageSize = (1u << Ln2PageSize) };
moab::BitTag::BitTag | ( | const char * | name, |
int | size, | ||
const void * | default_value | ||
) | [inline, private] |
Definition at line 19 of file BitTag.hpp.
: TagInfo( name, size, MB_TYPE_BIT, default_value, default_value ? 1 : 0 ) {}
moab::BitTag::~BitTag | ( | ) | [virtual] |
Definition at line 12 of file BitTag.cpp.
{ release_all_data(0,0,true); }
moab::BitTag::BitTag | ( | const BitTag & | ) | [private] |
ErrorCode moab::BitTag::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.
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 109 of file BitTag.cpp.
{ if (value_len) return MB_INVALID_SIZE; ErrorCode rval = seqman->check_valid_entities( error, handles, num_handles, true ); if (MB_SUCCESS != rval) return rval; EntityType type; size_t page; int offset; const unsigned char value = *reinterpret_cast<const unsigned char*>(value_ptr); for (size_t i = 0; i < num_handles; ++i) { unpack( handles[i], type, page, offset ); if (pageList[type].size() <= page) pageList[type].resize(page+1, 0); if (!pageList[type][page]) pageList[type][page] = new BitPage( storedBitsPerEntity, default_val()); pageList[type][page]->set_bits( offset, storedBitsPerEntity, value ); } return MB_SUCCESS; }
ErrorCode moab::BitTag::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.
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 230 of file BitTag.cpp.
{ if (value_len) return MB_INVALID_SIZE; ErrorCode rval = seqman->check_valid_entities( error, handles ); if (MB_SUCCESS != rval) return rval; EntityType type; EntityID count; size_t page; int offset, per_page = ents_per_page(); const unsigned char value = *reinterpret_cast<const unsigned char*>(value_ptr); Range::const_pair_iterator i; for (i = handles.const_pair_begin(); i != handles.const_pair_end(); ++i) { unpack( i->first, type, page, offset ); assert(TYPE_FROM_HANDLE(i->second) == type); // should be true because id of zero is never used count = i->second - i->first + 1; while (count) { if (page >= pageList[type].size()) pageList[type].resize( page+1, 0 ); if (!pageList[type][page]) pageList[type][page] = new BitPage( storedBitsPerEntity, default_val() ); size_t pcount = std::min( (EntityID)(per_page - offset), count ); pageList[type][page]->set_bits( offset, pcount, storedBitsPerEntity, value ); count -= pcount; offset = 0; ++page; } } return MB_SUCCESS; }
BitTag * moab::BitTag::create_tag | ( | const char * | name, |
int | size, | ||
const void * | default_value = 0 |
||
) | [static] |
Definition at line 17 of file BitTag.cpp.
unsigned char moab::BitTag::default_val | ( | ) | const [inline, private] |
Definition at line 389 of file BitTag.hpp.
{ if (get_default_value()) return *reinterpret_cast<const unsigned char*>(get_default_value()); else return 0; }
int moab::BitTag::ents_per_page | ( | ) | const [inline, private] |
Get the number of tag values that are stored in each BitPage.
Definition at line 416 of file BitTag.hpp.
{ return 8*PageSize/storedBitsPerEntity; }
ErrorCode moab::BitTag::find_entities_with_value | ( | const SequenceManager * | seqman, |
Error * | error_handler, | ||
Range & | output_entities, | ||
const void * | value, | ||
int | value_bytes = 0 , |
||
EntityType | type = MBMAXTYPE , |
||
const Range * | intersect_entities = 0 |
||
) | const [virtual] |
Get all tagged entities with tag value.
Get the list of entities which have the specified tag value.
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 | Opotional intersect list. If specified, search is restricted to entities in this list. |
Implements moab::TagInfo.
Definition at line 429 of file BitTag.cpp.
{ if (value_bytes && value_bytes != 1) { error->set_last_error("Inavlid tag size for bit tag: %d bytes\n",value_bytes); return MB_INVALID_SIZE; } const signed char bits = *reinterpret_cast<const unsigned char*>(value); if (intersect_entities) return get_entities_with_bits( *intersect_entities, type, output_entities, bits ); else return get_entities_with_bits( type, output_entities, bits ); }
ErrorCode moab::BitTag::get_data | ( | const SequenceManager * | seqman, |
Error * | error_handler, | ||
const EntityHandle * | entities, | ||
size_t | num_entities, | ||
void * | data | ||
) | const [virtual] |
Get tag value for passed entities.
Get tag values for specified entities.
Will fail for variable-length data.
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 63 of file BitTag.cpp.
{ EntityType type; size_t page; int offset; unsigned char def = default_val(); unsigned char* data = reinterpret_cast<unsigned char*>(gen_data); for (size_t i = 0; i < num_handles; ++i) { unpack( handles[i], type, page, offset ); if (pageList[type].size() <= page || !pageList[type][page]) data[i] = def; else data[i] = pageList[type][page]->get_bits( offset, storedBitsPerEntity ); } return MB_SUCCESS; }
ErrorCode moab::BitTag::get_data | ( | const SequenceManager * | seqman, |
Error * | error_handler, | ||
const Range & | entities, | ||
void * | data | ||
) | const [virtual] |
Get tag value for passed entities.
Get tag values for specified entities.
Will fail for variable-length data.
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 155 of file BitTag.cpp.
{ EntityType type; EntityID count; size_t page; int offset, per_page = ents_per_page(); unsigned char def = default_val(); unsigned char* data = reinterpret_cast<unsigned char*>(gen_data); Range::const_pair_iterator i; for (i = handles.const_pair_begin(); i != handles.const_pair_end(); ++i) { unpack( i->first, type, page, offset ); assert(TYPE_FROM_HANDLE(i->second) == type); // should be true because id of zero is never used count = i->second - i->first + 1; if (page >= pageList[type].size()) { memset( data, def, count ); data += count; continue; } while (count) { size_t pcount = std::min( (EntityID)(per_page - offset), count ); if (pageList[type][page]) pageList[type][page]->get_bits( offset, pcount, storedBitsPerEntity, data ); else memset( data, def, pcount ); data += pcount; count -= pcount; offset = 0; ++page; } } return MB_SUCCESS; }
ErrorCode moab::BitTag::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.
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 301 of file BitTag.cpp.
{ return report_unsupported(error); }
ErrorCode moab::BitTag::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.
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 309 of file BitTag.cpp.
{ return report_unsupported(error); }
ErrorCode moab::BitTag::get_entities_with_bits | ( | EntityType | type, |
Range & | entities, | ||
unsigned char | bits | ||
) | const |
Get entities for which an explicit tag of the specified value is stored.
Definition at line 454 of file BitTag.cpp.
{ std::pair<EntityType,EntityType> r = type_range(type); const int per_page = ents_per_page(); for (EntityType t = r.first; t != r.second; ++t) { for (size_t i = 0; i < pageList[t].size(); ++i) { if (pageList[t][i]) { EntityID id = i * per_page; EntityHandle h = CREATE_HANDLE( t, id ); int off = !i; // never zero ID pageList[t][i]->search( bits, off, per_page-off, storedBitsPerEntity, entities, h+off ); } } } return MB_SUCCESS; }
ErrorCode moab::BitTag::get_entities_with_bits | ( | const Range & | range, |
EntityType | type, | ||
Range & | entities, | ||
unsigned char | bits | ||
) | const |
Get entities for which an explicit tag of the specified value is stored.
Definition at line 474 of file BitTag.cpp.
{ if (MBMAXTYPE == in_type) { ErrorCode rval; for (--in_type; in_type >= MBVERTEX; --in_type) { rval = get_entities_with_bits( range, in_type, entities, bits ); if (MB_SUCCESS != rval) return rval; } return MB_SUCCESS; } EntityType type; EntityID count; size_t page; int offset, per_page = ents_per_page(); Range::const_iterator j, i, end; if (MBMAXTYPE == in_type) { i = range.begin(); end = range.end(); } else { std::pair<Range::iterator,Range::iterator> r = range.equal_range(in_type); i = r.first; end = r.second; } EntityHandle h; while (i != end) { h = *i; unpack( h, type, page, offset ); assert(MBMAXTYPE == in_type || type == in_type); i = i.end_of_block(); count = *i - h + 1; ++i; while (count > 0) { EntityID pcount = std::min( count, (EntityID)(per_page - offset) ); if (page < pageList[type].size() && pageList[type][page]) pageList[type][page]->search( bits, offset, pcount, storedBitsPerEntity, entities, h ); count -= pcount; h += pcount; assert(TYPE_FROM_HANDLE(h) == type); offset = 0; ++page; } } return MB_SUCCESS; }
ErrorCode moab::BitTag::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 529 of file BitTag.cpp.
{ per_entity = (storedBitsPerEntity > 4); // cannot return fraction of bytes, so round total = 0; for (EntityType t = (EntityType)0; t < MBMAXTYPE; ++t) { total += pageList[t].capacity() * sizeof(BitPage*); for (size_t i = 0; i < pageList[t].size(); ++i) if (pageList[t][i]) total += sizeof(BitPage); } return MB_SUCCESS; }
TagType moab::BitTag::get_storage_type | ( | ) | const [virtual] |
void moab::BitTag::get_tagged | ( | EntityType | type, |
Container & | entities | ||
) | const [inline, private] |
Definition at line 340 of file BitTag.cpp.
{ std::pair<EntityType,EntityType> r = type_range(type); typename Container::iterator hint = entities.begin(); const int per_page = ents_per_page(); for (EntityType t = r.first; t != r.second; ++t) { for (size_t i = 0; i < pageList[t].size(); ++i) { if (pageList[t][i]) { EntityID id = i * per_page; EntityHandle h = CREATE_HANDLE( t, id ); EntityHandle last = h + per_page - 1; // never zero ID if (!id) ++h; hint = entities.insert( hint, h, last ); } } } }
void moab::BitTag::get_tagged | ( | Range::const_iterator | begin, |
Range::const_iterator | end, | ||
Container & | entities | ||
) | const [inline, private] |
Definition at line 361 of file BitTag.cpp.
{ EntityType type; EntityID count; size_t page; int offset, per_page = ents_per_page(); typename Container::iterator hint = entities.begin(); EntityHandle h; Range::const_iterator i = begin; while (i != end) { h = *i; unpack( h, type, page, offset ); i = i.end_of_block(); count = *i - h + 1; ++i; while (count > 0) { EntityID pcount = std::min( count, (EntityID)(per_page - offset) ); if (page < pageList[type].size() && pageList[type][page]) hint = entities.insert( hint, h, h+pcount-1 ); count -= pcount; h += pcount; assert(TYPE_FROM_HANDLE(h) == type); offset = 0; ++page; } } }
void moab::BitTag::get_tagged | ( | Container & | entities, |
EntityType | type, | ||
const Range * | intersect | ||
) | const [inline, private] |
Definition at line 394 of file BitTag.cpp.
{ if (!intersect) get_tagged<Container>( type, entities ); else if (MBMAXTYPE == type) get_tagged<Container>( intersect->begin(), intersect->end(), entities ); else { std::pair<Range::iterator,Range::iterator> r = intersect->equal_range(type); get_tagged<Container>( r.first, r.second, entities ); } }
ErrorCode moab::BitTag::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.
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 | Opotional intersect list. If specified, search is restricted to entities in this list. |
Implements moab::TagInfo.
Definition at line 409 of file BitTag.cpp.
{ get_tagged<Range>( entities, type, intersect ); return MB_SUCCESS; }
bool moab::BitTag::is_tagged | ( | const SequenceManager * | , |
EntityHandle | h | ||
) | const [virtual] |
Check if entity is tagged.
Implements moab::TagInfo.
Definition at line 544 of file BitTag.cpp.
{ EntityType type; size_t page; int offset; unpack( h, type, page, offset ); return page < pageList[type].size() && pageList[type][page]; }
ErrorCode moab::BitTag::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.
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 | Opotional intersect list. If specified, search is restricted to entities in this list. |
Implements moab::TagInfo.
Definition at line 418 of file BitTag.cpp.
{ InsertCount counter( count ); get_tagged<InsertCount>( counter, type, intersect ); count = counter.end(); return MB_SUCCESS; }
ErrorCode moab::BitTag::release_all_data | ( | SequenceManager * | seqman, |
Error * | error_handler, | ||
bool | delete_pending | ||
) | [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. |
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 53 of file BitTag.cpp.
{ for (EntityType t = (EntityType)0; t != MBMAXTYPE; ++t) { for (size_t i = 0; i < pageList[t].size(); ++i) delete pageList[t][i]; pageList[t].clear(); } return MB_SUCCESS; }
ErrorCode moab::BitTag::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.
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 138 of file BitTag.cpp.
{ EntityType type; size_t page; int offset; const unsigned char val = default_val(); for (size_t i = 0; i < num_handles; ++i) { unpack( handles[i], type, page, offset ); if (pageList[type].size() > page && pageList[type][page]) pageList[type][page]->set_bits( offset, storedBitsPerEntity, val ); } return MB_SUCCESS; }
ErrorCode moab::BitTag::remove_data | ( | SequenceManager * | seqman, |
Error * | error_handler, | ||
const Range & | entities | ||
) | [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 270 of file BitTag.cpp.
{ EntityType type; EntityID count; size_t page; int offset, per_page = ents_per_page(); unsigned char val = default_val(); Range::const_pair_iterator i; for (i = handles.const_pair_begin(); i != handles.const_pair_end(); ++i) { unpack( i->first, type, page, offset ); assert(TYPE_FROM_HANDLE(i->second) == type); // should be true because id of zero is never used count = i->second - i->first + 1; while (count) { size_t pcount = std::min( (EntityID)(per_page - offset), count ); if (page < pageList[type].size() && pageList[type][page]) pageList[type][page]->set_bits( offset, pcount, storedBitsPerEntity, val ); count -= pcount; offset = 0; ++page; } } return MB_SUCCESS; }
ErrorCode moab::BitTag::reserve | ( | unsigned | bits | ) | [private] |
Definition at line 29 of file BitTag.cpp.
{ if (bits > 8) return MB_FAILURE; requestedBitsPerEntity = bits; // store smallest power of two greater than or // equal to the number of bits storedBitsPerEntity = 1; unsigned ln2storedbits = 0; while (storedBitsPerEntity < bits) { storedBitsPerEntity *= 2; ++ln2storedbits; } // pageShift = log2( ents_per_page() ) // = log2( 8 * pageSize / storedBitsPerEntity ) // = log2(8) + log2(pageSize) - log2(storedBitsPerEntity) // = 3 + Ln2PageSize - ln2storedbits; pageShift = 3 + Ln2PageSize - ln2storedbits; return MB_SUCCESS; }
ErrorCode moab::BitTag::set_data | ( | SequenceManager * | seqman, |
Error * | error_handler, | ||
const EntityHandle * | entities, | ||
size_t | num_entities, | ||
const void * | data | ||
) | [virtual] |
Set tag value for passed entities.
Store tag data or update stored tag values Will fail for variable-length data.
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 84 of file BitTag.cpp.
{ ErrorCode rval = seqman->check_valid_entities( error, handles, num_handles, true ); if (MB_SUCCESS != rval) return rval; EntityType type; size_t page; int offset; const unsigned char* data = reinterpret_cast<const unsigned char*>(gen_data); for (size_t i = 0; i < num_handles; ++i) { unpack( handles[i], type, page, offset ); if (pageList[type].size() <= page) pageList[type].resize(page+1, 0); if (!pageList[type][page]) pageList[type][page] = new BitPage( storedBitsPerEntity, default_val()); pageList[type][page]->set_bits( offset, storedBitsPerEntity, data[i] ); } return MB_SUCCESS; }
ErrorCode moab::BitTag::set_data | ( | SequenceManager * | seqman, |
Error * | error_handler, | ||
const Range & | entities, | ||
const void * | data | ||
) | [virtual] |
Set tag value for passed entities.
Store tag data or update stored tag values Will fail for variable-length data.
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 192 of file BitTag.cpp.
{ ErrorCode rval = seqman->check_valid_entities( error, handles ); if (MB_SUCCESS != rval) return rval; EntityType type; EntityID count; size_t page; int offset, per_page = ents_per_page(); unsigned char def = default_val(); const unsigned char* data = reinterpret_cast<const unsigned char*>(gen_data); Range::const_pair_iterator i; for (i = handles.const_pair_begin(); i != handles.const_pair_end(); ++i) { unpack( i->first, type, page, offset ); assert(TYPE_FROM_HANDLE(i->second) == type); // should be true because id of zero is never used count = i->second - i->first + 1; while (count) { if (page >= pageList[type].size()) pageList[type].resize( page+1, 0 ); if (!pageList[type][page]) pageList[type][page] = new BitPage( storedBitsPerEntity, def ); size_t pcount = std::min( (EntityID)(per_page - offset), count ); pageList[type][page]->set_bits( offset, pcount, storedBitsPerEntity, data ); data += pcount; count -= pcount; offset = 0; ++page; } } return MB_SUCCESS; }
ErrorCode moab::BitTag::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
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 316 of file BitTag.cpp.
{ return report_unsupported(error); }
ErrorCode moab::BitTag::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
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 324 of file BitTag.cpp.
{ return report_unsupported(error); }
ErrorCode moab::BitTag::tag_iterate | ( | SequenceManager * | seqman, |
Error * | error_handler, | ||
Range::iterator & | iter, | ||
const Range::iterator & | end, | ||
void *& | data_ptr, | ||
bool | allocate = true |
||
) | [virtual] |
Access tag data via direct pointer into contiguous blocks.
Iteratively obtain direct access to contiguous blocks of tag storage. This function cannot be used with bit tags because of the compressed bit storage. This function cannot be used with variable length tags because it does not provide a mechanism to determine the length of the value for each entity. This function may be used with sparse tags, but if it is used, it will return data for a single entity at a time.
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. |
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 331 of file BitTag.cpp.
{ return report_unsupported(error); }
void moab::BitTag::unpack | ( | EntityHandle | h, |
EntityType & | type, | ||
size_t & | page, | ||
int & | offset | ||
) | const [inline, private] |
Get indices from handle.
type | Output: entity type |
page | Output: index into pageList[type] |
offset | Output: index into pageList[type][page] |
Definition at line 407 of file BitTag.hpp.
{ type = TYPE_FROM_HANDLE(h); h = ID_FROM_HANDLE(h); page = ((size_t)h) >> pageShift; // h / ents_per_page() offset = h & ((1u<<pageShift)-1u); // h % ends_per_page() }
std::vector<BitPage*> moab::BitTag::pageList[MBMAXTYPE] [private] |
Array of BitPage instances storing actual data.
Definition at line 396 of file BitTag.hpp.
unsigned int moab::BitTag::pageShift [private] |
log2( ents_per_page() )
Definition at line 399 of file BitTag.hpp.
unsigned int moab::BitTag::requestedBitsPerEntity [private] |
user-requested bits per entity
Definition at line 397 of file BitTag.hpp.
unsigned int moab::BitTag::storedBitsPerEntity [private] |
allocated bits per entity (power of 2)
Definition at line 398 of file BitTag.hpp.