EPoly エッジ選択から、未接続のエッジ選択を作成する方法はありますか。

質問:

エッジ選択にフィルタ処理を行って、「エッジ選択要素」のような、接続されたエッジを含む配列を作成したいと考えています。2 つの配列のエッジは決して接続されません。 つまり、頂点を共有しません。

回答:

次の疑似コードは、実行可能な手段を記述したものです。

この関数は、主配列にエッジが残っていない場合に使用できるようになります。

これにより、未接続のエッジ選択と同数のサブ配列が作成されます。

次の関数は、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