|
cgma
|
#include <CATag.hpp>
Classes | |
| struct | TagInfo |
Public Member Functions | |
| ~CGMTagManager () | |
| iBase_ErrorType | createTag (const char *tag_name, const int tag_size, const int tag_type, char *default_value, long *tag_handle) |
| iBase_ErrorType | destroyTag (const long tag_handle, const bool forced) |
| const char * | getTagName (const long tag_handle) |
| int | getTagSize (const long tag_handle) |
| long | getTagHandle (const char *tag_name) |
| int | getTagType (const long tag_handle) |
| iBase_ErrorType | getArrData (ARRAY_IN_DECL(RefEntity *, entity_handles), const long tag_handle, ARRAY_INOUT_DECL(char, tag_value)) |
| iBase_ErrorType | setArrData (ARRAY_IN_DECL(RefEntity *, entity_handles), const long tag_handle, const char *tag_values, const int tag_values_size) |
| iBase_ErrorType | rmvArrTag (ARRAY_IN_DECL(RefEntity *, entity_handles), const long tag_handle) |
| iBase_ErrorType | getAllTags (const RefEntity *entity_handle, ARRAY_INOUT_DECL(long, tag_handles)) |
| std::vector< RefGroup * > * | pc_list (RefEntity *gentity, int list_no, const bool create_if_missing) |
| void | pc_list (RefEntity *gentity, std::vector< RefGroup * > *&parents, std::vector< RefGroup * > *&children, const bool create_if_missing) |
| void | get_pc_groups (RefGroup *this_grp, const int p_or_c, const int num_hops, std::vector< RefGroup * > &group_ptrs) |
| iBase_ErrorType | create_csa_tag (const char *tag_name, long *tag_handle) |
| iBase_ErrorType | set_csa_tag (RefEntity *this_ent, long tag_handle, CubitSimpleAttrib *csa_ptr) |
Static Public Member Functions | |
| static CubitAttrib * | CATag_creator (RefEntity *entity, const CubitSimpleAttrib &p_csa) |
| static CGMTagManager & | instance () |
Private Member Functions | |
| CGMTagManager () | |
| bool | getPresetTagData (const RefEntity *entity, const long tag_num, char *tag_value, int &tag_size) |
| iBase_ErrorType | setPresetTagData (RefEntity *entity, const long tag_num, const char *tag_value, const int tag_size) |
| CATag * | get_catag (RefEntity *ent, const bool create_if_missing=false) |
| long | pc_tag (const bool create_if_missing=false) |
| RefGroup * | interface_group (const bool create_if_missing=true) |
| CubitSimpleAttrib * | get_simple_attrib (RefEntity *entity, const char *name) |
Private Attributes | |
| int | CATag_att_type |
| long | pcTag |
| std::vector< TagInfo > | tagInfo |
| std::map< std::string, long > | tagNameMap |
| RefGroup * | interfaceGroup |
Static Private Attributes | |
| static TagInfo *const | presetTagInfo = preset_tag_list |
| static const int | numPresetTag = sizeof(preset_tag_list)/sizeof(preset_tag_list[0]) |
| static const char * | CATag_NAME = "ITAPS_Tag" |
| static const char * | CATag_NAME_INTERNAL = "ITAPS_TAG" |
Friends | |
| class | CATag |
| CGMTagManager::CGMTagManager | ( | ) | [private] |
Definition at line 126 of file CATag.cpp.
: interfaceGroup(NULL) { pcTag = 0; tagInfo.push_back(preset_tag_list[0]); // get the tag number for CATag DLIList<int> tag_types; int max_type = 0; CubitAttribManager *cam = CGMApp::instance()->attrib_manager(); cam->get_registered_types(tag_types); for (int i = 0; i < tag_types.size(); i++) { int this_type = tag_types.get_and_step(); max_type = (max_type < this_type ? this_type : max_type); } max_type++; CubitStatus status = cam->register_attrib_type(max_type, CATag_NAME, CATag_NAME_INTERNAL, &CGMTagManager::CATag_creator, false, true, true, true, true, false); if (CUBIT_FAILURE == status) { CGM_iGeom_setLastError( iBase_FAILURE, "Couldn't create cgm attribute for tags." ); } else CATag_att_type = max_type; // create preset tags, for CGM attributes we want to be visible as tags // name - make same as in MBTagConventions for (int i = 1; i < numPresetTag; ++i) tagNameMap[presetTagInfo[i].tagName] = -i; // neg handles beginning with -1 }
| CubitAttrib * CGMTagManager::CATag_creator | ( | RefEntity * | entity, |
| const CubitSimpleAttrib & | p_csa | ||
| ) | [static] |
| iBase_ErrorType CGMTagManager::create_csa_tag | ( | const char * | tag_name, |
| long * | tag_handle | ||
| ) |
Definition at line 186 of file CATag.cpp.
{
// make a special tag type to hold csa data from CGM; this tag holds, in this order:
// a) dbl_data (double*), dbl_data_size (int)
// b) int_data (int*), int_data_size (int)
// c) string_data (char*), string_data_size (int), indiv_string_size (int)
//
// For string data, multiple strings are packed into a single string, with each string
// occupying indiv_string_size bytes and string_size indicating number of such strings
// in packed string
//
// So, size of this tag is 3*sizeof(void*) + 4*sizeof(int), assuming pointers occupy
// same space regardless of what they point to
CSATagData dum_data;
return createTag(tag_name, sizeof(CSATagData), iBase_BYTES, (char*)&dum_data, tag_handle);
}
| iBase_ErrorType CGMTagManager::createTag | ( | const char * | tag_name, |
| const int | tag_size, | ||
| const int | tag_type, | ||
| char * | default_value, | ||
| long * | tag_handle | ||
| ) |
Definition at line 252 of file CATag.cpp.
{
std::string tmp_name(tag_name);
TagInfo tmp_info = {tag_length, tmp_name, tag_type, NULL, true};
std::map<std::string,long>::iterator mit = tagNameMap.find(tmp_name);
if (mit != tagNameMap.end()) {
// we found a tag with this name; is it still active?
bool active = (mit->second > 0 ? tagInfo[mit->second] :
presetTagInfo[-mit->second]).isActive;
*tag_handle = mit->second;
if (active) {
CGM_iGeom_setLastError( iBase_TAG_ALREADY_EXISTS );
return iBase_TAG_ALREADY_EXISTS;
}
tagInfo[*tag_handle] = tmp_info;
}
else {
// create a new tag entirely
tagInfo.push_back(tmp_info);
*tag_handle = tagInfo.size() - 1;
// put the name and handle into the map too
tagNameMap[std::string(tag_name)] = *tag_handle;
}
if (default_value != NULL) {
tagInfo[*tag_handle].defaultValue = (char *) malloc(tag_length);
memcpy(tagInfo[*tag_handle].defaultValue, default_value, tag_length);
}
RETURN(iBase_SUCCESS);
}
| iBase_ErrorType CGMTagManager::destroyTag | ( | const long | tag_handle, |
| const bool | forced | ||
| ) |
Definition at line 292 of file CATag.cpp.
{
if (!forced) {
// see whether this tag is still assigned anywhere
// not implemented yet
RETURN(iBase_NOT_SUPPORTED);
}
// if we got here, assume we can delete it
TagInfo *tinfo = (tag_handle > 0 ? &tagInfo[tag_handle] : &presetTagInfo[-tag_handle]);
tinfo->isActive = false;
RETURN(iBase_SUCCESS);
}
| CATag * CGMTagManager::get_catag | ( | RefEntity * | ent, |
| const bool | create_if_missing = false |
||
| ) | [private] |
Definition at line 492 of file CATag.cpp.
{
CubitAttrib *this_attrib = ent->get_cubit_attrib(CATag_att_type, create_if_missing);
if (NULL != this_attrib)
return dynamic_cast<CATag*>(this_attrib);
else
return NULL;
}
| void CGMTagManager::get_pc_groups | ( | RefGroup * | this_grp, |
| const int | p_or_c, | ||
| const int | num_hops, | ||
| std::vector< RefGroup * > & | group_ptrs | ||
| ) |
Definition at line 757 of file CATag.cpp.
{
if (NULL == this_grp) return;
int next_hop = num_hops - 1;
std::vector<RefGroup*> tmp_groups;
// get my children
std::vector<RefGroup*> *my_children = pc_list(this_grp, p_or_c, false);
if (NULL != my_children)
tmp_groups = *my_children;
// get their children if we're not out of hops
std::vector<RefGroup*>::iterator vit;
if (0 < next_hop) {
for (vit = tmp_groups.begin(); vit != tmp_groups.end(); vit++)
get_pc_groups(*vit, p_or_c, next_hop, group_ptrs);
}
// now add mine to the list; make sure it isn't there already
for (vit = tmp_groups.begin(); vit != tmp_groups.end(); vit++) {
if (std::find(group_ptrs.begin(), group_ptrs.end(), *vit) == group_ptrs.end())
group_ptrs.push_back(*vit);
}
}
| CubitSimpleAttrib * CGMTagManager::get_simple_attrib | ( | RefEntity * | entity, |
| const char * | name | ||
| ) | [private] |
Definition at line 550 of file CATag.cpp.
{
TopologyEntity* te_ptr = dynamic_cast<TopologyEntity*>(entity);
TopologyBridge* tb_ptr = te_ptr ? te_ptr->bridge_manager()->topology_bridge() : 0;
if (!tb_ptr) {
CGM_iGeom_setLastError( iBase_INVALID_ENTITY_HANDLE, "Entity not topology" );
return 0;
}
DLIList<CubitSimpleAttrib> attr_list;
tb_ptr->get_simple_attribute("MESH_INTERVAL", attr_list);
if (attr_list.size() == 0) {
CGM_iGeom_setLastError( iBase_TAG_NOT_FOUND, "No MESH_INTERVAL attribute" );
return 0;
}
CubitSimpleAttrib result = attr_list.pop();
CubitSimpleAttrib *p_result = new CubitSimpleAttrib(result);
return p_result;
}
| iBase_ErrorType CGMTagManager::getAllTags | ( | const RefEntity * | entity_handle, |
| ARRAY_INOUT_DECL(long, tag_handles) | |||
| ) |
Definition at line 461 of file CATag.cpp.
{
int i = 0, uid = 0, tag_size;
char *uid_ptr = (char*) &uid;
bool has_uid = getPresetTagData(entity_handle, -3, uid_ptr, tag_size);
int num_tags = (has_uid ? 3 : 2);
RefEntity *this_ent = (NULL == entity_handle ? interface_group() :
const_cast<RefEntity*>(entity_handle));
// const-cast because we're passing in false for create_if_missing
CATag *catag = get_catag(this_ent);
if (NULL != catag) {
// need to check whether entity has a uid
num_tags += catag->tagData.size();
CHECK_SIZE(*tag_handles, long, num_tags, iBase_FAILURE);
for (std::map<int,void*>::iterator tag_it = catag->tagData.begin();
tag_it != catag->tagData.end(); tag_it++)
(*tag_handles)[i++] = (*tag_it).first;
}
else {
CHECK_SIZE(*tag_handles, long, num_tags, iBase_FAILURE);
}
(*tag_handles)[i++] = -1;
(*tag_handles)[i++] = -2;
if (has_uid) (*tag_handles)[i++] = -3;
RETURN(iBase_SUCCESS);
}
| iBase_ErrorType CGMTagManager::getArrData | ( | ARRAY_IN_DECL(RefEntity *, entity_handles) | , |
| const long | tag_handle, | ||
| ARRAY_INOUT_DECL(char, tag_value) | |||
| ) |
Definition at line 348 of file CATag.cpp.
{
TagInfo *tinfo = (tag_handle > 0 ? &tagInfo[tag_handle] : &presetTagInfo[-tag_handle]);
int tag_size = tinfo->tagLength;
// either way, we have to have that many bytes when we leave this function
const bool allocated_data_arr = (*tag_value_allocated == 0);
TAG_CHECK_SIZE(*tag_value, *tag_value_allocated, entity_handles_size*tinfo->tagLength);
char *val_ptr = *tag_value;
if (tag_handle < 0) {
for (int i = 0; i < entity_handles_size; i++) {
bool result;
if (NULL == entity_handles[i])
result = getPresetTagData(interface_group(), tag_handle, val_ptr, tinfo->tagLength);
else
result = getPresetTagData(entity_handles[i], tag_handle, val_ptr, tinfo->tagLength);
if (!result) {
if (allocated_data_arr) {
free(*tag_value);
*tag_value = 0;
*tag_value_allocated = 0;
}
RETURN(iBase_TAG_NOT_FOUND);
}
val_ptr += tinfo->tagLength;
}
*tag_value_size = entity_handles_size*tinfo->tagLength;
RETURN(iBase_SUCCESS);
}
iBase_ErrorType result = iBase_SUCCESS, tmp_result;
for (int i = 0; i < entity_handles_size; i++) {
// ok to cast away const-ness because "false" passed in for create_if_missing
RefEntity *this_ent = (NULL == entity_handles[i] ? interface_group() :
const_cast<RefEntity*>(entity_handles[i]));
CATag *catag = get_catag(this_ent);
if (NULL != catag) {
tmp_result = catag->get_tag_data(tag_handle, val_ptr);
if (iBase_SUCCESS != tmp_result)
CGM_iGeom_setLastError( tmp_result, "Problem getting tag data." );
}
else if (NULL != tinfo->defaultValue) {
memcpy(val_ptr, tinfo->defaultValue, tinfo->tagLength);
tmp_result = iBase_SUCCESS;
}
else {
tmp_result = iBase_TAG_NOT_FOUND;
CGM_iGeom_setLastError( iBase_TAG_NOT_FOUND );
}
if (iBase_SUCCESS != tmp_result) result = tmp_result;
val_ptr += tag_size;
}
if (iBase_SUCCESS != result)
*tag_value_size = 0;
else
*tag_value_size = entity_handles_size*tinfo->tagLength;
RETURN(result);
}
| bool CGMTagManager::getPresetTagData | ( | const RefEntity * | entity, |
| const long | tag_num, | ||
| char * | tag_value, | ||
| int & | tag_size | ||
| ) | [private] |
Definition at line 571 of file CATag.cpp.
{
const char *this_name;
int name_len, val;
double dval;
int *this_id;
int *this_uid;
if (-tag_handle >= numPresetTag || tag_handle >= 0) {
CGM_iGeom_setLastError( iBase_INVALID_TAG_HANDLE, "Invalid tag handle" );
return false;
}
const TagInfo& info = presetTagInfo[-tag_handle];
tag_size = info.tagLength;
CubitSimpleAttrib* csa;
CubitString str;
switch (-tag_handle) {
case 1:
// entity name
this_name = entity->entity_name().c_str();
name_len = strlen(this_name);
// if name is too long, truncate
if (name_len > info.tagLength)
name_len = info.tagLength;
strncpy( tag_value, this_name, name_len );
// if name is too short, pad with zero bytes
if (name_len < info.tagLength)
memset( tag_value + name_len, 0, (info.tagLength - name_len) );
return true;
case 2:
// entity id
tag_size = sizeof(int);
this_id = reinterpret_cast<int*>(tag_value);
*this_id = entity->id();
return true;
case 3:
// unique id
tag_size = sizeof(int);
this_uid = reinterpret_cast<int*>(tag_value);
// const_cast because we're passing false for create_if_missing
*this_uid = TDUniqueId::get_unique_id(const_cast<RefEntity*>(entity), false);
return (*this_uid == 0 ? false : true);
case 4: // mesh interval
csa = get_simple_attrib( const_cast<RefEntity*>(entity), "MESH_INTERVAL" );
if (!csa)
return false;
val = csa->int_data_list()[0];
// check if interval is set
// If a) the size is set and b) the firmness is LIMP, then
// the interval count has not been set.
if ( csa->string_data_list().size() &&
csa->string_data_list()[0] == "LIMP" &&
csa->int_data_list().size() > 1 &&
!csa->int_data_list()[0])
val = 0;
delete csa;
if (val == 0 || val == CUBIT_INT_MIN) {
if (info.defaultValue)
val = *(int*)info.defaultValue;
else {
CGM_iGeom_setLastError( iBase_TAG_NOT_FOUND, "Interval not set" );
return 0;
}
}
*(int*)tag_value = val;
return true;
case 5: // mesh size
csa = get_simple_attrib( const_cast<RefEntity*>(entity), "MESH_INTERVAL" );
if (!csa)
return false;
// if size value is invalid or flag indicates size has not been set...
if (csa->double_data_list().size() == 0 ||
csa->double_data_list()[0] == CUBIT_DBL_MIN ||
(csa->int_data_list().size() > 1 && !csa->int_data_list()[1])) {
if (info.defaultValue)
dval = *(double*)info.defaultValue;
else {
delete csa;
CGM_iGeom_setLastError( iBase_TAG_NOT_FOUND, "Mesh size not set" );
return false;
}
}
else
dval = csa->double_data_list()[0];
delete csa;
*(double*)tag_value = dval;
return true;
case 6: // interval firmness
csa = get_simple_attrib( const_cast<RefEntity*>(entity), "MESH_INTERVAL" );
if (!csa)
return false;
if (csa->string_data_list().size() < 2) {
delete csa;
CGM_iGeom_setLastError( iBase_TAG_NOT_FOUND, "Interval firmness not set" );
return false;
}
str = csa->string_data_list()[1];
memcpy( tag_value, str.c_str(), 4 );
delete csa;
return true;
}
return false;
}
| long CGMTagManager::getTagHandle | ( | const char * | tag_name | ) |
Definition at line 323 of file CATag.cpp.
{
std::map<std::string,long>::iterator it =
tagNameMap.find(std::string(tag_name));
if (it != tagNameMap.end()) {
bool active = (it->second > 0 ? tagInfo[it->second] :
presetTagInfo[-it->second]).isActive;
if (active) {
CGM_iGeom_clearLastError();
return it->second;
}
}
CGM_iGeom_setLastError( iBase_TAG_NOT_FOUND );
return 0;
}
| const char * CGMTagManager::getTagName | ( | const long | tag_handle | ) |
Definition at line 308 of file CATag.cpp.
{
CGM_iGeom_clearLastError();
return (tag_handle > 0 ? tagInfo[tag_handle].tagName.c_str() :
presetTagInfo[-tag_handle].tagName.c_str());
}
| int CGMTagManager::getTagSize | ( | const long | tag_handle | ) |
Definition at line 315 of file CATag.cpp.
{
CGM_iGeom_clearLastError();
return (tag_handle > 0 ?
tagInfo[tag_handle].tagLength :
presetTagInfo[-tag_handle].tagLength);
}
| int CGMTagManager::getTagType | ( | const long | tag_handle | ) |
Definition at line 340 of file CATag.cpp.
{
CGM_iGeom_clearLastError();
return (tag_handle > 0 ?
tagInfo[tag_handle].tagType :
presetTagInfo[-tag_handle].tagType);
}
| static CGMTagManager& CGMTagManager::instance | ( | ) | [inline, static] |
Definition at line 126 of file CATag.hpp.
{
static CGMTagManager static_instance;
return static_instance;
}
| RefGroup * CGMTagManager::interface_group | ( | const bool | create_if_missing = true | ) | [private] |
Definition at line 502 of file CATag.cpp.
{
if (NULL == interfaceGroup)
interfaceGroup =
dynamic_cast<RefGroup*>(RefEntityName::instance()->get_refentity("interface_group"));
if (NULL == interfaceGroup && create_if_missing)
interfaceGroup = RefEntityFactory::instance()->construct_RefGroup("interface_group");
return interfaceGroup;
}
| std::vector< RefGroup * > * CGMTagManager::pc_list | ( | RefEntity * | gentity, |
| int | list_no, | ||
| const bool | create_if_missing | ||
| ) |
Definition at line 681 of file CATag.cpp.
{
if (NULL == gentity) return NULL;
int dum_tag_size = sizeof(std::vector<RefGroup*>*);
int dum = 2*dum_tag_size;
std::vector<RefGroup*> *pc_lists[2];
char *dum_ptr = (char*) pc_lists;
iBase_ErrorType result =
getArrData(&gentity, 1, pc_tag(create_if_missing), &dum_ptr,
&dum, &dum);
assert(iBase_SUCCESS == result);
if (iBase_SUCCESS != result) {
PRINT_ERROR("Failed to get array data.\n");
return NULL;
}
if (0 > list_no || 1 < list_no) return NULL;
if (NULL == pc_lists[list_no] && create_if_missing) {
pc_lists[list_no] = new std::vector<RefGroup*>();
result =
setArrData(&gentity, 1, pc_tag(), (char*)pc_lists, 2*dum_tag_size);
assert(iBase_SUCCESS == result);
if (iBase_SUCCESS != result) {
PRINT_ERROR("Failed to set array data.\n");
return NULL;
}
}
return pc_lists[list_no];
}
| void CGMTagManager::pc_list | ( | RefEntity * | gentity, |
| std::vector< RefGroup * > *& | parents, | ||
| std::vector< RefGroup * > *& | children, | ||
| const bool | create_if_missing | ||
| ) |
Definition at line 715 of file CATag.cpp.
{
if (NULL == gentity) return;
int dum_tag_size = sizeof(std::vector<RefGroup*>*);
int dum = 2*dum_tag_size;
std::vector<RefGroup*> *pc_lists[2];
char *dum_ptr = (char*) pc_lists;
iBase_ErrorType result =
getArrData(&gentity, 1, pc_tag(),
&dum_ptr, &dum, &dum);
assert(iBase_SUCCESS == result);
if (iBase_SUCCESS != result) {
PRINT_ERROR("Failed to get array data.\n");
return;
}
if ((NULL == pc_lists[0] || NULL == pc_lists[1]) && create_if_missing) {
bool must_set = false;
for (int i = 0; i < 2; i++) {
if (NULL == pc_lists[i]) {
pc_lists[i] = new std::vector<RefGroup*>();
must_set = true;
}
}
if (must_set) {
result = setArrData(&gentity, 1, pc_tag(), (char*)pc_lists,
2*dum_tag_size);
assert(iBase_SUCCESS == result);
if (iBase_SUCCESS != result) {
PRINT_ERROR("Failed to set array data.\n");
return;
}
}
}
parents = pc_lists[0];
children = pc_lists[1];
}
| long CGMTagManager::pc_tag | ( | const bool | create_if_missing = false | ) | [private] |
Definition at line 163 of file CATag.cpp.
{
if (0 == pcTag && create_if_missing) {
pcTag = getTagHandle("__cgm_parent_child_tag");
if (0 == pcTag) {
// ok, one doesn't exist, create one
void *def_val[] = {NULL, NULL};
createTag("__cgm_parent_child_tag", 2*sizeof(std::vector<RefGroup*>*),
iBase_BYTES, (char*)def_val, &pcTag);
}
}
return pcTag;
}
| iBase_ErrorType CGMTagManager::rmvArrTag | ( | ARRAY_IN_DECL(RefEntity *, entity_handles) | , |
| const long | tag_handle | ||
| ) |
Definition at line 449 of file CATag.cpp.
{
for (int i = 0; i < entity_handles_size; i++) {
CATag *catag = get_catag((entity_handles[i] == NULL ?
interface_group() : entity_handles[i]));
if (NULL != catag) catag->remove_tag(tag_handle);
}
RETURN(iBase_SUCCESS);
}
| iBase_ErrorType CGMTagManager::set_csa_tag | ( | RefEntity * | this_ent, |
| long | tag_handle, | ||
| CubitSimpleAttrib * | csa_ptr | ||
| ) |
Definition at line 204 of file CATag.cpp.
{
CSATagData this_data;
CSATagData *this_data_ptr = &this_data;
int this_data_size = sizeof(CSATagData), this_data_alloc = this_data_size;
// if data was set on this tag, reset in an attempt to not leak memory
iBase_ErrorType result = getArrData(&this_ent, 1, tag_handle,
(char**)&this_data_ptr, &this_data_alloc, &this_data_size);
if (iBase_SUCCESS != result && iBase_TAG_NOT_FOUND != result) return result;
if (iBase_TAG_NOT_FOUND != result) this_data.reset();
// set the data
this_data.dblDataSize = csa_ptr->double_data_list().size();
this_data.dblData = (double*) malloc(this_data.dblDataSize*sizeof(double));
for (int i = 0; i < this_data.dblDataSize; i++)
this_data.dblData[i] = csa_ptr->double_data_list()[0];
this_data.intDataSize = csa_ptr->int_data_list().size();
this_data.intData = (int*) malloc(this_data.intDataSize*sizeof(int));
for (int i = 0; i < this_data.intDataSize; i++)
this_data.intData[i] = csa_ptr->int_data_list()[i];
// find longest string, then allocate
std::vector<CubitString> sd = csa_ptr->string_data_list();
this_data.indivStringSize = 0;
for (int i = 0; i < (int)sd.size(); i++) {
if (((int) sd[i].length()) > this_data.indivStringSize)
this_data.indivStringSize = sd[i].length();
}
// round to next highest multiple of sizeof(int)
if (this_data.indivStringSize%sizeof(int) != 0)
this_data.indivStringSize = ((this_data.indivStringSize/sizeof(int))+1)*sizeof(int);
// now allocate
this_data.stringDataSize = sd.size()*this_data.indivStringSize;
this_data.stringData = (char*) malloc(this_data.stringDataSize);
for (int i = 0; i < (int)sd.size(); i++)
strncpy(this_data.stringData+i*this_data.indivStringSize, sd[i].c_str(),
this_data.indivStringSize);
result = setArrData(&this_ent, 1, tag_handle, (const char*)&this_data_ptr, sizeof(CSATagData));
return result;
}
| iBase_ErrorType CGMTagManager::setArrData | ( | ARRAY_IN_DECL(RefEntity *, entity_handles) | , |
| const long | tag_handle, | ||
| const char * | tag_values, | ||
| const int | tag_values_size | ||
| ) |
Definition at line 413 of file CATag.cpp.
{
TagInfo *tinfo = (tag_handle > 0 ? &tagInfo[tag_handle] : &presetTagInfo[-tag_handle]);
int tag_size = tinfo->tagLength;
const char *val_ptr = tag_values;
iBase_ErrorType result = iBase_SUCCESS, tmp_result;
if (tag_handle < 0) {
for (int i = 0; i < entity_handles_size; i++) {
if (NULL == entity_handles[i])
tmp_result = setPresetTagData(interface_group(), tag_handle, val_ptr, tag_size);
else
tmp_result = setPresetTagData(entity_handles[i], tag_handle, val_ptr, tag_size);
val_ptr += tag_size;
if (iBase_SUCCESS != tmp_result) result = tmp_result;
}
RETURN(result);
}
for (int i = 0; i < entity_handles_size; i++) {
RefEntity *this_ent = (NULL == entity_handles[i] ? interface_group() :
entity_handles[i]);
CATag *catag = get_catag(this_ent, true);
assert(NULL != catag);
catag->set_tag_data(tag_handle, val_ptr);
val_ptr += tag_size;
}
RETURN(iBase_SUCCESS);
}
| iBase_ErrorType CGMTagManager::setPresetTagData | ( | RefEntity * | entity, |
| const long | tag_num, | ||
| const char * | tag_value, | ||
| const int | tag_size | ||
| ) | [private] |
Definition at line 514 of file CATag.cpp.
{
switch (-tag_handle) {
case 1:
// entity name
if (presetTagInfo[-tag_handle].tagLength != tag_size) {
std::string tmp_str = "Tag of type '";
tmp_str += presetTagInfo[-tag_handle].tagName + "' is the wrong size.";
CGM_iGeom_setLastError(iBase_INVALID_ARGUMENT, tmp_str.c_str());
return iBase_INVALID_ARGUMENT;
}
entity->entity_name(CubitString(tag_value));
RETURN(iBase_SUCCESS);
case 2:
// entity id
CGM_iGeom_setLastError( iBase_NOT_SUPPORTED, "Can't set id of entities with this implementation." );
return iBase_NOT_SUPPORTED;
case 3:
// unique id
CGM_iGeom_setLastError( iBase_NOT_SUPPORTED, "Can't set unique id of entities with this implementation." );
return iBase_NOT_SUPPORTED;
case 4: // mesh interval
case 5: // mesh size
case 6: // mesh interval firmness
default:
CGM_iGeom_setLastError( iBase_NOT_SUPPORTED, "Can't set this tag on entities with this implementation." );
return iBase_NOT_SUPPORTED;
}
CGM_iGeom_setLastError( iBase_TAG_NOT_FOUND );
return iBase_TAG_NOT_FOUND;
}
int CGMTagManager::CATag_att_type [private] |
const char * CGMTagManager::CATag_NAME = "ITAPS_Tag" [static, private] |
const char * CGMTagManager::CATag_NAME_INTERNAL = "ITAPS_TAG" [static, private] |
RefGroup* CGMTagManager::interfaceGroup [private] |
const int CGMTagManager::numPresetTag = sizeof(preset_tag_list)/sizeof(preset_tag_list[0]) [static, private] |
long CGMTagManager::pcTag [private] |
CGMTagManager::TagInfo *const CGMTagManager::presetTagInfo = preset_tag_list [static, private] |
std::vector<TagInfo> CGMTagManager::tagInfo [private] |
std::map<std::string, long> CGMTagManager::tagNameMap [private] |