Optimize length of fill function

This commit is contained in:
Mans 2021-03-02 12:31:54 +01:00
parent a71efb2a49
commit 5feacbdc42
10 changed files with 85 additions and 34 deletions

Binary file not shown.

View File

@ -4,7 +4,7 @@ H,20,3,93,52,39,23,14,9.5,6.7,4.9,3.7,2.8,2.2,1.8,1.4,1.2,1.0,0.6,0.5,0.4
H,25,2,97,54,35,24,18,12,9,6.4,4.8,3.7,2.9,2.3,1.9,1.6,1.1,0.8,0.6,0.5 H,25,2,97,54,35,24,18,12,9,6.4,4.8,3.7,2.9,2.3,1.9,1.6,1.1,0.8,0.6,0.5
H,25,3,145,81,52,36,26,19,13,9.5,7.2,5.5,4.3,3.5,2.8,2.3,1.6,1.2,0.9,0.7 H,25,3,145,81,52,36,26,19,13,9.5,7.2,5.5,4.3,3.5,2.8,2.3,1.6,1.2,0.9,0.7
H,30,2,139,78,50,35,26,20,15,11,8.3,6.4,5.0,4.0,3.3,2.7,1.9,1.4,1.0,0.8 H,30,2,139,78,50,35,26,20,15,11,8.3,6.4,5.0,4.0,3.3,2.7,1.9,1.4,1.0,0.8
H,30,2,209,117,75,52,38,29,23,16,12,9.5,7.5,6.0,4.9,4.0,2.8,2.1,1.5,1.2 H,30,3,209,117,75,52,38,29,23,16,12,9.5,7.5,6.0,4.9,4.0,2.8,2.1,1.5,1.2
H,35,2,189,106,68,47,35,27,21,17,13,10,7.9,6.4,5.7,4.3,3.0,2.2,1.6,1.3 H,35,2,189,106,68,47,35,27,21,17,13,10,7.9,6.4,5.7,4.3,3.0,2.2,1.6,1.3
H,35,3,284,160,102,71,52,40,32,26,20,15,12,9.5,7.8,6.4,4.5,3.3,2.5,1.9 H,35,3,284,160,102,71,52,40,32,26,20,15,12,9.5,7.8,6.4,4.5,3.3,2.5,1.9
H,40,2,247,139,89,62,45,35,27,22,18,15,12,9.5,7.7,6.4,4.5,3.3,2.4,1.9 H,40,2,247,139,89,62,45,35,27,22,18,15,12,9.5,7.7,6.4,4.5,3.3,2.4,1.9

1 NAME [str] LB-HEIGHT [int] LB-THICKNESS [int] 300 [dbl] 400 [dbl] 500 [dbl] 600 [dbl] 700 [dbl] 800 [dbl] 900 [dbl] 1000 [dbl] 1100 [dbl] 1200 [dbl] 1300 [dbl] 1400 [dbl] 1500 [dbl] 1600 [dbl] 1800 [dbl] 2000 [dbl] 2200 [dbl] 2400 [dbl]
4 H 25 2 97 54 35 24 18 12 9 6.4 4.8 3.7 2.9 2.3 1.9 1.6 1.1 0.8 0.6 0.5
5 H 25 3 145 81 52 36 26 19 13 9.5 7.2 5.5 4.3 3.5 2.8 2.3 1.6 1.2 0.9 0.7
6 H 30 2 139 78 50 35 26 20 15 11 8.3 6.4 5.0 4.0 3.3 2.7 1.9 1.4 1.0 0.8
7 H 30 2 3 209 117 75 52 38 29 23 16 12 9.5 7.5 6.0 4.9 4.0 2.8 2.1 1.5 1.2
8 H 35 2 189 106 68 47 35 27 21 17 13 10 7.9 6.4 5.7 4.3 3.0 2.2 1.6 1.3
9 H 35 3 284 160 102 71 52 40 32 26 20 15 12 9.5 7.8 6.4 4.5 3.3 2.5 1.9
10 H 40 2 247 139 89 62 45 35 27 22 18 15 12 9.5 7.7 6.4 4.5 3.3 2.4 1.9

Binary file not shown.

View File

@ -206,7 +206,7 @@
Dim angleQuadrant As String = Data.angleRecessPoints.Rows(i)("QUADRANT") Dim angleQuadrant As String = Data.angleRecessPoints.Rows(i)("QUADRANT")
Dim p1XGUI, p1YGUI, p2XGUI, p2YGUI As Integer Dim p1XGUI, p1YGUI, p2XGUI, p2YGUI As Integer
For Each DR As DataRow In Data.gratingPoints.Rows For Each DR As DataRow In Data.gratingPoints.Rows
If DR("NAME").Split("_")(0) = "CA" & angleQuadrant Then If DR("NAME").Split("_")(0) = "CA" & i + 1 Then
Dim index As Integer = Data.gratingPoints.Rows.IndexOf(DR) Dim index As Integer = Data.gratingPoints.Rows.IndexOf(DR)
p1XGUI = Data.gratingPoints.Rows(index)("GUI X") p1XGUI = Data.gratingPoints.Rows(index)("GUI X")
p1YGUI = Data.gratingPoints.Rows(index)("GUI Y") p1YGUI = Data.gratingPoints.Rows(index)("GUI Y")
@ -247,14 +247,15 @@
Dim dashPen As Pen = New Pen(Color.DarkGray, 1) Dim dashPen As Pen = New Pen(Color.DarkGray, 1)
dashPen.DashPattern = {2, 4} dashPen.DashPattern = {2, 4}
Dim singleLength As Integer = Grating_Fill.maxSingleLength / Data.scaleDiff Dim singleLength As Integer = Grating_Fill.minLength / Data.scaleDiff
For i = 0 To Grating_Fill.numOfHorizontal - 2 For i = 0 To Grating_Fill.numOfHorizontal - 2
Dim x As Integer Dim x As Integer
If Grating_Fill.lengthRevNeeded AndAlso i = Grating_Fill.numOfHorizontal - 2 Then x = Data.grossAreaPoints.Rows(0)("GUI X") + singleLength * (i + 1)
x = Data.grossAreaPoints.Rows(0)("GUI X") + singleLength * i + Grating_Fill.revLength / Data.scaleDiff 'If Grating_Fill.lengthRevNeeded AndAlso i = Grating_Fill.numOfHorizontal - 2 Then
Else ' x = Data.grossAreaPoints.Rows(0)("GUI X") + singleLength * i + Grating_Fill.revLength / Data.scaleDiff
x = Data.grossAreaPoints.Rows(0)("GUI X") + singleLength * (i + 1) 'Else
End If 'x = Data.grossAreaPoints.Rows(0)("GUI X") + singleLength * (i + 1)
'End If
Dim y1 As Integer = Data.grossAreaPoints.Rows(0)("GUI Y") Dim y1 As Integer = Data.grossAreaPoints.Rows(0)("GUI Y")
Dim y2 As Integer = Data.grossAreaPoints.Rows(3)("GUI Y") Dim y2 As Integer = Data.grossAreaPoints.Rows(3)("GUI Y")
e.Graphics.DrawLine(dashPen, x, y1, x, y2) e.Graphics.DrawLine(dashPen, x, y1, x, y2)

View File

@ -98,7 +98,7 @@ Partial Class Individual
'Button_Back 'Button_Back
' '
Me.Button_Back.Location = New System.Drawing.Point(9, 10) Me.Button_Back.Location = New System.Drawing.Point(9, 10)
Me.Button_Back.Margin = New System.Windows.Forms.Padding(2, 2, 2, 2) Me.Button_Back.Margin = New System.Windows.Forms.Padding(2)
Me.Button_Back.Name = "Button_Back" Me.Button_Back.Name = "Button_Back"
Me.Button_Back.Size = New System.Drawing.Size(42, 33) Me.Button_Back.Size = New System.Drawing.Size(42, 33)
Me.Button_Back.TabIndex = 27 Me.Button_Back.TabIndex = 27
@ -107,7 +107,7 @@ Partial Class Individual
' '
'TextBox_Width 'TextBox_Width
' '
Me.TextBox_Width.Location = New System.Drawing.Point(110, 392) Me.TextBox_Width.Location = New System.Drawing.Point(110, 418)
Me.TextBox_Width.Name = "TextBox_Width" Me.TextBox_Width.Name = "TextBox_Width"
Me.TextBox_Width.Size = New System.Drawing.Size(155, 20) Me.TextBox_Width.Size = New System.Drawing.Size(155, 20)
Me.TextBox_Width.TabIndex = 26 Me.TextBox_Width.TabIndex = 26

View File

@ -239,6 +239,7 @@ Public Class Individual
' --- When calculate button is pressed --- ' --- When calculate button is pressed ---
Private Sub Button_Calculate_Click(sender As Object, e As EventArgs) Private Sub Button_Calculate_Click(sender As Object, e As EventArgs)
Grating_Fill.Calculate_Grid() Grating_Fill.Calculate_Grid()
Grating_Fill.Calculate_Recesses()
End Sub End Sub
' ---------------------------------- Export to SW ---------------------------------- ' ---------------------------------- Export to SW ----------------------------------
@ -247,7 +248,7 @@ Public Class Individual
If AppForm.fillMode Then If AppForm.fillMode Then
Model_3D_Fill.BuildGrid() Model_3D_Fill.BuildGrid()
Else Else
'Model_3D.BuildGrating() Model_3D.BuildGrating()
Drawing.CreateDrawing() Drawing.CreateDrawing()
End If End If
End Sub End Sub

View File

@ -52,6 +52,7 @@
recessData.Columns.Add("WIDTH", GetType(Integer)) recessData.Columns.Add("WIDTH", GetType(Integer))
recessData.Columns.Add("LENGTH", GetType(Integer)) recessData.Columns.Add("LENGTH", GetType(Integer))
recessData.Columns.Add("OFFSET", GetType(Integer)) recessData.Columns.Add("OFFSET", GetType(Integer))
recessData.Columns.Add("GRATINGS", GetType(Integer()))
End Sub End Sub
Public Shared Sub Init_GrossAreaPoints() Public Shared Sub Init_GrossAreaPoints()

View File

@ -4,11 +4,13 @@ Public Class Grating_Fill
Public Shared numOfHorizontal, numOfVertical As Integer Public Shared numOfHorizontal, numOfVertical As Integer
Public Shared widthRevNeeded, lengthRevNeeded As Boolean Public Shared widthRevNeeded, lengthRevNeeded As Boolean
Public Shared revLength, revWidth As Integer Public Shared revLength, revWidth As Integer
Public Shared minLength As Integer
Public Shared gratingDimensions As New DataTable Public Shared gratingDimensions As New DataTable
Public Shared Sub Calculate_Grid() Public Shared Sub Calculate_Grid()
Get_SingleGratingMaxDimensions() Get_SingleGratingMaxDimensions()
gratingDimensions.Clear() gratingDimensions.Clear()
gratingDimensions.Columns.Clear() gratingDimensions.Columns.Clear()
gratingDimensions.Columns.Add("INDEX", GetType(Integer)) gratingDimensions.Columns.Add("INDEX", GetType(Integer))
@ -18,19 +20,36 @@ Public Class Grating_Fill
gratingDimensions.Columns.Add("LENGTH", GetType(Integer)) gratingDimensions.Columns.Add("LENGTH", GetType(Integer))
numOfHorizontal = Math.Floor(Data.gratingL / maxSingleLength) + 1
If (Data.gratingL / maxSingleLength) Mod 1 = 0 Then
numOfHorizontal = Data.gratingL / maxSingleLength
Else
numOfHorizontal = Math.Floor(Data.gratingL / maxSingleLength) + 1
End If
numOfVertical = Math.Floor(Data.gratingW / maxSingleWidth) + 1 numOfVertical = Math.Floor(Data.gratingW / maxSingleWidth) + 1
Dim endLength As Integer minLength = (Math.Floor((Data.gratingL / 100) / numOfHorizontal) + 1) * 100 'Hantera längder med mer än 100mm mellan typ 1600-1800
If Data.gratingL - (numOfHorizontal - 1) * maxSingleLength < 200 Then
endLength = 200 If minLength > 1600 AndAlso (minLength / 100) Mod 2 = 1 Then
revLength = maxSingleLength - (endLength - (Data.gratingL - (numOfHorizontal - 1) * maxSingleLength)) minLength += 100
lengthRevNeeded = True
Else
endLength = Data.gratingL - (numOfHorizontal - 1) * maxSingleLength
lengthRevNeeded = False
End If End If
If minLength > maxSingleLength Then
minLength = maxSingleLength
End If
Dim endLength As Integer = Data.gratingL - (numOfHorizontal - 1) * minLength
'If Data.gratingL - (numOfHorizontal - 1) * maxSingleLength < 200 Then
' endLength = 200
' revLength = maxSingleLength - (endLength - (Data.gratingL - (numOfHorizontal - 1) * maxSingleLength))
' lengthRevNeeded = True
'Else
' endLength = Data.gratingL - (numOfHorizontal - 1) * maxSingleLength
' lengthRevNeeded = False
'End If
Dim endWidth As Integer Dim endWidth As Integer
If Data.gratingW - (numOfVertical - 1) * maxSingleWidth < 200 Then If Data.gratingW - (numOfVertical - 1) * maxSingleWidth < 200 Then
Dim neededLoadbars As Integer = Math.Floor((200 - (Data.gratingW - (numOfVertical - 1) * maxSingleWidth)) / User_Input.loadBarSpacing) + 1 Dim neededLoadbars As Integer = Math.Floor((200 - (Data.gratingW - (numOfVertical - 1) * maxSingleWidth)) / User_Input.loadBarSpacing) + 1
@ -51,10 +70,10 @@ Public Class Grating_Fill
If CDbl((i + 1) / numOfHorizontal) = row Then If CDbl((i + 1) / numOfHorizontal) = row Then
tempDR("LENGTH") = endLength tempDR("LENGTH") = endLength
row += 1 row += 1
ElseIf CDbl((i + 2) / numOfHorizontal) = row AndAlso lengthRevNeeded Then 'ElseIf CDbl((i + 2) / numOfHorizontal) = row AndAlso lengthRevNeeded Then
tempDR("LENGTH") = revLength ' tempDR("LENGTH") = revLength
Else Else
tempDR("LENGTH") = maxSingleLength tempDR("LENGTH") = minLength
End If End If
If i > numOfHorizontal * numOfVertical - 1 - numOfHorizontal Then If i > numOfHorizontal * numOfVertical - 1 - numOfHorizontal Then
@ -101,4 +120,27 @@ Public Class Grating_Fill
End Try End Try
Next Next
End Sub End Sub
Public Shared Sub Calculate_Recesses()
Dim cornerAngleCounter As Integer = 0
For Each DR As DataRow In Data.recessData.Rows
If DR("RECESS TYPE") = "ANGLE" Then
cornerAngleCounter += 1
For i = 1 To 2
Dim p1X, p1Y As Integer
For Each gDR As DataRow In Data.gratingPoints.Rows
If gDR("NAME") = "CA" & cornerAngleCounter & "_" & i Then
p1X = gDR("X")
p1Y = gDR("Y")
End If
Next
Next
'Kolla var de ligger jämfört med gratings
'Lägg till grating index i "GRATINGS"
End If
Next
End Sub
End Class End Class

View File

@ -1,5 +1,6 @@
Public Class Corner_Angle Public Class Corner_Angle
Private Shared buttonOffset As Integer Private Shared buttonOffset As Integer
Private Shared cornerAngleCounter As Integer = 0
' --- Create textboxes when user clicks the angle corner recess button --- ' --- Create textboxes when user clicks the angle corner recess button ---
Public Shared Sub AngleButton(sender As Object, e As EventArgs) Public Shared Sub AngleButton(sender As Object, e As EventArgs)
Individual.Panel_Recesses.Controls("Button_Angle_Corner").Enabled = False Individual.Panel_Recesses.Controls("Button_Angle_Corner").Enabled = False
@ -90,7 +91,7 @@
' --- When a corner function button is pressed --- ' --- When a corner function button is pressed ---
Private Shared Sub PointButton_Click(sender As Button, e As EventArgs) Private Shared Sub PointButton_Click(sender As Button, e As EventArgs)
'Determine which point is being pressed 'Determine which point is being pressed
Dim pointPressed As String = sender.Name.Split("_")(0) Dim pointPressed As String = sender.Name.Replace("_Button", "").Trim()
Dim index As Integer Dim index As Integer
For Each DR As DataRow In Data.gratingPoints.Rows For Each DR As DataRow In Data.gratingPoints.Rows
If DR("NAME") = pointPressed Then If DR("NAME") = pointPressed Then
@ -108,6 +109,8 @@
End If End If
Next Next
cornerAngleCounter += 1
'Retrive that points coords 'Retrive that points coords
Dim pXGUI As Integer = Data.gratingPoints.Rows(index)("GUI X") Dim pXGUI As Integer = Data.gratingPoints.Rows(index)("GUI X")
Dim pYGUI As Integer = Data.gratingPoints.Rows(index)("GUI Y") Dim pYGUI As Integer = Data.gratingPoints.Rows(index)("GUI Y")
@ -180,11 +183,11 @@
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
pointRow1("NAME") = "CA" & pointQuadrant & "_" & 1 pointRow1("NAME") = "CA" & cornerAngleCounter & "_" & 1
pointRow1("QUADRANT") = pointQuadrant pointRow1("QUADRANT") = pointQuadrant
pointRow1("RECESS OK") = False pointRow1("RECESS OK") = False
pointRow2("NAME") = "CA" & pointQuadrant & "_" & 2 pointRow2("NAME") = "CA" & cornerAngleCounter & "_" & 2
pointRow2("QUADRANT") = pointQuadrant pointRow2("QUADRANT") = pointQuadrant
pointRow2("RECESS OK") = False pointRow2("RECESS OK") = False
If pointQuadrant = 1 Then If pointQuadrant = 1 Then
@ -210,7 +213,7 @@
' Add angle recess help point (GUI) ' Add angle recess help point (GUI)
Dim pointRow = Data.angleRecessPoints.NewRow Dim pointRow = Data.angleRecessPoints.NewRow
pointRow("NAME") = "CA" & pointQuadrant pointRow("NAME") = "CA" & cornerAngleCounter
pointRow("QUADRANT") = pointQuadrant pointRow("QUADRANT") = pointQuadrant
pointRow("GUI X") = pXGUI + dXGUI pointRow("GUI X") = pXGUI + dXGUI
pointRow("GUI Y") = pYGUI + dYGUI pointRow("GUI Y") = pYGUI + dYGUI
@ -250,7 +253,7 @@
' Add angle recess help point (GUI) ' Add angle recess help point (GUI)
Dim pointRow = Data.angleRecessPoints.NewRow Dim pointRow = Data.angleRecessPoints.NewRow
pointRow("NAME") = "CA" & pointQuadrant pointRow("NAME") = "CA" & cornerAngleCounter
pointRow("QUADRANT") = pointQuadrant pointRow("QUADRANT") = pointQuadrant
pointRow("GUI X") = pXGUI - dXGUI pointRow("GUI X") = pXGUI - dXGUI
pointRow("GUI Y") = pYGUI + dYGUI pointRow("GUI Y") = pYGUI + dYGUI
@ -289,7 +292,7 @@
' Add angle recess help point (GUI) ' Add angle recess help point (GUI)
Dim pointRow = Data.angleRecessPoints.NewRow Dim pointRow = Data.angleRecessPoints.NewRow
pointRow("NAME") = "CA" & pointQuadrant pointRow("NAME") = "CA" & cornerAngleCounter
pointRow("QUADRANT") = pointQuadrant pointRow("QUADRANT") = pointQuadrant
pointRow("GUI X") = pXGUI - dXGUI pointRow("GUI X") = pXGUI - dXGUI
pointRow("GUI Y") = pYGUI - dYGUI pointRow("GUI Y") = pYGUI - dYGUI
@ -325,7 +328,7 @@
' Add angle recess help point (GUI) ' Add angle recess help point (GUI)
Dim pointRow = Data.angleRecessPoints.NewRow Dim pointRow = Data.angleRecessPoints.NewRow
pointRow("NAME") = "CA" & pointQuadrant pointRow("NAME") = "CA" & cornerAngleCounter
pointRow("QUADRANT") = pointQuadrant pointRow("QUADRANT") = pointQuadrant
pointRow("GUI X") = pXGUI + dXGUI pointRow("GUI X") = pXGUI + dXGUI
pointRow("GUI Y") = pYGUI - dYGUI pointRow("GUI Y") = pYGUI - dYGUI

View File

@ -1,5 +1,6 @@
Public Class Corner_Rectangle Public Class Corner_Rectangle
Private Shared buttonOffset As Integer Private Shared buttonOffset As Integer
Private Shared cornerRectangleCounter As Integer = 0
' --- Create textboxes when user clicks the rectangle corner recess button --- ' --- Create textboxes when user clicks the rectangle corner recess button ---
Public Shared Sub SquareButtton(sender As Object, e As EventArgs) Public Shared Sub SquareButtton(sender As Object, e As EventArgs)
Individual.Panel_Recesses.Controls("Button_Angle_Corner").Enabled = False Individual.Panel_Recesses.Controls("Button_Angle_Corner").Enabled = False
@ -89,7 +90,7 @@
' --- When a corner function button is pressed --- ' --- When a corner function button is pressed ---
Private Shared Sub PointButton_Click(sender As Button, e As EventArgs) Private Shared Sub PointButton_Click(sender As Button, e As EventArgs)
'Determine which point is being pressed 'Determine which point is being pressed
Dim pointPressed As String = sender.Name.Split("_")(0) Dim pointPressed As String = sender.Name.Replace("_Button", "").Trim()
Dim index As Integer Dim index As Integer
For Each DR As DataRow In Data.gratingPoints.Rows For Each DR As DataRow In Data.gratingPoints.Rows
If DR("NAME") = pointPressed Then If DR("NAME") = pointPressed Then
@ -107,6 +108,8 @@
End If End If
Next Next
cornerRectangleCounter += 1
'Retrive the points coords 'Retrive the points coords
Dim pXGUI As Integer = Data.gratingPoints.Rows(index)("GUI X") Dim pXGUI As Integer = Data.gratingPoints.Rows(index)("GUI X")
Dim pYGUI As Integer = Data.gratingPoints.Rows(index)("GUI Y") Dim pYGUI As Integer = Data.gratingPoints.Rows(index)("GUI Y")
@ -180,15 +183,15 @@
Dim pointRow2 As DataRow = Data.gratingPoints.NewRow Dim pointRow2 As DataRow = Data.gratingPoints.NewRow
Dim pointRow3 As DataRow = Data.gratingPoints.NewRow Dim pointRow3 As DataRow = Data.gratingPoints.NewRow
pointRow1("NAME") = "CR" & pointQuadrant & "_" & 1 pointRow1("NAME") = "CR" & cornerRectangleCounter & "_" & 1
pointRow1("QUADRANT") = pointQuadrant pointRow1("QUADRANT") = pointQuadrant
pointRow1("RECESS OK") = True pointRow1("RECESS OK") = True
pointRow2("NAME") = "CR" & pointQuadrant & "_" & 2 pointRow2("NAME") = "CR" & cornerRectangleCounter & "_" & 2
pointRow2("QUADRANT") = pointQuadrant pointRow2("QUADRANT") = pointQuadrant
pointRow2("RECESS OK") = False pointRow2("RECESS OK") = False
pointRow3("NAME") = "CR" & pointQuadrant & "_" & 3 pointRow3("NAME") = "CR" & cornerRectangleCounter & "_" & 3
pointRow3("QUADRANT") = pointQuadrant pointRow3("QUADRANT") = pointQuadrant
pointRow3("RECESS OK") = True pointRow3("RECESS OK") = True