View Full Version : how to determine if a mesh is closed

01 January 2009, 10:41 AM
Simple question hopefully with a simple answer. How can I determine if a mesh is closed or not?

01 January 2009, 11:02 AM
you could loop through the edges and see if any edge is only contained in one face... that face would be open


01 January 2009, 12:53 PM
Why not just use an STL modifier to check it?

01 January 2009, 01:02 PM
that could work but has the potential to be extremely slow, especially looping over multiple objects. I was hoping there was a built in function.

After writing the above and before posting I had a quick look at the edit_poly mod and came up with this function: fn isClosedMesh o =
addModifier o (edit_poly())
m = o.modifiers[1]
faces = #{1..(m.GetNumFaces())}
m.SetSelection #Face faces
isMeshClosed = (m.convertSelectionToBorder #Face #Edge) == 0
deleteModifier o 1
It only seems to work with the modify panel open though which is a pain

Anyone know of a better way to do this?

01 January 2009, 01:06 PM
-- For Editable Meshes and Polys:
(meshOp.getOpenEdges $).isEmpty
(polyOp.getOpenEdges $).isEmpty

-- true: the surface is closed
-- false: the surface is open

- Enrico

01 January 2009, 01:12 PM
Thanks Dave I'd completely forgotton about the STL modifier.

SyncViewS, your solution is nice and tidy. I don't think I've ever used getOpenEdges before. Thanks heaps

CGTalk Moderation
01 January 2009, 01:12 PM
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.