Merge branch 'Features/3D_In_VeinMatch' of https://gitlab.steamware.net/egaltech/omagoffice into Features/3D_In_VeinMatch
This commit is contained in:
@@ -266,7 +266,7 @@
|
||||
Style="{StaticResource VeinMatchWindow_ToggleButton}"
|
||||
Margin="1,5,1,0"
|
||||
Content="☢"
|
||||
ToolTip=""/>
|
||||
ToolTip="evidenzia intersezioni"/>
|
||||
<Button Name="Btn10"
|
||||
Style="{StaticResource VeinMatchWindow_Button}"
|
||||
Margin="1,5,1,0"
|
||||
|
||||
@@ -49,6 +49,7 @@ Public Class VeinMatchingWindow
|
||||
Private m_nId As Integer = GDB_ID.NULL
|
||||
Private m_PartSolidList As New ObservableCollection(Of PartSolid)
|
||||
Private m_dAngRot As Double = 0
|
||||
Private m_nTrasfNum As Integer = -1
|
||||
' Nero, Bianco, Fucsia, Rosso, Verde
|
||||
Private m_ColorList As New List(Of Color3d)({New Color3d(0, 0, 0), New Color3d(255, 255, 255), New Color3d(247, 21, 237),
|
||||
New Color3d(235, 12, 12), New Color3d(78, 249, 43)})
|
||||
@@ -254,7 +255,7 @@ Public Class VeinMatchingWindow
|
||||
Dim sNameAx As String = String.Empty
|
||||
EgtGetName(EgtGetParent(m_nId), sNameAx)
|
||||
Dim PartSolidIdTempSel As PartSolid = GetPartSolid(m_nIdPart)
|
||||
PartSolidIdTempSel.Unpair()
|
||||
'PartSolidIdTempSel.Unpair()
|
||||
Select Case sNameAx
|
||||
Case "X"
|
||||
PartSolidIdTempSel.vtDrag = Vector3d.X_AX
|
||||
@@ -396,6 +397,7 @@ Public Class VeinMatchingWindow
|
||||
PartSolidIdTempSel.nIdSurfSecond = nId
|
||||
EgtSetMark(nId)
|
||||
CompletePair()
|
||||
MyMsgTxBl.Text = ""
|
||||
Return
|
||||
End If
|
||||
' Passo al successivo
|
||||
@@ -536,16 +538,24 @@ Public Class VeinMatchingWindow
|
||||
' EgtMove(nMoveId, vtMove)
|
||||
'End If
|
||||
PartSolidSel.Move(PartSolidSel.vtDrag * (PartSolidSel.vtDrag * vtMove))
|
||||
If TgBtn9.IsChecked Then
|
||||
Dim vInters As ObservableCollection(Of PartSolid) = CalcInters(PartSolidSel.PartSolidId)
|
||||
If vInters.Count() <> 1 Then
|
||||
m_bDrag = False
|
||||
PartSolidSel.RemoveLastTrasf()
|
||||
End If
|
||||
End If
|
||||
|
||||
VeinMatching.SetProjectModified()
|
||||
EgtDraw()
|
||||
End If
|
||||
' altrimenti rotazione
|
||||
Else
|
||||
' altrimenti rotazione
|
||||
Else
|
||||
' Ricavo l'angolo di movimento
|
||||
m_ptCen = PartSolidSel.Center()
|
||||
Dim vtPrev As Vector3d = m_ptPrev - m_ptCen
|
||||
Dim vtCurr As Vector3d = ptCurr - m_ptCen
|
||||
MyMsgTxBl.Text = String.Format("{0:00.00}", vtCurr.z)
|
||||
'MyMsgTxBl.Text = String.Format("{0:00.00}", vtCurr.z)
|
||||
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
|
||||
@@ -676,14 +686,11 @@ Public Class VeinMatchingWindow
|
||||
If m_nIdToSel <> GDB_ID.NULL Then
|
||||
' Eseguo la selezione in Nesting
|
||||
Dim PartSolidIdToSel As PartSolid = GetPartSolid(m_nIdToSel)
|
||||
|
||||
' in teoria questo controllo non serve, perché creo un part Solid per tutti i part e se non hanno il solid non è un problema
|
||||
'If IsNothing(PartSolidIdToSel) Then
|
||||
' 'selezione di un Part che non ha un SOLID associato
|
||||
' EgtSelectObj(m_nIdToSel)
|
||||
' Return
|
||||
'End If
|
||||
|
||||
If IsNothing(PartSolidIdToSel) Then
|
||||
'selezione di un Part che non ha un SOLID associato
|
||||
EgtSelectObj(m_nIdToSel)
|
||||
Return
|
||||
End If
|
||||
m_nIdToSel = PartSolidIdToSel.PartId
|
||||
' seleziono
|
||||
Dim bSelected As Boolean = False
|
||||
@@ -948,7 +955,7 @@ Public Class VeinMatchingWindow
|
||||
End Sub
|
||||
|
||||
Private Sub CreateCurrSolid()
|
||||
Dim dThick As Double = 5
|
||||
Dim dThick As Double = 20
|
||||
EgtSetCurrentContext(m_nVeinCtx)
|
||||
Dim nParent As Integer = -1
|
||||
' verifico che sia un part
|
||||
@@ -1009,7 +1016,7 @@ Public Class VeinMatchingWindow
|
||||
If m_PartSolidList.Count = 0 Then
|
||||
CreatePartSolid()
|
||||
End If
|
||||
Dim dThick As Double = 5
|
||||
Dim dThick As Double = 20
|
||||
EgtSetCurrentContext(m_nVeinCtx)
|
||||
Dim IdFP As Integer = EgtGetFirstPart()
|
||||
Dim sName As String = String.Empty
|
||||
@@ -1173,6 +1180,7 @@ Public Class VeinMatchingWindow
|
||||
Dim vtMove As Vector3d = ptFin - ptIni
|
||||
Dim dAng As Double = GetAngle(vtDirF, vtDirS)
|
||||
PartSolidIdSel.Move(vtMove, bPart)
|
||||
m_nTrasfNum += 1
|
||||
' resetto tutto
|
||||
PartSolidIdSel.DeselectPart()
|
||||
If (dAng < EPS_SMALL Or Math.Abs(dAng - 180) < EPS_SMALL Or Math.Abs(dAng - 360) < EPS_SMALL) Then
|
||||
@@ -1181,7 +1189,7 @@ Public Class VeinMatchingWindow
|
||||
'PartSolidIdSel.nIdLineSecond = -1
|
||||
|
||||
If FindInters(PartSolidIdSel.PartId) Then
|
||||
MyMsgTxBl.Text = MyMsgTxBl.Text & "Inters!"
|
||||
MyMsgTxBl.Text = "Inters!"
|
||||
MyMsgTxBl.Foreground = Brushes.Red
|
||||
End If
|
||||
EgtDraw()
|
||||
@@ -1190,8 +1198,9 @@ Public Class VeinMatchingWindow
|
||||
' ruoto il solid che sto spostando
|
||||
Dim vtAx As Vector3d = vtDirF ^ vtDirS
|
||||
PartSolidIdSel.Rotate(ptFin, vtAx, dAng, bPart)
|
||||
m_nTrasfNum += 1
|
||||
If FindInters(PartSolidIdSel.PartId) Then
|
||||
MyMsgTxBl.Text = MyMsgTxBl.Text & "Inters!"
|
||||
MyMsgTxBl.Text = "Inters!"
|
||||
MyMsgTxBl.Foreground = Brushes.Red
|
||||
End If
|
||||
EgtDraw()
|
||||
@@ -1202,11 +1211,24 @@ Public Class VeinMatchingWindow
|
||||
' conferma l'accoppiamento
|
||||
Dim PartSolidSel As PartSolid = GetPartSolid(m_nIdPart)
|
||||
'PairPart(True) '' questo servirà per accoppiare il part col suo solid dopo un accoppiamento tra solidi
|
||||
PartSolidSel.PairParts()
|
||||
|
||||
' controllo di aver confermato l'operazione di accoppia ( e quindi di non aver appena cliccato il pulsante "Resetta accoppiamento")
|
||||
If PartSolidSel.nIdLineSecond <> GDB_ID.NULL Then
|
||||
Dim PartSolidPair As PartSolid = GetPartSolid(EgtGetParent(EgtGetParent(PartSolidSel.nIdLineSecond)))
|
||||
' setto la proprietà per entrambi
|
||||
PartSolidSel.AddPair(PartSolidPair)
|
||||
PartSolidPair.AddPair(PartSolidSel)
|
||||
' setto l'info
|
||||
PartSolidSel.PairParts()
|
||||
End If
|
||||
|
||||
PartSolidSel.ResetData()
|
||||
PartSolidSel.DeselectPart()
|
||||
m_nIdPart = -1
|
||||
'TgBtn6.IsChecked = False
|
||||
MyMsgTxBl.Text = ""
|
||||
'resetto il numero di operazioni effettutate durante il pair
|
||||
m_nTrasfNum = -1
|
||||
EgtDraw()
|
||||
End Sub
|
||||
|
||||
@@ -1222,6 +1244,23 @@ Public Class VeinMatchingWindow
|
||||
PairPart(False)
|
||||
End Sub
|
||||
|
||||
Private Sub Flip_Changed() Handles FlipOption.Click
|
||||
If TgBtn6.IsChecked = False Then Return
|
||||
If m_nIdPart = GDB_ID.NULL Then Return
|
||||
Dim PartSolidSel As PartSolid = GetPartSolid(m_nIdPart)
|
||||
Dim vtNorm As New Vector3d
|
||||
EgtSurfFrNormVersor(PartSolidSel.SurfId, GDB_ID.ROOT, vtNorm)
|
||||
Dim ptMid As New Point3d
|
||||
EgtMidPoint(PartSolidSel.nIdLineFirst, GDB_ID.ROOT, ptMid)
|
||||
PartSolidSel.Rotate(ptMid, vtNorm, 180)
|
||||
If FindInters(m_nIdPart) Then
|
||||
MyMsgTxBl.Text = "Inters!"
|
||||
MyMsgTxBl.Foreground = Brushes.Red
|
||||
End If
|
||||
m_nTrasfNum += 1
|
||||
EgtDraw()
|
||||
End Sub
|
||||
|
||||
Private Sub CompletePair()
|
||||
Dim PartSolidSel As PartSolid = GetPartSolid(m_nIdPart)
|
||||
Dim ptAx As New Point3d
|
||||
@@ -1242,7 +1281,15 @@ Public Class VeinMatchingWindow
|
||||
Private Sub ResetPair()
|
||||
If m_nIdPart = GDB_ID.NULL Then Return
|
||||
Dim PartSolidSel As PartSolid = GetPartSolid(m_nIdPart)
|
||||
For op As Integer = m_nTrasfNum To 0 Step -1
|
||||
PartSolidSel.UndoTrasf()
|
||||
Next
|
||||
PartSolidSel.ResetData()
|
||||
' resetto le intersezioni
|
||||
' NON è GESTITO IL CASO IN CUI TORNO AD UNA POSIZIONE IN CUI HO ANCORA UN'INTERSEZIONE!!!!
|
||||
FindInters(m_nIdPart)
|
||||
'resetto il numero di operazioni effettutate durante il pair
|
||||
m_nTrasfNum = -1
|
||||
EgtDraw()
|
||||
End Sub
|
||||
|
||||
@@ -1253,6 +1300,11 @@ Public Class VeinMatchingWindow
|
||||
' qui devo aggiungere un bottone per la funzione Unpair della classe PartSolid'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
|
||||
Private Sub Unpair(nId As Integer)
|
||||
Dim PartSolidSel As PartSolid = GetPartSolid(nId)
|
||||
For Each PartSolidPair As PartSolid In PartSolidSel.vPair
|
||||
' aggiorno la lista dei Pair per ogni elemento che era paired con il PartCurr
|
||||
PartSolidPair.RemovePair(PartSolidSel)
|
||||
Next
|
||||
' rimuovi le info dal PartCurr e da tutti i suoi Pair
|
||||
PartSolidSel.Unpair()
|
||||
End Sub
|
||||
|
||||
@@ -1266,11 +1318,36 @@ Public Class VeinMatchingWindow
|
||||
EgtErase(nIdInters)
|
||||
nIdInters = nIdNext
|
||||
End While
|
||||
Dim nIdSolid As Integer = PartSolidCurr.SolidId
|
||||
EgtSetCurrentContext(m_nVeinCtx)
|
||||
Dim vIntersId As New ObservableCollection(Of Integer)
|
||||
vIntersId.Add(nPartId)
|
||||
Dim vInters As ObservableCollection(Of PartSolid) = CalcInters(nPartId, True)
|
||||
nIdInters = EgtGetFirstInGroup(nIdTempL)
|
||||
' se trovo delle intersezioni metto tutto in trasparenza tranne le intersezioni
|
||||
' prima rimetto tutto opaco e poi eventualmente metto le trasparenze
|
||||
For Each PartSolidSel As PartSolid In m_PartSolidList
|
||||
PartSolidSel.MakeOpaque()
|
||||
MyMsgTxBl.Text = ""
|
||||
MyMsgTxBl.Foreground = Brushes.DarkKhaki
|
||||
Next
|
||||
If nIdInters <> -1 Then
|
||||
'EgtSetMark(nIdTempL)
|
||||
For Each PartSolidSel As PartSolid In vInters
|
||||
PartSolidSel.MakeTransparent()
|
||||
Next
|
||||
Return True
|
||||
End If
|
||||
Return False
|
||||
End Function
|
||||
|
||||
Public Function CalcInters(nPartId As Integer, Optional bKeepInters As Boolean = False) As ObservableCollection(Of PartSolid)
|
||||
EgtSetCurrentContext(m_nVeinCtx)
|
||||
Dim PartSolidCurr As PartSolid = GetPartSolid(nPartId)
|
||||
Dim nIdTempL = EgtGetFirstNameInGroup(PartSolidCurr.PartSolidId, "Temp")
|
||||
Dim vInters As New ObservableCollection(Of PartSolid)
|
||||
vInters.Add(PartSolidCurr)
|
||||
Dim nIdSolid As Integer = PartSolidCurr.SolidId
|
||||
For Each PartSolidSel As PartSolid In m_PartSolidList
|
||||
' prima di fare le intersezioni tra mesh verifico che le bbox abbiano un'intersezione
|
||||
If Not PartSolidCurr.bbSolid.Overlaps(PartSolidSel.bbSolid) Then Continue For
|
||||
' ho intersezione tra le bbox quindi proseguo con i conti
|
||||
If PartSolidSel.SolidId = nIdSolid Then Continue For
|
||||
Dim nIdSurfToCheck As Integer = PartSolidSel.SolidId
|
||||
If nIdSurfToCheck = -1 Then Continue For
|
||||
@@ -1278,27 +1355,22 @@ Public Class VeinMatchingWindow
|
||||
EgtSurfTmIntersect(nIdCopy, nIdSurfToCheck)
|
||||
If EgtSurfTmFacetCount(nIdCopy) <> 0 Then
|
||||
EgtSetColor(nIdCopy, New Color3d(255, 0, 0))
|
||||
vIntersId.Add(PartSolidSel.PartId)
|
||||
vInters.Add(PartSolidSel)
|
||||
Else
|
||||
EgtErase(nIdCopy)
|
||||
End If
|
||||
Next
|
||||
nIdInters = EgtGetFirstInGroup(nIdTempL)
|
||||
' se trovo delle intersezioni metto tutto in trasparenza tranne le intersezioni
|
||||
' prima rimetto tutto opaco e poi eventualmente metto le trasparenze
|
||||
For Each PartSolidSel As PartSolid In m_PartSolidList
|
||||
PartSolidSel.MakeOpaque()
|
||||
MyMsgTxBl.Foreground = Brushes.DarkKhaki
|
||||
Next
|
||||
If nIdInters <> -1 Then
|
||||
'EgtSetMark(nIdTempL)
|
||||
For Each PartId As Integer In vIntersId
|
||||
Dim PartSolidSel As PartSolid = GetPartSolid(PartId)
|
||||
PartSolidSel.MakeTransparent()
|
||||
Next
|
||||
Return True
|
||||
|
||||
If Not bKeepInters Then
|
||||
Dim nIdInters As Integer = EgtGetFirstInGroup(nIdTempL)
|
||||
While nIdInters <> GDB_ID.NULL
|
||||
Dim nIdNext As Integer = EgtGetNext(nIdInters)
|
||||
EgtErase(nIdInters)
|
||||
nIdInters = nIdNext
|
||||
End While
|
||||
End If
|
||||
Return False
|
||||
|
||||
Return vInters
|
||||
End Function
|
||||
|
||||
Private Sub Btn12_Click(sender As Object, e As RoutedEventArgs) Handles TgBtn12.Click
|
||||
@@ -1336,22 +1408,6 @@ Public Class VeinMatchingWindow
|
||||
EgtDraw()
|
||||
End Sub
|
||||
|
||||
Private Sub Flip_Changed() Handles FlipOption.Click
|
||||
If TgBtn6.IsChecked = False Then Return
|
||||
If m_nIdPart = GDB_ID.NULL Then Return
|
||||
Dim PartSolidSel As PartSolid = GetPartSolid(m_nIdPart)
|
||||
Dim vtNorm As New Vector3d
|
||||
EgtSurfFrNormVersor(PartSolidSel.SurfId, GDB_ID.ROOT, vtNorm)
|
||||
Dim ptMid As New Point3d
|
||||
EgtMidPoint(PartSolidSel.nIdLineFirst, GDB_ID.ROOT, ptMid)
|
||||
PartSolidSel.Rotate(ptMid, vtNorm, 180)
|
||||
If FindInters(m_nIdPart) Then
|
||||
MyMsgTxBl.Text = MyMsgTxBl.Text & "Inters!"
|
||||
MyMsgTxBl.Foreground = Brushes.Red
|
||||
End If
|
||||
EgtDraw()
|
||||
End Sub
|
||||
|
||||
Private Sub ExplodeSolid_Click() Handles Btn21.Click
|
||||
' recupero l'elenco di tutti i SOLID del progetto
|
||||
Dim CurrCentAssembly As New Point3d(0, 0, 0)
|
||||
@@ -1380,7 +1436,7 @@ Public Class VeinMatchingWindow
|
||||
|
||||
Private Sub Collapse_Click() Handles Btn22.Click
|
||||
For Each Item In m_PartSolidList
|
||||
Item.Move(-Item.vtLastMove)
|
||||
Item.ApplyTrasf(-Item.LastMove())
|
||||
Next
|
||||
EgtDraw()
|
||||
End Sub
|
||||
@@ -2888,7 +2944,7 @@ Public Class Aletta
|
||||
|
||||
End Class
|
||||
|
||||
Public Structure Trasformation
|
||||
Public Structure Transformation
|
||||
Public m_vtDir As Vector3d
|
||||
Public m_ptO As Point3d
|
||||
Public m_dAng As Double
|
||||
@@ -2897,6 +2953,13 @@ Public Structure Trasformation
|
||||
m_ptO = ptO
|
||||
m_dAng = dAng
|
||||
End Sub
|
||||
Public Shared Operator -(trf As Transformation) As Transformation
|
||||
Dim trfNew As New Transformation
|
||||
trfNew.m_dAng = trf.m_dAng
|
||||
trfNew.m_vtDir = trf.m_vtDir * -1
|
||||
trfNew.m_ptO = trf.m_ptO
|
||||
Return trfNew
|
||||
End Operator
|
||||
End Structure
|
||||
|
||||
Public Class PartSolid
|
||||
@@ -2948,6 +3011,17 @@ Public Class PartSolid
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_bbSolid As New BBox3d
|
||||
Public Property bbSolid As BBox3d
|
||||
Get
|
||||
EgtGetBBoxGlob(m_SolidId, 0, m_bbSolid)
|
||||
Return m_bbSolid
|
||||
End Get
|
||||
Set(value As BBox3d)
|
||||
m_bbSolid = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_nIdLineAxisRotate As Integer = -1
|
||||
Public Property nIdLineAxisRotate As Integer
|
||||
Get
|
||||
@@ -2978,19 +3052,19 @@ Public Class PartSolid
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_vPair As New ObservableCollection(Of Integer)
|
||||
Public ReadOnly Property vPair As ObservableCollection(Of Integer)
|
||||
Private m_vPair As New ObservableCollection(Of PartSolid)
|
||||
Public ReadOnly Property vPair As ObservableCollection(Of PartSolid)
|
||||
Get
|
||||
Return m_vPair
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Sub AddPair(nId As Integer)
|
||||
m_vPair.Add(nId)
|
||||
Public Sub AddPair(part As PartSolid)
|
||||
m_vPair.Add(part)
|
||||
End Sub
|
||||
|
||||
Public Sub RemovePair(nId As Integer)
|
||||
m_vPair.Remove(nId)
|
||||
Public Sub RemovePair(part As PartSolid)
|
||||
m_vPair.Remove(part)
|
||||
End Sub
|
||||
|
||||
Public Sub ResetPair()
|
||||
@@ -3057,74 +3131,76 @@ Public Class PartSolid
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_vtLastMove As New Vector3d
|
||||
Public Property vtLastMove As Vector3d
|
||||
Get
|
||||
Return m_vtLastMove
|
||||
End Get
|
||||
Set(value As Vector3d)
|
||||
m_vtLastMove = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_dLastAng As Double = 0
|
||||
Public Property dLastAng As Double
|
||||
Get
|
||||
Return m_dLastAng
|
||||
End Get
|
||||
Set(value As Double)
|
||||
m_dLastAng = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_vtLastRot As New Vector3d
|
||||
Public Property vtLastRot As Vector3d
|
||||
Get
|
||||
Return m_vtLastRot
|
||||
End Get
|
||||
Set(value As Vector3d)
|
||||
m_vtLastRot = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_ptLastRot As New Point3d
|
||||
Public Property ptLastRot As Point3d
|
||||
Get
|
||||
Return m_ptLastRot
|
||||
End Get
|
||||
Set(value As Point3d)
|
||||
m_ptLastRot = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
'Private m_nTime As Integer = 0
|
||||
'Public ReadOnly Property nTime As Integer
|
||||
'Private m_vtLastMove As New Vector3d
|
||||
'Public Property vtLastMove As Vector3d
|
||||
' Get
|
||||
' Return m_nTime
|
||||
' Return m_vtLastMove
|
||||
' End Get
|
||||
' Set(value As Vector3d)
|
||||
' m_vtLastMove = value
|
||||
' End Set
|
||||
'End Property
|
||||
|
||||
'Private m_vTrasfs As New ObservableCollection(Of Trasformation)
|
||||
'Public ReadOnly Property vTrasfs As ObservableCollection(Of Trasformation)
|
||||
'Private m_dLastAng As Double = 0
|
||||
'Public Property dLastAng As Double
|
||||
' Get
|
||||
' Return m_vTrasfs
|
||||
' Return m_dLastAng
|
||||
' End Get
|
||||
' Set(value As Double)
|
||||
' m_dLastAng = value
|
||||
' End Set
|
||||
'End Property
|
||||
'Public Sub AddTrasf(trf As Trasformation)
|
||||
' If m_vTrasfs.Count() < 10 Then
|
||||
' m_vTrasfs.Add(trf)
|
||||
' Else
|
||||
' m_vTrasfs.RemoveAt(0)
|
||||
' For i As Integer = 1 To 9
|
||||
' m_vTrasfs.Move(i, i - 1)
|
||||
' Next
|
||||
' m_vTrasfs.Add(trf)
|
||||
' End If
|
||||
'End Sub
|
||||
|
||||
'Public Sub ResetTrasf()
|
||||
' m_vTrasfs.Clear()
|
||||
'End Sub
|
||||
'Private m_vtLastRot As New Vector3d
|
||||
'Public Property vtLastRot As Vector3d
|
||||
' Get
|
||||
' Return m_vtLastRot
|
||||
' End Get
|
||||
' Set(value As Vector3d)
|
||||
' m_vtLastRot = value
|
||||
' End Set
|
||||
'End Property
|
||||
|
||||
'Private m_ptLastRot As New Point3d
|
||||
'Public Property ptLastRot As Point3d
|
||||
' Get
|
||||
' Return m_ptLastRot
|
||||
' End Get
|
||||
' Set(value As Point3d)
|
||||
' m_ptLastRot = value
|
||||
' End Set
|
||||
'End Property
|
||||
|
||||
Private m_nTime As Integer = -1
|
||||
Public ReadOnly Property nTime As Integer
|
||||
Get
|
||||
Return m_nTime
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private m_vTrasf As New ObservableCollection(Of Transformation)
|
||||
Public ReadOnly Property vTrasf As ObservableCollection(Of Transformation)
|
||||
Get
|
||||
Return m_vTrasf
|
||||
End Get
|
||||
End Property
|
||||
Public Sub AddTrasf(trf As Transformation)
|
||||
If m_vTrasf.Count() < 10 Then
|
||||
m_vTrasf.Add(trf)
|
||||
Else
|
||||
m_vTrasf.RemoveAt(0)
|
||||
'For i As Integer = 1 To 9
|
||||
' m_vTrasf.Move(i, i - 1)
|
||||
'Next
|
||||
m_vTrasf.Add(trf)
|
||||
End If
|
||||
If m_nTime < 9 Then m_nTime += 1
|
||||
End Sub
|
||||
|
||||
Public Sub ResetTrasf()
|
||||
m_vTrasf.Clear()
|
||||
m_nTime = -1
|
||||
End Sub
|
||||
|
||||
#End Region ' properties
|
||||
|
||||
@@ -3195,7 +3271,17 @@ Public Class PartSolid
|
||||
EgtResetMark(m_nIdLineSecond)
|
||||
End Sub
|
||||
|
||||
Public Sub Move(vtMove As Vector3d, Optional bPart As Boolean = False)
|
||||
Public Sub FindPaired(lPaired As List(Of Integer))
|
||||
For Each PartSolidPair As PartSolid In m_vPair
|
||||
Dim nVal As Integer = lPaired.FirstOrDefault(Function(x) x = PartSolidPair.PartId)
|
||||
If lPaired.FirstOrDefault(Function(x) x = PartSolidPair.PartId) <> PartSolidPair.PartId Then
|
||||
lPaired.Add(PartSolidPair.PartId)
|
||||
PartSolidPair.FindPaired(lPaired)
|
||||
End If
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Public Sub Move(vtMove As Vector3d, Optional bPart As Boolean = False, Optional bSaveHist As Boolean = True)
|
||||
' per quando metto l'annulla del PairParts
|
||||
'If bPart Then
|
||||
' EgtMove(m_PartId, vtMove)
|
||||
@@ -3205,18 +3291,34 @@ Public Class PartSolid
|
||||
' ' salvo la traslazione
|
||||
' m_vtLastMove = vtMove
|
||||
'End If
|
||||
EgtMove(m_PartId, vtMove)
|
||||
EgtMove(m_PartSolidId, vtMove)
|
||||
|
||||
'EgtMove(m_PartId, vtMove)
|
||||
'EgtMove(m_PartSolidId, vtMove)
|
||||
|
||||
' sposto la terna
|
||||
EgtMove(m_TernaId, vtMove)
|
||||
' sposto anche tutti i paired
|
||||
Dim lPaired As New List(Of Integer)
|
||||
lPaired.Add(PartId)
|
||||
FindPaired(lPaired)
|
||||
For Each nPartId As Integer In lPaired
|
||||
EgtMove(nPartId, vtMove)
|
||||
Dim nPartSolidId As Integer = 0
|
||||
EgtGetInfo(nPartId, "Child", nPartSolidId)
|
||||
EgtMove(nPartSolidId, vtMove)
|
||||
Next
|
||||
' salvo la traslazione
|
||||
m_vtLastMove = vtMove
|
||||
Dim trf As New Transformation
|
||||
trf.m_vtDir = vtMove
|
||||
If bSaveHist Then AddTrasf(trf)
|
||||
'm_vtLastMove = vtMove
|
||||
End Sub
|
||||
|
||||
Public Sub ConfirmMove()
|
||||
EgtMove(m_PartId, m_vtLastMove)
|
||||
EgtMove(m_PartId, LastMove().m_vtDir)
|
||||
End Sub
|
||||
|
||||
Public Sub Rotate(ptAx As Point3d, vtAx As Vector3d, dAng As Double, Optional bPart As Boolean = False)
|
||||
Public Sub Rotate(ptAx As Point3d, vtAx As Vector3d, dAng As Double, Optional bPart As Boolean = False, Optional bSaveHist As Boolean = True)
|
||||
' per quando metto l'annulla del PairParts
|
||||
'If bPart Then
|
||||
' EgtRotate(m_PartId, ptAx, vtAx, dAng)
|
||||
@@ -3231,20 +3333,35 @@ Public Class PartSolid
|
||||
' Dim vtMove As Vector3d = Center() - ptOrig
|
||||
' EgtMove(m_TernaId, vtMove)
|
||||
'End If
|
||||
EgtRotate(m_PartId, ptAx, vtAx, dAng)
|
||||
Dim ptOrig As Point3d = Center()
|
||||
EgtRotate(m_PartSolidId, ptAx, vtAx, dAng)
|
||||
|
||||
'EgtRotate(m_PartId, ptAx, vtAx, dAng)
|
||||
'EgtRotate(m_PartSolidId, ptAx, vtAx, dAng)
|
||||
|
||||
'ruoto tutti i paired insieme
|
||||
Dim lPaired As New List(Of Integer)
|
||||
lPaired.Add(PartId)
|
||||
FindPaired(lPaired)
|
||||
For Each nPartId As Integer In lPaired
|
||||
EgtRotate(nPartId, ptAx, vtAx, dAng)
|
||||
Dim nPartSolidId As Integer = 0
|
||||
EgtGetInfo(nPartId, "Child", nPartSolidId)
|
||||
EgtRotate(nPartSolidId, ptAx, vtAx, dAng)
|
||||
Next
|
||||
' salvo la rotazione
|
||||
m_vtLastRot = vtAx
|
||||
m_ptLastRot = ptAx
|
||||
m_dLastAng = dAng
|
||||
Dim trf As New Transformation
|
||||
trf.m_vtDir = vtAx
|
||||
trf.m_ptO = ptAx
|
||||
trf.m_dAng = dAng
|
||||
If bSaveHist Then AddTrasf(trf)
|
||||
' sposto anche la terna
|
||||
Dim ptOrig As Point3d = Center()
|
||||
Dim vtMove As Vector3d = Center() - ptOrig
|
||||
EgtMove(m_TernaId, vtMove)
|
||||
End Sub
|
||||
|
||||
Public Sub ConfirmRotate()
|
||||
EgtRotate(m_PartSolidId, m_ptLastRot, m_vtLastRot, m_dLastAng)
|
||||
Dim trf As Transformation = LastRotation()
|
||||
EgtRotate(m_PartSolidId, trf.m_ptO, trf.m_vtDir, trf.m_dAng)
|
||||
End Sub
|
||||
|
||||
Public Sub ConfirmPair()
|
||||
@@ -3271,6 +3388,7 @@ Public Class PartSolid
|
||||
m_nIdSurfSecond = -1
|
||||
End Sub
|
||||
Public Sub PairParts()
|
||||
If m_nIdLineSecond = GDB_ID.NULL Then Return
|
||||
' recupero l'id del part da accoppiare al corrente
|
||||
Dim nIdToPair As Integer = EgtGetParent(EgtGetParent(m_nIdLineSecond))
|
||||
Dim sName As String = String.Empty
|
||||
@@ -3285,7 +3403,23 @@ Public Class PartSolid
|
||||
Dim vAlreadyPaired As Array = sPaired.Split(CChar(","))
|
||||
Dim nIndex As Integer = Array.IndexOf(vAlreadyPaired, sToPair)
|
||||
If nIndex = -1 Then
|
||||
EgtSetInfo(PartId, "Paired", sPaired & "," & sToPair)
|
||||
If sPaired = String.Empty Then
|
||||
EgtSetInfo(PartId, "Paired", sToPair)
|
||||
Else
|
||||
EgtSetInfo(PartId, "Paired", sPaired & "," & sToPair)
|
||||
End If
|
||||
End If
|
||||
' accoppio il corrente al pair
|
||||
sToPair = CStr(PartId)
|
||||
EgtGetInfo(nIdToPair, "Paired", sPaired)
|
||||
vAlreadyPaired = sPaired.Split(CChar(","))
|
||||
nIndex = Array.IndexOf(vAlreadyPaired, sToPair)
|
||||
If nIndex = -1 Then
|
||||
If sPaired = String.Empty Then
|
||||
EgtSetInfo(nIdToPair, "Paired", sToPair)
|
||||
Else
|
||||
EgtSetInfo(nIdToPair, "Paired", sPaired & "," & sToPair)
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
@@ -3295,41 +3429,43 @@ Public Class PartSolid
|
||||
If sPair = "" Then Return
|
||||
' disaccoppio il corrente da tutti gli altri part
|
||||
EgtSetCurrentContext(m_nVeinCtx)
|
||||
Dim IdFP As Integer = EgtGetFirstPart()
|
||||
'' scorro tutti i part e tolgo l'id corrente dalle loro info Paired
|
||||
While IdFP <> GDB_ID.NULL
|
||||
If IdFP = m_PartId Then
|
||||
IdFP = EgtGetNextPart(IdFP)
|
||||
Continue While
|
||||
End If
|
||||
Dim sName As String = String.Empty
|
||||
EgtGetName(IdFP, sName)
|
||||
If sName = "SOLID" Then
|
||||
IdFP = EgtGetNextPart(IdFP)
|
||||
Continue While
|
||||
End If
|
||||
Dim sPaired As String = String.Empty
|
||||
EgtGetInfo(PartId, "Paired", sPaired)
|
||||
Dim vPaired As Array = sPaired.Split(CChar(","))
|
||||
Dim sIdToUnpair As String = CStr(m_PartId)
|
||||
Dim nIndex As Integer = Array.IndexOf(vPaired, sIdToUnpair)
|
||||
' ricostruisco l'informazione paired senza l'Id che ho disaccoppiato
|
||||
If nIndex <> -1 Then
|
||||
Dim sNewPaired As String = String.Empty
|
||||
For Each sIdPaired As String In vPaired
|
||||
If String.Compare(sIdPaired, sIdToUnpair, True) = 0 Then Continue For
|
||||
If sNewPaired <> String.Empty Then
|
||||
sNewPaired = sNewPaired & "," & sIdPaired
|
||||
Else
|
||||
sNewPaired = sIdPaired
|
||||
End If
|
||||
Next
|
||||
EgtSetInfo(PartId, "Paired", sNewPaired)
|
||||
End If
|
||||
Dim IdFP As Integer = EgtGetFirstPart()
|
||||
'' scorro tutti i part e tolgo l'id corrente dalle loro info Paired
|
||||
While IdFP <> GDB_ID.NULL
|
||||
If IdFP = m_PartId Then
|
||||
IdFP = EgtGetNextPart(IdFP)
|
||||
End While
|
||||
' resetto l'info Paired del corrente
|
||||
EgtSetInfo(m_PartId, "Paired", "")
|
||||
Continue While
|
||||
End If
|
||||
Dim sName As String = String.Empty
|
||||
EgtGetName(IdFP, sName)
|
||||
If sName = "SOLID" Then
|
||||
IdFP = EgtGetNextPart(IdFP)
|
||||
Continue While
|
||||
End If
|
||||
sPair = String.Empty
|
||||
EgtGetInfo(IdFP, "Paired", sPair)
|
||||
Dim vPaired As Array = sPair.Split(CChar(","))
|
||||
Dim sIdToUnpair As String = CStr(m_PartId)
|
||||
Dim nIndex As Integer = Array.IndexOf(vPaired, sIdToUnpair)
|
||||
' ricostruisco l'informazione paired senza l'Id che ho disaccoppiato
|
||||
If nIndex <> -1 Then
|
||||
Dim sNewPaired As String = String.Empty
|
||||
For Each sIdPaired As String In vPaired
|
||||
If String.Compare(sIdPaired, sIdToUnpair, True) = 0 Then Continue For
|
||||
If sNewPaired <> String.Empty Then
|
||||
sNewPaired = sNewPaired & "," & sIdPaired
|
||||
Else
|
||||
sNewPaired = sIdPaired
|
||||
End If
|
||||
Next
|
||||
EgtSetInfo(PartId, "Paired", sNewPaired)
|
||||
End If
|
||||
IdFP = EgtGetNextPart(IdFP)
|
||||
End While
|
||||
' resetto l'info Paired del corrente
|
||||
EgtSetInfo(m_PartId, "Paired", "")
|
||||
' resetto la lista
|
||||
ResetPair()
|
||||
End Sub
|
||||
|
||||
Public Function GetLineInfo(nInfo As Integer) As String
|
||||
@@ -3349,7 +3485,7 @@ Public Class PartSolid
|
||||
sAnswer = ptStart.ToString
|
||||
Case 3
|
||||
Dim ptEnd As New Point3d
|
||||
EgtStartPoint(m_nIdLineFirst, ptEnd)
|
||||
EgtEndPoint(m_nIdLineFirst, ptEnd)
|
||||
sAnswer = ptEnd.ToString
|
||||
End Select
|
||||
Return sAnswer
|
||||
@@ -3362,5 +3498,55 @@ Public Class PartSolid
|
||||
Public Sub MakeOpaque()
|
||||
EgtSetAlpha(SolidId, 100)
|
||||
End Sub
|
||||
|
||||
Public Function UndoTrasf() As Boolean
|
||||
If m_nTime = -1 Then Return False
|
||||
Dim trf As Transformation = m_vTrasf(m_nTime)
|
||||
ApplyTrasf(-trf, False)
|
||||
m_nTime -= 1
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Public Function RedoTrasf() As Boolean
|
||||
If m_nTime = 9 Then Return False
|
||||
If m_nTime + 1 > m_vTrasf.Count() Then Return False
|
||||
Dim trf As Transformation = m_vTrasf(m_nTime)
|
||||
ApplyTrasf(trf, False)
|
||||
If m_nTime < 9 Then m_nTime += 1
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Public Sub RemoveLastTrasf()
|
||||
If Not UndoTrasf() Then Return
|
||||
If m_nTime + 1 = m_vTrasf.Count() - 1 Then m_vTrasf.RemoveAt(m_nTime + 1)
|
||||
End Sub
|
||||
|
||||
Public Sub ApplyTrasf(trf As Transformation, Optional bSaveHist As Boolean = True)
|
||||
If trf.m_dAng = 0 Then
|
||||
Move(trf.m_vtDir, False, bSaveHist)
|
||||
Else
|
||||
Rotate(trf.m_ptO, trf.m_vtDir, trf.m_dAng, False, bSaveHist)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Function LastMove() As Transformation
|
||||
Dim trf As Transformation = m_vTrasf(nTime)
|
||||
Dim nTimeTemp As Integer = nTime
|
||||
While trf.m_dAng <> 0 And nTimeTemp > 0
|
||||
nTimeTemp -= 1
|
||||
trf = m_vTrasf(nTimeTemp)
|
||||
End While
|
||||
Return trf
|
||||
End Function
|
||||
|
||||
Public Function LastRotation() As Transformation
|
||||
Dim trf As Transformation = m_vTrasf(nTime)
|
||||
Dim nTimeTemp As Integer = nTime
|
||||
While trf.m_dAng = 0 And nTimeTemp > 0
|
||||
nTimeTemp -= 1
|
||||
trf = m_vTrasf(nTimeTemp)
|
||||
End While
|
||||
Return trf
|
||||
End Function
|
||||
#End Region ' metodi
|
||||
End Class
|
||||
Reference in New Issue
Block a user