Angle working for multiple grating SW
This commit is contained in:
parent
27c344123e
commit
66a8c1d3c1
|
|
@ -9,8 +9,8 @@ Public Class Multiple_Drawing
|
|||
Dim swApp As SldWorks.SldWorks
|
||||
swApp = CType(System.Runtime.InteropServices.Marshal.GetActiveObject("SldWorks.Application"), SldWorks.SldWorks)
|
||||
Dim Model As ModelDoc2
|
||||
Dim RootPoint(2) As Double
|
||||
Dim Normal(2) As Double
|
||||
Dim RootPoint(2) As Decimal
|
||||
Dim Normal(2) As Decimal
|
||||
swApp.UserControl = True
|
||||
|
||||
Dim swSkMgr As SketchManager
|
||||
|
|
@ -114,17 +114,17 @@ Public Class Multiple_Drawing
|
|||
Dim pointsDT As New DataTable
|
||||
pointsDT.Columns.Add("NAME", GetType(String))
|
||||
pointsDT.Columns.Add("TYPE", GetType(String))
|
||||
pointsDT.Columns.Add("X", GetType(Double))
|
||||
pointsDT.Columns.Add("Y", GetType(Double))
|
||||
pointsDT.Columns.Add("X", GetType(Decimal))
|
||||
pointsDT.Columns.Add("Y", GetType(Decimal))
|
||||
|
||||
Dim GAPointsDT As New DataTable
|
||||
GAPointsDT.Columns.Add("NAME", GetType(String))
|
||||
GAPointsDT.Columns.Add("X", GetType(Double))
|
||||
GAPointsDT.Columns.Add("Y", GetType(Double))
|
||||
GAPointsDT.Columns.Add("X", GetType(Decimal))
|
||||
GAPointsDT.Columns.Add("Y", GetType(Decimal))
|
||||
|
||||
' --- Determine grossArea points ----
|
||||
Dim pX(3) As Double
|
||||
Dim pY(3) As Double
|
||||
Dim pX(3) As Decimal
|
||||
Dim pY(3) As Decimal
|
||||
|
||||
Dim columnNum As Integer = (i + Grating_Fill.numOfHorizontal) Mod Grating_Fill.numOfHorizontal
|
||||
If columnNum <> (Grating_Fill.numOfHorizontal - 1) Then
|
||||
|
|
@ -190,8 +190,8 @@ Public Class Multiple_Drawing
|
|||
recessPointsDT.Columns.Add("NAME", GetType(String))
|
||||
recessPointsDT.Columns.Add("TYPE", GetType(String))
|
||||
recessPointsDT.Columns.Add("SIDE", GetType(Integer))
|
||||
recessPointsDT.Columns.Add("X", GetType(Double))
|
||||
recessPointsDT.Columns.Add("Y", GetType(Double))
|
||||
recessPointsDT.Columns.Add("X", GetType(Decimal))
|
||||
recessPointsDT.Columns.Add("Y", GetType(Decimal))
|
||||
|
||||
For j = 1 To 4
|
||||
For Each DR As DataRow In Data.gratingPoints.Rows
|
||||
|
|
@ -257,18 +257,16 @@ Public Class Multiple_Drawing
|
|||
If temp.Substring(0, 2) = "GA" Then
|
||||
pointsDT.Rows.RemoveAt(index + 2)
|
||||
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)
|
||||
|
||||
Dim cornerPoint(1) As Double
|
||||
Dim cornerPoint(1) As Decimal
|
||||
Dim pointNumGA As Integer = DR("SIDE") + 2
|
||||
If pointNumGA > 4 Then
|
||||
pointNumGA -= 4
|
||||
|
|
@ -288,21 +286,12 @@ Public Class Multiple_Drawing
|
|||
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 cornerPoint(1) As Decimal
|
||||
Dim pointNumGA As Integer = DR("SIDE") - 1
|
||||
If pointNumGA < 1 Then
|
||||
pointNumGA += 4
|
||||
|
|
@ -312,17 +301,10 @@ Public Class Multiple_Drawing
|
|||
cornerPoint(1) = GAPointsDT.Select("NAME = 'GA_" & pointNumGA & "'")(0)("Y")
|
||||
|
||||
Create_SecondAnglePoint(pointsDT, DR, cornerPoint, GAPointsDT, recessPointsDT)
|
||||
|
||||
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
Next
|
||||
|
||||
|
||||
|
||||
|
||||
pointsDT.TableName = "Grating " & i & " - C" & columnNum & " R" & rowNum
|
||||
pointsDS.Tables.Add(pointsDT)
|
||||
Next
|
||||
|
|
@ -330,11 +312,11 @@ Public Class Multiple_Drawing
|
|||
Return pointsDS
|
||||
End Function
|
||||
|
||||
Private Shared Function Get_RowIndex(pDT As DataTable, side As Integer, pX As Double, pY As Double, GApDT As DataTable)
|
||||
Private Shared Function Get_RowIndex(pDT As DataTable, side As Integer, pX As Decimal, pY As Decimal, GApDT As DataTable)
|
||||
|
||||
Dim rowName As String = ""
|
||||
Dim newX As Double = pX
|
||||
Dim newY As Double = pY
|
||||
Dim newX As Decimal = pX
|
||||
Dim newY As Decimal = pY
|
||||
|
||||
If side = 1 Then
|
||||
Dim sidePoints = pDT.Select("Y = '" & pY & "'")
|
||||
|
|
@ -368,14 +350,31 @@ Public Class Multiple_Drawing
|
|||
Next
|
||||
Else
|
||||
Dim sidePoints = pDT.Select("X = '" & pX & "'")
|
||||
For Each DR2 As DataRow In sidePoints
|
||||
If DR2("Y") < pY Then
|
||||
rowName = DR2("NAME")
|
||||
Else
|
||||
newY = GApDT.Select("NAME = 'GA_4'")(0)("Y")
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
If sidePoints(0)("NAME") = "GA_1" Then
|
||||
Dim pointList As New List(Of DataRow)
|
||||
For i = 1 To sidePoints.Length - 1
|
||||
pointList.Add(sidePoints(i))
|
||||
Next
|
||||
pointList.Add(sidePoints(0))
|
||||
|
||||
For Each DR2 As DataRow In pointList
|
||||
If DR2("Y") < pY Then
|
||||
rowName = DR2("NAME")
|
||||
Else
|
||||
newY = GApDT.Select("NAME = 'GA_4'")(0)("Y")
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
Else
|
||||
For Each DR2 As DataRow In sidePoints
|
||||
If DR2("Y") < pY Then
|
||||
rowName = DR2("NAME")
|
||||
Else
|
||||
newY = GApDT.Select("NAME = 'GA_4'")(0)("Y")
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
|
||||
Dim index As Integer = 0
|
||||
|
|
@ -393,14 +392,15 @@ Public Class Multiple_Drawing
|
|||
Return index
|
||||
End Function
|
||||
|
||||
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 p1(1) As Double
|
||||
Dim p2(1) As Double
|
||||
Private Shared Sub Create_SecondAnglePoint(pDT As DataTable, rpDR As DataRow, gp As Decimal(), GApDT As DataTable, rDT As DataTable)
|
||||
Dim p0(1) As Decimal
|
||||
Dim p1(1) As Decimal
|
||||
Dim p2(1) As Decimal
|
||||
|
||||
Dim newDR As DataRow = pDT.NewRow
|
||||
newDR("TYPE") = "Recess CA"
|
||||
|
||||
Dim side As Integer = 0
|
||||
Dim pointName As String = rpDR("NAME")
|
||||
If pointName.Split("_")(1) = 1 Then
|
||||
Dim DR = Data.gratingPoints.Select("NAME = '" & pointName.Split("_")(0) & "_2" & "'")
|
||||
|
|
@ -411,48 +411,66 @@ Public Class Multiple_Drawing
|
|||
|
||||
p2(0) = DR(0)("X")
|
||||
p2(1) = DR(0)("Y")
|
||||
|
||||
If rpDR("SIDE") + 1 > 4 Then
|
||||
side = rpDR("SIDE") + 1 - 4
|
||||
Else
|
||||
side = rpDR("SIDE") + 1
|
||||
End If
|
||||
Else
|
||||
Dim DR = Data.gratingPoints.Select("NAME = '" & pointName.Split("_")(0) & "_1" & "'")
|
||||
newDR("NAME") = pointName.Split("_")(0) & "_1"
|
||||
|
||||
p0(0) = DR(0)("X")
|
||||
p0(1) = DR(0)("Y")
|
||||
p0(0) = rpDR("X")
|
||||
p0(1) = rpDR("Y")
|
||||
|
||||
p2(0) = rpDR("X")
|
||||
p2(1) = rpDR("Y")
|
||||
p2(0) = DR(0)("X")
|
||||
p2(1) = DR(0)("Y")
|
||||
|
||||
If rpDR("SIDE") - 1 < 1 Then
|
||||
side = rpDR("SIDE") - 1 + 4
|
||||
Else
|
||||
side = rpDR("SIDE") - 1
|
||||
End If
|
||||
End If
|
||||
|
||||
For Each rDR As DataRow In rDT.Rows
|
||||
If rDR("NAME") = newDR("NAME") Then
|
||||
Exit Sub
|
||||
End If
|
||||
Next
|
||||
|
||||
If rpDR("SIDE") = 1 OrElse rpDR("SIDE") = 3 Then
|
||||
p1(0) = p2(0)
|
||||
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
|
||||
'If Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X") = GApDT.Select("NAME = 'GA_2'")(0)("X") OrElse
|
||||
' Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X") = GApDT.Select("NAME = 'GA_4'")(0)("X") Then
|
||||
' If Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") > GApDT.Select("NAME = 'GA_3'")(0)("Y") AndAlso
|
||||
' Data.gratingPoints.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
|
||||
' ElseIf Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") > GApDT.Select("NAME = 'GA_4'")(0)("Y") AndAlso
|
||||
' Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") < GApDT.Select("NAME = 'GA_1'")(0)("Y") Then
|
||||
|
||||
Exit Sub
|
||||
End If
|
||||
End If
|
||||
' Exit Sub
|
||||
' End If
|
||||
'End If
|
||||
ElseIf rpDR("SIDE") = 2 OrElse rpDR("SIDE") = 4 Then
|
||||
p1(0) = p0(0)
|
||||
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
|
||||
'If Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") = GApDT.Select("NAME = 'GA_3'")(0)("Y") OrElse
|
||||
' Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") = GApDT.Select("NAME = 'GA_1'")(0)("Y") Then
|
||||
' If Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X") < GApDT.Select("NAME = 'GA_3'")(0)("X") AndAlso
|
||||
' Data.gratingPoints.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
|
||||
' ElseIf Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X") > GApDT.Select("NAME = 'GA_1'")(0)("X") AndAlso
|
||||
' Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X") < GApDT.Select("NAME = 'GA_2'")(0)("X") Then
|
||||
|
||||
Exit Sub
|
||||
End If
|
||||
End If
|
||||
' Exit Sub
|
||||
' End If
|
||||
'End If
|
||||
End If
|
||||
|
||||
Dim gpInside As Boolean = Calculate_Triangle_Bool(gp, p0, p1, p2)
|
||||
|
|
@ -460,95 +478,129 @@ Public Class Multiple_Drawing
|
|||
Dim insertIndex As Integer = 0
|
||||
If gpInside = False Then
|
||||
' If false => new point at side rpDR("SIDE")+1
|
||||
Dim side As Integer = 0
|
||||
If rpDR("SIDE") + 1 > 4 Then
|
||||
side = rpDR("SIDE") + 1 - 4
|
||||
Else
|
||||
side = rpDR("SIDE") + 1
|
||||
End If
|
||||
|
||||
' FIXA: GA punkten tas bort innan vi behöver den här
|
||||
If side = 1 Then
|
||||
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") - GApDT.Select("NAME = 'GA_1'")(0)("X")
|
||||
Dim z As Double = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") - rpDR("Y")
|
||||
Dim x As Decimal = 0
|
||||
If pointName.Split("_")(1) = 1 Then
|
||||
x = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X") - GApDT.Select("NAME = 'GA_1'")(0)("X")
|
||||
Else
|
||||
x = GApDT.Select("NAME = 'GA_2'")(0)("X") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X")
|
||||
End If
|
||||
Dim c As Decimal = GApDT.Select("NAME = 'GA_1'")(0)("Y") - rpDR("Y")
|
||||
Dim z As Decimal = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") - rpDR("Y")
|
||||
newDR("X") = GApDT.Select("NAME = 'GA_1'")(0)("X") + c * x / z ' Triangle likformighet
|
||||
newDR("Y") = GApDT.Select("NAME = 'GA_1'")(0)("Y")
|
||||
ElseIf side = 2 Then
|
||||
Dim c As Double = GApDT.Select("NAME = 'GA_2'")(0)("X") - rpDR("X")
|
||||
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 x As Decimal = 0
|
||||
If pointName.Split("_")(1) = 1 Then
|
||||
x = GApDT.Select("NAME = 'GA_2'")(0)("Y") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y")
|
||||
Else
|
||||
x = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") - GApDT.Select("NAME = 'GA_3'")(0)("Y")
|
||||
End If
|
||||
Dim c As Decimal = GApDT.Select("NAME = 'GA_2'")(0)("X") - rpDR("X")
|
||||
Dim z As Decimal = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X") - rpDR("X")
|
||||
newDR("X") = GApDT.Select("NAME = 'GA_2'")(0)("X")
|
||||
newDR("Y") = GApDT.Select("NAME = 'GA_2'")(0)("Y") - c * x / z ' Triangle likformighet
|
||||
ElseIf side = 3 Then
|
||||
Dim c As Double = rpDR("Y") - GApDT.Select("NAME = 'GA_3'")(0)("Y")
|
||||
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 x As Decimal = 0
|
||||
If pointName.Split("_")(1) = 1 Then
|
||||
x = GApDT.Select("NAME = 'GA_3'")(0)("X") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X")
|
||||
Else
|
||||
x = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X") - GApDT.Select("NAME = 'GA_4'")(0)("X")
|
||||
End If
|
||||
Dim c As Decimal = rpDR("Y") - GApDT.Select("NAME = 'GA_3'")(0)("Y")
|
||||
Dim z As Decimal = rpDR("Y") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y")
|
||||
newDR("X") = GApDT.Select("NAME = 'GA_3'")(0)("X") - c * x / z ' Triangle likformighet
|
||||
newDR("Y") = GApDT.Select("NAME = 'GA_3'")(0)("Y")
|
||||
Else
|
||||
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") - GApDT.Select("NAME = 'GA_4'")(0)("Y")
|
||||
Dim z As Double = rpDR("X") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X")
|
||||
Dim x As Decimal = 0
|
||||
If pointName.Split("_")(1) = 1 Then
|
||||
x = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") - GApDT.Select("NAME = 'GA_4'")(0)("Y")
|
||||
Else
|
||||
x = GApDT.Select("NAME = 'GA_1'")(0)("Y") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y")
|
||||
End If
|
||||
Dim c As Decimal = rpDR("X") - GApDT.Select("NAME = 'GA_4'")(0)("X")
|
||||
Dim z As Decimal = rpDR("X") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X")
|
||||
newDR("X") = GApDT.Select("NAME = 'GA_4'")(0)("X")
|
||||
newDR("Y") = GApDT.Select("NAME = 'GA_4'")(0)("Y") + c * x / z ' Triangle likformighet
|
||||
End If
|
||||
|
||||
newDR("X") = Math.Round(newDR("X"), 3)
|
||||
newDR("Y") = Math.Round(newDR("Y"), 3)
|
||||
|
||||
insertIndex = Get_RowIndex(pDT, side, newDR("X"), newDR("Y"), GApDT) + 1
|
||||
Else
|
||||
' If true => remove point gp and new point at side rpDR("SIDE")+2
|
||||
Dim side As Integer = 0
|
||||
If rpDR("SIDE") + 2 > 4 Then
|
||||
side = rpDR("SIDE") + 2 - 4
|
||||
Dim temp As String = newDR("NAME")
|
||||
If temp.Split("_")(1) = 1 Then
|
||||
If side = 1 Then
|
||||
side = 4
|
||||
Else
|
||||
side -= 1
|
||||
End If
|
||||
Else
|
||||
side = rpDR("SIDE") + 2
|
||||
If side = 4 Then
|
||||
side = 1
|
||||
Else
|
||||
side += 1
|
||||
End If
|
||||
End If
|
||||
|
||||
'FIXA
|
||||
'If side = 1 Then
|
||||
' Dim c As Double = pDT.Select("NAME = 'P1'")(0)("Y") - rpDR("Y")
|
||||
' Dim x As Double = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X") - pDT.Select("NAME = 'P1'")(0)("X")
|
||||
' Dim z As Double = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") - rpDR("Y")
|
||||
' newDR("X") = pDT.Select("NAME = 'P1'")(0)("X") + c * x / z ' Triangle likformighet
|
||||
' newDR("Y") = pDT.Select("NAME = 'P1'")(0)("Y")
|
||||
'ElseIf side = 2 Then
|
||||
' Dim c As Double = pDT.Select("NAME = 'P2'")(0)("X") - rpDR("X")
|
||||
' Dim x As Double = pDT.Select("NAME = 'P2'")(0)("Y") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y")
|
||||
' Dim z As Double = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X") - rpDR("X")
|
||||
' newDR("X") = pDT.Select("NAME = 'P2'")(0)("X")
|
||||
' newDR("Y") = pDT.Select("NAME = 'P2'")(0)("Y") - c * x / z ' Triangle likformighet
|
||||
'ElseIf side = 3 Then
|
||||
' Dim c As Double = rpDR("Y") - pDT.Select("NAME = 'P3'")(0)("Y")
|
||||
' Dim x As Double = pDT.Select("NAME = 'P3'")(0)("X") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X")
|
||||
' Dim z As Double = rpDR("Y") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y")
|
||||
' newDR("X") = pDT.Select("NAME = 'P3'")(0)("X") - c * x / z ' Triangle likformighet
|
||||
' newDR("Y") = pDT.Select("NAME = 'P3'")(0)("Y")
|
||||
'Else
|
||||
' Dim c As Double = rpDR("X") - pDT.Select("NAME = 'P4'")(0)("X")
|
||||
' Dim x As Double = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") - pDT.Select("NAME = 'P4'")(0)("Y")
|
||||
' Dim z As Double = rpDR("X") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X")
|
||||
' newDR("X") = pDT.Select("NAME = 'P4'")(0)("X")
|
||||
' newDR("Y") = pDT.Select("NAME = 'P4'")(0)("Y") + c * x / z ' Triangle likformighet
|
||||
'End If
|
||||
If side = 1 Then
|
||||
Dim x As Decimal = rpDR("X") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X")
|
||||
Dim b As Decimal = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") - GApDT.Select("NAME = 'GA_1'")(0)("Y")
|
||||
Dim y As Decimal = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") - rpDR("Y")
|
||||
newDR("X") = GApDT.Select("NAME = 'GA_1'")(0)("X") + x * b / y - (GApDT.Select("NAME = 'GA_1'")(0)("X") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X")) ' Triangle likformighet
|
||||
newDR("Y") = GApDT.Select("NAME = 'GA_1'")(0)("Y")
|
||||
ElseIf side = 2 Then
|
||||
Dim x As Decimal = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") - rpDR("Y")
|
||||
Dim b As Decimal = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X") - GApDT.Select("NAME = 'GA_2'")(0)("X")
|
||||
Dim y As Decimal = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X") - rpDR("X")
|
||||
newDR("X") = GApDT.Select("NAME = 'GA_2'")(0)("X")
|
||||
newDR("Y") = GApDT.Select("NAME = 'GA_2'")(0)("Y") - x * b / y + (Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") - GApDT.Select("NAME = 'GA_2'")(0)("Y")) ' Triangle likformighet
|
||||
ElseIf side = 3 Then
|
||||
Dim x As Decimal = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X") - rpDR("X")
|
||||
Dim b As Decimal = GApDT.Select("NAME = 'GA_3'")(0)("Y") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y")
|
||||
Dim y As Decimal = rpDR("Y") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y")
|
||||
newDR("X") = GApDT.Select("NAME = 'GA_3'")(0)("X") - x * b / y + (Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X") - GApDT.Select("NAME = 'GA_3'")(0)("X")) ' Triangle likformighet
|
||||
newDR("Y") = GApDT.Select("NAME = 'GA_3'")(0)("Y")
|
||||
Else
|
||||
Dim x As Decimal = rpDR("Y") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y")
|
||||
Dim b As Decimal = GApDT.Select("NAME = 'GA_4'")(0)("X") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X")
|
||||
Dim y As Decimal = rpDR("X") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X")
|
||||
newDR("X") = GApDT.Select("NAME = 'GA_4'")(0)("X")
|
||||
newDR("Y") = GApDT.Select("NAME = 'GA_4'")(0)("Y") + x * b / y - (GApDT.Select("NAME = 'GA_4'")(0)("Y") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y")) ' Triangle likformighet
|
||||
End If
|
||||
|
||||
insertIndex = Get_RowIndex(pDT, side, newDR("X"), newDR("Y"), GApDT)
|
||||
|
||||
pDT.Rows.RemoveAt(insertIndex)
|
||||
If pointName.Split("_")(1) = 1 Then
|
||||
pDT.Rows.RemoveAt(insertIndex)
|
||||
Else
|
||||
If pDT.Rows.Count > insertIndex + 1 Then
|
||||
pDT.Rows.RemoveAt(insertIndex + 1)
|
||||
insertIndex += 1
|
||||
Else
|
||||
pDT.Rows.RemoveAt(0)
|
||||
insertIndex = 0
|
||||
End If
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
pDT.Rows.InsertAt(newDR, insertIndex)
|
||||
End Sub
|
||||
|
||||
Private Shared Function Calculate_Triangle_Bool(gp As Double(), p0 As Double(), p1 As Double(), p2 As Double())
|
||||
Private Shared Function Calculate_Triangle_Bool(gp As Decimal(), p0 As Decimal(), p1 As Decimal(), p2 As Decimal())
|
||||
|
||||
Dim s As Double = p0(1) * p2(0) - p0(0) * p2(1) + (p2(1) - p0(1)) * gp(0) + (p0(0) - p2(0)) * gp(1)
|
||||
Dim t As Double = p0(0) * p1(1) - p0(1) * p1(0) + (p0(1) - p1(1)) * gp(0) + (p1(0) - p0(0)) * gp(1)
|
||||
Dim s As Decimal = p0(1) * p2(0) - p0(0) * p2(1) + (p2(1) - p0(1)) * gp(0) + (p0(0) - p2(0)) * gp(1)
|
||||
Dim t As Decimal = p0(0) * p1(1) - p0(1) * p1(0) + (p0(1) - p1(1)) * gp(0) + (p1(0) - p0(0)) * gp(1)
|
||||
|
||||
If (s < 0 AndAlso t >= 0) OrElse (s >= 0 AndAlso t < 0) Then
|
||||
Return False
|
||||
End If
|
||||
|
||||
Dim area As Double = -p1(1) * p2(0) + p0(1) * (p2(0) - p1(0)) + p0(0) * (p1(1) - p2(1)) + p1(0) * p2(1)
|
||||
Dim area As Decimal = -p1(1) * p2(0) + p0(1) * (p2(0) - p1(0)) + p0(0) * (p1(1) - p2(1)) + p1(0) * p2(1)
|
||||
|
||||
If area < 0 Then
|
||||
If s <= 0 AndAlso s + t >= area Then
|
||||
|
|
|
|||
Loading…
Reference in New Issue