I need to store a series of polyline shapes that are defined as a list of x/y coordinates. These represent the locations of coordinates for each point in an irregular 2d shape. In VB, I was drawing a series of shapes and filling them with a color. It's for a mapping display showing buildings. Each building outline is drawn and then filled.
I had created a structure such as:
structure pts
x.f
y.f
endstructure
Define bldgs.pts(0)
Then, as I read the data file, "999" is used as a flag for the end of each segment.
I would read the datafile and continue to add the points to the bldgs() array until "999" was encountered".
In VB, I would then add the entire bldgs.pts() array to a collection called allpoints() say. So allpoints(0) would contain multiple copies of bldgs() with different sets of points.
I would then use For Each to draw the polyline segments of each building from the allpoints() collection.
How can I do this with Purebasic? I need an an array of a structured array; something like;
structure pts
x.f
y.f
endstructure
Define points.pts(0) ; first create the structure to hold the points.
Define bldgs().points ; then an array to hold the collection of points.
Here is the actual VB.NET code
Code: Select all
Here is the actual VB.NET code
Public gdiBLDGS As New Collection 'this is a collection of point arrays
Dim Temppts(0) As PointF
Dim x1 As Single
Dim y1 As Single
Dim ub As Int32
Dim FileName$ = TowerPath + "\asde_bldgs.srq"
' Open file.
FileOpen(1, FileName$, OpenMode.Input)
' Loop until end of file.
ub = 0
Do While Not EOF(1)
' Read line into variable.
Input(1, x1)
Input(1, y1)
If x1 = 999 And y1 = 999 Then
gdiBLDGS.Add(Temppts)
ub = 0
'clear the temppts array
ReDim Temppts(0)
Else
ReDim Preserve Temppts(ub)
Temppts(ub).X = x1 + 288.81145 '293.81145
Temppts(ub).Y = Abs(y1 + -88.59055) '-91.59055)
ub = ub + 1
End If
Loop
FileClose(1)