1816 lines
75 KiB
VB.net
1816 lines
75 KiB
VB.net
Imports System.IO
|
|
Imports System.Windows.Interop
|
|
Imports System.Collections.ObjectModel
|
|
Imports System.Runtime.InteropServices
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Public Class VeinMatchingWindow
|
|
|
|
' Dichiarazione Scene
|
|
Friend WithEvents VeinMatchingScene As New Scene
|
|
Private VeinMatchingSceneHost As New System.Windows.Forms.Integration.WindowsFormsHost
|
|
' Gestione finestra
|
|
Private m_bFirst As Boolean = True
|
|
Private m_bPositioned As Boolean = False
|
|
' Selezione e modifica
|
|
Private m_nRestRadius As Integer = 3
|
|
Private m_dSnapDist As Double = 0
|
|
Private m_nIdToSel As Integer = GDB_ID.NULL
|
|
Private m_nIdToDesel As Integer = GDB_ID.NULL
|
|
Private m_bEnableEdit As Boolean = False
|
|
Private m_bVerify As Boolean = True
|
|
Private m_bCurrVerify As Boolean = True
|
|
Private m_bMagnetic As Boolean = False
|
|
Private m_bDrag As Boolean = False
|
|
Private m_bRotate As Boolean = False
|
|
Private m_bDragToStart As Boolean = False
|
|
Private m_bDragging As Boolean = False
|
|
Private m_locPrev As System.Drawing.Point
|
|
Private m_ptPrev As Point3d
|
|
Private m_ptCen As Point3d
|
|
' Gestione rotazione pezzi in fase di Drag
|
|
Private m_bKeyCtrlPressed As Boolean = False
|
|
Private m_bKeyLeftShiftPressed As Boolean = False
|
|
Private m_dAngTotal As Double = 0
|
|
Private m_dStartAng As Double = 0
|
|
Private m_bStartRot As Boolean = False
|
|
Private m_bStartMove As Boolean = False
|
|
|
|
Private Sub Window_Initialized(sender As Object, e As EventArgs)
|
|
' Assegnazione scena all'host e posizionamento nella PlacePageGrid
|
|
VeinMatchingSceneHost.Child = VeinMatchingScene
|
|
VeinMatchingSceneHost.SetValue(Grid.ColumnProperty, 1)
|
|
Me.VeinMatchingGrid.Children.Add(VeinMatchingSceneHost)
|
|
' Per non farla visualizzare alla creazione
|
|
Me.Left = 32000
|
|
' Assegno messaggi
|
|
ExportBtn.Content = EgtMsg(MSG_VEINMATCHING + 1) ' Esporta
|
|
ShowTextBtn.Content = EgtMsg(MSG_VEINMATCHING + 2) ' Mostra Info
|
|
EditBtn.Content = EgtMsg(MSG_VEINMATCHING + 3) ' Modifica
|
|
VerifyBtn.Content = EgtMsg(MSG_VEINMATCHING + 4) ' Verifica
|
|
MagneticBtn.Content = EgtMsg(MSG_VEINMATCHING + 5) ' Magnetico
|
|
End Sub
|
|
|
|
Private Sub Window_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
|
|
' Inizializzazioni da eseguire appena prima della prima visualizzazione
|
|
If m_bFirst Then
|
|
' Imposto finestra senza SystemMenu
|
|
Dim hwnd As IntPtr = New WindowInteropHelper(Me).Handle
|
|
SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) And Not WS_SYSMENU)
|
|
' imposto colore di default
|
|
Dim DefColor As New Color3d(0, 0, 0)
|
|
GetMainPrivateProfileColor(S_GEOMDB, K_DEFAULTCOLOR, DefColor)
|
|
VeinMatchingScene.SetDefaultMaterial(DefColor)
|
|
' imposto colori sfondo
|
|
Dim BackTopColor As New Color3d(211, 211, 211)
|
|
GetMainPrivateProfileColor(S_SCENE, K_BACKTOP, BackTopColor)
|
|
Dim BackBotColor As New Color3d(211, 211, 211)
|
|
GetMainPrivateProfileColor(S_SCENE, K_BACKBOTTOM, BackBotColor)
|
|
VeinMatchingScene.SetViewBackground(BackTopColor, BackBotColor)
|
|
' imposto colore di evidenziazione
|
|
Dim MarkColor As New Color3d(255, 255, 0)
|
|
GetMainPrivateProfileColor(S_SCENE, K_MARK, MarkColor)
|
|
VeinMatchingScene.SetMarkMaterial(MarkColor)
|
|
' imposto colore per superfici selezionate
|
|
Dim SelSurfColor As New Color3d(255, 255, 192)
|
|
GetMainPrivateProfileColor(S_SCENE, K_SELSURF, SelSurfColor)
|
|
VeinMatchingScene.SetSelSurfMaterial(SelSurfColor)
|
|
' imposto tipo e colore del rettangolo di zoom
|
|
Dim bOutline As Boolean = True
|
|
Dim ZwColor As New Color3d(0, 0, 0)
|
|
GetMainPrivateProfileZoomWin(S_SCENE, K_ZOOMWIN, bOutline, ZwColor)
|
|
VeinMatchingScene.SetZoomWinAttribs(bOutline, ZwColor)
|
|
' imposto colore della linea di distanza
|
|
Dim DstLnColor As New Color3d(255, 0, 0)
|
|
GetMainPrivateProfileColor(S_SCENE, K_DISTLINE, DstLnColor)
|
|
VeinMatchingScene.SetDistLineMaterial(DstLnColor)
|
|
' imposto parametri OpenGL
|
|
Dim nDriver As Integer = GetMainPrivateProfileInt(S_OPENGL, K_DRIVER, 3)
|
|
Dim b2Buff As Boolean = (GetMainPrivateProfileInt(S_OPENGL, K_DOUBLEBUFFER, 1) <> 0)
|
|
Dim nColorBits As Integer = GetMainPrivateProfileInt(S_OPENGL, K_COLORBITS, 32)
|
|
Dim nDepthBits As Integer = GetMainPrivateProfileInt(S_OPENGL, K_DEPTHBITS, 32)
|
|
VeinMatchingScene.SetViewAttributes(nDriver, b2Buff, nColorBits, nDepthBits)
|
|
' inizializzo la scena (DB geometrico + visualizzazione) e verifico presenza chiave
|
|
If Not VeinMatchingScene.Init() Then
|
|
Me.Close()
|
|
End If
|
|
' modo di visualizzazione
|
|
Dim nShowMode As Integer = GetMainPrivateProfileInt(S_SCENE, K_SHOWMODE, SM.SHADING)
|
|
EgtSetShowMode(DirectCast(nShowMode, SM))
|
|
' visualizzazione avanzata dei triangoli costituenti le superfici
|
|
Dim bShowTriaAdv As Boolean = (GetMainPrivateProfileInt(S_SCENE, K_SHOWTRIAADV, 1) <> 0)
|
|
EgtSetShowTriaAdv(bShowTriaAdv)
|
|
' tipo visualizzazione per Zmap
|
|
Dim nShowZmap As Integer = GetMainPrivateProfileInt(S_SCENE, K_SHOWZMAP, 1)
|
|
EgtSetShowZmap(DirectCast(nShowZmap, ZSM), False)
|
|
' dimensione lineare max in pixel delle textures
|
|
Dim nTxrMaxLinPix As Integer = GetMainPrivateProfileInt(S_SCENE, K_TEXMAXLINPIX, 4096)
|
|
EgtSetTextureMaxLinPixels(nTxrMaxLinPix)
|
|
' massimo movimento mouse considerato nullo
|
|
m_nRestRadius = GetMainPrivateProfileInt(S_NEST, K_RESTRADIUS, 3)
|
|
m_dSnapDist = GetMainPrivateProfileDouble(S_NEST, K_SNAPDIST, 50)
|
|
' imposto stato bottone ShowText
|
|
ShowTextBtn.IsChecked = VeinMatching.bShowText
|
|
' imposto stato bottoni Edit e Verify
|
|
EditBtn.IsChecked = m_bEnableEdit
|
|
VerifyBtn.IsEnabled = m_bEnableEdit
|
|
VerifyBtn.IsChecked = m_bVerify
|
|
MagneticBtn.IsEnabled = m_bEnableEdit And m_bVerify
|
|
MagneticBtn.IsChecked = m_bMagnetic
|
|
' dichiaro inizializzazioni eseguite
|
|
m_bFirst = False
|
|
End If
|
|
' inibisco selezione diretta da Scene
|
|
VeinMatchingScene.SetStatusNull()
|
|
End Sub
|
|
|
|
Private Sub Window_Closed(sender As Object, e As EventArgs) Handles Me.Closed
|
|
' Salvo posizione Window (se posizionata e non minimizzata)
|
|
If m_bPositioned And Me.WindowState <> WindowState.Minimized Then
|
|
Dim nFlag As Integer = If(Me.WindowState = WindowState.Maximized, 1, 0)
|
|
WriteMainPrivateProfileWinPos(S_VEINMATCHING, K_VEINMA_PLACE, nFlag, CInt(Me.Left), CInt(Me.Top), CInt(Me.Width), CInt(Me.Height))
|
|
End If
|
|
End Sub
|
|
|
|
Friend Sub AdjustPosition()
|
|
' Se già posizionata, esco subito
|
|
If m_bPositioned Then Return
|
|
' Imposto posizione e dimensioni della MainWindow da INI
|
|
Dim nFlag, nLeft, nTop, nWidth, nHeight As Integer
|
|
If GetMainPrivateProfileWinPos(S_VEINMATCHING, K_VEINMA_PLACE, nFlag, nLeft, nTop, nWidth, nHeight) Then
|
|
Dim PtTL = New System.Drawing.Point(nLeft, nTop)
|
|
Dim s As System.Windows.Forms.Screen = System.Windows.Forms.Screen.FromPoint(PtTL)
|
|
If s.Bounds.Contains(PtTL) Then
|
|
Me.WindowStartupLocation = Windows.WindowStartupLocation.Manual
|
|
Me.Top = nTop
|
|
Me.Left = nLeft
|
|
Me.Height = nHeight
|
|
Me.Width = nWidth
|
|
Me.WindowState = If(nFlag = 1, WindowState.Maximized, WindowState.Normal)
|
|
m_bPositioned = True
|
|
VeinMatching.ZoomAll()
|
|
Return
|
|
End If
|
|
End If
|
|
' Imposto in posizione standard
|
|
Me.WindowStartupLocation = Windows.WindowStartupLocation.Manual
|
|
Me.Top = Application.Current.MainWindow.Top
|
|
Me.Left = Application.Current.MainWindow.Left
|
|
Me.Height = nHeight
|
|
Me.Width = nWidth
|
|
Me.WindowState = If(nFlag = 1, WindowState.Maximized, WindowState.Normal)
|
|
m_bPositioned = True
|
|
VeinMatching.ZoomAll()
|
|
End Sub
|
|
|
|
Private Sub OnMouseDownScene(sender As Object, e As Windows.Forms.MouseEventArgs) Handles VeinMatchingScene.OnMouseDownScene
|
|
' Per default no drag
|
|
m_bDrag = False
|
|
' Si può selezionare solo con il tasto sinistro e se stato NULL
|
|
If e.Button <> Windows.Forms.MouseButtons.Left Or Not VeinMatchingScene.IsStatusNull() Then Return
|
|
' Eseguo selezione
|
|
EgtSetObjFilterForSelWin(True, True, True, True, True)
|
|
Dim nSel As Integer
|
|
EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSel)
|
|
' Ricavo nome dell'entità selezionata e identificativo
|
|
Dim nId As Integer = EgtGetFirstObjInSelWin()
|
|
While nId <> GDB_ID.NULL
|
|
' Cerco l'identificativo del pezzo cui appartiene
|
|
Dim nPartId As Integer = EgtGetParent(EgtGetParent(nId))
|
|
If EgtIsPart(nPartId) Then
|
|
Dim nStat As Integer = GDB_ST.ON_
|
|
EgtGetStatus(nPartId, nStat)
|
|
' Se già selezionato o posizione oggetto incompatibile con flag posizione selezionati
|
|
If nStat = GDB_ST.SEL Then
|
|
' Memorizzo Id da deselezionare
|
|
m_nIdToDesel = nPartId
|
|
Else
|
|
' Memorizzo Id da selezionare
|
|
m_nIdToSel = nPartId
|
|
End If
|
|
If m_bEnableEdit Then m_bDrag = True
|
|
EgtDraw()
|
|
Exit While
|
|
End If
|
|
' Passo al successivo
|
|
nId = EgtGetNextObjInSelWin()
|
|
End While
|
|
' Se abilitata modifica, dati per drag
|
|
If m_bEnableEdit Then
|
|
m_locPrev = e.Location
|
|
m_bDrag = m_bDrag AndAlso EgtUnProjectPoint(e.Location, m_ptPrev)
|
|
m_bCurrVerify = m_bVerify And (Keyboard.Modifiers And ModifierKeys.Shift) = 0
|
|
m_bRotate = m_bDrag AndAlso (Keyboard.Modifiers And ModifierKeys.Control) > 0
|
|
m_bDragToStart = m_bDrag
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub OnMouseMoveScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles VeinMatchingScene.OnMouseMoveScene
|
|
' Se drag non abilitato o già in esecuzione, esco
|
|
If Not m_bDrag Or m_bDragging Then Return
|
|
' Determino cosa muovere
|
|
Dim nMoveId = If(m_nIdToSel <> GDB_ID.NULL, m_nIdToSel, GDB_ID.SEL)
|
|
' Se primo movimento di drag, verifico di aver superato la soglia di movimento in pixel
|
|
If m_bDragToStart Then
|
|
If Math.Abs(e.Location.X - m_locPrev.X) < m_nRestRadius And
|
|
Math.Abs(e.Location.Y - m_locPrev.Y) < m_nRestRadius Then
|
|
Return
|
|
End If
|
|
If m_bRotate Then
|
|
If Not EgtGetPartPartClusterCenterGlob(nMoveId, m_ptCen) Then Return
|
|
End If
|
|
m_bDragToStart = False
|
|
End If
|
|
' Inizio esecuzione di drag
|
|
m_bDragging = True
|
|
' Ricavo il punto corrente in coordinate mondo
|
|
Dim ptCurr As Point3d
|
|
EgtUnProjectPoint(e.Location, ptCurr)
|
|
' Se traslazione
|
|
If Not m_bRotate Then
|
|
' Ricavo il vettore di movimento
|
|
Dim vtMove As Vector3d = ptCurr - m_ptPrev
|
|
' Eseguo il movimento
|
|
If vtMove.SqLen() > EPS_SMALL * EPS_SMALL Then
|
|
' Con verifica di collisione
|
|
If m_bCurrVerify Then
|
|
EgtMovePart(nMoveId, True, vtMove)
|
|
EgtSaveCollInfo()
|
|
' se movimento risultante nullo, provo con movimento tangente
|
|
Dim bTgMoved As Boolean = False
|
|
If vtMove.IsSmall() Then
|
|
' riprovo con movimento tangente
|
|
Dim vtTgMove As Vector3d = ptCurr - m_ptPrev
|
|
EgtTgMovePartOnCollision(nMoveId, True, vtTgMove)
|
|
bTgMoved = (Not vtTgMove.IsSmall())
|
|
End If
|
|
' se abilitato magnetico (allineamento + snap), lo provo
|
|
Dim bAlignMoved As Boolean = False
|
|
Dim bSnapMoved As Boolean = False
|
|
If m_bMagnetic Then
|
|
EgtAlignPartOnCollision(nMoveId, True, bAlignMoved)
|
|
If m_dSnapDist > EPS_SMALL Then
|
|
EgtRestoreCollInfo()
|
|
' !!! Questa funzione usa i tagli, bisogna modificarla per farla funzionare in questo caso !!!
|
|
EgtMovePartToSnapPointOnCollision(nMoveId, True, m_dSnapDist, bSnapMoved)
|
|
End If
|
|
End If
|
|
' Standard
|
|
Else
|
|
EgtMove(nMoveId, vtMove)
|
|
End If
|
|
VeinMatching.SetProjectModified()
|
|
EgtDraw()
|
|
End If
|
|
' altrimenti rotazione
|
|
Else
|
|
' Ricavo l'angolo di movimento
|
|
Dim vtPrev As Vector3d = m_ptPrev - m_ptCen
|
|
Dim vtCurr As Vector3d = ptCurr - m_ptCen
|
|
Dim dAngRotDeg As Double = Math.Atan2(Vector3d.CrossXY(vtPrev, vtCurr), Vector3d.ScalarXY(vtPrev, vtCurr)) * 180.0 / Math.PI
|
|
If Math.Abs(dAngRotDeg) > EPS_ANG_SMALL Then
|
|
' Con verifica di collisione
|
|
If m_bCurrVerify Then
|
|
EgtRotatePart(nMoveId, True, m_ptCen, dAngRotDeg)
|
|
' Standard
|
|
Else
|
|
EgtRotate(nMoveId, m_ptCen, Vector3d.Z_AX(), dAngRotDeg, GDB_RT.GLOB)
|
|
End If
|
|
VeinMatching.SetProjectModified()
|
|
EgtDraw()
|
|
End If
|
|
End If
|
|
' Aggiorno il punto precedente
|
|
m_ptPrev = ptCurr
|
|
' Terminata esecuzione di drag
|
|
m_bDragging = False
|
|
End Sub
|
|
|
|
Private Sub OnMouseUpScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles VeinMatchingScene.OnMouseUpScene
|
|
' Se abilitata modifica
|
|
If m_bEnableEdit Then
|
|
' Se eseguito drag
|
|
If Not m_bDragToStart Then
|
|
' Non serve fare alcunché
|
|
' Se selezione da eseguire
|
|
ElseIf m_nIdToSel <> GDB_ID.NULL Then
|
|
' Eseguo la selezione
|
|
EgtSelectObj(m_nIdToSel)
|
|
' Se deselezione da eseguire
|
|
ElseIf m_nIdToDesel <> GDB_ID.NULL Then
|
|
EgtDeselectObj(m_nIdToDesel)
|
|
End If
|
|
' Altrimenti selezione/deselezione anche per nesting
|
|
Else
|
|
' Se selezione da eseguire
|
|
If m_nIdToSel <> GDB_ID.NULL Then
|
|
' Eseguo la selezione in Nesting
|
|
Dim bSelected As Boolean = False
|
|
Dim nOriId As Integer = GDB_ID.NULL
|
|
EgtGetInfo(m_nIdToSel, KEY_ORI_ID, nOriId)
|
|
If EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx()) AndAlso EgtExistsObj(nOriId) Then
|
|
Dim nMachGrpId As Integer
|
|
If (OmagOFFICEMap.refNestingTabVM.SelectPart(nOriId, False, nMachGrpId)) Then
|
|
bSelected = True
|
|
Else
|
|
If nMachGrpId = GDB_ID.NULL Then
|
|
' "Attenzione" "Pezzo non selezionabile in questa condizione"
|
|
MessageBox.Show(Me, EgtMsg(91606), EgtMsg(91122), MessageBoxButton.OK, MessageBoxImage.Exclamation)
|
|
Else
|
|
Dim sMachGrpName As String = String.Empty
|
|
EgtGetMachGroupName(nMachGrpId, sMachGrpName)
|
|
' "Attenzione" "Pezzo non selezionabile perchè appartenente a gruppo di lavoro non corrente :" ...
|
|
MessageBox.Show(Me, EgtMsg(91607) & " " & sMachGrpName, EgtMsg(91122), MessageBoxButton.OK, MessageBoxImage.Exclamation)
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
EgtSetCurrentContext(VeinMatchingScene.GetCtx())
|
|
' Se selezione riuscita, la eseguo anche in VME
|
|
If bSelected Then EgtSelectObj(m_nIdToSel)
|
|
' Se deselezione da eseguire
|
|
ElseIf m_nIdToDesel <> GDB_ID.NULL Then
|
|
' Eseguo la deselezione in Nesting
|
|
Dim bDeselected As Boolean = False
|
|
Dim nOriId As Integer = GDB_ID.NULL
|
|
EgtGetInfo(m_nIdToDesel, KEY_ORI_ID, nOriId)
|
|
If EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx()) AndAlso EgtExistsObj(nOriId) Then
|
|
If (OmagOFFICEMap.refNestingTabVM.DeselectPart(nOriId, False)) Then
|
|
bDeselected = True
|
|
End If
|
|
End If
|
|
EgtSetCurrentContext(VeinMatchingScene.GetCtx())
|
|
' Se deselezione riuscita, la eseguo anche in VME
|
|
If bDeselected Then EgtDeselectObj(m_nIdToDesel)
|
|
End If
|
|
End If
|
|
' Reset
|
|
m_bDrag = False
|
|
m_nIdToSel = GDB_ID.NULL
|
|
m_nIdToDesel = GDB_ID.NULL
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Sub ShowTextBtn_Click(sender As Object, e As RoutedEventArgs) Handles ShowTextBtn.Click
|
|
VeinMatching.SetShowText(If(ShowTextBtn.IsChecked, False))
|
|
End Sub
|
|
|
|
Private Sub EditBtn_Click(sender As Object, e As RoutedEventArgs) Handles EditBtn.Click
|
|
' Impostazione stato di modifica
|
|
m_bEnableEdit = If(EditBtn.IsChecked, False)
|
|
If Not m_bEnableEdit Then
|
|
EgtDeselectAll()
|
|
EgtDraw()
|
|
End If
|
|
VerifyBtn.IsEnabled = m_bEnableEdit
|
|
MagneticBtn.IsEnabled = m_bEnableEdit And m_bVerify
|
|
End Sub
|
|
|
|
Private Sub VerifyBtn_Click(sender As Object, e As RoutedEventArgs) Handles VerifyBtn.Click
|
|
m_bVerify = If(VerifyBtn.IsChecked, False)
|
|
MagneticBtn.IsEnabled = m_bEnableEdit And m_bVerify
|
|
End Sub
|
|
|
|
Private Sub MagneticBtn_Click(sender As Object, e As RoutedEventArgs) Handles MagneticBtn.Click
|
|
m_bMagnetic = If(MagneticBtn.IsChecked, False)
|
|
End Sub
|
|
|
|
Private Sub ExportBtn_Click(sender As Object, e As RoutedEventArgs) Handles ExportBtn.Click
|
|
Dim SaveFileDialog As New Microsoft.Win32.SaveFileDialog
|
|
SaveFileDialog.Title = "Export"
|
|
SaveFileDialog.Filter = "Images Png (*.png)|*.png" &
|
|
"|Images Jpeg (*.jpg;*.jpeg)|*.jpg;*.jpeg" &
|
|
"|Images Bitmap (*.bmp)|*.bmp"
|
|
SaveFileDialog.FilterIndex = 2
|
|
If Not SaveFileDialog.ShowDialog Then Return
|
|
VeinMatching.Export(SaveFileDialog.FileName)
|
|
End Sub
|
|
|
|
Private Sub AssemblyBtn_Click(sender As Object, e As RoutedEventArgs) Handles AssemblyBtn.Click
|
|
EstCalc.UpdateRawPart()
|
|
' lo spessore deve essere aggiornato per ogni lastra! (devo cicolare sull'elenco delle "macchinate"
|
|
Dim ThicknessRaw As Double = EstCalc.GetRawHeight
|
|
VeinMatching.AssemblyParts(ThicknessRaw)
|
|
End Sub
|
|
|
|
Private Sub Scene_KeyDown(sender As System.Object, e As System.Windows.Forms.KeyEventArgs) Handles VeinMatchingScene.KeyDown
|
|
' Con DEL eseguo cancellazione dei pezzi selezionati
|
|
If e.KeyData = System.Windows.Forms.Keys.Delete Then
|
|
' Se non ci sono oggetti selezionati, esco
|
|
If Not VeinMatching.SelectedObjects() Then Return
|
|
' Sei sicuro di voler cancellare i pezzi selezionati ?
|
|
If MessageBox.Show(EgtMsg(MSG_EGTMSGBOX + 21), "", MessageBoxButton.OKCancel, MessageBoxImage.Question) = MessageBoxResult.Cancel Then Return
|
|
VeinMatching.RemoveAllSelectedParts()
|
|
EgtDraw()
|
|
End If
|
|
End Sub
|
|
|
|
End Class
|
|
|
|
Friend Module VeinMatching
|
|
|
|
' Contesto del VeinMatching
|
|
Friend m_nVeinCtx As Integer = 0
|
|
' Nome fotografia
|
|
Private m_nPhoto As Integer = 0
|
|
' Dimensioni immagine da esportare
|
|
Private m_nImgWidth As Integer = 1600
|
|
Private m_nImgHeight As Integer = 1200
|
|
' Lista delle alzatine
|
|
Private m_ListAlzFront As New ObservableCollection(Of Aletta)
|
|
' Flag visualizzazione testi
|
|
Private m_bShowText As Boolean = True
|
|
Friend ReadOnly Property bShowText As Boolean
|
|
Get
|
|
Return m_bShowText
|
|
End Get
|
|
End Property
|
|
|
|
' Costanti
|
|
Const REF_NAME As String = "Ref"
|
|
Const KEY_ORI_REF As String = "OriRef"
|
|
Const DIM_REG As Double = 100000
|
|
Const SAFE_DIST As Double = 2000
|
|
Const WIDTH_ADD_REG As Double = 4000
|
|
|
|
Friend Function SetExportImageDim(nImgWidth As Integer, nImgHeight As Integer) As Boolean
|
|
m_nImgWidth = nImgWidth
|
|
m_nImgHeight = nImgHeight
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function SetRefOnAllParts() As Boolean
|
|
' Si opera nel contesto corrente
|
|
Dim nId As Integer = EgtGetFirstPart()
|
|
While nId <> GDB_ID.NULL
|
|
' Gruppo regione
|
|
Dim nRegLayId As Integer = EgtGetFirstNameInGroup(nId, NAME_REGION)
|
|
' Entità superficie regione piatta
|
|
Dim nRegId As Integer = EgtGetFirstInGroup(nRegLayId)
|
|
While nRegId <> GDB_ID.NULL
|
|
If EgtGetType(nRegId) = GDB_TY.SRF_FRGN Then
|
|
Exit While
|
|
End If
|
|
nRegId = EgtGetNext(nRegId)
|
|
End While
|
|
' Ne recupero il centroide
|
|
Dim ptCen As Point3d
|
|
EgtCentroid(nRegId, GDB_ID.ROOT, ptCen)
|
|
' Inserisco il riferimento
|
|
Dim frRef As New Frame3d(ptCen)
|
|
Dim nRefId As Integer = EgtCreateGeoFrame(nRegLayId, frRef, GDB_RT.GLOB)
|
|
EgtSetName(nRefId, REF_NAME)
|
|
' salvo nelle info il riferimento originale
|
|
EgtSetInfo(nRefId, KEY_ORI_REF, frRef)
|
|
' nascondo l'oggetto appena inserito
|
|
EgtSetMode(nRefId, GDB_MD.HIDDEN)
|
|
' Passo al pezzo successivo
|
|
nId = EgtGetNextPart(nId)
|
|
End While
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function SetRefOnPart(nId As Integer) As Boolean
|
|
' Si opera nel contesto corrente
|
|
' Verifico validità identificativo oggetto
|
|
If nId = GDB_ID.NULL Then Return False
|
|
' Recupero gruppo regione
|
|
Dim nRegLayId As Integer = EgtGetFirstNameInGroup(nId, NAME_REGION)
|
|
' Se c'è già il riferimento, esco
|
|
If EgtGetFirstNameInGroup(nRegLayId, REF_NAME) <> GDB_ID.NULL Then Return True
|
|
' Entità superficie regione piatta
|
|
Dim nRegId As Integer = EgtGetFirstInGroup(nRegLayId)
|
|
While nRegId <> GDB_ID.NULL
|
|
If EgtGetType(nRegId) = GDB_TY.SRF_FRGN Then
|
|
Exit While
|
|
End If
|
|
nRegId = EgtGetNext(nRegId)
|
|
End While
|
|
' Ne recupero il centroide
|
|
Dim ptCen As Point3d
|
|
EgtCentroid(nRegId, GDB_ID.ROOT, ptCen)
|
|
' Inserisco il riferimento
|
|
Dim frRef As New Frame3d(ptCen)
|
|
Dim nRefId As Integer = EgtCreateGeoFrame(nRegLayId, frRef, GDB_RT.GLOB)
|
|
EgtSetName(nRefId, REF_NAME)
|
|
' salvo nelle info il riferimento originale
|
|
EgtSetInfo(nRefId, KEY_ORI_REF, frRef)
|
|
' nascondo l'oggetto appena inserito
|
|
EgtSetMode(nRefId, GDB_MD.HIDDEN)
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function PutAllPartsOnValidPosition() As Boolean
|
|
' Recupero ingombro dell'insieme dei pezzi
|
|
Dim b3Parts As New BBox3d()
|
|
Dim PartId As Integer = EgtGetFirstPart()
|
|
While PartId <> GDB_ID.NULL
|
|
Dim b3Tmp As New BBox3d()
|
|
if EgtGetBBoxGlob( PartId, GDB_BB.STANDARD, b3Tmp) Then b3Parts.Add( b3Tmp)
|
|
PartId = EgtGetNextPart(PartId)
|
|
End While
|
|
' Se ingombro troppo grande, errore
|
|
If b3Parts.DimX() > 2 * ( DIM_REG - SAFE_DIST) Or b3Parts.DimY() > 2 * ( DIM_REG - SAFE_DIST) Then
|
|
Return False
|
|
End If
|
|
' Se fuori dalla regione di validità, li muovo
|
|
Dim vtMove As New Vector3d
|
|
If b3Parts.Min().x < -DIM_REG + SAFE_DIST Then
|
|
vtMove += New Vector3d( -DIM_REG + SAFE_DIST - b3Parts.Min().x, 0, 0)
|
|
End If
|
|
If b3Parts.Min().y < -DIM_REG + SAFE_DIST Then
|
|
vtMove += New Vector3d( 0, -DIM_REG + SAFE_DIST - b3Parts.Min().y, 0)
|
|
End If
|
|
If b3Parts.Max().x > DIM_REG - SAFE_DIST Then
|
|
vtMove += New Vector3d( DIM_REG - SAFE_DIST - b3Parts.Max().x, 0, 0)
|
|
End If
|
|
If b3Parts.Max().y > DIM_REG - SAFE_DIST Then
|
|
vtMove += New Vector3d( 0, DIM_REG - SAFE_DIST - b3Parts.Max().y, 0)
|
|
End If
|
|
If Not vtMove.IsSmall() Then
|
|
PartId = EgtGetFirstPart()
|
|
While PartId <> GDB_ID.NULL
|
|
EgtMove( PartId, vtMove, GDB_RT.GLOB)
|
|
PartId = EgtGetNextPart(PartId)
|
|
End While
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function AddPart(nPartId As Integer, Optional bPack As Boolean = False) As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Se esiste già il pezzo nel VM, esco
|
|
If GetVeinPartId(nPartId) <> GDB_ID.NULL Then Return True
|
|
' Verifico validità pezzo
|
|
If nPartId = GDB_ID.NULL Then Return False
|
|
' Salvo il pezzo su file temporaneo
|
|
Dim sTmpDir As String = String.Empty
|
|
If Not EgtGetTempDir(sTmpDir) Then Return False
|
|
Dim sTmpFile As String = sTmpDir & "\FlatPartVme.Nge"
|
|
EgtSaveObjToFile(nPartId, sTmpFile, NGE.BIN)
|
|
' Carico il file nel VM
|
|
Dim bOk As Boolean = My.Computer.FileSystem.FileExists(sTmpFile)
|
|
If bOk Then
|
|
bOk = AddPart(sTmpFile, nPartId, bPack)
|
|
' Ne aggiorno la visualizzazione
|
|
ZoomAll()
|
|
' Cancello il file
|
|
My.Computer.FileSystem.DeleteFile(sTmpFile)
|
|
End If
|
|
Return bOk
|
|
End Function
|
|
|
|
Friend Function AddPart(sPartFile As String, nPartId As Integer, Optional bPack As Boolean = False) As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Se esiste già il pezzo nel VM, esco
|
|
If GetVeinPartId(nPartId) <> GDB_ID.NULL Then Return True
|
|
' Imposto VeinMatching context
|
|
Dim nMainCtx = SetVeinContext()
|
|
If nMainCtx = 0 Then Return False
|
|
' Inserisco il pezzo
|
|
EgtInsertFile(sPartFile)
|
|
' Ne recupero l'Id
|
|
Dim nVeinId2 As Integer = EgtGetLastPart()
|
|
' Elimino eventuali preview delle lavorazioni
|
|
EgtErase(EgtGetFirstNameInGroup(nVeinId2, NAME_PREVIEW))
|
|
' Assegno Id originale
|
|
EgtSetInfo(nVeinId2, KEY_ORI_ID, nPartId)
|
|
' Ne garantisco la visibilità
|
|
Dim nStat As Integer = GDB_ST.OFF
|
|
If Not EgtGetStatus( nVeinId2, nStat) OrElse nStat <> GDB_ST.ON_ Then
|
|
EgtSetStatus( nVeinId2, GDB_ST.ON_)
|
|
End If
|
|
' Se impostato, nascondo scritte, sono nel layer "Region"
|
|
If Not m_bShowText Then
|
|
Dim nVeinRegId As Integer = EgtGetFirstNameInGroup(nVeinId2, NAME_REGION)
|
|
Dim nCurrId As Integer = EgtGetFirstInGroup(nVeinRegId)
|
|
While nCurrId <> GDB_ID.NULL
|
|
If EgtGetType(nCurrId) = GDB_TY.EXT_TEXT Then EgtSetStatus(nCurrId, GDB_ST.OFF)
|
|
nCurrId = EgtGetNext(nCurrId)
|
|
End While
|
|
End If
|
|
' Nascondo layer con valori angoli dei lati
|
|
Dim nLayAngId As Integer = EgtGetFirstNameInGroup(nVeinId2, SIDE_ANGLE_LAYER)
|
|
EgtSetStatus(nLayAngId, GDB_ST.OFF)
|
|
' Se richiesto, eseguo pack
|
|
If bPack Then EgtPackBox(nVeinId2, 0, 0, WIDTH_ADD_REG, DIM_REG, 0, True)
|
|
' Se necessario, ripristino il contesto originale
|
|
If nMainCtx > 0 Then EgtSetCurrentContext(nMainCtx)
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function AddParts(sPartFile As String, nFirstPartId As Integer, Optional bPack As Boolean = False) As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Imposto VeinMatching context
|
|
Dim nMainCtx = SetVeinContext()
|
|
If nMainCtx = 0 Then Return False
|
|
' Inserisco i pezzi e recupero Id primo pezzo inserito
|
|
Dim nFirstVeinId As Integer = EgtGetLastPart()
|
|
EgtInsertFile(sPartFile)
|
|
nFirstVeinId = If(nFirstVeinId <> GDB_ID.NULL, EgtGetNextPart(nFirstVeinId), EgtGetFirstPart())
|
|
' Ciclo sui pezzi inseriti
|
|
Dim nVeinId As Integer = nFirstVeinId
|
|
While nVeinId <> GDB_ID.NULL
|
|
' Calcolo Id originale
|
|
Dim nOrigId As Integer = nFirstPartId + nVeinId - nFirstVeinId
|
|
' Se già presente un pezzo con questo Id originale, elimino nuovo pezzo e vado al successivo
|
|
If GetVeinPartId(nOrigId) <> GDB_ID.NULL Then
|
|
Dim nToEraseId As Integer = nVeinId
|
|
nVeinId = EgtGetNextPart(nVeinId)
|
|
EgtErase(nToEraseId)
|
|
Continue While
|
|
End If
|
|
' Assegno Id originale
|
|
EgtSetInfo(nVeinId, KEY_ORI_ID, nOrigId)
|
|
' Nascondo scritte, sono nel layer "Region"
|
|
Dim nVeinRegId As Integer = EgtGetFirstNameInGroup(nVeinId, NAME_REGION)
|
|
Dim nCurrId As Integer = EgtGetFirstInGroup(nVeinRegId)
|
|
While nCurrId <> GDB_ID.NULL
|
|
If EgtGetType(nCurrId) = GDB_TY.EXT_TEXT Then EgtSetStatus(nCurrId, GDB_ST.OFF)
|
|
nCurrId = EgtGetNext(nCurrId)
|
|
End While
|
|
' Nascondo layer con valori angoli dei lati
|
|
nCurrId = EgtGetFirstNameInGroup(nVeinId, SIDE_ANGLE_LAYER)
|
|
EgtSetStatus(nCurrId, GDB_ST.OFF)
|
|
' Se richiesto, eseguo pack
|
|
If bPack Then EgtPackBox(nVeinId, 0, 0, WIDTH_ADD_REG, DIM_REG, 0, True)
|
|
' Passo al pezzo successivo
|
|
nVeinId = EgtGetNextPart(nVeinId)
|
|
End While
|
|
' Se necessario, ripristino il contesto originale
|
|
If nMainCtx > 0 Then EgtSetCurrentContext(nMainCtx)
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function OnInsertPartInRaw(nPartId As Integer, Optional bDeselect As Boolean = True) As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Recupero il contesto corrente (principale)
|
|
Dim nMainCtx = EgtGetCurrentContext()
|
|
' Se non c'è la fotografia, esco
|
|
Dim nPhotoId As Integer = EstPhoto.GetPhoto()
|
|
If nPhotoId = GDB_ID.NULL Then Return If(bDeselect, OnDeselectPart(nPartId), True)
|
|
' Recupero il nome originale del pezzo
|
|
Dim nOriId As Integer = nPartId
|
|
EgtGetInfo(nPartId, KEY_ORI_ID, nOriId)
|
|
' Recupero la path originale della foto
|
|
Dim sPhoto As String = String.Empty
|
|
EgtGetPhotoPath(nPhotoId, sPhoto)
|
|
' Verifico se esiste già questa foto nel VeinMatching
|
|
Dim sVeinPhoto As String = String.Empty
|
|
Dim nInd As Integer = 1
|
|
While nInd <= m_nPhoto
|
|
If GetVeinPhotoPath(nInd, sVeinPhoto) AndAlso
|
|
String.Compare(sPhoto, sVeinPhoto, True) = 0 Then
|
|
Exit While
|
|
End If
|
|
nInd += 1
|
|
End While
|
|
' Se necessario, copio la foto
|
|
If nInd > m_nPhoto Then
|
|
If Not CopyPhoto(nPhotoId) Then Return False
|
|
nInd = m_nPhoto
|
|
End If
|
|
' Recupero il pezzo nel VeinMatching
|
|
EgtSetCurrentContext(m_nVeinCtx)
|
|
Dim nId = GetVeinPartId(nOriId)
|
|
If nId <> GDB_ID.NULL Then
|
|
' Recupero la regione del pezzo
|
|
Dim nRegId As Integer = GetVeinPartRegionId(nId)
|
|
' Gli assegno la texture della foto
|
|
EgtSetTextureName(nRegId, GetVeinPhotoName(nInd))
|
|
' Sistemo il riferimento della texture
|
|
Dim refTxr As New Frame3d
|
|
GetVeinRefPhoto(nMainCtx, nPartId, nId, refTxr)
|
|
EgtSetTextureFrame(nRegId, refTxr, GDB_RT.GLOB)
|
|
' Sistemo il colore
|
|
Dim colWhite As New Color3d(255, 255, 255, 100)
|
|
EgtSetColor(nRegId, colWhite)
|
|
|
|
' Ripeto le stesse operazioni con il solido del pezzo, se esiste
|
|
Dim nSolidId As Integer = GetVeinPartSolidId(nId)
|
|
If nSolidId <> GDB_ID.NULL Then
|
|
EgtSetTextureName(nSolidId, GetVeinPhotoName(nInd))
|
|
EgtSetTextureFrame(nSolidId, refTxr, GDB_RT.GLOB)
|
|
EgtSetColor(nSolidId, colWhite)
|
|
End If
|
|
|
|
' Se richiesto, eseguo deselezione
|
|
If bDeselect Then EgtDeselectObj(nId)
|
|
End If
|
|
EgtDraw()
|
|
EgtSetCurrentContext(nMainCtx)
|
|
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function OnMovePartInRaw(nPartId As Integer) As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Recupero il contesto corrente (principale)
|
|
Dim nMainCtx = EgtGetCurrentContext()
|
|
' Se non c'è la fotografia, esco
|
|
Dim nPhotoId As Integer = EstPhoto.GetPhoto()
|
|
If nPhotoId = GDB_ID.NULL Then Return True
|
|
' Recupero il nome originale del pezzo
|
|
Dim nOriId As Integer = nPartId
|
|
EgtGetInfo(nPartId, KEY_ORI_ID, nOriId)
|
|
' Recupero il pezzo nel VeinMatching
|
|
EgtSetCurrentContext(m_nVeinCtx)
|
|
Dim nId = GetVeinPartId(nOriId)
|
|
If nId <> GDB_ID.NULL Then
|
|
' Recupero la regione del pezzo
|
|
Dim nRegId As Integer = GetVeinPartRegionId(nId)
|
|
Dim nSolidId As Integer = GetVeinPartSolidId(nId)
|
|
' Sistemo il riferimento della texture
|
|
Dim refTxr As New Frame3d
|
|
GetVeinRefPhoto(nMainCtx, nPartId, nId, refTxr)
|
|
EgtSetTextureFrame(nRegId, refTxr, GDB_RT.GLOB)
|
|
If nSolidId <> GDB_ID.NULL Then
|
|
EgtSetTextureFrame(nSolidId, refTxr, GDB_RT.GLOB)
|
|
End If
|
|
EgtDraw()
|
|
End If
|
|
EgtSetCurrentContext(nMainCtx)
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function OnRemovePartFromRaw(nPartId As Integer, Optional bDeselect As Boolean = True) As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Recupero il contesto corrente (principale)
|
|
Dim nMainCtx = EgtGetCurrentContext()
|
|
' Se non c'è la fotografia, esco
|
|
Dim nPhotoId As Integer = EstPhoto.GetPhoto()
|
|
If nPhotoId = GDB_ID.NULL Then Return If(bDeselect, OnDeselectPart(nPartId), True)
|
|
' Recupero il nome originale del pezzo
|
|
Dim nOriId As Integer = nPartId
|
|
EgtGetInfo(nPartId, KEY_ORI_ID, nOriId)
|
|
' Tolgo la texture dal pezzo
|
|
EgtSetCurrentContext(m_nVeinCtx)
|
|
Dim nId As Integer = GetVeinPartId(nOriId)
|
|
If nId <> GDB_ID.NULL Then
|
|
' Recupero la regione del pezzo
|
|
Dim nRegId As Integer = GetVeinPartRegionId(nId)
|
|
' Gli tolgo la texture
|
|
EgtRemoveTextureData(nRegId)
|
|
' Sistemo il colore
|
|
Dim colRegion As Color3d
|
|
EgtGetColor(EgtGetParent(nRegId), colRegion)
|
|
EgtSetColor(nRegId, colRegion)
|
|
' ripeto per il solido
|
|
Dim nSolidId As Integer = GetVeinPartSolidId(nId)
|
|
If nSolidId <> GDB_ID.NULL Then
|
|
EgtRemoveTextureData(nSolidId)
|
|
EgtSetColor(nSolidId, colRegion)
|
|
End If
|
|
' Se richiesto, eseguo deselezione
|
|
If bDeselect Then EgtDeselectObj(nId)
|
|
EgtDraw()
|
|
End If
|
|
EgtSetCurrentContext(nMainCtx)
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function OnRemovePart(nPartId As Integer, Optional bDraw As Boolean = True) As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Recupero il contesto corrente (principale)
|
|
Dim nMainCtx = EgtGetCurrentContext()
|
|
' Recupero il nome originale del pezzo
|
|
Dim nOriId As Integer = nPartId
|
|
EgtGetInfo(nPartId, KEY_ORI_ID, nOriId)
|
|
' Recupero il pezzo nel VeinMatching e lo cancello
|
|
EgtSetCurrentContext(m_nVeinCtx)
|
|
Dim nId = GetVeinPartId(nOriId)
|
|
If nId <> GDB_ID.NULL Then
|
|
EgtErase(nId)
|
|
If bDraw Then EgtDraw()
|
|
End If
|
|
' Ritorno al contesto originale
|
|
EgtSetCurrentContext(nMainCtx)
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function OnSelectPart(nPartId As Integer, Optional bDraw As Boolean = True) As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Recupero il contesto corrente (principale)
|
|
Dim nMainCtx = EgtGetCurrentContext()
|
|
' Recupero il nome originale del pezzo
|
|
Dim nOriId As Integer = nPartId
|
|
EgtGetInfo(nPartId, KEY_ORI_ID, nOriId)
|
|
' Recupero il pezzo nel VeinMatching
|
|
EgtSetCurrentContext(m_nVeinCtx)
|
|
Dim nId = GetVeinPartId(nOriId)
|
|
Dim bFound As Boolean = nId <> GDB_ID.NULL
|
|
' Lo seleziono e aggiorno visualizzazione
|
|
If bFound Then
|
|
EgtSelectObj(nId)
|
|
If bDraw Then EgtDraw()
|
|
End If
|
|
' Ritorno al contesto originale
|
|
EgtSetCurrentContext(nMainCtx)
|
|
Return bFound
|
|
End Function
|
|
|
|
Friend Function OnDeselectPart(nPartId As Integer) As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Recupero il contesto corrente (principale)
|
|
Dim nMainCtx = EgtGetCurrentContext()
|
|
' Recupero il nome originale del pezzo
|
|
Dim nOriId As Integer = nPartId
|
|
EgtGetInfo(nPartId, KEY_ORI_ID, nOriId)
|
|
' Recupero il pezzo nel VeinMatching
|
|
EgtSetCurrentContext(m_nVeinCtx)
|
|
Dim nId = GetVeinPartId(nOriId)
|
|
Dim bFound As Boolean = nId <> GDB_ID.NULL
|
|
' Lo seleziono
|
|
If bFound Then EgtDeselectObj(nId)
|
|
' Aggiorno visualizzazione e ritorno al contesto originale
|
|
EgtDraw()
|
|
EgtSetCurrentContext(nMainCtx)
|
|
Return bFound
|
|
End Function
|
|
|
|
Friend Function OnSelectAll() As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Imposto VeinMatching context
|
|
Dim nCurrCtx = SetVeinContext()
|
|
If nCurrCtx = 0 Then Return False
|
|
' Eseguo selezione di tutti i pezzi
|
|
EgtSelectAll()
|
|
EgtDraw()
|
|
' Se necessario, ripristino il contesto originale
|
|
If nCurrCtx > 0 Then EgtSetCurrentContext(nCurrCtx)
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function OnDeselectAll() As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Imposto VeinMatching context
|
|
Dim nCurrCtx = SetVeinContext()
|
|
If nCurrCtx = 0 Then Return False
|
|
' Eseguo deselezione di tutti i pezzi
|
|
EgtDeselectAll()
|
|
EgtDraw()
|
|
' Se necessario, ripristino il contesto originale
|
|
If nCurrCtx > 0 Then EgtSetCurrentContext(nCurrCtx)
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function SelectedObjects() As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return False
|
|
' Imposto VeinMatching context
|
|
Dim nCurrCtx = SetVeinContext()
|
|
If nCurrCtx = 0 Then Return False
|
|
Dim bFound As Boolean = (EgtGetFirstSelectedObj() <> GDB_ID.NULL)
|
|
' Se necessario, ripristino il contesto originale
|
|
If nCurrCtx > 0 Then EgtSetCurrentContext(nCurrCtx)
|
|
Return bFound
|
|
End Function
|
|
|
|
Friend Function RemoveAllSelectedParts() As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Imposto VeinMatching context
|
|
Dim nCurrCtx = SetVeinContext()
|
|
If nCurrCtx = 0 Then Return False
|
|
' Eseguo la cancellazione di tutti i pezzi selezionati
|
|
Dim nId As Integer = EgtGetFirstSelectedObj()
|
|
While nId <> GDB_ID.NULL
|
|
Dim nNextId As Integer = EgtGetNextSelectedObj()
|
|
EgtErase(nId)
|
|
nId = nNextId
|
|
End While
|
|
' Se necessario, ripristino il contesto originale
|
|
If nCurrCtx > 0 Then EgtSetCurrentContext(nCurrCtx)
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function Draw() As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Imposto VeinMatching context
|
|
Dim nCurrCtx = SetVeinContext()
|
|
If nCurrCtx = 0 Then Return False
|
|
' Eseguo Zoom
|
|
EgtDraw()
|
|
' Se necessario, ripristino il contesto originale
|
|
If nCurrCtx > 0 Then EgtSetCurrentContext(nCurrCtx)
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function ZoomAll() As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Imposto VeinMatching context
|
|
Dim nCurrCtx = SetVeinContext()
|
|
If nCurrCtx = 0 Then Return False
|
|
' Eseguo Zoom
|
|
EgtZoom(ZM.ALL)
|
|
' Se necessario, ripristino il contesto originale
|
|
If nCurrCtx > 0 Then EgtSetCurrentContext(nCurrCtx)
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function Clear() As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Imposto VeinMatching context
|
|
Dim nCurrCtx = SetVeinContext()
|
|
If nCurrCtx = 0 Then Return False
|
|
' Pulisco il DB
|
|
EgtNewFile()
|
|
EgtDraw()
|
|
' Reset contatore foto
|
|
m_nPhoto = 0
|
|
' creo regione valida per i pezzi
|
|
EgtCreateOutRegionRectangle(GDB_ID.ROOT, -DIM_REG, -DIM_REG, DIM_REG, DIM_REG, 0)
|
|
' Se necessario, ripristino il contesto originale
|
|
If nCurrCtx > 0 Then EgtSetCurrentContext(nCurrCtx)
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function Open(sFilePath As String) As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Recupero il contesto corrente (principale)
|
|
Dim nMainCtx = EgtGetCurrentContext()
|
|
' Apro il file
|
|
EgtSetCurrentContext(m_nVeinCtx)
|
|
Dim bOk As Boolean = EgtOpenFile(sFilePath)
|
|
' Aggiorno contatore foto
|
|
Dim nPhId As Integer = EgtGetFirstInGroup(EgtGetFirstNameInGroup(GDB_ID.ROOT, PHOTO_GRP))
|
|
While nPhId <> GDB_ID.NULL
|
|
Dim sName As String = String.Empty
|
|
EgtGetName(nPhId, sName)
|
|
Dim nVal As Integer = 0
|
|
If StringToInt(sName.Replace(PHOTO_NAME, ""), nVal) Then m_nPhoto = Math.Max(m_nPhoto, nVal)
|
|
nPhId = EgtGetNext(nPhId)
|
|
End While
|
|
' Se non presente, aggiungo regione valida per i pezzi
|
|
EgtCreateOutRegionRectangle(GDB_ID.ROOT, -DIM_REG, -DIM_REG, DIM_REG, DIM_REG, 0)
|
|
' Aggiorno visualizzazione testi
|
|
UpdateShowText(False)
|
|
' Eseguo zoom all
|
|
EgtZoom(ZM.ALL)
|
|
' Ripristino il contesto originale
|
|
EgtSetCurrentContext(nMainCtx)
|
|
Return bOk
|
|
End Function
|
|
|
|
Friend Function Save(sFilePath As String) As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Recupero il contesto corrente (principale)
|
|
Dim nMainCtx As Integer = EgtGetCurrentContext()
|
|
' Elimino foto inutilizzate
|
|
RemoveUnusedPhotos()
|
|
' Salvo il file
|
|
EgtSetCurrentContext(m_nVeinCtx)
|
|
Dim bOk As Boolean = EgtSaveFile(sFilePath, NGE.CMPTEXT)
|
|
' Ripristino il contesto originale
|
|
EgtSetCurrentContext(nMainCtx)
|
|
Return bOk
|
|
End Function
|
|
|
|
Friend Function Export(sFilePath As String) As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Recupero il contesto corrente (principale)
|
|
Dim nMainCtx = EgtGetCurrentContext()
|
|
' Esporto il file come immagine
|
|
EgtSetCurrentContext(m_nVeinCtx)
|
|
Dim bOk As Boolean = (EgtGetFileType(sFilePath) = FT.IMG)
|
|
bOk = bOk AndAlso EgtGetImage(DirectCast( EgtGetShowMode(), EgtInterface.SM),
|
|
New Color3d(255, 255, 255), New Color3d(255, 255, 255),
|
|
m_nImgWidth, m_nImgHeight, sFilePath)
|
|
' Ripristino il contesto originale
|
|
EgtSetCurrentContext(nMainCtx)
|
|
Return bOk
|
|
End Function
|
|
|
|
Friend Function ChangePhotoPath(sOldPath As String, sNewPath As String) As Boolean
|
|
' Cerco nel VeinMatching una foto con la path originale
|
|
Dim sVeinPhoto As String = String.Empty
|
|
Dim nInd As Integer = 1
|
|
While nInd <= m_nPhoto
|
|
If GetVeinPhotoPath(nInd, sVeinPhoto) AndAlso
|
|
String.Compare(sOldPath, sVeinPhoto, True) = 0 Then
|
|
Exit While
|
|
End If
|
|
nInd += 1
|
|
End While
|
|
' Se trovata, cambio il path
|
|
If nInd <= m_nPhoto Then
|
|
' Imposto VeinMatching context
|
|
Dim nCurrCtx = SetVeinContext()
|
|
If nCurrCtx = 0 Then Return False
|
|
' Eseguo
|
|
Dim nPhotoId As Integer = GetVeinPhotoId(nInd)
|
|
EgtChangePhotoPath(nPhotoId, sNewPath)
|
|
' Se necessario, ripristino il contesto originale
|
|
If nCurrCtx > 0 Then EgtSetCurrentContext(nCurrCtx)
|
|
End If
|
|
Return False
|
|
End Function
|
|
|
|
Friend Function RemoveUnusedPhotos() As Boolean
|
|
' Recupero il contesto corrente
|
|
Dim nMainCtx As Integer = EgtGetCurrentContext()
|
|
' Riempio array con path delle foto caricate
|
|
Dim vsPath As New List(Of String)
|
|
Dim nPhId As Integer = EgtGetFirstInGroup(EgtGetFirstNameInGroup(GDB_ID.ROOT, PHOTO_GRP))
|
|
While nPhId <> GDB_ID.NULL
|
|
Dim sPath As String = String.Empty
|
|
If EgtGetPhotoPath(nPhId, sPath) Then
|
|
vsPath.Add(sPath)
|
|
End If
|
|
nPhId = EgtGetNext(nPhId)
|
|
End While
|
|
' Passo al contesto del VeinMatching
|
|
EgtSetCurrentContext(m_nVeinCtx)
|
|
' Elimino foto di VeinMatching in eccesso
|
|
Dim nVmPhId As Integer = EgtGetFirstInGroup(EgtGetFirstNameInGroup(GDB_ID.ROOT, PHOTO_GRP))
|
|
While nVmPhId <> GDB_ID.NULL
|
|
Dim sPath As String = String.Empty
|
|
Dim bErase As Boolean = Not EgtGetPhotoPath(nVmPhId, sPath)
|
|
If Not bErase Then
|
|
Dim bFound As Boolean = False
|
|
For Each sVal As String In vsPath
|
|
If String.Compare(sVal, sPath, True) = 0 Then
|
|
bFound = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
bErase = Not bFound
|
|
End If
|
|
If bErase Then
|
|
Dim nEraseId As Integer = nVmPhId
|
|
nVmPhId = EgtGetNext(nVmPhId)
|
|
EgtErase(nEraseId)
|
|
Else
|
|
nVmPhId = EgtGetNext(nVmPhId)
|
|
End If
|
|
End While
|
|
' Ritorno al contesto corrente
|
|
EgtSetCurrentContext(nMainCtx)
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function SetShowText(bShow As Boolean) As Boolean
|
|
If bShow <> m_bShowText Then
|
|
m_bShowText = bShow
|
|
UpdateShowText()
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function IsPartIn(nPartId As Integer) As Boolean
|
|
Return (GetVeinPartId(nPartId) <> GDB_ID.NULL)
|
|
End Function
|
|
|
|
Friend Function ModifyPartText( nPartId As Integer, sNewText As String, Optional bDraw As Boolean = True) As Boolean
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return True
|
|
' Recupero il contesto corrente (principale)
|
|
Dim nMainCtx = EgtGetCurrentContext()
|
|
' Recupero il nome originale del pezzo
|
|
Dim nOriId As Integer = nPartId
|
|
EgtGetInfo(nPartId, KEY_ORI_ID, nOriId)
|
|
' Recupero il pezzo nel VeinMatching
|
|
EgtSetCurrentContext(m_nVeinCtx)
|
|
Dim nVeinPartId = GetVeinPartId(nOriId)
|
|
Dim bFound As Boolean = nVeinPartId <> GDB_ID.NULL
|
|
' Recupero il primo testo della regione e lo modifico
|
|
If bFound Then
|
|
Dim nVeinRegId As Integer = EgtGetFirstNameInGroup(nVeinPartId, NAME_REGION)
|
|
Dim nCurrId As Integer = EgtGetFirstInGroup(nVeinRegId)
|
|
While nCurrId <> GDB_ID.NULL
|
|
If EgtGetType(nCurrId) = GDB_TY.EXT_TEXT Then
|
|
EgtModifyText( nCurrId, sNewText)
|
|
Exit While
|
|
End If
|
|
nCurrId = EgtGetNext(nCurrId)
|
|
End While
|
|
End If
|
|
If bDraw Then EgtDraw()
|
|
' Ritorno al contesto originale
|
|
EgtSetCurrentContext(nMainCtx)
|
|
Return bFound
|
|
End Function
|
|
|
|
Friend Sub UpdateShowText(Optional bDraw As Boolean = True)
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return
|
|
' Recupero il contesto corrente (principale)
|
|
Dim nMainCtx As Integer = EgtGetCurrentContext()
|
|
' Ciclo sui pezzi
|
|
EgtSetCurrentContext(m_nVeinCtx)
|
|
Dim nPartId As Integer = EgtGetFirstPart()
|
|
While nPartId <> GDB_ID.NULL
|
|
Dim nVeinRegId As Integer = EgtGetFirstNameInGroup(nPartId, NAME_REGION)
|
|
Dim nCurrId As Integer = EgtGetFirstInGroup(nVeinRegId)
|
|
While nCurrId <> GDB_ID.NULL
|
|
If EgtGetType(nCurrId) = GDB_TY.EXT_TEXT Then EgtSetStatus(nCurrId, If(m_bShowText, GDB_ST.ON_, GDB_ST.OFF))
|
|
nCurrId = EgtGetNext(nCurrId)
|
|
End While
|
|
nPartId = EgtGetNextPart(nPartId)
|
|
End While
|
|
If bDraw Then EgtDraw()
|
|
' Ripristino il contesto originale
|
|
EgtSetCurrentContext(nMainCtx)
|
|
End Sub
|
|
|
|
Friend Sub SetProjectModified()
|
|
' Salvo il contesto corrente
|
|
Dim nCurrCtx As Integer = EgtGetCurrentContext()
|
|
' Recupero il contesto principale
|
|
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
|
|
' Imposto flag di modificato sul progetto principale
|
|
EgtSetModified()
|
|
' Ripristino il contesto originale
|
|
EgtSetCurrentContext(nCurrCtx)
|
|
End Sub
|
|
|
|
Private Function CopyPhoto(nPhotoId As Integer) As Boolean
|
|
' Recupero il contesto corrente
|
|
Dim nCurrCtx = EgtGetCurrentContext()
|
|
' Recupero i dati della fotografia
|
|
Dim sPath As String = String.Empty
|
|
If Not EgtGetPhotoPath(nPhotoId, sPath) OrElse Not File.Exists(sPath) Then Return False
|
|
Dim ptOri As Point3d
|
|
If Not EgtGetPhotoOrigin(nPhotoId, ptOri) Then Return False
|
|
Dim ptCen As Point3d
|
|
If Not EgtGetPhotoCenter(nPhotoId, ptCen) Then Return False
|
|
Dim dDimX, dDimY As Double
|
|
If Not EgtGetPhotoDimensions(nPhotoId, dDimX, dDimY) Then Return False
|
|
Dim ptMin, ptMax As Point3d
|
|
If Not EgtGetBBoxGlob(nPhotoId, GDB_BB.STANDARD, ptMin, ptMax) Then Return False
|
|
' Passo al contesto del VeinMatching
|
|
EgtSetCurrentContext(m_nVeinCtx)
|
|
' Se non esiste il gruppo per le foto, lo creo
|
|
Dim nPhGrpId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, PHOTO_GRP)
|
|
If nPhGrpId = GDB_ID.NULL Then
|
|
nPhGrpId = EgtCreateGroup(GDB_ID.ROOT)
|
|
If nPhGrpId = GDB_ID.NULL Then
|
|
EgtSetCurrentContext(nCurrCtx)
|
|
Return False
|
|
End If
|
|
EgtSetName(nPhGrpId, PHOTO_GRP)
|
|
End If
|
|
EgtSetLevel(nPhGrpId, GDB_LV.SYSTEM)
|
|
EgtSetStatus(nPhGrpId, GDB_ST.OFF)
|
|
' Carico la fotografia
|
|
m_nPhoto += 1
|
|
Dim nNewId As Integer = EgtAddPhoto2(GetVeinPhotoName(m_nPhoto), sPath, ptOri, ptCen, dDimX, dDimY, nPhGrpId, ptMin, ptMax)
|
|
' Ritorno al contesto corrente
|
|
EgtSetCurrentContext(nCurrCtx)
|
|
Return nNewId <> GDB_ID.NULL
|
|
End Function
|
|
|
|
Private Function SetVeinContext() As Integer
|
|
' Verifico esista il contesto del VeinMatching
|
|
If m_nVeinCtx = 0 Then Return 0
|
|
' Recupero il contesto corrente
|
|
Dim nCurrCtx = EgtGetCurrentContext()
|
|
' Se necessario, cambio contesto
|
|
If m_nVeinCtx <> nCurrCtx Then
|
|
If EgtSetCurrentContext(m_nVeinCtx) Then
|
|
Return nCurrCtx
|
|
Else
|
|
Return 0
|
|
End If
|
|
Else
|
|
Return -1
|
|
End If
|
|
End Function
|
|
|
|
Private Function GetVeinPhotoName(nInd As Integer) As String
|
|
Return PHOTO_NAME & nInd.ToString()
|
|
End Function
|
|
|
|
Private Function GetVeinPhotoId(nInd As Integer) As Integer
|
|
Return EgtGetFirstNameInGroup(EgtGetFirstNameInGroup(GDB_ID.ROOT, PHOTO_GRP), GetVeinPhotoName(nInd))
|
|
End Function
|
|
|
|
Private Function GetVeinPhotoPath(nInd As Integer, ByRef sPath As String) As Boolean
|
|
' Imposto VeinMatching context
|
|
Dim nCurrCtx = SetVeinContext()
|
|
If nCurrCtx = 0 Then Return False
|
|
' Recupero path dell'immagine della foto
|
|
Dim nId As Integer = EgtGetFirstNameInGroup(EgtGetFirstNameInGroup(GDB_ID.ROOT, PHOTO_GRP), GetVeinPhotoName(nInd))
|
|
Dim bOk As Boolean = EgtGetPhotoPath(nId, sPath)
|
|
' Se necessario, ripristino il contesto originale
|
|
If nCurrCtx > 0 Then EgtSetCurrentContext(nCurrCtx)
|
|
Return bOk
|
|
End Function
|
|
|
|
Private Function GetVeinRefPhoto(nMainCtx As Integer, nPartId As Integer, nVePartId As Integer, ByRef refPhoto As Frame3d) As Boolean
|
|
' Riferimento della foto rispetto al riferimento del pezzo nel contesto principale
|
|
If Not EgtSetCurrentContext(nMainCtx) Then Return False
|
|
' riferimento della foto in globale
|
|
If Not EstPhoto.GetPhotoTextureRef(refPhoto) Then
|
|
EgtSetCurrentContext(m_nVeinCtx)
|
|
Return False
|
|
End If
|
|
' riferimento del pezzo in globale
|
|
Dim nRefId As Integer = EgtGetFirstNameInGroup(EgtGetFirstNameInGroup(nPartId, NAME_REGION), REF_NAME)
|
|
Dim refPart As New Frame3d
|
|
If Not EgtFrame(nRefId, GDB_ID.ROOT, refPart) Then
|
|
EgtSetCurrentContext(m_nVeinCtx)
|
|
Return False
|
|
End If
|
|
' porto il riferimento della foto in quello del pezzo
|
|
refPhoto.ToLoc(refPart)
|
|
' Riferimento della foto rispetto al riferimento del pezzo in VeinMatching
|
|
If Not EgtSetCurrentContext(m_nVeinCtx) Then Return False
|
|
' riferimento del pezzo in globale
|
|
Dim nVeRefId As Integer = EgtGetFirstNameInGroup(EgtGetFirstNameInGroup(nVePartId, NAME_REGION), REF_NAME)
|
|
Dim refVePart As New Frame3d
|
|
If Not EgtFrame(nVeRefId, GDB_ID.ROOT, refVePart) Then Return False
|
|
refPhoto.ToGlob(refVePart)
|
|
Return True
|
|
End Function
|
|
|
|
Private Function GetVeinPartId(nPartId As Integer) As Integer
|
|
' Imposto VeinMatching context
|
|
Dim nCurrCtx = SetVeinContext()
|
|
If nCurrCtx = 0 Then Return GDB_ID.NULL
|
|
' Cerco il pezzo in Vein che corrisponde al pezzo desiderato
|
|
Dim nId As Integer = EgtGetFirstPart()
|
|
While nId <> GDB_ID.NULL
|
|
Dim nOriId As Integer
|
|
If EgtGetInfo(nId, KEY_ORI_ID, nOriId) AndAlso nOriId = nPartId Then
|
|
Exit While
|
|
End If
|
|
nId = EgtGetNextPart(nId)
|
|
End While
|
|
' Se necessario, ripristino il contesto originale
|
|
If nCurrCtx > 0 Then EgtSetCurrentContext(nCurrCtx)
|
|
Return nId
|
|
End Function
|
|
|
|
Private Function GetVeinPartRegionId(nVeinPartId As Integer) As Integer
|
|
' Imposto VeinMatching context
|
|
Dim nCurrCtx = SetVeinContext()
|
|
If nCurrCtx = 0 Then Return GDB_ID.NULL
|
|
' Gruppo regione
|
|
Dim nRegLayId As Integer = EgtGetFirstNameInGroup(nVeinPartId, NAME_REGION)
|
|
' Entità superficie regione piatta
|
|
Dim nRegId As Integer = EgtGetFirstInGroup(nRegLayId)
|
|
While nRegId <> GDB_ID.NULL
|
|
If EgtGetType(nRegId) = GDB_TY.SRF_FRGN Then
|
|
Exit While
|
|
End If
|
|
nRegId = EgtGetNext(nRegId)
|
|
End While
|
|
' Se necessario, ripristino il contesto originale
|
|
If nCurrCtx > 0 Then EgtSetCurrentContext(nCurrCtx)
|
|
Return nRegId
|
|
End Function
|
|
|
|
Private Function GetVeinPartSolidId(nVeinPartId As Integer) As Integer
|
|
' Imposto VeinMatching context
|
|
Dim nCurrCtx = SetVeinContext()
|
|
If nCurrCtx = 0 Then Return GDB_ID.NULL
|
|
' Gruppo regione
|
|
Dim nRegLayId As Integer = EgtGetFirstNameInGroup(nVeinPartId, NAME_VM_SOLID)
|
|
' Entità superficie regione piatta
|
|
Dim nRegId As Integer = EgtGetFirstInGroup(nRegLayId)
|
|
While nRegId <> GDB_ID.NULL
|
|
If EgtGetType(nRegId) = GDB_TY.SRF_MESH Then
|
|
Exit While
|
|
End If
|
|
nRegId = EgtGetNext(nRegId)
|
|
End While
|
|
' Se necessario, ripristino il contesto originale
|
|
If nCurrCtx > 0 Then EgtSetCurrentContext(nCurrCtx)
|
|
Return nRegId
|
|
End Function
|
|
|
|
' ------------------- FUNZIONI PER GESTIONE ALZATINE E FRONTALINI -------------------
|
|
Friend Function CreateListAlzAndFront() As Boolean
|
|
m_ListAlzFront.Clear()
|
|
EgtSetCurrentContext(m_nVeinCtx)
|
|
Dim nId As Integer = EgtGetFirstPart()
|
|
While nId <> GDB_ID.NULL
|
|
' verifico che il pezzo sia una alzatina
|
|
Dim sInfoName As String = String.Empty
|
|
EgtGetInfo(nId, "CMP", sInfoName)
|
|
If sInfoName = "AlzFront" Then
|
|
Dim AlzFront As New Aletta(nId)
|
|
m_ListAlzFront.Add(AlzFront)
|
|
End If
|
|
' Passo al pezzo successivo
|
|
nId = EgtGetNextPart(nId)
|
|
End While
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function LinkReferencesOnAlette() As Boolean
|
|
Dim x As Integer = EgtGetCurrentContext()
|
|
' forzo il DB geometrico corrente
|
|
EgtSetCurrentContext(m_nVeinCtx)
|
|
Dim nId As Integer = EgtGetFirstPart()
|
|
While nId <> GDB_ID.NULL
|
|
' escludo dalla ricerca le alette
|
|
Dim sCMP As String = String.Empty
|
|
EgtGetInfo(nId, "CMP", sCMP)
|
|
If sCMP = "AlzFront" Then
|
|
' Passo al pezzo successivo
|
|
nId = EgtGetNextPart(nId)
|
|
Continue While
|
|
End If
|
|
' Recupero gruppo regione
|
|
Dim nOutLoopLayId As Integer = EgtGetFirstNameInGroup(nId, NAME_OUTLOOP)
|
|
' Entità lato
|
|
Dim nSideId As Integer = EgtGetFirstInGroup(nOutLoopLayId)
|
|
While nSideId <> GDB_ID.NULL
|
|
Dim sInfoGUID As String = String.Empty
|
|
EgtGetInfo(nSideId, "RefAF", sInfoGUID)
|
|
If Not String.IsNullOrEmpty(sInfoGUID) Then
|
|
Dim Item As Aletta
|
|
For Each Item In m_ListAlzFront
|
|
If Item.RefGUID = sInfoGUID Then
|
|
Item.IdSideRef = nSideId
|
|
End If
|
|
Next
|
|
' ricerco nella lista delle alette il suo
|
|
End If
|
|
nSideId = EgtGetNext(nSideId)
|
|
End While
|
|
' Passo al pezzo successivo
|
|
nId = EgtGetNextPart(nId)
|
|
End While
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function AssemblyParts(ByVal ThicknessRaw As Double) As Boolean
|
|
Dim CurrContext As Integer = EgtGetCurrentContext()
|
|
' per definizione un piano cucicina deve avere lo stesso spessore delle alette
|
|
'(abbiamo dato per scontato che le alette siano realizate sullo stesso grezzo del pinao cucina...)
|
|
CreateListAlzAndFront()
|
|
LinkReferencesOnAlette()
|
|
|
|
EgtSetCurrentContext(m_nVeinCtx)
|
|
|
|
' costruisco tutti i piani cucina (recupero l'Id geometrico del VeinMatch)
|
|
Dim nId As Integer = EgtGetFirstPart()
|
|
While nId <> GDB_ID.NULL
|
|
Dim sInfoName As String = String.Empty
|
|
EgtGetInfo(nId, "CMP", sInfoName)
|
|
' recuoer
|
|
Dim sNominalThickness As String = String.Empty
|
|
EgtGetInfo(nId, "RawTN", sNominalThickness)
|
|
' verifico che il pezzo sia una piano cucina
|
|
If sInfoName.Contains("PCucina") Or sInfoName.Contains("PBagno") Then
|
|
If Not CreateKitchenTop(nId, ThicknessRaw) Then Return False
|
|
End If
|
|
' altrimenti passo al pezzo successivo
|
|
nId = EgtGetNextPart(nId)
|
|
End While
|
|
|
|
' costruisco alzatine e frontalini
|
|
Dim Item As Aletta
|
|
For Each Item In m_ListAlzFront
|
|
' verifico che il disegno 3D non sia già stato fatto
|
|
Dim nInfo3D As Integer = 0
|
|
EgtGetInfo(Item.SideId, "Info3D", nInfo3D)
|
|
If nInfo3D <> 1 Then
|
|
' EgtSetInfo(Item.SideId, "Info3D", 1)
|
|
' creo il solido
|
|
If Not CreateAlettaSolid(Item, ThicknessRaw) Then Return False
|
|
'' posiziono il solido
|
|
'If Not MoveAlettaSolid(Item, ThicknessRaw) Then Return False
|
|
End If
|
|
' posiziono il solido
|
|
If Not MoveAlettaSolid(Item, ThicknessRaw) Then Return False
|
|
' solo se arrivo fino a qui allora imposto l'info
|
|
EgtSetInfo(Item.SideId, "Info3D", 1)
|
|
Next
|
|
Draw()
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function CreateKitchenTop(ByRef nId As Integer, ByRef ThicknessRaw As Double) As Boolean
|
|
|
|
' creo o svuoto layer per facce del solido
|
|
Dim nSolidGrp As Integer = EgtGetFirstNameInGroup(nId, NAME_VM_SOLID)
|
|
If nSolidGrp <> GDB_ID.NULL Then
|
|
EgtEmptyGroup(nSolidGrp)
|
|
Else
|
|
nSolidGrp = EgtCreateGroup(nId)
|
|
EgtSetName(nSolidGrp, NAME_VM_SOLID)
|
|
End If
|
|
|
|
' recupero faccia top
|
|
Dim nRegGrp As Integer = EgtGetFirstNameInGroup(nId, NAME_REGION)
|
|
Dim nTopFr As Integer = EgtGetFirstInGroup(nRegGrp)
|
|
While nTopFr <> GDB_ID.NULL
|
|
If EgtGetType(nTopFr) = GDB_TY.SRF_FRGN Then Exit While
|
|
nTopFr = EgtGetNext(nTopFr)
|
|
End While
|
|
If nTopFr = GDB_ID.NULL Then Return False
|
|
EgtSetStatus(nTopFr, 0)
|
|
|
|
' setto colore per il solido
|
|
Dim cCol As New Color3d
|
|
EgtGetColor(nTopFr, cCol)
|
|
EgtSetColor(nSolidGrp, cCol)
|
|
|
|
' creo il solido
|
|
Dim bSameLoopsNbr As Boolean
|
|
Dim nSolidId As Integer
|
|
If Not CreateKitchenBaseSolid(nTopFr, nSolidGrp, ThicknessRaw, nSolidId, bSameLoopsNbr) Then Return False
|
|
|
|
' aggiungo componenti interni
|
|
If Not AddInternalComponents(nSolidId, nTopFr, bSameLoopsNbr, ThicknessRaw) Then Return False
|
|
|
|
' setto eventuale texture
|
|
Dim sTextName As String = String.Empty
|
|
EgtGetTextureName(nTopFr, sTextName)
|
|
If sTextName <> String.Empty Then
|
|
Dim frText As New Frame3d
|
|
EgtGetTextureFrame(nTopFr, nRegGrp, frText)
|
|
EgtSetTextureName(nSolidId, sTextName)
|
|
EgtSetTextureFrame(nSolidId, frText)
|
|
End If
|
|
|
|
' elimino curve ausiliarie
|
|
Dim nIdx As Integer = EgtGetFirstInGroup(nSolidGrp)
|
|
While nIdx <> GDB_ID.NULL
|
|
Dim newId As Integer = EgtGetNext(nIdx)
|
|
If EgtGetType(nIdx) <> GDB_TY.SRF_MESH Then
|
|
EgtErase(nIdx)
|
|
End If
|
|
nIdx = newId
|
|
End While
|
|
|
|
'Dim nOutloopGrpOrig As Integer = EgtGetFirstNameInGroup(nId, NAME_OUTLOOP & ".orig")
|
|
'If nOutloopGrpOrig <> GDB_ID.NULL Then
|
|
' EgtSetStatus(nOutloopGrpOrig, 1)
|
|
' Dim nOutloopGrp As Integer = EgtGetFirstNameInGroup(nId, NAME_OUTLOOP)
|
|
' EgtSetStatus(nOutloopGrp, 0)
|
|
'End If
|
|
|
|
Return True
|
|
|
|
End Function
|
|
|
|
Friend Function CreateKitchenBaseSolid(ByRef nTopFr As Integer, ByRef nSolidGrp As Integer, ByRef ThicknessRaw As Double,
|
|
ByRef nSolidStm As Integer, ByRef bSameLoopsNbr As Boolean) As Boolean
|
|
|
|
' creo la faccia bottom
|
|
Dim nBottomFr As Integer
|
|
Dim nPartId As Integer = EgtGetParent(EgtGetParent(nTopFr))
|
|
If Not EgtCalcFlatPartDownRegion(nPartId, ThicknessRaw) Then Return False
|
|
Dim nDwnRegGrp As Integer = EgtGetFirstNameInGroup(nPartId, "DwnReg")
|
|
If nDwnRegGrp <> GDB_ID.NULL Then
|
|
EgtSetStatus(nDwnRegGrp, 0)
|
|
nBottomFr = EgtGetFirstInGroup(nDwnRegGrp)
|
|
If nBottomFr = GDB_ID.NULL Then Return False
|
|
Else
|
|
nBottomFr = EgtCopy(nTopFr, nSolidGrp)
|
|
End If
|
|
Dim vtMove As Vector3d = -ThicknessRaw * Vector3d.Z_AX()
|
|
EgtMove(nBottomFr, vtMove)
|
|
EgtSetStatus(nBottomFr, 0)
|
|
|
|
' superficie laterale
|
|
Dim nTopCrvCount, nBottomCrvCount As Integer
|
|
Dim nTopCrv, nBottomCrv As Integer
|
|
nTopCrv = EgtExtractSurfFrChunkLoops(nTopFr, 0, nSolidGrp, nTopCrvCount)
|
|
nBottomCrv = EgtExtractSurfFrChunkLoops(nBottomFr, 0, nSolidGrp, nBottomCrvCount)
|
|
' modifico il punto iniziale della curva bottom per ottenere una buona superficie rigata
|
|
Dim ptStartTop As Point3d
|
|
EgtStartPoint(nTopCrv, ptStartTop)
|
|
EgtChangeClosedCurveStartPoint(nBottomCrv, ptStartTop - vtMove)
|
|
Dim nLateralStm As Integer = EgtCreateSurfTmRuled(nSolidGrp, nBottomCrv, nTopCrv, 0, EPS_STM)
|
|
|
|
' superfici trimesh per faccia top e bottom
|
|
Dim nTopStm, nBottomStm As Integer
|
|
bSameLoopsNbr = (nTopCrvCount = nBottomCrvCount)
|
|
If bSameLoopsNbr Then
|
|
If Not GetSrfTmFromFlatRegion(nTopFr, nSolidGrp, nTopStm) Then Return False
|
|
If Not GetSrfTmFromFlatRegion(nBottomFr, nSolidGrp, nBottomStm) Then Return False
|
|
Else
|
|
' creo le facce top e bottom dimenticando eventuali aperture
|
|
nTopStm = EgtCreateSurfTmByFlatContour(nSolidGrp, nTopCrv, EPS_STM)
|
|
nBottomStm = EgtCreateSurfTmByFlatContour(nSolidGrp, nBottomCrv, EPS_STM)
|
|
End If
|
|
EgtInvertSurface(nBottomStm)
|
|
|
|
nSolidStm = EgtCreateSurfTmBySewing(nSolidGrp, 3, {nTopStm, nBottomStm, nLateralStm}, True)
|
|
|
|
' elimino il layer generato dalla funzione "EgtCalcFlatPartDownRegion" e rinomino quello acceso
|
|
Dim nOutLoopOrig As Integer = EgtGetFirstNameInGroup(nPartId, NAME_OUTLOOP & ".orig")
|
|
If nOutLoopOrig <> GDB_ID.NULL Then
|
|
Dim nCurrOutLoop As Integer = EgtGetFirstNameInGroup(nPartId, NAME_OUTLOOP)
|
|
EgtErase(nCurrOutLoop)
|
|
EgtSetName(nOutLoopOrig, NAME_OUTLOOP)
|
|
EgtSetStatus(nOutLoopOrig, GDB_ST.ON_)
|
|
End If
|
|
|
|
Return nSolidStm <> GDB_ID.NULL
|
|
|
|
End Function
|
|
|
|
Friend Function AddInternalComponents(ByRef nSolidStm As Integer, ByRef nTopFr As Integer, ByRef bSameLoopsNbr As Boolean,
|
|
ByRef ThicknessRaw As Double) As Boolean
|
|
|
|
Dim nSolidGrp = EgtGetParent(nSolidStm)
|
|
|
|
' aperture interne
|
|
Dim nTopCrvCount As Integer
|
|
Dim nTopCrv As Integer = EgtExtractSurfFrChunkLoops(nTopFr, 0, nSolidGrp, nTopCrvCount)
|
|
If bSameLoopsNbr Then
|
|
Dim FacesStm(nTopCrvCount - 1) As Integer
|
|
FacesStm(0) = nSolidStm
|
|
' creo le superfici laterali definite dalle aperture
|
|
For i As Integer = 1 To nTopCrvCount - 1
|
|
FacesStm(i) = EgtCreateSurfTmByExtrusion(nSolidGrp, 1, {nTopCrv + i}, -ThicknessRaw * Vector3d.Z_AX(), EPS_STM)
|
|
EgtInvertSurface(FacesStm(i))
|
|
Next
|
|
nSolidStm = EgtCreateSurfTmBySewing(nSolidGrp, nTopCrvCount, FacesStm, True)
|
|
Else
|
|
' creo le aperture per sottrazione di solidi
|
|
For i As Integer = 1 To nTopCrvCount - 1
|
|
Dim nComponentSrf As Integer = EgtCreateSurfTmByRegionExtrusion(nSolidGrp, 1, {nTopCrv + i}, -(ThicknessRaw + 10) * Vector3d.Z_AX(), EPS_STM)
|
|
EgtSurfTmSubtract(nSolidStm, nComponentSrf)
|
|
EgtErase(nComponentSrf)
|
|
Next
|
|
End If
|
|
|
|
' ribassi
|
|
Dim nId As Integer = EgtGetFirstGroupInGroup(EgtGetParent(nSolidGrp))
|
|
While nId <> GDB_ID.NULL
|
|
Dim sName As String = ""
|
|
EgtGetName(nId, sName)
|
|
If sName <> "Pocket" Then
|
|
nId = EgtGetNextGroup(nId)
|
|
Continue While
|
|
End If
|
|
' cerco curva composita che definisce il ribasso
|
|
Dim nCrvCompoId As Integer = EgtGetFirstInGroup(nId)
|
|
While nCrvCompoId <> GDB_ID.NULL
|
|
If EgtGetType(nCrvCompoId) = GDB_TY.CRV_COMPO Then Exit While
|
|
nCrvCompoId = EgtGetNext(nCrvCompoId)
|
|
End While
|
|
|
|
Dim dThick As Double
|
|
EgtCurveThickness(nCrvCompoId, dThick)
|
|
Dim vtExtr As Vector3d
|
|
EgtCurveExtrusion(nCrvCompoId, vtExtr)
|
|
Dim nRecessSrf As Integer = EgtCreateSurfTmByRegionExtrusion(nId, 1, {nCrvCompoId}, (dThick + 100) * vtExtr, EPS_STM)
|
|
EgtSurfTmSubtract(nSolidStm, nRecessSrf)
|
|
EgtErase(nRecessSrf)
|
|
|
|
' Passo al pezzo successivo
|
|
nId = EgtGetNextGroup(nId)
|
|
End While
|
|
|
|
Return True
|
|
End Function
|
|
Friend Function GetSrfTmFromFlatRegion(ByRef nFlatRegion As Integer, ByRef nSolidGrp As Integer, ByRef nSrfTmId As Integer) As Boolean
|
|
|
|
If nFlatRegion = GDB_ID.NULL Then Return False
|
|
' curve che delimitano la superficie
|
|
Dim nCrvCount As Integer
|
|
Dim nCrv As Integer = EgtExtractSurfFrChunkLoops(nFlatRegion, 0, nSolidGrp, nCrvCount)
|
|
If nCrv = GDB_ID.NULL Then Return False
|
|
' creo array con gli indici delle curve
|
|
Dim CrvList(nCrvCount - 1) As Integer
|
|
For i As Integer = 0 To nCrvCount - 1
|
|
CrvList(i) = nCrv + i
|
|
Next
|
|
nSrfTmId = EgtCreateSurfTmByRegion(nSolidGrp, CrvList, EPS_STM)
|
|
' cancello le curve create
|
|
For i As Integer = 0 To nCrvCount - 1
|
|
EgtErase(CrvList(i))
|
|
Next
|
|
|
|
Return nSrfTmId <> GDB_ID.NULL
|
|
|
|
End Function
|
|
|
|
Friend Function CreateAlettaSolid(ByRef Item As Aletta, ByRef ThicknessRaw As Double) As Boolean
|
|
|
|
' angoli per i tagli
|
|
Dim dAngL, dAngR, dAng As Double
|
|
EgtGetInfo(Item.SideId + 1, INFO_SIDE_ANGLE, dAngR)
|
|
EgtGetInfo(Item.SideId + 3, INFO_SIDE_ANGLE, dAngL)
|
|
EgtGetInfo(Item.SideId, INFO_SIDE_ANGLE, dAng)
|
|
|
|
If Math.Abs(dAngL - 90) < EPS_SMALL Or Math.Abs(dAngL + 90) < EPS_SMALL Then dAngL = 0
|
|
If Math.Abs(dAngR - 90) < EPS_SMALL Or Math.Abs(dAngR + 90) < EPS_SMALL Then dAngR = 0
|
|
If Math.Abs(dAng - 90) < EPS_SMALL Or Math.Abs(dAng + 90) < EPS_SMALL Then dAng = 0
|
|
|
|
' punti che delimitano la front face (faccia adiacente a top lungo il lato di riferimento)
|
|
Dim pt1, pt2, pt3, pt4 As Point3d
|
|
EgtStartPoint(Item.SideId, pt4)
|
|
EgtEndPoint(Item.SideId, pt3)
|
|
pt2 = pt3 - ThicknessRaw * Vector3d.Z_AX()
|
|
pt1 = pt4 - ThicknessRaw * Vector3d.Z_AX()
|
|
|
|
' aggiungo tagli inclinati
|
|
pt2 = pt2 + ThicknessRaw * Math.Tan(dAngR * Math.PI / 180) * Vector3d.X_AX()
|
|
pt1 = pt1 - ThicknessRaw * Math.Tan(dAngL * Math.PI / 180) * Vector3d.X_AX()
|
|
|
|
' aggiungo eventuale taglio sul lato superiore
|
|
pt2 = pt2 - ThicknessRaw * Math.Tan(dAng * Math.PI / 180) * Vector3d.Y_AX()
|
|
pt1 = pt1 - ThicknessRaw * Math.Tan(dAng * Math.PI / 180) * Vector3d.Y_AX()
|
|
|
|
' punti che delimitano back face
|
|
Dim HeightTop As Double
|
|
EgtCurveLength(Item.SideId + 1, HeightTop)
|
|
Dim HeightBottom As Double = HeightTop + ThicknessRaw * Math.Tan(dAng * Math.PI / 180)
|
|
Dim ptB1 As Point3d = pt1 + HeightBottom * Vector3d.Y_AX()
|
|
Dim ptB2 As Point3d = pt2 + HeightBottom * Vector3d.Y_AX()
|
|
Dim ptB3 As Point3d = pt3 + HeightTop * Vector3d.Y_AX()
|
|
Dim ptB4 As Point3d = pt4 + HeightTop * Vector3d.Y_AX()
|
|
|
|
' Creo o svuoto layer per facce del solido
|
|
Dim nSolidGrp As Integer = EgtGetFirstNameInGroup(Item.PartId, NAME_VM_SOLID)
|
|
If nSolidGrp <> GDB_ID.NULL Then
|
|
EgtEmptyGroup(nSolidGrp)
|
|
Else
|
|
nSolidGrp = EgtCreateGroup(Item.PartId)
|
|
EgtSetName(nSolidGrp, NAME_VM_SOLID)
|
|
End If
|
|
Dim nRegionGrp As Integer = EgtGetFirstNameInGroup(Item.PartId, NAME_REGION)
|
|
Dim cCol As New Color3d
|
|
EgtGetColor(EgtGetFirstInGroup(nRegionGrp), cCol)
|
|
EgtSetColor(nSolidGrp, cCol)
|
|
|
|
' Top Face
|
|
Dim nTopSrfFR As Integer = EgtGetFirstInGroup(nRegionGrp)
|
|
Dim tmp As Integer
|
|
Dim nTopCrv As Integer = EgtExtractSurfFrChunkLoops(nTopSrfFR, 0, nRegionGrp, tmp)
|
|
If nTopCrv = GDB_ID.NULL Then Return False
|
|
Dim nTopSrf As Integer = EgtCreateSurfTmByRegion(nSolidGrp, {nTopCrv}, EPS_SMALL)
|
|
EgtErase(nTopCrv)
|
|
EgtSetStatus(nTopSrfFR, 0)
|
|
|
|
Dim nFrontSrf, nBackSrf, nBottomSrf, nRightSrf, nLeftSrf As Integer
|
|
' Front Face
|
|
If Not CreateSolidFace(nSolidGrp, {pt1, pt2, pt3, pt4}, nFrontSrf, False) Then Return False
|
|
' Back Face
|
|
If Not CreateSolidFace(nSolidGrp, {ptB1, ptB4, ptB3, ptB2}, nBackSrf) Then Return False
|
|
' Bottom face
|
|
If Not CreateSolidFace(nSolidGrp, {pt2, pt1, ptB1, ptB2}, nBottomSrf) Then Return False
|
|
' Right face
|
|
If Not CreateSolidFace(nSolidGrp, {ptB1, pt1, pt4, ptB4}, nRightSrf) Then Return False
|
|
' Left face
|
|
If Not CreateSolidFace(nSolidGrp, {ptB2, ptB3, pt3, pt2}, nLeftSrf) Then Return False
|
|
|
|
' creo il solido
|
|
Dim nSolidSrf As Integer = EgtCreateSurfTmBySewing(nSolidGrp, 6, {nTopSrf, nFrontSrf, nBackSrf, nBottomSrf, nRightSrf, nLeftSrf}, True)
|
|
|
|
' setto eventuale texture
|
|
Dim sTextName As String = String.Empty
|
|
EgtGetTextureName(nTopSrfFR, sTextName)
|
|
If sTextName <> String.Empty Then
|
|
Dim frText As New Frame3d
|
|
EgtGetTextureFrame(nTopSrfFR, nRegionGrp, frText)
|
|
EgtSetTextureName(nSolidSrf, sTextName)
|
|
EgtSetTextureFrame(nSolidSrf, frText)
|
|
End If
|
|
|
|
Dim nOutloopGrp As Integer = EgtGetParent(Item.SideId)
|
|
EgtSetStatus(nOutloopGrp, 0)
|
|
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function CreateSolidFace(ByRef nSrfGrp As Integer, ByRef Points As Point3d(), ByRef nSrfId As Integer,
|
|
Optional ByRef bDeleteCrv As Boolean = True) As Boolean
|
|
|
|
If Points.Count() <> 4 Then Return False
|
|
|
|
Dim nCrvId As Integer = EgtCreateCurveCompo(nSrfGrp, {EgtCreateLine(nSrfGrp, Points(0), Points(1)),
|
|
EgtCreateLine(nSrfGrp, Points(1), Points(2)),
|
|
EgtCreateLine(nSrfGrp, Points(2), Points(3)),
|
|
EgtCreateLine(nSrfGrp, Points(3), Points(0))}, True)
|
|
|
|
If nCrvId = GDB_ID.NULL Then Return False
|
|
nSrfId = EgtCreateSurfTmByRegion(nSrfGrp, {nCrvId}, EPS_SMALL)
|
|
If bDeleteCrv Then
|
|
EgtErase(nCrvId)
|
|
Else
|
|
EgtSetStatus(nCrvId, GDB_ST.OFF)
|
|
End If
|
|
Return nSrfId <> GDB_ID.NULL
|
|
End Function
|
|
|
|
Friend Function MoveAlettaSolid(ByRef Item As Aletta, ByRef ThicknessRaw As Double) As Boolean
|
|
|
|
Dim nType As Integer
|
|
If Not EgtGetInfo(Item.IdSideRef, "AF", nType) Then Return False
|
|
|
|
Dim ptSRef, ptERef, ptE As Point3d
|
|
If Not EgtStartPoint(Item.IdSideRef, GDB_ID.ROOT, ptSRef) Then Return False
|
|
If Not EgtEndPoint(Item.IdSideRef, GDB_ID.ROOT, ptERef) Then Return False
|
|
If Not EgtEndPoint(Item.SideId, GDB_ID.ROOT, ptE) Then Return False
|
|
|
|
' verifco che sia già stato ruotato
|
|
Dim nInfo3D As Integer = 0
|
|
EgtGetInfo(Item.SideId, "Info3D", nInfo3D)
|
|
|
|
If nInfo3D <> 1 Then
|
|
' ruoto il solido intorno al lato di riferimento
|
|
Dim vtRot As Vector3d = ptERef - ptSRef
|
|
If nType = 1 Then
|
|
EgtRotate(Item.PartId, ptE, vtRot, -90, GDB_RT.GLOB)
|
|
ElseIf nType = 2 Then
|
|
EgtRotate(Item.PartId, ptE, vtRot, 90, GDB_RT.GLOB)
|
|
End If
|
|
End If
|
|
|
|
' punto di riferimento per la traslazione sul solido
|
|
Dim ptSolid As Point3d
|
|
If nType = 1 Then
|
|
' cerco id della curva che definisce la front face
|
|
Dim nSolidGrp As Integer = EgtGetFirstNameInGroup(Item.PartId, NAME_VM_SOLID)
|
|
Dim nFrontCrvId As Integer = EgtGetFirstInGroup(nSolidGrp)
|
|
EgtStartPoint(nFrontCrvId, ptSolid)
|
|
ElseIf nType = 2 Then
|
|
EgtStartPoint(Item.SideId, ptSolid)
|
|
End If
|
|
|
|
Dim ItemFrame As New Frame3d
|
|
If Not EgtGetGroupGlobFrame(Item.PartId, ItemFrame) Then Return False
|
|
ptSolid.ToGlob(ItemFrame)
|
|
|
|
'punto di riferimento per la traslazione sul piano cucina
|
|
Dim ptKitchen As Point3d = ptERef
|
|
' traslazione
|
|
Dim vtMove As Vector3d = ptKitchen - ptSolid
|
|
EgtMove(Item.PartId, vtMove, GDB_RT.GLOB)
|
|
|
|
Return True
|
|
End Function
|
|
End Module
|
|
|
|
Public Class Aletta
|
|
|
|
Private m_PartId As Integer = -1
|
|
Public ReadOnly Property PartId As Integer
|
|
Get
|
|
Return m_PartId
|
|
End Get
|
|
End Property
|
|
|
|
Private m_SideId As Integer = -1
|
|
Public ReadOnly Property SideId As Integer
|
|
Get
|
|
Return m_SideId
|
|
End Get
|
|
End Property
|
|
|
|
Private m_RefGUID As String = String.Empty
|
|
Public ReadOnly Property RefGUID As String
|
|
Get
|
|
Return m_RefGUID
|
|
End Get
|
|
End Property
|
|
|
|
Private m_IdSideRef As Integer = -1
|
|
Public Property IdSideRef As Integer
|
|
Get
|
|
Return m_IdSideRef
|
|
End Get
|
|
Set(value As Integer)
|
|
m_IdSideRef = value
|
|
End Set
|
|
End Property
|
|
|
|
Sub New(nId As Integer)
|
|
m_PartId = nId
|
|
|
|
' Recupero l'info legata al lato che contiene iil riferiemnto
|
|
Dim nOutLoopLayId As Integer = EgtGetFirstNameInGroup(nId, NAME_OUTLOOP)
|
|
' Entità lato
|
|
Dim nSideId As Integer = EgtGetFirstInGroup(nOutLoopLayId)
|
|
While nSideId <> GDB_ID.NULL
|
|
Dim sInfoGUID As String = String.Empty
|
|
EgtGetInfo(nSideId, "RefAF", sInfoGUID)
|
|
If Not String.IsNullOrEmpty(sInfoGUID) Then
|
|
m_RefGUID = sInfoGUID
|
|
m_SideId = nSideId
|
|
Exit While
|
|
End If
|
|
nSideId = EgtGetNext(nSideId)
|
|
End While
|
|
End Sub
|
|
|
|
End Class |