From 4eac19a2ff40d52b5aa110fe19f79e456ec9a604 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Fri, 13 Mar 2026 13:39:21 +0100 Subject: [PATCH] EgtCAM5 : - piccole modifiche ad analisi superfici di Bezier. --- Project/ProjectVM.vb | 34 +++++++++-------- Utility/Analyze.vb | 87 +++++++++++++++++++++++++------------------- 2 files changed, 67 insertions(+), 54 deletions(-) diff --git a/Project/ProjectVM.vb b/Project/ProjectVM.vb index 3c18299..b4a9e31 100644 --- a/Project/ProjectVM.vb +++ b/Project/ProjectVM.vb @@ -1449,7 +1449,7 @@ Public Class ProjectVM m_Controller.MouseMoveInSelectionPoint(PtP) End Sub - Private Sub OnMouseAnalyzedEx(sender As Object, nId As Integer, nSub As Integer, ptSel As Point3d) Handles m_ProjectScene.OnMouseAnalyzedEx + Private Sub OnMouseAnalyzedEx(sender As Object, nId As Integer, nSub As Integer, ptSel As Point3d, nModKey As Integer) Handles m_ProjectScene.OnMouseAnalyzedEx Map.refManageLayerExpanderVM.UpdateObjInObjTree(nId) Map.refManageLayerExpanderVM.SelectIdInObjTree(nId) ' Cancello geometria e info di eventuale precedente analisi @@ -1460,19 +1460,17 @@ Public Class ProjectVM ' Visualizzo numerazione Analyze.CreateAnalyzeGroup() Analyze.CreateCurveCompoPntNbrs(nId) - ' Se superficie trimesh, visualizzo dati faccetta toccata + ' Se superficie trimesh, visualizzo dati faccetta toccata ElseIf EgtGetType(nId) = GDB_TY.SRF_MESH Then Dim nFac As Integer = EgtSurfTmFacetFromTria(nId, nSub) - If nFac <> -1 Then + If nFac >= 0 Then ' Visualizzo la normale e il contorno della faccia Analyze.CreateAnalyzeGroup() Analyze.CreateFacetNormal(nId, nFac) Analyze.CreateFacetLoops(nId, nFac) - - If (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift Then + If nModKey = Scene.MODKEY.SHIFT Then Analyze.CreateTriaLoop(nId, nSub) End If - ' Recupero i dati (in globale o griglia a seconda della impostazione) Dim ptC As Point3d Dim vtN As Vector3d @@ -1484,13 +1482,12 @@ Public Class ProjectVM " : C(" + LenToString(ptC.x, 3) + "," + LenToString(ptC.y, 3) + "," + LenToString(ptC.z, 3) + ")" + " N(" + DoubleToString(vtN.x, 4) + "," + DoubleToString(vtN.y, 4) + "," + DoubleToString(vtN.z, 4) + ")" + " / φ=" + DoubleToString(dPhi, 2) + " θ=" + DoubleToString(dTheta, 2) - - If (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift Then + If nModKey = Scene.MODKEY.SHIFT Then sOut &= ", Triangle " + nSub.ToString() End If Map.refStatusBarVM.NotifyStatusOutput(sOut) End If - ' Se Regione, visualizzo dati parte toccata + ' Se Regione, visualizzo dati parte toccata ElseIf EgtGetType(nId) = GDB_TY.SRF_FRGN Then Dim nChk As Integer = nSub If nChk >= 0 AndAlso nChk < EgtSurfFrChunkCount(nId) Then @@ -1511,20 +1508,25 @@ Public Class ProjectVM " / φ=" + DoubleToString(dPhi, 2) + " θ=" + DoubleToString(dTheta, 2) Map.refStatusBarVM.NotifyStatusOutput(sOut) End If + ' Se Superficie di Bezier ElseIf EgtGetType(nId) = GDB_TY.SRF_BEZ Then ' Visualizzo il punto selezionato, la normale e le tangenti nelle direzioni dei parametri Analyze.CreateAnalyzeGroup() - Dim dU As Double - Dim dV As Double - If Analyze.CreateSBzPointNormalAndTangents(nId, ptSel, dU, dV) Then - Dim sOut As String = "U = " + dU.ToString("F3") + - "; V = " + dV.ToString("F3") + Dim dU, dV As Double + Dim vtN As Vector3d + If Analyze.CreateSBzPointNormalAndTangents(nId, ptSel, dU, dV, vtN) Then + Dim dLen, dPhi, dTheta As Double + vtN.ToSpherical(dLen, dTheta, dPhi) + ' Emetto info sulla barra di stato + Dim sOut As String = "U=" + DoubleToString( dU, 4) + ",V=" + DoubleToString( dV, 4) + + " : P(" + LenToString(ptSel.x, 3) + "," + LenToString(ptSel.y, 3) + "," + LenToString(ptSel.z, 3) + ")" + + " N(" + DoubleToString(vtN.x, 4) + "," + DoubleToString(vtN.y, 4) + "," + DoubleToString(vtN.z, 4) + ")" + + " / φ=" + DoubleToString(dPhi, 2) + " θ=" + DoubleToString(dTheta, 2) Map.refStatusBarVM.NotifyStatusOutput(sOut) - If (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift Then + If nModKey = Scene.MODKEY.SHIFT Then Analyze.CreateSBzIsoParam(nId, dU, dV) End If End If - End If ' Aggiorno la visualizzazione EgtDraw() diff --git a/Utility/Analyze.vb b/Utility/Analyze.vb index faaa393..e1d962d 100644 --- a/Utility/Analyze.vb +++ b/Utility/Analyze.vb @@ -1,4 +1,5 @@ -Imports EgtUILib +Imports System.Data +Imports EgtUILib Module Analyze @@ -76,20 +77,6 @@ Module Analyze Return True End Function - Function CreateTriaNormal( nId As Integer, nT As Integer) As Boolean - 'If m_AnaGrpId = GDB_ID.NULL Then Return False - 'Dim bEnMod As Boolean = EgtGetEnableModified() - 'EgtDisableModified() - 'Dim ptC As Point3d - 'Dim vtN As Vector3d - 'If EgtSurfTmTriangleNormVersor( nId, nT, GDB_ID.ROOT, ptC, vtN) Then - ' Dim nNormId As Integer = EgtCreateGeoVector( m_AnaGrpId, 50 * vtN, ptC, GDB_RT.GLOB) - ' EgtSetColor( nNormId, New Color3d( 255, 0,0)) - 'End If - 'If bEnMod Then EgtEnableModified() - Return True - End Function - Function CreateChunkNormal( nId As Integer, nChk As Integer) As Boolean If m_AnaGrpId = GDB_ID.NULL Then Return False Dim bEnMod As Boolean = EgtGetEnableModified() @@ -123,26 +110,26 @@ Module Analyze If m_AnaGrpId = GDB_ID.NULL Then Return False Dim bEnMod As Boolean = EgtGetEnableModified() EgtDisableModified() - 'Riferimento della griglia corrente + ' Salvo riferimento della griglia corrente Dim refGrid As Frame3d = EgtGetGridFrame() - 'Nuovo riferimento griglia con Z come versore estrusione della curva + ' Nuovo riferimento griglia con Z come versore estrusione della curva Dim vtExtr As Vector3d : EgtCurveExtrusion( nId, vtExtr) If Not vtExtr.IsSmall() Then Dim refCrv As New Frame3d : refCrv.Setup( EgtGetGridOrigin(), vtExtr) EgtSetGridFrame( refCrv) End If - 'Recupero il numero di curve semplici + ' Recupero il numero di curve semplici Dim dStart, dEnd As Double EgtCurveDomain( nId, dStart, dEnd) Dim nCount As Integer = CInt( dEnd - dStart) - 1 ' Ciclo sulle curve semplici For i As Integer = 0 To nCount - 'Scrivo il punto iniziale di ogni curva componente + ' Scrivo il punto iniziale di ogni curva componente Dim ptS As Point3d EgtAtParamPoint( nId, i, GDB_ID.GRID, ptS) Dim nPntId As Integer = EgtCreateGeoPoint( m_AnaGrpId, ptS, GDB_RT.GRID) EgtSetColor( nPntId, New Color3d( 255, 0,0)) - 'Scrivo il numero identificativo di ogni curva componente + ' Scrivo il numero identificativo di ogni curva componente Dim ptP As Point3d EgtAtParamPoint( nId, i + 0.5, GDB_ID.GRID, ptP) Dim dLen As Double = 2 * Point3d.Dist( ptS, ptP) @@ -150,27 +137,52 @@ Module Analyze Dim nTxtId As Integer = EgtCreateTextAdv( m_AnaGrpId, ptP, 0, i.ToString(), "", 100, False, dH, 1, 0, INS_POS.MC, GDB_RT.GRID) EgtSetColor( nTxtId, New Color3d( 255, 0,0)) Next - 'Se curva aperta aggiungo il punto finale + ' Se curva aperta aggiungo il punto finale If Not EgtCurveIsClosed( nId) Then Dim ptE As Point3d EgtEndPoint( nId, GDB_ID.GRID, ptE) Dim nPntId As Integer = EgtCreateGeoPoint( m_AnaGrpId, ptE, GDB_RT.GRID) EgtSetColor( nPntId, New Color3d( 255, 0,0)) End If - 'Reimposto il riferimento originale alla griglia + ' Reimposto il riferimento originale alla griglia EgtSetGridFrame( refGrid) If bEnMod Then EgtEnableModified() Return True End Function - Function CreateSBzPointNormalAndTangents( nId As Integer, ptBez As Point3d, ByRef dU As Double, ByRef dV As Double) As Boolean - If m_AnaGrpId = GDB_ID.NULL Then Return False - Dim bEnMod As Boolean = EgtGetEnableModified() - EgtDisableModified() - - Dim bOk As Boolean = EgtSurfBezParamsFromPoint( nId, ptBez, m_AnaGrpId, dU, dV) - - If bEnMod Then EgtEnableModified() + Function CreateSBzPointNormalAndTangents( nId As Integer, ptBez As Point3d, ByRef dU As Double, ByRef dV As Double, ByRef vtN As Vector3d) As Boolean + Dim ptP As Point3d + Dim vtDirU, vtDirV As Vector3d + Dim bOk As Boolean = EgtSurfBezierParamsFromPoint( nId, ptBez, GDB_ID.ROOT, dU, dV) AndAlso + EgtSurfBezierGetPointNrmD1( nId, dU, dV, SRF_SIDE.FROM_MINUS, SRF_SIDE.FROM_MINUS, GDB_ID.ROOT, + ptP, vtN, vtDirU, vtDirV) + If bOk AndAlso m_AnaGrpId <> GDB_ID.NULL Then + Dim bEnMod As Boolean = EgtGetEnableModified() + EgtDisableModified() + ' Disegno Punto + Dim nPntId As Integer = EgtCreateGeoPoint( m_AnaGrpId, ptBez, GDB_RT.GLOB) + EgtSetColor( nPntId, New Color3d( 255, 0, 0)) + EgtSetStatus( nPntId, GDB_ST.SEL) + ' Disegno Vettore Normale + Dim nNormId As Integer = EgtCreateGeoVector( m_AnaGrpId, 50 * vtN, ptBez, GDB_RT.GLOB) + EgtSetColor( nNormId, New Color3d( 255, 0, 0)) + EgtSetStatus( nNormId, GDB_ST.SEL) + ' Disegno tangente in U + Dim dModU As Double = vtDirU.Len() + If dModU > EPS_ZERO Then + Dim nTgUId As Integer = EgtCreateGeoVector( m_AnaGrpId, 25 / dModU * vtDirU, ptBez, GDB_RT.GLOB) + EgtSetColor( nTgUId, New Color3d( 0, 128, 192)) + EgtSetStatus( nTgUId, GDB_ST.SEL) + End If + ' Disegno tangente in V + Dim dModV As Double = vtDirV.Len() + If dModV > EPS_ZERO Then + Dim nTgVId As Integer = EgtCreateGeoVector( m_AnaGrpId, 25 / dModV * vtDirV, ptBez, GDB_RT.GLOB) + EgtSetColor( nTgVId, New Color3d( 255, 128, 0)) + EgtSetStatus( nTgVId, GDB_ST.SEL) + End If + If bEnMod Then EgtEnableModified() + End If Return bOk End Function @@ -178,15 +190,14 @@ Module Analyze If m_AnaGrpId = GDB_ID.NULL Then Return False Dim bEnMod As Boolean = EgtGetEnableModified() EgtDisableModified() - Dim nIdCrv As Integer = EgtSurfBezierGetCurveU( nId, dV, m_AnaGrpId) - EgtSetColor( nIdCrv, New Color3d(128,128,255)) - Dim bOk As Boolean = nIdCrv <> GDB_ID.NULL - nIdCrv = EgtSurfBezierGetCurveV( nId, dU, m_AnaGrpId) - bOk = bOk And nIdCrv <> GDB_ID.NULL - EgtSetColor( nIdCrv, New Color3d(255,128,128)) - + Dim nCrvUId As Integer = EgtSurfBezierGetCurveU( nId, dV, m_AnaGrpId) + EgtSetColor( nCrvUId, New Color3d( 0, 128, 192)) + EgtSetStatus( nCrvUId, GDB_ST.SEL) + Dim nCrvVId As Integer = EgtSurfBezierGetCurveV( nId, dU, m_AnaGrpId) + EgtSetColor( nCrvVId, New Color3d( 255, 128, 0)) + EgtSetStatus( nCrvVId, GDB_ST.SEL) If bEnMod Then EgtEnableModified() - Return bOk + Return ( nCrvUId <> GDB_ID.NULL And nCrvVId <> GDB_ID.NULL) End Function End Module