Still some errors for angle recess (obsolete and points being removed)

This commit is contained in:
Anton 2021-04-16 15:37:55 +02:00
parent 66a8c1d3c1
commit a7e7b47633
7 changed files with 259 additions and 88 deletions

View File

@ -57,6 +57,7 @@
pointsMeasurements.Add("Wmes", {2, 3, 2}) pointsMeasurements.Add("Wmes", {2, 3, 2})
recessData.Columns.Add("RECESS TYPE", GetType(String)) recessData.Columns.Add("RECESS TYPE", GetType(String))
recessData.Columns.Add("NAME", GetType(String))
recessData.Columns.Add("CORNER", GetType(Integer)) recessData.Columns.Add("CORNER", GetType(Integer))
recessData.Columns.Add("SIDE", GetType(Integer)) recessData.Columns.Add("SIDE", GetType(Integer))
recessData.Columns.Add("WIDTH", GetType(Integer)) recessData.Columns.Add("WIDTH", GetType(Integer))

View File

@ -124,6 +124,7 @@
Dim dY As Decimal = Individual.Panel_Recesses.Controls("Y_TextBox").Text / 1000 Dim dY As Decimal = Individual.Panel_Recesses.Controls("Y_TextBox").Text / 1000
Data.recessData.Rows.Add() Data.recessData.Rows.Add()
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("NAME") = "CA" & cornerAngleCounter
For i = 2 To Data.pointsMeasurements.Count - 1 For i = 2 To Data.pointsMeasurements.Count - 1
Dim mesName As String = Data.pointsMeasurements.Keys(i) Dim mesName As String = Data.pointsMeasurements.Keys(i)

View File

@ -123,6 +123,7 @@
Dim dY As Decimal = Individual.Panel_Recesses.Controls("Y_TextBox").Text / 1000 Dim dY As Decimal = Individual.Panel_Recesses.Controls("Y_TextBox").Text / 1000
Data.recessData.Rows.Add() Data.recessData.Rows.Add()
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("NAME") = "CR" & cornerRectangleCounter
For i = 2 To Data.pointsMeasurements.Count - 1 For i = 2 To Data.pointsMeasurements.Count - 1
Dim mesName As String = Data.pointsMeasurements.Keys(i) Dim mesName As String = Data.pointsMeasurements.Keys(i)

View File

@ -103,6 +103,7 @@
Dim mesNum As Integer = Data.pointsMeasurements.Count - 1 Dim mesNum As Integer = Data.pointsMeasurements.Count - 1
Data.recessData.Rows.Add() Data.recessData.Rows.Add()
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("NAME") = "MS" & numOfMiddleRectangles
Dim pointRow1 As DataRow = Data.gratingMiddlePoints.NewRow Dim pointRow1 As DataRow = Data.gratingMiddlePoints.NewRow
Dim pointRow2 As DataRow = Data.gratingMiddlePoints.NewRow Dim pointRow2 As DataRow = Data.gratingMiddlePoints.NewRow
@ -135,7 +136,6 @@
numOfMiddleRectangles += 1 numOfMiddleRectangles += 1
Dim sidePoints3 As New List(Of Integer) Dim sidePoints3 As New List(Of Integer)
For j = 2 To Data.gratingPoints.Rows.Count - 1 For j = 2 To Data.gratingPoints.Rows.Count - 1
If Data.gratingPoints.Rows(j)("GUI Y") = Data.grossAreaPoints.Rows(2)("GUI Y") Then If Data.gratingPoints.Rows(j)("GUI Y") = Data.grossAreaPoints.Rows(2)("GUI Y") Then

View File

@ -285,6 +285,7 @@
Dim mesNum As Integer = Data.pointsMeasurements.Count - 1 Dim mesNum As Integer = Data.pointsMeasurements.Count - 1
Data.recessData.Rows.Add() Data.recessData.Rows.Add()
Data.recessData.Rows(Data.recessData.Rows.Count - 1)("NAME") = "CS" & numOfSideRectangles
Dim pointRow1 As DataRow = Data.gratingPoints.NewRow Dim pointRow1 As DataRow = Data.gratingPoints.NewRow
Dim pointRow2 As DataRow = Data.gratingPoints.NewRow Dim pointRow2 As DataRow = Data.gratingPoints.NewRow

View File

@ -435,7 +435,7 @@ Public Class Multiple_3D
Private Shared Sub Delete_Obsolete() Private Shared Sub Delete_Obsolete()
Dim listOfObsolete As New List(Of Integer) Dim listOfObsolete As List(Of Integer)
listOfObsolete = Find_Obsolete() listOfObsolete = Find_Obsolete()
Dim swApp As SldWorks.SldWorks Dim swApp As SldWorks.SldWorks
@ -459,7 +459,7 @@ Public Class Multiple_3D
Next Next
End Sub End Sub
Private Shared Function Find_Obsolete() Public Shared Function Find_Obsolete()
Dim listOfObsolete As New List(Of Integer) Dim listOfObsolete As New List(Of Integer)
For i = 0 To Grating_Fill.numOfVertical * Grating_Fill.numOfHorizontal - 1 For i = 0 To Grating_Fill.numOfVertical * Grating_Fill.numOfHorizontal - 1

View File

@ -88,8 +88,10 @@ Public Class Multiple_Drawing
' --- Assembly --- ' --- Assembly ---
Dim assembly As IAssemblyDoc Dim assembly As IAssemblyDoc
Dim AssemblyExtension As SldWorks.ModelDocExtension
Model = swApp.NewDocument("C:\ProgramData\SolidWorks\SOLIDWORKS 2020\templates\Assembly.asmdot", 0, 0, 0) Model = swApp.NewDocument("C:\ProgramData\SolidWorks\SOLIDWORKS 2020\templates\Assembly.asmdot", 0, 0, 0)
assembly = Model assembly = Model
AssemblyExtension = assembly.Extension
Dim compNames(numOfGratings - 1) As String Dim compNames(numOfGratings - 1) As String
Dim coordNames(numOfGratings - 1) As String Dim coordNames(numOfGratings - 1) As String
@ -102,7 +104,24 @@ Public Class Multiple_Drawing
Dim assemComps As Object Dim assemComps As Object
assemComps = assembly.AddComponents3((compNames), (transMatrix), (coordNames)) assemComps = assembly.AddComponents3((compNames), (transMatrix), (coordNames))
Model.ViewZoomtofit2()
longstatus = Model.SaveAs3(Settings.folderPaths("object_" & Data.objectNum & "_models3D_gratings_sw_support") & "\simplified_grating_assembly.SLDASM", 0, 0) longstatus = Model.SaveAs3(Settings.folderPaths("object_" & Data.objectNum & "_models3D_gratings_sw_support") & "\simplified_grating_assembly.SLDASM", 0, 0)
' --- Delete Obsolete ---
Dim listOfObsolete As List(Of Integer)
listOfObsolete = Multiple_3D.Find_Obsolete()
For i = 0 To listOfObsolete.Count - 1
assembly.ClearSelection2(True)
boolstatus = AssemblyExtension.SelectByID2("simplified_grating_" & listOfObsolete(i) & "-1@simplified_grating_assembly", "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)
assembly.EditDelete
My.Computer.FileSystem.DeleteFile(Settings.folderPaths("object_" & Data.objectNum & "_models3D_gratings_sw_support") & "\simplified_grating_" & listOfObsolete(i) & ".SLDPRT")
Next
Dim swErrors As Integer
Dim swWarnings As Integer
boolstatus = assembly.Save3(1, swErrors, swWarnings)
End Sub End Sub
Private Shared Function Create_GratingPoints() Private Shared Function Create_GratingPoints()
@ -239,6 +258,139 @@ Public Class Multiple_Drawing
Next Next
Next Next
' --- intersecting recesses ---
For Each DR As DataRow In Data.recessData.Rows
If DR("RECESS TYPE") = "ANGLE" Then
Dim recessName As String = DR("NAME")
Dim recessAlreadyOK As Boolean = False
For Each DR2 As DataRow In recessPointsDT.Rows
Dim pointName As String = DR2("NAME")
If pointName.Substring(0, 3) = recessName Then
recessAlreadyOK = True
Exit For
End If
Next
If recessAlreadyOK = True Then
Continue For
End If
' Recess points
Dim p0(1) As Decimal
Dim p1(1) As Decimal
Dim p2(1) As Decimal
p0(0) = Data.gratingPoints.Select("NAME = '" & recessName & "_1" & "'")(0)("X")
p0(1) = Data.gratingPoints.Select("NAME = '" & recessName & "_1" & "'")(0)("Y")
p1(0) = Data.gratingPoints.Select("NAME = '" & recessName & "_2" & "'")(0)("X")
p1(1) = Data.gratingPoints.Select("NAME = '" & recessName & "_2" & "'")(0)("Y")
If DR("CORNER") = 1 OrElse DR("CORNER") = 3 Then
p2(0) = p0(0)
p2(1) = p1(1)
Else
p2(0) = p1(0)
p2(1) = p0(1)
End If
Dim pointsInRecess As New Dictionary(Of String, Boolean)
For Each pDR As DataRow In pointsDT.Rows
Dim gp(1) As Decimal
gp(0) = pDR("X")
gp(1) = pDR("Y")
pointsInRecess.Add(pDR("NAME"), Calculate_Triangle_Bool(gp, p0, p1, p2))
Next
Dim numOfPInRec As Integer = 0
For Each bool As Boolean In pointsInRecess.Values
If bool = True Then
numOfPInRec += 1
End If
Next
If numOfPInRec = 0 OrElse numOfPInRec = 4 Then
Continue For
End If
' - Straight line equation: y = kx + m
Dim k As Decimal = (p1(1) - p0(1)) / (p1(0) - p0(0))
Dim m As Decimal = p0(1) - (k * p0(0))
Dim npDR As DataRow
Dim x1 As Decimal = (GAPointsDT.Rows(0)("Y") - m) / k
If x1 > GAPointsDT.Rows(0)("X") AndAlso x1 < GAPointsDT.Rows(1)("X") Then
' lägg till sida 1
npDR = pointsDT.NewRow()
npDR("NAME") = recessName & "_1" ' fixa
npDR("TYPE") = "Recess CA"
npDR("X") = x1
npDR("Y") = GAPointsDT.Rows(0)("Y")
Dim inIndex As Integer = Get_RowIndex(pointsDT, 1, npDR("X"), npDR("Y"), GAPointsDT)
pointsDT.Rows.InsertAt(npDR, inIndex + 1)
End If
Dim y2 As Decimal = k * GAPointsDT.Rows(1)("X") + m
If y2 < GAPointsDT.Rows(1)("Y") AndAlso y2 > GAPointsDT.Rows(2)("Y") Then
' lägg till sida 2
npDR = pointsDT.NewRow()
npDR("NAME") = recessName & "_2" ' fixa
npDR("TYPE") = "Recess CA"
npDR("X") = GAPointsDT.Rows(1)("X")
npDR("Y") = y2
Dim inIndex As Integer = Get_RowIndex(pointsDT, 2, npDR("X"), npDR("Y"), GAPointsDT)
pointsDT.Rows.InsertAt(npDR, inIndex + 1)
End If
Dim x3 As Decimal = (GAPointsDT.Rows(2)("Y") - m) / k
If x3 < GAPointsDT.Rows(2)("X") AndAlso x3 > GAPointsDT.Rows(3)("X") Then
' lägg till sida 3
npDR = pointsDT.NewRow()
npDR("NAME") = recessName & "_3" ' fixa
npDR("TYPE") = "Recess CA"
npDR("X") = x3
npDR("Y") = GAPointsDT.Rows(2)("Y")
Dim inIndex As Integer = Get_RowIndex(pointsDT, 3, npDR("X"), npDR("Y"), GAPointsDT)
pointsDT.Rows.InsertAt(npDR, inIndex + 1)
End If
Dim y4 As Decimal = k * GAPointsDT.Rows(3)("X") + m
If y4 > GAPointsDT.Rows(3)("Y") AndAlso y4 < GAPointsDT.Rows(0)("Y") Then
' lägg till sida 4
npDR = pointsDT.NewRow()
npDR("NAME") = recessName & "_4" ' fixa
npDR("TYPE") = "Recess CA"
npDR("X") = GAPointsDT.Rows(3)("X")
npDR("Y") = y4
Dim inIndex As Integer = Get_RowIndex(pointsDT, 4, npDR("X"), npDR("Y"), GAPointsDT)
pointsDT.Rows.InsertAt(npDR, inIndex + 1)
End If
For Each key As String In pointsInRecess.Keys
If pointsInRecess(key) = True Then
Dim removeIndex As Integer = 0
For k = 0 To pointsDT.Rows.Count - 1
If pointsDT.Rows(k)("NAME") = key Then
removeIndex = k
End If
Next
pointsDT.Rows.RemoveAt(removeIndex)
End If
Next
End If
Next
' --- Point on grating side - recesses ---
For Each DR As DataRow In recessPointsDT.Rows For Each DR As DataRow In recessPointsDT.Rows
If DR("TYPE") = "Corner Angle" Then If DR("TYPE") = "Corner Angle" Then
Dim pointName As String = DR("NAME") Dim pointName As String = DR("NAME")
@ -275,7 +427,7 @@ Public Class Multiple_Drawing
cornerPoint(0) = GAPointsDT.Select("NAME = 'GA_" & pointNumGA & "'")(0)("X") cornerPoint(0) = GAPointsDT.Select("NAME = 'GA_" & pointNumGA & "'")(0)("X")
cornerPoint(1) = GAPointsDT.Select("NAME = 'GA_" & pointNumGA & "'")(0)("Y") cornerPoint(1) = GAPointsDT.Select("NAME = 'GA_" & pointNumGA & "'")(0)("Y")
Create_SecondAnglePoint(pointsDT, DR, cornerPoint, GAPointsDT, recessPointsDT) Create_SecondAnglePoint(pointsDT, DR, cornerPoint, GAPointsDT, recessPointsDT, "")
Else Else
Dim DR3 As DataRow = pointsDT.NewRow() Dim DR3 As DataRow = pointsDT.NewRow()
DR3("NAME") = DR("NAME") DR3("NAME") = DR("NAME")
@ -300,7 +452,7 @@ Public Class Multiple_Drawing
cornerPoint(0) = GAPointsDT.Select("NAME = 'GA_" & pointNumGA & "'")(0)("X") cornerPoint(0) = GAPointsDT.Select("NAME = 'GA_" & pointNumGA & "'")(0)("X")
cornerPoint(1) = GAPointsDT.Select("NAME = 'GA_" & pointNumGA & "'")(0)("Y") cornerPoint(1) = GAPointsDT.Select("NAME = 'GA_" & pointNumGA & "'")(0)("Y")
Create_SecondAnglePoint(pointsDT, DR, cornerPoint, GAPointsDT, recessPointsDT) Create_SecondAnglePoint(pointsDT, DR, cornerPoint, GAPointsDT, recessPointsDT, "GA_" & pointNumGA)
End If End If
End If End If
Next Next
@ -320,6 +472,9 @@ Public Class Multiple_Drawing
If side = 1 Then If side = 1 Then
Dim sidePoints = pDT.Select("Y = '" & pY & "'") Dim sidePoints = pDT.Select("Y = '" & pY & "'")
If sidePoints.Length = 0 Then
newX = GApDT.Select("NAME = 'GA_1'")(0)("X")
End If
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")
@ -330,6 +485,9 @@ Public Class Multiple_Drawing
Next Next
ElseIf side = 2 Then ElseIf side = 2 Then
Dim sidePoints = pDT.Select("X = '" & pX & "'") Dim sidePoints = pDT.Select("X = '" & pX & "'")
If sidePoints.Length = 0 Then
newY = GApDT.Select("NAME = 'GA_2'")(0)("Y")
End If
For Each DR2 As DataRow In sidePoints For Each DR2 As DataRow In sidePoints
If DR2("Y") > pY Then If DR2("Y") > pY Then
rowName = DR2("NAME") rowName = DR2("NAME")
@ -340,6 +498,9 @@ Public Class Multiple_Drawing
Next Next
ElseIf side = 3 Then ElseIf side = 3 Then
Dim sidePoints = pDT.Select("Y = '" & pY & "'") Dim sidePoints = pDT.Select("Y = '" & pY & "'")
If sidePoints.Length = 0 Then
newX = GApDT.Select("NAME = 'GA_3'")(0)("X")
End If
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")
@ -350,36 +511,44 @@ Public Class Multiple_Drawing
Next Next
Else Else
Dim sidePoints = pDT.Select("X = '" & pX & "'") Dim sidePoints = pDT.Select("X = '" & pX & "'")
If sidePoints(0)("NAME") = "GA_1" Then If sidePoints.Length = 0 Then
Dim pointList As New List(Of DataRow) newY = GApDT.Select("NAME = 'GA_4'")(0)("Y")
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 Else
For Each DR2 As DataRow In sidePoints If sidePoints(0)("NAME") = "GA_1" Then
If DR2("Y") < pY Then Dim pointList As New List(Of DataRow)
rowName = DR2("NAME") For i = 1 To sidePoints.Length - 1
Else pointList.Add(sidePoints(i))
newY = GApDT.Select("NAME = 'GA_4'")(0)("Y") Next
Exit For pointList.Add(sidePoints(0))
End If
Next 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 End If
End If End If
Dim index As Integer = 0 Dim index As Integer = 0
If rowName = "" Then If rowName = "" Then
index = Get_RowIndex(pDT, side - 1, newX, newY, GApDT) Dim newSide As Integer = side - 1
If newSide = 0 Then
newSide = 4
End If
index = Get_RowIndex(pDT, newSide, newX, newY, GApDT)
Else Else
For j = 0 To pDT.Rows.Count - 1 For j = 0 To pDT.Rows.Count - 1
If pDT.Rows(j)("NAME") = rowName Then If pDT.Rows(j)("NAME") = rowName Then
@ -392,7 +561,7 @@ Public Class Multiple_Drawing
Return index Return index
End Function End Function
Private Shared Sub Create_SecondAnglePoint(pDT As DataTable, rpDR As DataRow, gp As Decimal(), GApDT As DataTable, rDT As DataTable) Private Shared Sub Create_SecondAnglePoint(pDT As DataTable, rpDR As DataRow, gp As Decimal(), GApDT As DataTable, rDT As DataTable, pNameToRemove As String)
Dim p0(1) As Decimal Dim p0(1) As Decimal
Dim p1(1) As Decimal Dim p1(1) As Decimal
Dim p2(1) As Decimal Dim p2(1) As Decimal
@ -443,34 +612,9 @@ 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 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 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
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 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 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
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)
@ -478,51 +622,54 @@ Public Class Multiple_Drawing
Dim insertIndex As Integer = 0 Dim insertIndex As Integer = 0
If gpInside = False Then If gpInside = False Then
' If false => new point at side rpDR("SIDE")+1 ' If false => new point at side rpDR("SIDE")+1
If side = 1 Then If side = 1 Then
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")
Dim x As Decimal = 0 Dim x As Decimal = 0
If pointName.Split("_")(1) = 1 Then If pointName.Split("_")(1) = 1 Then
x = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X") - GApDT.Select("NAME = 'GA_1'")(0)("X") x = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X") - GApDT.Select("NAME = 'GA_1'")(0)("X")
newDR("X") = GApDT.Select("NAME = 'GA_1'")(0)("X") + c * x / z ' Triangle likformighet
Else Else
x = GApDT.Select("NAME = 'GA_2'")(0)("X") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X") x = GApDT.Select("NAME = 'GA_2'")(0)("X") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X")
newDR("X") = GApDT.Select("NAME = 'GA_2'")(0)("X") - c * x / z ' Triangle likformighet
End If 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") newDR("Y") = GApDT.Select("NAME = 'GA_1'")(0)("Y")
ElseIf side = 2 Then ElseIf side = 2 Then
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")
Dim x As Decimal = 0 Dim x As Decimal = 0
If pointName.Split("_")(1) = 1 Then If pointName.Split("_")(1) = 1 Then
x = GApDT.Select("NAME = 'GA_2'")(0)("Y") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") x = GApDT.Select("NAME = 'GA_2'")(0)("Y") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y")
newDR("Y") = GApDT.Select("NAME = 'GA_2'")(0)("Y") - c * x / z ' Triangle likformighet
Else Else
x = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") - GApDT.Select("NAME = 'GA_3'")(0)("Y") x = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") - GApDT.Select("NAME = 'GA_3'")(0)("Y")
newDR("Y") = GApDT.Select("NAME = 'GA_3'")(0)("Y") + c * x / z ' Triangle likformighet
End If 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("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 ElseIf side = 3 Then
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")
Dim x As Decimal = 0 Dim x As Decimal = 0
If pointName.Split("_")(1) = 1 Then If pointName.Split("_")(1) = 1 Then
x = GApDT.Select("NAME = 'GA_3'")(0)("X") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X") x = GApDT.Select("NAME = 'GA_3'")(0)("X") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X")
newDR("X") = GApDT.Select("NAME = 'GA_3'")(0)("X") - c * x / z ' Triangle likformighet
Else Else
x = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X") - GApDT.Select("NAME = 'GA_4'")(0)("X") x = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X") - GApDT.Select("NAME = 'GA_4'")(0)("X")
newDR("X") = GApDT.Select("NAME = 'GA_4'")(0)("X") + c * x / z ' Triangle likformighet
End If 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") newDR("Y") = GApDT.Select("NAME = 'GA_3'")(0)("Y")
Else Else
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")
Dim x As Decimal = 0 Dim x As Decimal = 0
If pointName.Split("_")(1) = 1 Then If pointName.Split("_")(1) = 1 Then
x = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") - GApDT.Select("NAME = 'GA_4'")(0)("Y") x = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") - GApDT.Select("NAME = 'GA_4'")(0)("Y")
newDR("Y") = GApDT.Select("NAME = 'GA_4'")(0)("Y") + c * x / z ' Triangle likformighet
Else Else
x = GApDT.Select("NAME = 'GA_1'")(0)("Y") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") x = GApDT.Select("NAME = 'GA_1'")(0)("Y") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y")
newDR("Y") = GApDT.Select("NAME = 'GA_1'")(0)("Y") - c * x / z ' Triangle likformighet
End If 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("X") = GApDT.Select("NAME = 'GA_4'")(0)("X")
newDR("Y") = GApDT.Select("NAME = 'GA_4'")(0)("Y") + c * x / z ' Triangle likformighet
End If End If
newDR("X") = Math.Round(newDR("X"), 3) newDR("X") = Math.Round(newDR("X"), 3)
@ -548,47 +695,67 @@ Public Class Multiple_Drawing
If side = 1 Then If side = 1 Then
Dim x As Decimal = rpDR("X") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X") 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") 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 Dim b As Decimal = 0
If pointName.Split("_")(1) = 1 Then
b = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") - GApDT.Select("NAME = 'GA_1'")(0)("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
Else
b = GApDT.Select("NAME = 'GA_2'")(0)("Y") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y")
newDR("X") = GApDT.Select("NAME = 'GA_2'")(0)("X") - x * b / y + (Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X") - GApDT.Select("NAME = 'GA_2'")(0)("X")) ' Triangle likformighet
End If
newDR("Y") = GApDT.Select("NAME = 'GA_1'")(0)("Y") newDR("Y") = GApDT.Select("NAME = 'GA_1'")(0)("Y")
ElseIf side = 2 Then ElseIf side = 2 Then
Dim x As Decimal = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") - rpDR("Y") 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") Dim y As Decimal = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X") - rpDR("X")
Dim b As Decimal = 0
If pointName.Split("_")(1) = 1 Then
b = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("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"))
Else
b = GApDT.Select("NAME = 'GA_3'")(0)("X") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X")
newDR("Y") = GApDT.Select("NAME = 'GA_3'")(0)("Y") + x * b / y - (GApDT.Select("NAME = 'GA_3'")(0)("Y") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y"))
End If
newDR("X") = GApDT.Select("NAME = 'GA_2'")(0)("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 ElseIf side = 3 Then
Dim x As Decimal = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X") - rpDR("X") 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") 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 Dim b As Decimal = 0
If pointName.Split("_")(1) = 1 Then
b = GApDT.Select("NAME = 'GA_3'")(0)("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"))
Else
b = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") - GApDT.Select("NAME = 'GA_4'")(0)("Y")
newDR("X") = GApDT.Select("NAME = 'GA_4'")(0)("X") + x * b / y - (GApDT.Select("NAME = 'GA_4'")(0)("X") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X"))
End If
newDR("Y") = GApDT.Select("NAME = 'GA_3'")(0)("Y") newDR("Y") = GApDT.Select("NAME = 'GA_3'")(0)("Y")
Else Else
Dim x As Decimal = rpDR("Y") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") 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") Dim y As Decimal = rpDR("X") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X")
Dim b As Decimal = 0
If pointName.Split("_")(1) = 1 Then
b = GApDT.Select("NAME = 'GA_4'")(0)("X") - Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(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"))
Else
b = Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("X") - GApDT.Select("NAME = 'GA_1'")(0)("X")
newDR("Y") = GApDT.Select("NAME = 'GA_1'")(0)("Y") - x * b / y + (Data.gratingPoints.Select("NAME = '" & newDR("NAME") & "'")(0)("Y") - GApDT.Select("NAME = 'GA_1'")(0)("Y"))
End If
newDR("X") = GApDT.Select("NAME = 'GA_4'")(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 End If
insertIndex = Get_RowIndex(pDT, side, newDR("X"), newDR("Y"), GApDT) insertIndex = Get_RowIndex(pDT, side, newDR("X"), newDR("Y"), GApDT)
If pointName.Split("_")(1) = 1 Then pDT.Rows.InsertAt(newDR, insertIndex + 1)
pDT.Rows.RemoveAt(insertIndex)
Else Dim removeIndex As Integer = 0
If pDT.Rows.Count > insertIndex + 1 Then For k = 0 To pDT.Rows.Count - 1
pDT.Rows.RemoveAt(insertIndex + 1) If pDT.Rows(k)("NAME") = pNameToRemove Then
insertIndex += 1 removeIndex = k
Else
pDT.Rows.RemoveAt(0)
insertIndex = 0
End If End If
End If Next
pDT.Rows.RemoveAt(removeIndex)
End If End If
pDT.Rows.InsertAt(newDR, insertIndex)
End Sub End Sub
Private Shared Function Calculate_Triangle_Bool(gp As Decimal(), p0 As Decimal(), p1 As Decimal(), p2 As Decimal()) Private Shared Function Calculate_Triangle_Bool(gp As Decimal(), p0 As Decimal(), p1 As Decimal(), p2 As Decimal())