PDA

View Full Version : AppendifUnique and FindItem not working...


Kickflipkid687
05-16-2011, 01:50 AM
Hello,

Sorry for all the questions lately. I've been stuck on this problem for hours today, and I cannot get it to work properly without causing huge delays in processing time/ possible major memory leaking.

Basically, I am appending to an array, bitarrays of faces, like #{1,2,3,4,5..}

I am going through all faces in a Mesh, and saying, GetElementsUsingFace, then collecting all of those faces and appending to the array. However... this leads to multiple entries of the same bitarray, which I don't want.

BUT, the problem is that, using FindItem or AppendIfUnique doesn't want to properly find bitarrays inside another array....

I was able to get it to work finally, but it was causing massive slowdowns. I was basically doing append (#{1,2,3..} as array)[1] so then I found find the item properly.

There has to be a better way of doing this?? :argh:

Thank you very much!

denisT
05-16-2011, 02:06 AM
... double post

denisT
05-16-2011, 02:12 AM
Hello,

Sorry for all the questions lately. I've been stuck on this problem for hours today, and I cannot get it to work properly without causing huge delays in processing time/ possible major memory leaking.

Basically, I am appending to an array, bitarrays of faces, like #{1,2,3,4,5..}

I am going through all faces in a Mesh, and saying, GetElementsUsingFace, then collecting all of those faces and appending to the array. However... this leads to multiple entries of the same bitarray, which I don't want.

BUT, the problem is that, using FindItem or AppendIfUnique doesn't want to properly find bitarrays inside another array....

I was able to get it to work finally, but it was causing massive slowdowns. I was basically doing append (#{1,2,3..} as array)[1] so then I found find the item properly.

There has to be a better way of doing this?? :argh:

Thank you very much!

there is no Compare method for bitarrays in a sense that you are looking for. compare method for bitarrays compares their pointers and can't be used in finditem, appendifunique, and makeuniquearray.

you can use gethashvalue method and search by the hash value.
but the right way is just not process faces of already found elements.
--pseudo
for f in allfaces where not done[f] do (append elements (e = GetElementsUsingFace <node> f); done += e )

Kickflipkid687
05-16-2011, 02:22 AM
Crap.... ok. Basically, I'm doing all this to use the Meshop.Detach Faces method. I could use Polyop, but Meshop works much faster.

Although using Meshop, I have to deal with the newly detached object moving to [0,0,0] and then if I don't filter/loop properly, I get like 50 detaches on a teapot, and most of the objects only have 1-2 verts in them.


well for the strangling objects I can just do

delete (for o in objects where o.mesh.verts.count <=2 collect o)

Now I need to get their positions back to where they were. I was collecting all the verts for each element, adding them together and dividing by the num of verts to get the average pos. But this doesn't seem to be the actual center pos.

denisT
05-16-2011, 02:32 AM
you can make you own bitarray compare function.
the simple rule is: array a equals array b when a.numberset equals b.numberset and a-b is empty set.

denisT
05-16-2011, 02:40 AM
in general case you shouldn't care about number of element faces. total surface area makes more sense for me (or element bbox/volume).

Kickflipkid687
05-16-2011, 02:48 AM
Hm, I can look into the volume approach and see. :)


I saw you posted on this cracking script someone was making. You were detaching faces as objects and he said it was super fast. So I was looking at that approach for this.

My method I'm using now still isn't quite right. I think my old EPoly Method was faster than this one. I will have to download my version before I modified it and test.


Edit: Yeah, using my old method, breaking up 81 teapots as 1 mesh took 31 seconds, while my Editmesh version took 110 seconds :argh:

CGTalk Moderation
05-16-2011, 02:48 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.