HI

I am trying to rewrite a script another user wrote a while back
written originally in Python...in VB. There may be several problems
but for the time being my efforts to debug and find where the problem
lies are not working - I believe there may be something off with the
whole recursive structure. In any case my attempts to "Print" to see
where things have gone awry are not even working. Anyone care to give
some insight?

Imports System
Imports System.IO
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Reflection
Imports System.Collections
Imports System.Collections.Generic
Imports Microsoft.VisualBasic

Imports RMA.OpenNURBS
Imports RMA.Rhino

Imports Grasshopper
Imports Grasshopper.Kernel.Data
Imports Grasshopper.Kernel.Types

Class Grasshopper_Custom_Script
#Region "utility functions"
  ''' <summary>
  ''' Print a string to the [out] field of the Script component.
  ''' </summary>
  ''' <param name="msg">Text to print.</param>
  Private Sub Print(ByVal msg As String)
    'contents hidden in user frontend...
  End Sub

  ''' <summary>
  ''' Print a formatted string to the [out] field of the Script
component.
  ''' </summary>
  ''' <param name="s_format">Format specifier.</param>
  ''' <param name="args">Formatting items.</param>
  Private Sub Print(ByVal s_format As String, ByVal ParamArray args As
Object())
    'contents hidden in user frontend...
  End Sub

  ''' <summary>
  ''' Examines an object instance using Reflection and prints a
  ''' summary to the [out] field of the script component.
  ''' </summary>
  ''' <param name="d">Object to examine.</param>
  Private Sub Reflect(ByVal d As Object)
    'contents hidden in user frontend...
  End Sub

  ''' <summary>
  ''' Examines a specific method of a object instance using Reflection
and prints a
  ''' summary to the [out] field of the script component.
  ''' </summary>
  ''' <param name="d">Object to examine.</param>
  ''' <param name="proc_name">Name of method to examine.</param>
  Private Sub Reflect(ByVal d As Object, ByVal proc_name As String)
    'contents hidden in user frontend...
  End Sub
#End Region

#Region "members"
  Private app As MRhinoApp
  Private doc As MRhinoDoc

  Public A As System.Object
  Public B As System.Object
  Public C As System.Object
  Public D As System.Object
  Public EE As System.Object
#End Region

  Sub RunScript(ByVal uv As List(Of On3dPoint), ByVal G As List(Of
Object), ByVal i As Object, ByVal j As Object, ByVal minU As Double,
ByVal maxU As Double, ByVal minV As Double, ByVal maxV As Double)
    'your code here…

    Dim AA As New List(Of On3dPoint)
    Dim BB As New List(Of On3dPoint)
    Dim CC As New List(Of On3dPoint)
    Dim DD As New List(Of On3dPoint)
    Dim EE As New List(Of String)

    Dim u As New Double
    Dim v As New Double
    Dim depth As New Int32
    Dim ud As New Double
    Dim vd As New Double

    Dim k As New Integer
    Dim num As New Integer
    num = uv.Count - 1

    EE.Add("test")

    For k = 0 To num Step 1
      u = uv(k).x
      v = uv(k).y
      depth = int(G(k) * j)

      ud = (maxU - minU) / i
      vd = (maxV - minV) / i

      'Call subdivide(u, v, depth - 1, ud, vd, maxU, maxV, AA, BB, CC,
DD)
      Call subdivide(u, v, depth - 1, ud, vd, maxU, maxV, AA, BB, CC,
DD)

    Next

    A = AA
    B = BB
    C = CC
    D = DD

  End Sub

#Region "Additional methods and Type declarations"

  Sub subdivide(ByRef u As Double, ByRef v As Double, ByRef depth As
int32, ByRef ud As Double, ByRef vd As Double, ByVal maxU As Double,
ByVal maxV As Double, ByRef AA As List (Of On3dPoint), ByRef BB As
List (Of On3dPoint), ByRef CC As List (Of On3dPoint), ByRef DD As List
(Of On3dPoint))

    If u >= maxU Or v >= maxV Then
      Print("return")
      Return
    Else If depth < 2 Then
      Dim AAA As  On3dPoint = New On3dPoint(u, v, 0)
      Dim BBB As On3dPoint = New On3dPoint(u + ud, v, 0)
      Dim CCC As On3dPoint = New On3dPoint(u + ud, v + vd, 0)
      Dim DDD As On3dPoint = New On3dPoint(u, v + vd, 0)

      AA.Add(AAA)
      BB.Add(BBB)
      CC.Add(CCC)
      DD.Add(DDD)

    Else
      ud /= 2
      vd /= 2

      Call subdivide(u, v, depth - 1, ud, vd, maxU, maxV, AA, BB, CC,
DD)
    End If

#End Region
End Class

Reply via email to