Jump to content

Merging Single Points Between Gu_details


markh

Recommended Posts

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?

Link to comment
Share on other sites

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());

Link to comment
Share on other sites

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.

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...