我试图收集网格中所有边框(开放边缘)的边缘,并将这些边缘存储在一个数组中。更具体地说,我想将边缘分成尽可能多的数组,就像网格中有边框一样。
示例:我们有一个带有2个孔的网格(参见附件中的网格图像文件),因此它有2个边框,我喜欢用脚本生成一个包含2个子数组的数组,1个子数组对于每个洞/'开放边缘循环'此网格的图像:test mesh, vertex numbers indicated in blue/purple, edge numbers indicated in red
如果有人能告诉我将边缘收集到数组中的正确方法是非常感谢。如果您知道/可以想到将边缘分成各自的子阵列(对应于网格中的孔/边框)的好方法,请告诉我。
图片:
我尝试过的事情:
我尝试使用命令
选择开放边缘 polyOp.getOpenEdges $
我确实选择了打开的边缘,不幸的是我无法得到'由于getOpenEdges命令的结果是比特(here和here),因此使用此命令的所述开放边的边数。
我已经编写了一些伪代码,在所有打开的边都存储在数组中之后,这些伪代码可以将边分隔成各自的子数组:
- 注意:open_edges是存储网格的所有开放/边界边缘的数组
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
--if(no edge is found)then( edge_found = false )
--else(
-- Append the found edge to 'current_loop'
-- Remove the found edge from 'open_edges'
--)
) --end while edge_found == true do(
) --end while open_edges.count > 0 do(
如果您发现我的代码/方法中的错误将边缘分成各自的子阵列(对应于网格中的孔/边框),或者可以想到更好/更有效的方法来执行此过程,请让我知道。
谢谢!
注意:在附图中:' edge_and_vertex_nums.png'我用红色表示边数,用蓝色/紫色表示顶点数。
答案 0 :(得分:0)
试试这个。 您还可以简单地将firstHole数组与allOpenEdges进行比较,并删除重复项。
allOpenEdges = (polyop.getOpenEdges $) as array
firstHole = (polyop.getBorderFromEdge $ allOpenEdges[1]) as array
select $
subobjectlevel = 2
polyop.setEdgeSelection $ firstHole
subobjectLevel = 3
max select invert
secondHole = (polyop.getedgeselection $) as array
subobjectLevel = 0
format "count1: %, count2: %\n" firstHole.count secondHole.count