markh Posted September 21, 2007 Share Posted September 21, 2007 Hi everyone, I am trying to copy individual points, including their attributes, from one GU_Detail to another. Much like GU_Detail::merge() but I don't want to bring across the whole geometry and just a single point. I've tried various methods, based on using a GEO_Point from the source and attempting to copy it and it's attributes. eg. GU_Detail source, dest; const GEO_Point p = source.points()(25); GEO_Point *q = dest.appendPoint(); q->copyPoint(p, asize); Aside from guessing what 'asize' is, nothing I have tried has made the attributes available by name in the destination. Manually created the attributes isn't an option either, as I don't know which ones will be present in the source geometry. I've got very frustrated and in searching the examples I haven't been able to find anything similar, which hints that I'm going about this the wrong way. Any ideas? Quote Link to comment Share on other sites More sharing options...
edward Posted September 23, 2007 Share Posted September 23, 2007 The asize is the attribute size, the amount of attribute data (in bytes) to copy over. But you really have to be careful here since copying over the attribute data won't work unless your attribute dictionaries (ie. the meta information describing the attribute types, sizes, etc) match. The easiest way really is to use GEO_Detail::mergePoints() and give it a group containing the points you wish to copy. This will handle the attribute dictionaries for you. If you really must do it the hard way then it would be something like this: dest.pointAttribs().sortAs(source.pointsAttribs()); // make dest's attributes the same as source q->copyPoint(p, source.pointsAttribs(), dest.pointsAttribs()); Quote Link to comment Share on other sites More sharing options...
markh Posted September 24, 2007 Author Share Posted September 24, 2007 Thanks Edward, that's just what I need. I've used mergePoints() to achieve it. The code to copy a single point is roughly GB_PointGroup *gr; GEO_Point *point = source.points()(n); gr->add((GB_Element*)point); dest.mergePoints(source, gr); I'm aiming to put the source points into a few different destinations depending on their attributes, and because of this I've found it overall quicker to loop through the source and merge points one by one than to build a separate group for each destination and then do a small number of merges. 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.