16,554
社区成员
发帖
与我相关
我的任务
分享
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim o As Integer = 0
'获取文件数据
Dim _fileText As String = File.ReadAllText("04-05-50LMS_L___04-06-29.txt")
'格式化
Dim _sj As New GetSJ()
Dim _allpmsj As String() = _sj.getALLSJ(_fileText) '读取数据
Dim x As New List(Of Double) 'list x 定义的一个LIST
Dim y As New List(Of Double) 'list y 定义的一个LIST
Dim z As New List(Of Double) 'list z 定义的一个LIST
z = _sj.getZZ(_allpmsj)注意 运行到这里的时候 直接抛出异常了
GL.glClear(GL.GL_COLOR_BUFFER_BIT Or GL.GL_DEPTH_BUFFER_BIT)
GL.glLoadIdentity()'设置为当前矩阵 (我也不知道啥意思)
GL.glPointSize(10)'设置一个点的大小为10像素
GL.glBegin(GL.GL_POINTS)‘开始画点
For i As Integer = 0 To z.Count Step 1 '通过循环
x = _sj.getX(_allpmsj(i))'取得x
y = _sj.getY(_allpmsj(i))'取得y
For j As Integer = 0 To x.Count Step 1‘通过循环
GL.glVertex3d(x(j), y(j), z(i))’画一个点
Next
Next
GL.glEnd()’结束画点
WGL.wglSwapBuffers(hdc)
Catch ex As Exception
MessageBox.Show(ex.Message)’输出错误信息
End Try
End Sub
getZZ的函数为
Public Function getZZ(ByVal str As String())
Dim list As List(Of Double) = Nothing
Dim i As Integer = 0
For i = 0 To str.Length Step 1
list.Add(getZ(str(i)))
Next
Return list
End Function
GetZ的函数为
Public Function getZ(ByVal str As String)
Dim a = str
Dim i = a.IndexOf("{")
Dim j = a.IndexOf("|")
Dim c As Double = 0.0F
Dim b As String = a.Substring(i + 1, j - 1)
If (b.IndexOf("|") <> -1) Then
b = b.Substring(0, b.IndexOf("|"))
c = Convert.ToDouble(b)
End If
Return c
End Function
Public Function getZZ(ByVal str As String())
Dim list As List(Of Double) = Nothing 《====这里一个 造成下面未将对像实例 这里要new List() 而不能用Nothing
Dim i As Integer = 0
For i = 0 To str.Length Step 1
list.Add(getZ(str(i)))
Next
Return list
End Function