moab
|
Tag with only a global/mesh value. More...
#include <MeshTag.hpp>
Public Member Functions | |
MeshTag (const char *name, int size, DataType type, const void *default_value, int default_value_size) | |
constructor that takes all parameters | |
virtual | ~MeshTag () |
virtual TagType | get_storage_type () const |
virtual ErrorCode | release_all_data (SequenceManager *seqman, Error *error_handler, bool delete_pending) |
Remove/clear tag data for all entities. | |
virtual ErrorCode | get_data (const SequenceManager *seqman, Error *error_handler, const EntityHandle *entities, size_t num_entities, void *data) const |
Get tag value for passed entities. | |
virtual ErrorCode | get_data (const SequenceManager *seqman, Error *error_handler, const Range &entities, void *data) const |
Get tag value for passed entities. | |
virtual ErrorCode | get_data (const SequenceManager *seqman, Error *error_handler, const EntityHandle *entities, size_t num_entities, const void **data_ptrs, int *data_lengths) const |
Get tag value for passed entities. | |
virtual ErrorCode | get_data (const SequenceManager *seqman, Error *error_handler, const Range &entities, const void **data_ptrs, int *data_lengths) const |
Get tag value for passed entities. | |
virtual ErrorCode | set_data (SequenceManager *seqman, Error *error_handler, const EntityHandle *entities, size_t num_entities, const void *data) |
Set tag value for passed entities. | |
virtual ErrorCode | set_data (SequenceManager *seqman, Error *error_handler, const Range &entities, const void *data) |
Set tag value for passed entities. | |
virtual ErrorCode | set_data (SequenceManager *seqman, Error *error_handler, const EntityHandle *entities, size_t num_entities, void const *const *data_ptrs, const int *data_lengths) |
Set tag value for passed entities. | |
virtual ErrorCode | set_data (SequenceManager *seqman, Error *error_handler, const Range &entities, void const *const *data_ptrs, const int *data_lengths) |
Set tag value for passed entities. | |
virtual ErrorCode | clear_data (SequenceManager *seqman, Error *error_handler, const EntityHandle *entities, size_t num_entities, const void *value_ptr, int value_len=0) |
Set tag value for passed entities. | |
virtual ErrorCode | clear_data (SequenceManager *seqman, Error *error_handler, const Range &entities, const void *value_ptr, int value_len=0) |
Set tag value for passed entities. | |
virtual ErrorCode | remove_data (SequenceManager *seqman, Error *error_handler, const EntityHandle *entities, size_t num_entities) |
Remove/clear tag data for entities. | |
virtual ErrorCode | remove_data (SequenceManager *seqman, Error *error_handler, const Range &entities) |
Remove/clear tag data for entities. | |
virtual ErrorCode | tag_iterate (SequenceManager *seqman, Error *error_handler, Range::iterator &iter, const Range::iterator &end, void *&data_ptr, bool allocate=true) |
Access tag data via direct pointer into contiguous blocks. | |
virtual ErrorCode | get_tagged_entities (const SequenceManager *seqman, Range &output_entities, EntityType type=MBMAXTYPE, const Range *intersect=0) const |
Get all tagged entities. | |
virtual ErrorCode | num_tagged_entities (const SequenceManager *seqman, size_t &output_count, EntityType type=MBMAXTYPE, const Range *intersect=0) const |
Count all tagged entities. | |
virtual ErrorCode | find_entities_with_value (const SequenceManager *seqman, Error *error_handler, Range &output_entities, const void *value, int value_bytes=0, EntityType type=MBMAXTYPE, const Range *intersect_entities=0) const |
Get all tagged entities with tag value. | |
virtual bool | is_tagged (const SequenceManager *, EntityHandle h) const |
Check if entity is tagged. | |
virtual ErrorCode | get_memory_use (const SequenceManager *seqman, unsigned long &total, unsigned long &per_entity) const |
Get memory use for tag data. | |
Private Member Functions | |
MeshTag (const MeshTag &) | |
MeshTag & | operator= (const MeshTag &) |
Private Attributes | |
std::vector< unsigned char > | mValue |
Tag with only a global/mesh value.
Trivial tag implementation. No per-entity values. Only the global mesh value which is handled by the TagInfo
base class.
Definition at line 19 of file MeshTag.hpp.
moab::MeshTag::MeshTag | ( | const char * | name, |
int | size, | ||
DataType | type, | ||
const void * | default_value, | ||
int | default_value_size | ||
) |
constructor that takes all parameters
Definition at line 49 of file MeshTag.cpp.
moab::MeshTag::~MeshTag | ( | ) | [virtual] |
Definition at line 57 of file MeshTag.cpp.
{}
moab::MeshTag::MeshTag | ( | const MeshTag & | ) | [private] |
ErrorCode moab::MeshTag::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 217 of file MeshTag.cpp.
{ if (!all_root_set( error, get_name(), entities, num_entities )) return MB_TAG_NOT_FOUND; ErrorCode valid = validate_lengths( error, value_len ? &value_len : 0, 1 ); if (MB_SUCCESS != valid) return valid; if (num_entities > 0) { mValue.resize( value_len ); memcpy( &mValue[0], value_ptr, value_len ); } return MB_SUCCESS; }
ErrorCode moab::MeshTag::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 239 of file MeshTag.cpp.
{ if (range.empty()) return MB_SUCCESS; else return not_root_set( error, get_name(), range.front() ); }
ErrorCode moab::MeshTag::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 303 of file MeshTag.cpp.
{ return MB_SUCCESS; }
ErrorCode moab::MeshTag::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 65 of file MeshTag.cpp.
{ if (!all_root_set( error, get_name(), entities, num_entities )) return MB_TAG_NOT_FOUND; const void* ptr; int len; if (!mValue.empty()) { ptr = &mValue[0]; len = mValue.size(); } else if (get_default_value()) { ptr = get_default_value(); len = get_default_value_size(); } else { return not_found(error, get_name()); } SysUtil::setmem( data, ptr, len, num_entities ); return MB_SUCCESS; }
ErrorCode moab::MeshTag::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 94 of file MeshTag.cpp.
{ if (variable_length()) return var_len(error, get_name()); else if (r.empty()) return MB_SUCCESS; else return not_root_set( error, get_name(), r.front() ); }
ErrorCode moab::MeshTag::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 107 of file MeshTag.cpp.
{ const void* ptr; int len; if (!mValue.empty()) { ptr = &mValue[0]; len = mValue.size(); } else if (get_default_value()) { ptr = get_default_value(); len = get_default_value_size(); } else { return not_found( error, get_name() ); } for (size_t i = 0; i < num_entities; ++i) { if (entities[i]) return not_root_set(error,get_name(), entities[i]); // not root set data_ptrs[i] = ptr; if (data_lengths) data_lengths[i] = len; } return MB_SUCCESS; }
ErrorCode moab::MeshTag::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 139 of file MeshTag.cpp.
{ if (range.empty()) return MB_SUCCESS; else return not_root_set( error, get_name(), range.front() ); }
ErrorCode moab::MeshTag::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 317 of file MeshTag.cpp.
{ total = TagInfo::get_memory_use() + sizeof(*this) + mValue.size(); per_entity = 0; return MB_SUCCESS; }
TagType moab::MeshTag::get_storage_type | ( | ) | const [virtual] |
ErrorCode moab::MeshTag::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 287 of file MeshTag.cpp.
{ return MB_SUCCESS; }
bool moab::MeshTag::is_tagged | ( | const SequenceManager * | , |
EntityHandle | h | ||
) | const [virtual] |
Check if entity is tagged.
Implements moab::TagInfo.
Definition at line 314 of file MeshTag.cpp.
{ return !h && !mValue.empty(); }
ErrorCode moab::MeshTag::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 295 of file MeshTag.cpp.
{ return MB_SUCCESS; }
ErrorCode moab::MeshTag::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 62 of file MeshTag.cpp.
{ return MB_SUCCESS; }
ErrorCode moab::MeshTag::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 251 of file MeshTag.cpp.
{ if (!all_root_set( error, get_name(), entities, num_entities )) return MB_TAG_NOT_FOUND; if (num_entities) mValue.clear();; return MB_SUCCESS; }
ErrorCode moab::MeshTag::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 264 of file MeshTag.cpp.
{ if (range.empty()) return MB_SUCCESS; else return not_root_set( error, get_name(), range.front() ); }
ErrorCode moab::MeshTag::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 151 of file MeshTag.cpp.
{ if (variable_length()) return var_len(error, get_name());; if (!all_root_set( error, get_name(), entities, num_entities )) return MB_TAG_NOT_FOUND; if (num_entities > 0) { mValue.resize( get_size() ); const unsigned char* bytes = reinterpret_cast<const unsigned char*>(data); memcpy( &mValue[0], bytes + get_size() * (num_entities - 1), get_size() ); } return MB_SUCCESS; }
ErrorCode moab::MeshTag::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 170 of file MeshTag.cpp.
{ if (variable_length()) return var_len(error, get_name()); else if (range.empty()) return MB_SUCCESS; else return not_root_set( error, get_name(), range.front() ); }
ErrorCode moab::MeshTag::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 183 of file MeshTag.cpp.
{ if (!all_root_set( error, get_name(), entities, num_entities )) return MB_TAG_NOT_FOUND; ErrorCode valid = validate_lengths( error, data_lengths, num_entities ); if (MB_SUCCESS != valid) return valid; if (num_entities > 0) { mValue.resize( data_lengths[num_entities-1] ); memcpy( &mValue[0], data_ptrs[num_entities-1], mValue.size() ); } return MB_SUCCESS; }
ErrorCode moab::MeshTag::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 205 of file MeshTag.cpp.
{ if (range.empty()) return MB_SUCCESS; else return not_root_set( error, get_name(), range.front() ); }
ErrorCode moab::MeshTag::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. |
allocate | If true, allocate space for this tag as part of this call, else don't |
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 274 of file MeshTag.cpp.
{ if (beg == end) return MB_SUCCESS; else return not_root_set( error, get_name(), *beg ); }
std::vector<unsigned char> moab::MeshTag::mValue [private] |
Definition at line 371 of file MeshTag.hpp.