понедельник, 11 апреля 2011 г.

Обобщённая версия скрипта для деревьев данных. Превращает ель в сосну, напрмер :D

Под катом

Private Sub RunScript(ByVal x As DataTree(Of System.Object), ByVal BranchCount As System.Object, ByVal LimIndBranch As Object, ByVal ItemBranch As Object, ByVal selindex As List(Of System.Object), ByRef RebuildTree As Object, ByRef ModifyTree As Object, ByRef FlatModTree As Object, ByRef selectedlist As Object)
    Dim tree As New DataTree(Of Object)
    Dim j,i As Integer
    For j = 0 To BranchCount - 1
      Dim path As New GH_Path(j)
      For i = j * (LimIndBranch + 1)  To LimIndBranch * (j + 1) + j
        tree.Addrange(x.Branch(i), path)
      Next
    Next
    RebuildTree = tree
    Dim itree As New DataTree(Of Object)
    Dim selectedlist0 As New List(Of Object)
    Dim q As Integer
    For q = 0 To ItemBranch - 1
      Dim ipath As New GH_Path(q)
      selectedlist = nFunction(tree, q, selindex)
      itree.Addrange(nFunction(tree, q, selindex), ipath)
    Next
    ModifyTree = itree
    FlatModTree = itree.AllData
  End Sub

  '<Custom additional code>
  Function nFunction (ByRef tree As DataTree(Of System.Object), ByRef q As Integer, ByRef selindex As List (Of System.Object))As Object
    Dim List As New List(Of Object)
    Dim List2 As New List(Of Object)
    Dim num As Object
    List = tree.Branch(q)
    For Each num In selindex
      'max num in selindex =< max num in nStep!
      If selindex.Contains(num) Then List2.Add(List(num))
    Next
    nFunction = List2
  End Function

Комментариев нет:

Отправить комментарий