Infernalspawn Posted September 24, 2007 Share Posted September 24, 2007 Hi everyone, i try to get a list of the existing attributes from a geometry, but everytime i call, GEO_PointAttribDict attribs = ((GEO_Detail*)gdp)->pointAttribs(); the whole thin crashes, even when trying to debug the stuff i only get a segmentation fault but no backtrack into my code. does someome have managed it to get a list of all existing attributes of the incomming geometry ? thx Sebastian Quote Link to comment Share on other sites More sharing options...
edward Posted September 24, 2007 Share Posted September 24, 2007 There are several things that could go wrong that I can think of immediately: - The casting should be un-necessary if you have the right include files. Make sure you have #include <GU/GU_Detail.h>. - Have you checked that gdp != NULL? - pointAttribs() returns a reference, I think you're missing an & in there. I don't think there's a save operator=() that you can call. - Is your gdp empty? Unless, you've duplicated your input first, it will be. If you want to find the list of point attributes from your input, lock your input and then use inputGeo(). - Finally, once you have your attribute dictionary, you can look through them like this: for (GB_Attribute *atr = attribs.getHead(); atr != NULL; atr = (GB_Attribute *)atr->next()) { if (atr->getType() == GB_ATTRIB_MIXED) continue; cout << atr->getName() << " " << atr->getType() << " " << atr->getSize() << endl; } Quote Link to comment Share on other sites More sharing options...
pbowmar Posted September 24, 2007 Share Posted September 24, 2007 Strangely, the first code below works, the second (where gdp isn't a pointer) crashes, gdb telling me: #0 0x00000031 in ?? () #1 0xb53d76b5 in UT_LinkList::clearActive () from /opt/sidefx/hfs9.0.719/dsolib/libHoudiniUT.so #2 0xb60723de in GEO_Detail::~GEO_Detail () from /opt/sidefx/hfs9.0.719/dsolib/libHoudiniGEO.so #3 0xb6166c8e in GU_Detail::~GU_Detail () from /opt/sidefx/hfs9.0.719/dsolib/libHoudiniGEO.so Works fine: GU_Detail *gdp = new GU_Detail(); UT_String points_bgeo; int t; if( argc!=2 ) { fprintf(stderr,"Specify points path please.\n"); exit (1); } if(!strcmp(argv[1], "")) points_bgeo = NULL; else points_bgeo = argv[1]; if(gdp->load(points_bgeo,0)) { fprintf(stderr,"Could not load seed points!\n"); exit (1); } int numpoints = gdp->points().entries(); fprintf(stderr,"Num points: %d\n", numpoints); GEO_PointAttribDict attribs = gdp->pointAttribs(); for (GB_Attribute *atr = attribs.getHead(); atr != NULL; atr = (GB_Attribute *)atr->next()) { if (atr->getType() == GB_ATTRIB_MIXED) continue; cout << atr->getName() << " " << atr->getType() << " " << atr->getSize() << endl; } Segfaults at the end: GU_Detail gdp; UT_String points_bgeo; int t; if( argc!=2 ) { fprintf(stderr,"Specify points path please.\n"); exit (1); } if(!strcmp(argv[1], "")) points_bgeo = NULL; else points_bgeo = argv[1]; if(gdp.load(points_bgeo,0)) { fprintf(stderr,"Could not load seed points!\n"); exit (1); } int numpoints = gdp.points().entries(); fprintf(stderr,"Num points: %d\n", numpoints); GEO_PointAttribDict attribs = gdp.pointAttribs(); for (GB_Attribute *atr = attribs.getHead(); atr != NULL; atr = (GB_Attribute *)atr->next()) { if (atr->getType() == GB_ATTRIB_MIXED) continue; cout << atr->getName() << " " << atr->getType() << " " << atr->getSize() << endl; } Quote Link to comment Share on other sites More sharing options...
Infernalspawn Posted September 24, 2007 Author Share Posted September 24, 2007 hmm ... something i dont understand, ... or maybe missunderstand, ... i dont have to set gdp on my own, as long as its in an SOP node, right ?, because if i have to I'm wondering why my stuff is working without setting this variable. here's my current code time = context.myTime; duplicateSource(0, context); setVariableOrder(3, 2, 0, 1); setCurGdh(0, myGdpHandle); setupLocalVars(); if (error() < UT_ERROR_ABORT && cookInputGroups(context) < UT_ERROR_ABORT) { if (gdp != NULL) { GEO_PointAttribDict attribs = gdp->pointAttribs(); } [... iterating over points] } myCurrPoint = -1; unlockInputs(); resetLocalVarRefs(); return error(); and it still crashes ... do I have to set gdp or is it set automatic in the SOP node ? thx in advance Sebastian Quote Link to comment Share on other sites More sharing options...
edward Posted September 24, 2007 Share Posted September 24, 2007 @infernalspawn: ok, if you're inside a SOP_Node::cookMySop() code path, then gdp should be non-NULL already. I think you're still making the same mistake that pbowmar is. I'm not quite sure I understand your posted code since the attribute dictionary is the *same* for *all* points. So there should be no iterating over points at all. @pbowmar: - pointAttribs() returns a reference, I think you're missing an & in there. I don't think there's a safe operator=() that you can call. GEO_PointAttribDict &attribs = gdp->pointAttribs(); Quote Link to comment Share on other sites More sharing options...
Infernalspawn Posted September 25, 2007 Author Share Posted September 25, 2007 thx edward, it worked!! Quote Link to comment Share on other sites More sharing options...
pbowmar Posted September 25, 2007 Share Posted September 25, 2007 @pbowmar:- pointAttribs() returns a reference, I think you're missing an & in there. I don't think there's a safe operator=() that you can call. GEO_PointAttribDict &attribs = gdp->pointAttribs(); Cool, thanks Edward. I'm sure it's a C++ confusion on my part, of which of I have plenty!! Cheers, Peter B Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.