Select smoothed faces as if they were one face?
-
Is there a built in way to easily select faces that have edges smoothed together to make it appear like a single face? So, like think of a sphere with hidden geometry on. You can see its made up of a bunch of faces. With hidden geometry showing, you can see each face and selsect each individually. But with hidden geometry off, it appears as a single big face. Select one and you select them all.
Is there a way to run through a model and get each array of faces that makes up each larger group of faces? Does that make sense?
I have some ideas how to write a method that loops through and does this, but I thought there might be a method that helps do this quicker. Thanks,
Chris
-
Do you want to get an array of connected smoothed faces from one give face?
Or do you want multiple arrays of all smoothed faces? -
The end product that I will need is a single array that contains arrays of connected/smooth faces.
faces = [face1, [face2, face3, face4], face5, [face6, face7], face8, [face9, face10, face 11]]
But just figurung out how to make a single array per group of smoothed faces is enough. I can then turn them into an array like I've shown above.
I was thinking a recursive method? (I'm sort of guessing at the terms here). But one that I give a face name. Its job is to find all connected edges and determine if they are softe/smoothed. If yes, then it finds the other common face to that line and sends it back into the same method. It would then keep going until all faces that were connected have been run through the method and all edges have been tested to see if they are soft/smoothed.
Does that sound sort of logical? I know I will need to keep track of various things like edges that have been run already, and faces and such. I think I remember you running into an issue with recursive scanning like this. Is that something I should worry about?
Chris
-
Chris,
Here is a piece of code that I use in my scripts.
You can adapt the test on Edges (hidden?, smooth?, soft?) to your own need.#Determine all connected faces to the face (i.e. if bording edge is soft or hidden) #note; the recursive version seems to bugsplat on big number of faces. So I use an iterative version def face_neighbours(face) hsh_faces = {} lface = [face] while true break if lface.length == 0 f = lface[0] if hsh_faces[f.entityID] lface[0..0] = [] next end lface[0..0] = [] hsh_faces[f.entityID] = f f.edges.each do |e| if e.hidden? || e.soft? e.faces.each do |ff| lface.push ff unless ff == f || hsh_faces[ff.entityID] end end end end hsh_faces.values end
Fredo
-
Recursing is no good for this kind of thing. It doesn't take too much geometry before you create a stack overflow and bugsplat SU. I had major pains with that when I first made my Selection Toys plugin. Besides, after reading up on stack overflows and recursive loops, recursive loops is often inefficient.
Fredo's solution is the way to go. That's the method I ended up with as well. Build and array of the elements you want to process as you traverse your geometry and make a loop that runs until you've processes the whole array.
-
Whaat, its taken me some time to get back to this, but a HUGE thank you! This does the trick quite well. I send it a face and it gives me back all connected faces. I then can remove those faces from my selection set so as to not re-examine them. Absolutely brilliant. This will get written into my components onto faces script. Hopefully have it done and updated tonight. Thanks a million,
Chris
Advertisement