Single grating angle working for multiple
This commit is contained in:
parent
c29b4a223a
commit
27c344123e
|
|
@ -117,6 +117,11 @@ Public Class Multiple_Drawing
|
||||||
pointsDT.Columns.Add("X", GetType(Double))
|
pointsDT.Columns.Add("X", GetType(Double))
|
||||||
pointsDT.Columns.Add("Y", GetType(Double))
|
pointsDT.Columns.Add("Y", GetType(Double))
|
||||||
|
|
||||||
|
Dim GAPointsDT As New DataTable
|
||||||
|
GAPointsDT.Columns.Add("NAME", GetType(String))
|
||||||
|
GAPointsDT.Columns.Add("X", GetType(Double))
|
||||||
|
GAPointsDT.Columns.Add("Y", GetType(Double))
|
||||||
|
|
||||||
' --- Determine grossArea points ----
|
' --- Determine grossArea points ----
|
||||||
Dim pX(3) As Double
|
Dim pX(3) As Double
|
||||||
Dim pY(3) As Double
|
Dim pY(3) As Double
|
||||||
|
|
@ -171,8 +176,13 @@ Public Class Multiple_Drawing
|
||||||
DR("TYPE") = "GA"
|
DR("TYPE") = "GA"
|
||||||
DR("X") = pX(j)
|
DR("X") = pX(j)
|
||||||
DR("Y") = pY(j)
|
DR("Y") = pY(j)
|
||||||
|
|
||||||
pointsDT.Rows.Add(DR)
|
pointsDT.Rows.Add(DR)
|
||||||
|
|
||||||
|
DR = GAPointsDT.NewRow()
|
||||||
|
DR("NAME") = "GA_" & j + 1
|
||||||
|
DR("X") = pX(j)
|
||||||
|
DR("Y") = pY(j)
|
||||||
|
GAPointsDT.Rows.Add(DR)
|
||||||
Next
|
Next
|
||||||
|
|
||||||
' --- Add recess points ---
|
' --- Add recess points ---
|
||||||
|
|
@ -239,27 +249,70 @@ Public Class Multiple_Drawing
|
||||||
DR3("X") = DR("X")
|
DR3("X") = DR("X")
|
||||||
DR3("Y") = DR("Y")
|
DR3("Y") = DR("Y")
|
||||||
|
|
||||||
Dim index As Integer = Get_RowIndex(pointsDT, DR("SIDE"), DR("X"), DR("Y"))
|
Dim index As Integer = Get_RowIndex(pointsDT, DR("SIDE"), DR("X"), DR("Y"), GAPointsDT)
|
||||||
pointsDT.Rows.InsertAt(DR3, index + 1)
|
pointsDT.Rows.InsertAt(DR3, index + 1)
|
||||||
|
|
||||||
Try
|
If pointsDT.Rows.Count > index + 2 Then
|
||||||
pointsDT.Rows.RemoveAt(index + 2)
|
Dim temp As String = pointsDT.Rows(index + 2)("NAME")
|
||||||
Catch ex As Exception
|
If temp.Substring(0, 2) = "GA" Then
|
||||||
pointsDT.Rows.RemoveAt(0)
|
pointsDT.Rows.RemoveAt(index + 2)
|
||||||
End Try
|
End If
|
||||||
|
|
||||||
|
Else
|
||||||
|
Dim temp As String = pointsDT.Rows(0)("NAME")
|
||||||
|
If temp.Substring(0, 2) = "GA" Then
|
||||||
|
pointsDT.Rows.RemoveAt(0)
|
||||||
|
End If
|
||||||
|
|
||||||
|
End If
|
||||||
|
|
||||||
'Check if remove next point aswell (If angle crosses more than one grating)
|
'Check if remove next point aswell (If angle crosses more than one grating)
|
||||||
|
|
||||||
Dim cornerPoint(1) As Double
|
Dim cornerPoint(1) As Double
|
||||||
Dim pointNumGA As Integer = DR("SIDE") + 2
|
Dim pointNumGA As Integer = DR("SIDE") + 2
|
||||||
If pointNumGA > 4 Then
|
If pointNumGA > 4 Then
|
||||||
pointNumGA -= 4
|
pointNumGA -= 4
|
||||||
End If
|
End If
|
||||||
|
|
||||||
cornerPoint(0) = pointsDT.Select("NAME = 'GA_" & pointNumGA & "'")(0)("X")
|
cornerPoint(0) = GAPointsDT.Select("NAME = 'GA_" & pointNumGA & "'")(0)("X")
|
||||||
cornerPoint(1) = pointsDT.Select("NAME = 'GA_" & pointNumGA & "'")(0)("Y")
|
cornerPoint(1) = GAPointsDT.Select("NAME = 'GA_" & pointNumGA & "'")(0)("Y")
|
||||||
|
|
||||||
Create_SecondAnglePoint(pointsDT, DR, cornerPoint)
|
Create_SecondAnglePoint(pointsDT, DR, cornerPoint, GAPointsDT, recessPointsDT)
|
||||||
Else
|
Else
|
||||||
|
Dim DR3 As DataRow = pointsDT.NewRow()
|
||||||
|
DR3("NAME") = DR("NAME")
|
||||||
|
DR3("TYPE") = "Recess CA"
|
||||||
|
DR3("X") = DR("X")
|
||||||
|
DR3("Y") = DR("Y")
|
||||||
|
|
||||||
|
Dim index As Integer = Get_RowIndex(pointsDT, DR("SIDE"), DR("X"), DR("Y"), GAPointsDT)
|
||||||
|
pointsDT.Rows.InsertAt(DR3, index + 1)
|
||||||
|
|
||||||
|
'If pointsDT.Rows.Count > index Then
|
||||||
|
Dim temp As String = pointsDT.Rows(index)("NAME")
|
||||||
|
If temp.Substring(0, 2) = "GA" Then
|
||||||
|
pointsDT.Rows.RemoveAt(index)
|
||||||
|
End If
|
||||||
|
|
||||||
|
'Else
|
||||||
|
' Dim temp As String = pointsDT.Rows(0)("NAME")
|
||||||
|
' If temp.Substring(0, 2) = "GA" Then
|
||||||
|
' pointsDT.Rows.RemoveAt(0)
|
||||||
|
' End If
|
||||||
|
|
||||||
|
'End If
|
||||||
|
|
||||||
|
Dim cornerPoint(1) As Double
|
||||||
|
Dim pointNumGA As Integer = DR("SIDE") - 1
|
||||||
|
If pointNumGA < 1 Then
|
||||||
|
pointNumGA += 4
|
||||||
|
End If
|
||||||
|
|
||||||
|
cornerPoint(0) = GAPointsDT.Select("NAME = 'GA_" & pointNumGA & "'")(0)("X")
|
||||||
|
cornerPoint(1) = GAPointsDT.Select("NAME = 'GA_" & pointNumGA & "'")(0)("Y")
|
||||||
|
|
||||||
|
Create_SecondAnglePoint(pointsDT, DR, cornerPoint, GAPointsDT, recessPointsDT)
|
||||||
|
|
||||||
|
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
|
@ -277,15 +330,19 @@ Public Class Multiple_Drawing
|
||||||
Return pointsDS
|
Return pointsDS
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Private Shared Function Get_RowIndex(pDT As DataTable, side As Integer, pX As Double, pY As Double)
|
Private Shared Function Get_RowIndex(pDT As DataTable, side As Integer, pX As Double, pY As Double, GApDT As DataTable)
|
||||||
|
|
||||||
Dim rowName As String = ""
|
Dim rowName As String = ""
|
||||||
|
Dim newX As Double = pX
|
||||||
|
Dim newY As Double = pY
|
||||||
|
|
||||||
If side = 1 Then
|
If side = 1 Then
|
||||||
Dim sidePoints = pDT.Select("Y = '" & pY & "'")
|
Dim sidePoints = pDT.Select("Y = '" & pY & "'")
|
||||||
For Each DR2 As DataRow In sidePoints
|
For Each DR2 As DataRow In sidePoints
|
||||||
If DR2("X") < pX Then
|
If DR2("X") < pX Then
|
||||||
rowName = DR2("NAME")
|
rowName = DR2("NAME")
|
||||||
Else
|
Else
|
||||||
|
newX = GApDT.Select("NAME = 'GA_1'")(0)("X")
|
||||||
Exit For
|
Exit For
|
||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
|
|
@ -295,6 +352,7 @@ Public Class Multiple_Drawing
|
||||||
If DR2("Y") > pY Then
|
If DR2("Y") > pY Then
|
||||||
rowName = DR2("NAME")
|
rowName = DR2("NAME")
|
||||||
Else
|
Else
|
||||||
|
newY = GApDT.Select("NAME = 'GA_2'")(0)("Y")
|
||||||
Exit For
|
Exit For
|
||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
|
|
@ -304,6 +362,7 @@ Public Class Multiple_Drawing
|
||||||
If DR2("X") > pX Then
|
If DR2("X") > pX Then
|
||||||
rowName = DR2("NAME")
|
rowName = DR2("NAME")
|
||||||
Else
|
Else
|
||||||
|
newX = GApDT.Select("NAME = 'GA_3'")(0)("X")
|
||||||
Exit For
|
Exit For
|
||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
|
|
@ -313,23 +372,28 @@ Public Class Multiple_Drawing
|
||||||
If DR2("Y") < pY Then
|
If DR2("Y") < pY Then
|
||||||
rowName = DR2("NAME")
|
rowName = DR2("NAME")
|
||||||
Else
|
Else
|
||||||
|
newY = GApDT.Select("NAME = 'GA_4'")(0)("Y")
|
||||||
Exit For
|
Exit For
|
||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Dim index As Integer = 0
|
Dim index As Integer = 0
|
||||||
For j = 0 To pDT.Rows.Count - 1
|
If rowName = "" Then
|
||||||
If pDT.Rows(j)("NAME") = rowName Then
|
index = Get_RowIndex(pDT, side - 1, newX, newY, GApDT)
|
||||||
index = j
|
Else
|
||||||
Exit For
|
For j = 0 To pDT.Rows.Count - 1
|
||||||
End If
|
If pDT.Rows(j)("NAME") = rowName Then
|
||||||
Next
|
index = j
|
||||||
|
Exit For
|
||||||
|
End If
|
||||||
|
Next
|
||||||
|
End If
|
||||||
|
|
||||||
Return index
|
Return index
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Private Shared Sub Create_SecondAnglePoint(pDT As DataTable, rpDR As DataRow, gp As Double())
|
Private Shared Sub Create_SecondAnglePoint(pDT As DataTable, rpDR As DataRow, gp As Double(), GApDT As DataTable, rDT As DataTable)
|
||||||
Dim p0(1) As Double
|
Dim p0(1) As Double
|
||||||
Dim p1(1) As Double
|
Dim p1(1) As Double
|
||||||
Dim p2(1) As Double
|
Dim p2(1) As Double
|
||||||
|
|
@ -361,9 +425,34 @@ Public Class Multiple_Drawing
|
||||||
If rpDR("SIDE") = 1 OrElse rpDR("SIDE") = 3 Then
|
If rpDR("SIDE") = 1 OrElse rpDR("SIDE") = 3 Then
|
||||||
p1(0) = p2(0)
|
p1(0) = p2(0)
|
||||||
p1(1) = p0(1)
|
p1(1) = p0(1)
|
||||||
|
If rDT.Select("NAME = '" & newDR("NAME") & "'")(0)("X") = GApDT.Select("NAME = 'GA_2'")(0)("X") OrElse
|
||||||
|
rDT.Select("NAME = '" & newDR("NAME") & "'")(0)("X") = GApDT.Select("NAME = 'GA_4'")(0)("X") Then
|
||||||
|
If rDT.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") > GApDT.Select("NAME = 'GA_3'")(0)("Y") AndAlso
|
||||||
|
rDT.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") < GApDT.Select("NAME = 'GA_2'")(0)("Y") Then
|
||||||
|
|
||||||
|
Exit Sub
|
||||||
|
ElseIf rDT.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") > GApDT.Select("NAME = 'GA_4'")(0)("Y") AndAlso
|
||||||
|
rDT.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") < GApDT.Select("NAME = 'GA_1'")(0)("Y") Then
|
||||||
|
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
End If
|
||||||
ElseIf rpDR("SIDE") = 2 OrElse rpDR("SIDE") = 4 Then
|
ElseIf rpDR("SIDE") = 2 OrElse rpDR("SIDE") = 4 Then
|
||||||
p1(0) = p0(0)
|
p1(0) = p0(0)
|
||||||
p1(1) = p2(1)
|
p1(1) = p2(1)
|
||||||
|
|
||||||
|
If rDT.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") = GApDT.Select("NAME = 'GA_3'")(0)("Y") OrElse
|
||||||
|
rDT.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") = GApDT.Select("NAME = 'GA_1'")(0)("Y") Then
|
||||||
|
If rDT.Select("NAME = '" & newDR("NAME") & "'")(0)("X") < GApDT.Select("NAME = 'GA_3'")(0)("X") AndAlso
|
||||||
|
rDT.Select("NAME = '" & newDR("NAME") & "'")(0)("X") > GApDT.Select("NAME = 'GA_4'")(0)("X") Then
|
||||||
|
|
||||||
|
Exit Sub
|
||||||
|
ElseIf rDT.Select("NAME = '" & newDR("NAME") & "'")(0)("X") > GApDT.Select("NAME = 'GA_1'")(0)("X") AndAlso
|
||||||
|
rDT.Select("NAME = '" & newDR("NAME") & "'")(0)("X") < GApDT.Select("NAME = 'GA_2'")(0)("X") Then
|
||||||
|
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
End If
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Dim gpInside As Boolean = Calculate_Triangle_Bool(gp, p0, p1, p2)
|
Dim gpInside As Boolean = Calculate_Triangle_Bool(gp, p0, p1, p2)
|
||||||
|
|
@ -380,32 +469,32 @@ Public Class Multiple_Drawing
|
||||||
|
|
||||||
' FIXA: GA punkten tas bort innan vi behöver den här
|
' FIXA: GA punkten tas bort innan vi behöver den här
|
||||||
If side = 1 Then
|
If side = 1 Then
|
||||||
Dim c As Double = pDT.Select("NAME = 'GA_1'")(0)("Y") - rpDR("Y")
|
Dim c As Double = GApDT.Select("NAME = 'GA_1'")(0)("Y") - rpDR("Y")
|
||||||
Dim x As Double = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X") - pDT.Select("NAME = 'GA_1'")(0)("X")
|
Dim x As Double = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X") - GApDT.Select("NAME = 'GA_1'")(0)("X")
|
||||||
Dim z As Double = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") - rpDR("Y")
|
Dim z As Double = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") - rpDR("Y")
|
||||||
newDR("X") = pDT.Select("NAME = 'GA_1'")(0)("X") + c * x / z ' Triangle likformighet
|
newDR("X") = GApDT.Select("NAME = 'GA_1'")(0)("X") + c * x / z ' Triangle likformighet
|
||||||
newDR("Y") = pDT.Select("NAME = 'GA_1'")(0)("Y")
|
newDR("Y") = GApDT.Select("NAME = 'GA_1'")(0)("Y")
|
||||||
ElseIf side = 2 Then
|
ElseIf side = 2 Then
|
||||||
Dim c As Double = pDT.Select("NAME = 'GA_2'")(0)("X") - rpDR("X")
|
Dim c As Double = GApDT.Select("NAME = 'GA_2'")(0)("X") - rpDR("X")
|
||||||
Dim x As Double = pDT.Select("NAME = 'GA_2'")(0)("Y") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y")
|
Dim x As Double = GApDT.Select("NAME = 'GA_2'")(0)("Y") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y")
|
||||||
Dim z As Double = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X") - rpDR("X")
|
Dim z As Double = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X") - rpDR("X")
|
||||||
newDR("X") = pDT.Select("NAME = 'GA_2'")(0)("X")
|
newDR("X") = GApDT.Select("NAME = 'GA_2'")(0)("X")
|
||||||
newDR("Y") = pDT.Select("NAME = 'GA_2'")(0)("Y") - c * x / z ' Triangle likformighet
|
newDR("Y") = GApDT.Select("NAME = 'GA_2'")(0)("Y") - c * x / z ' Triangle likformighet
|
||||||
ElseIf side = 3 Then
|
ElseIf side = 3 Then
|
||||||
Dim c As Double = rpDR("Y") - pDT.Select("NAME = 'GA_3'")(0)("Y")
|
Dim c As Double = rpDR("Y") - GApDT.Select("NAME = 'GA_3'")(0)("Y")
|
||||||
Dim x As Double = pDT.Select("NAME = 'GA_3'")(0)("X") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X")
|
Dim x As Double = GApDT.Select("NAME = 'GA_3'")(0)("X") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X")
|
||||||
Dim z As Double = rpDR("Y") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y")
|
Dim z As Double = rpDR("Y") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y")
|
||||||
newDR("X") = pDT.Select("NAME = 'GA_3'")(0)("X") - c * x / z ' Triangle likformighet
|
newDR("X") = GApDT.Select("NAME = 'GA_3'")(0)("X") - c * x / z ' Triangle likformighet
|
||||||
newDR("Y") = pDT.Select("NAME = 'GA_3'")(0)("Y")
|
newDR("Y") = GApDT.Select("NAME = 'GA_3'")(0)("Y")
|
||||||
Else
|
Else
|
||||||
Dim c As Double = rpDR("X") - pDT.Select("NAME = 'GA_4'")(0)("X")
|
Dim c As Double = rpDR("X") - GApDT.Select("NAME = 'GA_4'")(0)("X")
|
||||||
Dim x As Double = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") - pDT.Select("NAME = 'GA_4'")(0)("Y")
|
Dim x As Double = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") - GApDT.Select("NAME = 'GA_4'")(0)("Y")
|
||||||
Dim z As Double = rpDR("X") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X")
|
Dim z As Double = rpDR("X") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X")
|
||||||
newDR("X") = pDT.Select("NAME = 'GA_4'")(0)("X")
|
newDR("X") = GApDT.Select("NAME = 'GA_4'")(0)("X")
|
||||||
newDR("Y") = pDT.Select("NAME = 'GA_4'")(0)("Y") + c * x / z ' Triangle likformighet
|
newDR("Y") = GApDT.Select("NAME = 'GA_4'")(0)("Y") + c * x / z ' Triangle likformighet
|
||||||
End If
|
End If
|
||||||
|
|
||||||
insertIndex = Get_RowIndex(pDT, side, newDR("X"), newDR("Y")) + 1
|
insertIndex = Get_RowIndex(pDT, side, newDR("X"), newDR("Y"), GApDT) + 1
|
||||||
Else
|
Else
|
||||||
' If true => remove point gp and new point at side rpDR("SIDE")+2
|
' If true => remove point gp and new point at side rpDR("SIDE")+2
|
||||||
Dim side As Integer = 0
|
Dim side As Integer = 0
|
||||||
|
|
@ -442,7 +531,7 @@ Public Class Multiple_Drawing
|
||||||
' newDR("Y") = pDT.Select("NAME = 'P4'")(0)("Y") + c * x / z ' Triangle likformighet
|
' newDR("Y") = pDT.Select("NAME = 'P4'")(0)("Y") + c * x / z ' Triangle likformighet
|
||||||
'End If
|
'End If
|
||||||
|
|
||||||
insertIndex = Get_RowIndex(pDT, side, newDR("X"), newDR("Y"))
|
insertIndex = Get_RowIndex(pDT, side, newDR("X"), newDR("Y"), GApDT)
|
||||||
|
|
||||||
pDT.Rows.RemoveAt(insertIndex)
|
pDT.Rows.RemoveAt(insertIndex)
|
||||||
End If
|
End If
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue