Collect Border Edges of mesh
I'm trying to collect the edges of all borders (open edges) in my mesh and store these edges in an array. More specifically I would like to seperate the edges into as many arrays as there are borders in the mesh. Example: we have a mesh with 2 holes in it (see attached files for an image of the mesh), therefore it has 2 borders, I'd like the script to produce an array with 2 subarrays, 1 subarray for each hole/'open edge loop'.
If anyone could tell me what the proper way to collect the edges into an array is that'd be very much appreciated. If you know/can think of a good way of separating the edges into their respective sub arrays (corresponding to the holes/border in the mesh) please let me know.
What I've tried:
I've tried selecting the open edges using the command
polyOp.getOpenEdges $
.
I did get this working for selecting the open edges, unfortunately I was not able to 'get' the edge numbers of said open edges using this command since the result of the getOpenEdges command is a bitarray(http://forums.cgsociety.org/archive/index.php?t-478659.html and https://help.autodesk.com/view/3DSMAX/2016/ENU/?guid=__files_GUID_B40F84...).
I've written some pseudocode which should work for seperating the edges into their respective subarrays after all open edges have been stored in an array:
--NOTE: open_edges is the array in which all open/border edges of the mesh are stored i = 0; edge_found = true while open_edges.count > 0 do( current_loop = #() while edge_found == true do( i += 1 if i==1 do( append current_loop open_edges[1]; Deleteitem open_edges 1 ) -- Select 2nd vertex of current_loop[-1] -- Find edge in 'open_edges' which has this vertex -- Append the found edge to 'current_loop' -- Remove the found edge from 'open_edges' --if(no edge is found)do( edge_found = false ) ) --end while edge_found == true do( ) --end while open_edges.count > 0 do(
If you spot a mistake in my code/approach for separating the edges into their respective sub arrays (corresponding to the holes/border in the mesh) or can think of a better/more efficient method of performing this process please let me know.
Thank you!
Note: in the attached image: 'edge_and_vertex_nums.png' I've indicated the edge numbers in red and the vertex numbers in blue/purple.
Attachment | Size |
---|---|
desired_ouput.png | 69.48 KB |
edge_and_vertex_nums.png | 53.79 KB |
open_edge_loop_numbers.png | 61.92 KB |
testmesh.max | 960 KB |
Comments
.
Tools and Scripts for Autodesk 3dsMax
.
for some reason when poly border has shared vert my function returns two separate edge groups for each part. But when you select this border in viewport manually it will contain both of them.
.
Because 3ds Max uses more inaccurate method than yours. :)
Tools and Scripts for Autodesk 3dsMax
.
you're almost there
1. polyOp.getOpenEdges
2. polyop.getBorderFromEdge
;)