Jump to content

Retrieving a detail attribute


Guest xionmark

Recommended Posts

Guest xionmark

Hi there,

I'm having problems retrieving a detail attribute (float, vector, string, etc.). I can create and retrieve point, primitive and vertex attributes and can create detail attributes (all verified in the spreadsheet) but for some reason I can't seem to be able to retrieve detail attribute offsets and thus the attribute values.

I have tried the different variants of findAttrib() & findAttribute(), for example:

int sd_CG_pos = gdp->findAttrib("sd_CG_pos", 3, GB_ATTRIB_VECTOR);

if(sd_CG_pos >= 0)

UT_Vector3 *CG_pos = (UT_Vector3 *)gdp->attribs().getAttribData(sd_CG_pos);

but I always get a -1 returned from the findAttrib() & findAttribute() calls.

ANother question: for a string detail attribute, what would one use for the "size" argument? I assumed 1 to represent "one string", but also tried the call without the size arg, no difference, they always return a -1 for the offset value (meaning it can't find the attribute):

int obj_tex_fname = gdp->findAttribute("sd_obj_tex_fname", 1, GB_ATTRIB_STRING, GEO_DETAIL_DICT);

-OR-

int obj_tex_fname = gdp->findAttrib("sd_obj_tex_fname", GB_ATTRIB_STRING);

Suggestions? Example?

Thanks!

-Mark

Link to comment
Share on other sites

This is a code snip from one of ours which works somehow:

int instance_attr_offset = centroids->pointAttribs().append("break_instance",sizeof(int),GB_ATTRIB_INDEX,"");

GB_Attribute *atr = centroids->pointAttribs().find("break_instance");

Link to comment
Share on other sites

Guest xionmark

Hi Jason,

Thanks for the example. It got me going down another path but ran into a wall. I can now find the detail attribute and find out what type it is (though I still don't know how to deal with strings yet) but when trying to find the offset to retrieve the data, it still returns a -1. This is true when looking for float, int, vector and string attributes.

myGB_Attr = gdp->attribs().find("sd_obj_tex_fname");
if(myGB_Attr) {
cout << "getType: " << myGB_Attr->getType() << endl;
cout << "getTypeInfo: " << myGB_Attr->getTypeInfo() << endl;
cout << "getName: " << myGB_Attr->getName() << endl;
cout << "getSize: " << myGB_Attr->getSize() << endl;
cout << "getAllocSize: " << myGB_Attr->getAllocSize() << endl;
cout << "getIndex: " << myGB_Attr->getIndex("sd_obj_tex_fname") << endl;
cout << "getIndexSize: " << myGB_Attr->getIndexSize() << endl;
}

example output:

getType: 4

getTypeInfo: 0

getName: sd_obj_tex_fname

getSize: 4

getAllocSize: 4

getIndex: -1

getIndexSize: 1

So how is one supposed to get the index offset from a GB_Attribute object?

Still puzzled :blink:

--Mark

Link to comment
Share on other sites

  • 3 weeks later...

hmm.. I know I saw some back and forth about attributes on the mailing list a while back, so if this has already been answered, please ignore (I should really pay more attention to my e-mails).

If not, I believe you're using the wrong value for size. Size, AFAIK, is the memory footprint, so you should use th result of sizeof, i.e.:

int fooOffset = gdp->findPointAttrib("foo", sizeof(int), GB_ATTRIB_INT);

.. or sizeof(UT_Vector4), etc.

as far as strings go, string attribs are indexed attributes - stored in the gdp and referenced by integer index, so size for the string would, again, be sizeof(int).

If you'd like a code example, I'll post one here. let me know.

::edited to add:: well, it appears this has all been answered in another thread. say la vee. hehe ;)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...