I have a MeshRegion
that defines a 2D surface embedded in 3D. Is there a function that returns all the boundaries of the mesh?
More specifically, I need for each boundary loop, a list of its vertices (or edges) ordered along the boundary. The ordering is important, i.e. subsequent vertices (or edges) in the list should be connected in the mesh.
I have a rather large obj file, but lets say I had the MeshRegion
defined below that gives half of a sphere (I can imagine more elegant code to get this mesh). Then I would like to extract all the vertices on the boundary (in this case only one loop), but in order of traversal along the boundary.
s = BoundaryDiscretizeGraphics[Graphics3D[{Ball[]}]];
pos = Flatten[Position[MeshCoordinates[s], {x_, _, _} /; x < 0]];
f = DeleteCases[MeshCells[s, 2][[All, 1]],
x_ /; Intersection[pos, x] != {}];
mesh = MeshRegion[MeshCoordinates[s], Polygon /@ f]