MrScienceOfficer Posted September 19, 2014 Share Posted September 19, 2014 (edited) hey guys, Is there a way to make a deep copy of a mesh? I want to iterate over the mesh and write out different pieces of it to files. Is this possible in a single node? I've been using a for each sop but its very slow... Thanks, Tom Edit: I started to look into creating a new GU_Detail based on a PrimitiveGroup, at least I think that's what it'll do... But now I can't figure out how to get primitive attributes while looping through GEO_Primitives. I can't find any examples of it, I even checked the slides to no avail... Thanks thanks Okay so I tried gdp->duplicate again and it seems to be a step in the right direction but what I don't get is regardless of what I might do to the copy why does gdp seem to be effected. Could it be the original the copy that is, because its not a pointer anymore. That wouldn't make very much sense... Gdp and thusly what gets drawn in the scene should be unchanged I would think? So any calls to duplicate empties the original GU_Detail object that doesn't make much sense I got it duplicateSource does work inside the loop. Not sure why I always forget about inheritance though. But I still don't get why calling duplicate doesn't work, unless I'm supposed to call it from the empty detail, though that didn't seem to work either. THANKSSSS hehe Edited September 20, 2014 by captain Quote Link to comment Share on other sites More sharing options...
Stalkerx777 Posted September 21, 2014 Share Posted September 21, 2014 (edited) duplicateSource shouldn't be called inside loop. This basically means "Get a copy of the geometry from first input". It doesn't meant to duplicate a current GU_Detail instance. What you need is to make a new GU_Detail, and copy or merge existing one. For example: GU_Detail *newgdp = new GU_Detail(); newgdp->copy(gdp); Edited September 21, 2014 by Stalkerx777 Quote Link to comment Share on other sites More sharing options...
MrScienceOfficer Posted September 21, 2014 Author Share Posted September 21, 2014 (edited) I agree it shouldn't be done that way, that's why I waited 14 hours to try it But I'm getting compile errors with that code, "cannot convert pararmeter one from 'GU_Detail *' to 'const GEO_Detail &' I tried it with duplicate(the GU_Detail version of copy) but it says the same only with GU instead of GEO. I can't work out the exactly what it wants and when I do, it tells me I don't have permission to access private function members but I think I did have it compiling somehow yesterday but I was probably doing it backwards. I just assumed because it was asking for reference it was going to put the gdp into the callee not the caller. Does that compile for you? But I do kinda want the original, I'm replicating functionally I had in a for each loop where I deleted most of the mesh saved the remainder out to file then started over, and at the end of the loop I destroy the gdp. My only concern is unknown side effects from duplicateSource, but it does work, plus its implemented as a callback so it only runs when the button is pressed. But I do have some questions, for one what is the proper syntax for duplicate or copy and why? I get mixed up with an abundance of pointers and references. And some what unrelated but since you did use it. I never use 'new' I always try to avoid it, it's only necessary when we want something to persist outside of the scope where we called it correct? And within a class structure using a class member will persist throughout the class. I'm just curious because I see it used a lot but I never use it. EDIT:: okay I see why I need new now... Theres a difference between a pointer at a class and a pointer at the memory allocated from a class, I think... I get it to compile with GU_Detail *temp = new GU_Detail(); temp->duplicate(*gdp); but that's just a pointer to the original, I need a deep copy. Because the next time I call it its empty. EDITEDIT: We can't say GU_Detail temp = new GU_Detail or GU_Detail It says we can't access private member functions. But a pointer to a pointer is the actual data right or a pointer to a reference? I would think a reference to pointer but wait no thats a reference from a real copy... Or maybe its a pointer on a pointer or a pointer F*cking a pointer......., Edited September 21, 2014 by captain Quote Link to comment Share on other sites More sharing options...
MrScienceOfficer Posted September 22, 2014 Author Share Posted September 22, 2014 (edited) Wait this is my real question, Okay So I allocate memory using new, programming 101 dictates I must then call delete on it when I am done. But when I call delete on my GU_Detail I get a segmentation fault. Does ClearAndDestroy de-allocate for me? EDIT: nevermind it must de allocate.. thats a dumb question. This one really through me for a loop. I think I'm gonna stick with dupilcateSource. I think its the safest method Double Nevermind GU_Detail *temp = new GU_detail; temp->duplicate(*gdp) That works obviously not the original hence the pointer to new part. Thanks Stalkerx777 I'm shutting up now Edited September 22, 2014 by captain 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.