エッジ選択にフィルタ処理を行って、「エッジ選択要素」のような、接続されたエッジを含む配列を作成したいと考えています。2 つの配列のエッジは決して接続されません。 つまり、頂点を共有しません。
次の疑似コードは、実行可能な手段を記述したものです。
現在のエッジ選択を取得し、主選択配列に入れます。
未接続のエッジ選択を入れる空の配列を作成します。
(A) 新しい空の配列をサブ配列としてこの配列に追加します。
現在のサブ配列のインデックスを書き留めます。
主選択配列から、最初のエッジを取得します。
このエッジを主選択配列から削除して、未接続の選択配列の現在のサブ配列へ追加します。
新しいサブ配列のエッジごとに、エッジを定義しているそれぞれの頂点を取得します。
2 つの頂点それぞれについて、そのエッジを取得します。これにより、現在のエッジで使用されている頂点を共有した隣接エッジがすべて得られます。
隣接エッジをループ処理して、主選択配列に表示されているかどうかを調べます。
エッジが主選択配列に存在する場合は、そのエッジを主選択配列から削除して、現在のサブ配列に追加します。
サブ配列のすべてのエッジを確認し終えたら、ループを終了します。
この時点ですべてのエッジが接続していれば、主配列は空になります。空でなければ、既に収集した選択に接続していないエッジが存在することになります。
新しい空のサブ配列を、コレクション配列に追加します。
(A) から繰り返します。
この関数は、主配列にエッジが残っていない場合に使用できるようになります。
これにより、未接続のエッジ選択と同数のサブ配列が作成されます。
次の関数は、MAXScript コードに擬似コードを実装します。
スクリプト:
fn getEPolyUnconnectedEdgesSelections thePoly = ( --get the edge selection mainSelection = (polyOp.getEdgeSelection thePoly) as array --init. an array to collect sub-arrays with selections "elements" unconnectedSelections = #() --repeat until the main selection array is empty while mainSelection.count > 0 do ( --append a new empty sub-array: append unconnectedSelections #() --remember the current sub-array's index: currentSelCount = unconnectedSelections.count --append the first edge from the main selectionarray to the sub-array: append unconnectedSelections[currentSelCount] mainSelection[1] --and remove the first edge from the main selectionarray: deleteItem mainSelection 1 --initialize a counter: cnt = 0 --while the counter is less than the edges in the sub-array while cnt < unconnectedSelections[currentSelCount].count do ( cnt += 1--increase the counter by 1 --get the vertices of the current edge in the current sub-array: currentEdgeVerts = (polyOp.GetVertsUsingEdge thePoly unconnectedSelections[currentSelCount][cnt]) as array neigborEdges = #()--init. an array to collect neighbor --for every vertex in the current edge, for v in currentEdgeVerts do --add the edges used by the vertex to the neighbors array join neigborEdges ((polyOp.GetEdgesUsingVert thePoly v) as array) --for each neighbor edge, for edge in neigborEdges do ( --see if the edge is in the main selection array checkInSelection = findItem mainSelection edge --if it is, if checkInSelection > 0 do ( --delete the edge from the main array deleteItem mainSelection checkInSelection --and add it to the current sub-array append unconnectedSelections[currentSelCount] edge )--end if )--end for edge loop )--end while cnt )--end while mainSelection.count --finally, return the array containing the sub-arrays of connected edges: unconnectedSelections )--end fn -- create box and mesh: b = box() convertTo b editable_poly select b getEPolyUnconnectedEdgesSelections $Box001--call the function