Vous êtes sur la page 1sur 30

Attribute VB_Name = "Module1" 'Option Explicit Public ShortestPathIndex() As Integer Public ObjectSelectIndex() As Integer Public TTFFileName As String Public

Type Linie xa As Single ya As Single za As Single xe As Single ye As Single ze As Single End Type Public Type Kreis xa As Single ya As Single za As Single r As Single End Type Public Type Bogen xa As Single ya As Single za As Single r As Single sw As Single ew As Single End Type Public Type Punkt xa As Single ya As Single za As Single End Type Public Type Vertex xa As Single ya As Single za As Single End Type Public Type Ellipse xa As Single ' Centerpoint ya As Single za As Single xm As Single ' Majoraxispoint rel. to Center ym As Single zm As Single v As Single ' Verhltnis der Minor zur Hauptachse sw As Single ' Startwinkel ew As Single ' Endwinkel End Type Public Linien() As Linie Public Save As Linie

Public Public Public Public Public Public Public Public Public Public Public Public Public Public Public Public Public Public Public Public

Kreise() As Kreis Bgen() As Bogen Punkte() As Punkt Vertex() As Vertex Ellipsen() As Ellipse

i, j, k, l, m, n, o As Integer pos As Integer Anzahl_Linien As Integer Aktuelle_Linie As Integer Text As String Pausenlnge, Start xpos, ypos As Single dx, dy As Integer step_min As Single Plasma As Boolean movex, movey, zoomx, zoomy, zoomx1, zoomy1 As Single lpBuffer As Long lpgm As Long cbBuffer As Long Type POINTAPI x As Long y As Long End Type Public Type FIXED fract As Integer Value As Integer End Type Public Type GlyphPoint x As Single y As Single OnOff As Boolean End Type Public Type GlyphContour PointCount As Integer Points() As GlyphPoint End Type Public Type Glyph Character As String ContourCount As Integer Contour() As GlyphContour End Type Public GlyphArray() As Glyph Public Zahl As Integer ' enthlt Anfangs- u. Endpunkt des Objektes mit Bounding Box Public Type Liste StartIndex As Integer

EndIndex As Integer xmin As Single ymin As Single xmax As Single ymax As Single Parent As Integer Child() As Integer Inside As Boolean Closed As Boolean Sequenz As Integer Lines() As Linie 'Linien-Array End Type Public Public Public Public Public Public Public Public SelectFlag As Boolean MoveFlag As Boolean RotateFlag As Boolean ScaleFlag As Boolean DeleteFlag As Boolean CutFlag As Boolean CopyFlag As Boolean ZoomFlag As Boolean

Public Save0 As Liste Public Save1 As Liste Public List() As Liste Public PortAddress, Value As Integer Public PortValue As Byte Dim begin_at As Integer Dim xsteps(4) As Integer Dim ysteps(4) As Integer Dim x_step, y_step As Integer

Sub Main() ' Voreinstellungen usw. step_min = 2.71 'entspricht 0.271mm/Schritt Load Form1 End Sub

' build line with straight and diagonal segments */ ' Parameter Zeilposition x bzw. y_target, Fahrgeschwindigkeit v in m/s*/ Public Function Go_to(x_target As Integer, y_target As Integer, v As Integer) Dim x_direction, y_direction As Integer Dim i, l, h, k As Integer

Dim steps, bent_steps, straight_steps, counter, x_straight, y_straight, x, y As Integer Dim v_x, v_y, step_delay, x_dist, y_dist As Double ' step_delay entspricht der Verzgerung in msec zwischen den einzelnen Steps */ x_direction = 1 y_direction = 1 x_dist = x_target - xpos If x_dist < 0 Then x_direction = -1 x_dist = -1 * x_dist End If y_dist = y_target - ypos If y_dist < 0 Then y_direction = -1 y_dist = -1 * y_dist End If ' check out x/y direction */

' aus Sicherheitsgrnden (Div durch NUll)*/ If ((x_dist <> 0) Or (y_dist <> 0)) Then If y_dist < x_dist Then ' check out x/y ratio */ ' more the x way */ ' Delay zwischen den Steps aus der Sollgeschwindigkeit berechen*/ x_straight = x_direction y_straight = 0 steps = x_dist bent_steps = y_dist v_x = x_dist / (Sqr(x_dist * x_dist + y_dist * y_dist)) * v ' Geschwindigkeit in x-Richtung*/ step_delay = 369 / v_x ' Achtung Millisekunden 369 entspr. 1000000/x_step_per_m*/ Else ' more the y way */ ' Delay zwischen den Steps aus der Sollgeschwindigkeit berechen*/ x_straight = 0 y_straight = y_direction steps = y_dist bent_steps = x_dist v_y = y_dist / (Sqr(x_dist * x_dist + y_dist * y_dist)) * v ' Geschwindigkeit in y-Richtung*/ step_delay = 369 / v_y ' Achtung Millisekunden*/ End If straight_steps = steps - bent_steps 'counter = (bent_steps < straight_steps) ? straight_steps : (-1 * bent_steps) straight_steps = straight_steps * 2

bent_steps = bent_steps * 2 For i = 0 To steps - 1 ' Hier Abbruchfunktion, z.B. durch Endschalter und Sicherheitsschalter einfgen ' main loop for line drawing (include abort function here) */ If counter > 0 Then ' do straight step */ counter = counter - bent_steps ' already doubled! */ x = x_straight y = y_straight Else ' do bent step */ counter = counter + straight_steps ' already doubled! */ x = x_direction y = y_direction End If ' Schritte ausfhren Call Schritt((x), (y), 1) ' Aktuelle Position aktualisieren xpos = xpos + x ypos = ypos + y ' hier Delay zwischen den Steps einfgen; geanuer Multiplikator noch zu bestimmen*/ For k = 1 To CLng(step_delay) For kk = 1 To 1000 Next kk Next k Next i End If End Function Public Function DxfRead(File As String) Dim Pi, NumberOfLines As Integer Dim tol, x, alpha, Bogenlnge, BogenlngeRad As Single

Open File For Input As #1 j k l m n o = = = = = = 0 0 0 0 0 0 ' ' ' ' ' '

' Datei ffnen.

Gibt Anzahl der gelesenen Linien an Anzahl der Kreise Anzahl der Kreisbgen Anzahl der Punkte Anzahl der Polylines Anzahl der Ellipsen

Pi = 3.1416

ReDim ReDim ReDim ReDim ReDim ReDim

Linien(0) Kreise(0) Bgen(0) Punkte(0) Vertex(0) Ellipsen(0)

' Anmerkung: Bei Systemeinstellung Deutsch werden Zahlenwerte mit Kommas ' versehen -> Text muss immer mit folgendem Code gewandelt werden (, > .) 'pos = InStr(Text, ".") 'Punkt durch Komma ersetzen 'If pos <> 0 Then 'Text = Left(Text, pos - 1) & "," & Right(Text, Len(Text) - pos) 'End If

' Hauptschleife Do While Not EOF(1) ' Schleife bis Dateiende. Line Input #1, Text ' Zeile in Variable einlesen. If Text = " 0" Then Null_Found: Line Input #1, Text ' Linie parsen If (Text = "Line") Or (Text = "LINE") Then Line Input #1, Text Do While (Text <> " 0") If Text = " 10" Then ' Anfangspunkt x-Koordinate lesen Line Input #1, Text Linien(j).xa = CSng(Text) ElseIf Text = " 20" Then ' Anfangspunkt y-Koordinate lesen Line Input #1, Text Linien(j).ya = CSng(Text) ElseIf Text = " 30" Then ' Anfangspunkt z-Koordinate lesen Line Input #1, Text Linien(j).za = CSng(Text) ElseIf Text = " 11" Then ' Endpunkt x-Koordinate lesen Line Input #1, Text Linien(j).xe = CSng(Text) ElseIf Text = " 21" Then ' Endpunkt y-Koordinate lesen Line Input #1, Text Linien(j).ye = CSng(Text) ElseIf Text = " 31" Then ' Endpunkt z-Koordinate lesen

Line Input #1, Text Linien(j).ze = CSng(Text) Else 'Dummyread Line Input #1, Text End If Loop Form1.Picture1.Line (Linien(j).xa, Linien(j).ya)-(Linien (j).xe, Linien(j).ye) j = j + 1 ReDim Preserve Linien(UBound(Linien) + 1) ' durch preserve bleiben bei Redim die Daten erhalten!!! GoTo Null_Found ' Circle parsen ElseIf (Text = "Circle") Or (Text = "CIRCLE") Then Line Input #1, Text Do While (Text <> " 0") If Text = " 10" Then ' Anfangspunkt x-Koordinate lesen Line Input #1, Text Kreise(k).xa = CSng(Text) ElseIf Text = " 20" Then ' Anfangspunkt y-Koordinate lesen Line Input #1, Text Kreise(k).ya = CSng(Text) ElseIf Text = " 30" Then ' Anfangspunkt z-Koordinate lesen Line Input #1, Text Kreise(k).za = CSng(Text) ElseIf Text = " 40" Then ' Radius lesen Line Input #1, Text Kreise(k).r = CSng(Text) Else 'Dummyread Line Input #1, Text End If Loop Form1.Picture1.Circle (Kreise(k).xa, Kreise(k).ya), Kreise (k).r ' Kreis in Linien umwandeln (alpha ist Sektorwinkel) tol = 10 ' max .zul. Fehler =10/10mm x = (1 - tol / Kreise(k).r) alpha = Atn(-x / Sqr(-x * x + 1)) + 2 * Atn(1) NumberOfLines = CInt(2 * 3.14159 / alpha) For i = 0 To NumberOfLines - 1 Linien(j).xa = Kreise(k).xa + Kreise(k).r * Cos(i / NumberOfLines * 2 * 3.14159) Linien(j).ya = Kreise(k).ya + Kreise(k).r * Sin(i / NumberOfLines * 2 * 3.14159)

Linien(j).za = Linien(j).xe = 1) / NumberOfLines * 2 * 3.14159) Linien(j).ye = 1) / NumberOfLines * 2 * 3.14159) Linien(j).ze =

0 Kreise(k).xa + Kreise(k).r * Cos((i + Kreise(k).ya + Kreise(k).r * Sin((i + 0

'Picture1.Line (Linien(j).xa, Linien(j).ya)-(Linien (j).xe, Linien(j).ye) j = j + 1 ReDim Preserve Linien(UBound(Linien) + 1) Next i k = k + 1 ReDim Preserve Kreise(UBound(Kreise) + 1) ' durch preserve bleiben bei Redim die Daten erhalten!!! GoTo Null_Found ' Arc parsen ElseIf (Text = "Arc") Or (Text = "ARC") Line Input #1, Text Do While (Text <> " 0") If Text = " 10" Then ' Anfangspunkt x-Koordinate Line Input #1, Text Bgen(l).xa = CSng(Text) ElseIf Text = " 20" Then ' Anfangspunkt y-Koordinate Line Input #1, Text Bgen(l).ya = CSng(Text) ElseIf Text = " 30" Then ' Anfangspunkt z-Koordinate Line Input #1, Text Bgen(l).za = CSng(Text) ElseIf Text = " 40" Then ' Radius lesen Line Input #1, Text Bgen(l).r = CSng(Text) ElseIf Text = " 50" Then ' Startwinkel lesen Line Input #1, Text Bgen(l).sw = CSng(Text) ElseIf Text = " 51" Then ' Endwinkel lesen Line Input #1, Text Bgen(l).ew = CSng(Text) Else 'Dummyread Line Input #1, Text End If Loop

Then

lesen

lesen

lesen

Form1.Picture1.Circle (Bgen(l).xa, Bgen(l).ya), Bgen (l).r, , Bgen(l).sw / 180 * 3.1416, Bgen(l).ew / 180 * 3.1416 ' Bogen in Linien umwandeln (alpha ist Sektorwinkel) tol = 10 ' max .zul. Fehler =10/10mm x = (1 - tol / Bgen(l).r) alpha = Atn(-x / Sqr(-x * x + 1)) + 2 * Atn(1) ' Winkel in Grad Bogenlnge = Bgen(l).ew - Bgen(l).sw If Bogenlnge < 0 Then Bogenlnge = Bogenlnge + 360 End If BogenlngeRad = Bogenlnge / 180 * Pi NumberOfLines = CInt(BogenlngeRad / alpha) For i = 0 To NumberOfLines - 1 Linien(j).xa = Bgen(l).xa + Bgen(l).r * Cos(i / NumberOfLines * BogenlngeRad + Bgen(l).sw / 180 * Pi) Linien(j).ya = Bgen(l).ya + Bgen(l).r * Sin(i / NumberOfLines * BogenlngeRad + Bgen(l).sw / 180 * Pi) Linien(j).za = 0 Linien(j).xe = Bgen(l).xa + Bgen(l).r * Cos((i + 1) / NumberOfLines * BogenlngeRad + Bgen(l).sw / 180 * Pi) Linien(j).ye = Bgen(l).ya + Bgen(l).r * Sin((i + 1) / NumberOfLines * BogenlngeRad + Bgen(l).sw / 180 * Pi) Linien(j).ze = 0 'Picture1.Line (Linien(j).xa, Linien(j).ya)-(Linien (j).xe, Linien(j).ye) j = j + 1 ReDim Preserve Linien(UBound(Linien) + 1) Next i l = l + 1 ReDim Preserve Bgen(UBound(Bgen) + 1) ' durch preserve bleiben bei Redim die Daten erhalten!!! GoTo Null_Found ' Ellipse parsen ElseIf (Text = "Ellipse") Or (Text = "ELLIPSE") Then Line Input #1, Text Do While (Text <> " 0") If Text = " 10" Then Line Input #1, Text Ellipsen(o).xa = CSng(Text) ElseIf Text = " 20" Then Line Input #1, Text Ellipsen(o).ya = CSng(Text) ElseIf Text = " 30" Then Line Input #1, Text Ellipsen(o).za = CSng(Text) ElseIf Text = " 11" Then

Line Input #1, Text Ellipsen(o).xm = CSng(Text) ElseIf Text = " 21" Then Line Input #1, Text Ellipsen(o).ym = CSng(Text) ElseIf Text = " 31" Then Line Input #1, Text Ellipsen(o).zm = CSng(Text) ElseIf Text = " 40" Then ' Verhltnis der kleinen zur groen Achse Line Input #1, Text Ellipsen(o).v = CSng(Text) ElseIf Text = " 41" Then ' Startwinkel lesen Line Input #1, Text Ellipsen(o).sw = CSng(Text) ElseIf Text = " 42" Then ' Endwinkel lesen Line Input #1, Text Ellipsen(o).ew = CSng(Text) Else 'Dummyread Line Input #1, Text End If Loop ' Anpassen !!! Picture1.Circle (Bgen(l).xa, Bgen(l).ya), Bgen(l).r, , Bgen(l).sw / 180 * 3.1416, Bgen(l).ew / 180 * 3.1416 o = o + 1 ReDim Preserve Ellipsen(UBound(Ellipsen) + 1) ' durch preserve bleiben bei Redim die Daten erhalten!!! GoTo Null_Found ' Punkte parsen ElseIf (Text = "Point") Or (Text = "POINT") Then Line Input #1, Text Do While (Text <> " 0") If Text = " 10" Then ' Anfangspunkt x-Koordinate lesen Line Input #1, Text Punkte(m).xa = CSng(Text) ElseIf Text = " 20" Then ' Anfangspunkt y-Koordinate lesen Line Input #1, Text Punkte(m).ya = CSng(Text) ElseIf Text = " 30" Then ' Anfangspunkt z-Koordinate lesen Line Input #1, Text Punkte(m).za = CSng(Text) Else 'Dummyread Line Input #1, Text End If

Loop ' Picture1.Point (Punkte(m).xa, Punkte(m).ya) m = m + 1 ReDim Preserve Punkte(UBound(Punkte) + 1) ' durch preserve bleiben bei Redim die Daten erhalten!!! GoTo Null_Found ' Polyline parsen (es wird immer angenommen, das es sich um closed PL handelt) ElseIf (Text = "Vertex") Or (Text = "VERTEX") Then Line Input #1, Text Do While (Text <> "SEQEND") If Text = " 10" Then ' Anfangspunkt x-Koordinate lesen Line Input #1, Text Vertex(n).xa = CSng(Text) ElseIf Text = " 20" Then ' Anfangspunkt y-Koordinate lesen Line Input #1, Text Vertex(n).ya = CSng(Text) ElseIf Text = " 30" Then ' Anfangspunkt z-Koordinate lesen Line Input #1, Text Vertex(n).za = CSng(Text) n = n + 1 ReDim Preserve Vertex(UBound(Vertex) + 1) Else 'Dummyread Line Input #1, Text End If Loop For i = 0 To n - 1 Linien(j).xa = Vertex(i).xa Linien(j).ya = Vertex(i).ya Linien(j).za = Vertex(i).za Linien(j).xe = Vertex((i + 1) Mod n).xa Linien(j).ye = Vertex((i + 1) Mod n).ya Linien(j).ze = Vertex((i + 1) Mod n).za Form1.Picture1.Line (Linien(j).xa, Linien(j).ya)(Linien(j).xe, Linien(j).ye) j = j + 1 ReDim Preserve Linien(UBound(Linien) + 1) Next i n = 0 GoTo Null_Found Else ' break or do nothing End If End If Loop ' Ende Hauptschleife (Dateiende) Close #1 ' Datei schlieen

End Function Public Function Schritt(x As Integer, y As Integer, wait As Integer) ' x,y =-1,0,1 xsteps(0) = 0: xsteps(1) = 4: xsteps(2) = 12: xsteps(3) = 8 ysteps(0) = 0: ysteps(1) = 2: ysteps(2) = 3: ysteps(3) = 1 begin_at = 0 If Plasma <> plasma_old Then begin_at = -1 * plasma_delay 'update memory for plasma status plasma_old = Plasma End If 'output to hardware ('wait' times) For i = begin_at To wait 'plasma delay period over? If i = 0 Then x_step = (x_step + 4 + x) Mod 4 ' xstep, ystep = 0,1,2,3 */ y_step = (y_step + 4 + y) Mod 4 ' move when plasma set */ ' Cint(Wahr)= -1 -> -64 Out PortAddress, CInt(Plasma) * (-64) + xsteps(x_step) + ysteps (y_step) End If Next i End Function Public Function GlyphRead(File As String) Dim Text, Text0, Text1, Text2, Buchstabe As String Dim i, j, Zahl1, Zahl2 As Integer Dim x, y As Single Dim OnOff As Boolean Dim k, l, n As Integer Dim Gp As GlyphPoint Dim GpArray() As GlyphPoint Dim Charactercount, PointCount As Integer Dim t As Single ReDim GpArray(1) ReDim GlyphArray(1) Zahl = 0 ' Text.Fil enthlt TrueTypeInformationen Open File For Input As #3 ' Datei ffnen. ' Hauptschleife Do While Not EOF(3) ' Schleife bis Dateiende. Line Input #3, Text ' Zeile in Variable einlesen. Buchstabe = Right(Trim(Text), 3)

Text0 = Left(Trim(Text), 6) If Text0 = "object" Then Zahl = Zahl + 1 'Zahl enthlt Anzahl der Objekte GlyphArray(Zahl).Character = Buchstabe Line Input #3, Text Zahl1 = CInt(Right(Trim(Text), 1)) 'Zahl1 enthlt Anzahl der Contouren pro Objekt (Charakter) Text0 = Left(Trim(Text), 5) GlyphArray(Zahl).ContourCount = Zahl1 ReDim GlyphArray(Zahl).Contour(Zahl1) For i = 1 To Zahl1 Line Input #3, Text 'Zahl2 enthlt die Anzahl der Punkte pro Contour Zahl2 = CInt(Right(Trim(Text), 2)) 'Zahl2 enthlt Anzahl der Punkte Pro Contour Text0 = Left(Trim(Text), 7) ReDim GlyphArray(Zahl).Contour(i).Points(Zahl2) GlyphArray(Zahl).Contour(i).PointCount = Zahl2 For j = 1 To Zahl2 Line Input #3, Text 'X/Y-Koordinate und onoff bestimmt ob auf Contour oder nicht x = CSng(Left(Trim(Text), 9)) y = CSng(Mid(Trim(Text), 10, 9)) OnOff = CBool(Right(Trim(Text), 1)) GlyphArray(Zahl).Contour(i).Points(j).OnOff = OnOff GlyphArray(Zahl).Contour(i).Points(j).x = x GlyphArray(Zahl).Contour(i).Points(j).y = y Next j Next i ReDim Preserve GlyphArray(UBound(GlyphArray) + 1) Else End If Loop Close #3 'GlyphToOutline konvertieren Charactercount = Zahl For k = 1 To Charactercount 'Zahl !!!! noch nicht global For i = 1 To GlyphArray(k).ContourCount 'Zahl1 PointCount = GlyphArray(k).Contour(i).PointCount 'Zahl2 For j = 1 To PointCount - 1 If Not (GlyphArray(k).Contour(i).Points(j).OnOff) And Not (GlyphArray(k).Contour(i).Points(j + 1).OnOff) Then Gp.x = 0.5 * (GlyphArray(k).Contour(i).Points(j).x + GlyphArray(k).Contour(i).Points(j + 1).x) Gp.y = 0.5 * (GlyphArray(k).Contour(i).Points(j).y + GlyphArray(k).Contour(i).Points(j + 1).y) Gp.OnOff = True ' Interpolierten Punkt im Array einfgen (zwischen j

und j+1) und vorher Array+1 dim. ReDim Preserve GlyphArray(k).Contour(i).Points(UBound (GlyphArray(k).Contour(i).Points) + 1) PointCount = PointCount + 1 For l = PointCount - 1 To j + 1 Step -1 GlyphArray(k).Contour(i).Points(l) = GlyphArray (k).Contour(i).Points(l + 1) Next l GlyphArray(k).Contour(i).Points(j + 1) = Gp 'neuen Punkt einfgen Else End If Next j GlyphArray(k).Contour(i).PointCount = PointCount Next i Next k ' Als nchstes die Punkte auf den Q-Splines berechnen n = 2 'Interpolationsgrad ReDim GpArray(n - 1) For k = 1 To Charactercount 'Zahl !!!! noch nicht global For i = 1 To GlyphArray(k).ContourCount 'Zahl1 For j = 1 To GlyphArray(k).Contour(i).PointCount - 1 'Zahl2 ' off-curve Point erkannt If Not (GlyphArray(k).Contour(i).Points(j).OnOff) Then For m = 1 To n - 1 t = m / n 'Parameterisierte Darstellugn des QSplines GpArray(m).x = (1 - t) ^ 2 * GlyphArray(k).Contour (i).Points(j - 1).x + 2 * t * (1 - t) * GlyphArray(k).Contour(i).Points (j).x + t ^ 2 * (GlyphArray(k).Contour(i).Points(j + 1).x) ^ 2 GpArray(m).y = (1 - t) ^ 2 * GlyphArray(k).Contour (i).Points(j - 1).y + 2 * t * (1 - t) * GlyphArray(k).Contour(i).Points (j).y + t ^ 2 * (GlyphArray(k).Contour(i).Points(j + 1).y) ^ 2 GpArray(m).OnOff = True ' Alle Punkte liegen jettz auf der Contour Next m 'Neue Punkte GpArray einfgen (Dim nicht vergessen) ReDim Preserve GlyphArray(k).Contour(i).Points(UBound (GlyphArray(k).Contour(i).Points) + n - 1) PointCount = GlyphArray(k).Contour(i).PointCount PointCount = PointCount + n - 1 For l = PointCount - 1 To j Step -1 GlyphArray(k).Contour(i).Points(l + n - 1) = GlyphArray(k).Contour(i).Points(l) Next l ' Punkte mssen einzeln gespeichert werden For m = 1 To n - 1 GlyphArray(k).Contour(i).Points(j + m - 1) = GpArray(m)

Next m GlyphArray(k).Contour(i).PointCount = PointCount Else End If Next j Next i Next k End Function Public Function GlyphToOutline(GlyphArray() As Glyph, Interpolationsgrad As Integer) Dim i, j, k, l, n As Integer Dim Gp As GlyphPoint Dim GpArray() As GlyphPoint Dim Charactercount, PointCount As Integer Dim t As Single ReDim GpArray(1)

' falls zwei Punkte off-curve liegen, on-curve-Punkt als Mittelwert der beiden bestimmen und in ' Datenstruktur an passender Stelle (dazwischen) eintragen Charactercount = Zahl For k = 1 To Charactercount 'Zahl !!!! noch nicht global For i = 1 To GlyphArray(k).ContourCount 'Zahl1 PointCount = GlyphArray(k).Contour(i).PointCount 'Zahl2 For j = 1 To PointCount - 1 If Not (GlyphArray(k).Contour(i).Points(j).OnOff) And Not (GlyphArray(k).Contour(i).Points(j + 1).OnOff) Then Gp.x = 0.5 * (GlyphArray(k).Contour(i).Points(j).x + GlyphArray(k).Contour(i).Points(j + 1).x) Gp.y = 0.5 * (GlyphArray(k).Contour(i).Points(j).y + GlyphArray(k).Contour(i).Points(j + 1).y) Gp.OnOff = True ' Interpolierten Punkt im Array einfgen (zwischen j und j +1) und vorher Array+1 dim. 'PunkteDim = GlyphArray(k).Contour(i).Points(j) 'ReDim Preserve PunkteDim(UBound(PunkteDim) + 1) PointCount = PointCount + 1 For l = PointCount - 1 To j + 1 Step -1 GlyphArray(k).Contour(i).Points(l) = GlyphArray (k).Contour(i).Points(l + 1) Next l GlyphArray(k).Contour(i).Points(j + 1) = Gp 'neuen Punkt einfgen Else End If Next j

GlyphArray(k).Contour(i).PointCount = PointCount Next i Next k ' Als nchstes die Punkte auf den Q-Splines berechnen n = Interpolationsgrad For k = 1 To Charactercount 'Zahl !!!! noch nicht global For i = 1 To GlyphArray(k).ContourCount 'Zahl1 For j = 1 To GlyphArray(k).Contour(i).PointCount - 1 'Zahl2 ' off-curve Point erkannt If Not (GlyphArray(k).Contour(i).Points(j).OnOff) Then For m = 1 To n - 1 ReDim GpArray(n - 1) t = m / n 'Parameterisierte Darstellugn des Q-Splines GpArray(m).x = (1 - t) ^ 2 * GlyphArray(k).Contour (i).Points(j - 1).x + 2 * t * (1 - t) * GlyphArray(k).Contour(i).Points (j).x + t ^ 2 * (GlyphArray(k).Contour(i).Points(j + 1).x) ^ 2 GpArray(m).y = (1 - t) ^ 2 * GlyphArray(k).Contour (i).Points(j - 1).y + 2 * t * (1 - t) * GlyphArray(k).Contour(i).Points (j).y + t ^ 2 * (GlyphArray(k).Contour(i).Points(j + 1).y) ^ 2 GpArray(m).OnOff = True ' Alle Punkte liegen jettz auf der Contour Next m 'Neue Punkte GpArray einfgen (Dim nicht vergessen) 'PunkteDim = GlyphArray(k).Contour(i).Points(j) 'ReDim Preserve PunkteDim(UBound(PunkteDim) + n - 1) PointCount = PointCount + n - 1 For l = PointCount - 1 To j Step -1 GlyphArray(k).Contour(i).Points(l) = GlyphArray (k).Contour(i).Points(l + n) Next l ' Punkte mssen einzeln gespeichert werden 'GlyphArray(k).Contour(i).Points(j) = GpArray 'neuen Punkt einfgen Else End If Next j Next i Next k End Function

Public Function TTFRead(File As String) Dim i As Integer Dim b() As Byte ReDim b(1) ' Datei im Binrmodus ffnen

Open File For Binary Access Read As #3 ' Datei ffnen. i = 1 ' Hauptschleife Do While Not EOF(3) ' Schleife bis Dateiende. Get #3, , b(i) ReDim Preserve b(i + 1) i = i + 1 Loop ' Datei schlieen Close #3 End Function Public Function HpglRead(File As String) Dim NumberOfLines, pu, pd, komma1, semikolon1, komma2, semikolon2 As Integer j = 0 ' Gibt Anzahl der gelesenen Linien an ReDim Linien(1) Open File For Input As #1 ' Datei ffnen. ' Hauptschleife Do While Not EOF(1) ' Schleife bis Dateiende. Line Input #1, Text ' Zeile in Variable einlesen. pu = InStr(Text, "PU") pd = InStr(Text, "PD") komma1 = InStr(Text, ",") semikolon1 = InStr(Text, ";") komma2 = InStr(komma1 + 1, Text, ",") semikolon2 = InStr(semikolon1 + 1, Text, ";") ' Linie-Datenstruktur beschreiben Linien(j).xa = CDbl(Mid(Text, pu + 2, komma1 - pu - 2)) Linien(j).ya = CDbl(Mid(Text, komma1 + 1, semikolon1 - komma1 - 1)) Linien(j).za = 0 Linien(j).xe = CDbl(Mid(Text, pd + 2, komma2 - pd - 2)) Linien(j).ye = CDbl(Mid(Text, komma2 + 1, semikolon2 - komma2 - 1)) Linien(j).ze = 0 j = j + 1 ReDim Preserve Linien(UBound(Linien) + 1) Loop ' Ende Hauptschleife (Dateiende) Close #1 ' Datei schlieen End Function Public Function Optimierung() ' Wegoptimierung mit j: Anzahl der Linien ' formt falls mglich aus Einzel-Linien geschlossene oder offene Cuts, die in List gelistet werden Dim i, k, l, m, StartIndex, EndIndex As Integer ' Enthlt Start -u. Endindex der Cut-Objekte ReDim List(0)

m = 0 Form1.MousePointer = ccHourglass If j > 0 Then List(0).StartIndex = 0 For i = 0 To j - 1 x_Start = Linien(List(m).StartIndex).xa: y_Start = Linien(List (m).StartIndex).ya X_end = Linien(i).xe: Y_end = Linien(i).ye For k = i + 1 To j X_start_next = Linien(k).xa: Y_start_next = Linien(k).ya X_end_next = Linien(k).xe: Y_end_next = Linien(k).ye ' 4 Verbindungsflle unterscheiden: ' 1. Endpunkt mit Anfangspunkt der nchsten Linie verbunden If X_end = X_start_next And Y_end = Y_start_next Then ' Linien i+1 und k austauschen Save = Linien(k) Linien(k) = Linien(i + 1) Linien(i + 1) = Save EndIndex = k Exit For ' 2. Endpunkt mit nchsten Endpunkt verbunden (Start- u. Endpunkt (next) vertauschen) ElseIf X_end = X_end_next And Y_end = Y_end_next Then ' Linien austauschen Save = Linien(k) Linien(k) = Linien(i + 1) Linien(i + 1) = Save ' Anfangs- u. Endpunkt austauschen Linien(i + 1).xa = Save.xe Linien(i + 1).ya = Save.ye Linien(i + 1).za = Save.ze Linien(i + 1).xe = Save.xa Linien(i + 1).ye = Save.ya Linien(i + 1).ze = Save.za EndIndex = k Exit For ' 3. Anfangspunkt mit Endpunkt der nchsten Linie verbunden ElseIf x_Start = X_end_next And y_Start = Y_end_next Then ' Linie am Anfang der Liste(m) einfgen Save = Linien(k) For l = k - 1 To List(m).StartIndex Step -1 Linien(l + 1) = Linien(l) Next l Linien(List(m).StartIndex) = Save EndIndex = k Exit For ' 4. Anfangspunkt mit Anfangspunkt der nchsten Linie verbunden ElseIf x_Start = X_start_next And y_Start = Y_start_next Then

End If Next k If k > j Then List(m).EndIndex = i ReDim Preserve List(UBound(List) + 1) List(m + 1).StartIndex = i + 1 m = m + 1 End If Next i End If ' letztes Element lschen ReDim Preserve List(UBound(List) - 1) ' Linien in List einfgen For k = 0 To UBound(List) ReDim List(k).Lines(Abs(List(k).EndIndex - List(k).StartIndex)) kkk = 0 For kk = List(k).StartIndex To List(k).EndIndex List(k).Lines(kkk) = Linien(kk) kkk = kkk + 1 Next kk Next k Form1.MousePointer = ccDefault End Function Public Function Random() ' Linien vertauschen per Zufall For i = 1 To Int(UBound(Linien())) Index1 = Int(UBound(Linien()) * Rnd) Index2 = Int(UBound(Linien()) * Rnd) Save = Linien(Index1) Linien(Index1) = Linien(Index2) Linien(Index2) = Save Next i End Function Public Function BoundingBox() ' bestimmt die geometrischen Grenzen der gelisteten Objekte For i = 0 To Int(UBound(List())) For k = 0 To UBound(List(i).Lines) ' Startwert setzen If k = 0 Then xmin = List(i).Lines(k).xa: xmax = List(i).Lines(k).xa: ymax = List(i).Lines(k).ya: ymin = List(i).Lines(k).ye End If If xmin > List(i).Lines(k).xa Then xmin = List(i).Lines(k).xa End If If xmin > List(i).Lines(k).xe Then xmin = List(i).Lines(k).xe

End If If xmax < List(i).Lines(k).xa Then xmax = List(i).Lines(k).xa End If If xmax < List(i).Lines(k).xe Then xmax = List(i).Lines(k).xe End If If ymin > List(i).Lines(k).ya Then ymin = List(i).Lines(k).ya End If If ymin > List(i).Lines(k).ye Then ymin = List(i).Lines(k).ye End If If ymax < List(i).Lines(k).ya Then ymax = List(i).Lines(k).ya End If If ymax < List(i).Lines(k).ye Then ymax = List(i).Lines(k).ye End If Next k List(i).xmax = xmax List(i).xmin = xmin List(i).ymax = ymax List(i).ymin = ymin Next i ' Grenzen (BoundingBox) einzeichnen Form1.Picture1.ForeColor = vbWhite For i = 0 To Int(UBound(List())) Form1.Picture1.Line (List(i).xmax, List(i).ymax)-(List(i).xmax, (i).ymin) Form1.Picture1.Line (List(i).xmin, List(i).ymin)-(List(i).xmax, (i).ymin) Form1.Picture1.Line (List(i).xmin, List(i).ymin)-(List(i).xmin, (i).ymax) Form1.Picture1.Line (List(i).xmin, List(i).ymax)-(List(i).xmax, (i).ymax) Next i Form1.Picture1.ForeColor = vbBlue End Function

List List List List

Public Function Inside() ' Prft ob sich ein Objekt innerhalb der BoundingBox eines anderen Objektes befindet Form1.MousePointer = ccHourglass For i = 0 To Int(UBound(List())) ReDim List(i).Child(0) Next i For i = 0 To Int(UBound(List()))

For k = 0 To Int(UBound(List())) If (List(i).xmax < List(k).xmax) And (List(i).xmin > List(k).xmin) And (List(i).ymax < List(k).ymax) And (List(i).ymin > List(k).ymin) Then ' Child-Objekt liegt innerhalb des Parent-Objektes List(i).Parent = k List(i).Inside = True List(k).Child(UBound(List(k).Child())) = i ReDim Preserve List(k).Child(UBound(List(k).Child()) + 1) End If Next k Next i Form1.MousePointer = ccDefault End Function Public Function ShortestPath(x_Start As Single, y_Start As Single) ' Bestimmt den nahezu krzesten und optimalen Weg bzgl. des Startpunktes ' innere Objekte werden immer zuerst geschnitten, d.h. angefahren Dim Distance() As Single Dim ParentIndex() As Integer Dim SaveInt As Integer ReDim ParentIndex(0) ReDim ShortestPathIndex(0) ReDim Distance(UBound(List())) Dim m As Integer m = 0 ' Haupt-Objekte bestimmen, d.h. inside=false ' deren Kinder werden zuerst geschnitten und dann der Parent zuletzt ' Array ParentIndex zeigt auf Parents in Liste List For k = 0 To Int(UBound(List())) If List(k).Inside = False Then ParentIndex(UBound(ParentIndex)) = k ReDim Preserve ParentIndex(UBound(ParentIndex) + 1) End If Next k ReDim Preserve ParentIndex(UBound(ParentIndex) - 1) x_Next = x_Start: y_Next = y_Start For k = 0 To Int(UBound(ParentIndex())) ' Bestimme Objektzentren der Eltern und Distanz minDistance = 100000 For i = k To Int(UBound(ParentIndex())) Distance(i) = Sqr(((List(ParentIndex(i)).xmax + List(ParentIndex (i)).xmin) / 2 - x_Next) ^ 2 + ((List(ParentIndex(i)).ymax + List (ParentIndex(i)).ymin) / 2 - y_Next) ^ 2) If Distance(i) < minDistance Then If Not (Distance(i) = 0) Then minDistance = Distance(i) ' nhestes Objekt hat Index minIndex

minindex = ParentIndex(i) ' nhester Wert nach vorne kopieren -> Parentindex enthlt Schnittreihenfolge SaveInt = ParentIndex(i) ParentIndex(i) = ParentIndex(k) ParentIndex(k) = SaveInt End If End If Next i x_Next = (List(ParentIndex(k)).xmax + List(ParentIndex(k)).xmin) / 2 y_Next = (List(ParentIndex(k)).ymax + List(ParentIndex(k)).ymin) / 2 Next k ' ParentIndex enthlt jetzt die Zeiger auf die Listelemente fr den krzesten Weg ' Krzesten Weg der Kinder berechnen For k = 0 To Int(UBound(ParentIndex())) ' Kinder vorhanden, falls nur ein oder kein Kind keine Sortierung notwendig -> >1 If UBound(List(ParentIndex(k)).Child) > 1 Then ' Endpunkt des vorherigen Parents bestimmen (zur Distanzberechnung) If k <> 0 Then x_Next = Linien(List(ParentIndex(k - 1)).EndIndex).xe y_Next = Linien(List(ParentIndex(k - 1)).EndIndex).ye Else x_Next = x_Start y_Next = y_Start End If For m = 0 To Int(UBound(List(ParentIndex(k)).Child)) - 1 minDistance = 100000 For i = m To Int(UBound(List(ParentIndex(k)).Child)) - 1 Pointer = List(ParentIndex(k)).Child(i) Distance(i) = Sqr(((List(Pointer).xmax + List(Pointer).xmin) / 2 - x_Next) ^ 2 + ((List(Pointer).ymax + List(Pointer).ymin) / 2 - y_Next) ^ 2) If Distance(i) < minDistance Then If Not (Distance(i) = 0) Then minDistance = Distance(i) ' nhester Wert nach vorne kopieren -> Parentindex enth lt Schnittreihenfolge SaveInt = List(ParentIndex(k)).Child(i) List(ParentIndex(k)).Child(i) = List(ParentIndex (k)).Child(m) List(ParentIndex(k)).Child(m) = SaveInt End If Else End If Next i x_Next = (List(List(ParentIndex(k)).Child(m)).xmax + List(List

(ParentIndex(k)).Child(m)).xmin) / 2 y_Next = (List(List(ParentIndex(k)).Child(m)).ymax + List(List (ParentIndex(k)).Child(m)).ymin) / 2 Next m End If Next k ' ParentIndex wird jetzt um die jeweiligen Kinder zum ShortestPathIndex erweitert For k = 0 To Int(UBound(ParentIndex())) If UBound(List(ParentIndex(k)).Child) > 0 Then ' Kinder vorhanden For l = 0 To UBound(List(ParentIndex(k)).Child) - 1 ShortestPathIndex(UBound(ShortestPathIndex)) = List(ParentIndex (k)).Child(l) ReDim Preserve ShortestPathIndex(UBound(ShortestPathIndex) + 1) Next l ShortestPathIndex(UBound(ShortestPathIndex)) = ParentIndex(k) ReDim Preserve ShortestPathIndex(UBound(ShortestPathIndex) + 1) Else ' keine Kinder ShortestPathIndex(UBound(ShortestPathIndex)) = ParentIndex(k) ReDim Preserve ShortestPathIndex(UBound(ShortestPathIndex) + 1) End If Next k ' letztes unntiges Element lschen; Dimension von SWIndex mu jetzt gleich der Dim. der List sein ReDim Preserve ShortestPathIndex(UBound(ShortestPathIndex) - 1) ' Shortest Path einzeichnen (gelb) Form1.Picture1.ForeColor = vbYellow ' Startpunkt x_Next = x_Start: y_Next = y_Start Form1.Picture1.CurrentX = x_Next Form1.Picture1.CurrentY = y_Next For k = 0 To Int(UBound(ShortestPathIndex())) x_Next = (List(ShortestPathIndex(k)).xmax + List(ShortestPathIndex (k)).xmin) / 2 y_Next = (List(ShortestPathIndex(k)).ymax + List(ShortestPathIndex (k)).ymin) / 2 Form1.Picture1.Line -(x_Next, y_Next) Next k Form1.Picture1.ForeColor = vbBlue End Function Public Function Simulation() ' Simulation des 'krzesten' Schneidweges (wird durch Array ShortestPathIndex festgelegt) Form1.MousePointer = ccHourglass

Form1.Picture1.Cls Form1.Picture1.ForeColor = vbRed For k = 0 To Int(UBound(ShortestPathIndex())) ' Zeiger auf Start- u. Endlinie im LinienArray auslesen For i = 0 To UBound(List(ShortestPathIndex(k)).Lines) For l = 0 To 5000 'Delay Next l Form1.Picture1.Line (List(ShortestPathIndex(k)).Lines(i).xa, List (ShortestPathIndex(k)).Lines(i).ya)-(List(ShortestPathIndex(k)).Lines (i).xe, List(ShortestPathIndex(k)).Lines(i).ye) Form1.Picture1.Refresh Next i Next k Form1.Picture1.ForeColor = vbBlue Form1.MousePointer = ccDefault End Function Public Function ObjectSelect(x As Single, y As Single) ' Prft ob Maus sich innerhalb eines Objektes befindet ' Voraussetzung -> BoundingBox schon berechnet! Form1.MousePointer = ccHourglass ReDim ObjectSelectIndex(0) For k = 0 To Int(UBound(List())) If (x < List(k).xmax) And (x > List(k).xmin) And (y < List(k).ymax) And (y > List(k).ymin) Then 'Objekt gefunden und zugehrigen Index in Select-Liste eintragen ObjectSelectIndex(UBound(ObjectSelectIndex())) = k ReDim Preserve ObjectSelectIndex(UBound(ObjectSelectIndex) + 1) End If Next k ReDim Preserve ObjectSelectIndex(UBound(ObjectSelectIndex) - 1) Form1.MousePointer = ccDefault End Function Public Function CutObject() ' Schneidet ausgewhltes Objekt aus ' Auswahl steht in ObjectSelectIndex PortAddress = &H378 ' Plasma gleich siebte Steuerleitung -> 64 -> dieses Bit deaktivieren mit inv. Maske PlasmaOff = 255 - 64 'Inverse And-Maske PlasmaOn = 64 'Or-Maske PlasmaDelay = 10 ' Skalierung 0.271mm pro Schritt, da Koordinaten in 1/10mm angegeben scale_factor = 0.271 Form1.MousePointer = ccHourglass ' CutIndex enthlt zu schneidendes Objekt

For k = 0 To Int(UBound(ObjectSelectIndex())) If List(ObjectSelectIndex(k)).Inside Then CutIndex = ObjectSelectIndex(k) Exit For Else CutIndex = ObjectSelectIndex(0) End If Next k ' Objekt mit CutIndex schneiden Form1.Picture1.ForeColor = &HFF ' Schnittgeschwindigkeit lesen v = CInt(Form1.Text1.Text) ' Plasma ausschalten und zum Startpunkt fahren PortValue = Inp(PortAddress) Out PortAddress, PortValue And PlasmaOff Plasma = False Call Go_to(CInt(List(CutIndex).Lines(0).xa * scale_factor), CInt(List (CutIndex).Lines(0).ya * scale_factor), (v)) ' Plasma einschalten PortValue = Inp(PortAddress) Out PortAddress, PortValue Or PlasmaOn Plasma = True 'Plasmaeinstich-verzgerung For k = 0 To 10000 For kk = 0 To PlasmaDelay Next kk Next k For k = 0 To UBound(List(CutIndex).Lines) ' hier Schritte an LPT ausgeben -> mit Go_to und Schritt Call Go_to(CInt(List(CutIndex).Lines(k).xe * scale_factor), CInt(List (CutIndex).Lines(k).ye * scale_factor), (v)) ' geschnittenes Objekt zeichnen Form1.Picture1.Line (List(CutIndex).Lines(k).xa, List(CutIndex).Lines (k).ya)-(List(CutIndex).Lines(k).xe, List(CutIndex).Lines(k).ye) ' Position angeben Form1.Text4(0).Text = xpos / scale_factor / 10 Form1.Text4(1).Text = ypos / scale_factor / 10 Form1.Refresh Next k ' Plasma ausschalten PortValue = Inp(PortAddress) Out PortAddress, PortValue And PlasmaOff Plasma = False Form1.Picture1.ForeColor = &HFF0000

Form1.MousePointer = ccDefault End Function Public Function MoveObject(dx As Single, dy As Single) ' selektiertes Objekt bewegen um dx und dy Form1.MousePointer = ccHourglass ' MoveIndex enthlt zu schneidendes Objekt For k = 0 To Int(UBound(ObjectSelectIndex())) If List(ObjectSelectIndex(k)).Inside Then MoveIndex = ObjectSelectIndex(k) Exit For Else MoveIndex = ObjectSelectIndex(0) End If Next k ' zu bewegende Linien bestimmen For k = 0 To UBound(List(MoveIndex).Lines) ' Koordinaten bestimmen und Linien-Start-u.Endpunkte anpassen List(MoveIndex).Lines(k).xa = List(MoveIndex).Lines(k).xa - dx List(MoveIndex).Lines(k).xe = List(MoveIndex).Lines(k).xe - dx List(MoveIndex).Lines(k).ya = List(MoveIndex).Lines(k).ya - dy List(MoveIndex).Lines(k).ye = List(MoveIndex).Lines(k).ye - dy Next k ' altes Objekt (Grafik) lschen und neuzeichen an neuer Stelle Call BoundingBox Call Inside Call ShortestPath(0, 0) Call AutoZoom Form1.MousePointer = ccDefault End Function Public Function DeleteObject() ' selektiertes Objekt bewegen um dx und dy Form1.MousePointer = ccHourglass ' DeleteIndex enthlt zu lschendes Objekt For k = 0 To Int(UBound(ObjectSelectIndex())) If List(ObjectSelectIndex(k)).Inside Then DeleteIndex = ObjectSelectIndex(k) Exit For Else DeleteIndex = ObjectSelectIndex(0) End If Next k ' List aktualisieren (zu lschendes mit dem letzten Element berschreiben) und eventl Linien lschen lastList = UBound(List) List(DeleteIndex) = List(lastList)

ReDim Preserve List(UBound(List) - 1) ' noch Linien lschen Call BoundingBox Call Inside Call ShortestPath(0, 0) Call AutoZoom Form1.MousePointer = ccDefault End Function Public Function CopyObject(dx As Single, dy As Single) ' selektiertes Objekt kopieren um dx und dy Form1.MousePointer = ccHourglass ' MoveIndex enthlt zu schneidendes Objekt For k = 0 To Int(UBound(ObjectSelectIndex())) If List(ObjectSelectIndex(k)).Inside Then CopyIndex = ObjectSelectIndex(k) Exit For Else CopyIndex = ObjectSelectIndex(0) End If Next k ' Liste erweitern um 1 ReDim Preserve List(UBound(List) + 1) LastIndex = UBound(List) List(LastIndex) = List(CopyIndex) For k = 0 To UBound(List(LastIndex).Lines) ' Koordinaten bestimmen und Linien-Start-u.Endpunkte anpassen List(LastIndex).Lines(k).xa = List(LastIndex).Lines(k).xa - dx List(LastIndex).Lines(k).xe = List(LastIndex).Lines(k).xe - dx List(LastIndex).Lines(k).ya = List(LastIndex).Lines(k).ya - dy List(LastIndex).Lines(k).ye = List(LastIndex).Lines(k).ye - dy Next k ' altes Objekt (Grafik) lschen und neuzeichen an neuer Stelle Call BoundingBox Call Inside Call ShortestPath(0, 0) Call AutoZoom Form1.MousePointer = ccDefault End Function Public Function RotateObject(xb As Single, yb As Single, xc As Single, yc As Single) ' selektiertes Objekt um das Objektzentrum um Winkel alpha des Dreieckes ABC drehen Form1.MousePointer = ccHourglass ' RotateIndex enthlt zu schneidendes Objekt

For k = 0 To Int(UBound(ObjectSelectIndex())) If List(ObjectSelectIndex(k)).Inside Then RotateIndex = ObjectSelectIndex(k) Exit For Else RotateIndex = ObjectSelectIndex(0) End If Next k ' Rotationswinkel Rw [rad] berechnen ' Punkt A bzw 0 des Dreieckes x0 = (List(RotateIndex).xmax + List(RotateIndex).xmin) / 2 y0 = (List(RotateIndex).ymax + List(RotateIndex).ymin) / 2 Rw = Atn((yc - y0) / (xc - x0)) - Atn((yb - y0) / (xb - x0)) ' Punkte um A mit Rotationswinkel drehen For k = 0 To UBound(List(RotateIndex).Lines) xa = List(RotateIndex).Lines(k).xa - x0 xe = List(RotateIndex).Lines(k).xe - x0 ya = List(RotateIndex).Lines(k).ya - y0 ye = List(RotateIndex).Lines(k).ye - y0 ' Koordinaten bestimmen und Linien-Start-u.Endpunkte anpassen List(RotateIndex).Lines(k).xa = Cos(Rw) * xa - Sin(Rw) * ya + List(RotateIndex).Lines(k).xe = Cos(Rw) * xe - Sin(Rw) * ye + List(RotateIndex).Lines(k).ya = Sin(Rw) * xa + Cos(Rw) * ya + List(RotateIndex).Lines(k).ye = Sin(Rw) * xe + Cos(Rw) * ye + Next k ' altes Objekt (Grafik) lschen und neuzeichen an neuer Stelle Call BoundingBox Call Inside Call ShortestPath(0, 0) Call AutoZoom Form1.MousePointer = ccDefault End Function Public Function ScaleObject(xb As Single, yb As Single, xc As Single, yc As Single) ' selektiertes Objekt um das Objektzentrum skalieren (strecken bzw. stauchen) Form1.MousePointer = ccHourglass ' SclaeIndex enthlt zu schneidendes Objekt For k = 0 To Int(UBound(ObjectSelectIndex())) If List(ObjectSelectIndex(k)).Inside Then ScaleIndex = ObjectSelectIndex(k) Exit For Else ScaleIndex = ObjectSelectIndex(0) End If Next k

x0 x0 y0 y0

' Skalierung berechnen ' Punkt A bzw 0 des Dreieckes x0 = (List(ScaleIndex).xmax + List(ScaleIndex).xmin) / 2 y0 = (List(ScaleIndex).ymax + List(ScaleIndex).ymin) / 2 Sc = Sqr((yc - y0) ^ 2 + (xc - x0) ^ 2) / Sqr((yb - y0) ^ 2 + (xb - x0) ^ 2) ' Punkte um A skalieren For k = 0 To UBound(List(ScaleIndex).Lines) xa = List(ScaleIndex).Lines(k).xa - x0 xe = List(ScaleIndex).Lines(k).xe - x0 ya = List(ScaleIndex).Lines(k).ya - y0 ye = List(ScaleIndex).Lines(k).ye - y0 ' Koordinaten bestimmen und Linien-Start-u.Endpunkte anpassen List(ScaleIndex).Lines(k).xa = xa * Sc + x0 List(ScaleIndex).Lines(k).xe = xe * Sc + x0 List(ScaleIndex).Lines(k).ya = ya * Sc + y0 List(ScaleIndex).Lines(k).ye = ye * Sc + y0 Next k ' altes Objekt (Grafik) lschen und neuzeichen an neuer Stelle Call BoundingBox Call Inside Call ShortestPath(0, 0) Call AutoZoom Form1.MousePointer = ccDefault End Function

' !!!!! Oberer dieser Funktion mu noch angepat werden (MaxMin-Suche) Public Function AutoZoom() ' Finde x u. y Maximal/Minimalwerte und zeige File im Picture an (Skalierung) xmax = List(0).Lines(0).xa xmin = List(0).Lines(0).xa ymax = List(0).Lines(0).ya ymin = List(0).Lines(0).ya If j > 0 Then For ii = 0 To UBound(List) For i = 0 To UBound(List(ii).Lines) If List(ii).Lines(i).xa > xmax Then xmax = List(ii).Lines(i).xa If List(ii).Lines(i).xe > xmax Then xmax = List(ii).Lines(i).xe If List(ii).Lines(i).xa < xmin Then xmin = List(ii).Lines(i).xa If List(ii).Lines(i).xe < xmin Then xmin = List(ii).Lines(i).xe If List(ii).Lines(i).ya > ymax Then ymax = List(ii).Lines(i).ya If List(ii).Lines(i).ye > ymax Then ymax = List(ii).Lines(i).ye If List(ii).Lines(i).ya < ymin Then ymin = List(ii).Lines(i).ya If List(ii).Lines(i).ye < ymin Then ymin = List(ii).Lines(i).ye Next i Next ii

Form1.Text4(2).Text = xmax / 10 ' da sonst in 1/10mm angegeben Form1.Text4(3).Text = xmin / 10 Form1.Text4(4).Text = ymax / 10 Form1.Text4(5).Text = ymin / 10 Form1.Picture1.Cls If (xmax - xmin) > 2 * (ymax - ymin) Then Form1.Picture1.ScaleWidth = xmax - xmin Form1.Picture1.ScaleHeight = -(xmax - xmin) / 2 Else Form1.Picture1.ScaleHeight = -(ymax - ymin) Form1.Picture1.ScaleWidth = (ymax - ymin) * 2 End If Form1.Picture1.ScaleTop = ymax Form1.Picture1.ScaleLeft = xmin Form1.Text5(0).Text = Form1.Picture1.ScaleTop / 10 Form1.Text5(1).Text = (Form1.Picture1.ScaleTop + Form1.Picture1.ScaleHeight) / 10 Form1.Text5(2).Text = Form1.Picture1.ScaleLeft / 10 Form1.Text5(3).Text = (Form1.Picture1.ScaleLeft + Form1.Picture1.ScaleWidth) / 10 ' zeichnet nur Linien, die mittels List adressiert werden For ii = 0 To UBound(List) For i = 0 To UBound(List(ii).Lines) Form1.Picture1.Line (List(ii).Lines(i).xa, List(ii).Lines (i).ya)-(List(ii).Lines(i).xe, List(ii).Lines(i).ye) Next i Next ii End If End Function Public Function List2LineArray() ' wandelt die Listobjekte in einen Linienarray, der wiederrum in eine PLT o DXF-Datei gewandelt werden kann (siehe speichern) ReDim Linien(0) k = 0 For ii = 0 To UBound(List) For i = 0 To UBound(List(ii).Lines) Linien(k) = List(ii).Lines(i) k = k + 1 ReDim Preserve Linien(UBound(Linien) + 1) Next i Next ii ReDim Preserve Linien(UBound(Linien) - 1) End Function

Vous aimerez peut-être aussi