Farliam

Point Cloud

Oct 5th, 2020 (edited)
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 44.50 KB | None | 0 0
  1. 'Klasse zum erstellen von einer PointCloud
  2.  
  3. Option Strict On
  4. Option Explicit On
  5.  
  6. Imports System.IO
  7. Imports System.Numerics
  8. Imports System.Runtime.InteropServices
  9. Imports System.Runtime.Serialization.Formatters.Binary
  10.  
  11. Namespace Quaternion2DPlane
  12.     <Serializable()>
  13.     Public Class KomplexPlane
  14.  
  15. #Region "TopVariabel"
  16.         ''' <summary>
  17.         ''' Gibt die Formate zum bearbeiten der Ebne an
  18.         ''' </summary>
  19.         Public Enum PushFlag
  20.             ''' <summary>
  21.             ''' Zieht den Bereich Kugelförmig mit Angabe eines Radius in die Ebne ein. Überschneidende Bereiche werden mitberechnet.
  22.             ''' </summary>
  23.             PushRoundUp = 0
  24.             ''' <summary>
  25.             ''' Drück den Bereich Kugelförmig mit Angabe eines Radius in die Ebne ein. Überschneidende Bereiche werden mitberechnet.
  26.             ''' </summary>
  27.             PushRoundDown = 1
  28.             ''' <summary>
  29.             ''' Zieht den Bereich Kegelförmig mit Angabe eines Radius in die Ebne ein. Überschneidende Bereiche werden mitberechnet.
  30.             ''' </summary>
  31.             PushLinearUp = 2
  32.             ''' <summary>
  33.             ''' Drückt den Bereich Kegelförmig mit Angabe eines Radius in die Ebne ein. Überschneidende Bereiche werden mitberechnet.
  34.             ''' </summary>
  35.             PushLinearDown = 3
  36.         End Enum
  37.         ''' <summary>
  38.         ''' Gibt das zu verwendende Format an
  39.         ''' </summary>
  40.         Public Enum MeshExportFormat
  41.             ''' <summary>
  42.             ''' Einfache Positionsdaten
  43.             ''' </summary>
  44.             X_Y_Z = 0
  45.             ''' <summary>
  46.             '''Positionsdaten gefolgt vom Reflexionsgrad
  47.             ''' </summary>
  48.             X_Y_Z_Reflectance = 1
  49.             ''' <summary>
  50.             ''' Positionsdaten gefolgt von RGB Werten
  51.             ''' </summary>
  52.             X_Y_Z_R_G_B = 2
  53.             ''' <summary>
  54.             ''' Positionsdaten gefolgt von RGB Werten und dem Reflexionsgrad
  55.             ''' </summary>
  56.             X_Y_Z_R_G_B_Reflectance = 3
  57.             ''' <summary>
  58.             ''' Definiert eine Vertex Position
  59.             ''' </summary>
  60.             X_Y_Z_NX_NY_NZ = 4
  61.         End Enum
  62.         ''' <summary>
  63.         ''' Definiert die Eigentschaften zum ersten Erstellen/Füllen der Komplexen Ebne
  64.         ''' </summary>
  65.         Public Enum CreateFlag
  66.             ''' <summary>
  67.             ''' <code>Entspricht keiner Auswahl. Die Standartgenerierung wird stadessen verwendet.</code>
  68.             ''' </summary>
  69.             None = -1
  70.             ''' <summary>
  71.             ''' Die X und Y Ebene wird gleichmäßig zwischen den gespeicherten Min und Max Werten aufgeteilt. Z Werte erhalten den Standart Wert.
  72.             '''</summary>
  73.             XY_Between_Default = 0
  74.             ''' <summary>
  75.             ''' Die X,Y und Z Ebne wird auf die gespeicherten Werten gesetzt (Property SetFix_X,SetFix_Y und SetFix_Z
  76.             ''' </summary>
  77.             XYZ_Fixed = 1
  78.             ''' <summary>
  79.             ''' Die X und Y Ebne wird wie bei CreateFlag.0 erstellt. Die Z Ebene wird beginnend von der ersten Spalte Links
  80.             ''' in Richtung Rechts zwischen zmin zu zmax aufgeteilt und gefüllt.
  81.             ''' </summary>
  82.             XY_Between_Default_Z_1 = 2
  83.             ''' <summary>
  84.             ''' Die X und Y Ebne wird wie bei CreateFlag.0 erstellt. Die Z Ebene wird beginnend von der letzten Spalte rechts
  85.             ''' in Richtung Links zwischen zmin zu zmax aufgeteilt und gefüllt.
  86.             ''' </summary>
  87.             XY_Between_Default_Z_2 = 3
  88.             ''' <summary>
  89.             ''' Die X und Y Ebne wird wie bei CreateFlag.0 erstellt. Die Z Ebene wird beginnend von der ersten Zeile oben,
  90.             ''' in Richtung unten zwischen zmin und zmax aufgeteilt und gefüllt.
  91.             ''' </summary>
  92.             XY_Between_Default_Z_3 = 4
  93.             ''' <summary>
  94.             ''' Die X und Y Ebne wird wie bei CreateFlag.0 erstellt. Die Z Ebene wird beginnend von der letzten Zeile unten
  95.             ''' in Richtung oben zwischen zmin und zmax aufgeteilt und gefüllt.
  96.             ''' </summary>
  97.             XY_Between_Default_Z_4 = 5
  98.             ''' <summary>
  99.             ''' Die X und Y Ebne wird wie bei CreateFlag.0 erstellt.
  100.             ''' Die Z Ebne beschreibt eine Pyramidenartige Struktur welche bei zmin beginnt. Und zmax aufhört
  101.             ''' Der Mittelpunkt der Ebne entspricht am Ende dem zmax Wert.
  102.             ''' </summary>
  103.             XY_Between_Default_Z_Stair_To_Middle_Up = 6
  104.             ''' <summary>
  105.             ''' Die X und Y Ebne wird wie bei CreateFlag.0 erstellt.
  106.             ''' Die Z Ebne beschreibt eine Pyramidenartige Struktur welche bei zmax beginnt. Und zmin aufhört
  107.             ''' Der Mittelpunkt der Ebne entspricht am Ende dem zmin Wert.
  108.             ''' </summary>
  109.             XY_Between_Default_Z_Stair_To_Middle_Down = 7
  110.             ''' <summary>
  111.             ''' XY wird zwischen den min/max Werten aufgeteilt. Für den Faktor werden die Größenordnungen der Ebne verwendet.
  112.             '''Für Z wird der Faktor aus dem Mittelwert der Bild-Breite/Höhe errechnet. Anschließend wie bei XY aufgeteilt
  113.             ''' </summary>
  114.             Random_Between = 8
  115.         End Enum
  116.  
  117.         Private mParents As New List(Of ParentHolder)       'Private - Kein Zugriff durch Property z.Z.
  118.         Private mPlane(,) As Quaternion                     'Private - Kein Zugriff durch Property z.Z.
  119.         Private mBreite As Integer                          'Property ReadOnly
  120.         Private mHöhe As Integer                            'Property ReadOnly
  121.  
  122.         Private xmin_Default As Double = -2.0               'Property ReadOnly
  123.         Private xmax_Default As Double = 2.0                'Property ReadOnly
  124.         Private ymin_Default As Double = -1.0               'Property ReadOnly
  125.         Private ymax_Default As Double = 1.0                'Property ReadOnly
  126.         Private zmin_Default As Double = -2.0               'Property ReadOnly
  127.         Private zmax_Default As Double = 2.0                'Property ReadOnly
  128.  
  129.         Private Fix_X_Default As Double = 1.0               'Property
  130.         Private Fix_Y_Default As Double = 1.0               'Property
  131.         Private Fix_Z_Default As Double = 0.0               'Property
  132.  
  133.         Private MeshGutterSeperator As Char = CChar(";")    'Property
  134.         Private MeshBreite As Integer                       'Property
  135.         Private MeshHöhe As Integer                         'Property
  136.         Private MeshTiefe As Integer                        'Property
  137.         Private MeshReflectance As Integer = 50             'Property
  138.  
  139.         Private PushFaktor As Integer = 1                   'Property
  140.  
  141. #End Region
  142.  
  143. #Region "Property"
  144.         Public Property GetPushFaktor() As Integer
  145.             Get
  146.                 Return PushFaktor
  147.             End Get
  148.             Set(value As Integer)
  149.                 PushFaktor = value
  150.             End Set
  151.         End Property
  152.         Public Property GetMeshReflectance() As Integer
  153.             Get
  154.                 Return MeshReflectance
  155.             End Get
  156.             Set(value As Integer)
  157.                 MeshReflectance = value
  158.             End Set
  159.         End Property
  160.         Public Property GetMeshTiefe() As Integer
  161.             Get
  162.                 Return MeshTiefe
  163.             End Get
  164.             Set(value As Integer)
  165.                 MeshTiefe = value
  166.             End Set
  167.         End Property
  168.         Public Property GetMeshHöhe() As Integer
  169.             Get
  170.                 Return MeshHöhe
  171.             End Get
  172.             Set(value As Integer)
  173.                 MeshHöhe = value
  174.             End Set
  175.         End Property
  176.  
  177.         Public Property GetMeshBreite() As Integer
  178.             Get
  179.                 Return MeshBreite
  180.             End Get
  181.             Set(value As Integer)
  182.                 MeshBreite = value
  183.             End Set
  184.         End Property
  185.         Public Property GetMeshSeperator() As Char
  186.             Get
  187.                 Return MeshGutterSeperator
  188.             End Get
  189.             Set(value As Char)
  190.                 MeshGutterSeperator = value
  191.             End Set
  192.         End Property
  193.         Public Property GetFix_Z() As Double
  194.             Get
  195.                 Return Fix_Z_Default
  196.             End Get
  197.             Set(value As Double)
  198.                 Fix_Z_Default = value
  199.             End Set
  200.         End Property
  201.         Public Property GetFix_Y() As Double
  202.             Get
  203.                 Return Fix_Y_Default
  204.             End Get
  205.             Set(value As Double)
  206.                 Fix_Y_Default = value
  207.             End Set
  208.         End Property
  209.         Public Property GetFix_X() As Double
  210.             Get
  211.                 Return Fix_X_Default
  212.             End Get
  213.             Set(value As Double)
  214.                 Fix_X_Default = value
  215.             End Set
  216.         End Property
  217.         Public ReadOnly Property Get_zmaxDefault() As Double
  218.             Get
  219.                 Return zmax_Default
  220.             End Get
  221.         End Property
  222.         Public ReadOnly Property Get_zminDefault() As Double
  223.             Get
  224.                 Return zmin_Default
  225.             End Get
  226.         End Property
  227.         Public ReadOnly Property Get_ymaxDefault() As Double
  228.             Get
  229.                 Return ymax_Default
  230.             End Get
  231.         End Property
  232.         Public ReadOnly Property Get_yminDefault() As Double
  233.             Get
  234.                 Return ymin_Default
  235.             End Get
  236.         End Property
  237.         Public ReadOnly Property Get_xmaxDefault() As Double
  238.             Get
  239.                 Return xmax_Default
  240.             End Get
  241.         End Property
  242.  
  243.         Public ReadOnly Property Get_xminDefault() As Double
  244.             Get
  245.                 Return xmin_Default
  246.             End Get
  247.         End Property
  248.         Public ReadOnly Property GetBreite() As Integer
  249.             Get
  250.                 Return mBreite
  251.             End Get
  252.         End Property
  253.         Public ReadOnly Property GetHöhe() As Integer
  254.             Get
  255.                 Return mHöhe
  256.             End Get
  257.         End Property
  258. #End Region
  259.  
  260. #Region "New"
  261.         Public Sub New(ByVal Breite As Integer, ByVal Höhe As Integer)
  262.             mBreite = Breite
  263.             mHöhe = Höhe
  264.             MeshBreite = mBreite
  265.             MeshHöhe = mHöhe
  266.             MeshTiefe = CInt(Math.Sqrt(mBreite * mHöhe))
  267.             ReDim mPlane(mBreite, mHöhe)
  268.         End Sub
  269.  
  270.         Public Sub New(ByVal Breite As Integer, ByVal Höhe As Integer, ByVal CreFlag As CreateFlag)
  271.             mBreite = Breite
  272.             mHöhe = Höhe
  273.             ReDim mPlane(mBreite, mHöhe)
  274.             Select Case CreFlag
  275.                 Case CreateFlag.None
  276.                     Create_XYZ_Fixed()
  277.                 Case CreateFlag.Random_Between
  278.                     Create_Random_Between()
  279.                 Case CreateFlag.XYZ_Fixed
  280.                     Create_XYZ_Fixed()
  281.                 Case CreateFlag.XY_Between_Default
  282.                     Create_XY_Between_Default()
  283.                 Case CreateFlag.XY_Between_Default_Z_1
  284.                     Create_XY_Between_Default_Z_1()
  285.                 Case CreateFlag.XY_Between_Default_Z_2
  286.                     Create_XY_Between_Default_Z_2()
  287.                 Case CreateFlag.XY_Between_Default_Z_3
  288.                     Create_XY_Between_Default_Z_3()
  289.                 Case CreateFlag.XY_Between_Default_Z_4
  290.                     Create_XY_Between_Default_Z_4()
  291.                 Case CreateFlag.XY_Between_Default_Z_Stair_To_Middle_Down
  292.                     Create_XY_Between_Default_Z_Stair_To_Middle_Down()
  293.                 Case CreateFlag.XY_Between_Default_Z_Stair_To_Middle_Up
  294.                     Create_XY_Between_Default_Z_Stair_To_Middle_Up()
  295.                 Case Else
  296.                     Create_XYZ_Fixed()
  297.             End Select
  298.         End Sub
  299. #End Region
  300.  
  301. #Region "Private Hilfsfunktionen"
  302.         Private Function GetAbsolute(ByVal val1 As Double, ByVal val2 As Double) As Double
  303.             Dim result As Double
  304.             Dim big As Double = Math.Max(val1, val2)
  305.             Dim small As Double = Math.Min(val1, val2)
  306.  
  307.             If big > 0 And small > 0 Then
  308.                 result = big - small
  309.             ElseIf big > 0 And small < 0 Then
  310.                 result = Math.Abs(small) + big
  311.             Else
  312.                 result = Math.Abs(Math.Abs(big) - Math.Abs(small))
  313.             End If
  314.             Return result
  315.         End Function
  316.  
  317.         Private Function CreateRoundPoints(ByVal Durchmesser As Integer, ByVal startpoint As Point) As List(Of Point)
  318.             Dim points As New List(Of Point)
  319.             Dim xStart As Integer = startpoint.X - Durchmesser
  320.             Dim xEnd As Integer = startpoint.X + Durchmesser
  321.             Dim yStart As Integer = startpoint.Y - Durchmesser
  322.             Dim yEnd As Integer = startpoint.Y + Durchmesser
  323.  
  324.             For x As Integer = xStart To xEnd
  325.                 For y As Integer = yStart To yEnd
  326.                     Dim pkt As New Point(x, y)
  327.                     If x >= 0 And x <= mBreite And
  328.                             y >= 0 And y <= mHöhe Then
  329.                         If GetLinearPosDist(pkt, startpoint) <= Durchmesser Then points.Add(pkt)
  330.                     End If
  331.                 Next
  332.             Next
  333.             Return points
  334.         End Function
  335.         Private Function GetLinearPosDist(ByVal P1 As PointF, ByVal P2 As PointF) As Double
  336.             Return Math.Sqrt((Math.Pow((P2.X - P1.X), 2)) + Math.Pow((P2.Y - P1.Y), 2))
  337.         End Function
  338.  
  339.         Private Function ToRadians(ByVal deg As Double) As Double
  340.             Return Math.PI / 180 * deg
  341.         End Function
  342. #End Region
  343.  
  344. #Region "CreateEbne Sub"
  345.         Public Sub ReFreshEbne(ByVal Flag As CreateFlag)
  346.             Select Case Flag
  347.                 Case CreateFlag.None
  348.                     Create_XYZ_Fixed()
  349.                 Case CreateFlag.Random_Between
  350.                     Create_Random_Between()
  351.                 Case CreateFlag.XYZ_Fixed
  352.                     Create_XYZ_Fixed()
  353.                 Case CreateFlag.XY_Between_Default
  354.                     Create_XY_Between_Default()
  355.                 Case CreateFlag.XY_Between_Default_Z_1
  356.                     Create_XY_Between_Default_Z_1()
  357.                 Case CreateFlag.XY_Between_Default_Z_2
  358.                     Create_XY_Between_Default_Z_2()
  359.                 Case CreateFlag.XY_Between_Default_Z_3
  360.                     Create_XY_Between_Default_Z_3()
  361.                 Case CreateFlag.XY_Between_Default_Z_4
  362.                     Create_XY_Between_Default_Z_4()
  363.                 Case CreateFlag.XY_Between_Default_Z_Stair_To_Middle_Down
  364.                     Create_XY_Between_Default_Z_Stair_To_Middle_Down()
  365.                 Case CreateFlag.XY_Between_Default_Z_Stair_To_Middle_Up
  366.                     Create_XY_Between_Default_Z_Stair_To_Middle_Up()
  367.                 Case Else
  368.                     Create_XYZ_Fixed()
  369.             End Select
  370.         End Sub
  371.         Private Sub Create_XY_Between_Default()
  372.             Dim xStep As Double = GetAbsolute(xmin_Default, xmax_Default) / mBreite
  373.             Dim yStep As Double = GetAbsolute(ymin_Default, ymax_Default) / mHöhe
  374.             For x As Integer = 0 To mBreite
  375.                 For y As Integer = 0 To mHöhe
  376.                     mPlane(x, y) = New Quaternion(xmin_Default + (x * xStep), ymin_Default + (y * yStep), Fix_Z_Default, 0)
  377.                 Next
  378.             Next
  379.         End Sub
  380.  
  381.         Private Sub Create_XYZ_Fixed()
  382.             'Alle Werte werden auf die Standartparameter gesetzt
  383.             For x As Integer = 0 To mBreite
  384.                 For y As Integer = 0 To mHöhe
  385.                     mPlane(x, y) = New Quaternion(Fix_X_Default, Fix_Y_Default, Fix_Z_Default, 0)
  386.                 Next
  387.             Next
  388.         End Sub
  389.  
  390.         Private Sub Create_XY_Between_Default_Z_1()
  391.             ' Die X und Y Ebne wird wie bei CreateFlag.0 erstellt. Die Z Ebene wird beginnend von der ersten Spalte Links
  392.             ' in Richtung Rechts zwischen zmin zu zmax aufgeteilt und gefüllt.
  393.             Dim xStep As Double = GetAbsolute(xmin_Default, xmax_Default) / mBreite
  394.             Dim yStep As Double = GetAbsolute(ymin_Default, ymax_Default) / mHöhe
  395.             Dim zStep As Double = GetAbsolute(zmin_Default, zmax_Default) / mBreite
  396.             For x As Integer = 0 To mBreite
  397.                 For y As Integer = 0 To mHöhe
  398.                     mPlane(x, y) = New Quaternion(xmin_Default + (x * xStep), ymin_Default + (y * yStep), zmin_Default + (x * zStep), 0)
  399.                 Next
  400.             Next
  401.  
  402.         End Sub
  403.  
  404.         Private Sub Create_XY_Between_Default_Z_2()
  405.             ' Die X und Y Ebne wird wie bei CreateFlag.0 erstellt. Die Z Ebene wird beginnend von der letzten Spalte rechts
  406.             ' in Richtung Links zwischen zmin zu zmax aufgeteilt und gefüllt.
  407.             Dim xStep As Double = GetAbsolute(xmin_Default, xmax_Default) / mBreite
  408.             Dim yStep As Double = GetAbsolute(ymin_Default, ymax_Default) / mHöhe
  409.             Dim zStep As Double = GetAbsolute(zmin_Default, zmax_Default) / mBreite
  410.             For x As Integer = 0 To mBreite
  411.                 For y As Integer = 0 To mHöhe
  412.                     mPlane(x, y) = New Quaternion(xmin_Default + (x * xStep), ymin_Default + (y * yStep), zmax_Default - (x * zStep), 0)
  413.                 Next
  414.             Next
  415.  
  416.         End Sub
  417.  
  418.         Private Sub Create_XY_Between_Default_Z_3()
  419.             ' Die X und Y Ebne wird wie bei CreateFlag.0 erstellt. Die Z Ebene wird beginnend von der ersten Zeile oben,
  420.             ' in Richtung unten zwischen zmin und zmax aufgeteilt und gefüllt.
  421.             Dim xStep As Double = GetAbsolute(xmin_Default, xmax_Default) / mBreite
  422.             Dim yStep As Double = GetAbsolute(ymin_Default, ymax_Default) / mHöhe
  423.             Dim zStep As Double = GetAbsolute(zmin_Default, zmax_Default) / mBreite
  424.             For y As Integer = 0 To mHöhe
  425.                 For x As Integer = 0 To mBreite
  426.                     mPlane(x, y) = New Quaternion(xmin_Default + (x * xStep), ymin_Default + (y * yStep), zmin_Default + (x * zStep), 0)
  427.                 Next
  428.             Next
  429.         End Sub
  430.  
  431.         Private Sub Create_XY_Between_Default_Z_4()
  432.             'Die X und Y Ebne wird wie bei CreateFlag.0 erstellt. Die Z Ebene wird beginnend von der letzten Zeile unten
  433.             ' in Richtung oben zwischen zmin und zmax aufgeteilt und gefüllt.
  434.             Dim xStep As Double = GetAbsolute(xmin_Default, xmax_Default) / mBreite
  435.             Dim yStep As Double = GetAbsolute(ymin_Default, ymax_Default) / mHöhe
  436.             Dim zStep As Double = GetAbsolute(zmin_Default, zmax_Default) / mBreite
  437.             For y As Integer = 0 To mHöhe
  438.                 For x As Integer = 0 To mBreite
  439.                     mPlane(x, y) = New Quaternion(xmin_Default + (x * xStep), ymin_Default + (y * yStep), zmax_Default - (x * zStep), 0)
  440.                 Next
  441.             Next
  442.         End Sub
  443.  
  444.         Private Sub Create_XY_Between_Default_Z_Stair_To_Middle_Up()
  445.             'Die X und Y Ebne wird wie bei CreateFlag.0 erstellt.
  446.             'Die Z Ebne beschreibt eine Pyramidenartige Struktur welche bei zmin beginnt. Und zmax aufhört
  447.             'Der Mittelpunkt der Ebne entspricht am Ende dem zmax Wert.
  448.             Dim xStep As Double = GetAbsolute(xmin_Default, xmax_Default) / mBreite
  449.             Dim yStep As Double = GetAbsolute(ymin_Default, ymax_Default) / mHöhe
  450.             Dim zAbsolutDiagonal As Double = GetLinearPosDist(Point.Empty, New PointF(CSng(mBreite / 2), CSng(mHöhe / 2)))
  451.             Dim zStep As Double = GetAbsolute(zmin_Default, zmax_Default) / zAbsolutDiagonal
  452.             For y As Integer = 0 To mHöhe
  453.                 For x As Integer = 0 To mBreite
  454.                     Dim zWay As Double = zAbsolutDiagonal - GetLinearPosDist(New Point(x, y), New PointF(CSng(mBreite / 2), CSng(mHöhe / 2)))
  455.                     Dim zValue As Double = zmin_Default + (zStep * zWay)
  456.                     mPlane(x, y) = New Quaternion(xmin_Default + (x * xStep), ymin_Default + (y * yStep), zValue, 0)
  457.                 Next
  458.             Next
  459.         End Sub
  460.  
  461.         Private Sub Create_XY_Between_Default_Z_Stair_To_Middle_Down()
  462.             ' Die X und Y Ebne wird wie bei CreateFlag.0 erstellt.
  463.             'Die Z Ebne beschreibt eine Pyramidenartige Struktur welche bei zmax beginnt. Und zmin aufhört
  464.             ' Der Mittelpunkt der Ebne entspricht am Ende dem zmin Wert.
  465.             Dim xStep As Double = GetAbsolute(xmin_Default, xmax_Default) / mBreite
  466.             Dim yStep As Double = GetAbsolute(ymin_Default, ymax_Default) / mHöhe
  467.             Dim zAbsolutDiagonal As Double = GetLinearPosDist(Point.Empty, New PointF(CSng(mBreite / 2), CSng(mHöhe / 2)))
  468.             Dim zStep As Double = GetAbsolute(zmin_Default, zmax_Default) / zAbsolutDiagonal
  469.             For y As Integer = 0 To mHöhe
  470.                 For x As Integer = 0 To mBreite
  471.                     Dim zWay As Double = zAbsolutDiagonal - GetLinearPosDist(New Point(x, y), New PointF(CSng(mBreite / 2), CSng(mHöhe / 2)))
  472.                     Dim zValue As Double = zmax_Default - (zStep * zWay)
  473.                     mPlane(x, y) = New Quaternion(xmin_Default + (x * xStep), ymin_Default + (y * yStep), zValue, 0)
  474.                 Next
  475.             Next
  476.         End Sub
  477.  
  478.         Private Sub Create_Random_Between()
  479.             ' XY wird zwischen den min/max Werten aufgeteilt. Für den Faktor werden die Größenordnungen der Ebne verwendet.
  480.             'Für Z wird der Faktor aus dem Mittelwert der Bild-Breite/Höhe errechnet. Anschließend wie bei XY aufgeteilt
  481.             Dim xStep As Double = GetAbsolute(xmin_Default, xmax_Default) / mBreite
  482.             Dim yStep As Double = GetAbsolute(ymin_Default, ymax_Default) / mHöhe
  483.             Dim zMidRange As Integer = CInt(Math.Sqrt(mBreite * mHöhe)) 'Sowohl für Step als auch für rand zwischen 0 und <-
  484.             Dim zStep As Double = GetAbsolute(zmin_Default, zmax_Default) / zMidRange
  485.             Dim rnd As New System.Random(TimeOfDay.Second * TimeOfDay.Minute * TimeOfDay.Millisecond)
  486.             For x As Integer = 0 To mBreite
  487.                 For y As Integer = 0 To mHöhe
  488.                     Dim zValue As Double = zmin_Default + (rnd.Next(0, zMidRange) * zStep)
  489.                     mPlane(x, y) = New Quaternion(xmin_Default + (x * xStep), ymin_Default + (y * yStep), zValue, 0)
  490.                 Next
  491.             Next
  492.         End Sub
  493. #End Region
  494.  
  495. #Region "Export MeshFile"
  496.         Public Function ExportMesh(ByVal sPfad As String, ByVal Format As MeshExportFormat, ByVal Overwrite As Boolean) As Boolean
  497.             If Not Overwrite And My.Computer.FileSystem.FileExists(sPfad) Then Return False
  498.             If My.Computer.FileSystem.FileExists(sPfad) And Overwrite Then My.Computer.FileSystem.DeleteFile(sPfad)
  499.             Dim result As Boolean = False
  500.             Select Case Format
  501.                 Case MeshExportFormat.X_Y_Z
  502.                     result = ExportMesh_X_Y_Z(sPfad)
  503.                 Case MeshExportFormat.X_Y_Z_NX_NY_NZ
  504.                     result = ExportMesh_X_Y_Z_NX_NY_NZ(sPfad)
  505.                 Case MeshExportFormat.X_Y_Z_Reflectance
  506.                     result = ExportMesh_X_Y_Z_Reflectance(sPfad)
  507.                 Case MeshExportFormat.X_Y_Z_R_G_B
  508.                     result = ExportMesh_X_Y_Z_R_G_B(sPfad)
  509.                 Case MeshExportFormat.X_Y_Z_R_G_B_Reflectance
  510.                     result = ExportMesh_X_Y_Z_R_G_B_Reflectance(sPfad)
  511.             End Select
  512.             Return result
  513.         End Function
  514.  
  515.         Private Function ExportMesh_X_Y_Z(ByVal sPfad As String) As Boolean
  516.             Try
  517.                 Dim s As New Text.StringBuilder
  518.                 Dim xStep As Double = MeshBreite / GetAbsolute(xmin_Default, xmax_Default)
  519.                 Dim yStep As Double = MeshHöhe / GetAbsolute(ymin_Default, ymax_Default)
  520.                 Dim zStep As Double = MeshTiefe / GetAbsolute(zmin_Default, zmax_Default)
  521.                 Dim xVal, yVal, zVal As Double
  522.                 For x As Integer = 0 To mBreite
  523.                     For y As Integer = 0 To mHöhe
  524.                         With mPlane(x, y)
  525.                             xVal = .GetX * xStep
  526.                             yVal = .GetY * yStep
  527.                             zVal = .GetZ * zStep
  528.                         End With
  529.                         s.AppendLine(xVal.ToString & MeshGutterSeperator &
  530.                                      yVal.ToString & MeshGutterSeperator &
  531.                                      zVal.ToString)
  532.                     Next
  533.                     System.IO.File.AppendAllText(sPfad, s.Replace(",", ".").ToString)
  534.                     s.Clear()
  535.                 Next
  536.                 s.Clear()
  537.                 Return True
  538.             Catch ex As Exception
  539.                 Return False
  540.             End Try
  541.         End Function
  542.  
  543.         Private Function ExportMesh_X_Y_Z_Reflectance(ByVal sPfad As String) As Boolean
  544.             Try
  545.                 Dim s As New Text.StringBuilder
  546.                 Dim xStep As Double = MeshBreite / GetAbsolute(xmin_Default, xmax_Default)
  547.                 Dim yStep As Double = MeshHöhe / GetAbsolute(ymin_Default, ymax_Default)
  548.                 Dim zStep As Double = MeshTiefe / GetAbsolute(zmin_Default, zmax_Default)
  549.                 Dim xVal, yVal, zVal As Double
  550.                 For x As Integer = 0 To mBreite
  551.                     For y As Integer = 0 To mHöhe
  552.                         With mPlane(x, y)
  553.                             xVal = .GetX * xStep
  554.                             yVal = .GetY * yStep
  555.                             zVal = .GetZ * zStep
  556.                         End With
  557.                         s.AppendLine(xVal.ToString & MeshGutterSeperator &
  558.                                      yVal.ToString & MeshGutterSeperator &
  559.                                      zVal.ToString & MeshGutterSeperator &
  560.                                      MeshReflectance.ToString)
  561.                     Next
  562.                     System.IO.File.AppendAllText(sPfad, s.Replace(",", ".").ToString)
  563.                     s.Clear()
  564.                 Next
  565.                 s.Clear()
  566.                 Return True
  567.             Catch ex As Exception
  568.                 Return False
  569.             End Try
  570.         End Function
  571.  
  572.         Private Function ExportMesh_X_Y_Z_R_G_B(ByVal sPfad As String) As Boolean
  573.             Try
  574.                 Dim s As New Text.StringBuilder
  575.                 Dim xStep As Double = MeshBreite / GetAbsolute(xmin_Default, xmax_Default)
  576.                 Dim yStep As Double = MeshHöhe / GetAbsolute(ymin_Default, ymax_Default)
  577.                 Dim zStep As Double = MeshTiefe / GetAbsolute(zmin_Default, zmax_Default)
  578.                 Dim xVal, yVal, zVal As Double
  579.  
  580.                 Dim redStep As Double = 254 / GetLinearPosDist(Point.Empty, New Point(CInt(MeshTiefe / 2), CInt(MeshTiefe / 2)))
  581.                 Dim greenStep As Double = 254 / GetLinearPosDist(Point.Empty, New Point(CInt(MeshHöhe / 2), CInt(MeshHöhe / 2)))
  582.                 Dim blueStep As Double = 254 / GetLinearPosDist(Point.Empty, New Point(CInt(MeshBreite / 2), CInt(MeshBreite / 2)))
  583.  
  584.                 For x As Integer = 0 To mBreite
  585.                     For y As Integer = 0 To mHöhe
  586.                         With mPlane(x, y)
  587.                             xVal = .GetX * xStep
  588.                             yVal = .GetY * yStep
  589.                             zVal = .GetZ * zStep
  590.                         End With
  591.                         s.AppendLine(xVal.ToString & MeshGutterSeperator &
  592.                                      yVal.ToString & MeshGutterSeperator &
  593.                                      zVal.ToString & MeshGutterSeperator &
  594.                                      (redStep * Math.Abs(zVal)).ToString & MeshGutterSeperator &
  595.                                      (greenStep * Math.Abs(yVal)).ToString & MeshGutterSeperator &
  596.                                      (blueStep * Math.Abs(xVal)).ToString)
  597.                     Next
  598.                     System.IO.File.AppendAllText(sPfad, s.Replace(",", ".").ToString)
  599.                     s.Clear()
  600.                 Next
  601.                 s.Clear()
  602.                 Return True
  603.             Catch ex As Exception
  604.                 Return False
  605.             End Try
  606.         End Function
  607.  
  608.         Private Function ExportMesh_X_Y_Z_R_G_B_Reflectance(ByVal sPfad As String) As Boolean
  609.             Try
  610.                 Dim s As New Text.StringBuilder
  611.                 Dim xStep As Double = MeshBreite / GetAbsolute(xmin_Default, xmax_Default)
  612.                 Dim yStep As Double = MeshHöhe / GetAbsolute(ymin_Default, ymax_Default)
  613.                 Dim zStep As Double = MeshTiefe / GetAbsolute(zmin_Default, zmax_Default)
  614.                 Dim xVal, yVal, zVal As Double
  615.  
  616.                 Dim redStep As Double = 254 / GetLinearPosDist(Point.Empty, New Point(CInt(MeshTiefe / 2), CInt(MeshTiefe / 2)))
  617.                 Dim greenStep As Double = 254 / GetLinearPosDist(Point.Empty, New Point(CInt(MeshHöhe / 2), CInt(MeshHöhe / 2)))
  618.                 Dim blueStep As Double = 254 / GetLinearPosDist(Point.Empty, New Point(CInt(MeshBreite / 2), CInt(MeshBreite / 2)))
  619.  
  620.                 For x As Integer = 0 To mBreite
  621.                     For y As Integer = 0 To mHöhe
  622.                         With mPlane(x, y)
  623.                             xVal = .GetX * xStep
  624.                             yVal = .GetY * yStep
  625.                             zVal = .GetZ * zStep
  626.                         End With
  627.                         s.AppendLine(xVal.ToString & MeshGutterSeperator &
  628.                                      yVal.ToString & MeshGutterSeperator &
  629.                                      zVal.ToString & MeshGutterSeperator &
  630.                                      (redStep * Math.Abs(zVal)).ToString & MeshGutterSeperator &
  631.                                      (greenStep * Math.Abs(yVal)).ToString & MeshGutterSeperator &
  632.                                      (blueStep * Math.Abs(xVal)).ToString & MeshGutterSeperator &
  633.                                      MeshReflectance.ToString)
  634.                     Next
  635.                     System.IO.File.AppendAllText(sPfad, s.Replace(",", ".").ToString)
  636.                     s.Clear()
  637.                 Next
  638.                 s.Clear()
  639.                 Return True
  640.             Catch ex As Exception
  641.                 Return False
  642.             End Try
  643.         End Function
  644.  
  645.         Private Function ExportMesh_X_Y_Z_NX_NY_NZ(ByVal sPfad As String) As Boolean
  646.             Try
  647.                 Dim s As New Text.StringBuilder
  648.                 Dim xStep As Double = MeshBreite / GetAbsolute(xmin_Default, xmax_Default)
  649.                 Dim yStep As Double = MeshHöhe / GetAbsolute(ymin_Default, ymax_Default)
  650.                 Dim zStep As Double = MeshTiefe / GetAbsolute(zmin_Default, zmax_Default)
  651.                 Dim xVal, yVal, zVal As Double
  652.                 For x As Integer = 0 To mBreite
  653.                     For y As Integer = 0 To mHöhe
  654.                         With mPlane(x, y)
  655.                             xVal = .GetX * xStep
  656.                             yVal = .GetY * yStep
  657.                             zVal = .GetZ * zStep
  658.                         End With
  659.                         s.AppendLine(xVal.ToString & MeshGutterSeperator &
  660.                                      yVal.ToString & MeshGutterSeperator &
  661.                                      zVal.ToString & MeshGutterSeperator &
  662.                                      xVal.ToString & MeshGutterSeperator &
  663.                                      yVal.ToString & MeshGutterSeperator &
  664.                                      zVal.ToString)
  665.                     Next
  666.                     System.IO.File.AppendAllText(sPfad, s.Replace(",", ".").ToString)
  667.                     s.Clear()
  668.                 Next
  669.                 s.Clear()
  670.                 Return True
  671.             Catch ex As Exception
  672.                 Return False
  673.             End Try
  674.         End Function
  675. #End Region
  676.  
  677. #Region "Manipulation der Ebne"
  678.         Public Sub PushManipulation(ByVal Durchmesser As Integer, ByVal Mittelpunkt As Point, ByVal Flag As PushFlag)
  679.             Select Case Flag
  680.                 Case PushFlag.PushLinearDown
  681.                     PushEbneLinearDown(Durchmesser, Mittelpunkt)
  682.                 Case PushFlag.PushLinearUp
  683.                     PushEbneLinearUp(Durchmesser, Mittelpunkt)
  684.                 Case PushFlag.PushRoundDown
  685.                     PushEbneRoundDown(Durchmesser, Mittelpunkt)
  686.                 Case PushFlag.PushRoundUp
  687.                     PushEbneRoundUp(Durchmesser, Mittelpunkt)
  688.             End Select
  689.         End Sub
  690.  
  691.         Private Sub PushEbneLinearDown(ByVal Durchmesser As Integer, ByVal MidPoint As Point)
  692.             'Drückt die Ebne Linear/Kegelförmig nach unten
  693.             'Wir müssen uns von oben nach unten arbeiten. Somit fangen wir mit vollem Radius an
  694.             'I setzen wir auf 1. Da 0 Ebne beginn
  695.             'Wir benötigen nur den ZStepper
  696.             Dim zAbsolutDiagonal As Double = Math.Sqrt(mBreite * mHöhe)
  697.             Dim zStep As Double = GetAbsolute(zmin_Default, zmax_Default) / zAbsolutDiagonal
  698.             For i As Integer = 1 To Durchmesser
  699.                 Dim SchnittPunkte As List(Of Point) = CreateRoundPoints(Durchmesser - i, MidPoint)
  700.                 For Each oSPoint As Point In SchnittPunkte
  701.                     'Die Punkte sollten von der Funktion schon überpüft worden sein,
  702.                     'ob sie innerhalb unserer Grenzen liegen. Falls nicht -> CreateRoundPoints
  703.                     With mPlane(oSPoint.X, oSPoint.Y)
  704.                         mPlane(oSPoint.X, oSPoint.Y) = New Quaternion(.GetX, .GetY, .GetZ - (zStep * PushFaktor), .GetW)
  705.                     End With
  706.                 Next
  707.             Next
  708.         End Sub
  709.  
  710.         Private Sub PushEbneLinearUp(ByVal Durchmesser As Integer, ByVal MidPoint As Point)
  711.             'Drückt die Ebne Linear/Kegelförmig nach oben
  712.             'Wir müssen uns von oben nach unten arbeiten. Somit fangen wir mit vollem Radius an
  713.             'I setzen wir auf 1. Da 0 Ebne beginn
  714.             'Wir benötigen nur den ZStepper
  715.             Dim zAbsolutDiagonal As Double = Math.Sqrt(mBreite * mHöhe)
  716.             Dim zStep As Double = GetAbsolute(zmin_Default, zmax_Default) / zAbsolutDiagonal
  717.             For i As Integer = 1 To Durchmesser
  718.                 Dim SchnittPunkte As List(Of Point) = CreateRoundPoints(Durchmesser - i, MidPoint)
  719.                 For Each oSPoint As Point In SchnittPunkte
  720.                     'Die Punkte sollten von der Funktion schon überpüft worden sein,
  721.                     'ob sie innerhalb unserer Grenzen liegen. Falls nicht -> CreateRoundPoints
  722.                     With mPlane(oSPoint.X, oSPoint.Y)
  723.                         mPlane(oSPoint.X, oSPoint.Y) = New Quaternion(.GetX, .GetY, .GetZ + (zStep * PushFaktor), .GetW)
  724.                     End With
  725.                 Next
  726.             Next
  727.         End Sub
  728.  
  729.         Private Sub PushEbneRoundDown(ByVal Durchmesser As Integer, ByVal MidPoint As Point)
  730.             Dim zAbsolutDiagonal As Double = Math.Sqrt(mBreite * mHöhe)
  731.             Dim zStep As Double = GetAbsolute(zmin_Default, zmax_Default) / zAbsolutDiagonal
  732.             Dim zAlpha As Double = 0
  733.             For i As Integer = 1 To Durchmesser - 1
  734.                 Dim rad As Double = ToRadians(180 / (Durchmesser - i) * i)
  735.                 zAlpha = Math.Sin(rad) * zStep
  736.                 Dim SchnittPunkte As List(Of Point) = CreateRoundPoints(Durchmesser - i, MidPoint)
  737.                 For Each oSPoint As Point In SchnittPunkte
  738.                     'Die Punkte sollten von der Funktion schon überpüft worden sein,
  739.                     'ob sie innerhalb unserer Grenzen liegen. Falls nicht -> CreateRoundPoints
  740.                     With mPlane(oSPoint.X, oSPoint.Y)
  741.                         mPlane(oSPoint.X, oSPoint.Y) = New Quaternion(.GetX, .GetY, .GetZ - Math.Abs(zAlpha * PushFaktor), .GetW)
  742.                     End With
  743.                 Next
  744.             Next
  745.         End Sub
  746.  
  747.         Private Sub PushEbneRoundUp(ByVal Durchmesser As Integer, ByVal MidPoint As Point)
  748.             Dim zAbsolutDiagonal As Double = Math.Sqrt(mBreite * mHöhe)
  749.             Dim zStep As Double = GetAbsolute(zmin_Default, zmax_Default) / zAbsolutDiagonal
  750.             Dim zAlpha As Double = 0
  751.             For i As Integer = 1 To Durchmesser - 1
  752.                 Dim rad As Double = ToRadians(180 / (Durchmesser - i) * i)
  753.                 zAlpha = Math.Sin(rad) * zStep
  754.                 Dim SchnittPunkte As List(Of Point) = CreateRoundPoints(Durchmesser - i, MidPoint)
  755.                 For Each oSPoint As Point In SchnittPunkte
  756.                     'Die Punkte sollten von der Funktion schon überpüft worden sein,
  757.                     'ob sie innerhalb unserer Grenzen liegen. Falls nicht -> CreateRoundPoints
  758.                     With mPlane(oSPoint.X, oSPoint.Y)
  759.                         mPlane(oSPoint.X, oSPoint.Y) = New Quaternion(.GetX, .GetY, .GetZ + Math.Abs(zAlpha * PushFaktor), .GetW)
  760.                     End With
  761.                 Next
  762.             Next
  763.         End Sub
  764.  
  765.         Public Sub Blowup(ByVal MidPoint As Point, ByVal Masse As Double, ByVal Wiederstand As Double, ByVal Streuung As Double)
  766.             Dim nMasse As Double = Masse
  767.             Dim nWiederstand As Double = Wiederstand
  768.             Dim nStreuung As Double = Streuung
  769.             If nMasse > 100 Then nMasse = 100
  770.             If nMasse <= 0 Then nMasse = 1
  771.             Dim zL As Integer = CInt(Math.Sqrt(mBreite * mHöhe) / 100 * Masse)
  772.             Dim zStep As Double = GetAbsolute(zmin_Default, zmax_Default) / Math.Sqrt(mBreite * mHöhe)
  773.             Dim AbstandUrsprung As Double = 1
  774.             Dim rnd As New System.Random(TimeOfDay.Second * TimeOfDay.Minute * TimeOfDay.Millisecond)
  775.             Do While True
  776.                 Dim pkt As List(Of Point) = CreateRoundPoints(CInt(AbstandUrsprung), MidPoint)
  777.                 For Each pk As Point In pkt
  778.                     Dim mnKraft As Double = zStep - (6.6743 * (zStep * zL * zStep) / (GetLinearPosDist(pk, MidPoint) * 2))
  779.                     If pk = MidPoint Then
  780.                         mnKraft = zStep - (6.6743 * (zStep * zL * zStep) / (GetLinearPosDist(New Point(MidPoint.X, MidPoint.Y - CInt(AbstandUrsprung)), MidPoint) * 2))
  781.                     End If
  782.                     mnKraft -= (zStep / 100 * Wiederstand)
  783.                     If rnd.Next(0, 100) <= Streuung Then
  784.                         Dim st As Double = ((mnKraft / 100) * (100 - Wiederstand))
  785.                         mnKraft -= st
  786.                     End If
  787.                     mnKraft = Math.Abs(mnKraft)
  788.                     With mPlane(pk.X, pk.Y)
  789.                         mPlane(pk.X, pk.Y) = New Quaternion(.GetX, .GetY, .GetZ - mnKraft, .GetW)
  790.                     End With
  791.                 Next
  792.                 AbstandUrsprung += 1
  793.                 If AbstandUrsprung >= zL Then Exit Do
  794.             Loop
  795.         End Sub
  796. #End Region
  797.  
  798.     End Class
  799.  
  800.     <Serializable()>
  801.     Public Class ParentHolder
  802.  
  803.         Private ReadOnly mChilds As List(Of ChildHolder)
  804.         Public Sub New()
  805.             mChilds = New List(Of ChildHolder)
  806.         End Sub
  807.  
  808.         Public Sub New(ByVal _Child As ChildHolder)
  809.             mChilds = New List(Of ChildHolder)
  810.             mChilds.Add(_Child)
  811.         End Sub
  812.  
  813.         ''' <summary>
  814.         ''' <code>Gibt das Item am gewählten Index zurück.</code>
  815.         ''' </summary>
  816.         ''' <param name="Index">Der Index des Elementes.</param>
  817.         ''' <returns></returns>
  818.         Public Function Item(ByVal Index As Integer) As ChildHolder
  819.             If Index < 0 Then Throw New IndexOutOfRangeException("Index auserhalb des Bereiches!")
  820.             If Index > mChilds.Count Then Throw New IndexOutOfRangeException("Index auserhalb des Bereiches!")
  821.             Return mChilds(Index)
  822.         End Function
  823.  
  824.         ''' <summary>
  825.         ''' <code>Fügt ein Element in den Speichern ein.</code>
  826.         ''' </summary>
  827.         ''' <param name="Item">Object zum ablegen.</param>
  828.         Public Sub Add(ByVal Item As ChildHolder)
  829.             mChilds.Add(Item)
  830.         End Sub
  831.         ''' <summary>
  832.         ''' <code>Überprüft ob ein Element mit dem gesuchten übereinstimmt und existiert.</code>
  833.         ''' </summary>
  834.         ''' <param name="Item">Das zu suchende Element.</param>
  835.         ''' <returns></returns>
  836.         Public Function Exist(ByVal Item As ChildHolder) As Boolean
  837.             Dim result As Boolean = False
  838.             For Each ch As ChildHolder In mChilds
  839.                 If ch.Equals(Item) Then
  840.                     result = True
  841.                     Exit For
  842.                 End If
  843.             Next
  844.             Return result
  845.         End Function
  846.         ''' <summary>
  847.         ''' <code>Gibt alle Elemente als Array zurück.</code>
  848.         ''' </summary>
  849.         ''' <returns></returns>
  850.         Public Function ToArray() As ChildHolder()
  851.             Return mChilds.ToArray()
  852.         End Function
  853.         ''' <summary>
  854.         ''' <code>Entfernt ein Element am gewünschten Index.</code>
  855.         ''' </summary>
  856.         ''' <param name="Index">Der Index im Array</param>
  857.         Public Sub Remove(ByVal Index As Integer)
  858.             If Index < 0 Then Throw New IndexOutOfRangeException("Der Index kann nicht kleiner 0 sein!")
  859.             If Index > mChilds.Count Then Throw New IndexOutOfRangeException("Der Wert kann nicht größer als die Anzahl der Elemente sein.")
  860.             mChilds.RemoveAt(Index)
  861.         End Sub
  862.         ''' <summary>
  863.         ''' <code>Entfernt das erste Element das mit dem gesuchten Übereinstimmt aus dem Speicher.</code>
  864.         ''' </summary>
  865.         ''' <param name="Item">Das zu entfernende Element</param>
  866.         ''' <returns></returns>
  867.         Public Function RemoveFirst(ByVal Item As ChildHolder) As Boolean
  868.             Dim val As Integer = -1
  869.             For i As Integer = 0 To mChilds.Count - 1
  870.                 If mChilds(i).Equals(Item) Then
  871.                     val = i
  872.                     Exit For
  873.                 End If
  874.             Next
  875.             If Not val = -1 Then
  876.                 mChilds.RemoveAt(val)
  877.                 Return True
  878.             Else
  879.                 Return False
  880.             End If
  881.         End Function
  882.  
  883.         ''' <summary>
  884.         ''' <code>Gibt die Anzahl der existierende Elemente, die mit dem gesuchten übereinstimmen zurück.</code>
  885.         ''' </summary>
  886.         ''' <param name="Item">Zu suchende Elemente</param>
  887.         ''' <returns></returns>
  888.         Public Function CountOf(ByVal Item As ChildHolder) As Integer
  889.             Dim val As Integer = 0
  890.             For Each child As ChildHolder In mChilds
  891.                 If child.Equals(Item) Then val += 1
  892.             Next
  893.             Return val
  894.         End Function
  895.  
  896.         ''' <summary>
  897.         ''' <code>Entfernt alle Elemente die mit dem gesuchten übereinstimmen aus dem Speicher.</code>
  898.         ''' </summary>
  899.         ''' <param name="Item">Die zu entfernenden Elemente</param>
  900.         Public Sub RemoveAll(ByVal Item As ChildHolder)
  901.             Do Until CountOf(Item) = 0
  902.                 RemoveFirst(Item)
  903.             Loop
  904.         End Sub
  905.  
  906.         Public Overrides Function ToString() As String
  907.             Dim totalBytes As Integer
  908.             Dim b As BinaryFormatter = New BinaryFormatter()
  909.             Dim m As MemoryStream = New MemoryStream()
  910.             b.Serialize(m, Me)
  911.             totalBytes = CInt(m.Length)
  912.             m.Close()
  913.             m.Dispose()
  914.             b = Nothing
  915.             Return "{ParentHolder:[" & mChilds.Count & "];Byte[" & totalBytes & "]}"
  916.         End Function
  917.  
  918.     End Class
  919.     <Serializable()>
  920.     Public Structure ChildHolder
  921.  
  922.         Public Shared Empty As New ChildHolder(0, 0, New Quaternion(0, 0, 0, 0))
  923.  
  924.         Public Sub New(ByVal x As Integer, ByVal y As Integer, ByVal quat As Quaternion)
  925.             GetX = x
  926.             GetY = y
  927.             GetQuaternion = quat
  928.         End Sub
  929.  
  930.         Public ReadOnly Property GetX() As Integer
  931.         Public ReadOnly Property GetY() As Integer
  932.         Public ReadOnly Property GetQuaternion() As Quaternion
  933.  
  934.         Public Shadows Function Equals(obj As ChildHolder) As Boolean
  935.             Try
  936.                 Return obj.GetQuaternion = GetQuaternion AndAlso obj.GetX = GetX AndAlso obj.GetY = GetY
  937.             Catch ex As Exception
  938.                 Throw New Exception(ex.Message)
  939.             End Try
  940.         End Function
  941.         Public Overrides Function ToString() As String
  942.             Dim sb As System.Text.StringBuilder = New System.Text.StringBuilder()
  943.             sb.Append("{X:")
  944.             sb.Append(GetX)
  945.             sb.Append(" Y:")
  946.             sb.Append(GetY & "}")
  947.             sb.Append(GetQuaternion.ToString)
  948.             Return sb.ToString()
  949.         End Function
  950.  
  951.     End Structure
  952.  
  953. End Namespace
Add Comment
Please, Sign In to add comment