EgtCAM5 :

- ulteriori modifiche in disposizione con piani di lavoro (bancaletti).
This commit is contained in:
Dario Sassi
2024-10-16 14:56:05 +02:00
parent be4bc812da
commit bf424a49e1
3 changed files with 395 additions and 189 deletions
@@ -281,6 +281,7 @@ Public Class DispositionParameterExpanderVM
End Select
Map.refRawPartOptionVM.SetMoveWithFixture(False)
Map.refFixtureParametersVM.UpdateFixtureTypeList()
DispositionUtility.InitHookData()
End Sub
#End Region ' METHODS
@@ -1,5 +1,6 @@
Imports System.Windows.Forms.AxHost
Imports EgtUILib
Imports Microsoft.VisualBasic.ApplicationServices
Public NotInheritable Class DispositionUtility
@@ -9,7 +10,6 @@ Public NotInheritable Class DispositionUtility
Friend Const NEXT_ As String = "Next"
Friend Const HOOK As String = "HOOK*"
Friend Const CLASS_ As String = "CLASS"
Friend Const USED As String = "USED"
Friend Const FIXED As String = "FIXED*"
Friend Const TYPE As String = "TYPE"
Friend Const FREE As String = "FREE"
@@ -25,6 +25,62 @@ Public NotInheritable Class DispositionUtility
Friend Shared m_nUsedHookId As Integer = GDB_ID.NULL
Friend Shared m_nPrevUsedHookId As Integer = GDB_ID.NULL
Friend Class HookData
Public m_sName As String
Public m_sParent As String
Public m_bParentAxis As Boolean
Public m_sGrParentAxis As String
Public m_nId As Integer
Public m_nType As HOOKTYPE
Public m_ptP1 As Point3d
Public m_ptP2 As Point3d
Public m_nClass As Integer
Public m_nHooked As Integer
Public m_sHooked As String
Sub New()
m_sName = ""
m_sParent = ""
m_bParentAxis = False
m_sGrParentAxis = ""
m_nId = GDB_ID.NULL
m_nType = HOOKTYPE.FREE
m_ptP1 = Point3d.ORIG()
m_ptP2 = Point3d.ORIG()
m_nClass = 0
m_nHooked = GDB_ID.NULL
m_sHooked = ""
End Sub
Sub New(sName As String, sParent As String, bParentAxis As Boolean, sGrParentAxis As String,
nId As Integer, ptP As Point3d, nClass As Integer)
m_sName = sName
m_sParent = sParent
m_bParentAxis = bParentAxis
m_sGrParentAxis = sGrParentAxis
m_nId = nId
m_nType = HOOKTYPE.POINT
m_ptP1 = ptP
m_ptP2 = Point3d.ORIG()
m_nClass = nClass
m_nHooked = GDB_ID.NULL
m_sHooked = ""
End Sub
Sub New(sName As String, sParent As String, bParentAxis As Boolean, sGrParentAxis As String,
nId As Integer, ptP1 As Point3d, ptP2 As Point3d, nClass As Integer)
m_sName = sName
m_sParent = sParent
m_bParentAxis = bParentAxis
m_sGrParentAxis = sGrParentAxis
m_nId = nId
m_nType = HOOKTYPE.LINE
m_ptP1 = ptP1
m_ptP2 = ptP2
m_nClass = nClass
m_nHooked = GDB_ID.NULL
m_sHooked = ""
End Sub
End Class
Friend Shared m_vHookData As New List(Of HookData)
' Identificativi per elemento da selezionare/deselezionare
Friend Enum SelType As Integer
NULL = 0
@@ -522,18 +578,18 @@ End Select
Return True
End Function
' Funzione che verifica se asse o sottoasse di tavola (e quindi barra o carrello)
' Funzione che verifica se asse o sottoasse di tavola (e quindi barra o carrello)
Friend Shared Function VerifyTableAxis( nObjId As Integer) As Boolean
' Verifico se asse
Dim sObjName As String = ""
' Verifico se asse
Dim sObjName As String = ""
If Not EgtGetName( nObjId, sObjName) OrElse EgtGetAxisId( sObjName) = GDB_ID.NULL Then Return False
' Recupero il padre
' Recupero il padre
Dim nParId As Integer = EgtGetParent( nObjId)
Dim sParName As String = ""
Dim sParName As String = ""
If Not EgtGetName( nParId, sParName) Then Return False
' Verifico se tavola
' Verifico se tavola
If EgtGetTableId( sParName) <> GDB_ID.NULL Then Return True
' Verifico se asse di tavola
' Verifico se asse di tavola
Return VerifyTableAxis( nParId)
End Function
@@ -556,39 +612,41 @@ End Select
GetBarExtreme(nMoveId, dCurrBarPos, dCurrBarMEnc, dCurrBarPEnc)
' Recupero dati eventuale barra precedente
Dim sPrevBarName As String = ""
If EgtGetInfo( nMoveId, PREV, sPrevBarName) Then
If EgtGetInfo( nMoveId, PREV, sPrevBarName) Then
Dim nPrevBarId As Integer = EgtGetAxisId( sPrevBarName)
Dim dPrevBarPos As Double = 0
Dim dPrevBarMEnc As Double = 0
Dim dPrevBarPEnc As Double = 0
if Not GetBarExtreme(nPrevBarId, dPrevBarPos, dPrevBarMEnc, dPrevBarPEnc) Then Return False
if Not GetBarExtreme(nPrevBarId, dPrevBarPos, dPrevBarMEnc, dPrevBarPEnc) Then Return False
dAxMin = Math.Max( dAxMin, dPrevBarPos + dPrevBarPEnc + dCurrBarMEnc)
End If
' Recupero dati eventuale barra successiva
Dim sNextBarName As String = ""
If EgtGetInfo( nMoveId, NEXT_, sNextBarName) Then
Dim nNextBarId As Integer = EgtGetAxisId( sNextBarName)
If EgtGetInfo( nMoveId, NEXT_, sNextBarName) Then
Dim nNextBarId As Integer = EgtGetAxisId( sNextBarName)
Dim dNextBarPos As Double = 0
Dim dNextBarMEnc As Double = 0
Dim dNextBarPEnc As Double = 0
if Not GetBarExtreme(nNextBarId, dNextBarPos, dNextBarMEnc, dNextBarPEnc) Then Return False
dAxMax = Math.Min( dAxMax, dNextBarPos - dNextBarMEnc - dCurrBarPEnc)
End If
' Limito lo spostamento alle corse ammesse
dAxMax = Math.Min( dAxMax, dNextBarPos - dNextBarMEnc - dCurrBarPEnc)
End If
' Limito lo spostamento alle corse ammesse
If dAxMax < dAxMin Then Return False
Dim dNewBarPos As Double = dCurrBarPos + vtMove * vtDir
dNewBarPos = Math.Min( Math.Max( dNewBarPos,dAxMin), dAxMax)
' Eseguo lo spostamento
' Eseguo lo spostamento
EgtMoveDispAxis( sName, dNewBarPos)
Return True
End Function
Dim vtRealMove As Vector3d = ( dNewBarPos - dCurrBarPos) * vtDir
UpdateFixturesForDispAxisMove( sName, vtRealMove)
Return True
End Function
Private Shared Function GetBarExtreme(nMoveId As Integer, ByRef dPos As Double, ByRef dMEnc As Double, ByRef dPEnc As Double) As Boolean
' Recupero la posizione
Dim sName As String = ""
If Not EgtGetName( nMoveId, sName) OrElse Not EgtGetAxisPos( sName, dPos) Then Return False
' Recupero ingombro negativo
dMEnc = 0
' Recupero ingombro negativo
dMEnc = 0
EgtGetInfo(nMoveId, MDIST, dMEnc)
' recupero ingombro positivo
dPEnc = 0
@@ -652,7 +710,7 @@ End Select
While nBarId <> GDB_ID.NULL
Dim sBarName As String = ""
If EgtGetName( nBarId, sBarName) AndAlso EgtGetAxisId( sBarName) <> GDB_ID.NULL Then
nCurrHookId = EgtGetFirstNameInGroup(nBarId, HOOK)
nCurrHookId = EgtGetFirstNameInGroup(nBarId, HOOK)
While nCurrHookId <> GDB_ID.NULL
HookAnalyzer(nCurrHookId, nFixtHookType, nFixtHookClass, ptCurr + m_vtHook, nNearestHookId, dNearestHookDist, ptNearestHook, nMoveId)
nCurrHookId = EgtGetNextName(nCurrHookId, HOOK)
@@ -687,9 +745,41 @@ End Select
Return True
End Function
' funzione di debug
Private Shared Sub DebugHookInfo()
' Salvo in outlog tutte le info sugli hook per poter debuggare
' Funzioni gestione tabella degli Hook
Private Shared Function AddOneHookData( nHookId As Integer, sParent As String, bParentAxis As Boolean) As Boolean
Dim sHook As String = ""
EgtGetName( nHookId, sHook)
Dim sGrParentAxis As String = ""
If bParentAxis Then
Dim nIdGrParent As Integer = EgtGetParent( EgtGetParent( nHookId))
Dim sParentName As String = ""
If EgtGetName( nIdGrParent, sParentName) AndAlso EgtGetAxisId( sParentName) = nIdGrParent Then
sGrParentAxis = sParentName
End If
End If
Dim nClass As Integer = 0
EgtGetInfo(nHookId, CLASS_, nClass)
Dim nType As Integer = EgtGetType( nHookId)
If nType = GDB_TY.GEO_POINT Then
Dim ptP As Point3d
EgtStartPoint( nHookId, GDB_ID.ROOT, ptP)
Dim hdCurr As New HookData( sHook, sParent, bParentAxis, sGrParentAxis, nHookId, ptP, nClass)
m_vHookData.Add( hdCurr)
Return True
Else If nType = GDB_TY.CRV_LINE Then
Dim ptP1 As Point3d
EgtStartPoint( nHookId, GDB_ID.ROOT, ptP1)
Dim ptP2 As Point3d
EgtEndPoint( nHookId, GDB_ID.ROOT, ptP2)
Dim hdCurr As New HookData( sHook, sParent, bParentAxis, sGrParentAxis, nHookId, ptP1, ptP2, nClass)
m_vHookData.Add( hdCurr)
Return True
End If
Return False
End Function
Friend Shared Sub PrepareHookData()
' Pulisco lista di Hook
m_vHookData.Clear()
' Recupero Id tavola corrente
Dim sTableName As String = ""
EgtGetTableName(sTableName)
@@ -697,11 +787,8 @@ End Select
' *** Cerco hook su tavola ***
Dim nTableSolidId As Integer = EgtGetFirstNameInGroup(nTableId, SOLID)
Dim nCurrHookId As Integer = EgtGetFirstNameInGroup(nTableSolidId, HOOK)
EgtOutLog("TABLE")
While nCurrHookId <> GDB_ID.NULL
Dim sUsed As String = ""
EgtGetInfo(nCurrHookId, USED, sUsed)
EgtOutLog(nCurrHookId & " -> " & sUsed)
AddOneHookData( nCurrHookId, SOLID, False)
nCurrHookId = EgtGetNextName(nCurrHookId, HOOK)
End While
' *** Cerco hook su barre fisse ***
@@ -709,86 +796,224 @@ End Select
While nTableFixedId <> GDB_ID.NULL
Dim sName As String = ""
EgtGetName( nTableFixedId, sName)
EgtOutLog( sName)
nCurrHookId = EgtGetFirstNameInGroup(nTableFixedId, HOOK)
While nCurrHookId <> GDB_ID.NULL
Dim sUsed As String = ""
EgtGetInfo(nCurrHookId, USED, sUsed)
EgtOutLog(nCurrHookId & " -> " & sUsed)
AddOneHookData( nCurrHookId, sName, False)
nCurrHookId = EgtGetNextName(nCurrHookId, HOOK)
End While
nTableFixedId = EgtGetNextName(nTableFixedId, FIXED)
End While
' *** Cerco hook su barre mobili ***
' *** Cerco hook su barre mobili ***
Dim nBarId As Integer = EgtGetFirstGroupInGroup(nTableId)
While nBarId <> GDB_ID.NULL
Dim sBarName As String = ""
If EgtGetName( nBarId, sBarName) AndAlso EgtGetAxisId( sBarName) <> GDB_ID.NULL Then
EgtOutLog(sBarName)
If EgtGetName( nBarId, sBarName) AndAlso EgtGetAxisId( sBarName) = nBarId Then
nCurrHookId = EgtGetFirstNameInGroup(nBarId, HOOK)
While nCurrHookId <> GDB_ID.NULL
Dim sUsed As String = ""
EgtGetInfo(nCurrHookId, USED, sUsed)
EgtOutLog(nCurrHookId & " -> " & sUsed)
AddOneHookData( nCurrHookId, sBarName, True)
nCurrHookId = EgtGetNextName(nCurrHookId, HOOK)
End While
' Cerco su eventuali carrelli
Dim nCharId As Integer = EgtGetFirstGroupInGroup(nBarId)
While nCharId <> GDB_ID.NULL
Dim sCharName As String = ""
If EgtGetName( nCharId, sCharName) AndAlso EgtGetAxisId( sCharName) <> GDB_ID.NULL Then
EgtOutLog(sCharName)
If EgtGetName( nCharId, sCharName) AndAlso EgtGetAxisId( sCharName) = nCharId Then
nCurrHookId = EgtGetFirstNameInGroup(nCharId, DispositionUtility.HOOK)
While nCurrHookId <> GDB_ID.NULL
Dim sUsed As String = ""
EgtGetInfo(nCurrHookId, USED, sUsed)
EgtOutLog(nCurrHookId & " -> " & sUsed)
AddOneHookData( nCurrHookId, sCharName, True)
nCurrHookId = EgtGetNextName(nCurrHookId, HOOK)
End While
End If
nCharId = EgtGetNextGroup(nCharId)
End While
End If
End While
End If
nBarId = EgtGetNextGroup(nBarId)
End While
End Sub
' funzioni che leggono e settano le ventose agganciate agli hook
Private Shared Function GetHookUsed(nHookId As Integer, nFixtureId As Integer, nFixtureUsed As Integer) As Boolean
' cerco punto hook sulla ventosa
Dim nFixtSolidId As Integer = EgtGetFirstNameInGroup(nFixtureId, SOLID)
Dim nFixtHookId As Integer = EgtGetFirstNameInGroup(nFixtSolidId, HOOK)
' leggo tipo e classe
Dim nFixtHookType As HOOKTYPE = HOOKTYPE.FREE
Dim sType As String = ""
EgtGetInfo(nFixtHookId, TYPE, sType)
If sType.Equals(POINT) Then
nFixtHookType = HOOKTYPE.POINT
ElseIf sType.Equals(LINE) Then
nFixtHookType = HOOKTYPE.LINE
Else 'FREE
nFixtHookType = HOOKTYPE.FREE
' esco perchè non devo cercare alcun punto
Return False
End If
Select Case nFixtHookType
Case HOOKTYPE.POINT
Return EgtGetInfo(m_nUsedHookId, USED, nFixtureUsed)
Case HOOKTYPE.LINE
Dim sInfo As String = String.Empty
EgtGetInfo(m_nUsedHookId, USED, sInfo)
Dim SplitInfo() As String = sInfo.Split(";"c)
For Each Info In SplitInfo
Dim nInfo As Integer = GDB_ID.NULL
Integer.TryParse(sInfo, nInfo)
If nInfo = nFixtureId Then Return True
Friend Shared Sub PrepareHookedFixtures()
' Ciclo su tutte le fixtures in tavola
Dim nFixtId As Integer = EgtGetFirstFixture()
While nFixtId <> GDB_ID.NULL
Dim nHookId As Integer = EgtGetFirstNameInGroup( EgtGetFirstNameInGroup( nFixtId, SOLID), HOOK)
Dim ptP As Point3d
If EgtStartPoint( nHookId, GDB_ID.ROOT, ptP) Then
For Each hkCurr As HookData In m_vHookData
If hkCurr.m_nType = HOOKTYPE.POINT Then
If Point3d.SqDistXY( ptP, hkCurr.m_ptP1) < 1 Then
hkCurr.m_nHooked = nFixtId
Exit For
End If
ElseIf hkCurr.m_nType = HOOKTYPE.LINE Then
End If
Next
Return False
Case Else
Return False
End Select
End If
nFixtId = EgtGetNextFixture( nFixtId)
End While
End Sub
Friend Shared Sub InitHookData()
' Carico i dati degli agganci
PrepareHookData()
' Determino eventuali fixtures agganciate
PrepareHookedFixtures()
' Log di debug
If Map.refMainWindowVM.DebugLevel() >= 4 then
EgtOutLog( " *** HOOK DATA TABLE ***")
Dim sCurrParent As String = ""
For Each hkCurr As HookData In m_vHookData
If hkCurr.m_sParent <> sCurrParent Then
sCurrParent = hkCurr.m_sParent
If String.IsNullOrWhiteSpace( hkCurr.m_sGrParentAxis) Then
EgtOutLog( sCurrParent & If( hkCurr.m_bParentAxis, " Axis", " Fixed"))
Else
EgtOutLog( sCurrParent & " (" & hkCurr.m_sGrParentAxis & ") Axis")
End If
End If
If hkCurr.m_nType = HOOKTYPE.POINT Then
EgtOutLog( " " & hkCurr.m_sName & " (" & hkCurr.m_nId &
") Point(" & hkCurr.m_ptP1.ToString() & ") Class=" & hkCurr.m_nClass &
If( hkCurr.m_nHooked = GDB_ID.NULL, " Free", " Fixt " & hkCurr.m_nHooked))
Else If hkCurr.m_nType = HOOKTYPE.LINE Then
EgtOutLog( " " & hkCurr.m_sName & " (" & hkCurr.m_nId &
") Line(" & hkCurr.m_ptP1.ToString() & "),(" & hkCurr.m_ptP2.ToString() & ") Class=" & hkCurr.m_nClass &
If( hkCurr.m_nHooked = GDB_ID.NULL, " Free", " Fixt " & hkCurr.m_nHooked))
End If
Next
End If
End Sub
Friend Shared Function GetHookClass( nHookId As Integer) As Integer
For Each hkCurr As HookData In m_vHookData
If hkCurr.m_nId = nHookId Then Return hkCurr.m_nClass
Next
Return -1
End Function
Friend Shared Function GetIsHookUsed( nHookId As Integer) As Boolean
For Each hkCurr As HookData In m_vHookData
If hkCurr.m_nId = nHookId Then
If hkCurr.m_nType = HOOKTYPE.POINT Then
Return ( hkCurr.m_nHooked <> GDB_ID.NULL)
Else
Return Not String.IsNullOrWhiteSpace( hkCurr.m_sHooked)
End If
End If
Next
Return True
End Function
Friend Shared Function GetHookUsed( nHookId As Integer) As Integer
For Each hkCurr As HookData In m_vHookData
If hkCurr.m_nId = nHookId Then
If hkCurr.m_nType = HOOKTYPE.POINT Then
Return hkCurr.m_nHooked
Else
Return -2
End If
End If
Next
Return GDB_ID.NULL
End Function
Friend Shared Function SetHookUsed( nHookId As Integer, nFixtureId As Integer) As Boolean
' Rimuovo da eventuale precedente aggancio
For Each hkCurr As HookData In m_vHookData
If hkCurr.m_nHooked = nFixtureId Then
hkCurr.m_nHooked = GDB_ID.NULL
End If
Next
' Inserisco in nuovo aggancio
For Each hkCurr As HookData In m_vHookData
If hkCurr.m_nId = nHookId Then
If hkCurr.m_nType = HOOKTYPE.POINT Then
hkCurr.m_nHooked = nFixtureId
Return True
Else
Return False
End If
End If
Next
Return False
End Function
Friend Shared Function AddHookUsed( nHookId As Integer, nFixtureId As Integer) As Boolean
For Each hkCurr As HookData In m_vHookData
If hkCurr.m_nId = nHookId Then
If hkCurr.m_nType = HOOKTYPE.POINT Then
Return False
Else
' Verifico non sia già presente
Dim SplitInfo() As String = hkCurr.m_sHooked.Split(";"c)
For Each sInfo As String In SplitInfo
Dim nInfo As Integer = GDB_ID.NULL
Integer.TryParse(sInfo, nInfo)
If nInfo = nFixtureId Then Return True
Next
' Lo aggiungo
hkCurr.m_sHooked &= nFixtureId.ToString() & ";"
Return True
End If
End If
Next
Return False
End Function
Friend Shared Function RemoveHookUsed( nHookId As Integer, nFixtureId As Integer) As Boolean
For Each hkCurr As HookData In m_vHookData
If hkCurr.m_nId = nHookId Then
If hkCurr.m_nType = HOOKTYPE.POINT Then
Return False
Else
' Se lo trovo, lo tolgo dall'elenco
Dim SplitInfo() As String = hkCurr.m_sHooked.Split(";"c)
hkCurr.m_sHooked = ""
For Each sInfo As String In SplitInfo
Dim nInfo As Integer = GDB_ID.NULL
Integer.TryParse(sInfo, nInfo)
If nInfo <> nFixtureId Then
hkCurr.m_sHooked &= sInfo & ";"
End If
Next
Return True
End If
End If
Next
Return False
End Function
Friend Shared Function ResetHookUsed( nHookId As Integer) As Boolean
For Each hkCurr As HookData In m_vHookData
If hkCurr.m_nId = nHookId Then
hkCurr.m_nHooked = GDB_ID.NULL
hkCurr.m_sHooked = ""
Return True
End If
Next
Return False
End Function
Friend Shared Function UpdateFixturesForDispAxisMove( sName As String, vtMove As Vector3d) As Boolean
For Each hkCurr As HookData In m_vHookData
If hkCurr.m_sParent = sName OrElse hkCurr.m_sGrParentAxis = sName Then
' Aggiorno posizione di aggancio
If hkCurr.m_nType = HOOKTYPE.POINT Then
hkCurr.m_ptP1 += vtMove
ElseIf hkCurr.m_nType = HOOKTYPE.POINT Then
hkCurr.m_ptP1 += vtMove
hkCurr.m_ptP2 += vtMove
End If
' Sposto anche eventuale ventosa agganciata
If hkCurr.m_nHooked <> GDB_ID.NULL Then
EgtMoveFixture( hkCurr.m_nHooked, vtMove)
End If
End If
Next
Return True
End Function
' Funzioni che leggono e settano le ventose agganciate agli hook
Private Shared Sub SetHookUsed(nHookId As Integer, nFixtureId As Integer, bUsed As Boolean)
' cerco punto hook sulla ventosa
Dim nFixtSolidId As Integer = EgtGetFirstNameInGroup(nFixtureId, SOLID)
@@ -809,35 +1034,15 @@ End Select
Select Case nFixtHookType
Case HOOKTYPE.POINT
If bUsed Then
EgtSetInfo(m_nUsedHookId, USED, nFixtureId)
SetHookUsed(m_nUsedHookId, nFixtureId)
Else
EgtRemoveInfo(m_nUsedHookId, USED)
ResetHookUsed(m_nUsedHookId)
End If
Case HOOKTYPE.LINE
If bUsed Then
Dim sInfo As String = String.Empty
EgtGetInfo(m_nUsedHookId, USED, sInfo)
Dim SplitInfo() As String = sInfo.Split(";"c)
For Each Info In SplitInfo
Dim nInfo As Integer = GDB_ID.NULL
Integer.TryParse(sInfo, nInfo)
If nInfo = nFixtureId Then Return
Next
sInfo = sInfo & nFixtureId & ";"
EgtSetInfo(m_nUsedHookId, USED, sInfo)
AddHookUsed( m_nUsedHookId, nFixtureId)
Else
Dim sInfo As String = String.Empty
EgtGetInfo(m_nUsedHookId, USED, sInfo)
Dim SplitInfo() As String = sInfo.Split(";"c)
sInfo = ""
For Each Info In SplitInfo
Dim nInfo As Integer = GDB_ID.NULL
Integer.TryParse(sInfo, nInfo)
If nInfo <> nFixtureId Then
sInfo = sInfo & Info & ";"
End If
Next
EgtSetInfo(m_nUsedHookId, USED, sInfo)
RemoveHookUsed( m_nUsedHookId, nFixtureId)
End If
End Select
End Sub
@@ -846,66 +1051,66 @@ End Select
Private Shared Sub HookAnalyzer(nCurrHookId As Integer, nFixtHookType As Integer, nFixtHookClass As Integer,
ptFixtHook As Point3d, ByRef nNearestHookId As Integer, ByRef dNearestHookDist As Double,
ByRef ptNearestHook As Point3d, nMoveId As Integer)
' verifico se del tipo giusto
' Verifico se del tipo giusto
Dim nTableHookType As GDB_TY = EgtGetType(nCurrHookId)
If (nTableHookType = GDB_TY.GEO_POINT And nFixtHookType = HOOKTYPE.POINT) OrElse
(nTableHookType = GDB_TY.CRV_LINE And nFixtHookType = HOOKTYPE.LINE) Then
' verifico se della stessa classe
Dim nTableHookClass As Integer = 0
EgtGetInfo(nCurrHookId, CLASS_, nTableHookClass)
If nTableHookClass = nFixtHookClass Then
Dim dDist As Double = 0
' punto a distanza minima sull'hook
Dim ptCurrHook As Point3d
If nTableHookType = GDB_TY.GEO_POINT Then
' verifico se utilizzato
Dim nTableHookUsed As Integer = GDB_ID.NULL
If EgtGetInfo(nCurrHookId, USED, nTableHookUsed) AndAlso nTableHookUsed <> nMoveId Then Return
If nTableHookUsed = nMoveId Then
SetHookUsed(nCurrHookId, nMoveId, False)
'EgtRemoveInfo(nCurrHookId, USED)
m_nPrevUsedHookId = nCurrHookId
End If
' calcolo distanza punto hook tavola dal punto hook della ventosa
EgtStartPoint(nCurrHookId, GDB_ID.ROOT, ptCurrHook)
dDist = Point3d.DistXY(ptCurrHook, ptFixtHook)
'If nTableHookUsed <> nMoveId Then
' ' calcolo distanza punto hook tavola dal punto hook della ventosa
' EgtStartPoint(nCurrHookId, GDB_ID.ROOT, ptCurrHook)
' dDist = Point3d.Dist(ptCurrHook, ptFixtHook)
'Else
' EgtRemoveInfo(nCurrHookId, USED)
' m_nPrevUsedHookId = nCurrHookId
' Return
'End If
'If Not EgtGetInfo(nCurrHookId, USED, nTableHookUsed) Or nTableHookUsed = nMoveId Then
' ' calcolo distanza punto hook tavola dal punto hook della ventosa
' EgtStartPoint(nCurrHookId, GDB_ID.ROOT, ptCurrHook)
' dDist = Point3d.Dist(ptCurrHook, ptFixtHook)
'Else
' Return
'End If
ElseIf nTableHookType = GDB_TY.CRV_LINE Then
' calcolo distanza linea hook tavola dal punto hook della ventosa
Dim nRefId As Integer = 0
Dim dU As Double = 0
EgtPointCurveDist(ptFixtHook, nCurrHookId, nRefId, dDist, dU)
EgtAtParamPoint(nCurrHookId, dU, GDB_ID.ROOT, ptCurrHook)
Else
Return
End If
' se minore della distanza minima, sostituisco il valore
If dDist < dNearestHookDist Then
nNearestHookId = nCurrHookId
dNearestHookDist = dDist
ptNearestHook = ptCurrHook
End If
Else
If Not (nTableHookType = GDB_TY.GEO_POINT And nFixtHookType = HOOKTYPE.POINT) AndAlso
Not (nTableHookType = GDB_TY.CRV_LINE And nFixtHookType = HOOKTYPE.LINE) Then
Return
End If
' Verifico se della stessa classe
Dim nTableHookClass As Integer = GetHookClass( nCurrHookId)
If nTableHookClass <> nFixtHookClass Then
Return
End If
Dim dDist As Double = 0
' punto a distanza minima sull'hook
Dim ptCurrHook As Point3d
If nTableHookType = GDB_TY.GEO_POINT Then
' verifico se utilizzato
Dim nTableHookUsed As Integer = GetHookUsed( nCurrHookId)
If nTableHookUsed <> GDB_ID.NULL AndAlso nTableHookUsed <> nMoveId Then
Return
End If
If nTableHookUsed = nMoveId Then
SetHookUsed(nCurrHookId, nMoveId, False)
m_nPrevUsedHookId = nCurrHookId
End If
' calcolo distanza punto hook tavola dal punto hook della ventosa
EgtStartPoint(nCurrHookId, GDB_ID.ROOT, ptCurrHook)
dDist = Point3d.DistXY(ptCurrHook, ptFixtHook)
'If nTableHookUsed <> nMoveId Then
' ' calcolo distanza punto hook tavola dal punto hook della ventosa
' EgtStartPoint(nCurrHookId, GDB_ID.ROOT, ptCurrHook)
' dDist = Point3d.Dist(ptCurrHook, ptFixtHook)
'Else
' EgtRemoveInfo(nCurrHookId, USED)
' m_nPrevUsedHookId = nCurrHookId
' Return
'End If
'If Not EgtGetInfo(nCurrHookId, USED, nTableHookUsed) Or nTableHookUsed = nMoveId Then
' ' calcolo distanza punto hook tavola dal punto hook della ventosa
' EgtStartPoint(nCurrHookId, GDB_ID.ROOT, ptCurrHook)
' dDist = Point3d.Dist(ptCurrHook, ptFixtHook)
'Else
' Return
'End If
ElseIf nTableHookType = GDB_TY.CRV_LINE Then
' calcolo distanza linea hook tavola dal punto hook della ventosa
Dim nRefId As Integer = 0
Dim dU As Double = 0
EgtPointCurveDist(ptFixtHook, nCurrHookId, nRefId, dDist, dU)
EgtAtParamPoint(nCurrHookId, dU, GDB_ID.ROOT, ptCurrHook)
Else
Return
End If
' se minore della distanza minima, sostituisco il valore
If dDist < dNearestHookDist Then
nNearestHookId = nCurrHookId
dNearestHookDist = dDist
ptNearestHook = ptCurrHook
End If
End Sub
' Funzione che fissa il vettore di hook
@@ -5,8 +5,6 @@ Imports EgtUILib
Public Class FixtureParametersVM
Inherits ViewModelBase
Friend Const USED As String = "USED"
Private m_FixtureTypeList As ObservableCollection(Of FixtureListItem)
Public ReadOnly Property FixtureTypeList As ObservableCollection(Of FixtureListItem)
Get
@@ -248,7 +246,7 @@ Public Class FixtureParametersVM
End If
End Function
' Funzione che aggancia la ventosa al più vicino hook libero
' Funzione che cerca un hook libero adatto alla ventosa e se trovato la posiziona
Friend Shared Function PositionFixtureOnNearestHook(nFixtureId As Integer) As Boolean
' cerco punto hook sulla ventosa
Dim nFixtSolidId As Integer = EgtGetFirstNameInGroup(nFixtureId, SOLID)
@@ -286,7 +284,7 @@ Public Class FixtureParametersVM
EgtMoveFixture(nFixtureId, ptCurrHook - ptFixtHook)
' verifico se è in una posizione valida
If DispositionUtility.VerifyFixturePosition(nFixtureId, New Vector3d) Then
EgtSetInfo(nCurrHookId, used, nFixtureId)
DispositionUtility.SetHookUsed( nCurrHookId, nFixtureId)
Return True
End If
End If
@@ -303,7 +301,7 @@ Public Class FixtureParametersVM
EgtMoveFixture(nFixtureId, ptCurrHook - ptFixtHook)
' verifico se è in una posizione valida
If DispositionUtility.VerifyFixturePosition(nFixtureId, New Vector3d) Then
EgtSetInfo(nCurrHookId, USED, nFixtureId)
DispositionUtility.SetHookUsed( nCurrHookId, nFixtureId)
Return True
End If
End If
@@ -324,7 +322,7 @@ Public Class FixtureParametersVM
EgtMoveFixture(nFixtureId, ptCurrHook - ptFixtHook)
' verifico se è in una posizione valida
If DispositionUtility.VerifyFixturePosition(nFixtureId, New Vector3d) Then
EgtSetInfo(nCurrHookId, USED, nFixtureId)
DispositionUtility.SetHookUsed( nCurrHookId, nFixtureId)
Return True
End If
End If
@@ -343,7 +341,7 @@ Public Class FixtureParametersVM
EgtMoveFixture(nFixtureId, ptCurrHook - ptFixtHook)
' verifico se è in una posizione valida
If DispositionUtility.VerifyFixturePosition(nFixtureId, New Vector3d) Then
EgtSetInfo(nCurrHookId, USED, nFixtureId)
DispositionUtility.SetHookUsed( nCurrHookId, nFixtureId)
Return True
End If
End If
@@ -358,36 +356,38 @@ Public Class FixtureParametersVM
Return False
End Function
' Funzione che analizza l'hook e se valido ne prestituisce lo posizione(punto)
' Funzione che analizza l'hook e se valido ne restituisce la posizione (punto)
Private Shared Function HookAnalyzer(nCurrHookId As Integer, nFixtHookType As Integer, nFixtHookClass As Integer,
ptFixtHook As Point3d, ByRef ptCurrHook As Point3d) As Boolean
' verifico se del tipo giusto
' Verifico se del tipo giusto
Dim nTableHookType As GDB_TY = EgtGetType(nCurrHookId)
If (nTableHookType = GDB_TY.GEO_POINT And nFixtHookType = DispositionUtility.HOOKTYPE.POINT) OrElse
(nTableHookType = GDB_TY.CRV_LINE And nFixtHookType = DispositionUtility.HOOKTYPE.LINE) Then
' verifico se della stessa classe
Dim nTableHookClass As Integer = 0
EgtGetInfo(nCurrHookId, DispositionUtility.CLASS_, nTableHookClass)
If nTableHookClass = nFixtHookClass Then
Dim dDist As Double = 0
' punto a distanza minima sull'hook
If nTableHookType = GDB_TY.GEO_POINT Then
' verifico se utilizzato
Dim nTableHookUsed As Boolean = False
If Not EgtGetInfo(nCurrHookId, DispositionUtility.USED, nTableHookUsed) Then
' calcolo distanza punto hook tavola dal punto hook della ventosa
EgtStartPoint(nCurrHookId, GDB_ID.ROOT, ptCurrHook)
Return True
End If
ElseIf nTableHookType = GDB_TY.CRV_LINE Then
' calcolo distanza linea hook tavola dal punto hook della ventosa
Dim nRefId As Integer = 0
Dim dU As Double = 0
EgtPointCurveDist(ptFixtHook, nCurrHookId, nRefId, dDist, dU)
EgtAtParamPoint(nCurrHookId, dU, GDB_ID.ROOT, ptCurrHook)
Return True
End If
If Not (nTableHookType = GDB_TY.GEO_POINT And nFixtHookType = DispositionUtility.HOOKTYPE.POINT) AndAlso
Not (nTableHookType = GDB_TY.CRV_LINE And nFixtHookType = DispositionUtility.HOOKTYPE.LINE) Then
Return False
End If
' Verifico se della stessa classe
Dim nTableHookClass As Integer = DispositionUtility.GetHookClass( nCurrHookId)
If nTableHookClass <> nFixtHookClass Then
Return False
End If
Dim dDist As Double = 0
' punto a distanza minima sull'hook
If nTableHookType = GDB_TY.GEO_POINT Then
' verifico se utilizzato
If Not DispositionUtility.GetIsHookUsed( nCurrHookId) Then
' calcolo distanza punto hook tavola dal punto hook della ventosa
EgtStartPoint(nCurrHookId, GDB_ID.ROOT, ptCurrHook)
Return True
End If
ElseIf nTableHookType = GDB_TY.CRV_LINE Then
' calcolo distanza linea hook tavola dal punto hook della ventosa
Dim nRefId As Integer = 0
Dim dU As Double = 0
EgtPointCurveDist(ptFixtHook, nCurrHookId, nRefId, dDist, dU)
EgtAtParamPoint(nCurrHookId, dU, GDB_ID.ROOT, ptCurrHook)
Return True
End If
Return False
End Function